text
stringlengths
1
1.05M
class Solution { public: vector<vector<int>> permuteUnique(vector<int>& nums) { vector<vector<int>> ret; sort(nums.begin(), nums.end()); do { vector<int> vec; for (const auto i : nums) vec.push_back(i); ret.push_back(vec); } while (next_permutation(nums.begin(), nums.end())); return ret; } };
<%docstring>A single-byte RET instruction.</%docstring> ret
; set of CEmu software debug command ; macro dbg command,func,data if CONFIG_DEBUG match =cmd?, command push af push hl scf sbc hl, hl ld (hl), a pop hl pop af else match =thread?, command push iy ld iy, DEBUG_THREAD call kthread.create pop iy else match =open?, command push af push hl scf sbc hl, hl ld (hl), 2 pop hl pop af else match =set?, command push de ld de, data push af push hl scf sbc hl, hl match =break?, func ld (hl), 3 else match =watch ld (hl), 11 end match pop hl pop af pop de else match =rm?, command push de ld de, data push af push hl scf sbc hl, hl match =break?, func ld (hl), 4 else match =watch?, func ld (hl), 8 end match pop hl pop af pop de else err 'dbg : invalid argument' end match end if end macro macro dbg_rm_all_break push hl scf sbc hl, hl ld (hl), 9 pop hl end macro macro dbg_rm_all_watch push hl scf sbc hl, hl ld (hl), 10 pop hl end macro if CONFIG_DEBUG DEBUG_THREAD: dbg open ; ; hl is path, bc is flags, de is mode ld hl, DEBUG_PATH_2 ld bc, KERNEL_VFS_O_RW or (KERNEL_VFS_O_CREAT *256) call _open push hl ld de, $D01000 ld bc, 32768 call _write pop hl push hl ; fd is hl, de is offset, bc is whence ld de, 0 ld bc, SEEK_SET call _lseek pop hl ld de, $D60000 ld bc, 32768 call _read ret DEBUG_PATH: db "/tifs/SORCERY",0 DEBUG_PATH_2: db "/file", 0 DEBUG_PATH_LINK: db "/tifs/", 0 DEBUG_PATH_LINK2: db "/bin/", 0 end if
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; The MIT License ; ; Copyright (c) 2014 Intel Corporation ; ; Permission is hereby granted, free of charge, to any person ; obtaining a copy of this software and associated documentation ; files (the "Software"), to deal in the Software without ; restriction, including without limitation the rights to use, ; copy, modify, merge, publish, distribute, 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. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %ifndef __HUFFMAN_ASM__ %define __HUFFMAN_ASM__ %include "options.asm" %include "lz0a_const.asm" ; Macros for doing Huffman Encoding %ifdef LONGER_HUFFTABLE %if (D > 8192) %error History D is larger than 8K, cannot use %LONGER_HUFFTABLE % error %else %define DIST_TABLE_SIZE 8192 %define DECODE_OFFSET 26 %endif %else %define DIST_TABLE_SIZE 1024 %define DECODE_OFFSET 20 %endif ;extern const struct HuffTables { ; ; // bits 7:0 are the length ; // bits 31:8 are the code ; UINT32 dist_table[DIST_TABLE_SIZE]; ; ; // bits 7:0 are the length ; // bits 31:8 are the code ; UINT32 len_table[256]; ; ; // bits 3:0 are the length ; // bits 15:4 are the code ; UINT16 lit_table[257]; ; ; // bits 3:0 are the length ; // bits 15:4 are the code ; UINT16 dcodes[30 - DECODE_OFFSET]; ; ;} huff_tables; extern huff_tables extern dist_table extern len_table extern lit_table %ifndef LONGER_HUFFTABLE extern dcodes %endif %ifdef LONGER_HUFFTABLE ; Uses RCX, clobbers dist ; get_dist_code dist, code, len %macro get_dist_code 3 %define %%dist %1d ; 32-bit IN, clobbered %define %%distq %1 ; 64-bit IN %define %%code %2d ; 32-bit OUT %define %%len %3d ; 32-bit OUT %define %%lenq %3 ; 64-bit TMP ; mov %%len, [dist_table - 4 + 4*%%dist] lea %%lenq, [rel dist_table - 4] mov %%len, [%%lenq + 4*%%distq] mov %%code, %%len and %%len, 0xFF; shr %%code, 8 %endm %else ; Assumes (dist != 0) ; Uses RCX, clobbers dist ; void compute_dist_code dist, code, len %macro compute_dist_code 3 %define %%dist %1 ; IN, clobbered %define %%code %2 ; OUT %define %%len %3 ; OUT dec %%dist bsr ecx, %%dist ; ecx = msb = bsr(dist) dec ecx ; ecx = num_extra_bits = msb - N mov %%code, 1 shl %%code, CL dec %%code ; code = ((1 << num_extra_bits) - 1) and %%code, %%dist ; code = extra_bits shr %%dist, CL ; dist >>= num_extra_bits lea %%dist, [%%dist + 2*ecx] ; dist = sym = dist + num_extra_bits*2 movzx %%dist, word [dcodes + 2 * (%%dist - DECODE_OFFSET)] mov %%len, ecx ; len = num_extra_bits mov ecx, %%dist ; ecx = sym and ecx, 0xF ; ecx = sym & 0xF shl %%code, CL ; code = extra_bits << (sym & 0xF) shr %%dist, 4 ; dist = (sym >> 4) or %%code, %%dist ; code = (sym >> 4) | (extra_bits << (sym & 0xF)) add %%len, ecx ; len = num_extra_bits + (sym & 0xF) %endm ; Uses RCX, clobbers dist ; get_dist_code dist, code, len %macro get_dist_code 3 %define %%dist %1d ; 32-bit IN, clobbered %define %%code %2d ; 32-bit OUT %define %%len %3d ; 32-bit OUT cmp %%dist, DIST_TABLE_SIZE jg %%do_compute mov %%len, [dist_table - 4 + 4*%%dist] mov %%code, %%len and %%len, 0xFF; shr %%code, 8 jmp %%done %%do_compute: compute_dist_code %%dist, %%code, %%len %%done: %endm %endif ; "len" can be same register as "length" ; get_len_code length, code, len %macro get_len_code 3 %define %%length %1d ; 32-bit IN %define %%lengthq %1 ; 64-bit IN %define %%code %2d ; 32-bit OUT %define %%len %3d ; 32-bit OUT %define %%lenq %3 ; 64-bit TMP ; mov %%len, [len_table - 12 + 4*%%length] lea %%lenq, [rel len_table - 12] mov %%len, [%%lenq + 4*%%lengthq] mov %%code, %%len and %%len, 0xFF; shr %%code, 8 %endm %ifdef WIDER_LIT_TABLES ; Use 4-byte lit tables ; "len" can be same register as "lit" ; get_lit_code lit, code, len %macro get_lit_code 3 %define %%lit %1d ; 32-bit IN %define %%litq %1 ; 64-bit IN %define %%code %2d ; 32-bit OUT %define %%len %3d ; 32-bit OUT %define %%lenq %3 ; 64-bit TMP ; movzx %%len, word [lit_table + 4*%%lit] lea %%lenq, [rel lit_table wrt] mov %%len, dword [%%lenq + 4*%%litq] mov %%code, %%len and %%len, 0xF; shr %%code, 4 %endm %macro get_lit_code_const 3 %define %%lit %1 ; 32-bit IN (constant) %define %%litq %1 ; 64-bit IN %define %%code %2d ; 32-bit OUT %define %%len %3d ; 32-bit OUT %define %%lenq %3 ; 64-bit TMP mov %%len, dword [rel lit_table + 4*%%lit] mov %%code, %%len and %%len, 0xF; shr %%code, 4 %endm %else ; Use 2-byte lit tables ; "len" can be same register as "lit" ; get_lit_code lit, code, len %macro get_lit_code 3 %define %%lit %1d ; 32-bit IN %define %%litq %1 ; 64-bit IN %define %%code %2d ; 32-bit OUT %define %%len %3d ; 32-bit OUT %define %%lenq %3 ; 64-bit TMP ; movzx %%len, word [lit_table + 2*%%lit] lea %%lenq, [rel lit_table] movzx %%len, word [%%lenq + 2*%%litq] mov %%code, %%len and %%len, 0xF; shr %%code, 4 %endm %macro get_lit_code_const 3 %define %%lit %1 ; 32-bit IN (constant) %define %%litq %1 ; 64-bit IN %define %%code %2d ; 32-bit OUT %define %%len %3d ; 32-bit OUT %define %%lenq %3 ; 64-bit TMP ; movzx %%len, word [lit_table + 2*%%lit] lea %%lenq, [rel lit_table] movzx %%len, word [%%lenq + 2*%%litq] mov %%code, %%len and %%len, 0xF; shr %%code, 4 %endm %endif ;; end WIDER_LIT_TABLES / else %endif
; if a hidden object was found, stores $00 in [hDidntFindAnyHiddenObject], else stores $ff CheckForHiddenObject: ld hl, hItemAlreadyFound xor a ld [hli], a ld [hli], a ld [hli], a ld [hl], a ld hl, HiddenObjectMaps ld de, 3 ld a, [wCurMap] call IsInArray jr nc, .noMatch inc hl ld a, [hli] ld h, [hl] ld l, a push hl ld hl, wHiddenObjectFunctionArgument xor a ld [hli], a ld [hli], a ld [hl], a pop hl .hiddenObjectLoop ld a, [hli] cp $ff jr z, .noMatch ld [wHiddenObjectY], a ld b, a ld a, [hli] ld [wHiddenObjectX], a ld c, a call CheckIfCoordsInFrontOfPlayerMatch ld a, [hCoordsInFrontOfPlayerMatch] and a jr z, .foundMatchingObject inc hl inc hl inc hl inc hl push hl ld hl, wHiddenObjectIndex inc [hl] pop hl jr .hiddenObjectLoop .foundMatchingObject ld a, [hli] ld [wHiddenObjectFunctionArgument], a ld a, [hli] ld [wHiddenObjectFunctionRomBank], a ld a, [hli] ld h, [hl] ld l, a ret .noMatch ld a, $ff ld [hDidntFindAnyHiddenObject], a ret ; checks if the coordinates in front of the player's sprite match Y in b and X in c ; [hCoordsInFrontOfPlayerMatch] = $00 if they match, $ff if they don't match CheckIfCoordsInFrontOfPlayerMatch: ld a, [wPlayerFacingDirection] ; player's sprite facing direction cp SPRITE_FACING_UP jr z, .facingUp cp SPRITE_FACING_LEFT jr z, .facingLeft cp SPRITE_FACING_RIGHT jr z, .facingRight ; facing down ld a, [wYCoord] inc a jr .upDownCommon .facingUp ld a, [wYCoord] dec a .upDownCommon cp b jr nz, .didNotMatch ld a, [wXCoord] cp c jr nz, .didNotMatch jr .matched .facingLeft ld a, [wXCoord] dec a jr .leftRightCommon .facingRight ld a, [wXCoord] inc a .leftRightCommon cp c jr nz, .didNotMatch ld a, [wYCoord] cp b jr nz, .didNotMatch .matched xor a jr .done .didNotMatch ld a, $ff .done ld [hCoordsInFrontOfPlayerMatch], a ret INCLUDE "data/hidden_objects.asm"
; A194522: First coordinate of (4,5)-Lagrange pair for n. ; Submitted by Jon Maiga ; -1,-2,2,1,0,-1,3,2,1,0,-1,3,2,1,0,4,3,2,1,0,4,3,2,1,5,4,3,2,1,5,4,3,2,6,5,4,3,2,6,5,4,3,7,6,5,4,3,7,6,5,4,8,7,6,5,4,8,7,6,5,9,8,7,6,5,9,8,7,6,10,9,8,7,6,10,9,8,7,11,10,9,8,7,11,10,9,8,12,11,10,9,8,12,11,10,9 add $0,16 mul $0,2 add $0,1 mov $1,$0 div $1,9 mul $1,10 sub $1,$0 add $1,1 mov $0,$1 div $0,2
INCLUDE "graphics/grafix.inc" MODULE smc777_getmaxx SECTION code_clib PUBLIC getmaxx PUBLIC _getmaxx EXTERN __smc777_mode EXTERN __console_w .getmaxx ._getmaxx ld a,(__smc777_mode) and @00001100 cp @00001000 ; 640 ld hl,639 ret z cp @00000100 ; 320 ld hl,319 ret z ; We must be in lores mode here ld a,(__console_w) add a dec a ld l,a ld h,0 ret
; A053439: Expansion of (1+x+2*x^3)/((1-x)*(1-x^2)^2). ; 1,2,4,8,11,18,22,32,37,50,56,72,79,98,106,128,137,162,172,200,211,242,254,288,301,338,352,392,407,450,466,512,529,578,596,648,667,722,742,800,821,882,904,968,991,1058,1082,1152,1177,1250,1276,1352,1379,1458,1486,1568,1597,1682,1712,1800,1831,1922,1954,2048,2081,2178,2212,2312,2347,2450,2486,2592,2629,2738,2776,2888,2927,3042,3082,3200,3241,3362,3404,3528,3571,3698,3742,3872,3917,4050,4096,4232,4279,4418,4466,4608,4657,4802,4852,5000,5051,5202,5254,5408,5461,5618,5672,5832,5887,6050,6106,6272,6329,6498,6556,6728,6787,6962,7022,7200,7261,7442,7504,7688,7751,7938,8002,8192,8257,8450,8516,8712,8779,8978,9046,9248,9317,9522,9592,9800,9871,10082,10154,10368,10441,10658,10732,10952,11027,11250,11326,11552,11629,11858,11936,12168,12247,12482,12562,12800,12881,13122,13204,13448,13531,13778,13862,14112,14197,14450,14536,14792,14879,15138,15226,15488,15577,15842,15932,16200,16291,16562,16654,16928,17021,17298,17392,17672,17767,18050,18146,18432,18529,18818,18916,19208,19307,19602,19702,20000,20101,20402,20504,20808,20911,21218,21322,21632,21737,22050,22156,22472,22579,22898,23006,23328,23437,23762,23872,24200,24311,24642,24754,25088,25201,25538,25652,25992,26107,26450,26566,26912,27029,27378,27496,27848,27967,28322,28442,28800,28921,29282,29404,29768,29891,30258,30382,30752,30877,31250 mov $2,$0 mov $3,$0 div $3,2 sub $2,$3 mul $0,$2 mov $1,$0 add $1,1 add $1,$3
segment .data output: dq "%c%i", 0 new_line db 0x0a, 0 fuck: dq "fuuuuck", 0 extern printf segment .text global encode encode: ;An assembly function to ; 1. Accepts a string of length 15 ; 2. Encodes the String using Run Length Encoding; ; 3. Outputs the encoded String to the terminal; ;And is called by a c program push rbp ;This is our first character that we will use mov r15, rdi ;Our input mov r14, [r15] ;Our oletter that we will compare first with mov r8, 0 ;Our character counter mov r9, 0 ;Our loop counter while: mov r13, [r15 + r8] ;This is our current character cmp r13b, 0x00 je endWhile inc r8 ;Check if our character is repeated ;If so we'll increment the character counter ;If not we save the number and reset it cmp r14b, r13b jnz newCharacter inc r9 jmp while newCharacter: mov rdi, output mov rsi, r14 mov rdx, r9 mov rax, 2 call printf mov r14, r13;New previous character mov r9, 1 ;Reset the character count jmp while endWhile: ;get the last character mov rdi, output mov rsi, r14 mov rdx, r9 mov rax, 2 call printf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; PRINT NEW LINE ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov rdi, new_line call printf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; EXIT ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;exit the program xor eax, eax pop rbp ret
%ifdef CONFIG { "RegData": { "R15": "0x41424344454600FF", "R14": "0x00000000000000FF", "R13": "0x00000000000000FF", "R12": "0x41424344454600FF", "R11": "0x00000000000000FF", "R10": "0x00000000000000FF" }, "MemoryRegions": { "0x100000000": "4096" } } %endif mov rdx, 0xe0000000 mov rax, 0xFFFFFFFFFFFFFFFF mov [rdx + 8 * 0], rax mov r15, 0x4142434445464748 mov r14, 0x4142434445464748 mov r13, 0x4142434445464748 mov r12, 0x4142434445464748 mov r11, 0x4142434445464748 mov r10, 0x4142434445464748 movzx r15w, byte [rdx + 8 * 0] movzx r14d, byte [rdx + 8 * 0] movzx r13, byte [rdx + 8 * 0] movzx r12w, al movzx r11d, al movzx r10, al hlt
; nasm -f elf32 ex9.asm -o ex9.o ; gcc -m32 ex9.o -o ex9.out ; ./ex9.out ; echo $? global main section .text main: mov ebp, esp; for correct debugging push 21 ; save 21 on the stack (int = 4 bytes = 32 bits) call times2 ; jump to times2 mov ebx, eax ; ebx (exit status) = eax = 42 mov eax, 1 ; exit call int 0x80 ; system call times2: push ebp ; save ebp on the stack (int = 4 bytes = 32 bits) mov ebp, esp ; save esp (stack pointer) in ebp mov eax, [ebp+8]; eax = 21 (int = 4 bytes = 32 bits) add eax, eax ; eax += eax == 21 += 21 == 42 mov esp, ebp ; restore esp (stack pointer) from ebp pop ebp ; restore ebp from the stack ret ; return to the next line after the call
# A demonstration of some simple MIPS instructions # used to test QtSPIM # Declare main as a global function .globl main # All program code is placed after the # .text assembler directive .text # The label 'main' represents the starting point main: li $t2, 25 # Load immediate value (25) lw $t3, value # Load the word stored in value (see bottom) add $t4, $t2, $t3 # Add sub $t5, $t2, $t3 # Subtract addi $t2, $t1, 5 andi $t1, $t2, 4 beq $t4, $t5, label div $t5, $t2 la $t4, 200 sw $t5, Z #Store the answer in Z (declared at the bottom) sw $t4, 4($sp) label: # Exit the program by means of a syscall. # There are many syscalls - pick the desired one # by placing its code in $v0. The code for exit is "10" li $v0, 10 # Sets $v0 to "10" to select exit syscall syscall # Exit # All memory structures are placed after the # .data assembler directive .data # The .word assembler directive reserves space # in memory for a single 4-byte word (or multiple 4-byte words) # and assigns that memory location an initial value # (or a comma separated list of initial values) value: .word 12 Z: .word 0
db 0 ; species ID placeholder db 80, 100, 70, 45, 50, 60 ; hp atk def spd sat sdf db FIGHTING, FIGHTING ; type db 90 ; catch rate db 146 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F0 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/machoke/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_SLOW ; growth rate dn EGG_HUMANSHAPE, EGG_HUMANSHAPE ; egg groups ; tm/hm learnset tmhm DYNAMICPUNCH, HEADBUTT, CURSE, TOXIC, ROCK_SMASH, HIDDEN_POWER, SUNNY_DAY, SNORE, PROTECT, ENDURE, FRUSTRATION, EARTHQUAKE, RETURN, DIG, MUD_SLAP, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, FIRE_BLAST, THUNDERPUNCH, DETECT, REST, ATTRACT, THIEF, FIRE_PUNCH, STRENGTH, FLAMETHROWER ; end
/* * Copyright (c) 2017, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, 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. */ L0: (W&~f0.1)jmpi L416 L16: cmp (1|M0) (eq)f1.0 null.0<1>:w r24.2<0;1,0>:ub 0x1:uw (~f1.0) mov (1|M0) r25.2<1>:f r10.1<0;1,0>:f (f1.0) mov (1|M0) r25.2<1>:f r10.6<0;1,0>:f mov (8|M0) r17.0<1>:ud r25.0<8;8,1>:ud add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x44EB100:ud mov (1|M0) r16.2<1>:ud 0xD000:ud send (1|M0) r84:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x48EB301:ud or (1|M0) r17.7<1>:ud r17.7<0;1,0>:ud 0x8000000:ud mov (1|M0) r16.2<1>:ud 0xA000:ud send (1|M0) r88:uw r16:ub 0x2 a0.0 mov (1|M0) a0.8<1>:uw 0xA00:uw mov (1|M0) a0.9<1>:uw 0xA80:uw mov (1|M0) a0.10<1>:uw 0xB00:uw add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x40:uw mov (16|M0) r80.0<1>:uw r90.0<16;16,1>:uw mov (16|M0) r81.0<1>:uw r91.0<16;16,1>:uw mov (16|M0) r90.0<1>:uw r92.0<16;16,1>:uw mov (16|M0) r91.0<1>:uw r93.0<16;16,1>:uw mov (16|M0) r82.0<1>:uw r94.0<16;16,1>:uw mov (16|M0) r83.0<1>:uw r95.0<16;16,1>:uw mov (16|M0) r92.0<1>:uw 0xFFFF:uw mov (16|M0) r93.0<1>:uw 0xFFFF:uw mov (16|M0) r94.0<1>:uw 0xFFFF:uw mov (16|M0) r95.0<1>:uw 0xFFFF:uw L416: nop
; A143956: Triangle read by rows, A000012 * A136521 * A000012; 1<=k<=n. ; 1,3,2,5,4,2,7,6,4,2,9,8,6,4,2,11,10,8,6,4,2,13,12,10,8,6,4,2,15,14,12,10,8,6,4,2,17,16,14,12,10,8,6,4,2,19,18,16,14,12,10,8,6,4,2,21,20,18,16,14,12,10,8,6,4,2 lpb $0,1 mov $1,$0 add $0,1 sub $1,2 add $2,1 mov $3,$0 sub $0,$2 trn $0,2 add $3,1 add $3,$1 lpe mul $2,2 mov $1,$2 trn $3,3 sub $1,$3 add $1,1
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 5, 0x90 .globl g9_EncryptCFB_RIJ128_AES_NI .type g9_EncryptCFB_RIJ128_AES_NI, @function g9_EncryptCFB_RIJ128_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(144), %esp movl (32)(%ebp), %eax movdqu (%eax), %xmm4 movdqu %xmm4, (%esp) .Lblks_loopgas_1: movl (8)(%ebp), %esi movl (28)(%ebp), %edx lea (,%edx,4), %ebx movl (24)(%ebp), %edx cmp %ebx, %edx cmovl %edx, %ebx xor %ecx, %ecx .L__0000gas_1: movb (%esi,%ecx), %dl movb %dl, (80)(%esp,%ecx) add $(1), %ecx cmp %ebx, %ecx jl .L__0000gas_1 movl (20)(%ebp), %ecx movl (16)(%ebp), %edx lea (,%edx,4), %eax lea (-144)(%ecx,%eax,4), %eax xor %esi, %esi mov %ebx, %edi .Lsingle_blkgas_1: movdqu (%esp,%esi), %xmm0 pxor (%ecx), %xmm0 cmp $(12), %edx jl .Lkey_128_sgas_1 jz .Lkey_192_sgas_1 .Lkey_256_sgas_1: aesenc (-64)(%eax), %xmm0 aesenc (-48)(%eax), %xmm0 .Lkey_192_sgas_1: aesenc (-32)(%eax), %xmm0 aesenc (-16)(%eax), %xmm0 .Lkey_128_sgas_1: aesenc (%eax), %xmm0 aesenc (16)(%eax), %xmm0 aesenc (32)(%eax), %xmm0 aesenc (48)(%eax), %xmm0 aesenc (64)(%eax), %xmm0 aesenc (80)(%eax), %xmm0 aesenc (96)(%eax), %xmm0 aesenc (112)(%eax), %xmm0 aesenc (128)(%eax), %xmm0 aesenclast (144)(%eax), %xmm0 movdqu (80)(%esp,%esi), %xmm1 pxor %xmm1, %xmm0 movdqu %xmm0, (16)(%esp,%esi) addl (28)(%ebp), %esi subl (28)(%ebp), %edi jg .Lsingle_blkgas_1 movl (12)(%ebp), %edi xor %ecx, %ecx .L__0001gas_1: movb (16)(%esp,%ecx), %dl movb %dl, (%edi,%ecx) add $(1), %ecx cmp %ebx, %ecx jl .L__0001gas_1 movdqu (%esp,%ebx), %xmm0 movdqu %xmm0, (%esp) addl %ebx, (8)(%ebp) addl %ebx, (12)(%ebp) subl %ebx, (24)(%ebp) jg .Lblks_loopgas_1 add $(144), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe1: .size g9_EncryptCFB_RIJ128_AES_NI, .Lfe1-(g9_EncryptCFB_RIJ128_AES_NI) .p2align 5, 0x90 .globl g9_EncryptCFB32_RIJ128_AES_NI .type g9_EncryptCFB32_RIJ128_AES_NI, @function g9_EncryptCFB32_RIJ128_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi sub $(144), %esp movl (32)(%ebp), %eax movdqu (%eax), %xmm4 movdqu %xmm4, (%esp) .Lblks_loopgas_2: movl (8)(%ebp), %esi movl (28)(%ebp), %edx lea (,%edx,4), %ebx movl (24)(%ebp), %edx cmp %ebx, %edx cmovl %edx, %ebx xor %ecx, %ecx .L__0002gas_2: movl (%esi,%ecx), %edx movl %edx, (80)(%esp,%ecx) add $(4), %ecx cmp %ebx, %ecx jl .L__0002gas_2 movl (20)(%ebp), %ecx movl (16)(%ebp), %edx lea (,%edx,4), %eax lea (-144)(%ecx,%eax,4), %eax xor %esi, %esi mov %ebx, %edi .Lsingle_blkgas_2: movdqu (%esp,%esi), %xmm0 pxor (%ecx), %xmm0 cmp $(12), %edx jl .Lkey_128_sgas_2 jz .Lkey_192_sgas_2 .Lkey_256_sgas_2: aesenc (-64)(%eax), %xmm0 aesenc (-48)(%eax), %xmm0 .Lkey_192_sgas_2: aesenc (-32)(%eax), %xmm0 aesenc (-16)(%eax), %xmm0 .Lkey_128_sgas_2: aesenc (%eax), %xmm0 aesenc (16)(%eax), %xmm0 aesenc (32)(%eax), %xmm0 aesenc (48)(%eax), %xmm0 aesenc (64)(%eax), %xmm0 aesenc (80)(%eax), %xmm0 aesenc (96)(%eax), %xmm0 aesenc (112)(%eax), %xmm0 aesenc (128)(%eax), %xmm0 aesenclast (144)(%eax), %xmm0 movdqu (80)(%esp,%esi), %xmm1 pxor %xmm1, %xmm0 movdqu %xmm0, (16)(%esp,%esi) addl (28)(%ebp), %esi subl (28)(%ebp), %edi jg .Lsingle_blkgas_2 movl (12)(%ebp), %edi xor %ecx, %ecx .L__0003gas_2: movl (16)(%esp,%ecx), %edx movl %edx, (%edi,%ecx) add $(4), %ecx cmp %ebx, %ecx jl .L__0003gas_2 movdqu (%esp,%ebx), %xmm0 movdqu %xmm0, (%esp) addl %ebx, (8)(%ebp) addl %ebx, (12)(%ebp) subl %ebx, (24)(%ebp) jg .Lblks_loopgas_2 add $(144), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe2: .size g9_EncryptCFB32_RIJ128_AES_NI, .Lfe2-(g9_EncryptCFB32_RIJ128_AES_NI) .p2align 5, 0x90 .globl g9_EncryptCFB128_RIJ128_AES_NI .type g9_EncryptCFB128_RIJ128_AES_NI, @function g9_EncryptCFB128_RIJ128_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (28)(%ebp), %eax movdqu (%eax), %xmm0 movl (8)(%ebp), %esi movl (12)(%ebp), %edi movl (24)(%ebp), %ebx movl (20)(%ebp), %ecx movl (16)(%ebp), %edx lea (,%edx,4), %eax lea (-144)(%ecx,%eax,4), %eax .Lblks_loopgas_3: pxor (%ecx), %xmm0 movdqu (%esi), %xmm1 cmp $(12), %edx jl .Lkey_128_sgas_3 jz .Lkey_192_sgas_3 .Lkey_256_sgas_3: aesenc (-64)(%eax), %xmm0 aesenc (-48)(%eax), %xmm0 .Lkey_192_sgas_3: aesenc (-32)(%eax), %xmm0 aesenc (-16)(%eax), %xmm0 .Lkey_128_sgas_3: aesenc (%eax), %xmm0 aesenc (16)(%eax), %xmm0 aesenc (32)(%eax), %xmm0 aesenc (48)(%eax), %xmm0 aesenc (64)(%eax), %xmm0 aesenc (80)(%eax), %xmm0 aesenc (96)(%eax), %xmm0 aesenc (112)(%eax), %xmm0 aesenc (128)(%eax), %xmm0 aesenclast (144)(%eax), %xmm0 pxor %xmm1, %xmm0 movdqu %xmm0, (%edi) add $(16), %esi add $(16), %edi sub $(16), %ebx jg .Lblks_loopgas_3 pop %edi pop %esi pop %ebx pop %ebp ret .Lfe3: .size g9_EncryptCFB128_RIJ128_AES_NI, .Lfe3-(g9_EncryptCFB128_RIJ128_AES_NI)
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "util.h" #include "chainparams.h" #include "sync.h" #include "ui_interface.h" #include "uint256.h" #include "version.h" #include "netbase.h" #include "allocators.h" #include <algorithm> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/algorithm/string/case_conv.hpp> // for to_lower() #include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith() // Work around clang compilation problem in Boost 1.46: // /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup // See also: http://stackoverflow.com/questions/10020179/compilation-fail-in-boost-librairies-program-options // http://clang.debian.net/status.php?version=3.0&key=CANNOT_FIND_FUNCTION namespace boost { namespace program_options { std::string to_internal(const std::string&); } } #include <boost/program_options/detail/config_file.hpp> #include <boost/program_options/parsers.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/foreach.hpp> #include <boost/thread.hpp> #include <openssl/crypto.h> #include <openssl/rand.h> #include <openssl/err.h> #include <stdarg.h> #ifdef WIN32 #ifdef _MSC_VER #pragma warning(disable:4786) #pragma warning(disable:4804) #pragma warning(disable:4805) #pragma warning(disable:4717) #endif #ifdef _WIN32_WINNT #undef _WIN32_WINNT #endif #define _WIN32_WINNT 0x0501 #ifdef _WIN32_IE #undef _WIN32_IE #endif #define _WIN32_IE 0x0501 #define WIN32_LEAN_AND_MEAN 1 #ifndef NOMINMAX #define NOMINMAX #endif #include <io.h> /* for _commit */ #include "shlobj.h" #elif defined(__linux__) # include <sys/prctl.h> #endif using namespace std; //Dark features bool fMasterNode = false; string strMasterNodePrivKey = ""; string strMasterNodeAddr = ""; bool fLiteMode = false; bool fEnableInstantX = true; int nInstantXDepth = 10; int nDarksendRounds = 2; int nAnonymizepiratecashAmount = 1000; int nLiquidityProvider = 0; /** Spork enforcement enabled time */ int64_t enforceMasternodePaymentsTime = 4085657524; int nMasternodeMinProtocol = 0; bool fSucessfullyLoaded = false; bool fEnableDarksend = false; /** All denominations used by darksend */ std::vector<int64_t> darkSendDenominations; map<string, string> mapArgs; map<string, vector<string> > mapMultiArgs; bool fDebug = false; bool fDebugSmsg = false; bool fNoSmsg = false; bool fPrintToConsole = false; bool fPrintToDebugLog = true; bool fDaemon = false; bool fServer = false; bool fCommandLine = false; string strMiscWarning; bool fNoListen = false; bool fLogTimestamps = false; volatile bool fReopenDebugLog = false; // Init OpenSSL library multithreading support static CCriticalSection** ppmutexOpenSSL; void locking_callback(int mode, int i, const char* file, int line) { if (mode & CRYPTO_LOCK) { ENTER_CRITICAL_SECTION(*ppmutexOpenSSL[i]); } else { LEAVE_CRITICAL_SECTION(*ppmutexOpenSSL[i]); } } // Init class CInit { public: CInit() { // Init OpenSSL library multithreading support ppmutexOpenSSL = (CCriticalSection**)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(CCriticalSection*)); for (int i = 0; i < CRYPTO_num_locks(); i++) ppmutexOpenSSL[i] = new CCriticalSection(); CRYPTO_set_locking_callback(locking_callback); #ifdef WIN32 // Seed OpenSSL PRNG with current contents of the screen RAND_screen(); #endif // Seed OpenSSL PRNG with performance counter RandAddSeed(); } ~CInit() { // Shutdown OpenSSL library multithreading support CRYPTO_set_locking_callback(NULL); for (int i = 0; i < CRYPTO_num_locks(); i++) delete ppmutexOpenSSL[i]; OPENSSL_free(ppmutexOpenSSL); } } instance_of_cinit; bool GetRandBytes(unsigned char *buf, int num) { if (RAND_bytes(buf, num) == 0) { LogPrint("rand", "%s : OpenSSL RAND_bytes() failed with error: %s\n", __func__, ERR_error_string(ERR_get_error(), NULL)); return false; } return true; } void RandAddSeed() { // Seed with CPU performance counter int64_t nCounter = GetPerformanceCounter(); RAND_add(&nCounter, sizeof(nCounter), 1.5); memset(&nCounter, 0, sizeof(nCounter)); } void RandAddSeedPerfmon() { RandAddSeed(); // This can take up to 2 seconds, so only do it every 10 minutes static int64_t nLastPerfmon; if (GetTime() < nLastPerfmon + 10 * 60) return; nLastPerfmon = GetTime(); #ifdef WIN32 // Don't need this on Linux, OpenSSL automatically uses /dev/urandom // Seed with the entire set of perfmon data unsigned char pdata[250000]; memset(pdata, 0, sizeof(pdata)); unsigned long nSize = sizeof(pdata); long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize); RegCloseKey(HKEY_PERFORMANCE_DATA); if (ret == ERROR_SUCCESS) { RAND_add(pdata, nSize, nSize/100.0); OPENSSL_cleanse(pdata, nSize); LogPrint("rand", "RandAddSeed() %lu bytes\n", nSize); } #endif } uint64_t GetRand(uint64_t nMax) { if (nMax == 0) return 0; // The range of the random source must be a multiple of the modulus // to give every possible output value an equal possibility uint64_t nRange = (std::numeric_limits<uint64_t>::max() / nMax) * nMax; uint64_t nRand = 0; do { GetRandBytes((unsigned char*)&nRand, sizeof(nRand)); } while (nRand >= nRange); return (nRand % nMax); } int GetRandInt(int nMax) { return GetRand(nMax); } uint256 GetRandHash() { uint256 hash; GetRandBytes((unsigned char*)&hash, sizeof(hash)); return hash; } // LogPrintf() has been broken a couple of times now // by well-meaning people adding mutexes in the most straightforward way. // It breaks because it may be called by global destructors during shutdown. // Since the order of destruction of static/global objects is undefined, // defining a mutex as a global object doesn't work (the mutex gets // destroyed, and then some later destructor calls OutputDebugStringF, // maybe indirectly, and you get a core dump at shutdown trying to lock // the mutex). static boost::once_flag debugPrintInitFlag = BOOST_ONCE_INIT; // We use boost::call_once() to make sure these are initialized in // in a thread-safe manner the first time it is called: static FILE* fileout = NULL; static boost::mutex* mutexDebugLog = NULL; static void DebugPrintInit() { assert(fileout == NULL); assert(mutexDebugLog == NULL); boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; fileout = fopen(pathDebug.string().c_str(), "a"); if (fileout) setbuf(fileout, NULL); // unbuffered mutexDebugLog = new boost::mutex(); } bool LogAcceptCategory(const char* category) { if (category != NULL) { if (!fDebug) return false; // Give each thread quick access to -debug settings. // This helps prevent issues debugging global destructors, // where mapMultiArgs might be deleted before another // global destructor calls LogPrint() static boost::thread_specific_ptr<set<string> > ptrCategory; if (ptrCategory.get() == NULL) { const vector<string>& categories = mapMultiArgs["-debug"]; ptrCategory.reset(new set<string>(categories.begin(), categories.end())); // thread_specific_ptr automatically deletes the set when the thread ends. } const set<string>& setCategories = *ptrCategory.get(); // if not debugging everything and not debugging specific category, LogPrint does nothing. if (setCategories.count(string("")) == 0 && setCategories.count(string(category)) == 0) return false; } return true; } int LogPrintStr(const std::string &str) { int ret = 0; // Returns total number of characters written if (fPrintToConsole) { // print to console ret = fwrite(str.data(), 1, str.size(), stdout); } else if (fPrintToDebugLog) { static bool fStartedNewLine = true; boost::call_once(&DebugPrintInit, debugPrintInitFlag); if (fileout == NULL) return ret; boost::mutex::scoped_lock scoped_lock(*mutexDebugLog); // reopen the log file, if requested if (fReopenDebugLog) { fReopenDebugLog = false; boost::filesystem::path pathDebug = GetDataDir() / "debug.log"; if (freopen(pathDebug.string().c_str(),"a",fileout) != NULL) setbuf(fileout, NULL); // unbuffered } // Debug print useful for profiling if (fLogTimestamps && fStartedNewLine) ret += fprintf(fileout, "%s ", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str()); if (!str.empty() && str[str.size()-1] == '\n') fStartedNewLine = true; else fStartedNewLine = false; ret = fwrite(str.data(), 1, str.size(), fileout); } return ret; } void ParseString(const string& str, char c, vector<string>& v) { if (str.empty()) return; string::size_type i1 = 0; string::size_type i2; while (true) { i2 = str.find(c, i1); if (i2 == str.npos) { v.push_back(str.substr(i1)); return; } v.push_back(str.substr(i1, i2-i1)); i1 = i2+1; } } string FormatMoney(int64_t n, bool fPlus) { // Note: not using straight sprintf here because we do NOT want // localized number formatting. int64_t n_abs = (n > 0 ? n : -n); int64_t quotient = n_abs/COIN; int64_t remainder = n_abs%COIN; string str = strprintf("%d.%08d", quotient, remainder); // Right-trim excess zeros before the decimal point: int nTrim = 0; for (int i = str.size()-1; (str[i] == '0' && isdigit(str[i-2])); --i) ++nTrim; if (nTrim) str.erase(str.size()-nTrim, nTrim); if (n < 0) str.insert((unsigned int)0, 1, '-'); else if (fPlus && n > 0) str.insert((unsigned int)0, 1, '+'); return str; } bool ParseMoney(const string& str, int64_t& nRet) { return ParseMoney(str.c_str(), nRet); } bool ParseMoney(const char* pszIn, int64_t& nRet) { string strWhole; int64_t nUnits = 0; const char* p = pszIn; while (isspace(*p)) p++; for (; *p; p++) { if (*p == '.') { p++; int64_t nMult = CENT*10; while (isdigit(*p) && (nMult > 0)) { nUnits += nMult * (*p++ - '0'); nMult /= 10; } break; } if (isspace(*p)) break; if (!isdigit(*p)) return false; strWhole.insert(strWhole.end(), *p); } for (; *p; p++) if (!isspace(*p)) return false; if (strWhole.size() > 10) // guard against 63 bit overflow return false; if (nUnits < 0 || nUnits > COIN) return false; int64_t nWhole = atoi64(strWhole); int64_t nValue = nWhole*COIN + nUnits; nRet = nValue; return true; } // safeChars chosen to allow simple messages/URLs/email addresses, but avoid anything // even possibly remotely dangerous like & or > static string safeChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890 .,;_/:?@"); string SanitizeString(const string& str) { string strResult; for (std::string::size_type i = 0; i < str.size(); i++) { if (safeChars.find(str[i]) != std::string::npos) strResult.push_back(str[i]); } return strResult; } const signed char p_util_hexdigit[256] = { -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0,1,2,3,4,5,6,7,8,9,-1,-1,-1,-1,-1,-1, -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,0xa,0xb,0xc,0xd,0xe,0xf,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, }; bool IsHex(const string& str) { BOOST_FOREACH(char c, str) { if (HexDigit(c) < 0) return false; } return (str.size() > 0) && (str.size()%2 == 0); } vector<unsigned char> ParseHex(const char* psz) { // convert hex dump to vector vector<unsigned char> vch; while (true) { while (isspace(*psz)) psz++; signed char c = HexDigit(*psz++); if (c == (signed char)-1) break; unsigned char n = (c << 4); c = HexDigit(*psz++); if (c == (signed char)-1) break; n |= c; vch.push_back(n); } return vch; } vector<unsigned char> ParseHex(const string& str) { return ParseHex(str.c_str()); } static void InterpretNegativeSetting(string name, map<string, string>& mapSettingsRet) { // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set if (name.find("-no") == 0) { std::string positive("-"); positive.append(name.begin()+3, name.end()); if (mapSettingsRet.count(positive) == 0) { bool value = !GetBoolArg(name, false); mapSettingsRet[positive] = (value ? "1" : "0"); } } } void ParseParameters(int argc, const char* const argv[]) { mapArgs.clear(); mapMultiArgs.clear(); for (int i = 1; i < argc; i++) { std::string str(argv[i]); std::string strValue; size_t is_index = str.find('='); if (is_index != std::string::npos) { strValue = str.substr(is_index+1); str = str.substr(0, is_index); } #ifdef WIN32 boost::to_lower(str); if (boost::algorithm::starts_with(str, "/")) str = "-" + str.substr(1); #endif if (str[0] != '-') break; mapArgs[str] = strValue; mapMultiArgs[str].push_back(strValue); } // New 0.6 features: BOOST_FOREACH(const PAIRTYPE(string,string)& entry, mapArgs) { string name = entry.first; // interpret --foo as -foo (as long as both are not set) if (name.find("--") == 0) { std::string singleDash(name.begin()+1, name.end()); if (mapArgs.count(singleDash) == 0) mapArgs[singleDash] = entry.second; name = singleDash; } // interpret -nofoo as -foo=0 (and -nofoo=0 as -foo=1) as long as -foo not set InterpretNegativeSetting(name, mapArgs); } } std::string GetArg(const std::string& strArg, const std::string& strDefault) { if (mapArgs.count(strArg)) return mapArgs[strArg]; return strDefault; } int64_t GetArg(const std::string& strArg, int64_t nDefault) { if (mapArgs.count(strArg)) return atoi64(mapArgs[strArg]); return nDefault; } bool GetBoolArg(const std::string& strArg, bool fDefault) { if (mapArgs.count(strArg)) { if (mapArgs[strArg].empty()) return true; return (atoi(mapArgs[strArg]) != 0); } return fDefault; } bool SoftSetArg(const std::string& strArg, const std::string& strValue) { if (mapArgs.count(strArg)) return false; mapArgs[strArg] = strValue; return true; } bool SoftSetBoolArg(const std::string& strArg, bool fValue) { if (fValue) return SoftSetArg(strArg, std::string("1")); else return SoftSetArg(strArg, std::string("0")); } string EncodeBase64(const unsigned char* pch, size_t len) { static const char *pbase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; string strRet=""; strRet.reserve((len+2)/3*4); int mode=0, left=0; const unsigned char *pchEnd = pch+len; while (pch<pchEnd) { int enc = *(pch++); switch (mode) { case 0: // we have no bits strRet += pbase64[enc >> 2]; left = (enc & 3) << 4; mode = 1; break; case 1: // we have two bits strRet += pbase64[left | (enc >> 4)]; left = (enc & 15) << 2; mode = 2; break; case 2: // we have four bits strRet += pbase64[left | (enc >> 6)]; strRet += pbase64[enc & 63]; mode = 0; break; } } if (mode) { strRet += pbase64[left]; strRet += '='; if (mode == 1) strRet += '='; } return strRet; } string EncodeBase64(const string& str) { return EncodeBase64((const unsigned char*)str.c_str(), str.size()); } vector<unsigned char> DecodeBase64(const char* p, bool* pfInvalid) { static const int decode64_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; if (pfInvalid) *pfInvalid = false; vector<unsigned char> vchRet; vchRet.reserve(strlen(p)*3/4); int mode = 0; int left = 0; while (1) { int dec = decode64_table[(unsigned char)*p]; if (dec == -1) break; p++; switch (mode) { case 0: // we have no bits and get 6 left = dec; mode = 1; break; case 1: // we have 6 bits and keep 4 vchRet.push_back((left<<2) | (dec>>4)); left = dec & 15; mode = 2; break; case 2: // we have 4 bits and get 6, we keep 2 vchRet.push_back((left<<4) | (dec>>2)); left = dec & 3; mode = 3; break; case 3: // we have 2 bits and get 6 vchRet.push_back((left<<6) | dec); mode = 0; break; } } if (pfInvalid) switch (mode) { case 0: // 4n base64 characters processed: ok break; case 1: // 4n+1 base64 character processed: impossible *pfInvalid = true; break; case 2: // 4n+2 base64 characters processed: require '==' if (left || p[0] != '=' || p[1] != '=' || decode64_table[(unsigned char)p[2]] != -1) *pfInvalid = true; break; case 3: // 4n+3 base64 characters processed: require '=' if (left || p[0] != '=' || decode64_table[(unsigned char)p[1]] != -1) *pfInvalid = true; break; } return vchRet; } string DecodeBase64(const string& str) { vector<unsigned char> vchRet = DecodeBase64(str.c_str()); return string((const char*)&vchRet[0], vchRet.size()); } // Base64 encoding with secure memory allocation SecureString EncodeBase64Secure(const SecureString& input) { // Init openssl BIO with base64 filter and memory output BIO *b64, *mem; b64 = BIO_new(BIO_f_base64()); BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); // No newlines in output mem = BIO_new(BIO_s_mem()); BIO_push(b64, mem); // Decode the string BIO_write(b64, &input[0], input.size()); (void) BIO_flush(b64); // Create output variable from buffer mem ptr BUF_MEM *bptr; BIO_get_mem_ptr(b64, &bptr); SecureString output(bptr->data, bptr->length); // Cleanse secure data buffer from memory OPENSSL_cleanse((void *) bptr->data, bptr->length); // Free memory BIO_free_all(b64); return output; } // Base64 decoding with secure memory allocation SecureString DecodeBase64Secure(const SecureString& input) { SecureString output; // Init openssl BIO with base64 filter and memory input BIO *b64, *mem; b64 = BIO_new(BIO_f_base64()); BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); //Do not use newlines to flush buffer mem = BIO_new_mem_buf((void *) &input[0], input.size()); BIO_push(b64, mem); // Prepare buffer to receive decoded data if(input.size() % 4 != 0) { throw runtime_error("Input length should be a multiple of 4"); } size_t nMaxLen = input.size() / 4 * 3; // upper bound, guaranteed divisible by 4 output.resize(nMaxLen); // Decode the string size_t nLen; nLen = BIO_read(b64, (void *) &output[0], input.size()); output.resize(nLen); // Free memory BIO_free_all(b64); return output; } string EncodeBase32(const unsigned char* pch, size_t len) { static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567"; string strRet=""; strRet.reserve((len+4)/5*8); int mode=0, left=0; const unsigned char *pchEnd = pch+len; while (pch<pchEnd) { int enc = *(pch++); switch (mode) { case 0: // we have no bits strRet += pbase32[enc >> 3]; left = (enc & 7) << 2; mode = 1; break; case 1: // we have three bits strRet += pbase32[left | (enc >> 6)]; strRet += pbase32[(enc >> 1) & 31]; left = (enc & 1) << 4; mode = 2; break; case 2: // we have one bit strRet += pbase32[left | (enc >> 4)]; left = (enc & 15) << 1; mode = 3; break; case 3: // we have four bits strRet += pbase32[left | (enc >> 7)]; strRet += pbase32[(enc >> 2) & 31]; left = (enc & 3) << 3; mode = 4; break; case 4: // we have two bits strRet += pbase32[left | (enc >> 5)]; strRet += pbase32[enc & 31]; mode = 0; } } static const int nPadding[5] = {0, 6, 4, 3, 1}; if (mode) { strRet += pbase32[left]; for (int n=0; n<nPadding[mode]; n++) strRet += '='; } return strRet; } string EncodeBase32(const string& str) { return EncodeBase32((const unsigned char*)str.c_str(), str.size()); } vector<unsigned char> DecodeBase32(const char* p, bool* pfInvalid) { static const int decode32_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; if (pfInvalid) *pfInvalid = false; vector<unsigned char> vchRet; vchRet.reserve((strlen(p))*5/8); int mode = 0; int left = 0; while (1) { int dec = decode32_table[(unsigned char)*p]; if (dec == -1) break; p++; switch (mode) { case 0: // we have no bits and get 5 left = dec; mode = 1; break; case 1: // we have 5 bits and keep 2 vchRet.push_back((left<<3) | (dec>>2)); left = dec & 3; mode = 2; break; case 2: // we have 2 bits and keep 7 left = left << 5 | dec; mode = 3; break; case 3: // we have 7 bits and keep 4 vchRet.push_back((left<<1) | (dec>>4)); left = dec & 15; mode = 4; break; case 4: // we have 4 bits, and keep 1 vchRet.push_back((left<<4) | (dec>>1)); left = dec & 1; mode = 5; break; case 5: // we have 1 bit, and keep 6 left = left << 5 | dec; mode = 6; break; case 6: // we have 6 bits, and keep 3 vchRet.push_back((left<<2) | (dec>>3)); left = dec & 7; mode = 7; break; case 7: // we have 3 bits, and keep 0 vchRet.push_back((left<<5) | dec); mode = 0; break; } } if (pfInvalid) switch (mode) { case 0: // 8n base32 characters processed: ok break; case 1: // 8n+1 base32 characters processed: impossible case 3: // +3 case 6: // +6 *pfInvalid = true; break; case 2: // 8n+2 base32 characters processed: require '======' if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || p[3] != '=' || p[4] != '=' || p[5] != '=' || decode32_table[(unsigned char)p[6]] != -1) *pfInvalid = true; break; case 4: // 8n+4 base32 characters processed: require '====' if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || p[3] != '=' || decode32_table[(unsigned char)p[4]] != -1) *pfInvalid = true; break; case 5: // 8n+5 base32 characters processed: require '===' if (left || p[0] != '=' || p[1] != '=' || p[2] != '=' || decode32_table[(unsigned char)p[3]] != -1) *pfInvalid = true; break; case 7: // 8n+7 base32 characters processed: require '=' if (left || p[0] != '=' || decode32_table[(unsigned char)p[1]] != -1) *pfInvalid = true; break; } return vchRet; } string DecodeBase32(const string& str) { vector<unsigned char> vchRet = DecodeBase32(str.c_str()); return string((const char*)&vchRet[0], vchRet.size()); } bool WildcardMatch(const char* psz, const char* mask) { while (true) { switch (*mask) { case '\0': return (*psz == '\0'); case '*': return WildcardMatch(psz, mask+1) || (*psz && WildcardMatch(psz+1, mask)); case '?': if (*psz == '\0') return false; break; default: if (*psz != *mask) return false; break; } psz++; mask++; } } bool WildcardMatch(const string& str, const string& mask) { return WildcardMatch(str.c_str(), mask.c_str()); } bool ParseInt32(const std::string& str, int32_t *out) { char *endp = NULL; errno = 0; // strtol will not set errno if valid long int n = strtol(str.c_str(), &endp, 10); if(out) *out = (int)n; // Note that strtol returns a *long int*, so even if strtol doesn't report a over/underflow // we still have to check that the returned value is within the range of an *int32_t*. On 64-bit // platforms the size of these types may be different. return endp && *endp == 0 && !errno && n >= std::numeric_limits<int32_t>::min() && n <= std::numeric_limits<int32_t>::max(); } std::string FormatParagraph(const std::string in, size_t width, size_t indent) { std::stringstream out; size_t col = 0; size_t ptr = 0; while(ptr < in.size()) { // Find beginning of next word ptr = in.find_first_not_of(' ', ptr); if (ptr == std::string::npos) break; // Find end of next word size_t endword = in.find_first_of(' ', ptr); if (endword == std::string::npos) endword = in.size(); // Add newline and indentation if this wraps over the allowed width if (col > 0) { if ((col + endword - ptr) > width) { out << '\n'; for(size_t i=0; i<indent; ++i) out << ' '; col = 0; } else out << ' '; } // Append word out << in.substr(ptr, endword - ptr); col += endword - ptr + 1; ptr = endword; } return out.str(); } static std::string FormatException(std::exception* pex, const char* pszThread) { #ifdef WIN32 char pszModule[MAX_PATH] = ""; GetModuleFileNameA(NULL, pszModule, sizeof(pszModule)); #else const char* pszModule = "piratecash"; #endif if (pex) return strprintf( "EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread); else return strprintf( "UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread); } void PrintException(std::exception* pex, const char* pszThread) { std::string message = FormatException(pex, pszThread); LogPrintf("\n\n************************\n%s\n", message); fprintf(stderr, "\n\n************************\n%s\n", message.c_str()); strMiscWarning = message; throw; } void PrintExceptionContinue(std::exception* pex, const char* pszThread) { std::string message = FormatException(pex, pszThread); LogPrintf("\n\n************************\n%s\n", message); fprintf(stderr, "\n\n************************\n%s\n", message.c_str()); strMiscWarning = message; } boost::filesystem::path GetDefaultDataDir() { namespace fs = boost::filesystem; // Windows < Vista: C:\Documents and Settings\Username\Application Data\Piratecash // Windows >= Vista: C:\Users\Username\AppData\Roaming\Piratecash // Mac: ~/Library/Application Support/Piratecash // Unix: ~/.piratecash #ifdef WIN32 // Windows return GetSpecialFolderPath(CSIDL_APPDATA) / "Piratecash"; #else fs::path pathRet; char* pszHome = getenv("HOME"); if (pszHome == NULL || strlen(pszHome) == 0) pathRet = fs::path("/"); else pathRet = fs::path(pszHome); #ifdef MAC_OSX // Mac pathRet /= "Library/Application Support"; fs::create_directory(pathRet); return pathRet / "Piratecash"; #else // Unix return pathRet / ".piratecash"; #endif #endif } static boost::filesystem::path pathCached[CChainParams::MAX_NETWORK_TYPES+1]; static CCriticalSection csPathCached; const boost::filesystem::path &GetDataDir(bool fNetSpecific) { namespace fs = boost::filesystem; LOCK(csPathCached); int nNet = CChainParams::MAX_NETWORK_TYPES; if (fNetSpecific) nNet = Params().NetworkID(); fs::path &path = pathCached[nNet]; // This can be called during exceptions by LogPrintf(), so we cache the // value so we don't have to do memory allocations after that. if (!path.empty()) return path; if (mapArgs.count("-datadir")) { path = fs::system_complete(mapArgs["-datadir"]); if (!fs::is_directory(path)) { path = ""; return path; } } else { path = GetDefaultDataDir(); } if (fNetSpecific) path /= Params().DataDir(); fs::create_directory(path); return path; } string randomStrGen(int length) { static string charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; string result; result.resize(length); for (int32_t i = 0; i < length; i++) result[i] = charset[rand() % charset.length()]; return result; } void createConf() { srand(time(NULL)); ofstream pConf; pConf.open(GetConfigFile().generic_string().c_str()); const char* nodes = "\nrpcport=11888" "\nrpcallowip=127.0.0.1" "\ndaemon=1" "\nserver=1" "\nlisten=1" "\ntxindex=1" "\nlistenonion=0"; pConf << std::string("rpcuser=") + randomStrGen(5) + std::string("\nrpcpassword=") + randomStrGen(15) + std::string(nodes); pConf.close(); } void ClearDatadirCache() { std::fill(&pathCached[0], &pathCached[CChainParams::MAX_NETWORK_TYPES+1], boost::filesystem::path()); } boost::filesystem::path GetConfigFile() { boost::filesystem::path pathConfigFile(GetArg("-conf", "piratecash.conf")); if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir(false) / pathConfigFile; return pathConfigFile; } boost::filesystem::path GetMasternodeConfigFile() { boost::filesystem::path pathConfigFile(GetArg("-mnconf", "masternode.conf")); if (!pathConfigFile.is_complete()) pathConfigFile = GetDataDir() / pathConfigFile; return pathConfigFile; } void ReadConfigFile(map<string, string>& mapSettingsRet, map<string, vector<string> >& mapMultiSettingsRet) { boost::filesystem::ifstream streamConfig(GetConfigFile()); if (!streamConfig.good()){ // Create empty darksilk.conf if it does not excist createConf(); FILE* configFile = fopen(GetConfigFile().string().c_str(), "a"); if (configFile != NULL) fclose(configFile); return; // Nothing to read, so just return } set<string> setOptions; setOptions.insert("*"); for (boost::program_options::detail::config_file_iterator it(streamConfig, setOptions), end; it != end; ++it) { // Don't overwrite existing settings so command line settings override bitcoin.conf string strKey = string("-") + it->string_key; if (mapSettingsRet.count(strKey) == 0) { mapSettingsRet[strKey] = it->value[0]; // interpret nofoo=1 as foo=0 (and nofoo=0 as foo=1) as long as foo not set) InterpretNegativeSetting(strKey, mapSettingsRet); } mapMultiSettingsRet[strKey].push_back(it->value[0]); } // If datadir is changed in .conf file: ClearDatadirCache(); } boost::filesystem::path GetPidFile() { boost::filesystem::path pathPidFile(GetArg("-pid", "piratecashd.pid")); if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile; return pathPidFile; } #ifndef WIN32 void CreatePidFile(const boost::filesystem::path &path, pid_t pid) { FILE* file = fopen(path.string().c_str(), "w"); if (file) { fprintf(file, "%d\n", pid); fclose(file); } } #endif bool RenameOver(boost::filesystem::path src, boost::filesystem::path dest) { #ifdef WIN32 return MoveFileExA(src.string().c_str(), dest.string().c_str(), MOVEFILE_REPLACE_EXISTING); #else int rc = std::rename(src.string().c_str(), dest.string().c_str()); return (rc == 0); #endif /* WIN32 */ } void FileCommit(FILE *fileout) { fflush(fileout); // harmless if redundantly called #ifdef WIN32 HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(fileout)); FlushFileBuffers(hFile); #else fsync(fileno(fileout)); #endif } std::string getTimeString(int64_t timestamp, char *buffer, size_t nBuffer) { struct tm* dt; time_t t = timestamp; dt = localtime(&t); strftime(buffer, nBuffer, "%Y-%m-%d %H:%M:%S %z", dt); // %Z shows long strings on windows return std::string(buffer); // copies the null-terminated character sequence }; std::string bytesReadable(uint64_t nBytes) { if (nBytes >= 1024ll*1024ll*1024ll*1024ll) return strprintf("%.2f TB", nBytes/1024.0/1024.0/1024.0/1024.0); if (nBytes >= 1024*1024*1024) return strprintf("%.2f GB", nBytes/1024.0/1024.0/1024.0); if (nBytes >= 1024*1024) return strprintf("%.2f MB", nBytes/1024.0/1024.0); if (nBytes >= 1024) return strprintf("%.2f KB", nBytes/1024.0); return strprintf("%d B", nBytes); }; void ShrinkDebugFile() { // Scroll debug.log if it's getting too big boost::filesystem::path pathLog = GetDataDir() / "debug.log"; FILE* file = fopen(pathLog.string().c_str(), "r"); if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000) { // Restart the file with some of the end char pch[200000]; fseek(file, -sizeof(pch), SEEK_END); int nBytes = fread(pch, 1, sizeof(pch), file); fclose(file); file = fopen(pathLog.string().c_str(), "w"); if (file) { fwrite(pch, 1, nBytes, file); fclose(file); } } else if (file != NULL) fclose(file); } // // "Never go to sea with two chronometers; take one or three." // Our three time sources are: // - System clock // - Median of other nodes clocks // - The user (asking the user to fix the system clock if the first two disagree) // static int64_t nMockTime = 0; // For unit testing int64_t GetTime() { if (nMockTime) return nMockTime; return time(NULL); } void SetMockTime(int64_t nMockTimeIn) { nMockTime = nMockTimeIn; } static CCriticalSection cs_nTimeOffset; static int64_t nTimeOffset = 0; int64_t GetTimeOffset() { LOCK(cs_nTimeOffset); return nTimeOffset; } int64_t GetAdjustedTime() { return GetTime() + GetTimeOffset(); } void AddTimeData(const CNetAddr& ip, int64_t nTime) { int64_t nOffsetSample = nTime - GetTime(); LOCK(cs_nTimeOffset); // Ignore duplicates static set<CNetAddr> setKnown; if (!setKnown.insert(ip).second) return; // Add data static CMedianFilter<int64_t> vTimeOffsets(200,0); vTimeOffsets.input(nOffsetSample); LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1) { int64_t nMedian = vTimeOffsets.median(); std::vector<int64_t> vSorted = vTimeOffsets.sorted(); // Only let other nodes change our time by so much if (abs64(nMedian) < 70 * 60) { nTimeOffset = nMedian; } else { nTimeOffset = 0; static bool fDone; if (!fDone) { // If nobody has a time different than ours but within 5 minutes of ours, give a warning bool fMatch = false; BOOST_FOREACH(int64_t nOffset, vSorted) if (nOffset != 0 && abs64(nOffset) < 5 * 60) fMatch = true; if (!fMatch) { fDone = true; string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Transfercoin will not work properly."); strMiscWarning = strMessage; LogPrintf("*** %s\n", strMessage); uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); } } } if (fDebug) { BOOST_FOREACH(int64_t n, vSorted) LogPrintf("%+d ", n); LogPrintf("| "); } LogPrintf("nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); } } uint32_t insecure_rand_Rz = 11; uint32_t insecure_rand_Rw = 11; void seed_insecure_rand(bool fDeterministic) { //The seed values have some unlikely fixed points which we avoid. if(fDeterministic) { insecure_rand_Rz = insecure_rand_Rw = 11; } else { uint32_t tmp; do{ GetRandBytes((unsigned char*)&tmp,4); }while(tmp==0 || tmp==0x9068ffffU); insecure_rand_Rz=tmp; do{ GetRandBytes((unsigned char*)&tmp,4); }while(tmp==0 || tmp==0x464fffffU); insecure_rand_Rw=tmp; } } string FormatVersion(int nVersion) { if (nVersion%100 == 0) return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100); else return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100); } string FormatFullVersion() { return CLIENT_BUILD; } // Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014) std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments) { std::ostringstream ss; ss << "/"; ss << name << ":" << FormatVersion(nClientVersion); if (!comments.empty()) ss << "(" << boost::algorithm::join(comments, "; ") << ")"; ss << "/"; return ss.str(); } #ifdef WIN32 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) { namespace fs = boost::filesystem; char pszPath[MAX_PATH] = ""; if(SHGetSpecialFolderPathA(NULL, pszPath, nFolder, fCreate)) { return fs::path(pszPath); } LogPrintf("SHGetSpecialFolderPathA() failed, could not obtain requested path.\n"); return fs::path(""); } #endif void runCommand(std::string strCommand) { int nErr = ::system(strCommand.c_str()); if (nErr) LogPrintf("runCommand error: system(%s) returned %d\n", strCommand, nErr); } void RenameThread(const char* name) { #if defined(PR_SET_NAME) // Only the first 15 characters are used (16 - NUL terminator) ::prctl(PR_SET_NAME, name, 0, 0, 0); #elif 0 && (defined(__FreeBSD__) || defined(__OpenBSD__)) // TODO: This is currently disabled because it needs to be verified to work // on FreeBSD or OpenBSD first. When verified the '0 &&' part can be // removed. pthread_set_name_np(pthread_self(), name); #elif defined(MAC_OSX) && defined(__MAC_OS_X_VERSION_MAX_ALLOWED) // pthread_setname_np is XCode 10.6-and-later #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 pthread_setname_np(name); #endif #else // Prevent warnings for unused parameters... (void)name; #endif } std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime) { // std::locale takes ownership of the pointer std::locale loc(std::locale::classic(), new boost::posix_time::time_facet(pszFormat)); std::stringstream ss; ss.imbue(loc); ss << boost::posix_time::from_time_t(nTime); return ss.str(); }
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Geoworks 1994 -- All Rights Reserved PROJECT: PC GEOS MODULE: Spell Library FILE: spellC.asm AUTHOR: Joon Song, Sep 23, 1994 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/23/94 Initial revision DESCRIPTION: This file contains C interface routines for the geode routines $Id: spellC.asm,v 1.1 97/04/07 11:05:53 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetGeosConvention C_SpellCode segment resource COMMENT @---------------------------------------------------------------------- C FUNCTION: ICCheckWord C DECLARATION: extern SpellResult _far _pascal ICCheckWord(MemHandle icBuff, char *lookupWord); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICCHECKWORD proc far icBuff:hptr, lookupWord:fptr uses ds,si .enter mov cx, icBuff lds si, lookupWord call ICCheckWord .leave ret ICCHECKWORD endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICGetTextOffsets C DECLARATION: extern void _far _pascal ICGetTextOffsets(MemHandle icBuff, word *firstOffset, word *lastOffset); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICGETTEXTOFFSETS proc far icBuff:hptr, firstOffset:fptr, lastOffset:fptr uses es,di .enter mov cx, icBuff call ICGetTextOffsets les di, firstOffset stosw les di, lastOffset mov_tr ax, cx stosw .leave ret ICGETTEXTOFFSETS endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICGetErrorFlags C DECLARATION: extern void _far _pascal ICGetErrorFlags(MemHandle icBuff, SpellErrorFlags *errorFlags, SpellErrorFlagsHigh *errorFlagsHigh); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICGETERRORFLAGS proc far icBuff:hptr, errorFlags:fptr, errorFlagsHigh:fptr uses es,di .enter mov cx, icBuff call ICGetErrorFlags les di, errorFlags stosw les di, errorFlagsHigh mov_tr ax, cx stosw .leave ret ICGETERRORFLAGS endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICResetSpellCheck C DECLARATION: extern void _far _pascal ICResetSpellCheck(MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICRESETSPELLCHECK proc far icBuff:hptr .enter mov cx, icBuff call ICResetSpellCheck .leave ret ICRESETSPELLCHECK endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICCheckForEmbeddedPunctuation C DECLARATION: extern Boolean _far _pascal ICCheckForEmbeddedPunctuation( MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICCHECKFOREMBEDDEDPUNCTUATION proc far icBuff:hptr .enter mov bx, icBuff call ICCheckForEmbeddedPunctuation .leave ret ICCHECKFOREMBEDDEDPUNCTUATION endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICGetLanguage C DECLARATION: extern StandardLanguage _far _pascal ICGetLanguage(MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICGETLANGUAGE proc far icBuff:hptr .enter mov bx, icBuff call ICGetLanguage .leave ret ICGETLANGUAGE endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICInit C DECLARATION: extern SpellResult _far _pascal ICInit(MemHandle *icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICINIT proc far icBuffPtr:fptr uses ds, si .enter call ICInit lds si, icBuffPtr mov ds:[si], bx .leave ret ICINIT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICExit C DECLARATION: extern SpellErrors _far _pascal ICExit(MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICEXIT proc far icBuff:hptr .enter mov bx, icBuff call ICExit .leave ret ICEXIT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICStopCheck C DECLARATION: extern void _far _pascal ICStopCheck(MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICSTOPCHECK proc far icBuff:hptr .enter mov bx, icBuff call ICStopCheck .leave ret ICSTOPCHECK endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICSpl C DECLARATION: extern word _far _pascal ICSpl(MemHandle icBuff, char *string); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICSPL proc far icBuff:hptr, string:fptr uses ds,si .enter mov bx, icBuff lds si, string call ICSpl .leave ret ICSPL endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICGetNumAlts C DECLARATION: extern word _far _pascal ICGetNumAlts(MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICGETNUMALTS proc far icBuff:hptr .enter mov bx, icBuff call ICGetNumAlts .leave ret ICGETNUMALTS endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICGetAlternate C DECLARATION: extern void _far _pascal ICGetAlternate(MemHandle icBuff, word index, char *original, char *alternate); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICGETALTERNATE proc far icBuff:hptr, index:word, original:fptr, alternate:fptr uses ds,si,es,di .enter mov ax, index mov bx, icBuff lds si, original les di, alternate call ICGetAlternate .leave ret ICGETALTERNATE endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICIgnore C DECLARATION: extern void _far _pascal ICIgnore(MemHandle icBuff, char *ignoreWord); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICIGNORE proc far icBuff:hptr, ignoreWord:fptr uses ds,si .enter mov bx, icBuff lds si, ignoreWord call ICIgnore .leave ret ICIGNORE endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICAddUser C DECLARATION: extern void _far _pascal ICAddUser(MemHandle icBuff, char *addWord, SpellResult *spellResult, UserResult *userResult); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICADDUSER proc far icBuff:hptr, addWord:fptr, spellResult:fptr, userResult:fptr uses ds,si .enter mov bx, icBuff lds si, addWord call ICAddUser lds si, spellResult mov ds:[si], ax lds si, userResult mov ds:[si], dx .leave ret ICADDUSER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICDeleteUser C DECLARATION: extern void _far _pascal ICDeleteUser(MemHandle icBuff, char *deleteWord, SpellResult *spellResult, UserResult *userResult); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICDELETEUSER proc far icBuff:hptr, deleteWord:fptr, spellResult:fptr, userResult:fptr uses ds,si .enter mov bx, icBuff lds si, deleteWord call ICDeleteUser lds si, spellResult mov ds:[si], ax lds si, userResult mov ds:[si], dx .leave ret ICDELETEUSER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICBuildUserList C DECLARATION: extern MemHandle _far _pascal ICBuildUserList(MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICBUILDUSERLIST proc far icBuff:hptr .enter mov bx, icBuff call ICBuildUserList mov_tr ax, bx .leave ret ICBUILDUSERLIST endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICResetIgnore C DECLARATION: extern void _far _pascal ICGetAlternate(MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICRESETIGNORE proc far icBuff:hptr .enter mov bx, icBuff call ICResetIgnore .leave ret ICRESETIGNORE endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICUpdateUser C DECLARATION: extern void _far _pascal ICUpdateUser(MemHandle icBuff); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICUPDATEUSER proc far icBuff:hptr .enter mov bx, icBuff call ICUpdateUser .leave ret ICUPDATEUSER endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICSetTask C DECLARATION: extern void _far _pascal ICSetTask(MemHandle icBuff, SpellTask spellTask); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 9/94 Initial version ------------------------------------------------------------------------------@ ICSETTASK proc far icBuff:hptr, spellTask:word .enter mov bx, icBuff mov ax, spellTask call ICSetTask .leave ret ICSETTASK endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICGetAnagrams C DECLARATION: extern SpellResult _far _pascal ICGetAnagrams(MemHandle icBuff, char *lookupWord, word minLength); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 10/94 Initial version ------------------------------------------------------------------------------@ ICGETANAGRAMS proc far icBuff:hptr, lookupWord:fptr, minLength:word uses ds,si .enter if NO_ANAGRAM_WILDCARD_IN_SPELL_LIBRARY EC < ERROR ANAGRAMS_AND_WILDCARDS_NOT_SUPPORTED > else mov bx, icBuff mov cx, minLength lds si, lookupWord call ICGetAnagrams endif .leave ret ICGETANAGRAMS endp COMMENT @---------------------------------------------------------------------- C FUNCTION: ICGetWildcards C DECLARATION: extern SpellResult _far _pascal ICGetWildcards(MemHandle icBuff, char *lookupWord); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Joon 10/94 Initial version ------------------------------------------------------------------------------@ ICGETWILDCARDS proc far icBuff:hptr, lookupWord:fptr uses ds,si .enter if NO_ANAGRAM_WILDCARD_IN_SPELL_LIBRARY EC < ERROR ANAGRAMS_AND_WILDCARDS_NOT_SUPPORTED > else mov bx, icBuff lds si, lookupWord call ICGetWildcards endif .leave ret ICGETWILDCARDS endp C_SpellCode ends SetDefaultConvention
;; last edit date: 2016/10/25 ;; author: Forec ;; LICENSE ;; Copyright (c) 2015-2017, Forec <forec@bupt.edu.cn> ;; Permission to use, copy, modify, and/or distribute this code for any ;; purpose with or without fee is hereby granted, provided that the above ;; copyright notice and this permission notice appear in all copies. ;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. title forec_t28 .model small .data an dw ? bn dw ? cn dw ? dn dw ? .code start: mov ax, @data mov ds, ax mov es, ax mov ax, an mov bx, bn mov cx, cn cmp ax, 00h jz zero cmp bx, 00h jz zero cmp cx, 00h jz zero mov dx, 00h add dx, ax add dx, bx add dx, cx mov dn, dx jmp quit zero: mov dn, 00h quit: mov ah, 4ch int 21h end start
#pragma comment(linker, "/STACK:102400000,102400000") #pragma GCC optimize ("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef vector<int> vi; const int maxn = 1e6+5; const int mod = 1e9+7; const ll INF = 2e15; const double PI = acos(-1.0); #define lson x << 1, l, mid #define rson x << 1 | 1, mid + 1, r const int lowbit(int x) { return x&-x; } #define in freopen("in.txt","r",stdin) std::map<int, int> mp; double g(int spq,int s,int p,int q) { double k = 1.0 * (p + q) - 2.0 * PI; // std::cout << "k=" << k << '\n'; double k1 = 1.0 * ( (s + q) * (s + q) + (s + p) * (s + p) - k * k ) / (2.0 * (s + q) * (s + p)); // std::cout << "k1 = " << k1 << '\n'; double k2 = 1.0 * ((s + q) * (s + q) + k * k - (s + p) * (s + p) ) / (2.0 * k * (s + q)); // std::cout << "k2=" << k2 << '\n'; double k3 = acos(k1); // std::cout << "k3=" << k3 << '\n'; double k4 = acos(k2); // std::cout << "k4=" << k4 << '\n'; double k5 = s * (k3 + k4) / PI; double k6 = k4 * spq / PI; double k7 = p * (0.5 - k3 / (2.0 * PI)); double res = 2.0 * k7 - k6 - k5; double ans = p - res; // std::cout << "ans=" << ans << '\n'; return (int)ans; } int G(int n) { int ans = 0; for(int s = 5;s <= n; s++) { for(int p = 5 ;p <= n - s; p++) { for(int q = p + 1; p < q && s + p + q <= n; q++) { ans += g(s + p + q , s , p, q); } } } return ans; } int main(int argc, char const *argv[]) { if(g(16,5,5,6) != 9) { std::cout << "fuck!" << '\n'; exit(0); } else { std::cout << "OK...g(16,5,5,6) = 9" << '\n'; } std::cout << G(16) << '\n'; std::cout << G(20) << '\n'; std::cout << G(500) << '\n'; cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; return 0; }
GLOBAL get_x_resolution GLOBAL get_y_resolution section .text get_x_resolution: mov ax, [5084h] ret get_y_resolution: mov ax, [5086h] ret
/* $Id: RTUtf16PrintHexBytes.cpp 69111 2017-10-17 14:26:02Z vboxsync $ */ /** @file * IPRT - RTUtf16PrintHexBytes. */ /* * Copyright (C) 2009-2017 Oracle Corporation * * This file is part of VirtualBox Open Source Edition (OSE), as * available from http://www.virtualbox.org. This file is free software; * you can redistribute it and/or modify it under the terms of the GNU * General Public License (GPL) as published by the Free Software * Foundation, in version 2 as it comes in the "COPYING" file of the * VirtualBox OSE distribution. VirtualBox OSE is distributed in the * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. * * The contents of this file may alternatively be used under the terms * of the Common Development and Distribution License Version 1.0 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the * VirtualBox OSE distribution, in which case the provisions of the * CDDL are applicable instead of those of the GPL. * * You may elect to license modified versions of this file under the * terms and conditions of either the GPL or the CDDL or both. */ /********************************************************************************************************************************* * Header Files * *********************************************************************************************************************************/ #include "internal/iprt.h" #include <iprt/string.h> #include <iprt/assert.h> #include <iprt/err.h> RTDECL(int) RTUtf16PrintHexBytes(PRTUTF16 pwszBuf, size_t cwcBuf, void const *pv, size_t cb, uint32_t fFlags) { AssertReturn(!(fFlags & ~RTSTRPRINTHEXBYTES_F_UPPER), VERR_INVALID_PARAMETER); AssertPtrReturn(pwszBuf, VERR_INVALID_POINTER); AssertReturn(cb * 2 >= cb, VERR_BUFFER_OVERFLOW); AssertReturn(cwcBuf >= cb * 2 + 1, VERR_BUFFER_OVERFLOW); if (cb) AssertPtrReturn(pv, VERR_INVALID_POINTER); static char const s_szHexDigitsLower[17] = "0123456789abcdef"; static char const s_szHexDigitsUpper[17] = "0123456789ABCDEF"; const char *pszHexDigits = !(fFlags & RTSTRPRINTHEXBYTES_F_UPPER) ? s_szHexDigitsLower : s_szHexDigitsUpper; uint8_t const *pb = (uint8_t const *)pv; while (cb-- > 0) { uint8_t b = *pb++; *pwszBuf++ = pszHexDigits[b >> 4]; *pwszBuf++ = pszHexDigits[b & 0xf]; } *pwszBuf = '\0'; return VINF_SUCCESS; }
/* * Automatically Generated from Mathematica. * Fri 5 Nov 2021 16:19:56 GMT-04:00 */ #ifdef MATLAB_MEX_FILE #include <stdexcept> #include <cmath> #include<math.h> /** * Copied from Wolfram Mathematica C Definitions file mdefs.hpp * Changed marcos to inline functions (Eric Cousineau) */ inline double Power(double x, double y) { return pow(x, y); } inline double Sqrt(double x) { return sqrt(x); } inline double Abs(double x) { return fabs(x); } inline double Exp(double x) { return exp(x); } inline double Log(double x) { return log(x); } inline double Sin(double x) { return sin(x); } inline double Cos(double x) { return cos(x); } inline double Tan(double x) { return tan(x); } inline double ArcSin(double x) { return asin(x); } inline double ArcCos(double x) { return acos(x); } inline double ArcTan(double x) { return atan(x); } /* update ArcTan function to use atan2 instead. */ inline double ArcTan(double x, double y) { return atan2(y,x); } inline double Sinh(double x) { return sinh(x); } inline double Cosh(double x) { return cosh(x); } inline double Tanh(double x) { return tanh(x); } const double E = 2.71828182845904523536029; const double Pi = 3.14159265358979323846264; const double Degree = 0.01745329251994329576924; inline double Sec(double x) { return 1/cos(x); } inline double Csc(double x) { return 1/sin(x); } #endif /* * Sub functions */ static void output1(double *p_output1,const double *var1,const double *var2) { double _NotUsed; NULL; p_output1[0]=1; p_output1[1]=-1; p_output1[2]=1; p_output1[3]=-1; p_output1[4]=1; p_output1[5]=-1; p_output1[6]=1; p_output1[7]=-1; p_output1[8]=1; p_output1[9]=-1; p_output1[10]=1; p_output1[11]=-1; p_output1[12]=1; p_output1[13]=-1; p_output1[14]=1; p_output1[15]=-1; p_output1[16]=1; p_output1[17]=-1; p_output1[18]=1; p_output1[19]=-1; p_output1[20]=1; p_output1[21]=-1; p_output1[22]=1; p_output1[23]=-1; p_output1[24]=1; p_output1[25]=-1; p_output1[26]=1; p_output1[27]=-1; p_output1[28]=1; p_output1[29]=-1; p_output1[30]=1; p_output1[31]=-1; p_output1[32]=1; p_output1[33]=-1; p_output1[34]=1; p_output1[35]=-1; p_output1[36]=1; p_output1[37]=-1; p_output1[38]=1; p_output1[39]=-1; p_output1[40]=1; p_output1[41]=-1; p_output1[42]=1; p_output1[43]=-1; p_output1[44]=1; p_output1[45]=-1; p_output1[46]=1; p_output1[47]=-1; p_output1[48]=1; p_output1[49]=-1; p_output1[50]=1; p_output1[51]=-1; p_output1[52]=1; p_output1[53]=-1; p_output1[54]=1; p_output1[55]=-1; p_output1[56]=1; p_output1[57]=-1; p_output1[58]=1; p_output1[59]=-1; p_output1[60]=1; p_output1[61]=-1; p_output1[62]=1; p_output1[63]=-1; p_output1[64]=1; p_output1[65]=-1; p_output1[66]=1; p_output1[67]=-1; p_output1[68]=1; p_output1[69]=-1; p_output1[70]=1; p_output1[71]=-1; } #ifdef MATLAB_MEX_FILE #include "mex.h" /* * Main function */ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { size_t mrows, ncols; double *var1,*var2; double *p_output1; /* Check for proper number of arguments. */ if( nrhs != 2) { mexErrMsgIdAndTxt("MATLAB:MShaped:invalidNumInputs", "Two input(s) required (var1,var2)."); } else if( nlhs > 1) { mexErrMsgIdAndTxt("MATLAB:MShaped:maxlhs", "Too many output arguments."); } /* The input must be a noncomplex double vector or scaler. */ mrows = mxGetM(prhs[0]); ncols = mxGetN(prhs[0]); if( !mxIsDouble(prhs[0]) || mxIsComplex(prhs[0]) || ( !(mrows == 36 && ncols == 1) && !(mrows == 1 && ncols == 36))) { mexErrMsgIdAndTxt( "MATLAB:MShaped:inputNotRealVector", "var1 is wrong."); } mrows = mxGetM(prhs[1]); ncols = mxGetN(prhs[1]); if( !mxIsDouble(prhs[1]) || mxIsComplex(prhs[1]) || ( !(mrows == 36 && ncols == 1) && !(mrows == 1 && ncols == 36))) { mexErrMsgIdAndTxt( "MATLAB:MShaped:inputNotRealVector", "var2 is wrong."); } /* Assign pointers to each input. */ var1 = mxGetPr(prhs[0]); var2 = mxGetPr(prhs[1]); /* Create matrices for return arguments. */ plhs[0] = mxCreateDoubleMatrix((mwSize) 72, (mwSize) 1, mxREAL); p_output1 = mxGetPr(plhs[0]); /* Call the calculation subroutine. */ output1(p_output1,var1,var2); } #else // MATLAB_MEX_FILE #include "J_xPlusCont_LeftImpact.hh" namespace LeftImpact { void J_xPlusCont_LeftImpact_raw(double *p_output1, const double *var1,const double *var2) { // Call Subroutines output1(p_output1, var1, var2); } } #endif // MATLAB_MEX_FILE
; A304685: a(n) = A000699(n) (mod 3). ; Submitted by Jamie Morken(s2) ; 1,1,1,0,2,1,0,0,1,0,0,0,0,1,2,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,1,0,0,2,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 mov $1,52122 sub $1,$0 mul $1,2 bin $1,$0 mod $1,3 mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_WC_ht+0x9741, %rsi lea addresses_normal_ht+0x11f41, %rdi and %rax, %rax mov $24, %rcx rep movsw xor $60928, %r9 lea addresses_A_ht+0xc9c1, %r9 clflush (%r9) nop nop xor %rcx, %rcx movl $0x61626364, (%r9) nop nop nop cmp %rax, %rax lea addresses_WC_ht+0x13f41, %r14 nop nop nop nop nop add $736, %rsi movb $0x61, (%r14) inc %r9 lea addresses_WT_ht+0x1b741, %r14 nop nop and $29615, %rcx mov $0x6162636465666768, %rsi movq %rsi, %xmm0 movups %xmm0, (%r14) nop nop nop nop and $41838, %rax lea addresses_WT_ht+0x12f41, %r14 nop nop sub $40155, %rcx movw $0x6162, (%r14) nop nop nop sub $62669, %r14 lea addresses_WC_ht+0x164c9, %rcx xor %r15, %r15 mov (%rcx), %rdi nop nop nop nop sub $45735, %r14 lea addresses_WT_ht+0xcd4d, %rcx clflush (%rcx) nop nop nop and $48332, %r9 movw $0x6162, (%rcx) nop nop nop nop inc %r9 lea addresses_WT_ht+0xf941, %rax clflush (%rax) nop nop nop nop nop cmp %r15, %r15 mov $0x6162636465666768, %r14 movq %r14, %xmm3 vmovups %ymm3, (%rax) and %rsi, %rsi lea addresses_A_ht+0x2341, %rcx clflush (%rcx) nop nop dec %r14 mov (%rcx), %r9w nop cmp $9002, %rax lea addresses_WC_ht+0x19251, %rax nop dec %rdi mov (%rax), %esi dec %r14 lea addresses_D_ht+0x1b0f9, %r9 nop nop xor %rdi, %rdi and $0xffffffffffffffc0, %r9 movntdqa (%r9), %xmm5 vpextrq $1, %xmm5, %r15 nop and %r14, %r14 lea addresses_A_ht+0xa12c, %rcx nop nop nop nop nop dec %rdi and $0xffffffffffffffc0, %rcx vmovaps (%rcx), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %r15 nop nop nop add %r15, %r15 lea addresses_WT_ht+0x4239, %r14 nop nop nop nop xor $27086, %rdi mov $0x6162636465666768, %rcx movq %rcx, (%r14) nop nop nop nop dec %rax pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r15 pop %r14 ret .global s_faulty_load s_faulty_load: push %r10 push %r15 push %r9 push %rax push %rcx push %rsi // Faulty Load lea addresses_D+0xdf41, %rax nop nop nop cmp %r10, %r10 movups (%rax), %xmm5 vpextrq $1, %xmm5, %r9 lea oracles, %rsi and $0xff, %r9 shlq $12, %r9 mov (%rsi,%r9,1), %r9 pop %rsi pop %rcx pop %rax pop %r9 pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 4, 'type': 'addresses_D', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_WC_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_A_ht', 'congruent': 5}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT_ht', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WT_ht', 'congruent': 11}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC_ht', 'congruent': 2}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WT_ht', 'congruent': 1}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WT_ht', 'congruent': 9}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_A_ht', 'congruent': 9}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 3}} {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 2}} {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': True, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 0}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT_ht', 'congruent': 3}, 'OP': 'STOR'} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
// $Id: POSIX_Proactor.cpp 86102 2009-07-18 04:15:48Z wotte $ #include "ace/POSIX_Proactor.h" #if defined (ACE_HAS_AIO_CALLS) #if !defined (__ACE_INLINE__) #include "ace/POSIX_Proactor.inl" #endif /* __ACE_INLINE__ */ # if defined (ACE_HAS_SYS_SYSTEMINFO_H) # include /**/ <sys/systeminfo.h> # endif /* ACE_HAS_SYS_SYSTEMINFO_H */ #include "ace/ACE.h" #include "ace/Flag_Manip.h" #include "ace/Task_T.h" #include "ace/Log_Msg.h" #include "ace/Object_Manager.h" #include "ace/OS_NS_sys_socket.h" #include "ace/OS_NS_signal.h" #include "ace/OS_NS_unistd.h" #if defined (sun) # include "ace/OS_NS_strings.h" #endif /* sun */ // ********************************************************************* ACE_BEGIN_VERSIONED_NAMESPACE_DECL /** * @class ACE_POSIX_Wakeup_Completion * * This result object is used by the <end_event_loop> of the * ACE_Proactor interface to wake up all the threads blocking * for completions. */ class ACE_POSIX_Wakeup_Completion : public ACE_POSIX_Asynch_Result { public: /// Constructor. ACE_POSIX_Wakeup_Completion (const ACE_Handler::Proxy_Ptr &handler_proxy, const void *act = 0, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN); /// Destructor. virtual ~ACE_POSIX_Wakeup_Completion (void); /// This method calls the <handler>'s <handle_wakeup> method. virtual void complete (size_t bytes_transferred = 0, int success = 1, const void *completion_key = 0, u_long error = 0); }; // ********************************************************************* ACE_POSIX_Proactor::ACE_POSIX_Proactor (void) : os_id_ (ACE_OS_UNDEFINED) { #if defined(sun) os_id_ = ACE_OS_SUN; // set family char Buf [32]; ::memset(Buf,0,sizeof(Buf)); ACE_OS::sysinfo (SI_RELEASE , Buf, sizeof(Buf)-1); if (ACE_OS::strcasecmp (Buf , "5.6") == 0) os_id_ = ACE_OS_SUN_56; else if (ACE_OS::strcasecmp (Buf , "5.7") == 0) os_id_ = ACE_OS_SUN_57; else if (ACE_OS::strcasecmp (Buf , "5.8") == 0) os_id_ = ACE_OS_SUN_58; #elif defined(HPUX) os_id_ = ACE_OS_HPUX; // set family #elif defined(__sgi) os_id_ = ACE_OS_IRIX; // set family #elif defined(__OpenBSD) os_id_ = ACE_OS_OPENBSD; // set family // do the same //#else defined (LINUX, __FreeBSD__ ...) //setup here os_id_ #endif } ACE_POSIX_Proactor::~ACE_POSIX_Proactor (void) { this->close (); } int ACE_POSIX_Proactor::close (void) { return 0; } int ACE_POSIX_Proactor::register_handle (ACE_HANDLE handle, const void *completion_key) { ACE_UNUSED_ARG (handle); ACE_UNUSED_ARG (completion_key); return 0; } int ACE_POSIX_Proactor::wake_up_dispatch_threads (void) { return 0; } int ACE_POSIX_Proactor::close_dispatch_threads (int) { return 0; } size_t ACE_POSIX_Proactor::number_of_threads (void) const { // @@ Implement it. ACE_NOTSUP_RETURN (0); } void ACE_POSIX_Proactor::number_of_threads (size_t threads) { // @@ Implement it. ACE_UNUSED_ARG (threads); } ACE_HANDLE ACE_POSIX_Proactor::get_handle (void) const { return ACE_INVALID_HANDLE; } ACE_Asynch_Read_Stream_Impl * ACE_POSIX_Proactor::create_asynch_read_stream (void) { ACE_Asynch_Read_Stream_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Read_Stream (this), 0); return implementation; } ACE_Asynch_Read_Stream_Result_Impl * ACE_POSIX_Proactor::create_asynch_read_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block &message_block, size_t bytes_to_read, const void* act, ACE_HANDLE event, int priority, int signal_number) { ACE_Asynch_Read_Stream_Result_Impl *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Read_Stream_Result (handler_proxy, handle, message_block, bytes_to_read, act, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Write_Stream_Impl * ACE_POSIX_Proactor::create_asynch_write_stream (void) { ACE_Asynch_Write_Stream_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Write_Stream (this), 0); return implementation; } ACE_Asynch_Write_Stream_Result_Impl * ACE_POSIX_Proactor::create_asynch_write_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block &message_block, size_t bytes_to_write, const void* act, ACE_HANDLE event, int priority, int signal_number) { ACE_Asynch_Write_Stream_Result_Impl *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Write_Stream_Result (handler_proxy, handle, message_block, bytes_to_write, act, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Read_File_Impl * ACE_POSIX_Proactor::create_asynch_read_file (void) { ACE_Asynch_Read_File_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Read_File (this), 0); return implementation; } ACE_Asynch_Read_File_Result_Impl * ACE_POSIX_Proactor::create_asynch_read_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block &message_block, size_t bytes_to_read, const void* act, u_long offset, u_long offset_high, ACE_HANDLE event, int priority, int signal_number) { ACE_Asynch_Read_File_Result_Impl *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Read_File_Result (handler_proxy, handle, message_block, bytes_to_read, act, offset, offset_high, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Write_File_Impl * ACE_POSIX_Proactor::create_asynch_write_file (void) { ACE_Asynch_Write_File_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Write_File (this), 0); return implementation; } ACE_Asynch_Write_File_Result_Impl * ACE_POSIX_Proactor::create_asynch_write_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block &message_block, size_t bytes_to_write, const void* act, u_long offset, u_long offset_high, ACE_HANDLE event, int priority, int signal_number) { ACE_Asynch_Write_File_Result_Impl *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Write_File_Result (handler_proxy, handle, message_block, bytes_to_write, act, offset, offset_high, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Read_Dgram_Impl * ACE_POSIX_Proactor::create_asynch_read_dgram (void) { ACE_Asynch_Read_Dgram_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Read_Dgram (this), 0); return implementation; } ACE_Asynch_Read_Dgram_Result_Impl * ACE_POSIX_Proactor::create_asynch_read_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block *message_block, size_t bytes_to_read, int flags, int protocol_family, const void* act, ACE_HANDLE event , int priority , int signal_number) { ACE_Asynch_Read_Dgram_Result_Impl *implementation=0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Read_Dgram_Result(handler_proxy, handle, message_block, bytes_to_read, flags, protocol_family, act, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Write_Dgram_Impl * ACE_POSIX_Proactor::create_asynch_write_dgram (void) { ACE_Asynch_Write_Dgram_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Write_Dgram (this), 0); return implementation; } ACE_Asynch_Write_Dgram_Result_Impl * ACE_POSIX_Proactor::create_asynch_write_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block *message_block, size_t bytes_to_write, int flags, const void* act, ACE_HANDLE event, int priority , int signal_number) { ACE_Asynch_Write_Dgram_Result_Impl *implementation=0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Write_Dgram_Result(handler_proxy, handle, message_block, bytes_to_write, flags, act, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Accept_Impl * ACE_POSIX_Proactor::create_asynch_accept (void) { ACE_Asynch_Accept_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Accept (this), 0); return implementation; } ACE_Asynch_Accept_Result_Impl * ACE_POSIX_Proactor::create_asynch_accept_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE listen_handle, ACE_HANDLE accept_handle, ACE_Message_Block &message_block, size_t bytes_to_read, const void* act, ACE_HANDLE event, int priority, int signal_number) { ACE_Asynch_Accept_Result_Impl *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Accept_Result (handler_proxy, listen_handle, accept_handle, message_block, bytes_to_read, act, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Connect_Impl * ACE_POSIX_Proactor::create_asynch_connect (void) { ACE_Asynch_Connect_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Connect (this), 0); return implementation; } ACE_Asynch_Connect_Result_Impl * ACE_POSIX_Proactor::create_asynch_connect_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE connect_handle, const void* act, ACE_HANDLE event, int priority, int signal_number) { ACE_Asynch_Connect_Result_Impl *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Connect_Result (handler_proxy, connect_handle, act, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Transmit_File_Impl * ACE_POSIX_Proactor::create_asynch_transmit_file (void) { ACE_Asynch_Transmit_File_Impl *implementation = 0; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Transmit_File (this), 0); return implementation; } ACE_Asynch_Transmit_File_Result_Impl * ACE_POSIX_Proactor::create_asynch_transmit_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE socket, ACE_HANDLE file, ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, size_t bytes_to_write, u_long offset, u_long offset_high, size_t bytes_per_send, u_long flags, const void *act, ACE_HANDLE event, int priority, int signal_number) { ACE_Asynch_Transmit_File_Result_Impl *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Transmit_File_Result (handler_proxy, socket, file, header_and_trailer, bytes_to_write, offset, offset_high, bytes_per_send, flags, act, event, priority, signal_number), 0); return implementation; } ACE_Asynch_Result_Impl * ACE_POSIX_Proactor::create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy, const void *act, const ACE_Time_Value &tv, ACE_HANDLE event, int priority, int signal_number) { ACE_POSIX_Asynch_Timer *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Timer (handler_proxy, act, tv, event, priority, signal_number), 0); return implementation; } #if 0 int ACE_POSIX_Proactor::handle_signal (int, siginfo_t *, ucontext_t *) { // Perform a non-blocking "poll" for all the I/O events that have // completed in the I/O completion queue. ACE_Time_Value timeout (0, 0); int result = 0; for (;;) { result = this->handle_events (timeout); if (result != 0 || errno == ETIME) break; } // If our handle_events failed, we'll report a failure to the // Reactor. return result == -1 ? -1 : 0; } int ACE_POSIX_Proactor::handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) { ACE_UNUSED_ARG (close_mask); ACE_UNUSED_ARG (handle); return this->close (); } #endif /* 0 */ void ACE_POSIX_Proactor::application_specific_code (ACE_POSIX_Asynch_Result *asynch_result, size_t bytes_transferred, const void */* completion_key*/, u_long error) { ACE_SEH_TRY { // Call completion hook asynch_result->complete (bytes_transferred, error ? 0 : 1, 0, // No completion key. error); } ACE_SEH_FINALLY { // This is crucial to prevent memory leaks delete asynch_result; } } int ACE_POSIX_Proactor::post_wakeup_completions (int how_many) { ACE_POSIX_Wakeup_Completion *wakeup_completion = 0; for (int ci = 0; ci < how_many; ci++) { ACE_NEW_RETURN (wakeup_completion, ACE_POSIX_Wakeup_Completion (this->wakeup_handler_.proxy ()), -1); if (this->post_completion (wakeup_completion) == -1) return -1; } return 0; } ACE_POSIX_Proactor::Proactor_Type ACE_POSIX_Proactor::get_impl_type (void) { return PROACTOR_POSIX; } /** * @class ACE_AIOCB_Notify_Pipe_Manager * * @brief This class manages the notify pipe of the AIOCB Proactor. * * This class acts as the Handler for the * <Asynch_Read> operations issued on the notify pipe. This * class is very useful in implementing <Asynch_Accept> operation * class for the <AIOCB_Proactor>. This is also useful for * implementing <post_completion> for <AIOCB_Proactor>. * <AIOCB_Proactor> class issues a <Asynch_Read> on * the pipe, using this class as the * Handler. <POSIX_Asynch_Result *>'s are sent through the * notify pipe. When <POSIX_Asynch_Result *>'s show up on the * notify pipe, the <POSIX_AIOCB_Proactor> dispatches the * completion of the <Asynch_Read_Stream> and calls the * <handle_read_stream> of this class. This class calls * <complete> on the <POSIX_Asynch_Result *> and thus calls the * application handler. * Handling the MessageBlock: * We give this message block to read the result pointer through * the notify pipe. We expect that to read 4 bytes from the * notify pipe, for each <accept> call. Before giving this * message block to another <accept>, we update <wr_ptr> and put * it in its initial position. */ class ACE_AIOCB_Notify_Pipe_Manager : public ACE_Handler { public: /// Constructor. You need the posix proactor because you need to call /// <application_specific_code> ACE_AIOCB_Notify_Pipe_Manager (ACE_POSIX_AIOCB_Proactor *posix_aiocb_proactor); /// Destructor. virtual ~ACE_AIOCB_Notify_Pipe_Manager (void); /// Send the result pointer through the notification pipe. int notify (); /// This is the call back method when <Asynch_Read> from the pipe is /// complete. virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result); private: /// The implementation proactor class. ACE_POSIX_AIOCB_Proactor *posix_aiocb_proactor_; /// Message block to get ACE_POSIX_Asynch_Result pointer from the pipe. ACE_Message_Block message_block_; /// Pipe for the communication between Proactor and the /// Asynch_Accept/Asynch_Connect and other post_completions ACE_Pipe pipe_; /// To do asynch_read on the pipe. ACE_POSIX_Asynch_Read_Stream read_stream_; /// Default constructor. Shouldnt be called. ACE_AIOCB_Notify_Pipe_Manager (void); }; ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager (ACE_POSIX_AIOCB_Proactor *posix_aiocb_proactor) : posix_aiocb_proactor_ (posix_aiocb_proactor), message_block_ (sizeof (2)), read_stream_ (posix_aiocb_proactor) { // Open the pipe. this->pipe_.open (); // Set write side in NONBLOCK mode ACE::set_flags (this->pipe_.write_handle (), ACE_NONBLOCK); // Set read side in BLOCK mode ACE::clr_flags (this->pipe_.read_handle (), ACE_NONBLOCK); // Let AIOCB_Proactor know about our handle posix_aiocb_proactor_->set_notify_handle (this->pipe_.read_handle ()); // Open the read stream. if (this->read_stream_.open (this->proxy (), this->pipe_.read_handle (), 0, // Completion Key 0) // Proactor == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT("%N:%l:%p\n"), ACE_TEXT("ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager:") ACE_TEXT("Open on Read Stream failed"))); // Issue an asynch_read on the read_stream of the notify pipe. if (this->read_stream_.read (this->message_block_, 1, // enough to read 1 byte 0, // ACT 0) // Priority == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT("%N:%l:%p\n"), ACE_TEXT("ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager:") ACE_TEXT("Read from pipe failed"))); } ACE_AIOCB_Notify_Pipe_Manager::~ACE_AIOCB_Notify_Pipe_Manager (void) { // 1. try to cancel pending aio this->read_stream_.cancel (); // 2. close both handles // Destuctor of ACE_Pipe does not close handles. // We can not use ACE_Pipe::close() as it // closes read_handle and than write_handle. // In some systems close() may wait for // completion for all asynch. pending requests. // So we should close write_handle firstly // to force read completion ( if 1. does not help ) // and then read_handle and not vice versa ACE_HANDLE h = this->pipe_.write_handle (); if (h != ACE_INVALID_HANDLE) ACE_OS::closesocket (h); h = this->pipe_.read_handle (); if ( h != ACE_INVALID_HANDLE) ACE_OS::closesocket (h); } int ACE_AIOCB_Notify_Pipe_Manager::notify () { // Send the result pointer through the pipe. char char_send = 0; ssize_t ret_val = ACE::send (this->pipe_.write_handle (), &char_send, sizeof (char_send)); if (ret_val < 0) { if (errno != EWOULDBLOCK) #if 0 ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P %t):%p\n"), ACE_TEXT ("ACE_AIOCB_Notify_Pipe_Manager::notify") ACE_TEXT ("Error:Writing on to notify pipe failed"))); #endif /* 0 */ return -1; } return 0; } void ACE_AIOCB_Notify_Pipe_Manager::handle_read_stream (const ACE_Asynch_Read_Stream::Result & /*result*/) { // 1. Start new read to avoid pipe overflow // Set the message block properly. Put the <wr_ptr> back in the // initial position. if (this->message_block_.length () > 0) this->message_block_.wr_ptr (this->message_block_.rd_ptr ()); // One accept has completed. Issue a read to handle any // <post_completion>s in the future. if (-1 == this->read_stream_.read (this->message_block_, 1, // enough to read 1 byte 0, // ACT 0)) // Priority ACE_ERROR ((LM_ERROR, ACE_TEXT ("%N:%l:(%P | %t):%p\n"), ACE_TEXT ("ACE_AIOCB_Notify_Pipe_Manager::handle_read_stream:") ACE_TEXT ("Read from pipe failed"))); // 2. Do the upcalls // this->posix_aiocb_proactor_->process_result_queue (); } // Public constructor for common use. ACE_POSIX_AIOCB_Proactor::ACE_POSIX_AIOCB_Proactor (size_t max_aio_operations) : aiocb_notify_pipe_manager_ (0), aiocb_list_ (0), result_list_ (0), aiocb_list_max_size_ (max_aio_operations), aiocb_list_cur_size_ (0), notify_pipe_read_handle_ (ACE_INVALID_HANDLE), num_deferred_aiocb_ (0), num_started_aio_ (0) { // Check for correct value for max_aio_operations check_max_aio_num (); this->create_result_aiocb_list (); this->create_notify_manager (); // start pseudo-asynchronous accept task // one per all future acceptors this->get_asynch_pseudo_task().start (); } // Special protected constructor for ACE_SUN_Proactor ACE_POSIX_AIOCB_Proactor::ACE_POSIX_AIOCB_Proactor (size_t max_aio_operations, ACE_POSIX_Proactor::Proactor_Type) : aiocb_notify_pipe_manager_ (0), aiocb_list_ (0), result_list_ (0), aiocb_list_max_size_ (max_aio_operations), aiocb_list_cur_size_ (0), notify_pipe_read_handle_ (ACE_INVALID_HANDLE), num_deferred_aiocb_ (0), num_started_aio_ (0) { //check for correct value for max_aio_operations this->check_max_aio_num (); this->create_result_aiocb_list (); // @@ We should create Notify_Pipe_Manager in the derived class to // provide correct calls for virtual functions !!! } // Destructor. ACE_POSIX_AIOCB_Proactor::~ACE_POSIX_AIOCB_Proactor (void) { this->close(); } ACE_POSIX_Proactor::Proactor_Type ACE_POSIX_AIOCB_Proactor::get_impl_type (void) { return PROACTOR_AIOCB; } int ACE_POSIX_AIOCB_Proactor::close (void) { // stop asynch accept task this->get_asynch_pseudo_task().stop (); this->delete_notify_manager (); this->clear_result_queue (); return this->delete_result_aiocb_list (); } void ACE_POSIX_AIOCB_Proactor::set_notify_handle (ACE_HANDLE h) { notify_pipe_read_handle_ = h; } int ACE_POSIX_AIOCB_Proactor::create_result_aiocb_list (void) { if (aiocb_list_ != 0) return 0; ACE_NEW_RETURN (aiocb_list_, aiocb *[aiocb_list_max_size_], -1); ACE_NEW_RETURN (result_list_, ACE_POSIX_Asynch_Result *[aiocb_list_max_size_], -1); // Initialize the array. for (size_t ai = 0; ai < this->aiocb_list_max_size_; ai++) { aiocb_list_[ai] = 0; result_list_[ai] = 0; } return 0; } int ACE_POSIX_AIOCB_Proactor::delete_result_aiocb_list (void) { if (aiocb_list_ == 0) // already deleted return 0; size_t ai; // Try to cancel all uncompleted operations; POSIX systems may have // hidden system threads that still can work with our aiocbs! for (ai = 0; ai < aiocb_list_max_size_; ai++) if (this->aiocb_list_[ai] != 0) // active operation this->cancel_aiocb (result_list_[ai]); int num_pending = 0; for (ai = 0; ai < aiocb_list_max_size_; ai++) { if (this->aiocb_list_[ai] == 0 ) // not active operation continue; // Get the error and return status of the aio_ operation. int error_status = 0; size_t transfer_count = 0; int flg_completed = this->get_result_status (result_list_[ai], error_status, transfer_count); //don't delete uncompleted AIOCB's if (flg_completed == 0) // not completed !!! { num_pending++; #if 0 char * errtxt = ACE_OS::strerror (error_status); if (errtxt == 0) errtxt ="?????????"; char * op = (aiocb_list_[ai]->aio_lio_opcode == LIO_WRITE )? "WRITE":"READ" ; ACE_ERROR ((LM_ERROR, ACE_TEXT("slot=%d op=%s status=%d xfercnt=%d %s\n"), ai, op, error_status, transfer_count, errtxt)); #endif /* 0 */ } else // completed , OK { delete this->result_list_[ai]; this->result_list_[ai] = 0; this->aiocb_list_[ai] = 0; } } // If it is not possible cancel some operation (num_pending > 0 ), // we can do only one thing -report about this // and complain about POSIX implementation. // We know that we have memory leaks, but it is better than // segmentation fault! ACE_DEBUG ((LM_DEBUG, ACE_TEXT("ACE_POSIX_AIOCB_Proactor::delete_result_aiocb_list\n") ACE_TEXT(" number pending AIO=%d\n"), num_pending)); delete [] this->aiocb_list_; this->aiocb_list_ = 0; delete [] this->result_list_; this->result_list_ = 0; return (num_pending == 0 ? 0 : -1); // ?? or just always return 0; } void ACE_POSIX_AIOCB_Proactor::check_max_aio_num () { long max_os_aio_num = ACE_OS::sysconf (_SC_AIO_MAX); // Define max limit AIO's for concrete OS // -1 means that there is no limit, but it is not true // (example, SunOS 5.6) if (max_os_aio_num > 0 && aiocb_list_max_size_ > (unsigned long) max_os_aio_num) aiocb_list_max_size_ = max_os_aio_num; #if defined (HPUX) || defined (__FreeBSD__) // Although HPUX 11.00 allows to start 2048 AIO's for all process in // system it has a limit 256 max elements for aio_suspend () It is a // pity, but ... long max_os_listio_num = ACE_OS::sysconf (_SC_AIO_LISTIO_MAX); if (max_os_listio_num > 0 && aiocb_list_max_size_ > (unsigned long) max_os_listio_num) aiocb_list_max_size_ = max_os_listio_num; #endif /* HPUX || __FreeBSD__ */ // check for user-defined value // ACE_AIO_MAX_SIZE if defined in POSIX_Proactor.h if (aiocb_list_max_size_ <= 0 || aiocb_list_max_size_ > ACE_AIO_MAX_SIZE) aiocb_list_max_size_ = ACE_AIO_MAX_SIZE; // check for max number files to open int max_num_files = ACE::max_handles (); if (max_num_files > 0 && aiocb_list_max_size_ > (unsigned long) max_num_files) { ACE::set_handle_limit (aiocb_list_max_size_); max_num_files = ACE::max_handles (); } if (max_num_files > 0 && aiocb_list_max_size_ > (unsigned long) max_num_files) aiocb_list_max_size_ = (unsigned long) max_num_files; ACE_DEBUG ((LM_DEBUG, "(%P | %t) ACE_POSIX_AIOCB_Proactor::Max Number of AIOs=%d\n", aiocb_list_max_size_)); #if defined(__sgi) ACE_DEBUG((LM_DEBUG, ACE_TEXT( "SGI IRIX specific: aio_init!\n"))); //typedef struct aioinit { // int aio_threads; /* The number of aio threads to start (5) */ // int aio_locks; /* Initial number of preallocated locks (3) */ // int aio_num; /* estimated total simultanious aiobc structs (1000) */ // int aio_usedba; /* Try to use DBA for raw I/O in lio_listio (0) */ // int aio_debug; /* turn on debugging (0) */ // int aio_numusers; /* max number of user sprocs making aio_* calls (5) */ // int aio_reserved[3]; //} aioinit_t; aioinit_t aioinit; aioinit.aio_threads = 10; /* The number of aio threads to start (5) */ aioinit.aio_locks = 20; /* Initial number of preallocated locks (3) */ /* estimated total simultaneous aiobc structs (1000) */ aioinit.aio_num = aiocb_list_max_size_; aioinit.aio_usedba = 0; /* Try to use DBA for raw IO in lio_listio (0) */ aioinit.aio_debug = 0; /* turn on debugging (0) */ aioinit.aio_numusers = 100; /* max number of user sprocs making aio_* calls (5) */ aioinit.aio_reserved[0] = 0; aioinit.aio_reserved[1] = 0; aioinit.aio_reserved[2] = 0; aio_sgi_init (&aioinit); #endif return; } void ACE_POSIX_AIOCB_Proactor::create_notify_manager (void) { // Remember! this issues a Asynch_Read // on the notify pipe for doing the Asynch_Accept/Connect. if (aiocb_notify_pipe_manager_ == 0) ACE_NEW (aiocb_notify_pipe_manager_, ACE_AIOCB_Notify_Pipe_Manager (this)); } void ACE_POSIX_AIOCB_Proactor::delete_notify_manager (void) { // We are responsible for delete as all pointers set to 0 after // delete, it is save to delete twice delete aiocb_notify_pipe_manager_; aiocb_notify_pipe_manager_ = 0; } int ACE_POSIX_AIOCB_Proactor::handle_events (ACE_Time_Value &wait_time) { // Decrement <wait_time> with the amount of time spent in the method ACE_Countdown_Time countdown (&wait_time); return this->handle_events_i (wait_time.msec ()); } int ACE_POSIX_AIOCB_Proactor::handle_events (void) { return this->handle_events_i (ACE_INFINITE); } int ACE_POSIX_AIOCB_Proactor::notify_completion(int sig_num) { ACE_UNUSED_ARG (sig_num); return this->aiocb_notify_pipe_manager_->notify (); } int ACE_POSIX_AIOCB_Proactor::post_completion (ACE_POSIX_Asynch_Result *result) { ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1)); int ret_val = this->putq_result (result); return ret_val; } int ACE_POSIX_AIOCB_Proactor::putq_result (ACE_POSIX_Asynch_Result *result) { // this protected method should be called with locked mutex_ // we can't use GUARD as Proactor uses non-recursive mutex if (!result) return -1; int sig_num = result->signal_number (); int ret_val = this->result_queue_.enqueue_tail (result); if (ret_val == -1) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:ACE_POSIX_AIOCB_Proactor::putq_result failed\n"), -1); this->notify_completion (sig_num); return 0; } ACE_POSIX_Asynch_Result * ACE_POSIX_AIOCB_Proactor::getq_result (void) { ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, 0)); ACE_POSIX_Asynch_Result* result = 0; if (this->result_queue_.dequeue_head (result) != 0) return 0; // don't waste time if queue is empty - it is normal // or check queue size before dequeue_head // ACE_ERROR_RETURN ((LM_ERROR, // ACE_TEXT("%N:%l:(%P | %t):%p\n"), // ACE_TEXT("ACE_POSIX_AIOCB_Proactor::getq_result failed")), // 0); return result; } int ACE_POSIX_AIOCB_Proactor::clear_result_queue (void) { int ret_val = 0; ACE_POSIX_Asynch_Result* result = 0; while ((result = this->getq_result ()) != 0) { delete result; ret_val++; } return ret_val; } int ACE_POSIX_AIOCB_Proactor::process_result_queue (void) { int ret_val = 0; ACE_POSIX_Asynch_Result* result = 0; while ((result = this->getq_result ()) != 0) { this->application_specific_code (result, result->bytes_transferred(), // 0, No bytes transferred. 0, // No completion key. result->error()); //0, No error. ret_val++; } return ret_val; } int ACE_POSIX_AIOCB_Proactor::handle_events_i (u_long milli_seconds) { int result_suspend = 0; int retval= 0; if (milli_seconds == ACE_INFINITE) // Indefinite blocking. result_suspend = aio_suspend (aiocb_list_, aiocb_list_max_size_, 0); else { // Block on <aio_suspend> for <milli_seconds> timespec timeout; timeout.tv_sec = milli_seconds / 1000; timeout.tv_nsec = (milli_seconds - (timeout.tv_sec * 1000)) * 1000000; result_suspend = aio_suspend (aiocb_list_, aiocb_list_max_size_, &timeout); } // Check for errors if (result_suspend == -1) { if (errno != EAGAIN && // Timeout errno != EINTR ) // Interrupted call ACE_ERROR ((LM_ERROR, ACE_TEXT ("%N:%l:(%P|%t)::%p\n"), ACE_TEXT ("handle_events: aio_suspend failed"))); // let continue work // we should check "post_completed" queue } else { size_t index = 0; size_t count = aiocb_list_max_size_; // max number to iterate int error_status = 0; size_t transfer_count = 0; for (;; retval++) { ACE_POSIX_Asynch_Result *asynch_result = find_completed_aio (error_status, transfer_count, index, count); if (asynch_result == 0) break; // Call the application code. this->application_specific_code (asynch_result, transfer_count, 0, // No completion key. error_status); } } // process post_completed results retval += this->process_result_queue (); return retval > 0 ? 1 : 0; } int ACE_POSIX_AIOCB_Proactor::get_result_status (ACE_POSIX_Asynch_Result *asynch_result, int &error_status, size_t &transfer_count) { transfer_count = 0; // Get the error status of the aio_ operation. // The following aio_ptr anathema is required to work around a bug in an over-aggressive // optimizer in GCC 4.1.2. aiocb *aio_ptr (asynch_result); error_status = aio_error (aio_ptr); if (error_status == EINPROGRESS) return 0; // not completed ssize_t op_return = aio_return (aio_ptr); if (op_return > 0) transfer_count = static_cast<size_t> (op_return); // else transfer_count is already 0, error_status reports the error. return 1; // completed } ACE_POSIX_Asynch_Result * ACE_POSIX_AIOCB_Proactor::find_completed_aio (int &error_status, size_t &transfer_count, size_t &index, size_t &count) { // parameter index defines initial slot to scan // parameter count tells us how many slots should we scan ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->mutex_, 0)); ACE_POSIX_Asynch_Result *asynch_result = 0; if (num_started_aio_ == 0) // save time return 0; for (; count > 0; index++ , count--) { if (index >= aiocb_list_max_size_) // like a wheel index = 0; if (aiocb_list_[index] == 0) // Dont process null blocks. continue; if (0 != this->get_result_status (result_list_[index], error_status, transfer_count)) // completed break; } // end for if (count == 0) // all processed , nothing found return 0; asynch_result = result_list_[index]; aiocb_list_[index] = 0; result_list_[index] = 0; aiocb_list_cur_size_--; num_started_aio_--; // decrement count active aios index++; // for next iteration count--; // for next iteration this->start_deferred_aio (); //make attempt to start deferred AIO //It is safe as we are protected by mutex_ return asynch_result; } int ACE_POSIX_AIOCB_Proactor::start_aio (ACE_POSIX_Asynch_Result *result, ACE_POSIX_Proactor::Opcode op) { ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::start_aio"); ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->mutex_, -1)); int ret_val = (aiocb_list_cur_size_ >= aiocb_list_max_size_) ? -1 : 0; if (result == 0) // Just check the status of the list return ret_val; // Save operation code in the aiocb switch (op) { case ACE_POSIX_Proactor::ACE_OPCODE_READ: result->aio_lio_opcode = LIO_READ; break; case ACE_POSIX_Proactor::ACE_OPCODE_WRITE: result->aio_lio_opcode = LIO_WRITE; break; default: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%N:%l:(%P|%t)::") ACE_TEXT ("start_aio: Invalid op code %d\n"), op), -1); } if (ret_val != 0) // No free slot { errno = EAGAIN; return -1; } // Find a free slot and store. ssize_t slot = allocate_aio_slot (result); if (slot < 0) return -1; size_t index = static_cast<size_t> (slot); result_list_[index] = result; //Store result ptr anyway aiocb_list_cur_size_++; ret_val = start_aio_i (result); switch (ret_val) { case 0: // started OK aiocb_list_[index] = result; return 0; case 1: // OS AIO queue overflow num_deferred_aiocb_ ++; return 0; default: // Invalid request, there is no point break; // to start it later } result_list_[index] = 0; aiocb_list_cur_size_--; return -1; } ssize_t ACE_POSIX_AIOCB_Proactor::allocate_aio_slot (ACE_POSIX_Asynch_Result *result) { size_t i = 0; // we reserve zero slot for ACE_AIOCB_Notify_Pipe_Manager // so make check for ACE_AIOCB_Notify_Pipe_Manager request if (notify_pipe_read_handle_ == result->aio_fildes) // Notify_Pipe ? { // should be free, if (result_list_[i] != 0) // only 1 request { // is allowed errno = EAGAIN; ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:(%P | %t)::\n" "ACE_POSIX_AIOCB_Proactor::allocate_aio_slot:" "internal Proactor error 0\n"), -1); } } else //try to find free slot as usual, but starting from 1 { for (i= 1; i < this->aiocb_list_max_size_; i++) if (result_list_[i] == 0) break; } if (i >= this->aiocb_list_max_size_) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:(%P | %t)::\n" "ACE_POSIX_AIOCB_Proactor::allocate_aio_slot:" "internal Proactor error 1\n"), -1); //setup OS notification methods for this aio result->aio_sigevent.sigev_notify = SIGEV_NONE; return static_cast<ssize_t> (i); } // start_aio_i has new return codes // 0 AIO was started successfully // 1 AIO was not started, OS AIO queue overflow // -1 AIO was not started, other errors int ACE_POSIX_AIOCB_Proactor::start_aio_i (ACE_POSIX_Asynch_Result *result) { ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::start_aio_i"); int ret_val; const ACE_TCHAR *ptype = 0; // Start IO // The following aio_ptr anathema is required to work around a bug in // the optimizer for GCC 4.1.2 aiocb * aio_ptr (result); switch (result->aio_lio_opcode ) { case LIO_READ : ptype = ACE_TEXT ("read "); ret_val = aio_read (aio_ptr); break; case LIO_WRITE : ptype = ACE_TEXT ("write"); ret_val = aio_write (aio_ptr); break; default: ptype = ACE_TEXT ("?????"); ret_val = -1; break; } if (ret_val == 0) { ++this->num_started_aio_; } else // if (ret_val == -1) { if (errno == EAGAIN || errno == ENOMEM) //Ok, it will be deferred AIO ret_val = 1; else ACE_ERROR ((LM_ERROR, ACE_TEXT ("%N:%l:(%P | %t)::start_aio_i: aio_%s %p\n"), ptype, ACE_TEXT ("queueing failed"))); } return ret_val; } int ACE_POSIX_AIOCB_Proactor::start_deferred_aio () { ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::start_deferred_aio"); // This protected method is called from // find_completed_aio after any AIO completion // We should call this method always with locked // ACE_POSIX_AIOCB_Proactor::mutex_ // // It tries to start the first deferred AIO // if such exists if (num_deferred_aiocb_ == 0) return 0; // nothing to do size_t i = 0; for (i= 0; i < this->aiocb_list_max_size_; i++) if (result_list_[i] !=0 // check for && aiocb_list_[i] ==0) // deferred AIO break; if (i >= this->aiocb_list_max_size_) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:(%P | %t)::\n" "start_deferred_aio:" "internal Proactor error 3\n"), -1); ACE_POSIX_Asynch_Result *result = result_list_[i]; int ret_val = start_aio_i (result); switch (ret_val) { case 0 : //started OK , decrement count of deferred AIOs aiocb_list_[i] = result; num_deferred_aiocb_ --; return 0; case 1 : return 0; //try again later default : // Invalid Parameters , should never be break; } //AL notify user result_list_[i] = 0; --aiocb_list_cur_size_; --num_deferred_aiocb_; result->set_error (errno); result->set_bytes_transferred (0); this->putq_result (result); // we are with locked mutex_ here ! return -1; } int ACE_POSIX_AIOCB_Proactor::cancel_aio (ACE_HANDLE handle) { // This new method should be called from // ACE_POSIX_Asynch_Operation instead of usual ::aio_cancel // It scans the result_list_ and defines all AIO requests // that were issued for handle "handle" // // For all deferred AIO requests with handle "handle" // it removes its from the lists and notifies user // // For all running AIO requests with handle "handle" // it calls ::aio_cancel. According to the POSIX standards // we will receive ECANCELED for all ::aio_canceled AIO requests // later on return from ::aio_suspend ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::cancel_aio"); int num_total = 0; int num_cancelled = 0; { ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->mutex_, -1)); size_t ai = 0; for (ai = 0; ai < this->aiocb_list_max_size_; ai++) { if (this->result_list_[ai] == 0) // Skip empty slot continue; if (this->result_list_[ai]->aio_fildes != handle) // Not ours continue; ++num_total; ACE_POSIX_Asynch_Result *asynch_result = this->result_list_[ai]; if (this->aiocb_list_[ai] == 0) // Canceling a deferred operation { num_cancelled++; this->num_deferred_aiocb_--; this->aiocb_list_[ai] = 0; this->result_list_[ai] = 0; this->aiocb_list_cur_size_--; asynch_result->set_error (ECANCELED); asynch_result->set_bytes_transferred (0); this->putq_result (asynch_result); // we are with locked mutex_ here ! } else // Cancel started aio { int rc_cancel = this->cancel_aiocb (asynch_result); if (rc_cancel == 0) //notification in the future num_cancelled++; //it is OS responsiblity } } } // release mutex_ if (num_total == 0) return 1; // ALLDONE if (num_cancelled == num_total) return 0; // CANCELLED return 2; // NOT CANCELLED } int ACE_POSIX_AIOCB_Proactor::cancel_aiocb (ACE_POSIX_Asynch_Result * result) { // This method is called from cancel_aio // to cancel a previously submitted AIO request int rc = ::aio_cancel (0, result); // Check the return value and return 0/1/2 appropriately. if (rc == AIO_CANCELED) return 0; else if (rc == AIO_ALLDONE) return 1; else // (rc == AIO_NOTCANCELED) return 2; } // ********************************************************************* #if defined(ACE_HAS_POSIX_REALTIME_SIGNALS) ACE_POSIX_SIG_Proactor::ACE_POSIX_SIG_Proactor (size_t max_aio_operations) : ACE_POSIX_AIOCB_Proactor (max_aio_operations, ACE_POSIX_Proactor::PROACTOR_SIG) { // = Set up the mask we'll use to block waiting for SIGRTMIN. Use that // to add it to the signal mask for this thread, and also set the process // signal action to pass signal information when we want it. // Clear the signal set. ACE_OS::sigemptyset (&this->RT_completion_signals_); // Add the signal number to the signal set. if (ACE_OS::sigaddset (&this->RT_completion_signals_, ACE_SIGRTMIN) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_POSIX_SIG_Proactor: %p\n"), ACE_TEXT ("sigaddset"))); this->block_signals (); // Set up the signal action for SIGRTMIN. this->setup_signal_handler (ACE_SIGRTMIN); // we do not have to create notify manager // but we should start pseudo-asynchronous accept task // one per all future acceptors this->get_asynch_pseudo_task().start (); return; } ACE_POSIX_SIG_Proactor::ACE_POSIX_SIG_Proactor (const sigset_t signal_set, size_t max_aio_operations) : ACE_POSIX_AIOCB_Proactor (max_aio_operations, ACE_POSIX_Proactor::PROACTOR_SIG) { // = Keep <Signal_set> with the Proactor, mask all the signals and // setup signal actions for the signals in the <signal_set>. // = Keep <signal_set> with the Proactor. // Empty the signal set first. if (sigemptyset (&this->RT_completion_signals_) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT("Error:(%P | %t):%p\n"), ACE_TEXT("sigemptyset failed"))); // For each signal number present in the <signal_set>, add it to // the signal set we use, and also set up its process signal action // to allow signal info to be passed into sigwait/sigtimedwait. int member = 0; for (int si = ACE_SIGRTMIN; si <= ACE_SIGRTMAX; si++) { member = sigismember (&signal_set, si); if (member == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT("%N:%l:(%P | %t)::%p\n"), ACE_TEXT("ACE_POSIX_SIG_Proactor::ACE_POSIX_SIG_Proactor:") ACE_TEXT("sigismember failed"))); else if (member == 1) { sigaddset (&this->RT_completion_signals_, si); this->setup_signal_handler (si); } } // Mask all the signals. this->block_signals (); // we do not have to create notify manager // but we should start pseudo-asynchronous accept task // one per all future acceptors this->get_asynch_pseudo_task().start (); return; } ACE_POSIX_SIG_Proactor::~ACE_POSIX_SIG_Proactor (void) { this->close (); // @@ Enable the masked signals again. } ACE_POSIX_Proactor::Proactor_Type ACE_POSIX_SIG_Proactor::get_impl_type (void) { return PROACTOR_SIG; } int ACE_POSIX_SIG_Proactor::handle_events (ACE_Time_Value &wait_time) { // Decrement <wait_time> with the amount of time spent in the method ACE_Countdown_Time countdown (&wait_time); return this->handle_events_i (&wait_time); } int ACE_POSIX_SIG_Proactor::handle_events (void) { return this->handle_events_i (0); } int ACE_POSIX_SIG_Proactor::notify_completion (int sig_num) { // Get this process id. pid_t const pid = ACE_OS::getpid (); if (pid == (pid_t) -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("Error:%N:%l(%P | %t):%p"), ACE_TEXT("<getpid> failed")), -1); // Set the signal information. sigval value; #if defined (ACE_HAS_SIGVAL_SIGVAL_INT) value.sigval_int = -1; #else value.sival_int = -1; #endif /* ACE_HAS_SIGVAL_SIGVAL_INT */ // Queue the signal. if (sigqueue (pid, sig_num, value) == 0) return 0; if (errno != EAGAIN) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("Error:%N:%l:(%P | %t):%p\n"), ACE_TEXT("<sigqueue> failed")), -1); return -1; } ACE_Asynch_Result_Impl * ACE_POSIX_SIG_Proactor::create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy, const void *act, const ACE_Time_Value &tv, ACE_HANDLE event, int priority, int signal_number) { int is_member = 0; // Fix the signal number. if (signal_number == -1) { int si; for (si = ACE_SIGRTMAX; (is_member == 0) && (si >= ACE_SIGRTMIN); si--) { is_member = sigismember (&this->RT_completion_signals_, si); if (is_member == -1) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:(%P | %t)::%s\n", "ACE_POSIX_SIG_Proactor::create_asynch_timer:" "sigismember failed"), 0); } if (is_member == 0) ACE_ERROR_RETURN ((LM_ERROR, "Error:%N:%l:(%P | %t)::%s\n", "ACE_POSIX_SIG_Proactor::ACE_POSIX_SIG_Proactor:" "Signal mask set empty"), 0); else // + 1 to nullify loop increment. signal_number = si + 1; } ACE_Asynch_Result_Impl *implementation; ACE_NEW_RETURN (implementation, ACE_POSIX_Asynch_Timer (handler_proxy, act, tv, event, priority, signal_number), 0); return implementation; } #if 0 static void sig_handler (int sig_num, siginfo_t *, ucontext_t *) { // Should never be called ACE_DEBUG ((LM_DEBUG, "%N:%l:(%P | %t)::sig_handler received signal: %d\n", sig_num)); } #endif /*if 0*/ int ACE_POSIX_SIG_Proactor::setup_signal_handler (int signal_number) const { // Set up the specified signal so that signal information will be // passed to sigwaitinfo/sigtimedwait. Don't change the default // signal handler - having a handler and waiting for the signal can // produce undefined behavior. // But can not use SIG_DFL // With SIG_DFL after delivering the first signal // SIG_DFL handler resets SA_SIGINFO flags // and we will lose all information sig_info // At least all SunOS have such behavior #if 0 struct sigaction reaction; sigemptyset (&reaction.sa_mask); // Nothing else to mask. reaction.sa_flags = SA_SIGINFO; // Realtime flag. reaction.sa_sigaction = ACE_SIGNAL_C_FUNC (sig_handler); // (SIG_DFL); int sigaction_return = ACE_OS::sigaction (signal_number, &reaction, 0); if (sigaction_return == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT("Error:%p\n"), ACE_TEXT("Proactor couldnt do sigaction for the RT SIGNAL")), -1); #else ACE_UNUSED_ARG(signal_number); #endif return 0; } int ACE_POSIX_SIG_Proactor::block_signals (void) const { return ACE_OS::pthread_sigmask (SIG_BLOCK, &this->RT_completion_signals_, 0); } ssize_t ACE_POSIX_SIG_Proactor::allocate_aio_slot (ACE_POSIX_Asynch_Result *result) { size_t i = 0; //try to find free slot as usual, starting from 0 for (i = 0; i < this->aiocb_list_max_size_; i++) if (result_list_[i] == 0) break; if (i >= this->aiocb_list_max_size_) ACE_ERROR_RETURN ((LM_ERROR, "%N:%l:(%P | %t)::\n" "ACE_POSIX_SIG_Proactor::allocate_aio_slot " "internal Proactor error 1\n"), -1); // setup OS notification methods for this aio // store index!!, not pointer in signal info result->aio_sigevent.sigev_notify = SIGEV_SIGNAL; result->aio_sigevent.sigev_signo = result->signal_number (); #if defined (ACE_HAS_SIGVAL_SIGVAL_INT) result->aio_sigevent.sigev_value.sigval_int = static_cast<int> (i); #else result->aio_sigevent.sigev_value.sival_int = static_cast<int> (i); #endif /* ACE_HAS_SIGVAL_SIGVAL_INT */ return static_cast<ssize_t> (i); } int ACE_POSIX_SIG_Proactor::handle_events_i (const ACE_Time_Value *timeout) { int result_sigwait = 0; siginfo_t sig_info; do { // Wait for the signals. if (timeout == 0) { result_sigwait = ACE_OS::sigwaitinfo (&this->RT_completion_signals_, &sig_info); } else { result_sigwait = ACE_OS::sigtimedwait (&this->RT_completion_signals_, &sig_info, timeout); if (result_sigwait == -1 && errno == EAGAIN) return 0; } } while (result_sigwait == -1 && errno == EINTR); if (result_sigwait == -1) // Not a timeout, not EINTR: tell caller of error return -1; // Decide what to do. We always check the completion queue since it's an // easy, quick check. What is decided here is whether to check for // I/O completions and, if so, how completely to scan. int flg_aio = 0; // 1 if AIO Completion possible size_t index = 0; // start index to scan aiocb list size_t count = 1; // max number of aiocbs to scan int error_status = 0; size_t transfer_count = 0; if (sig_info.si_code == SI_ASYNCIO || this->os_id_ == ACE_OS_SUN_56) { flg_aio = 1; // AIO signal received // define index to start // nothing will happen if it contains garbage #if defined (ACE_HAS_SIGVAL_SIGVAL_INT) index = static_cast<size_t> (sig_info.si_value.sigval_int); #else index = static_cast<size_t> (sig_info.si_value.sival_int); #endif /* ACE_HAS_SIGVAL_SIGVAL_INT */ // Assume we have a correctly-functioning implementation, and that // there is one I/O to process, and it's correctly specified in the // siginfo received. There are, however, some special situations // where this isn't true... if (os_id_ == ACE_OS_SUN_56) // Solaris 6 { // 1. Solaris 6 always loses any RT signal, // if it has more SIGQUEMAX=32 pending signals // so we should scan the whole aiocb list // 2. Moreover,it has one more bad habit // to notify aio completion // with SI_QUEUE code instead of SI_ASYNCIO, hence the // OS_SUN_56 addition to the si_code check, above. count = aiocb_list_max_size_; } } else if (sig_info.si_code != SI_QUEUE) { // Unknown signal code. // may some other third-party libraries could send it // or message queue could also generate it ! // So print the message and check our completions ACE_ERROR ((LM_DEBUG, ACE_TEXT ("%N:%l:(%P | %t): ") ACE_TEXT ("ACE_POSIX_SIG_Proactor::handle_events: ") ACE_TEXT ("Unexpected signal code (%d) returned ") ACE_TEXT ("from sigwait; expecting %d\n"), result_sigwait, sig_info.si_code)); flg_aio = 1; } int ret_aio = 0; int ret_que = 0; if (flg_aio) for (;; ret_aio++) { ACE_POSIX_Asynch_Result *asynch_result = find_completed_aio (error_status, transfer_count, index, count); if (asynch_result == 0) break; // Call the application code. this->application_specific_code (asynch_result, transfer_count, 0, // No completion key. error_status); // Error } // process post_completed results ret_que = this->process_result_queue (); // Uncomment this if you want to test // and research the behavior of you system #if 0 ACE_DEBUG ((LM_DEBUG, "(%t) NumAIO=%d NumQueue=%d\n", ret_aio, ret_que)); #endif return ret_aio + ret_que > 0 ? 1 : 0; } #endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */ // ********************************************************************* ACE_POSIX_Asynch_Timer::ACE_POSIX_Asynch_Timer (const ACE_Handler::Proxy_Ptr &handler_proxy, const void *act, const ACE_Time_Value &tv, ACE_HANDLE event, int priority, int signal_number) : ACE_POSIX_Asynch_Result (handler_proxy, act, event, 0, 0, priority, signal_number), time_ (tv) { } void ACE_POSIX_Asynch_Timer::complete (size_t /* bytes_transferred */, int /* success */, const void * /* completion_key */, u_long /* error */) { ACE_Handler *handler = this->handler_proxy_.get ()->handler (); if (handler != 0) handler->handle_time_out (this->time_, this->act ()); } // ********************************************************************* ACE_POSIX_Wakeup_Completion::ACE_POSIX_Wakeup_Completion (const ACE_Handler::Proxy_Ptr &handler_proxy, const void *act, ACE_HANDLE event, int priority, int signal_number) : ACE_Asynch_Result_Impl (), ACE_POSIX_Asynch_Result (handler_proxy, act, event, 0, 0, priority, signal_number) { } ACE_POSIX_Wakeup_Completion::~ACE_POSIX_Wakeup_Completion (void) { } void ACE_POSIX_Wakeup_Completion::complete (size_t /* bytes_transferred */, int /* success */, const void * /* completion_key */, u_long /* error */) { ACE_Handler *handler = this->handler_proxy_.get ()->handler (); if (handler != 0) handler->handle_wakeup (); } ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_HAS_AIO_CALLS */
/* Copyright © 2019 Apple Inc. All rights reserved. * * Use of this source code is governed by a BSD-3-clause license that can * be found in the LICENSE.txt file or at * https://opensource.org/licenses/BSD-3-Clause */ #ifndef TEST_UNITY_TOOLKITS_NEURAL_NET_NEURAL_NET_MOCKS_HPP_ #define TEST_UNITY_TOOLKITS_NEURAL_NET_NEURAL_NET_MOCKS_HPP_ #include <deque> #include <functional> #include <memory> #include <core/util/test_macros.hpp> #include <ml/neural_net/compute_context.hpp> #include <ml/neural_net/image_augmentation.hpp> #include <ml/neural_net/model_backend.hpp> namespace turi { namespace neural_net { using turi::neural_net::compute_context; using turi::neural_net::float_array; using turi::neural_net::float_array_map; using turi::neural_net::image_annotation; using turi::neural_net::image_augmenter; using turi::neural_net::labeled_image; using turi::neural_net::model_backend; using turi::neural_net::shared_float_array; // TODO: Adopt a real mocking library. Or at least factor out the shared // boilerplate into some utility templates or macros. Yes, if necessary, create // our own simplistic mocking tools. class mock_image_augmenter : public image_augmenter { public: using prepare_images_call = std::function<result(std::vector<labeled_image> source_batch)>; ~mock_image_augmenter() { TS_ASSERT(prepare_images_calls_.empty()); } const options& get_options() const override { return options_; } result prepare_images(std::vector<labeled_image> source_batch) override { TS_ASSERT(!prepare_images_calls_.empty()); prepare_images_call expected_call = std::move(prepare_images_calls_.front()); prepare_images_calls_.pop_front(); return expected_call(std::move(source_batch)); } options options_; std::deque<prepare_images_call> prepare_images_calls_; }; class mock_model_backend : public model_backend { public: using set_learning_rate_call = std::function<void(float lr)>; using train_call = std::function<float_array_map(const float_array_map& inputs)>; using predict_call = std::function<float_array_map(const float_array_map& inputs)>; ~mock_model_backend() { TS_ASSERT(train_calls_.empty()); TS_ASSERT(predict_calls_.empty()); } void set_learning_rate(float lr) override { TS_ASSERT(!set_learning_rate_calls_.empty()); set_learning_rate_call expected_call = std::move(set_learning_rate_calls_.front()); set_learning_rate_calls_.pop_front(); expected_call(lr); } float_array_map train(const float_array_map& inputs) override { TS_ASSERT(!train_calls_.empty()); train_call expected_call = std::move(train_calls_.front()); train_calls_.pop_front(); return expected_call(inputs); } float_array_map predict(const float_array_map& inputs) const override { TS_ASSERT(!predict_calls_.empty()); predict_call expected_call = std::move(predict_calls_.front()); predict_calls_.pop_front(); return expected_call(inputs); } float_array_map export_weights() const override { return export_weights_retval_; } std::deque<set_learning_rate_call> set_learning_rate_calls_; std::deque<train_call> train_calls_; mutable std::deque<predict_call> predict_calls_; float_array_map export_weights_retval_; }; class mock_compute_context : public compute_context { public: using create_augmenter_call = std::function<std::unique_ptr<image_augmenter>( const image_augmenter::options& opts)>; using create_object_detector_call = std::function<std::unique_ptr<model_backend>( int n, int c_in, int h_in, int w_in, int c_out, int h_out, int w_out, const float_array_map& config, const float_array_map& weights)>; /** * TODO: const float_array_map& weights, * const float_array_map& config. * Until the nn_spec in C++ is ready, do not pass in any weights. */ using create_drawing_classifier_call = std::function<std::unique_ptr<model_backend>( /* TODO: const float_array_map& config if needed */ const float_array_map& weights, size_t batch_size, size_t num_classes)>; ~mock_compute_context() { TS_ASSERT(create_augmenter_calls_.empty()); TS_ASSERT(create_object_detector_calls_.empty()); TS_ASSERT(create_drawing_classifier_calls_.empty()); } size_t memory_budget() const override { return 0; } std::vector<std::string> gpu_names() const override { return {}; } std::unique_ptr<image_augmenter> create_image_augmenter( const image_augmenter::options& opts) override { TS_ASSERT(!create_augmenter_calls_.empty()); create_augmenter_call expected_call = std::move(create_augmenter_calls_.front()); create_augmenter_calls_.pop_front(); return expected_call(opts); } std::unique_ptr<model_backend> create_object_detector( int n, int c_in, int h_in, int w_in, int c_out, int h_out, int w_out, const float_array_map& config, const float_array_map& weights) override { TS_ASSERT(!create_object_detector_calls_.empty()); create_object_detector_call expected_call = std::move(create_object_detector_calls_.front()); create_object_detector_calls_.pop_front(); return expected_call(n, c_in, h_in, w_in, c_out, h_out, w_out, config, weights); } /** * TODO: const float_array_map& weights, const float_array_map& config. * Until the nn_spec in C++ isn't ready, do not pass in any weights. */ std::unique_ptr<model_backend> create_drawing_classifier( /* TODO: const float_array_map& config if needed */ const float_array_map& weights, size_t batch_size, size_t num_classes) override { TS_ASSERT(!create_drawing_classifier_calls_.empty()); create_drawing_classifier_call expected_call = std::move(create_drawing_classifier_calls_.front()); create_drawing_classifier_calls_.pop_front(); return expected_call( /* TODO: const float_array_map& config if needed */ weights, batch_size, num_classes); } std::unique_ptr<model_backend> create_activity_classifier( int n, int c_in, int h_in, int w_in, int c_out, int h_out, int w_out, const float_array_map& config, const float_array_map& weights) override { throw std::runtime_error("create_activity_classifier not implemented"); } std::unique_ptr<model_backend> create_style_transfer( const float_array_map& config, const float_array_map& weights) override { throw std::runtime_error("create_style_transfer not implemented"); } mutable std::deque<create_augmenter_call> create_augmenter_calls_; mutable std::deque<create_object_detector_call> create_object_detector_calls_; mutable std::deque<create_drawing_classifier_call> create_drawing_classifier_calls_; }; } // namespace neural_net } // namespace turi #endif // TEST_UNITY_TOOLKITS_NEURAL_NET_NEURAL_NET_MOCKS_HPP_
# x mapeado em $s1 .text .globl teste teste: addi $16, $zero, 1 # x=1 addi $8, $zero, 0x1001 sll $8, $8, 16 # valor do adress para acessar a memória armazenado em $t0 lw $17, 0($t0) # load de x1 para $s1 lw $18, 4($t0) # load de x1 para $s2 lw $19, 8($t0) # load de x1 para $s3 lw $20, 12($t0) # load de x1 para $s4 .data x1: .word 15 x2: .word 25 x3: .word 13 x4: .word 17
/* Copyright 2020 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #include "tensorflow/lite/delegates/gpu/common/quantization_util.h" #include <stdint.h> #include <algorithm> #include <limits> #include <memory> #include <vector> #include <gmock/gmock.h> #include <gtest/gtest.h> #include "absl/container/flat_hash_map.h" #include "absl/status/status.h" #include "tensorflow/lite/c/common.h" #include "tensorflow/lite/util.h" using ::testing::Eq; using ::testing::FloatNear; using ::testing::Pointwise; namespace tflite { namespace gpu { namespace { std::unique_ptr<TfLiteIntArray, TfLiteIntArrayDeleter> BuildTfLiteIntArray( const std::vector<int>& data) { std::unique_ptr<TfLiteIntArray, TfLiteIntArrayDeleter> result( TfLiteIntArrayCreate(data.size())); std::copy(data.begin(), data.end(), result->data); return result; } // TODO(b/158578883): this function is copied from the Micro codebase. Consider // moving to a shared location. void PopulateContext(std::vector<TfLiteTensor>& tensors, TfLiteContext& context) { context.tensors_size = tensors.size(); context.tensors = tensors.data(); context.recommended_num_threads = 1; } // TODO(b/158578883): this function is copied from the Micro codebase. Consider // moving to a shared location. int ElementCount(const TfLiteIntArray& dims) { int result = 1; for (int i = 0; i < dims.size; ++i) { result *= dims.data[i]; } return result; } // TODO(b/158578883): this function is copied from the Micro codebase. Consider // moving to a shared location. template <typename T> inline float ScaleFromMinMax(const float min, const float max) { return (max - min) / ((std::numeric_limits<T>::max() * 1.0) - std::numeric_limits<T>::min()); } // TODO(b/158578883): this function is copied from the Micro codebase. Consider // moving to a shared location. template <typename T> inline int ZeroPointFromMinMax(const float min, const float max) { return static_cast<int>(std::numeric_limits<T>::min()) + static_cast<int>(-min / ScaleFromMinMax<T>(min, max) + 0.5f); } // TODO(b/158578883): this function is copied from the Micro codebase. Consider // moving to a shared location. TfLiteTensor CreateQuantizedTensor(const int8_t* data, TfLiteIntArray* dims, const char* name, float min, float max, bool is_variable) { TfLiteTensor result; result.type = kTfLiteInt8; result.data.int8 = const_cast<int8_t*>(data); result.dims = dims; result.params = {ScaleFromMinMax<int8_t>(min, max), ZeroPointFromMinMax<int8_t>(min, max)}; result.allocation_type = kTfLiteMemNone; result.bytes = ElementCount(*dims) * sizeof(int8_t); result.allocation = nullptr; result.name = name; result.is_variable = is_variable; return result; } // TODO(b/158578883): this function is copied from the Micro codebase. Consider // moving to a shared location. TfLiteTensor CreateQuantizedTensor(const uint8_t* data, TfLiteIntArray* dims, const char* name, float min, float max, bool is_variable) { TfLiteTensor result; result.type = kTfLiteUInt8; result.data.uint8 = const_cast<uint8_t*>(data); result.dims = dims; result.params = {ScaleFromMinMax<uint8_t>(min, max), ZeroPointFromMinMax<uint8_t>(min, max)}; result.allocation_type = kTfLiteMemNone; result.bytes = ElementCount(*dims) * sizeof(uint8_t); result.allocation = nullptr; result.name = name; result.is_variable = false; return result; } // TODO(b/158578883): this function is copied from the Micro codebase. Consider // moving to a shared location. TfLiteTensor CreateTensor(TfLiteIntArray* dims, const char* name, bool is_variable) { TfLiteTensor result; result.dims = dims; result.name = name; result.params = {}; result.quantization = {kTfLiteNoQuantization, nullptr}; result.is_variable = is_variable; result.allocation_type = kTfLiteMemNone; result.allocation = nullptr; return result; } // TODO(b/158578883): this function is copied from the Micro codebase. Consider // moving to a shared location. TfLiteTensor CreateFloatTensor(const float* data, TfLiteIntArray* dims, const char* name, bool is_variable) { TfLiteTensor result = CreateTensor(dims, name, is_variable); result.type = kTfLiteFloat32; result.data.f = const_cast<float*>(data); result.bytes = ElementCount(*dims) * sizeof(float); return result; } TEST(DequantizeInputs, Int8) { TfLiteContext context; auto input_dims = BuildTfLiteIntArray({1, 3, 2, 1}); std::vector<int8_t> data = {-3, -2, -1, 1, 2, 3}; std::vector<float> dequantized_data(data.size()); TfLiteTensor input = CreateQuantizedTensor( data.data(), input_dims.get(), "input", /*min=*/-12.8f, /*max=*/12.7f, /*is_variable=*/false); TfLiteTensor dequantized_input = CreateFloatTensor( dequantized_data.data(), input_dims.get(), "input_dequant", /*is_variable=*/true); std::vector<TfLiteTensor> tensors{input, dequantized_input}; PopulateContext(tensors, context); std::vector<uint32_t> input_indices = {1}; absl::flat_hash_map<int, int> quant_conversion_map = {{1, 0}}; auto status = DequantizeInputs(&context, input_indices, quant_conversion_map); EXPECT_TRUE(status.ok()); EXPECT_THAT(dequantized_data, Pointwise(FloatNear(1e-6), {-0.3, -0.2, -0.1, 0.1, 0.2, 0.3})); } TEST(DequantizeInputs, UInt8) { TfLiteContext context; auto input_dims = BuildTfLiteIntArray({1, 3, 2, 1}); std::vector<uint8_t> data = {0, 1, 2, 3, 4, 5}; std::vector<float> dequantized_data(data.size()); TfLiteTensor input = CreateQuantizedTensor(data.data(), input_dims.get(), "input", /*min=*/0.0f, /*max=*/25.5f, /*is_variable=*/false); TfLiteTensor dequantized_input = CreateFloatTensor( dequantized_data.data(), input_dims.get(), "input_dequant", /*is_variable=*/true); std::vector<TfLiteTensor> tensors{input, dequantized_input}; PopulateContext(tensors, context); std::vector<int64_t> input_indices = {1}; absl::flat_hash_map<int, int> quant_conversion_map = {{1, 0}}; auto status = DequantizeInputs(&context, input_indices, quant_conversion_map); EXPECT_TRUE(status.ok()); EXPECT_THAT(dequantized_data, Pointwise(FloatNear(1e-6), {0.0, 0.1, 0.2, 0.3, 0.4, 0.5})); } TEST(QuantizeOutputs, Int8) { TfLiteContext context; auto input_dims = BuildTfLiteIntArray({1, 3, 2, 1}); std::vector<float> data = {-0.3, -0.2, -0.1, 0.1, 0.2, 0.3}; std::vector<int8_t> quantized_data(data.size()); TfLiteTensor output = CreateFloatTensor(data.data(), input_dims.get(), "output", /*is_variable=*/false); TfLiteTensor quantized_output = CreateQuantizedTensor( quantized_data.data(), input_dims.get(), "output_quant", /*min=*/-12.8f, /*max=*/12.7f, /*is_variable=*/true); std::vector<TfLiteTensor> tensors{output, quantized_output}; PopulateContext(tensors, context); std::vector<uint32_t> output_indices = {0}; absl::flat_hash_map<int, int> quant_conversion_map = {{0, 1}}; auto status = QuantizeOutputs(&context, output_indices, quant_conversion_map); EXPECT_TRUE(status.ok()); EXPECT_THAT(quantized_data, Pointwise(Eq(), {-3, -2, -1, 1, 2, 3})); } TEST(QuantizeOutputs, UInt8) { TfLiteContext context; auto input_dims = BuildTfLiteIntArray({1, 3, 2, 1}); std::vector<float> data = {0.0, 0.1, 0.2, 0.3, 0.4, 0.5}; std::vector<uint8_t> quantized_data(data.size()); TfLiteTensor output = CreateFloatTensor(data.data(), input_dims.get(), "output", /*is_variable=*/false); TfLiteTensor quantized_output = CreateQuantizedTensor( quantized_data.data(), input_dims.get(), "output_quant", /*min=*/0.0f, /*max=*/25.5f, /*is_variable=*/true); std::vector<TfLiteTensor> tensors{output, quantized_output}; PopulateContext(tensors, context); std::vector<int64_t> output_indices = {0}; absl::flat_hash_map<int, int> quant_conversion_map = {{0, 1}}; auto status = QuantizeOutputs(&context, output_indices, quant_conversion_map); EXPECT_TRUE(status.ok()); EXPECT_THAT(quantized_data, Pointwise(Eq(), {0, 1, 2, 3, 4, 5})); } } // namespace } // namespace gpu } // namespace tflite
setrepeat 3 frame 0, 06 frame 4, 06 dorepeat 1 endanim
%include "TiberianSun.inc" %include "macros/patch.inc" %include "macros/datatypes.inc" ;;; TechnoClass::Draw_Pips @SET 0x00637CE3, { mov ebx, 0xfffffff4 } ;@SET 0x00637CE3, { lea ebx, [GroupYAdjustment] } ;@SET 0x00637D11, { lea eax, [ebx-24] } ;@SET 0x00637D27, { sub ecx, 10 }
#include "ili9328.h" SPISettings setting(8000000, MSBFIRST, SPI_MODE3); ili9328SPI::ili9328SPI(uint8_t cs, uint8_t reset) : Adafruit_GFX(TFT_WIDTH, TFT_HEIGHT) { CSpin = cs; RSTpin = reset; } void ili9328SPI::begin(void) { CSPinSet = digitalPinToBitMask(CSpin); CSPort = portOutputRegister(digitalPinToPort(CSpin)); pinMode(CSpin, OUTPUT); pinMode(RSTpin, OUTPUT); SPI.begin(); init(); } void ili9328SPI::init(void) { digitalWrite(RSTpin, HIGH); delay(100); digitalWrite(RSTpin, LOW); delay(500); digitalWrite(RSTpin, HIGH); delay(500); writereg16(0x00E5, 0x78F0); writereg16(0x0001, 0x0000); writereg16(0x0002, 0x0400); writereg16(0x0003, 0x1090); writereg16(0x0004, 0x0000); writereg16(0x0008, 0x0202); writereg16(0x0009, 0x0000); writereg16(0x000A, 0x0000); writereg16(0x000C, 0x0000); writereg16(0x000D, 0x0000); writereg16(0x000F, 0x0000); writereg16(0x0010, 0x0000); writereg16(0x0011, 0x0007); writereg16(0x0012, 0x0000); writereg16(0x0013, 0x0000); writereg16(0x0007, 0x0001); delay(200); writereg16(0x0010, 0x1690); writereg16(0x0011, 0x0227); delay(50); writereg16(0x0012, 0x008C); delay(50); writereg16(0x0013, 0x1500); writereg16(0x0029, 0x0004); writereg16(0x002B, 0x000D); delay(50); writereg16(0x0020, 0x0000); writereg16(0x0021, 0x0000); writereg16(0x0030, 0x0000); writereg16(0x0031, 0x0607); writereg16(0x0032, 0x0305); writereg16(0x0035, 0x0000); writereg16(0x0036, 0x1604); writereg16(0x0037, 0x0204); writereg16(0x0038, 0x0001); writereg16(0x0039, 0x0707); writereg16(0x003C, 0x0000); writereg16(0x003D, 0x000F); writereg16(0x0050, 0x0000); writereg16(0x0051, 0x00EF); writereg16(0x0052, 0x0000); writereg16(0x0053, 0x013F); writereg16(0x0060, 0xA700); writereg16(0x0061, 0x0001); writereg16(0x006A, 0x0000); writereg16(0x0080, 0x0000); writereg16(0x0081, 0x0000); writereg16(0x0082, 0x0000); writereg16(0x0083, 0x0000); writereg16(0x0084, 0x0000); writereg16(0x0085, 0x0000); writereg16(0x0090, 0x0010); writereg16(0x0092, 0x0600); writereg16(0x0007, 0x0133); } void ili9328SPI::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { SPI.beginTransaction(setting); setblock(x, x + w, y, y + h); for (uint16_t i = 0; i < w + 1; i++) { for (uint16_t j = 0; j < h + 1; j++) { writedat16(color); } } SPI.endTransaction(); } void ili9328SPI::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) { SPI.beginTransaction(setting); setblock(x, x, y, y + h); for (uint16_t j = 0; j < h + 1; j++) { writedat16(color); } SPI.endTransaction(); } void ili9328SPI::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) { SPI.beginTransaction(setting); setblock(x, x + w, y, y); for (uint16_t j = 0; j < w + 1; j++) { writedat16(color); } SPI.endTransaction(); } void ili9328SPI::drawPixel(int16_t x, int16_t y, uint16_t color) { SPI.beginTransaction(setting); //NOT WORKING CODE /*int16_t rx, ry; switch (rotation) { case 1: rx = y; ry = TFT_HEIGHT - x; break; case 2: rx = TFT_WIDTH - x; ry = TFT_HEIGHT - y; break; case 3: rx = y; ry = TFT_WIDTH - x; break; default: rx = x; ry = y; break; } setblock(rx, rx, ry, ry); */ setblock(x, x, y, y); writedat16(color); SPI.endTransaction(); } void ili9328SPI::setRotation(uint8_t x){ Adafruit_GFX::setRotation(x); rotation = x; } uint16_t ili9328SPI::color565(uint8_t r, uint8_t g, uint8_t b) { uint16_t rb, gb, bb; rb = (r & 0xF8) << 8; gb = (g & 0xFC) << 3; bb = b >> 3; return rb | gb | bb; } void ili9328SPI::setblock(uint16_t x0, uint16_t x1, uint16_t y0, uint16_t y1) { writecom16(0x0050); writedat16(y0); writecom16(0x0051); writedat16(y1); writecom16(0x0052); writedat16(x0); writecom16(0x0053); writedat16(x1); writecom16(0x0020); writedat16(x0); writecom16(0x0021); writedat16(y0); writecom16(0x0022); } void ili9328SPI::writereg16(uint16_t com, uint16_t dat) { SPI.beginTransaction(setting); writecom16(com); writedat16(dat); SPI.endTransaction(); } void ili9328SPI::writecom16(uint16_t com) { CS_LOW; WRITE16(0x70); WRITE16(com >> 8); WRITE16(com); CS_HIGH; } void ili9328SPI::writedat16(uint16_t dat) { CS_LOW; WRITE16(0x72); WRITE16(dat >> 8); WRITE16(dat); CS_HIGH; }
/* * Copyright (C) 2017 Jolla Ltd. * Contact: Chris Adams <chris.adams@jollamobile.com> * All rights reserved. * BSD 3-Clause License, see LICENSE. */ #include "plugin.h" #include <QtCore/QMetaObject> Q_PLUGIN_METADATA(IID Sailfish_Secrets_AuthenticationPlugin_IID) Q_LOGGING_CATEGORY(lcSailfishSecretsPluginInapp, "org.sailfishos.secrets.plugin.authentication.inapp", QtWarningMsg) using namespace Sailfish::Secrets; Daemon::Plugins::InAppPlugin::InAppPlugin(QObject *parent) : AuthenticationPlugin(parent) { } Daemon::Plugins::InAppPlugin::~InAppPlugin() { } Result Daemon::Plugins::InAppPlugin::beginAuthentication( uint callerPid, qint64 requestId, const Sailfish::Secrets::InteractionParameters::PromptText &promptText) { Q_UNUSED(callerPid); Q_UNUSED(requestId); Q_UNUSED(promptText); return Result(Result::OperationRequiresSystemUserInteraction, QLatin1String("In-App plugin cannot properly authenticate the user")); } Result Daemon::Plugins::InAppPlugin::beginUserInputInteraction( uint callerPid, qint64 requestId, const Sailfish::Secrets::InteractionParameters &interactionParameters, const QString &interactionServiceAddress) { #ifdef SAILFISHSECRETS_TESTPLUGIN if (interactionServiceAddress.isEmpty() && interactionParameters.promptText().message().endsWith( QLatin1String("Enter the lock code for the unit test"))) { QMetaObject::invokeMethod(this, "userInputInteractionCompleted", Qt::QueuedConnection, Q_ARG(uint, callerPid), Q_ARG(qint64, requestId), Q_ARG(Sailfish::Secrets::InteractionParameters, interactionParameters), Q_ARG(QString, interactionServiceAddress), Q_ARG(Sailfish::Secrets::Result, Sailfish::Secrets::Result(Sailfish::Secrets::Result::Succeeded)), Q_ARG(QByteArray, QByteArray("example lock code for the unit test"))); return Result(Result::Pending); } else if (interactionParameters.promptText().instruction().endsWith( QLatin1String("Enter the old master lock code."))) { static int oldLockCount = 0; oldLockCount += 1; QMetaObject::invokeMethod(this, "userInputInteractionCompleted", Qt::QueuedConnection, Q_ARG(uint, callerPid), Q_ARG(qint64, requestId), Q_ARG(Sailfish::Secrets::InteractionParameters, interactionParameters), Q_ARG(QString, interactionServiceAddress), Q_ARG(Sailfish::Secrets::Result, Sailfish::Secrets::Result(Sailfish::Secrets::Result::Succeeded)), Q_ARG(QByteArray, oldLockCount % 2 == 1 ? QByteArray() : QByteArray("masterlock"))); return Result(Result::Pending); } else if (interactionParameters.promptText().newInstruction().endsWith( QLatin1String("Enter the new master lock code."))) { static int newLockCount = 0; newLockCount += 1; QMetaObject::invokeMethod(this, "userInputInteractionCompleted", Qt::QueuedConnection, Q_ARG(uint, callerPid), Q_ARG(qint64, requestId), Q_ARG(Sailfish::Secrets::InteractionParameters, interactionParameters), Q_ARG(QString, interactionServiceAddress), Q_ARG(Sailfish::Secrets::Result, Sailfish::Secrets::Result(Sailfish::Secrets::Result::Succeeded)), Q_ARG(QByteArray, newLockCount % 2 == 1 ? QByteArray("masterlock") : QByteArray())); return Result(Result::Pending); } else if (interactionParameters.promptText().instruction().endsWith( QLatin1String("Enter the master lock code to unlock the secrets service."))) { QMetaObject::invokeMethod(this, "userInputInteractionCompleted", Qt::QueuedConnection, Q_ARG(uint, callerPid), Q_ARG(qint64, requestId), Q_ARG(Sailfish::Secrets::InteractionParameters, interactionParameters), Q_ARG(QString, interactionServiceAddress), Q_ARG(Sailfish::Secrets::Result, Sailfish::Secrets::Result(Sailfish::Secrets::Result::Succeeded)), Q_ARG(QByteArray, QByteArray("masterlock"))); return Result(Result::Pending); } else if (interactionParameters.promptText().instruction().endsWith( QLatin1String("Enter the old lock code to unlock the plugin."))) { QMetaObject::invokeMethod(this, "userInputInteractionCompleted", Qt::QueuedConnection, Q_ARG(uint, callerPid), Q_ARG(qint64, requestId), Q_ARG(Sailfish::Secrets::InteractionParameters, interactionParameters), Q_ARG(QString, interactionServiceAddress), Q_ARG(Sailfish::Secrets::Result, Sailfish::Secrets::Result(Sailfish::Secrets::Result::Succeeded)), Q_ARG(QByteArray, QByteArray())); return Result(Result::Pending); } else if (interactionParameters.promptText().newInstruction().endsWith( QLatin1String("Enter the new lock code for the plugin."))) { QMetaObject::invokeMethod(this, "userInputInteractionCompleted", Qt::QueuedConnection, Q_ARG(uint, callerPid), Q_ARG(qint64, requestId), Q_ARG(Sailfish::Secrets::InteractionParameters, interactionParameters), Q_ARG(QString, interactionServiceAddress), Q_ARG(Sailfish::Secrets::Result, Sailfish::Secrets::Result(Sailfish::Secrets::Result::Succeeded)), Q_ARG(QByteArray, QByteArray("pluginlock"))); return Result(Result::Pending); } else if (interactionParameters.promptText().instruction().endsWith( QLatin1String("Enter the lock code to unlock the plugin."))) { QMetaObject::invokeMethod(this, "userInputInteractionCompleted", Qt::QueuedConnection, Q_ARG(uint, callerPid), Q_ARG(qint64, requestId), Q_ARG(Sailfish::Secrets::InteractionParameters, interactionParameters), Q_ARG(QString, interactionServiceAddress), Q_ARG(Sailfish::Secrets::Result, Sailfish::Secrets::Result(Sailfish::Secrets::Result::Succeeded)), Q_ARG(QByteArray, QByteArray("pluginlock"))); return Result(Result::Pending); } else if (interactionParameters.operation() != InteractionParameters::RequestUserData) { QMetaObject::invokeMethod(this, "userInputInteractionCompleted", Qt::QueuedConnection, Q_ARG(uint, callerPid), Q_ARG(qint64, requestId), Q_ARG(Sailfish::Secrets::InteractionParameters, interactionParameters), Q_ARG(QString, interactionServiceAddress), Q_ARG(Sailfish::Secrets::Result, Sailfish::Secrets::Result(Sailfish::Secrets::Result::Succeeded)), Q_ARG(QByteArray, QByteArray("sailfish"))); // passphrase for importKey unit tests return Result(Result::Pending); } #endif if (interactionServiceAddress.isEmpty()) { return Result(Result::InteractionServiceUnknownError, QLatin1String("Invalid interaction service address for in-app authentication")); } InteractionRequestWatcher *watcher = new InteractionRequestWatcher(this); watcher->setRequestId(requestId); watcher->setCallerPid(callerPid); watcher->setInteractionParameters(interactionParameters); watcher->setInteractionServiceAddress(interactionServiceAddress); connect(watcher, static_cast<void (InteractionRequestWatcher::*)(quint64)>(&InteractionRequestWatcher::interactionRequestFinished), this, &Daemon::Plugins::InAppPlugin::interactionRequestFinished); connect(watcher, &InteractionRequestWatcher::interactionRequestResponse, this, &Daemon::Plugins::InAppPlugin::interactionRequestResponse); if (!watcher->connectToInteractionService()) { watcher->deleteLater(); return Result( Result::InteractionServiceUnavailableError, QString::fromUtf8("Unable to connect to ui service")); } if (!watcher->sendInteractionRequest()) { watcher->deleteLater(); return Result( Result::InteractionServiceRequestFailedError, QString::fromUtf8("Unable to send interaction request to ui service")); } m_requests.insert(requestId, watcher); return Result(Result::Pending); } void Daemon::Plugins::InAppPlugin::interactionRequestResponse( quint64 requestId, const InteractionResponse &response) { InteractionRequestWatcher *watcher = m_requests.value(requestId); if (watcher == Q_NULLPTR) { qCDebug(lcSailfishSecretsPluginInapp) << "Unknown ui request response:" << requestId; return; } m_responses.insert(requestId, response); watcher->finishInteractionRequest(); } void Daemon::Plugins::InAppPlugin::interactionRequestFinished( quint64 requestId) { InteractionRequestWatcher *watcher = m_requests.take(requestId); if (watcher == Q_NULLPTR) { qCDebug(lcSailfishSecretsPluginInapp) << "Unknown ui request finished:" << requestId; return; } watcher->disconnectFromInteractionService(); watcher->deleteLater(); InteractionResponse response = m_responses.take(requestId); emit userInputInteractionCompleted( watcher->callerPid(), watcher->requestId(), watcher->interactionParameters(), watcher->interactionServiceAddress(), response.result(), response.responseData()); }
; --------------------------------------------------------------------------- ; Copyright (c) 1998-2013, Brian Gladman, Worcester, UK. All rights reserved. ; ; The redistribution and use of this software (with or without changes) ; is allowed without the payment of fees or royalties provided that: ; ; source code distributions include the above copyright notice, this ; list of conditions and the following disclaimer; ; ; binary distributions include the above copyright notice, this list ; of conditions and the following disclaimer in their documentation. ; ; This software is provided 'as is' with no explicit or implied warranties ; in respect of its operation, including, but not limited to, correctness ; and fitness for purpose. ; --------------------------------------------------------------------------- ; Issue Date: 20/12/2007 ; ; I am grateful to Dag Arne Osvik for many discussions of the techniques that ; can be used to optimise AES assembler code on AMD64/EM64T architectures. ; Some of the techniques used in this implementation are the result of ; suggestions made by him for which I am most grateful. ; An AES implementation for AMD64 processors using the YASM assembler. This ; implemetation provides only encryption, decryption and hence requires key ; scheduling support in C. It uses 8k bytes of tables but its encryption and ; decryption performance is very close to that obtained using large tables. ; It can use either Windows or Gnu/Linux calling conventions, which are as ; follows: ; windows gnu/linux ; ; in_blk rcx rdi ; out_blk rdx rsi ; context (cx) r8 rdx ; ; preserved rsi - + rbx, rbp, rsp, r12, r13, r14 & r15 ; registers rdi - on both ; ; destroyed - rsi + rax, rcx, rdx, r8, r9, r10 & r11 ; registers - rdi on both ; ; The default convention is that for windows, the gnu/linux convention being ; used if __GNUC__ is defined. ; ; Define _SEH_ to include support for Win64 structured exception handling ; (this requires YASM version 0.6 or later). ; ; This code provides the standard AES block size (128 bits, 16 bytes) and the ; three standard AES key sizes (128, 192 and 256 bits). It has the same call ; interface as my C implementation. It uses the Microsoft C AMD64 calling ; conventions in which the three parameters are placed in rcx, rdx and r8 ; respectively. The rbx, rsi, rdi, rbp and r12..r15 registers are preserved. ; ; AES_RETURN aes_encrypt(const unsigned char in_blk[], ; unsigned char out_blk[], const aes_encrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt(const unsigned char in_blk[], ; unsigned char out_blk[], const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_encrypt_key<NNN>(const unsigned char key[], ; const aes_encrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt_key<NNN>(const unsigned char key[], ; const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_encrypt_key(const unsigned char key[], ; unsigned int len, const aes_decrypt_ctx cx[1]); ; ; AES_RETURN aes_decrypt_key(const unsigned char key[], ; unsigned int len, const aes_decrypt_ctx cx[1]); ; ; where <NNN> is 128, 192 or 256. In the last two calls the length can be in ; either bits or bytes. ;---------------------------------------------------------------------------- ; Comment in/out the following lines to obtain the desired subroutines. These ; selections MUST match those in the C header files aes.h and aesopt.h %define USE_INTEL_AES_IF_PRESENT %define AES_128 ; define if AES with 128 bit keys is needed %define AES_192 ; define if AES with 192 bit keys is needed %define AES_256 ; define if AES with 256 bit keys is needed %define AES_VAR ; define if a variable key size is needed %define ENCRYPTION ; define if encryption is needed %define DECRYPTION ; define if decryption is needed ;---------------------------------------------------------------------------- %ifdef USE_INTEL_AES_IF_PRESENT %define aes_ni(x) aes_ %+ x %+ _i %undef AES_REV_DKS %else %define aes_ni(x) aes_ %+ x %define AES_REV_DKS %endif %define LAST_ROUND_TABLES ; define for the faster version using extra tables ; The encryption key schedule has the following in memory layout where N is the ; number of rounds (10, 12 or 14): ; ; lo: | input key (round 0) | ; each round is four 32-bit words ; | encryption round 1 | ; | encryption round 2 | ; .... ; | encryption round N-1 | ; hi: | encryption round N | ; ; The decryption key schedule is normally set up so that it has the same ; layout as above by actually reversing the order of the encryption key ; schedule in memory (this happens when AES_REV_DKS is set): ; ; lo: | decryption round 0 | = | encryption round N | ; | decryption round 1 | = INV_MIX_COL[ | encryption round N-1 | ] ; | decryption round 2 | = INV_MIX_COL[ | encryption round N-2 | ] ; .... .... ; | decryption round N-1 | = INV_MIX_COL[ | encryption round 1 | ] ; hi: | decryption round N | = | input key (round 0) | ; ; with rounds except the first and last modified using inv_mix_column() ; But if AES_REV_DKS is NOT set the order of keys is left as it is for ; encryption so that it has to be accessed in reverse when used for ; decryption (although the inverse mix column modifications are done) ; ; lo: | decryption round 0 | = | input key (round 0) | ; | decryption round 1 | = INV_MIX_COL[ | encryption round 1 | ] ; | decryption round 2 | = INV_MIX_COL[ | encryption round 2 | ] ; .... .... ; | decryption round N-1 | = INV_MIX_COL[ | encryption round N-1 | ] ; hi: | decryption round N | = | encryption round N | ; ; This layout is faster when the assembler key scheduling is used (not ; used here). ; ; The DLL interface must use the _stdcall convention in which the number ; of bytes of parameter space is added after an @ to the rouutine's name. ; We must also remove our parameters from the stack before return (see ; the do_exit macro). Define DLL_EXPORT for the Dynamic Link Library version. ; %define DLL_EXPORT ; End of user defines %ifdef AES_VAR %ifndef AES_128 %define AES_128 %endif %ifndef AES_192 %define AES_192 %endif %ifndef AES_256 %define AES_256 %endif %endif %ifdef AES_VAR %define KS_LENGTH 60 %elifdef AES_256 %define KS_LENGTH 60 %elifdef AES_192 %define KS_LENGTH 52 %else %define KS_LENGTH 44 %endif %define r0 rax %define r1 rdx %define r2 rcx %define r3 rbx %define r4 rsi %define r5 rdi %define r6 rbp %define r7 rsp %define raxd eax %define rdxd edx %define rcxd ecx %define rbxd ebx %define rsid esi %define rdid edi %define rbpd ebp %define rspd esp %define raxb al %define rdxb dl %define rcxb cl %define rbxb bl %define rsib sil %define rdib dil %define rbpb bpl %define rspb spl %define r0h ah %define r1h dh %define r2h ch %define r3h bh %define r0d eax %define r1d edx %define r2d ecx %define r3d ebx ; finite field multiplies by {02}, {04} and {08} %define f2(x) ((x<<1)^(((x>>7)&1)*0x11b)) %define f4(x) ((x<<2)^(((x>>6)&1)*0x11b)^(((x>>6)&2)*0x11b)) %define f8(x) ((x<<3)^(((x>>5)&1)*0x11b)^(((x>>5)&2)*0x11b)^(((x>>5)&4)*0x11b)) ; finite field multiplies required in table generation %define f3(x) (f2(x) ^ x) %define f9(x) (f8(x) ^ x) %define fb(x) (f8(x) ^ f2(x) ^ x) %define fd(x) (f8(x) ^ f4(x) ^ x) %define fe(x) (f8(x) ^ f4(x) ^ f2(x)) ; macro for expanding S-box data %macro enc_vals 1 db %1(0x63),%1(0x7c),%1(0x77),%1(0x7b),%1(0xf2),%1(0x6b),%1(0x6f),%1(0xc5) db %1(0x30),%1(0x01),%1(0x67),%1(0x2b),%1(0xfe),%1(0xd7),%1(0xab),%1(0x76) db %1(0xca),%1(0x82),%1(0xc9),%1(0x7d),%1(0xfa),%1(0x59),%1(0x47),%1(0xf0) db %1(0xad),%1(0xd4),%1(0xa2),%1(0xaf),%1(0x9c),%1(0xa4),%1(0x72),%1(0xc0) db %1(0xb7),%1(0xfd),%1(0x93),%1(0x26),%1(0x36),%1(0x3f),%1(0xf7),%1(0xcc) db %1(0x34),%1(0xa5),%1(0xe5),%1(0xf1),%1(0x71),%1(0xd8),%1(0x31),%1(0x15) db %1(0x04),%1(0xc7),%1(0x23),%1(0xc3),%1(0x18),%1(0x96),%1(0x05),%1(0x9a) db %1(0x07),%1(0x12),%1(0x80),%1(0xe2),%1(0xeb),%1(0x27),%1(0xb2),%1(0x75) db %1(0x09),%1(0x83),%1(0x2c),%1(0x1a),%1(0x1b),%1(0x6e),%1(0x5a),%1(0xa0) db %1(0x52),%1(0x3b),%1(0xd6),%1(0xb3),%1(0x29),%1(0xe3),%1(0x2f),%1(0x84) db %1(0x53),%1(0xd1),%1(0x00),%1(0xed),%1(0x20),%1(0xfc),%1(0xb1),%1(0x5b) db %1(0x6a),%1(0xcb),%1(0xbe),%1(0x39),%1(0x4a),%1(0x4c),%1(0x58),%1(0xcf) db %1(0xd0),%1(0xef),%1(0xaa),%1(0xfb),%1(0x43),%1(0x4d),%1(0x33),%1(0x85) db %1(0x45),%1(0xf9),%1(0x02),%1(0x7f),%1(0x50),%1(0x3c),%1(0x9f),%1(0xa8) db %1(0x51),%1(0xa3),%1(0x40),%1(0x8f),%1(0x92),%1(0x9d),%1(0x38),%1(0xf5) db %1(0xbc),%1(0xb6),%1(0xda),%1(0x21),%1(0x10),%1(0xff),%1(0xf3),%1(0xd2) db %1(0xcd),%1(0x0c),%1(0x13),%1(0xec),%1(0x5f),%1(0x97),%1(0x44),%1(0x17) db %1(0xc4),%1(0xa7),%1(0x7e),%1(0x3d),%1(0x64),%1(0x5d),%1(0x19),%1(0x73) db %1(0x60),%1(0x81),%1(0x4f),%1(0xdc),%1(0x22),%1(0x2a),%1(0x90),%1(0x88) db %1(0x46),%1(0xee),%1(0xb8),%1(0x14),%1(0xde),%1(0x5e),%1(0x0b),%1(0xdb) db %1(0xe0),%1(0x32),%1(0x3a),%1(0x0a),%1(0x49),%1(0x06),%1(0x24),%1(0x5c) db %1(0xc2),%1(0xd3),%1(0xac),%1(0x62),%1(0x91),%1(0x95),%1(0xe4),%1(0x79) db %1(0xe7),%1(0xc8),%1(0x37),%1(0x6d),%1(0x8d),%1(0xd5),%1(0x4e),%1(0xa9) db %1(0x6c),%1(0x56),%1(0xf4),%1(0xea),%1(0x65),%1(0x7a),%1(0xae),%1(0x08) db %1(0xba),%1(0x78),%1(0x25),%1(0x2e),%1(0x1c),%1(0xa6),%1(0xb4),%1(0xc6) db %1(0xe8),%1(0xdd),%1(0x74),%1(0x1f),%1(0x4b),%1(0xbd),%1(0x8b),%1(0x8a) db %1(0x70),%1(0x3e),%1(0xb5),%1(0x66),%1(0x48),%1(0x03),%1(0xf6),%1(0x0e) db %1(0x61),%1(0x35),%1(0x57),%1(0xb9),%1(0x86),%1(0xc1),%1(0x1d),%1(0x9e) db %1(0xe1),%1(0xf8),%1(0x98),%1(0x11),%1(0x69),%1(0xd9),%1(0x8e),%1(0x94) db %1(0x9b),%1(0x1e),%1(0x87),%1(0xe9),%1(0xce),%1(0x55),%1(0x28),%1(0xdf) db %1(0x8c),%1(0xa1),%1(0x89),%1(0x0d),%1(0xbf),%1(0xe6),%1(0x42),%1(0x68) db %1(0x41),%1(0x99),%1(0x2d),%1(0x0f),%1(0xb0),%1(0x54),%1(0xbb),%1(0x16) %endmacro %macro dec_vals 1 db %1(0x52),%1(0x09),%1(0x6a),%1(0xd5),%1(0x30),%1(0x36),%1(0xa5),%1(0x38) db %1(0xbf),%1(0x40),%1(0xa3),%1(0x9e),%1(0x81),%1(0xf3),%1(0xd7),%1(0xfb) db %1(0x7c),%1(0xe3),%1(0x39),%1(0x82),%1(0x9b),%1(0x2f),%1(0xff),%1(0x87) db %1(0x34),%1(0x8e),%1(0x43),%1(0x44),%1(0xc4),%1(0xde),%1(0xe9),%1(0xcb) db %1(0x54),%1(0x7b),%1(0x94),%1(0x32),%1(0xa6),%1(0xc2),%1(0x23),%1(0x3d) db %1(0xee),%1(0x4c),%1(0x95),%1(0x0b),%1(0x42),%1(0xfa),%1(0xc3),%1(0x4e) db %1(0x08),%1(0x2e),%1(0xa1),%1(0x66),%1(0x28),%1(0xd9),%1(0x24),%1(0xb2) db %1(0x76),%1(0x5b),%1(0xa2),%1(0x49),%1(0x6d),%1(0x8b),%1(0xd1),%1(0x25) db %1(0x72),%1(0xf8),%1(0xf6),%1(0x64),%1(0x86),%1(0x68),%1(0x98),%1(0x16) db %1(0xd4),%1(0xa4),%1(0x5c),%1(0xcc),%1(0x5d),%1(0x65),%1(0xb6),%1(0x92) db %1(0x6c),%1(0x70),%1(0x48),%1(0x50),%1(0xfd),%1(0xed),%1(0xb9),%1(0xda) db %1(0x5e),%1(0x15),%1(0x46),%1(0x57),%1(0xa7),%1(0x8d),%1(0x9d),%1(0x84) db %1(0x90),%1(0xd8),%1(0xab),%1(0x00),%1(0x8c),%1(0xbc),%1(0xd3),%1(0x0a) db %1(0xf7),%1(0xe4),%1(0x58),%1(0x05),%1(0xb8),%1(0xb3),%1(0x45),%1(0x06) db %1(0xd0),%1(0x2c),%1(0x1e),%1(0x8f),%1(0xca),%1(0x3f),%1(0x0f),%1(0x02) db %1(0xc1),%1(0xaf),%1(0xbd),%1(0x03),%1(0x01),%1(0x13),%1(0x8a),%1(0x6b) db %1(0x3a),%1(0x91),%1(0x11),%1(0x41),%1(0x4f),%1(0x67),%1(0xdc),%1(0xea) db %1(0x97),%1(0xf2),%1(0xcf),%1(0xce),%1(0xf0),%1(0xb4),%1(0xe6),%1(0x73) db %1(0x96),%1(0xac),%1(0x74),%1(0x22),%1(0xe7),%1(0xad),%1(0x35),%1(0x85) db %1(0xe2),%1(0xf9),%1(0x37),%1(0xe8),%1(0x1c),%1(0x75),%1(0xdf),%1(0x6e) db %1(0x47),%1(0xf1),%1(0x1a),%1(0x71),%1(0x1d),%1(0x29),%1(0xc5),%1(0x89) db %1(0x6f),%1(0xb7),%1(0x62),%1(0x0e),%1(0xaa),%1(0x18),%1(0xbe),%1(0x1b) db %1(0xfc),%1(0x56),%1(0x3e),%1(0x4b),%1(0xc6),%1(0xd2),%1(0x79),%1(0x20) db %1(0x9a),%1(0xdb),%1(0xc0),%1(0xfe),%1(0x78),%1(0xcd),%1(0x5a),%1(0xf4) db %1(0x1f),%1(0xdd),%1(0xa8),%1(0x33),%1(0x88),%1(0x07),%1(0xc7),%1(0x31) db %1(0xb1),%1(0x12),%1(0x10),%1(0x59),%1(0x27),%1(0x80),%1(0xec),%1(0x5f) db %1(0x60),%1(0x51),%1(0x7f),%1(0xa9),%1(0x19),%1(0xb5),%1(0x4a),%1(0x0d) db %1(0x2d),%1(0xe5),%1(0x7a),%1(0x9f),%1(0x93),%1(0xc9),%1(0x9c),%1(0xef) db %1(0xa0),%1(0xe0),%1(0x3b),%1(0x4d),%1(0xae),%1(0x2a),%1(0xf5),%1(0xb0) db %1(0xc8),%1(0xeb),%1(0xbb),%1(0x3c),%1(0x83),%1(0x53),%1(0x99),%1(0x61) db %1(0x17),%1(0x2b),%1(0x04),%1(0x7e),%1(0xba),%1(0x77),%1(0xd6),%1(0x26) db %1(0xe1),%1(0x69),%1(0x14),%1(0x63),%1(0x55),%1(0x21),%1(0x0c),%1(0x7d) %endmacro %define u8(x) f2(x), x, x, f3(x), f2(x), x, x, f3(x) %define v8(x) fe(x), f9(x), fd(x), fb(x), fe(x), f9(x), fd(x), x %define w8(x) x, 0, 0, 0, x, 0, 0, 0 %define tptr rbp ; table pointer %define kptr r8 ; key schedule pointer %define fofs 128 ; adjust offset in key schedule to keep |disp| < 128 %define fk_ref(x,y) [kptr-16*x+fofs+4*y] %ifdef AES_REV_DKS %define rofs 128 %define ik_ref(x,y) [kptr-16*x+rofs+4*y] %else %define rofs -128 %define ik_ref(x,y) [kptr+16*x+rofs+4*y] %endif %define tab_0(x) [tptr+8*x] %define tab_1(x) [tptr+8*x+3] %define tab_2(x) [tptr+8*x+2] %define tab_3(x) [tptr+8*x+1] %define tab_f(x) byte [tptr+8*x+1] %define tab_i(x) byte [tptr+8*x+7] %define t_ref(x,r) tab_ %+ x(r) %macro ff_rnd 5 ; normal forward round mov %1d, fk_ref(%5,0) mov %2d, fk_ref(%5,1) mov %3d, fk_ref(%5,2) mov %4d, fk_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 xor %1d, t_ref(0,rsi) xor %4d, t_ref(1,rdi) movzx esi, al movzx edi, ah xor %3d, t_ref(2,rsi) xor %2d, t_ref(3,rdi) movzx esi, bl movzx edi, bh shr ebx, 16 xor %2d, t_ref(0,rsi) xor %1d, t_ref(1,rdi) movzx esi, bl movzx edi, bh xor %4d, t_ref(2,rsi) xor %3d, t_ref(3,rdi) movzx esi, cl movzx edi, ch shr ecx, 16 xor %3d, t_ref(0,rsi) xor %2d, t_ref(1,rdi) movzx esi, cl movzx edi, ch xor %1d, t_ref(2,rsi) xor %4d, t_ref(3,rdi) movzx esi, dl movzx edi, dh shr edx, 16 xor %4d, t_ref(0,rsi) xor %3d, t_ref(1,rdi) movzx esi, dl movzx edi, dh xor %2d, t_ref(2,rsi) xor %1d, t_ref(3,rdi) mov eax,%1d mov ebx,%2d mov ecx,%3d mov edx,%4d %endmacro %ifdef LAST_ROUND_TABLES %macro fl_rnd 5 ; last forward round add tptr, 2048 mov %1d, fk_ref(%5,0) mov %2d, fk_ref(%5,1) mov %3d, fk_ref(%5,2) mov %4d, fk_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 xor %1d, t_ref(0,rsi) xor %4d, t_ref(1,rdi) movzx esi, al movzx edi, ah xor %3d, t_ref(2,rsi) xor %2d, t_ref(3,rdi) movzx esi, bl movzx edi, bh shr ebx, 16 xor %2d, t_ref(0,rsi) xor %1d, t_ref(1,rdi) movzx esi, bl movzx edi, bh xor %4d, t_ref(2,rsi) xor %3d, t_ref(3,rdi) movzx esi, cl movzx edi, ch shr ecx, 16 xor %3d, t_ref(0,rsi) xor %2d, t_ref(1,rdi) movzx esi, cl movzx edi, ch xor %1d, t_ref(2,rsi) xor %4d, t_ref(3,rdi) movzx esi, dl movzx edi, dh shr edx, 16 xor %4d, t_ref(0,rsi) xor %3d, t_ref(1,rdi) movzx esi, dl movzx edi, dh xor %2d, t_ref(2,rsi) xor %1d, t_ref(3,rdi) %endmacro %else %macro fl_rnd 5 ; last forward round mov %1d, fk_ref(%5,0) mov %2d, fk_ref(%5,1) mov %3d, fk_ref(%5,2) mov %4d, fk_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) xor %1d, esi rol edi, 8 xor %4d, edi movzx esi, al movzx edi, ah movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) rol esi, 16 rol edi, 24 xor %3d, esi xor %2d, edi movzx esi, bl movzx edi, bh shr ebx, 16 movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) xor %2d, esi rol edi, 8 xor %1d, edi movzx esi, bl movzx edi, bh movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) rol esi, 16 rol edi, 24 xor %4d, esi xor %3d, edi movzx esi, cl movzx edi, ch movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) shr ecx, 16 xor %3d, esi rol edi, 8 xor %2d, edi movzx esi, cl movzx edi, ch movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) rol esi, 16 rol edi, 24 xor %1d, esi xor %4d, edi movzx esi, dl movzx edi, dh movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) shr edx, 16 xor %4d, esi rol edi, 8 xor %3d, edi movzx esi, dl movzx edi, dh movzx esi, t_ref(f,rsi) movzx edi, t_ref(f,rdi) rol esi, 16 rol edi, 24 xor %2d, esi xor %1d, edi %endmacro %endif %macro ii_rnd 5 ; normal inverse round mov %1d, ik_ref(%5,0) mov %2d, ik_ref(%5,1) mov %3d, ik_ref(%5,2) mov %4d, ik_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 xor %1d, t_ref(0,rsi) xor %2d, t_ref(1,rdi) movzx esi, al movzx edi, ah xor %3d, t_ref(2,rsi) xor %4d, t_ref(3,rdi) movzx esi, bl movzx edi, bh shr ebx, 16 xor %2d, t_ref(0,rsi) xor %3d, t_ref(1,rdi) movzx esi, bl movzx edi, bh xor %4d, t_ref(2,rsi) xor %1d, t_ref(3,rdi) movzx esi, cl movzx edi, ch shr ecx, 16 xor %3d, t_ref(0,rsi) xor %4d, t_ref(1,rdi) movzx esi, cl movzx edi, ch xor %1d, t_ref(2,rsi) xor %2d, t_ref(3,rdi) movzx esi, dl movzx edi, dh shr edx, 16 xor %4d, t_ref(0,rsi) xor %1d, t_ref(1,rdi) movzx esi, dl movzx edi, dh xor %2d, t_ref(2,rsi) xor %3d, t_ref(3,rdi) mov eax,%1d mov ebx,%2d mov ecx,%3d mov edx,%4d %endmacro %ifdef LAST_ROUND_TABLES %macro il_rnd 5 ; last inverse round add tptr, 2048 mov %1d, ik_ref(%5,0) mov %2d, ik_ref(%5,1) mov %3d, ik_ref(%5,2) mov %4d, ik_ref(%5,3) movzx esi, al movzx edi, ah shr eax, 16 xor %1d, t_ref(0,rsi) xor %2d, t_ref(1,rdi) movzx esi, al movzx edi, ah xor %3d, t_ref(2,rsi) xor %4d, t_ref(3,rdi) movzx esi, bl movzx edi, bh shr ebx, 16 xor %2d, t_ref(0,rsi) xor %3d, t_ref(1,rdi) movzx esi, bl movzx edi, bh xor %4d, t_ref(2,rsi) xor %1d, t_ref(3,rdi) movzx esi, cl movzx edi, ch shr ecx, 16 xor %3d, t_ref(0,rsi) xor %4d, t_ref(1,rdi) movzx esi, cl movzx edi, ch xor %1d, t_ref(2,rsi) xor %2d, t_ref(3,rdi) movzx esi, dl movzx edi, dh shr edx, 16 xor %4d, t_ref(0,rsi) xor %1d, t_ref(1,rdi) movzx esi, dl movzx edi, dh xor %2d, t_ref(2,rsi) xor %3d, t_ref(3,rdi) %endmacro %else %macro il_rnd 5 ; last inverse round mov %1d, ik_ref(%5,0) mov %2d, ik_ref(%5,1) mov %3d, ik_ref(%5,2) mov %4d, ik_ref(%5,3) movzx esi, al movzx edi, ah movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) shr eax, 16 xor %1d, esi rol edi, 8 xor %2d, edi movzx esi, al movzx edi, ah movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) rol esi, 16 rol edi, 24 xor %3d, esi xor %4d, edi movzx esi, bl movzx edi, bh movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) shr ebx, 16 xor %2d, esi rol edi, 8 xor %3d, edi movzx esi, bl movzx edi, bh movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) rol esi, 16 rol edi, 24 xor %4d, esi xor %1d, edi movzx esi, cl movzx edi, ch movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) shr ecx, 16 xor %3d, esi rol edi, 8 xor %4d, edi movzx esi, cl movzx edi, ch movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) rol esi, 16 rol edi, 24 xor %1d, esi xor %2d, edi movzx esi, dl movzx edi, dh movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) shr edx, 16 xor %4d, esi rol edi, 8 xor %1d, edi movzx esi, dl movzx edi, dh movzx esi, t_ref(i,rsi) movzx edi, t_ref(i,rdi) rol esi, 16 rol edi, 24 xor %2d, esi xor %3d, edi %endmacro %endif %ifdef ENCRYPTION global aes_ni(encrypt) %ifdef DLL_EXPORT export aes_ni(encrypt) %endif section .data align=64 align 64 enc_tab: enc_vals u8 %ifdef LAST_ROUND_TABLES enc_vals w8 %endif section .text align=16 align 16 %ifdef _SEH_ proc_frame aes_ni(encrypt) alloc_stack 7*8 ; 7 to align stack to 16 bytes save_reg rsi,4*8 save_reg rdi,5*8 save_reg rbx,1*8 save_reg rbp,2*8 save_reg r12,3*8 end_prologue mov rdi, rcx ; input pointer mov [rsp+0*8], rdx ; output pointer %else aes_ni(encrypt): %ifdef __GNUC__ sub rsp, 4*8 ; gnu/linux binary interface mov [rsp+0*8], rsi ; output pointer mov r8, rdx ; context %else sub rsp, 6*8 ; windows binary interface mov [rsp+4*8], rsi mov [rsp+5*8], rdi mov rdi, rcx ; input pointer mov [rsp+0*8], rdx ; output pointer %endif mov [rsp+1*8], rbx ; input pointer in rdi mov [rsp+2*8], rbp ; output pointer in [rsp] mov [rsp+3*8], r12 ; context in r8 %endif movzx esi, byte [kptr+4*KS_LENGTH] lea tptr, [rel enc_tab] sub kptr, fofs mov eax, [rdi+0*4] mov ebx, [rdi+1*4] mov ecx, [rdi+2*4] mov edx, [rdi+3*4] xor eax, [kptr+fofs] xor ebx, [kptr+fofs+4] xor ecx, [kptr+fofs+8] xor edx, [kptr+fofs+12] lea kptr,[kptr+rsi] cmp esi, 10*16 je .3 cmp esi, 12*16 je .2 cmp esi, 14*16 je .1 mov rax, -1 jmp .4 .1: ff_rnd r9, r10, r11, r12, 13 ff_rnd r9, r10, r11, r12, 12 .2: ff_rnd r9, r10, r11, r12, 11 ff_rnd r9, r10, r11, r12, 10 .3: ff_rnd r9, r10, r11, r12, 9 ff_rnd r9, r10, r11, r12, 8 ff_rnd r9, r10, r11, r12, 7 ff_rnd r9, r10, r11, r12, 6 ff_rnd r9, r10, r11, r12, 5 ff_rnd r9, r10, r11, r12, 4 ff_rnd r9, r10, r11, r12, 3 ff_rnd r9, r10, r11, r12, 2 ff_rnd r9, r10, r11, r12, 1 fl_rnd r9, r10, r11, r12, 0 mov rbx, [rsp] mov [rbx], r9d mov [rbx+4], r10d mov [rbx+8], r11d mov [rbx+12], r12d xor rax, rax .4: mov rbx, [rsp+1*8] mov rbp, [rsp+2*8] mov r12, [rsp+3*8] %ifdef __GNUC__ add rsp, 4*8 ret %else mov rsi, [rsp+4*8] mov rdi, [rsp+5*8] %ifdef _SEH_ add rsp, 7*8 ret endproc_frame %else add rsp, 6*8 ret %endif %endif %endif %ifdef DECRYPTION global aes_ni(decrypt) %ifdef DLL_EXPORT export aes_ni(decrypt) %endif section .data align 64 dec_tab: dec_vals v8 %ifdef LAST_ROUND_TABLES dec_vals w8 %endif section .text align 16 %ifdef _SEH_ proc_frame aes_ni(decrypt) alloc_stack 7*8 ; 7 to align stack to 16 bytes save_reg rsi,4*8 save_reg rdi,5*8 save_reg rbx,1*8 save_reg rbp,2*8 save_reg r12,3*8 end_prologue mov rdi, rcx ; input pointer mov [rsp+0*8], rdx ; output pointer %else aes_ni(decrypt): %ifdef __GNUC__ sub rsp, 4*8 ; gnu/linux binary interface mov [rsp+0*8], rsi ; output pointer mov r8, rdx ; context %else sub rsp, 6*8 ; windows binary interface mov [rsp+4*8], rsi mov [rsp+5*8], rdi mov rdi, rcx ; input pointer mov [rsp+0*8], rdx ; output pointer %endif mov [rsp+1*8], rbx ; input pointer in rdi mov [rsp+2*8], rbp ; output pointer in [rsp] mov [rsp+3*8], r12 ; context in r8 %endif movzx esi, byte[kptr+4*KS_LENGTH] lea tptr, [rel dec_tab] sub kptr, rofs mov eax, [rdi+0*4] mov ebx, [rdi+1*4] mov ecx, [rdi+2*4] mov edx, [rdi+3*4] %ifdef AES_REV_DKS mov rdi, kptr lea kptr,[kptr+rsi] %else lea rdi,[kptr+rsi] %endif xor eax, [rdi+rofs] xor ebx, [rdi+rofs+4] xor ecx, [rdi+rofs+8] xor edx, [rdi+rofs+12] cmp esi, 10*16 je .3 cmp esi, 12*16 je .2 cmp esi, 14*16 je .1 mov rax, -1 jmp .4 .1: ii_rnd r9, r10, r11, r12, 13 ii_rnd r9, r10, r11, r12, 12 .2: ii_rnd r9, r10, r11, r12, 11 ii_rnd r9, r10, r11, r12, 10 .3: ii_rnd r9, r10, r11, r12, 9 ii_rnd r9, r10, r11, r12, 8 ii_rnd r9, r10, r11, r12, 7 ii_rnd r9, r10, r11, r12, 6 ii_rnd r9, r10, r11, r12, 5 ii_rnd r9, r10, r11, r12, 4 ii_rnd r9, r10, r11, r12, 3 ii_rnd r9, r10, r11, r12, 2 ii_rnd r9, r10, r11, r12, 1 il_rnd r9, r10, r11, r12, 0 mov rbx, [rsp] mov [rbx], r9d mov [rbx+4], r10d mov [rbx+8], r11d mov [rbx+12], r12d xor rax, rax .4: mov rbx, [rsp+1*8] mov rbp, [rsp+2*8] mov r12, [rsp+3*8] %ifdef __GNUC__ add rsp, 4*8 ret %else mov rsi, [rsp+4*8] mov rdi, [rsp+5*8] %ifdef _SEH_ add rsp, 7*8 ret endproc_frame %else add rsp, 6*8 ret %endif %endif %endif end
#pragma once #include <cstdlib> #include <iostream> #include <map> namespace flg { using namespace std; enum class Symbol { min_term, boxed_bool, boxed_i32, boxed_i64, boxed_fp32, boxed_fp64, boxed_string, /* INSERT 0 */ max_term }; ostream& operator<<(ostream& out, const Symbol& sym) { switch (sym) { case Symbol::min_term: return out << "min_term"; case Symbol::boxed_bool: return out << "boxed_bool"; case Symbol::boxed_i32: return out << "boxed_i32"; case Symbol::boxed_i64: return out << "boxed_i64"; case Symbol::boxed_fp32: return out << "boxed_fp32"; case Symbol::boxed_fp64: return out << "boxed_fp64"; case Symbol::boxed_string: return out << "boxed_string"; /* INSERT 1 */ case Symbol::max_term: return out << "max_term"; } __builtin_unreachable(); } map<string, Symbol> symbol_table; void initialize_symbols() { /* INSERT 2 */ } Symbol lookup_symbol(const string& name) { auto it = symbol_table.find(name); if (it != symbol_table.end()) { return it->second; } cerr << "Unrecognized symbol: " << name << endl; abort(); __builtin_unreachable(); } Symbol lookup_tuple_symbol(size_t arity) { switch (arity) { /* INSERT 3 */ default: cerr << "Unrecognized tuple arity: " << arity << endl; abort(); } __builtin_unreachable(); } size_t symbol_arity(const Symbol& sym) { switch (sym) { /* INSERT 4 */ default: abort(); } __builtin_unreachable(); } } // namespace flg
// Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "cldnn_program.h" #include "cldnn_common_utils.h" #include "ngraph/op/proposal.hpp" #include "cldnn/primitives/proposal.hpp" #include "cldnn/primitives/mutable_data.hpp" #include "cldnn/runtime/debug_configuration.hpp" namespace CLDNNPlugin { static void CreateProposalOp(Program& p, const std::shared_ptr<ngraph::op::v0::Proposal>& op) { p.ValidateInputs(op, {3}); auto inputPrimitives = p.GetInputPrimitiveIDs(op); auto attrs = op->get_attrs(); float nms_thresh = attrs.nms_thresh; int min_size = attrs.min_size; int feature_stride = attrs.feat_stride; int pre_nms_topn = attrs.pre_nms_topn; int post_nms_topn = attrs.post_nms_topn; const std::vector<float> ratio = attrs.ratio; const std::vector<float> scale = attrs.scale; float box_coordinate_scale = attrs.box_coordinate_scale; float box_size_scale = attrs.box_size_scale; int base_size = attrs.base_size; std::string framework = attrs.framework; bool normalize = attrs.normalize; bool clip_before_nms = attrs.clip_before_nms; bool clip_after_nms = attrs.clip_after_nms; float coordinates_offset; bool swap_xy; bool initial_clip; bool round_ratios; bool shift_anchors; if (framework == "tensorflow") { coordinates_offset = 0.0f; initial_clip = true; shift_anchors = true; round_ratios = false; swap_xy = true; } else { coordinates_offset = 1.0f; initial_clip = false; shift_anchors = false; round_ratios = true; swap_xy = false; } if (op->get_output_size() == 2) { auto mutable_precision = op->get_output_element_type(1); if (mutable_precision == ngraph::element::i64) { mutable_precision = ngraph::element::i32; } cldnn::layout mutableLayout = cldnn::layout(DataTypeFromPrecision(mutable_precision), DefaultFormatForDims(op->get_output_shape(1).size()), CldnnTensorFromIEDims(op->get_output_shape(1))); GPU_DEBUG_GET_INSTANCE(debug_config); GPU_DEBUG_IF(debug_config->verbose >= 2) { GPU_DEBUG_COUT << "[" << layer_type_name_ID(op) << ": mutable data]" << std::endl; } auto shared_memory = p.GetEngine().allocate_memory(mutableLayout); cldnn::primitive_id proposal_mutable_id_w = layer_type_name_ID(op) + "_md_write"; auto argmax_mutable_prim = cldnn::mutable_data(proposal_mutable_id_w, shared_memory, op->get_friendly_name()); p.primitiveIDs[proposal_mutable_id_w] = proposal_mutable_id_w; p.AddPrimitive(argmax_mutable_prim); inputPrimitives.push_back(proposal_mutable_id_w); std::string proposalLayerName = layer_type_name_ID(op) + ".0"; auto proposalPrim = cldnn::proposal(proposalLayerName, inputPrimitives[0], // cls_score inputPrimitives[1], // bbox_pred inputPrimitives[2], // im_info inputPrimitives[3], // second_output 0, // max_num_proposals is unused nms_thresh, base_size, min_size, feature_stride, pre_nms_topn, post_nms_topn, ratio, scale, coordinates_offset, box_coordinate_scale, box_size_scale, false, swap_xy, initial_clip, clip_before_nms, clip_after_nms, round_ratios, shift_anchors, normalize, op->get_friendly_name()); p.AddPrimitive(proposalPrim); cldnn::primitive_id proposal_mutable_id_r = layer_type_name_ID(op) + ".1"; auto argmax_mutable_prim_r = cldnn::mutable_data(proposal_mutable_id_r, { proposalLayerName }, shared_memory, op->get_friendly_name()); p.primitiveIDs[proposal_mutable_id_r] = proposal_mutable_id_r; p.AddPrimitive(argmax_mutable_prim_r); p.AddPrimitiveToProfiler(proposalLayerName, op); return; } std::string proposalLayerName = layer_type_name_ID(op); auto proposalPrim = cldnn::proposal(proposalLayerName, inputPrimitives[0], // cls_score inputPrimitives[1], // bbox_pred inputPrimitives[2], // im_info 0, // max_num_proposals is unused nms_thresh, base_size, min_size, feature_stride, pre_nms_topn, post_nms_topn, ratio, scale, coordinates_offset, box_coordinate_scale, box_size_scale, false, swap_xy, initial_clip, clip_before_nms, clip_after_nms, round_ratios, shift_anchors, normalize, op->get_friendly_name()); p.AddPrimitive(proposalPrim); p.AddPrimitiveToProfiler(op); } REGISTER_FACTORY_IMPL(v0, Proposal); REGISTER_FACTORY_IMPL(v4, Proposal); } // namespace CLDNNPlugin
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2017 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 <chain.h> #include <chainparams.h> #include <core_io.h> #include <index/txindex.h> #include <primitives/block.h> #include <primitives/transaction.h> #include <validation.h> #include <httpserver.h> #include <rpc/blockchain.h> #include <rpc/server.h> #include <streams.h> #include <sync.h> #include <txmempool.h> #include <utilstrencodings.h> #include <version.h> #include <boost/algorithm/string.hpp> #include <univalue.h> static const size_t MAX_GETUTXOS_OUTPOINTS = 15; //allow a max of 15 outpoints to be queried at once enum class RetFormat { UNDEF, BINARY, HEX, JSON, }; static const struct { RetFormat rf; const char* name; } rf_names[] = { {RetFormat::UNDEF, ""}, {RetFormat::BINARY, "bin"}, {RetFormat::HEX, "hex"}, {RetFormat::JSON, "json"}, }; struct CCoin { uint32_t nHeight; CTxOut out; ADD_SERIALIZE_METHODS; CCoin() : nHeight(0) {} explicit CCoin(Coin&& in) : nHeight(in.nHeight), out(std::move(in.out)) {} template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { uint32_t nTxVerDummy = 0; READWRITE(nTxVerDummy); READWRITE(nHeight); READWRITE(out); } }; static bool RESTERR(HTTPRequest* req, enum HTTPStatusCode status, std::string message) { req->WriteHeader("Content-Type", "text/plain"); req->WriteReply(status, message + "\r\n"); return false; } static RetFormat ParseDataFormat(std::string& param, const std::string& strReq) { const std::string::size_type pos = strReq.rfind('.'); if (pos == std::string::npos) { param = strReq; return rf_names[0].rf; } param = strReq.substr(0, pos); const std::string suff(strReq, pos + 1); for (unsigned int i = 0; i < ARRAYLEN(rf_names); i++) if (suff == rf_names[i].name) return rf_names[i].rf; /* If no suffix is found, return original string. */ param = strReq; return rf_names[0].rf; } static std::string AvailableDataFormatsString() { std::string formats; for (unsigned int i = 0; i < ARRAYLEN(rf_names); i++) if (strlen(rf_names[i].name) > 0) { formats.append("."); formats.append(rf_names[i].name); formats.append(", "); } if (formats.length() > 0) return formats.substr(0, formats.length() - 2); return formats; } static bool ParseHashStr(const std::string& strReq, uint256& v) { if (!IsHex(strReq) || (strReq.size() != 64)) return false; v.SetHex(strReq); return true; } static bool CheckWarmup(HTTPRequest* req) { std::string statusmessage; if (RPCIsInWarmup(&statusmessage)) return RESTERR(req, HTTP_SERVICE_UNAVAILABLE, "Service temporarily unavailable: " + statusmessage); return true; } static bool rest_headers(HTTPRequest* req, const std::string& strURIPart) { if (!CheckWarmup(req)) return false; std::string param; const RetFormat rf = ParseDataFormat(param, strURIPart); std::vector<std::string> path; boost::split(path, param, boost::is_any_of("/")); if (path.size() != 2) return RESTERR(req, HTTP_BAD_REQUEST, "No header count specified. Use /rest/headers/<count>/<hash>.<ext>."); long count = strtol(path[0].c_str(), nullptr, 10); if (count < 1 || count > 2000) return RESTERR(req, HTTP_BAD_REQUEST, "Header count out of range: " + path[0]); std::string hashStr = path[1]; uint256 hash; if (!ParseHashStr(hashStr, hash)) return RESTERR(req, HTTP_BAD_REQUEST, "Invalid hash: " + hashStr); std::vector<const CBlockIndex *> headers; headers.reserve(count); { LOCK(cs_main); const CBlockIndex* pindex = LookupBlockIndex(hash); while (pindex != nullptr && chainActive.Contains(pindex)) { headers.push_back(pindex); if (headers.size() == (unsigned long)count) break; pindex = chainActive.Next(pindex); } } CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION); for (const CBlockIndex *pindex : headers) { ssHeader << pindex->GetBlockHeader(); } switch (rf) { case RetFormat::BINARY: { std::string binaryHeader = ssHeader.str(); req->WriteHeader("Content-Type", "application/octet-stream"); req->WriteReply(HTTP_OK, binaryHeader); return true; } case RetFormat::HEX: { std::string strHex = HexStr(ssHeader.begin(), ssHeader.end()) + "\n"; req->WriteHeader("Content-Type", "text/plain"); req->WriteReply(HTTP_OK, strHex); return true; } case RetFormat::JSON: { UniValue jsonHeaders(UniValue::VARR); { LOCK(cs_main); for (const CBlockIndex *pindex : headers) { jsonHeaders.push_back(blockheaderToJSON(pindex)); } } std::string strJSON = jsonHeaders.write() + "\n"; req->WriteHeader("Content-Type", "application/json"); req->WriteReply(HTTP_OK, strJSON); return true; } default: { return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: .bin, .hex)"); } } } static bool rest_block(HTTPRequest* req, const std::string& strURIPart, bool showTxDetails) { if (!CheckWarmup(req)) return false; std::string hashStr; const RetFormat rf = ParseDataFormat(hashStr, strURIPart); uint256 hash; if (!ParseHashStr(hashStr, hash)) return RESTERR(req, HTTP_BAD_REQUEST, "Invalid hash: " + hashStr); CBlock block; CBlockIndex* pblockindex = nullptr; { LOCK(cs_main); pblockindex = LookupBlockIndex(hash); if (!pblockindex) { return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not available (pruned data)"); if (!ReadBlockFromDisk(block, pblockindex, Params().GetConsensus())) return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); } CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); ssBlock << block; switch (rf) { case RetFormat::BINARY: { std::string binaryBlock = ssBlock.str(); req->WriteHeader("Content-Type", "application/octet-stream"); req->WriteReply(HTTP_OK, binaryBlock); return true; } case RetFormat::HEX: { std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()) + "\n"; req->WriteHeader("Content-Type", "text/plain"); req->WriteReply(HTTP_OK, strHex); return true; } case RetFormat::JSON: { UniValue objBlock; { LOCK(cs_main); objBlock = blockToJSON(block, pblockindex, showTxDetails); } std::string strJSON = objBlock.write() + "\n"; req->WriteHeader("Content-Type", "application/json"); req->WriteReply(HTTP_OK, strJSON); return true; } default: { return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + AvailableDataFormatsString() + ")"); } } } static bool rest_block_extended(HTTPRequest* req, const std::string& strURIPart) { return rest_block(req, strURIPart, true); } static bool rest_block_notxdetails(HTTPRequest* req, const std::string& strURIPart) { return rest_block(req, strURIPart, false); } // A bit of a hack - dependency on a function defined in rpc/blockchain.cpp UniValue getblockchaininfo(const JSONRPCRequest& request); static bool rest_chaininfo(HTTPRequest* req, const std::string& strURIPart) { if (!CheckWarmup(req)) return false; std::string param; const RetFormat rf = ParseDataFormat(param, strURIPart); switch (rf) { case RetFormat::JSON: { JSONRPCRequest jsonRequest; jsonRequest.params = UniValue(UniValue::VARR); UniValue chainInfoObject = getblockchaininfo(jsonRequest); std::string strJSON = chainInfoObject.write() + "\n"; req->WriteHeader("Content-Type", "application/json"); req->WriteReply(HTTP_OK, strJSON); return true; } default: { return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: json)"); } } } static bool rest_mempool_info(HTTPRequest* req, const std::string& strURIPart) { if (!CheckWarmup(req)) return false; std::string param; const RetFormat rf = ParseDataFormat(param, strURIPart); switch (rf) { case RetFormat::JSON: { UniValue mempoolInfoObject = mempoolInfoToJSON(); std::string strJSON = mempoolInfoObject.write() + "\n"; req->WriteHeader("Content-Type", "application/json"); req->WriteReply(HTTP_OK, strJSON); return true; } default: { return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: json)"); } } } static bool rest_mempool_contents(HTTPRequest* req, const std::string& strURIPart) { if (!CheckWarmup(req)) return false; std::string param; const RetFormat rf = ParseDataFormat(param, strURIPart); switch (rf) { case RetFormat::JSON: { UniValue mempoolObject = mempoolToJSON(true); std::string strJSON = mempoolObject.write() + "\n"; req->WriteHeader("Content-Type", "application/json"); req->WriteReply(HTTP_OK, strJSON); return true; } default: { return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: json)"); } } } static bool rest_tx(HTTPRequest* req, const std::string& strURIPart) { if (!CheckWarmup(req)) return false; std::string hashStr; const RetFormat rf = ParseDataFormat(hashStr, strURIPart); uint256 hash; if (!ParseHashStr(hashStr, hash)) return RESTERR(req, HTTP_BAD_REQUEST, "Invalid hash: " + hashStr); if (g_txindex) { g_txindex->BlockUntilSyncedToCurrentChain(); } CTransactionRef tx; uint256 hashBlock = uint256(); if (!GetTransaction(hash, tx, Params().GetConsensus(), hashBlock, true)) return RESTERR(req, HTTP_NOT_FOUND, hashStr + " not found"); CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); ssTx << tx; switch (rf) { case RetFormat::BINARY: { std::string binaryTx = ssTx.str(); req->WriteHeader("Content-Type", "application/octet-stream"); req->WriteReply(HTTP_OK, binaryTx); return true; } case RetFormat::HEX: { std::string strHex = HexStr(ssTx.begin(), ssTx.end()) + "\n"; req->WriteHeader("Content-Type", "text/plain"); req->WriteReply(HTTP_OK, strHex); return true; } case RetFormat::JSON: { UniValue objTx(UniValue::VOBJ); TxToUniv(*tx, hashBlock, objTx); std::string strJSON = objTx.write() + "\n"; req->WriteHeader("Content-Type", "application/json"); req->WriteReply(HTTP_OK, strJSON); return true; } default: { return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + AvailableDataFormatsString() + ")"); } } } static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart) { if (!CheckWarmup(req)) return false; std::string param; const RetFormat rf = ParseDataFormat(param, strURIPart); std::vector<std::string> uriParts; if (param.length() > 1) { std::string strUriParams = param.substr(1); boost::split(uriParts, strUriParams, boost::is_any_of("/")); } // throw exception in case of an empty request std::string strRequestMutable = req->ReadBody(); if (strRequestMutable.length() == 0 && uriParts.size() == 0) return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request"); bool fInputParsed = false; bool fCheckMemPool = false; std::vector<COutPoint> vOutPoints; // parse/deserialize input // input-format = output-format, rest/getutxos/bin requires binary input, gives binary output, ... if (uriParts.size() > 0) { //inputs is sent over URI scheme (/rest/getutxos/checkmempool/txid1-n/txid2-n/...) if (uriParts[0] == "checkmempool") fCheckMemPool = true; for (size_t i = (fCheckMemPool) ? 1 : 0; i < uriParts.size(); i++) { uint256 txid; int32_t nOutput; std::string strTxid = uriParts[i].substr(0, uriParts[i].find('-')); std::string strOutput = uriParts[i].substr(uriParts[i].find('-')+1); if (!ParseInt32(strOutput, &nOutput) || !IsHex(strTxid)) return RESTERR(req, HTTP_BAD_REQUEST, "Parse error"); txid.SetHex(strTxid); vOutPoints.push_back(COutPoint(txid, (uint32_t)nOutput)); } if (vOutPoints.size() > 0) fInputParsed = true; else return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request"); } switch (rf) { case RetFormat::HEX: { // convert hex to bin, continue then with bin part std::vector<unsigned char> strRequestV = ParseHex(strRequestMutable); strRequestMutable.assign(strRequestV.begin(), strRequestV.end()); } case RetFormat::BINARY: { try { //deserialize only if user sent a request if (strRequestMutable.size() > 0) { if (fInputParsed) //don't allow sending input over URI and HTTP RAW DATA return RESTERR(req, HTTP_BAD_REQUEST, "Combination of URI scheme inputs and raw post data is not allowed"); CDataStream oss(SER_NETWORK, PROTOCOL_VERSION); oss << strRequestMutable; oss >> fCheckMemPool; oss >> vOutPoints; } } catch (const std::ios_base::failure& e) { // abort in case of unreadable binary data return RESTERR(req, HTTP_BAD_REQUEST, "Parse error"); } break; } case RetFormat::JSON: { if (!fInputParsed) return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request"); break; } default: { return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + AvailableDataFormatsString() + ")"); } } // limit max outpoints if (vOutPoints.size() > MAX_GETUTXOS_OUTPOINTS) return RESTERR(req, HTTP_BAD_REQUEST, strprintf("Error: max outpoints exceeded (max: %d, tried: %d)", MAX_GETUTXOS_OUTPOINTS, vOutPoints.size())); // check spentness and form a bitmap (as well as a JSON capable human-readable string representation) std::vector<unsigned char> bitmap; std::vector<CCoin> outs; std::string bitmapStringRepresentation; std::vector<bool> hits; bitmap.resize((vOutPoints.size() + 7) / 8); { auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const CTxMemPool& mempool) { for (const COutPoint& vOutPoint : vOutPoints) { Coin coin; bool hit = !mempool.isSpent(vOutPoint) && view.GetCoin(vOutPoint, coin); hits.push_back(hit); if (hit) outs.emplace_back(std::move(coin)); } }; if (fCheckMemPool) { // use db+mempool as cache backend in case user likes to query mempool LOCK2(cs_main, mempool.cs); CCoinsViewCache& viewChain = *pcoinsTip; CCoinsViewMemPool viewMempool(&viewChain, mempool); process_utxos(viewMempool, mempool); } else { LOCK(cs_main); // no need to lock mempool! process_utxos(*pcoinsTip, CTxMemPool()); } for (size_t i = 0; i < hits.size(); ++i) { const bool hit = hits[i]; bitmapStringRepresentation.append(hit ? "1" : "0"); // form a binary string representation (human-readable for json output) bitmap[i / 8] |= ((uint8_t)hit) << (i % 8); } } switch (rf) { case RetFormat::BINARY: { // serialize data // use exact same output as mentioned in Bip64 CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION); ssGetUTXOResponse << chainActive.Height() << chainActive.Tip()->GetBlockHash() << bitmap << outs; std::string ssGetUTXOResponseString = ssGetUTXOResponse.str(); req->WriteHeader("Content-Type", "application/octet-stream"); req->WriteReply(HTTP_OK, ssGetUTXOResponseString); return true; } case RetFormat::HEX: { CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION); ssGetUTXOResponse << chainActive.Height() << chainActive.Tip()->GetBlockHash() << bitmap << outs; std::string strHex = HexStr(ssGetUTXOResponse.begin(), ssGetUTXOResponse.end()) + "\n"; req->WriteHeader("Content-Type", "text/plain"); req->WriteReply(HTTP_OK, strHex); return true; } case RetFormat::JSON: { UniValue objGetUTXOResponse(UniValue::VOBJ); // pack in some essentials // use more or less the same output as mentioned in Bip64 objGetUTXOResponse.pushKV("chainHeight", chainActive.Height()); objGetUTXOResponse.pushKV("chaintipHash", chainActive.Tip()->GetBlockHash().GetHex()); objGetUTXOResponse.pushKV("bitmap", bitmapStringRepresentation); UniValue utxos(UniValue::VARR); for (const CCoin& coin : outs) { UniValue utxo(UniValue::VOBJ); utxo.pushKV("height", (int32_t)coin.nHeight); utxo.pushKV("value", ValueFromAmount(coin.out.nValue)); // include the script in a json output UniValue o(UniValue::VOBJ); ScriptPubKeyToUniv(coin.out.scriptPubKey, o, true); utxo.pushKV("scriptPubKey", o); utxos.push_back(utxo); } objGetUTXOResponse.pushKV("utxos", utxos); // return json string std::string strJSON = objGetUTXOResponse.write() + "\n"; req->WriteHeader("Content-Type", "application/json"); req->WriteReply(HTTP_OK, strJSON); return true; } default: { return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + AvailableDataFormatsString() + ")"); } } } static const struct { const char* prefix; bool (*handler)(HTTPRequest* req, const std::string& strReq); } uri_prefixes[] = { {"/rest/tx/", rest_tx}, {"/rest/block/notxdetails/", rest_block_notxdetails}, {"/rest/block/", rest_block_extended}, {"/rest/chaininfo", rest_chaininfo}, {"/rest/mempool/info", rest_mempool_info}, {"/rest/mempool/contents", rest_mempool_contents}, {"/rest/headers/", rest_headers}, {"/rest/getutxos", rest_getutxos}, }; bool StartREST() { for (unsigned int i = 0; i < ARRAYLEN(uri_prefixes); i++) RegisterHTTPHandler(uri_prefixes[i].prefix, false, uri_prefixes[i].handler); return true; } void InterruptREST() { } void StopREST() { for (unsigned int i = 0; i < ARRAYLEN(uri_prefixes); i++) UnregisterHTTPHandler(uri_prefixes[i].prefix, false); }
#if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) #include <boost/proto/transform/detail/preprocessed/when.hpp> #elif !defined(BOOST_PP_IS_ITERATING) #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) #pragma wave option(preserve: 2, line: 0, output: "preprocessed/when.hpp") #endif /////////////////////////////////////////////////////////////////////////////// /// \file when.hpp /// Definition of when transform. // // Copyright 2008 Eric Niebler. Distributed under the Boost // Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) #pragma wave option(preserve: 1) #endif #define BOOST_PP_ITERATION_PARAMS_1 \ (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/detail/when.hpp>)) #include BOOST_PP_ITERATE() #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) #pragma wave option(output: null) #endif #else #define N BOOST_PP_ITERATION() /// \brief A grammar element and a PrimitiveTransform that associates /// a transform with the grammar. /// /// Use <tt>when\<\></tt> to override a grammar's default transform /// with a custom transform. It is for used when composing larger /// transforms by associating smaller transforms with individual /// rules in your grammar, as in the following transform which /// counts the number of terminals in an expression. /// /// \code /// // Count the terminals in an expression tree. /// // Must be invoked with initial state == mpl::int_<0>(). /// struct CountLeaves /// : or_< /// when<terminal<_>, mpl::next<_state>()> /// , otherwise<fold<_, _state, CountLeaves> > /// > /// {}; /// \endcode /// /// The <tt>when\<G, R(A0,A1,...)\></tt> form accepts either a /// CallableTransform or an ObjectTransform as its second parameter. /// <tt>when\<\></tt> uses <tt>is_callable\<R\>::value</tt> to /// distinguish between the two, and uses <tt>call\<\></tt> to /// evaluate CallableTransforms and <tt>make\<\></tt> to evaluate /// ObjectTransforms. template<typename Grammar, typename R BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> struct when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A))> : transform<when<Grammar, R(BOOST_PP_ENUM_PARAMS(N, A))> > { typedef Grammar first; typedef R second(BOOST_PP_ENUM_PARAMS(N, A)); typedef typename Grammar::proto_grammar proto_grammar; // Note: do not evaluate is_callable<R> in this scope. // R may be an incomplete type at this point. template<typename Expr, typename State, typename Data> struct impl : transform_impl<Expr, State, Data> { // OK to evaluate is_callable<R> here. R should be compete by now. typedef typename mpl::if_c< is_callable<R>::value , call<R(BOOST_PP_ENUM_PARAMS(N, A))> // "R" is a function to call , make<R(BOOST_PP_ENUM_PARAMS(N, A))> // "R" is an object to construct >::type which; typedef typename which::template impl<Expr, State, Data>::result_type result_type; /// Evaluate <tt>R(A0,A1,...)</tt> as a transform either with /// <tt>call\<\></tt> or with <tt>make\<\></tt> depending on /// whether <tt>is_callable\<R\>::value</tt> is \c true or /// \c false. /// /// \param e The current expression /// \param s The current state /// \param d An arbitrary data /// \pre <tt>matches\<Expr, Grammar\>::value</tt> is \c true /// \return <tt>which()(e, s, d)</tt> result_type operator ()( typename impl::expr_param e , typename impl::state_param s , typename impl::data_param d ) const { return typename which::template impl<Expr, State, Data>()(e, s, d); } }; }; #undef N #endif
/* * Copyright (C) 2020-2021 Intel Corporation * * SPDX-License-Identifier: MIT * */ #include "shared/source/debugger/debugger.h" #include "shared/source/device/device.h" #include "shared/source/helpers/api_specific_config.h" #include "shared/source/helpers/basic_math.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/os_interface/hw_info_config.h" #include "shared/source/source_level_debugger/source_level_debugger.h" #include <iomanip> namespace NEO { static const char *spirvWithVersion = "SPIR-V_1.2 "; void Device::initializeCaps() { auto &hwInfo = getHardwareInfo(); auto hwInfoConfig = HwInfoConfig::get(hwInfo.platform.eProductFamily); auto addressing32bitAllowed = is64bit; auto &hwHelper = HwHelper::get(hwInfo.platform.eRenderCoreFamily); bool ocl21FeaturesEnabled = hwInfo.capabilityTable.supportsOcl21Features; if (DebugManager.flags.ForceOCLVersion.get() != 0) { ocl21FeaturesEnabled = (DebugManager.flags.ForceOCLVersion.get() == 21); } if (DebugManager.flags.ForceOCL21FeaturesSupport.get() != -1) { ocl21FeaturesEnabled = DebugManager.flags.ForceOCL21FeaturesSupport.get(); } if (ocl21FeaturesEnabled) { addressing32bitAllowed = false; } deviceInfo.sharedSystemAllocationsSupport = hwInfoConfig->getSharedSystemMemCapabilities(); if (DebugManager.flags.EnableSharedSystemUsmSupport.get() != -1) { deviceInfo.sharedSystemAllocationsSupport = DebugManager.flags.EnableSharedSystemUsmSupport.get(); } deviceInfo.vendorId = 0x8086; deviceInfo.maxReadImageArgs = 128; deviceInfo.maxWriteImageArgs = 128; deviceInfo.maxParameterSize = 2048; deviceInfo.addressBits = 64; deviceInfo.ilVersion = spirvWithVersion; //copy system info to prevent misaligned reads const auto systemInfo = hwInfo.gtSystemInfo; deviceInfo.globalMemCachelineSize = 64; uint32_t allSubDevicesMask = static_cast<uint32_t>(getDeviceBitfield().to_ulong()); constexpr uint32_t singleSubDeviceMask = 1; deviceInfo.globalMemSize = getGlobalMemorySize(allSubDevicesMask); deviceInfo.maxMemAllocSize = getGlobalMemorySize(singleSubDeviceMask); // Allocation can be placed only on one SubDevice if (DebugManager.flags.Force32bitAddressing.get() || addressing32bitAllowed || is32bit) { double percentOfGlobalMemoryAvailable = getPercentOfGlobalMemoryAvailable(); deviceInfo.globalMemSize = std::min(deviceInfo.globalMemSize, static_cast<uint64_t>(4 * GB * percentOfGlobalMemoryAvailable)); deviceInfo.addressBits = 32; deviceInfo.force32BitAddressess = is64bit; } deviceInfo.globalMemSize = alignDown(deviceInfo.globalMemSize, MemoryConstants::pageSize); deviceInfo.maxMemAllocSize = std::min(deviceInfo.globalMemSize, deviceInfo.maxMemAllocSize); // if globalMemSize was reduced for 32b if (!deviceInfo.sharedSystemAllocationsSupport) { deviceInfo.maxMemAllocSize = ApiSpecificConfig::getReducedMaxAllocSize(deviceInfo.maxMemAllocSize); deviceInfo.maxMemAllocSize = std::min(deviceInfo.maxMemAllocSize, this->hardwareCapabilities.maxMemAllocSize); } // Some specific driver model configurations may impose additional limitations auto driverModelMaxMemAlloc = std::numeric_limits<size_t>::max(); if (this->executionEnvironment->rootDeviceEnvironments[0]->osInterface) { driverModelMaxMemAlloc = this->executionEnvironment->rootDeviceEnvironments[0]->osInterface->getDriverModel()->getMaxMemAllocSize(); } deviceInfo.maxMemAllocSize = std::min<std::uint64_t>(driverModelMaxMemAlloc, deviceInfo.maxMemAllocSize); deviceInfo.profilingTimerResolution = getProfilingTimerResolution(); if (DebugManager.flags.OverrideProfilingTimerResolution.get() != -1) { deviceInfo.profilingTimerResolution = static_cast<double>(DebugManager.flags.OverrideProfilingTimerResolution.get()); deviceInfo.outProfilingTimerClock = static_cast<size_t>(1000000000.0 / deviceInfo.profilingTimerResolution); } else { deviceInfo.outProfilingTimerClock = static_cast<size_t>(getProfilingTimerClock()); } deviceInfo.outProfilingTimerResolution = static_cast<size_t>(deviceInfo.profilingTimerResolution); constexpr uint64_t maxPixelSize = 16; deviceInfo.imageMaxBufferSize = static_cast<size_t>(deviceInfo.maxMemAllocSize / maxPixelSize); deviceInfo.maxNumEUsPerSubSlice = 0; deviceInfo.numThreadsPerEU = 0; auto simdSizeUsed = DebugManager.flags.UseMaxSimdSizeToDeduceMaxWorkgroupSize.get() ? CommonConstants::maximalSimdSize : hwHelper.getMinimalSIMDSize(); deviceInfo.maxNumEUsPerSubSlice = (systemInfo.EuCountPerPoolMin == 0 || hwInfo.featureTable.ftrPooledEuEnabled == 0) ? (systemInfo.EUCount / systemInfo.SubSliceCount) : systemInfo.EuCountPerPoolMin; if (systemInfo.DualSubSliceCount != 0) { deviceInfo.maxNumEUsPerDualSubSlice = (systemInfo.EuCountPerPoolMin == 0 || hwInfo.featureTable.ftrPooledEuEnabled == 0) ? (systemInfo.EUCount / systemInfo.DualSubSliceCount) : systemInfo.EuCountPerPoolMin; } else { deviceInfo.maxNumEUsPerDualSubSlice = deviceInfo.maxNumEUsPerSubSlice; } deviceInfo.numThreadsPerEU = systemInfo.ThreadCount / systemInfo.EUCount; deviceInfo.threadsPerEUConfigs = hwHelper.getThreadsPerEUConfigs(); auto maxWS = hwInfoConfig->getMaxThreadsForWorkgroupInDSSOrSS(hwInfo, static_cast<uint32_t>(deviceInfo.maxNumEUsPerSubSlice), static_cast<uint32_t>(deviceInfo.maxNumEUsPerDualSubSlice)) * simdSizeUsed; maxWS = Math::prevPowerOfTwo(maxWS); deviceInfo.maxWorkGroupSize = std::min(maxWS, 1024u); if (DebugManager.flags.OverrideMaxWorkgroupSize.get() != -1) { deviceInfo.maxWorkGroupSize = DebugManager.flags.OverrideMaxWorkgroupSize.get(); } deviceInfo.maxWorkItemSizes[0] = deviceInfo.maxWorkGroupSize; deviceInfo.maxWorkItemSizes[1] = deviceInfo.maxWorkGroupSize; deviceInfo.maxWorkItemSizes[2] = deviceInfo.maxWorkGroupSize; deviceInfo.maxSamplers = hwHelper.getMaxNumSamplers(); deviceInfo.computeUnitsUsedForScratch = hwHelper.getComputeUnitsUsedForScratch(&hwInfo); deviceInfo.maxFrontEndThreads = HwHelper::getMaxThreadsForVfe(hwInfo); deviceInfo.localMemSize = hwInfo.capabilityTable.slmSize * KB; if (DebugManager.flags.OverrideSlmSize.get() != -1) { deviceInfo.localMemSize = DebugManager.flags.OverrideSlmSize.get() * KB; } deviceInfo.imageSupport = hwInfo.capabilityTable.supportsImages; deviceInfo.image2DMaxWidth = 16384; deviceInfo.image2DMaxHeight = 16384; deviceInfo.image3DMaxDepth = 2048; deviceInfo.imageMaxArraySize = 2048; deviceInfo.printfBufferSize = 4 * MB; deviceInfo.maxClockFrequency = hwInfo.capabilityTable.maxRenderFrequency; deviceInfo.maxSubGroups = hwHelper.getDeviceSubGroupSizes(); deviceInfo.vmeAvcSupportsPreemption = hwInfo.capabilityTable.ftrSupportsVmeAvcPreemption; NEO::Debugger *debugger = getRootDeviceEnvironment().debugger.get(); deviceInfo.debuggerActive = false; if (debugger) { UNRECOVERABLE_IF(!debugger->isLegacy()); deviceInfo.debuggerActive = static_cast<NEO::SourceLevelDebugger *>(debugger)->isDebuggerActive(); } if (deviceInfo.debuggerActive) { this->preemptionMode = PreemptionMode::Disabled; } std::stringstream deviceName; deviceName << this->getDeviceName(hwInfo); deviceName << " [0x" << std::hex << std::setw(4) << std::setfill('0') << hwInfo.platform.usDeviceID << "]"; deviceInfo.name = deviceName.str(); } } // namespace NEO
; A152205: Triangle read by rows, A000012 * A152204. ; Submitted by Jon Maiga ; 1,4,9,1,16,4,25,9,1,36,16,4,49,25,9,1,64,36,16,4,81,49,25,9,1,100,64,36,16,4,121,81,49,25,9,1,144,100,64,36,16,4,169,121,81,49,25,9,1 seq $0,122196 ; Fractal sequence: count down by 2's from successive integers. pow $0,2
section .text global get_max get_max: push ebp mov ebp, esp ; [ebp+8] is array pointer ; [ebp+12] is array length mov ebx, [ebp+8] mov ecx, [ebp+12] xor eax, eax compare: cmp eax, [ebx+ecx*4-4] jge check_end mov eax, [ebx+ecx*4-4] check_end: loopnz compare leave ret
// Copyright (c) 2011-2021 The Khronos Group, Inc. // SPDX-License-Identifier: Apache-2.0 const size_t nElems = 10u; // Create a vector and fill it with values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 std::vector<int> v { nElems }; std::iota(std::begin(v), std::end(v), 0); // Create a buffer with no associated user storage sycl::buffer<int, 1> b { range<1>(nElems) }; // Create a queue queue myQueue; myQueue.submit([&](handler &cgh) { // Retrieve a ranged write accessor to a global buffer with access to the // first half of the buffer accessor acc { b, cgh, range<1>(nElems / 2), id<1>(0), write_only }; // Copy the first five elements of the vector into the buffer associated with // the accessor cgh.copy(v.data(), acc); });
org $0000 ; Object types OBJECT_NONE EQU 0 OBJECT_SWITCH EQU 1 OBJECT_DOOR EQU 2 OBJECT_DOOR_DESTROY EQU 3 OBJECT_FLOOR_DESTROY EQU 4 OBJECT_WALL_DESTROY EQU 5 OBJECT_BOX_LEFT EQU 6 OBJECT_BOX_RIGHT EQU 7 OBJECT_JAR EQU 8 OBJECT_TELEPORTER EQU 9 ; Pickable object types OBJECT_KEY_GREEN EQU 11 OBJECT_KEY_BLUE EQU 12 OBJECT_KEY_YELLOW EQU 13 OBJECT_BREAD EQU 14 OBJECT_MEAT EQU 15 OBJECT_HEALTH EQU 16 OBJECT_KEY_RED EQU 17 OBJECT_KEY_WHITE EQU 18 OBJECT_KEY_PURPLE EQU 19 ; Object types for enemies OBJECT_ENEMY_SKELETON EQU 20 OBJECT_ENEMY_ORC EQU 21 OBJECT_ENEMY_MUMMY EQU 22 OBJECT_ENEMY_TROLL EQU 23 OBJECT_ENEMY_ROCK EQU 24 OBJECT_ENEMY_KNIGHT EQU 25 OBJECT_ENEMY_DALGURAK EQU 26 OBJECT_ENEMY_GOLEM EQU 27 OBJECT_ENEMY_OGRE EQU 28 OBJECT_ENEMY_MINOTAUR EQU 29 OBJECT_ENEMY_DEMON EQU 30 OBJECT_ENEMY_SECONDARY EQU 31 Screen_5_0: DB 58, 2, 3, 103, 75, 76, 61, 62, 75, 76, 61, 62, 4, 2, 3, 2 DB 77, 3, 2, 3, 2, 2, 2, 4, 2, 2, 6, 2, 3, 2, 2, 6 DB 78, 2, 2, 2, 4, 2, 2, 2, 6, 3, 4, 4, 4, 2, 3, 2 DB 61, 62, 102, 2, 4, 4, 2, 3, 4, 2, 3, 2, 2, 2, 71, 140 DB 77, 248, 2, 2, 2, 2, 2, 2, 2, 2, 6, 2, 71, 140, 0, 18 DB 58, 69, 0, 0, 0, 21, 61, 62, 75, 76, 61, 62, 75, 76, 35, 36 DB 77, 146, 0, 0, 0, 0, 146, 0, 0, 0, 0, 144, 0, 0, 146, 98 DB 74, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 147, 100 DB 76, 10, 11, 12, 13, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76 DB 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15 HardScreen_5_0: DB 66, 85, 85, 170 DB 64, 0, 0, 0 DB 64, 0, 0, 0 DB 88, 0, 0, 13 DB 80, 0, 0, 213 DB 80, 37, 85, 85 DB 80, 0, 0, 1 DB 80, 0, 0, 1 DB 85, 192, 0, 1 DB 85, 85, 85, 85 Obj_5_0: DB 1 ; PLAYER DB 6, OBJECT_ENEMY_ORC, 13, 7, 0, 47 DB 9, OBJECT_ENEMY_ORC, 8, 3, 0, 47 DB 0, OBJECT_NONE, 0, 0, 0, 0 ; EMPTY OBJECT DB 0, OBJECT_NONE, 0, 0, 0, 0 ; EMPTY OBJECT DB 0, OBJECT_NONE, 0, 0, 0, 0 ; EMPTY OBJECT DB 0, OBJECT_NONE, 0, 0, 0, 0 ; EMPTY OBJECT DB 0, OBJECT_NONE, 0, 0, 0, 0 ; EMPTY OBJECT
; A029714: a(n) = Sum_{k divides 3^n} S(k), where S is the Kempner function A002034. ; 1,4,10,19,28,40,55,73,91,112,136,163,190,217,247,280,316,352,391,433,478,523,571,622,676,730,784,841,901,964,1027,1093,1162,1234,1306,1381,1459,1540,1621,1702,1783,1867,1954,2044,2134,2227,2323,2422,2521,2623 mov $34,$0 mov $36,$0 add $36,1 lpb $36,1 clr $0,34 mov $0,$34 sub $36,1 sub $0,$36 mov $31,$0 mov $33,$0 add $33,1 lpb $33,1 mov $0,$31 sub $33,1 sub $0,$33 mov $27,$0 mov $29,2 lpb $29,1 mov $0,$27 sub $29,1 add $0,$29 sub $0,1 cal $0,80579 ; a(1)=1; for n>1, a(n)=a(n-1)+1 if n is already in the sequence, a(n)=a(n-1)+4 otherwise. mov $3,$0 sub $3,1 mov $26,$3 cmp $26,0 add $3,$26 add $3,1 mov $1,$3 mov $30,$29 lpb $30,1 mov $28,$1 sub $30,1 lpe lpe lpb $27,1 mov $27,0 sub $28,$1 lpe mov $1,$28 sub $1,1 add $32,$1 lpe add $35,$32 lpe mov $1,$35
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"",%progbits .text p224r1_data: _prime224r1: .long 0x1, 0x0, 0x0, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF .p2align 5, 0x90 .type h9_add_224, @function h9_add_224: movl (%esi), %eax addl (%ebx), %eax movl %eax, (%edi) movl (4)(%esi), %eax adcl (4)(%ebx), %eax movl %eax, (4)(%edi) movl (8)(%esi), %eax adcl (8)(%ebx), %eax movl %eax, (8)(%edi) movl (12)(%esi), %eax adcl (12)(%ebx), %eax movl %eax, (12)(%edi) movl (16)(%esi), %eax adcl (16)(%ebx), %eax movl %eax, (16)(%edi) movl (20)(%esi), %eax adcl (20)(%ebx), %eax movl %eax, (20)(%edi) movl (24)(%esi), %eax adcl (24)(%ebx), %eax movl %eax, (24)(%edi) mov $(0), %eax adc $(0), %eax ret .Lfe1: .size h9_add_224, .Lfe1-(h9_add_224) .p2align 5, 0x90 .type h9_sub_224, @function h9_sub_224: movl (%esi), %eax subl (%ebx), %eax movl %eax, (%edi) movl (4)(%esi), %eax sbbl (4)(%ebx), %eax movl %eax, (4)(%edi) movl (8)(%esi), %eax sbbl (8)(%ebx), %eax movl %eax, (8)(%edi) movl (12)(%esi), %eax sbbl (12)(%ebx), %eax movl %eax, (12)(%edi) movl (16)(%esi), %eax sbbl (16)(%ebx), %eax movl %eax, (16)(%edi) movl (20)(%esi), %eax sbbl (20)(%ebx), %eax movl %eax, (20)(%edi) movl (24)(%esi), %eax sbbl (24)(%ebx), %eax movl %eax, (24)(%edi) mov $(0), %eax adc $(0), %eax ret .Lfe2: .size h9_sub_224, .Lfe2-(h9_sub_224) .p2align 5, 0x90 .type h9_shl_224, @function h9_shl_224: movdqu (%esi), %xmm0 movdqu (12)(%esi), %xmm1 movl (24)(%esi), %eax psrldq $(4), %xmm1 movdqa %xmm0, %xmm2 psllq $(1), %xmm0 psrlq $(63), %xmm2 movdqa %xmm1, %xmm3 psllq $(1), %xmm1 psrlq $(63), %xmm3 palignr $(8), %xmm2, %xmm3 pslldq $(8), %xmm2 por %xmm3, %xmm1 por %xmm2, %xmm0 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) psrldq $(8), %xmm1 movd %xmm1, (24)(%edi) shr $(31), %eax ret .Lfe3: .size h9_shl_224, .Lfe3-(h9_shl_224) .p2align 5, 0x90 .type h9_shr_224, @function h9_shr_224: movdqu (%esi), %xmm0 movdqu (12)(%esi), %xmm2 movd %eax, %xmm1 palignr $(4), %xmm2, %xmm1 movdqa %xmm0, %xmm2 psrlq $(1), %xmm0 psllq $(63), %xmm2 movdqa %xmm1, %xmm3 psrlq $(1), %xmm1 psllq $(63), %xmm3 movdqa %xmm3, %xmm4 palignr $(8), %xmm2, %xmm3 psrldq $(8), %xmm4 por %xmm3, %xmm0 por %xmm4, %xmm1 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) psrldq $(8), %xmm1 movd %xmm1, (24)(%edi) ret .Lfe4: .size h9_shr_224, .Lfe4-(h9_shr_224) .p2align 5, 0x90 .globl h9_p224r1_add .type h9_p224r1_add, @function h9_p224r1_add: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebx call h9_add_224 mov %eax, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call h9_sub_224 lea (%esp), %esi movl (8)(%ebp), %edi sub %eax, %edx cmovne %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe5: .size h9_p224r1_add, .Lfe5-(h9_p224r1_add) .p2align 5, 0x90 .globl h9_p224r1_sub .type h9_p224r1_sub, @function h9_p224r1_sub: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebx call h9_sub_224 mov %eax, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call h9_add_224 lea (%esp), %esi movl (8)(%ebp), %edi test %edx, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe6: .size h9_p224r1_sub, .Lfe6-(h9_p224r1_sub) .p2align 5, 0x90 .globl h9_p224r1_neg .type h9_p224r1_neg, @function h9_p224r1_neg: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi mov $(0), %eax subl (%esi), %eax movl %eax, (%edi) mov $(0), %eax sbbl (4)(%esi), %eax movl %eax, (4)(%edi) mov $(0), %eax sbbl (8)(%esi), %eax movl %eax, (8)(%edi) mov $(0), %eax sbbl (12)(%esi), %eax movl %eax, (12)(%edi) mov $(0), %eax sbbl (16)(%esi), %eax movl %eax, (16)(%edi) mov $(0), %eax sbbl (20)(%esi), %eax movl %eax, (20)(%edi) mov $(0), %eax sbbl (24)(%esi), %eax movl %eax, (24)(%edi) sbb %edx, %edx lea (%esp), %edi movl (8)(%ebp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call h9_add_224 lea (%esp), %esi movl (8)(%ebp), %edi test %edx, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe7: .size h9_p224r1_neg, .Lfe7-(h9_p224r1_neg) .p2align 5, 0x90 .globl h9_p224r1_mul_by_2 .type h9_p224r1_mul_by_2, @function h9_p224r1_mul_by_2: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call h9_shl_224 mov %eax, %edx mov %edi, %esi movl (8)(%ebp), %edi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call h9_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe8: .size h9_p224r1_mul_by_2, .Lfe8-(h9_p224r1_mul_by_2) .p2align 5, 0x90 .globl h9_p224r1_mul_by_3 .type h9_p224r1_mul_by_3, @function h9_p224r1_mul_by_3: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(64), %esp and $(-16), %esp movl %eax, (60)(%esp) lea p224r1_data, %eax lea ((_prime224r1-p224r1_data))(%eax), %eax movl %eax, (56)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi call h9_shl_224 mov %eax, %edx mov %edi, %esi lea (28)(%esp), %edi mov (56)(%esp), %ebx call h9_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov %edi, %esi movl (12)(%ebp), %ebx call h9_add_224 mov %eax, %edx movl (8)(%ebp), %edi mov (56)(%esp), %ebx call h9_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (60)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe9: .size h9_p224r1_mul_by_3, .Lfe9-(h9_p224r1_mul_by_3) .p2align 5, 0x90 .globl h9_p224r1_div_by_2 .type h9_p224r1_div_by_2, @function h9_p224r1_div_by_2: push %ebp mov %esp, %ebp push %ebx push %esi push %edi mov %esp, %eax sub $(32), %esp and $(-16), %esp movl %eax, (28)(%esp) lea (%esp), %edi movl (12)(%ebp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call h9_add_224 mov $(0), %edx movl (%esi), %ecx and $(1), %ecx cmovne %edi, %esi cmove %edx, %eax movl (8)(%ebp), %edi call h9_shr_224 mov (28)(%esp), %esp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe10: .size h9_p224r1_div_by_2, .Lfe10-(h9_p224r1_div_by_2) .p2align 5, 0x90 .globl h9_p224r1_mul_mont_slm .type h9_p224r1_mul_mont_slm, @function h9_p224r1_mul_mont_slm: push %ebp mov %esp, %ebp push %ebx push %esi push %edi push %ebp mov %esp, %eax sub $(48), %esp and $(-16), %esp movl %eax, (44)(%esp) pxor %mm0, %mm0 movq %mm0, (%esp) movq %mm0, (8)(%esp) movq %mm0, (16)(%esp) movq %mm0, (24)(%esp) movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %ebp movl %edi, (32)(%esp) movl %esi, (36)(%esp) movl %ebp, (40)(%esp) mov $(7), %edi movd (4)(%esi), %mm1 movd (8)(%esi), %mm2 movd (12)(%esi), %mm3 movd (16)(%esi), %mm4 .p2align 5, 0x90 .Lmmul_loopgas_11: movd %edi, %mm7 movl (%ebp), %edx movl (%esi), %eax movd %edx, %mm0 add $(4), %ebp movl %ebp, (40)(%esp) pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 mul %edx addl (%esp), %eax adc $(0), %edx pmuludq %mm0, %mm3 pmuludq %mm0, %mm4 movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (4)(%esp), %ecx movd (20)(%esi), %mm1 adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (8)(%esp), %ebx movd (24)(%esi), %mm2 adc $(0), %edx pmuludq %mm0, %mm1 pmuludq %mm0, %mm2 movd %mm3, %ebp psrlq $(32), %mm3 add %edx, %ebp movd %mm3, %edx adc $(0), %edx addl (12)(%esp), %ebp adc $(0), %edx movd %mm4, %edi psrlq $(32), %mm4 add %edx, %edi movd %mm4, %edx adc $(0), %edx addl (16)(%esp), %edi adc $(0), %edx neg %eax adc $(0), %ecx movl %ecx, (%esp) adc $(0), %ebx movl %ebx, (4)(%esp) mov %eax, %ecx sbb $(0), %eax sub %eax, %ebp movl %ebp, (8)(%esp) mov %ecx, %eax mov $(0), %ebp sbb $(0), %edi movl %edi, (12)(%esp) adc $(0), %ebp movd %mm1, %ecx psrlq $(32), %mm1 add %edx, %ecx movd %mm1, %edx adc $(0), %edx addl (20)(%esp), %ecx adc $(0), %edx movd %mm2, %ebx psrlq $(32), %mm2 add %edx, %ebx movd %mm2, %edx adc $(0), %edx addl (24)(%esp), %ebx adc $(0), %edx sub %ebp, %ecx movl %ecx, (16)(%esp) sbb $(0), %ebx movl %ebx, (20)(%esp) movd %mm7, %edi sbb $(0), %eax mov $(0), %ebx addl (28)(%esp), %edx adc $(0), %ebx add %eax, %edx movl %edx, (24)(%esp) adc $(0), %ebx movl %ebx, (28)(%esp) sub $(1), %edi movd (4)(%esi), %mm1 movd (8)(%esi), %mm2 movd (12)(%esi), %mm3 movd (16)(%esi), %mm4 jz .Lexit_mmul_loopgas_11 movl (40)(%esp), %ebp jmp .Lmmul_loopgas_11 .Lexit_mmul_loopgas_11: emms mov (32)(%esp), %edi lea (%esp), %esi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call h9_sub_224 movl (28)(%esp), %edx sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) mov (44)(%esp), %esp pop %ebp pop %edi pop %esi pop %ebx pop %ebp ret .Lfe11: .size h9_p224r1_mul_mont_slm, .Lfe11-(h9_p224r1_mul_mont_slm) .p2align 5, 0x90 .globl h9_p224r1_sqr_mont_slm .type h9_p224r1_sqr_mont_slm, @function h9_p224r1_sqr_mont_slm: push %ebp mov %esp, %ebp push %esi push %edi movl (12)(%ebp), %esi movl (8)(%ebp), %edi push %esi push %esi push %edi call h9_p224r1_mul_mont_slm add $(12), %esp pop %edi pop %esi pop %ebp ret .Lfe12: .size h9_p224r1_sqr_mont_slm, .Lfe12-(h9_p224r1_sqr_mont_slm) .p2align 5, 0x90 .globl h9_p224r1_mred .type h9_p224r1_mred, @function h9_p224r1_mred: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (12)(%ebp), %esi mov $(7), %ecx xor %edx, %edx .p2align 5, 0x90 .Lmred_loopgas_13: movl (%esi), %eax neg %eax mov $(0), %ebx movl %ebx, (%esi) movl (4)(%esi), %ebx adc $(0), %ebx movl %ebx, (4)(%esi) movl (8)(%esi), %ebx adc $(0), %ebx movl %ebx, (8)(%esi) push %eax movl (12)(%esi), %ebx sbb $(0), %eax sub %eax, %ebx movl %ebx, (12)(%esi) pop %eax movl (16)(%esi), %ebx sbb $(0), %ebx movl %ebx, (16)(%esi) movl (20)(%esi), %ebx sbb $(0), %ebx movl %ebx, (20)(%esi) movl (24)(%esi), %ebx sbb $(0), %ebx movl %ebx, (24)(%esi) movl (28)(%esi), %ebx sbb $(0), %eax add %edx, %eax mov $(0), %edx adc $(0), %edx add %eax, %ebx movl %ebx, (28)(%esi) adc $(0), %edx lea (4)(%esi), %esi sub $(1), %ecx jnz .Lmred_loopgas_13 movl (8)(%ebp), %edi lea p224r1_data, %ebx lea ((_prime224r1-p224r1_data))(%ebx), %ebx call h9_sub_224 sub %eax, %edx cmove %edi, %esi movdqu (%esi), %xmm0 movq (16)(%esi), %xmm1 movd (24)(%esi), %xmm2 movdqu %xmm0, (%edi) movq %xmm1, (16)(%edi) movd %xmm2, (24)(%edi) pop %edi pop %esi pop %ebx pop %ebp ret .Lfe13: .size h9_p224r1_mred, .Lfe13-(h9_p224r1_mred) .p2align 5, 0x90 .globl h9_p224r1_select_pp_w5 .type h9_p224r1_select_pp_w5, @function h9_p224r1_select_pp_w5: push %ebp mov %esp, %ebp push %esi push %edi pxor %xmm0, %xmm0 movl (8)(%ebp), %edi movl (12)(%ebp), %esi movl (16)(%ebp), %eax movd %eax, %xmm7 pshufd $(0), %xmm7, %xmm7 mov $(1), %edx movd %edx, %xmm6 pshufd $(0), %xmm6, %xmm6 movdqa %xmm0, (%edi) movdqa %xmm0, (16)(%edi) movdqa %xmm0, (32)(%edi) movdqa %xmm0, (48)(%edi) movdqa %xmm0, (64)(%edi) pxor %xmm3, %xmm3 movdqa %xmm6, %xmm5 mov $(16), %ecx .p2align 5, 0x90 .Lselect_loopgas_14: movdqa %xmm5, %xmm4 pcmpeqd %xmm7, %xmm4 movdqu (%esi), %xmm0 pand %xmm4, %xmm0 por (%edi), %xmm0 movdqa %xmm0, (%edi) movdqu (16)(%esi), %xmm1 pand %xmm4, %xmm1 por (16)(%edi), %xmm1 movdqa %xmm1, (16)(%edi) movdqu (32)(%esi), %xmm0 pand %xmm4, %xmm0 por (32)(%edi), %xmm0 movdqa %xmm0, (32)(%edi) movdqu (48)(%esi), %xmm1 pand %xmm4, %xmm1 por (48)(%edi), %xmm1 movdqa %xmm1, (48)(%edi) movdqu (64)(%esi), %xmm0 pand %xmm4, %xmm0 por (64)(%edi), %xmm0 movdqa %xmm0, (64)(%edi) movd (80)(%esi), %xmm1 pand %xmm4, %xmm1 por %xmm1, %xmm3 paddd %xmm6, %xmm5 add $(84), %esi sub $(1), %ecx jnz .Lselect_loopgas_14 movd %xmm3, (80)(%edi) pop %edi pop %esi pop %ebp ret .Lfe14: .size h9_p224r1_select_pp_w5, .Lfe14-(h9_p224r1_select_pp_w5)
INCLUDE "hardware.inc" ;============================================================== ; rst handlers as routines ;============================================================== CALL_HL EQU $30 RST_38 EQU $38 ;============================================================== ; structs ;============================================================== ; each scanline gets some data, structured like so: RSRESET RASTER_SCRY RB 1 ; data for rSCY RASTER_SCRX RB 1 ; data for rSCX sizeof_RASTER RB 0 sizeof_RASTER_TABLE EQU ((SCRN_Y+1)*sizeof_RASTER) ; the +1 is because data is needed to display raster 0 ; (think of it as an HBlank handler happening on raster '-1' ROLL_SIZE EQU 32 ;============================================================== ; macros ;============================================================== ; breakpoint (halt the debugger) BREAKPOINT: MACRO ld b,b ENDM ;-------------------------------------------------------------- ; display a log message LOGMESSAGE: MACRO ld d,d jr .end\@ DW $6464 DW $0000 DB \1 .end\@: ENDM ;-------------------------------------------------------------- ; wait for the start of the next vblank WaitVBlankStart: MACRO .waitvbl\@ ldh a,[rLY] cp SCRN_Y jr nz,.waitvbl\@ ENDM ;-------------------------------------------------------------- SwapBuffers: MACRO ASSERT(LOW(wRasterTableA) == LOW(wRasterTableB)) ; the README uses hardcoded addresses, but any two aligned addresses work ldh a,[hFillBuffer] ldh [hDrawBuffer],a xor HIGH(wRasterTableA) ^ HIGH(wRasterTableB) ldh [hFillBuffer],a ENDM ;-------------------------------------------------------------- ; set the change tutorial part flag SetChangePartFlag: MACRO ld a,1 ld [wChangePart],a ENDM ;-------------------------------------------------------------- ; SetProcessFunc <funcptr> SetProcessFunc: MACRO ld hl,wProcessFunc ld bc,\1 ld a,c ld [hl+],a ld [hl],b ENDM ;============================================================== ; RST handlers ;============================================================== SECTION "RST $30",ROM0[CALL_HL] ; call the function pointed to by hl CallHL:: jp hl ; ------------------------------------------------------------- SECTION "RST $38",ROM0[RST_38] Rst_38:: BREAKPOINT ret ;============================================================== ; interrupt handlers ;============================================================== SECTION "VBlank Handler",ROM0[$40] VBlankHandler:: push af ld a,1 ld [wVBlankDone],a jr VBlankContinued ; ------------------------------------------------------------- SECTION "HBlank Handler",ROM0[$48] HBlankHandler:: ; 40 cycles push af ; 4 push hl ; 4 ;------------------------------- ; obtain the pointer to the data pair ldh a,[rLY] ; 3 inc a ; 1 add a,a ; 1 ; double the offset since each line uses 2 bytes ld l,a ; 1 ldh a,[hDrawBuffer] ; 3 adc 0 ; 2 ld h,a ; 1 ; hl now points to somewhere in the draw buffer ; set the scroll registers ld a,[hl+] ; 2 ldh [rSCY],a ; 3 ld a,[hl+] ; 2 ldh [rSCX],a ; 3 pop hl ; 3 pop af ; 3 reti ; 4 ; ------------------------------------------------------------- VBlankContinued:: pop af pop af ; remove WaitForVBlankInt's ret from the stack to avoid a race condition reti ;============================================================== ; cartridge header ;============================================================== SECTION "ROM Header",ROM0[$100] ROMHeader:: nop jp Start NINTENDO_LOGO DB "DeadCScroll" ; game title DB "BObj" ; product code DB CART_COMPATIBLE_DMG DW $00 ; license code DB CART_INDICATOR_GB DB CART_ROM_MBC5 DB CART_ROM_32K DB CART_SRAM_NONE DB CART_DEST_NON_JAPANESE DB $33 ; licensee code DB $00 ; mask ROM version DB $00 ; complement check DW $00 ; cartridge checksum ;============================================================== ; starting point ;============================================================== SECTION "Start",ROM0[$150] Start:: call Initialize mainloop: ; call the process function and handle any part transition ld hl,wProcessFunc ld a,[hl+] ld h,[hl] ld l,a rst CALL_HL call ProcessPartTransition ; change parts (if necessary) ;-------------------------------------- call WaitForVBlankDone ; clear the vblank done flag xor a ld [wVBlankDone],a ;-------------------------------------- SwapBuffers call PrepRaster0 ;-------------------------------------- ; update the frame counter ld hl,wFrameCounter inc [hl] jr mainloop ;============================================================== ; support routines (bank 0) ;============================================================== SECTION "WaitForVBlank",ROM0 ; wait for the vblank handler to set the flag ; done as a routine instead of a macro to avoid a halt race condition WaitForVBlankDone:: .waitloop: halt ld a,[wVBlankDone] and a jr z,.waitloop ret ; ------------------------------------------------------------- SECTION "PrepRaster0",ROM0 ; emulate the HBlank handler as if LY=-1 (to render the 0th scanline's worth of pixels correctly) PrepRaster0:: ldh a,[hDrawBuffer] ld h,a ld l,0 ; set the scroll registers ld a,[hl+] ldh [rSCY],a ld a,[hl+] ldh [rSCX],a ret ; ------------------------------------------------------------- SECTION "Tutorial Driver",ROM0 ProcessPartTransition:: ; see if the transition flag is set ld a,[wChangePart] and a ret z ; not set, exit early ; clear the flag xor a ld [wChangePart],a ; put the actual pointer in hl ld hl,wTutePartPtr ld a,[hl+] ld h,[hl] ld l,a ; put the init function pointer in de ld a,[hl+] ld e,a ld a,[hl+] ld d,a push de ; 'jp de' prep (see the ret below) ; update the ptr for the next transition ld d,h ld e,l ld hl,wTutePartPtr ld a,e ld [hl+],a ld [hl],d ; reset the frame counter so each part starts at 0 xor a ld hl,wFrameCounter ld [hl],a ; the ret here actually calls the init function because of the push earlier ; i.e. simulate 'jp de' ret TutePartInitFuncTable: DW InitShowDelay DW InitXSine DW InitShowDelay DW InitYSine DW InitShowDelay DW InitXYSine DW InitShowDelay DW InitSmearOff DW InitLightDelay DW InitSmearOn DW InitShowDelay DW InitRollOff DW InitDarkDelay DW InitRollOn DW InitRestart ; ------------------------------------------------------------- SECTION "Part - X Sine",ROM0 InitXSine: LOGMESSAGE "InitXSine" ; set the progression line to the first raster ld hl,wProgressLine ld a,SCRN_Y ld [hl],a ; set the data pointer (technically an offset) to the end of a raster buffer ; the pointer will be resolved later ld hl,sizeof_RASTER_TABLE-sizeof_RASTER ld a,l ld [wDataPtr],a ld a,h ld [wDataPtr+1],a ; start with subpart 0 ld hl,wFlags xor a ld [hl+],a ; hl = wCounter ; set the counter to 0 ld [hl],a SetProcessFunc ProcessXSine ret ProcessXSine: ; check the flags ld hl,wFlags ld a,[hl] and a jr z,.subpart0 dec a jr z,.subpart1 ; ending (diminish the sine up the screen) .subpart2 call UpdateXSine2 ; update the table index ld hl,wTableIndex inc [hl] ld hl,wProgressLine ld a,[hl] dec a jr z,.subpart2done ld [hl],a ret .subpart2done SetChangePartFlag ret ; middle (watch the sine for a bit) .subpart1 call UpdateXSine1 ; update the table index ld hl,wTableIndex inc [hl] ret ; beginning (progress the sine up the screen) .subpart0 call UpdateXSine0 ld hl,wProgressLine ld a,[hl] dec a cp $FF jr z,.subpart0done ld [hl],a ret .subpart0done ; move to the next subpart ld hl,wFlags inc [hl] ; reset the timer ld hl,wFrameCounter xor a ld [hl],a ; start the sine from 0 ld hl,wTableIndex ld [hl],a ret UpdateXSine0: ld hl,wProgressLine ld a,[hl] cpl add SCRN_Y+2 ld e,a ; e=num iterations ; obtain a pointer into the fill buffer ld hl,wDataPtr ld a,[hl+] ld c,a ld b,[hl] ldh a,[hFillBuffer] ld h,a ld l,0 add hl,bc ; set up loop constants ld bc,XSineTable .loop ; store y value ld a,ROLL_SIZE ld [hl+],a ; store x value ld a,[bc] inc c ld [hl+],a ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; update the data pointer for next time ld hl,wDataPtr ld a,[hl+] ld h,[hl] ld l,a ; assume that sizeof_RASTER is 2, alas dec hl dec hl ; store the new pointer ld a,l ld [wDataPtr],a ld a,h ld [wDataPtr+1],a ret ; just a straight sine table lookup and fill the entire buffer ; (use this one if you don't need a progression effect like sub-part 0/2) UpdateXSine1: ld hl,wTableIndex ld a,[hl] ld c,a ld b,HIGH(XSineTable) ldh a,[hFillBuffer] ld h,a ld l,0 ld e,SCRN_Y+1 .loop ; store y value ld a,ROLL_SIZE ld [hl+],a ; store x value ld a,[bc] inc c ld [hl+],a ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; see if the last raster was 0 ; if it was update a counter ; when the counter reaches 3, move to the next subpart ld a,c and a ret nz ld hl,wCounter ld a,[hl] inc a cp 3 jr z,.subpart1done ld [hl],a ret .subpart1done ; move to the next subpart ld hl,wFlags inc [hl] ; reset the progress line to the bottom of the screen ld hl,wProgressLine ld a,SCRN_Y ld [hl],a ret UpdateXSine2: ld hl,wProgressLine ld a,[hl] ld e,a ld hl,wTableIndex ld a,[hl] ld c,a ld b,HIGH(XSineTable) ldh a,[hFillBuffer] ld h,a ld l,0 .loop ; store y value ld a,ROLL_SIZE ld [hl+],a ; store x value ld a,[bc] inc c ld [hl+],a ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; below (or equal) the line ; only two lines need to be cleared ld bc,(ROLL_SIZE<<8) ld a,b ld [hl+],a ld a,c ld [hl+],a ld a,b ld [hl+],a ld a,c ld [hl+],a ret ; ------------------------------------------------------------- SECTION "Part - Y Sine",ROM0 InitYSine: LOGMESSAGE "InitYSine" ; set the progression line to the last raster ld hl,wProgressLine ld a,SCRN_Y ld [hl],a ; set the data pointer (technically an offset) to the end of a raster buffer ; the pointer will be resolved later ld hl,sizeof_RASTER_TABLE-sizeof_RASTER ld a,l ld [wDataPtr],a ld a,h ld [wDataPtr+1],a ; start with subpart 0 ld hl,wFlags xor a ld [hl+],a ; hl = wCounter ; set the counter to 0 ld [hl],a SetProcessFunc ProcessYSine ret ProcessYSine: ; check the flags ld hl,wFlags ld a,[hl] and a jr z,.subpart0 dec a jr z,.subpart1 ; ending (diminish the sine up the screen) .subpart2 call UpdateYSine2 ; update the table index ld hl,wTableIndex inc [hl] ld hl,wProgressLine ld a,[hl] dec a jr z,.subpart2done ld [hl],a ret .subpart2done SetChangePartFlag ret ; middle (watch the sine for a bit) .subpart1 call UpdateYSine1 ; update the table index ld hl,wTableIndex inc [hl] ret ; beginning (progress the sine up the screen) .subpart0 call UpdateYSine0 ld hl,wProgressLine ld a,[hl] dec a cp $FF jr z,.subpart0done ld [hl],a ret .subpart0done ; move to the next subpart ld hl,wFlags inc [hl] ; reset the timer ld hl,wFrameCounter xor a ld [hl],a ; start the sine from 0 ld hl,wTableIndex ld [hl],a ret UpdateYSine0: ld hl,wProgressLine ld a,[hl] cpl add SCRN_Y+2 ld e,a ; e=num iterations ; obtain a pointer into the fill buffer ld hl,wDataPtr ld a,[hl+] ld c,a ld b,[hl] ldh a,[hFillBuffer] ld h,a ld l,0 add hl,bc ; set up loop constants ld bc,YSineTable .loop ; store y value ld a,[bc] inc c add ROLL_SIZE ld [hl+],a ; store x value xor a ld [hl+],a ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; update the data pointer for next time ld hl,wDataPtr ld a,[hl+] ld h,[hl] ld l,a ; assume that sizeof_RASTER is 2, alas dec hl dec hl ; store the new pointer ld a,l ld [wDataPtr],a ld a,h ld [wDataPtr+1],a ret ; just a straight sine table lookup and fill the entire buffer ; (use this one if you don't need a progression effect like sub-part 0/2) UpdateYSine1: ld hl,wTableIndex ld a,[hl] ld c,a ld b,HIGH(YSineTable) ldh a,[hFillBuffer] ld h,a ld l,0 ld e,SCRN_Y+1 .loop ; store y value ld a,[bc] inc c add ROLL_SIZE ld [hl+],a ; store x value xor a ld [hl+],a ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; see if the last raster was 0 ; if it was update a counter ; when the counter reaches 2, move to the next subpart ld a,c and a ret nz ld hl,wCounter ld a,[hl] inc a cp 2 jr z,.subpart1done ld [hl],a ret .subpart1done ; move to the next subpart ld hl,wFlags inc [hl] ; reset the progress line to the bottom of the screen ld hl,wProgressLine ld a,SCRN_Y ld [hl],a ret UpdateYSine2: ld hl,wProgressLine ld a,[hl] ld e,a ld hl,wTableIndex ld a,[hl] ld c,a ld b,HIGH(YSineTable) ldh a,[hFillBuffer] ld h,a ld l,0 .loop ; store y value ld a,[bc] inc c add ROLL_SIZE ld [hl+],a ; store x value xor a ld [hl+],a ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; below (or equal) the line ; only two lines need to be cleared ld bc,(ROLL_SIZE<<8) ld a,b ld [hl+],a ld a,c ld [hl+],a ld a,b ld [hl+],a ld a,c ld [hl+],a ret ; ------------------------------------------------------------- SECTION "Part - XY Sine",ROM0 InitXYSine: LOGMESSAGE "InitXYSine" ; set the progression line to the first raster ld hl,wProgressLine ld a,SCRN_Y ld [hl],a ; set the data pointer (technically an offset) to the end of a raster buffer ; the pointer will be resolved later ld hl,sizeof_RASTER_TABLE-sizeof_RASTER ld a,l ld [wDataPtr],a ld a,h ld [wDataPtr+1],a ; start with subpart 0 ld hl,wFlags xor a ld [hl+],a ; hl = wCounter ; set the counter to 0 ld [hl],a SetProcessFunc ProcessXYSine ret ProcessXYSine: ; check the flags ld hl,wFlags ld a,[hl] and a jr z,.subpart0 dec a jr z,.subpart1 ; ending (diminish the sine up the screen) .subpart2 call UpdateXYSine2 ; update the table index ld hl,wTableIndex inc [hl] ld hl,wProgressLine ld a,[hl] dec a jr z,.subpart2done ld [hl],a ret .subpart2done SetChangePartFlag ret ; middle (watch the sine for a bit) .subpart1 call UpdateXYSine1 ; update the table index ld hl,wTableIndex inc [hl] ret ; beginning (progress the sine up the screen) .subpart0 call UpdateXYSine0 ld hl,wProgressLine ld a,[hl] dec a cp $FF jr z,.subpart0done ld [hl],a ret .subpart0done ; move to the next subpart ld hl,wFlags inc [hl] ; reset the timer ld hl,wFrameCounter xor a ld [hl],a ; start the sine from 0 ld hl,wTableIndex ld [hl],a ret UpdateXYSine0: ld hl,wProgressLine ld a,[hl] cpl add SCRN_Y+2 ld e,a ; e=num iterations ; obtain a pointer into the fill buffer ld hl,wDataPtr ld a,[hl+] ld c,a ld b,[hl] ldh a,[hFillBuffer] ld h,a ld l,0 add hl,bc ; set up loop constants ld c,0 .loop ; store y value ld b,HIGH(YSineTable) ld a,[bc] add ROLL_SIZE ld [hl+],a ; store x value ld b,HIGH(XSineTable) ld a,[bc] ld [hl+],a inc c ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; update the data pointer for next time ld hl,wDataPtr ld a,[hl+] ld h,[hl] ld l,a ; assume that sizeof_RASTER is 2, alas dec hl dec hl ; store the new pointer ld a,l ld [wDataPtr],a ld a,h ld [wDataPtr+1],a ret ; just a straight sine table lookup and fill the entire buffer ; (use this one if you don't need a progression effect like sub-part 0/2) UpdateXYSine1: ld hl,wTableIndex ld a,[hl] ld c,a ldh a,[hFillBuffer] ld h,a ld l,0 ld e,SCRN_Y+1 .loop ; store y value ld b,HIGH(YSineTable) ld a,[bc] add ROLL_SIZE ld [hl+],a ; store x value ld b,HIGH(XSineTable) ld a,[bc] ld [hl+],a inc c ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; see if the last raster was 0 ; if it was update a counter ; when the counter reaches 3, move to the next subpart ld a,c and a ret nz ld hl,wCounter ld a,[hl] inc a cp 3 jr z,.subpart1done ld [hl],a ret .subpart1done ; move to the next subpart ld hl,wFlags inc [hl] ; reset the progress line to the bottom of the screen ld hl,wProgressLine ld a,SCRN_Y ld [hl],a ret UpdateXYSine2: ld hl,wProgressLine ld a,[hl] ld e,a ld hl,wTableIndex ld a,[hl] ld c,a ldh a,[hFillBuffer] ld h,a ld l,0 .loop ; store y value ld b,HIGH(YSineTable) ld a,[bc] add ROLL_SIZE ld [hl+],a ; store x value ld b,HIGH(XSineTable) ld a,[bc] ld [hl+],a inc c ; loop delimiter (stop at the bottom of the screen) dec e jr nz,.loop ; below (or equal) the line ; only two lines need to be cleared ld bc,(ROLL_SIZE<<8) ld a,b ld [hl+],a ld a,c ld [hl+],a ld a,b ld [hl+],a ld a,c ld [hl+],a ret ; ------------------------------------------------------------- SECTION "Part - Smear On",ROM0 ; smear on (bottom to top) InitSmearOn: LOGMESSAGE "InitSmearOn" ; set the progression line to the last raster ld hl,wProgressLine ld a,SCRN_Y ld [hl],a SetProcessFunc ProcessSmearOn ret ProcessSmearOn: ld hl,wProgressLine ld a,[hl] dec a jr z,.done ld [hl],a call UpdateSmear ret .done SetChangePartFlag ret ; ------------------------------------------------------------- SECTION "Part - Smear Off",ROM0 ; smear off (top to bottom) InitSmearOff: LOGMESSAGE "InitSmearOff" ; set the progression line to the first raster ld hl,wProgressLine xor a ld [hl],a SetProcessFunc ProcessSmearOff ret ProcessSmearOff: ld hl,wProgressLine ld a,[hl] inc a cp SCRN_Y jr z,.done ld [hl],a call UpdateSmear ret .done SetChangePartFlag ret ; a = wProgressLine UpdateSmear: ; only y data is updated here ; from the top of the screen to wProgressLine, set the value to wProgressLine ; below wProgressLine is 0 ld e,a ; copy wProgressLine ldh a,[hFillBuffer] ld h,a ld l,0 ; above the line ld c,l ld b,e ; b = wProgressLine, c = scroll x ld d,c .loop ld a,b add ROLL_SIZE ld [hl+],a ; store scroll y value ld a,c ld [hl+],a ; store scroll x value dec b inc d ld a,d cp e jr nz,.loop ; below (or equal) the line ; only two lines need to be cleared ld bc,(ROLL_SIZE<<8) ld a,b ld [hl+],a ld a,c ld [hl+],a ld a,b ld [hl+],a ld a,c ld [hl+],a ret ; ------------------------------------------------------------- SECTION "Part - Roll Off",ROM0 ; roll off (bottom to top) InitRollOff: LOGMESSAGE "InitRollOff" ; set the progression line to the last raster ld hl,wProgressLine ld a,SCRN_Y+ROLL_SIZE ld [hl],a ; set the data pointer (technically an offset) to the end of a raster buffer ; the pointer will be resolved later ld hl,sizeof_RASTER_TABLE-sizeof_RASTER ld a,l ld [wDataPtr],a ld a,h ld [wDataPtr+1],a SetProcessFunc ProcessRollOff ret ProcessRollOff: ld hl,wProgressLine ld a,[hl] dec a jr z,.done ld [hl],a call UpdateRollOff ret .done SetChangePartFlag ret ; a=wProgressLine UpdateRollOff: ld b,a ; b=progress line ; obtain a pointer into the fill buffer ld hl,wDataPtr ld a,[hl+] ld e,a ld d,[hl] ldh a,[hFillBuffer] ld h,a ld l,0 add hl,de ; for the height of the roll, use the table as a displacement from the current raster ld c,ROLL_SIZE ld de,RollTable .rollloop ; don't update if the current progress line is off-screen (above raster 0) ld a,b cp ROLL_SIZE jr c,.skipstore ; store y value ld a,[de] add ROLL_SIZE ld [hl+],a ; store x value (always 0) xor a ld [hl+],a .skipstore inc de ; prevent going off the end of the buffer inc b ld a,b cp SCRN_Y+ROLL_SIZE jr z,.updatedataptr ; loop delimiter dec c jr nz,.rollloop ; below (or equal) the line ld c,b ld a,b sub ROLL_SIZE ld b,a ld de,SCRN_Y+12+ROLL_SIZE ld a,e sub b ld e,a .clearloop ld a,e ld [hl+],a ld a,d ld [hl+],a dec e inc c ld a,c cp SCRN_Y+ROLL_SIZE jr nz,.clearloop .updatedataptr ; update the data pointer for next time ld hl,wDataPtr ld a,[hl+] ld h,[hl] ld l,a ; prevent a buffer underrun or h ret z ; assume that sizeof_RASTER is 2, alas dec hl dec hl ; store the new pointer ld a,l ld [wDataPtr],a ld a,h ld [wDataPtr+1],a ret ; ------------------------------------------------------------- SECTION "Part - Roll On",ROM0 ; roll on (top to bottom) InitRollOn: LOGMESSAGE "InitRollOn" ; set the progression line to the first raster ld hl,wProgressLine xor a ld [hl],a SetProcessFunc ProcessRollOn ret ProcessRollOn: ld hl,wProgressLine ld a,[hl] inc a cp SCRN_Y+ROLL_SIZE jr z,.done ld [hl],a call UpdateRollOn ret .done SetChangePartFlag ret ; a=wProgressLine UpdateRollOn: ld b,a ; b=progress line ldh a,[hFillBuffer] ld h,a xor a ld l,a ld a,b cp ROLL_SIZE jr z,.doroll jr nc,.dofill jr .doroll ; fill the buffer with $3200 up to the progress line .dofill ld a,b sub ROLL_SIZE ld c,a ld de,(ROLL_SIZE<<8) ; y=32, x=0 .zeroloop ld a,d ld [hl+],a ld a,e ld [hl+],a dec c jr nz,.zeroloop .doroll ; for the height of the roll, use the table as a displacement from the current raster ld c,ROLL_SIZE ld de,RollTable .rollloop cp ROLL_SIZE jr nc,.dostore jr z,.dostore jr .loopend .dostore ; store y value ld a,[de] add ROLL_SIZE ld [hl+],a ; store x value (always 0) xor a ld [hl+],a .loopend inc de ; prevent going off the end of the buffer inc b ld a,b cp SCRN_Y+ROLL_SIZE ret z ; loop delimiter dec c jr nz,.rollloop ret ; ------------------------------------------------------------- SECTION "Part - Show Delay",ROM0 InitShowDelay: LOGMESSAGE "InitShowDelay" ; clear the raster tables to 0,0 for every raster ld hl,wRasterTableA ld b,SCRN_Y+1 call BlankScreenMem ld hl,wRasterTableB ld b,SCRN_Y+1 call BlankScreenMem SetProcessFunc ProcessDelay ret ; 'clear' memory so the normal screen is positioned correctly ; (it starts 4 tiles down instead of at 0,0) BlankScreenMem: ld de,(ROLL_SIZE<<8) ; y=32, x=0 .loop ld a,d ld [hl+],a ld a,e ld [hl+],a dec b jr nz,.loop ret ; ------------------------------------------------------------- SECTION "Part - Light Delay",ROM0 InitLightDelay: LOGMESSAGE "InitLightDelay" ; clear the raster tables to offscreen for every raster ld hl,wRasterTableA ld b,SCRN_Y+1 ld de,SCRN_Y+4+ROLL_SIZE call InitBlankRasterBuffer ld hl,wRasterTableB ld b,SCRN_Y+1 ld de,SCRN_Y+4+ROLL_SIZE call InitBlankRasterBuffer SetProcessFunc ProcessDelay ret ; ------------------------------------------------------------- SECTION "Part - Dark Delay",ROM0 InitDarkDelay: LOGMESSAGE "InitDarkDelay" ; clear the raster tables to offscreen for every raster ld hl,wRasterTableA ld b,SCRN_Y+1 ld de,SCRN_Y+12+ROLL_SIZE call InitBlankRasterBuffer ld hl,wRasterTableB ld b,SCRN_Y+1 ld de,SCRN_Y+12+ROLL_SIZE call InitBlankRasterBuffer SetProcessFunc ProcessDelay ret ProcessDelay: ld hl,wFrameCounter ld a,[hl] cp 150 ; ~2.5 seconds ret nz SetChangePartFlag ret ; b = num buffer entry (pairs) to set ; d = x value (always 0) ; e = y value InitBlankRasterBuffer: .loop ld a,e ld [hl+],a ld a,d ld [hl+],a dec e ; offset by LY dec b jr nz,.loop ret ; ------------------------------------------------------------- SECTION "Part - Restart",ROM0 InitRestart: LOGMESSAGE "InitRestart" SetProcessFunc ProcessRestart ret ProcessRestart: call InitFirstPart ret ;============================================================== ; support routines (bank 2) ;============================================================== SECTION "Bank 1 Routines",ROMX,BANK[1] Initialize: di ;-------------------------------------- ; turn off the screen after entering a vblank WaitVBlankStart ; clear LCD control registers and disable audio xor a ldh [rLCDC],a ldh [rIE],a ldh [rIF],a ldh [rSTAT],a ldh [rAUDENA],a ; disable the audio ;-------------------------------------- ; initialize the window position to 255,255 dec a ldh [rWY],a ldh [rWX],a ;-------------------------------------- ; set the bg palette ld a,$E4 ldh [rBGP],a ;-------------------------------------- ; copy the tile map to vram ld de,BGTileMap ; source ld hl,_SCRN0+(ROLL_SIZE*4) ; dest ld bc,(BGTileMapEnd - BGTileMap) ; num bytes call CopyMem ;-------------------------------------- ; copy the bg tiles to vram ld de,BGTiles ; source ld hl,_VRAM8000 ; dest ld bc,(BGTilesEnd - BGTiles) ; num bytes call CopyMem ;-------------------------------------- ; set up the initial state call InitVariables call InitFirstPart ;-------------------------------------- ; turn on the display ld a,LCDCF_ON|LCDCF_BG8000|LCDCF_BG9800|LCDCF_OBJOFF|LCDCF_BGON ldh [rLCDC],a WaitVBlankStart ;------------------------------- ; set up the lcdc int ld a,STATF_MODE00 ldh [rSTAT],a ;-------------------------------------- ; enable the interrupts ld a,IEF_VBLANK|IEF_LCDC ldh [rIE],a xor a ei ldh [rIF],a ret ;-------------------------------------------------------------- ; copy bc bytes from de to hl CopyMem: .loop ld a,[de] ld [hl+],a inc de dec bc ld a,b or c jr nz,.loop ret ;-------------------------------------------------------------- InitVariables: ld hl,wVBlankDone xor a ld [hl+],a ; wVBlankDone ld [hl+],a ; wFrameCounter ld [hl+],a ; wChangePart ; set up the double-buffering system ld a,HIGH(wRasterTableA) ldh [hDrawBuffer],a xor $02 ldh [hFillBuffer],a ; hDrawBuffer=wRasterTableA ; hFillBuffer=wRasterTableB ret ;-------------------------------------------------------------- InitFirstPart: ; init the part pointer to the start of the table ld de,TutePartInitFuncTable ld hl,wTutePartPtr ld a,e ld [hl+],a ld [hl],d ; prep the first part SetChangePartFlag call ProcessPartTransition call PrepRaster0 ret ;============================================================== ; work ram ;============================================================== SECTION "Raster Table A",WRAM0[$C000] wRasterTableA:: DS sizeof_RASTER_TABLE SECTION "Raster Table B",WRAM0[$C200] wRasterTableB:: DS sizeof_RASTER_TABLE SECTION "Tutorial Part Variables",WRAM0,ALIGN[3] wProcessFunc:: DS 2 ; pointer to a function to call towards the start of a frame wTutePartPtr:: DS 2 ; pointer in TutorialPartInitFuncTable for the next part SECTION "Variables",WRAM0 wVBlankDone: DS 1 wFrameCounter: DS 1 ; a simple frame counter wChangePart: DS 1 wTableIndex: DS 1 ; general-purpose index into a table wProgressLine: DS 1 ; current raster used as a progressive scan wFlags: DS 1 ; a holder of misc flags/data for part's use wCounter: DS 1 ; general-purpose counter for part's use wDataPtr: DS 2 ; (part use) pointer to somewhere in wRasterTableA/wRasterTableB ;============================================================== ; high ram ;============================================================== SECTION "HRAM Variables",HRAM ; buffer offsets (put in h, l=00) ; $C0 = Table A / $C2 = Table B hDrawBuffer:: DS 1 ; the buffer currently being drawn (the inverse of hFillBuffer) hFillBuffer:: DS 1 ; the buffer currently being filled (the inverse of hDrawBuffer) ;============================================================== ; bank 1 data (put down here so it's out of the way) ;============================================================== SECTION "Bank 1 Data",ROMX,BANK[1] BGTileMap: DB $00,$00,$00,$00,$00,$01,$00,$00,$00,$00,$00,$00,$00,$02,$03,$00,$00,$00,$00,$04,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $05,$06,$07,$07,$08,$09,$0a,$07,$07,$07,$0b,$0c,$0d,$09,$0a,$07,$07,$08,$0e,$0f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$10,$11,$11,$12,$13,$14,$15,$16,$11,$17,$18,$19,$13,$14,$11,$11,$12,$13,$1a,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$1b,$1c,$00,$00,$1d,$00,$1e,$1f,$00,$20,$1d,$21,$1d,$00,$1c,$22,$23,$1d,$1a,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $02,$24,$1d,$00,$00,$1d,$00,$25,$26,$27,$28,$1d,$29,$1d,$2a,$1d,$2b,$2c,$1d,$1a,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$1b,$1d,$2d,$2e,$2f,$30,$31,$32,$33,$34,$1d,$35,$1d,$29,$1d,$2d,$2e,$2f,$1a,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$1b,$1d,$36,$37,$38,$39,$3a,$3a,$3a,$3b,$3c,$3d,$3e,$3f,$1d,$36,$37,$38,$40,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$1b,$37,$38,$41,$00,$00,$42,$43,$44,$45,$46,$47,$48,$49,$37,$4a,$4b,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$4c,$4d,$30,$4e,$00,$4f,$50,$51,$52,$53,$54,$55,$56,$57,$58,$59,$5a,$02,$03,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$00,$00,$5b,$5c,$00,$5d,$1d,$5e,$31,$5f,$60,$61,$1d,$1d,$62,$00,$63,$64,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$00,$00,$65,$66,$00,$67,$5d,$68,$69,$6a,$1d,$1d,$1d,$6b,$6c,$6d,$6e,$1f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$01,$00,$6f,$70,$00,$00,$71,$72,$73,$63,$1d,$1d,$1d,$74,$75,$73,$25,$76,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $00,$00,$00,$00,$77,$00,$00,$00,$78,$79,$00,$7a,$7b,$7c,$1d,$7d,$7e,$31,$76,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $7f,$80,$7f,$80,$77,$81,$82,$83,$84,$85,$86,$87,$88,$89,$8a,$8b,$8c,$1d,$8d,$20,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $8e,$8f,$8e,$8f,$90,$91,$92,$93,$94,$95,$96,$97,$98,$1d,$1d,$99,$9a,$1d,$9b,$8f,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $9c,$9d,$9c,$9d,$9e,$9f,$a0,$a1,$a2,$a3,$31,$a4,$1d,$1d,$1d,$1d,$1d,$a5,$a6,$9d,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $a7,$a8,$a7,$a8,$a7,$a8,$a9,$aa,$ab,$ac,$ad,$5d,$1d,$1d,$1d,$1d,$1d,$ae,$a7,$a8,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$b0,$1d,$1d,$1d,$b1,$b2,$b3,$af,$af,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 DB $af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$af,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 BGTileMapEnd: BGTiles: DB $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $fb,$c7,$fd,$83,$ef,$b7,$ff,$b7,$fd,$83,$bb,$ef,$db,$e7,$ff,$ff DB $ff,$f8,$ff,$f0,$ef,$f0,$ff,$ec,$ee,$fd,$fe,$f3,$f7,$eb,$ff,$ff DB $ff,$7f,$ff,$3f,$ff,$3f,$bf,$7f,$7f,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$f7,$8f,$fb,$07,$df,$6f,$ff,$6f DB $fc,$fc,$fc,$fc,$fc,$fc,$fe,$fe,$fe,$fe,$ff,$ff,$ff,$ff,$ff,$ff DB $00,$00,$00,$00,$7f,$7f,$7f,$7f,$3f,$30,$3f,$30,$18,$1f,$98,$9f DB $00,$00,$00,$00,$ff,$ff,$ff,$ff,$ff,$00,$ff,$00,$00,$ff,$00,$ff DB $01,$01,$00,$00,$fc,$fc,$ff,$ff,$ff,$03,$ff,$00,$07,$f8,$01,$fe DB $fc,$fc,$7c,$7c,$1c,$1c,$06,$06,$c0,$c0,$f0,$f0,$fc,$3c,$ff,$0f DB $00,$00,$00,$00,$7f,$7f,$7f,$7f,$3f,$30,$3f,$30,$18,$1f,$18,$1f DB $00,$00,$00,$00,$fe,$fe,$fe,$fe,$fc,$0c,$fc,$0c,$18,$f8,$18,$f8 DB $3f,$3f,$3e,$3e,$38,$38,$60,$60,$03,$03,$0f,$0f,$3f,$3c,$ff,$f0 DB $81,$81,$00,$00,$3c,$3c,$ff,$ff,$ff,$c3,$ff,$00,$e7,$18,$81,$7e DB $ff,$ff,$7f,$7f,$1f,$1f,$07,$07,$c1,$c1,$f0,$f0,$fc,$3c,$ff,$0f DB $fb,$07,$77,$df,$b7,$cf,$ff,$ff,$ff,$ff,$7f,$7f,$1f,$1f,$0f,$0f DB $8c,$8f,$cc,$cf,$c6,$c7,$e6,$e7,$e3,$e3,$f3,$f3,$f3,$f3,$f3,$f3 DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$f0,$ff,$fc,$ff,$ff,$ff,$ff,$ff DB $7f,$83,$1f,$e0,$07,$f8,$01,$fe,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $cc,$cf,$fc,$ff,$fe,$ff,$fe,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$80,$ff,$80,$ff DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$7f,$ff,$7f,$ff,$3f,$ff,$3f,$ff DB $33,$f3,$3f,$ff,$7f,$ff,$7f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $fe,$c1,$f8,$07,$e0,$1f,$80,$7f,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$3c,$ff,$ff,$ff,$ff,$ff DB $cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf,$cf DB $f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3,$f3 DB $ff,$3f,$ff,$0f,$7f,$83,$1f,$e0,$07,$f8,$01,$fe,$00,$ff,$00,$ff DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $c0,$ff,$c0,$ff,$e0,$ff,$e0,$ff,$f0,$ff,$f0,$ff,$f8,$ff,$f8,$ff DB $1f,$ff,$1f,$ff,$0f,$ff,$0f,$ff,$07,$ff,$07,$ff,$03,$ff,$03,$ff DB $ff,$ff,$ff,$ff,$ff,$ff,$fb,$ff,$f7,$ff,$f3,$ff,$f3,$ff,$27,$ff DB $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$df,$ff,$c3,$ff DB $ff,$ff,$ff,$ff,$fc,$ff,$c0,$ff,$c1,$ff,$c0,$ff,$e0,$ff,$f8,$ff DB $ff,$ff,$ff,$ff,$7f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$7f,$ff,$1f,$ff DB $f3,$73,$f3,$33,$f3,$33,$b3,$73,$73,$f3,$f3,$f3,$f3,$f3,$f3,$f3 DB $f8,$ff,$f8,$ff,$f0,$ff,$f0,$ff,$e0,$ff,$e0,$ff,$c0,$ff,$c0,$ff DB $03,$ff,$03,$ff,$07,$ff,$07,$ff,$0f,$ff,$0f,$ff,$1f,$ff,$1f,$ff DB $80,$ff,$c0,$ff,$e1,$ff,$fb,$ff,$ff,$ff,$fc,$ff,$f8,$ff,$f8,$ff DB $7f,$ff,$ff,$ff,$ff,$ff,$e3,$ff,$03,$ff,$03,$ff,$03,$ff,$03,$ff DB $c3,$ff,$c3,$ff,$c3,$ff,$c3,$ff,$c3,$ff,$c3,$ff,$c3,$ff,$c3,$ff DB $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$f3,$ff,$c3,$ff,$c3,$ff DB $fe,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$c7,$ff,$c0,$ff,$fc,$ff DB $0f,$ff,$87,$ff,$c3,$ff,$c3,$ff,$c3,$ff,$c3,$ff,$03,$ff,$03,$ff DB $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$fc,$ff,$f0,$ff DB $ff,$ff,$ff,$ff,$fc,$ff,$f0,$ff,$c0,$ff,$00,$ff,$00,$ff,$00,$ff DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$03,$ff DB $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$fe,$ff,$fe,$ff,$fc,$ff,$fc,$ff DB $80,$ff,$80,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $3f,$ff,$3f,$ff,$7f,$ff,$7f,$ff,$7f,$80,$7f,$80,$00,$ff,$00,$ff DB $f8,$ff,$fe,$ff,$ff,$ff,$ff,$ff,$ff,$00,$ff,$00,$00,$ff,$00,$ff DB $03,$f3,$03,$c3,$c3,$c3,$c3,$c3,$e3,$63,$e3,$63,$33,$f3,$33,$f3 DB $c3,$ff,$fb,$c7,$ff,$c3,$ff,$c3,$ff,$c3,$cf,$c3,$c7,$c3,$c7,$c3 DB $c0,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$03,$ff DB $00,$ff,$00,$ff,$00,$ff,$03,$ff,$0f,$ff,$3c,$fc,$f0,$f0,$c1,$c1 DB $0f,$ff,$3c,$fc,$f0,$f0,$c1,$c1,$07,$07,$1f,$1f,$7f,$7f,$ff,$ff DB $f8,$ff,$38,$3f,$30,$3f,$30,$3f,$3f,$3f,$3f,$3f,$00,$00,$00,$00 DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$ff,$ff,$ff,$ff,$00,$00,$00,$00 DB $1f,$ff,$1f,$ff,$0c,$fc,$0c,$fc,$fc,$fc,$fc,$fc,$00,$00,$00,$00 DB $00,$ff,$c0,$ff,$f0,$ff,$3c,$3f,$0f,$0f,$83,$83,$e0,$e0,$f8,$f8 DB $c7,$c3,$c7,$c3,$ff,$ff,$ff,$ff,$c3,$c3,$c3,$c3,$00,$00,$00,$00 DB $00,$ff,$03,$ff,$0f,$ff,$3c,$fc,$f0,$f0,$c1,$c1,$07,$07,$1e,$1f DB $ff,$ff,$ff,$ff,$03,$03,$03,$03,$73,$73,$f3,$f3,$b3,$f3,$33,$f3 DB $0f,$0f,$1f,$1f,$7f,$7f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $07,$07,$1f,$1f,$7f,$7f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $ff,$ff,$ff,$ff,$c0,$ff,$e0,$ff,$e0,$ff,$e0,$ff,$e0,$ff,$e0,$ff DB $ff,$ff,$ff,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $ff,$ff,$ff,$ff,$1f,$fe,$0f,$fe,$0f,$fe,$0f,$ff,$0f,$ff,$07,$ff DB $ff,$ff,$ff,$ff,$32,$c3,$02,$e3,$22,$e3,$03,$c3,$01,$c0,$60,$60 DB $9f,$ff,$8f,$ff,$1c,$f0,$18,$f0,$38,$e0,$e0,$c0,$c0,$00,$01,$00 DB $ff,$ff,$ff,$ff,$0f,$00,$0f,$00,$1e,$01,$1c,$03,$30,$0f,$f0,$0f DB $f8,$ff,$f0,$ff,$18,$ff,$18,$ff,$18,$ff,$18,$ff,$38,$ff,$38,$ff DB $33,$f3,$33,$f3,$33,$f3,$33,$f3,$33,$f3,$33,$f3,$33,$f3,$33,$f3 DB $0f,$ff,$3c,$fc,$f0,$f0,$c1,$c1,$07,$07,$1e,$1f,$78,$7f,$e0,$ff DB $07,$07,$1e,$1f,$78,$7f,$e1,$ff,$83,$ff,$07,$ff,$07,$ff,$0f,$ff DB $f0,$f0,$f0,$f0,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $07,$07,$1f,$1f,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $7f,$ff,$7f,$ff,$7f,$ff,$7f,$ff,$7f,$ff,$3f,$ff,$bf,$7f,$d7,$3f DB $ff,$ff,$ff,$ff,$ff,$ff,$fe,$ff,$f8,$ff,$f0,$ff,$c0,$ff,$80,$ff DB $c0,$ff,$80,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $00,$ff,$00,$ff,$00,$ff,$20,$ff,$10,$ff,$1c,$ff,$0f,$ff,$0f,$ff DB $02,$fe,$00,$fe,$00,$fe,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$c0,$ff DB $00,$18,$01,$0e,$0f,$00,$0e,$80,$06,$f1,$00,$f0,$00,$f0,$00,$f2 DB $0f,$08,$8d,$0e,$85,$06,$05,$46,$47,$06,$5c,$3f,$5e,$bc,$04,$f0 DB $70,$0f,$30,$0f,$b3,$0f,$9f,$0f,$9f,$0f,$9f,$0f,$0f,$1f,$2f,$1f DB $f8,$ff,$f0,$ff,$f0,$ff,$f0,$ff,$e0,$ff,$c0,$ff,$80,$ff,$00,$ff DB $30,$f0,$30,$f0,$3f,$ff,$3f,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $07,$07,$1e,$1f,$f8,$ff,$e0,$ff,$00,$ff,$07,$ff,$0f,$ff,$1f,$ff DB $80,$ff,$00,$ff,$00,$ff,$00,$ff,$1f,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $07,$ff,$07,$ff,$03,$ff,$03,$ff,$c1,$ff,$e0,$ff,$e0,$ff,$f0,$ff DB $ff,$fc,$fb,$fc,$fe,$f8,$fe,$f0,$fc,$f0,$fc,$f0,$fc,$f0,$fc,$f8 DB $d7,$3f,$ff,$1f,$7f,$0f,$3f,$0f,$1f,$07,$1f,$07,$1f,$07,$3f,$0f DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$80,$ff DB $07,$ff,$07,$ff,$0f,$f3,$19,$e7,$1d,$e3,$1c,$e3,$3c,$c3,$3e,$c1 DB $0d,$f2,$04,$fb,$00,$f9,$00,$f8,$00,$fc,$00,$fc,$00,$ff,$00,$ff DB $20,$c0,$80,$60,$00,$21,$2c,$83,$84,$03,$00,$07,$80,$07,$00,$8f DB $06,$3f,$0c,$7f,$0c,$ff,$0c,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $1f,$ff,$3f,$ff,$3f,$fb,$3f,$f9,$40,$c0,$40,$c0,$40,$c0,$00,$80 DB $f0,$ff,$f8,$ff,$f8,$ff,$f8,$ff,$fc,$ff,$fc,$ff,$fc,$ff,$fe,$ff DB $7f,$ff,$7f,$ff,$3f,$ff,$3f,$ff,$3f,$ff,$1f,$ff,$1f,$ff,$1f,$ff DB $fc,$fc,$fb,$fb,$fb,$fb,$fc,$f8,$ff,$fc,$fd,$fc,$fe,$fc,$fe,$ff DB $1f,$1f,$6f,$6f,$ef,$6f,$9f,$8f,$3f,$0f,$7f,$1f,$3f,$1f,$1f,$ff DB $80,$ff,$e0,$ff,$e0,$ff,$f0,$ff,$f8,$ff,$fc,$ff,$ff,$ff,$ff,$ff DB $3e,$c1,$3f,$c0,$3f,$c0,$3f,$c0,$3f,$c0,$3f,$c0,$3f,$c0,$3f,$c0 DB $00,$ff,$01,$ff,$07,$ff,$1f,$ff,$ff,$7f,$ff,$7f,$ff,$3f,$ff,$3f DB $80,$ff,$c0,$ff,$c0,$ff,$e0,$ff,$e0,$ff,$e0,$ff,$e0,$ff,$f0,$ff DB $00,$ff,$00,$ff,$00,$ff,$01,$fe,$03,$fc,$07,$f8,$07,$f8,$07,$f8 DB $00,$80,$80,$00,$e1,$00,$e1,$00,$e1,$00,$e1,$00,$e0,$00,$f0,$00 DB $ff,$ff,$ff,$ff,$ff,$7f,$ff,$7f,$ff,$7f,$ff,$7f,$ff,$3f,$ff,$3f DB $fe,$ff,$fe,$ff,$fe,$ff,$fe,$ff,$fc,$ff,$fc,$ff,$fc,$ff,$fc,$ff DB $fe,$fc,$ff,$fe,$fe,$ff,$fe,$fe,$ff,$fe,$ff,$ff,$ff,$ff,$ff,$ff DB $1f,$0f,$3f,$1f,$df,$3f,$1f,$1f,$3f,$1f,$ff,$3f,$3f,$3f,$3f,$3f DB $e0,$ff,$f0,$ff,$fe,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff DB $1f,$e0,$1f,$e0,$1f,$e0,$1f,$e0,$1f,$e0,$1f,$e0,$3f,$c0,$3f,$c0 DB $ff,$3f,$ff,$1f,$ff,$1f,$ff,$1f,$ff,$1f,$ff,$0f,$ff,$0f,$ff,$0f DB $07,$f8,$03,$fc,$01,$fe,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $f0,$00,$f0,$00,$f8,$00,$f8,$00,$fc,$00,$7c,$80,$3c,$c0,$1e,$e0 DB $03,$ff,$03,$ff,$03,$ff,$03,$ff,$03,$ff,$03,$ff,$03,$ff,$03,$ff DB $ff,$3f,$3f,$ff,$3f,$ff,$3f,$ff,$3f,$ff,$3f,$ff,$3f,$ff,$3f,$ff DB $ff,$c0,$ff,$c0,$ff,$c0,$ff,$c0,$ff,$c0,$ff,$c0,$ff,$c0,$ff,$e0 DB $ff,$0f,$ff,$0f,$f7,$0f,$f3,$0f,$f1,$0f,$f0,$0f,$f1,$0f,$e1,$1f DB $c0,$ff,$fe,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$fc,$fc,$f8,$f8 DB $00,$ff,$00,$ff,$80,$ff,$c0,$ff,$e0,$ff,$a0,$b0,$30,$00,$30,$00 DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$1f,$00,$01 DB $1e,$e0,$0e,$f0,$07,$f8,$07,$f8,$03,$fc,$01,$fe,$01,$fe,$00,$ff DB $7f,$0f,$7f,$0f,$7f,$0f,$7c,$0f,$78,$07,$f8,$07,$f8,$07,$f8,$07 DB $fd,$ff,$fc,$ff,$fc,$ff,$fe,$ff,$ef,$ff,$9f,$ff,$3e,$ff,$3f,$ff DB $ff,$ff,$ff,$ff,$3f,$ff,$1d,$ff,$1b,$ff,$19,$ff,$39,$ff,$f3,$ff DB $ff,$ff,$ff,$f3,$ff,$e1,$ff,$c0,$ff,$c0,$ff,$80,$ff,$80,$ff,$00 DB $fd,$ff,$fc,$ff,$fc,$ff,$fe,$7f,$ff,$7f,$ff,$1f,$ff,$0f,$ff,$06 DB $ff,$ff,$ff,$ff,$7f,$f8,$7f,$e0,$ff,$c0,$ff,$c1,$ff,$83,$ff,$03 DB $ff,$c0,$ff,$00,$ff,$00,$ff,$00,$ff,$78,$f7,$f8,$fd,$f2,$e8,$f7 DB $c1,$3f,$81,$7f,$81,$7f,$01,$ff,$01,$ff,$01,$ff,$01,$ff,$01,$ff DB $ff,$bf,$ff,$8f,$e3,$02,$c0,$00,$88,$00,$bf,$00,$fe,$30,$fc,$b8 DB $f0,$f0,$e0,$c0,$e0,$00,$41,$00,$00,$09,$1b,$00,$72,$00,$46,$00 DB $2c,$00,$67,$00,$c7,$00,$cc,$0b,$1c,$83,$9c,$03,$1c,$03,$00,$1f DB $00,$00,$f8,$00,$f7,$08,$f0,$0f,$0f,$f0,$03,$fc,$00,$ff,$00,$ff DB $00,$1f,$00,$03,$00,$00,$00,$c0,$c0,$38,$86,$01,$70,$80,$04,$f8 DB $00,$ff,$00,$ff,$00,$7f,$00,$0f,$00,$00,$00,$00,$80,$60,$18,$07 DB $f8,$07,$cc,$03,$cc,$03,$c4,$03,$44,$03,$00,$03,$80,$03,$c0,$01 DB $03,$ff,$03,$ff,$03,$ff,$03,$ff,$41,$ff,$31,$ff,$18,$ff,$18,$ff DB $9f,$ff,$ff,$ff,$ff,$ff,$ef,$ff,$cf,$ff,$8f,$ff,$87,$ff,$83,$ff DB $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff,$ef,$ff,$e7,$ff,$c3,$ff,$c7,$ff DB $ff,$fc,$ff,$f8,$ff,$f0,$ff,$e1,$ff,$c1,$ff,$c1,$ff,$c1,$ff,$e1 DB $ff,$38,$ff,$7c,$ff,$ff,$ff,$e0,$7f,$e0,$ff,$e0,$bf,$e0,$bf,$f1 DB $ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$c0 DB $ff,$07,$ff,$0f,$ff,$1f,$ff,$3e,$ff,$3c,$ff,$0d,$ff,$01,$ff,$03 DB $d8,$e7,$e0,$9f,$c0,$3f,$80,$7f,$80,$ff,$80,$ff,$80,$ff,$80,$ff DB $01,$ff,$03,$ff,$03,$ff,$03,$ff,$03,$ff,$06,$ff,$06,$ff,$04,$ff DB $f0,$f8,$f0,$f0,$e0,$f0,$e0,$f8,$40,$f8,$c0,$fc,$c0,$fe,$80,$fe DB $4a,$04,$40,$86,$40,$86,$00,$c6,$80,$47,$80,$47,$00,$47,$00,$67 DB $00,$1f,$00,$0f,$00,$0f,$00,$0f,$00,$0f,$00,$87,$00,$c3,$00,$e3 DB $81,$00,$1c,$e0,$03,$fc,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $e0,$01,$20,$01,$e1,$00,$0f,$f0,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $0f,$ff,$0f,$ff,$07,$ff,$07,$ff,$07,$ff,$0f,$ff,$0f,$ff,$0b,$ff DB $00,$ff,$00,$ff,$03,$fc,$47,$b8,$27,$d8,$67,$98,$63,$9c,$30,$cf DB $4f,$bf,$ce,$3f,$c6,$3f,$82,$7f,$08,$f7,$06,$f9,$83,$7c,$03,$fc DB $3f,$e1,$3f,$e1,$3f,$f1,$5f,$b1,$3f,$dd,$67,$9f,$63,$9c,$30,$cf DB $5f,$b0,$df,$38,$cf,$38,$8f,$7c,$0f,$f4,$07,$fe,$83,$7f,$03,$fc DB $ff,$c0,$ff,$80,$ff,$80,$ff,$80,$ff,$80,$ff,$c0,$ff,$c0,$7f,$fc DB $ff,$73,$ff,$e3,$be,$ef,$ba,$ff,$88,$f7,$c6,$f9,$e3,$7c,$f3,$3c DB $80,$ff,$80,$ff,$c0,$ff,$40,$ff,$60,$ff,$60,$bf,$70,$bf,$30,$df DB $0c,$ff,$0f,$ff,$0f,$ff,$1b,$ff,$19,$f7,$17,$f9,$13,$fd,$13,$fd DB $04,$63,$0c,$73,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$03,$ff,$02,$ff,$01,$ff,$01,$ff DB $0c,$ff,$06,$ff,$03,$fe,$03,$fe,$f3,$fe,$7f,$9e,$63,$9c,$30,$cf DB $00,$ff,$18,$e7,$0c,$f3,$1c,$e3,$3c,$c3,$fe,$01,$ff,$00,$ff,$00 DB $26,$d9,$10,$ef,$1c,$e3,$1e,$e1,$3f,$c0,$7f,$80,$ff,$00,$ff,$00 DB $07,$ff,$19,$e7,$0c,$f3,$1c,$e3,$3c,$c3,$fe,$01,$ff,$00,$ff,$00 DB $f6,$19,$f0,$df,$7c,$f3,$1e,$e1,$3f,$c0,$7f,$80,$ff,$00,$ff,$00 DB $18,$ff,$18,$ef,$0c,$ff,$1c,$e7,$3c,$c7,$fe,$07,$ff,$03,$ff,$00 DB $36,$f9,$30,$ef,$3c,$e3,$3e,$e1,$3f,$e0,$3f,$e0,$bf,$e0,$ff,$e0 DB $80,$ff,$c0,$ff,$60,$ff,$20,$ff,$30,$ff,$fc,$1f,$fe,$07,$ff,$03 DB $01,$ff,$01,$ff,$01,$ff,$01,$ff,$01,$ff,$01,$ff,$01,$ff,$03,$ff DB $ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$00 DB $c0,$ff,$e0,$7f,$f0,$3f,$f8,$1f,$fc,$0f,$fc,$07,$f8,$0f,$f8,$0f DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$00,$ff,$02,$ff,$03,$ff,$07,$fd DB $00,$ff,$00,$ff,$00,$ff,$00,$ff,$01,$ff,$07,$ff,$0f,$fc,$bf,$f8 DB $03,$fe,$07,$fe,$1f,$fc,$3f,$f0,$ff,$e0,$ff,$00,$ff,$00,$ff,$00 BGTilesEnd: ; ------------------------------------------------------------- SECTION "X Sine Table",ROMX,BANK[1],ALIGN[8] XSineTable: DB $00,$00,$FF,$FE,$FD,$FD,$FC,$FB,$FA,$F9,$F9,$F8,$F7,$F6,$F6,$F5 DB $F4,$F4,$F3,$F2,$F1,$F1,$F0,$EF,$EF,$EE,$ED,$ED,$EC,$EC,$EB,$EA DB $EA,$E9,$E9,$E8,$E8,$E7,$E7,$E6,$E6,$E5,$E5,$E5,$E4,$E4,$E4,$E3 DB $E3,$E3,$E2,$E2,$E2,$E2,$E1,$E1,$E1,$E1,$E1,$E1,$E1,$E1,$E1,$E1 DB $E0,$E1,$E1,$E1,$E1,$E1,$E1,$E1,$E1,$E1,$E1,$E2,$E2,$E2,$E2,$E3 DB $E3,$E3,$E4,$E4,$E4,$E5,$E5,$E5,$E6,$E6,$E7,$E7,$E8,$E8,$E9,$E9 DB $EA,$EA,$EB,$EC,$EC,$ED,$ED,$EE,$EF,$EF,$F0,$F1,$F1,$F2,$F3,$F4 DB $F4,$F5,$F6,$F6,$F7,$F8,$F9,$F9,$FA,$FB,$FC,$FD,$FD,$FE,$FF,$00 DB $00,$00,$01,$02,$03,$03,$04,$05,$06,$07,$07,$08,$09,$0A,$0A,$0B DB $0C,$0C,$0D,$0E,$0F,$0F,$10,$11,$11,$12,$13,$13,$14,$14,$15,$16 DB $16,$17,$17,$18,$18,$19,$19,$1A,$1A,$1B,$1B,$1B,$1C,$1C,$1C,$1D DB $1D,$1D,$1E,$1E,$1E,$1E,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F DB $20,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1F,$1E,$1E,$1E,$1E,$1D DB $1D,$1D,$1C,$1C,$1C,$1B,$1B,$1B,$1A,$1A,$19,$19,$18,$18,$17,$17 DB $16,$16,$15,$14,$14,$13,$13,$12,$11,$11,$10,$0F,$0F,$0E,$0D,$0C DB $0C,$0B,$0A,$0A,$09,$08,$07,$07,$06,$05,$04,$03,$03,$02,$01,$00 SECTION "Y Sine Table",ROMX,BANK[1],ALIGN[8] YSineTable: DB $00,$00,$01,$01,$02,$02,$03,$03,$04,$04,$05,$05,$06,$06,$06,$07 DB $07,$07,$07,$07,$07,$08,$07,$07,$07,$07,$07,$07,$06,$06,$06,$05 DB $05,$04,$04,$03,$03,$02,$02,$01,$01,$00,$00,$00,$FF,$FF,$FE,$FE DB $FD,$FC,$FC,$FC,$FB,$FB,$FA,$FA,$FA,$F9,$F9,$F9,$F9,$F9,$F9,$F8 DB $F9,$F9,$F9,$F9,$F9,$F9,$FA,$FA,$FA,$FB,$FB,$FC,$FC,$FD,$FD,$FE DB $FE,$FF,$FF,$00 DB $00,$00,$01,$01,$02,$02,$03,$03,$04,$04,$05,$05,$06,$06,$06,$07 DB $07,$07,$07,$07,$07,$08,$07,$07,$07,$07,$07,$07,$06,$06,$06,$05 DB $05,$04,$04,$03,$03,$02,$02,$01,$01,$00,$00,$00,$FF,$FF,$FE,$FE DB $FD,$FC,$FC,$FC,$FB,$FB,$FA,$FA,$FA,$F9,$F9,$F9,$F9,$F9,$F9,$F8 DB $F9,$F9,$F9,$F9,$F9,$F9,$FA,$FA,$FA,$FB,$FB,$FC,$FC,$FD,$FD,$FE DB $FE,$FF,$FF,$00 DB $00,$00,$01,$01,$02,$02,$03,$03,$04,$04,$05,$05,$06,$06,$06,$07 DB $07,$07,$07,$07,$07,$08,$07,$07,$07,$07,$07,$07,$06,$06,$06,$05 DB $05,$04,$04,$03,$03,$02,$02,$01,$01,$00,$00,$00,$FF,$FF,$FE,$FE DB $FD,$FC,$FC,$FC,$FB,$FB,$FA,$FA,$FA,$F9,$F9,$F9,$F9,$F9,$F9,$F8 DB $F9,$F9,$F9,$F9,$F9,$F9,$FA,$FA,$FA,$FB,$FB,$FC,$FC,$FD,$FD,$FE DB $FE,$FF,$FF,$00 DB $00 SECTION "Roll Table",ROMX,BANK[1],ALIGN[8] RollTable: DB 64,60,58,56,54,52,50,48,46,44,43,41,39,38,36,34 DB 33,31,29,27,26,24,22,21,19,17,15,13,11, 9, 7, 5
; A113726: A Jacobsthal convolution. ; Submitted by Christian Krause ; 1,0,1,4,5,8,25,44,77,176,353,660,1365,2776,5417,10876,21981,43648,87153,175076,349669,698280,1398585,2797260,5590381,11184720,22373761,44735284,89474165,178969208,357910345,715807004,1431683837,2863325216 add $0,2 mov $2,2 lpb $0 sub $0,1 mov $5,$1 mov $1,$3 mul $5,2 sub $4,$5 mul $4,2 sub $3,$4 mov $4,$2 mov $2,$3 add $5,$4 mov $3,$5 lpe mov $0,$1 div $0,2
.ORIG x3000 LD R0, Nx8A9C LD R3, Nxn8000 AND R4, R4, #0 AND R0, R0, #-2 ADD R0, R0, #1 BRzp START ADD R4, R4, #-1 BRnzp START P ADD R4, R4, R4 ADD R0, R0, R0 CHECK_P BRp P ADD R1, R0, R3 BRp N BRnzp OK N ADD R4, R4, R4 ADD R4, R4, #1 START ADD R0, R0, R0 CHECK_N BRp P ADD R1, R0, R3 BRp N BRnzp OK OK HALT Nx8A9C .FILL xAFFF Nxn8000 .FILL x-8000 NxnC000 .FILL x-C000 .END
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld a, 00 ldff(ff), a ld b, 97 call lwaitly_b ld a, b1 ldff(40), a ld a, 00 ldff(4b), a ld c, 41 ld a, ff ldff(4a), a ld a, 01 ldff(45), a ld a, 40 ldff(c), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ei .text@1000 lstatint: nop .text@1159 ld c, 4a ld a, 04 ldff(43), a nop ldff(c), a ld c, 41 .text@118a ldff a, (c) and a, 03 jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
// 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 "media/midi/usb_midi_device_factory_android.h" #include <jni.h> #include <vector> #include "base/android/scoped_java_ref.h" #include "base/bind.h" #include "base/containers/hash_tables.h" #include "base/lazy_instance.h" #include "base/memory/scoped_vector.h" #include "base/message_loop/message_loop.h" #include "base/synchronization/lock.h" #include "jni/UsbMidiDeviceFactoryAndroid_jni.h" #include "media/midi/usb_midi_device_android.h" namespace media { namespace { typedef UsbMidiDevice::Factory::Callback Callback; } // namespace UsbMidiDeviceFactoryAndroid::UsbMidiDeviceFactoryAndroid() : delegate_(NULL) {} UsbMidiDeviceFactoryAndroid::~UsbMidiDeviceFactoryAndroid() { JNIEnv* env = base::android::AttachCurrentThread(); if (!raw_factory_.is_null()) Java_UsbMidiDeviceFactoryAndroid_close(env, raw_factory_.obj()); } void UsbMidiDeviceFactoryAndroid::EnumerateDevices( UsbMidiDeviceDelegate* delegate, Callback callback) { DCHECK(!delegate_); JNIEnv* env = base::android::AttachCurrentThread(); uintptr_t pointer = reinterpret_cast<uintptr_t>(this); raw_factory_.Reset(Java_UsbMidiDeviceFactoryAndroid_create(env, pointer)); delegate_ = delegate; callback_ = callback; if (Java_UsbMidiDeviceFactoryAndroid_enumerateDevices( env, raw_factory_.obj(), base::android::GetApplicationContext())) { // Asynchronous operation. return; } // No devices are found. ScopedVector<UsbMidiDevice> devices; callback.Run(true, &devices); } // Called from the Java world. void UsbMidiDeviceFactoryAndroid::OnUsbMidiDeviceRequestDone( JNIEnv* env, jobject caller, jobjectArray devices) { size_t size = env->GetArrayLength(devices); ScopedVector<UsbMidiDevice> devices_to_pass; for (size_t i = 0; i < size; ++i) { UsbMidiDeviceAndroid::ObjectRef raw_device( env, env->GetObjectArrayElement(devices, i)); devices_to_pass.push_back(new UsbMidiDeviceAndroid(raw_device, delegate_)); } callback_.Run(true, &devices_to_pass); } bool UsbMidiDeviceFactoryAndroid::RegisterUsbMidiDeviceFactory(JNIEnv* env) { return RegisterNativesImpl(env); } } // namespace media
// license:BSD-3-Clause // copyright-holders:Fabio Priuli /*********************************************************************************************************** Interton Electronic VC 4000 cart emulation ***********************************************************************************************************/ /* Game List and Emulation Status When you load a game it will normally appear to be unresponsive. Most carts contain a number of variants of each game (e.g. Difficulty, Player1 vs Player2 or Player1 vs Computer, etc). Press F2 (if needed) to select which game variant you would like to play. The variant number will increment on-screen. When you've made your choice, press F1 to start. The main keys are unlabelled, because an overlay is provided with each cart. See below for a guide. You need to read the instructions that come with each game. In some games, the joystick is used like 4 buttons, and other games like a paddle. The two modes are incompatible when using a keyboard. Therefore (in the emulation) a config dipswitch is used. The preferred setting is listed below. (AC = Auto-centre, NAC = no auto-centre, 90 = turn controller 90 degrees). The list is rather incomplete, information will be added as it becomes available. The game names and numbers were obtained from the Amigan Software site. Cart Num Name ---------------------------------------------- 1. Grand Prix / Car Races / Autosport / Motor Racing / Road Race Config: Paddle, NAC Status: Working Controls: Left-Right: Steer; Up: Accelerate 2. Black Jack Status: Not working (some digits missing; indicator missing; dealer's cards missing) Controls: set bet with S and D; A to deal; 1 to hit, 2 to stay; Q accept insurance, E to decline; double-up (unknown key) Indicator: E make a bet then deal; I choose insurance; - you lost; + you won; X hit or stay 3. Olympics / Paddle Games / Bat & Ball / Pro Sport 60 / Sportsworld Config: Paddle, NAC Status: Working 4. Tank Battle / Combat Config: Button, 90 Status: Working Controls: Left-Right: Steer; Up: Accelerate; Fire: Shoot 5. Maths 1 Status: Working Controls: Z difficulty; X = addition or subtraction; C ask question; A=1;S=2;D=3;Q=4;W=5;E=6;1=7;2=8;3=9;0=0; C enter 6. Maths 2 Status: Not working Controls: Same as above. 7. Air Sea Attack / Air Sea Battle Config: Button, 90 Status: Working Controls: Left-Right: Move; Fire: Shoot 8. Treasure Hunt / Capture the Flag / Concentration / Memory Match Config: Buttons Status: Working 9. Labyrinth / Maze / Intelligence 1 Config: Buttons Status: Working 10. Winter Sports Notes: Background colours should be Cyan and White instead of Red and Black 11. Hippodrome / Horse Race 12. Hunting / Shooting Gallery 13. Chess 1 Status: Can't see what you're typing, wrong colours 14. Moto-cros 15. Four in a row / Intelligence 2 Config: Buttons Status: Working Notes: Seems the unused squares should be black. The screen jumps about while the computer is "thinking". 16. Code Breaker / Master Mind / Intelligence 3 / Challenge 17. Circus STatus: severe gfx issues 18. Boxing / Prize Fight 19. Outer Space / Spacewar / Space Attack / Outer Space Combat 20. Melody Simon / Musical Memory / Follow the Leader / Musical Games / Electronic Music / Face the Music 21. Capture / Othello / Reversi / Attack / Intelligence 4 Config: Buttons Status: Working Notes: Seems the unused squares should be black 22. Chess 2 Status: Can't see what you're typing, wrong colours 23. Pinball / Flipper / Arcade Status: gfx issues 24. Soccer 25. Bowling / NinePins Config: Paddle, rotated 90 degrees, up/down autocentre, left-right does not Status: Working 26. Draughts 27. Golf Status: gfx issues 28. Cockpit Status: gfx issues 29. Metropolis / Hangman Status: gfx issues 30. Solitaire 31. Casino Status: gfx issues, items missing and unplayable Controls: 1 or 3=START; q=GO; E=STOP; D=$; Z=^; X=tens; C=units 32. Invaders / Alien Invasion / Earth Invasion Status: Works Config: Buttons 33. Super Invaders Status: Stars are missing, colours are wrong Config: Buttons (90) 36. BackGammon Status: Not all counters are visible, Dice & game number not visible. Controls: Fire=Exec; 1=D+; 3=D-; Q,W,E=4,5,6; A,S,D=1,2,3; Z=CL; X=STOP; C=SET 37. Monster Man / Spider's Web Status: Works Config: Buttons 38. Hyperspace Status: Works Config: Buttons (90) Controls: 3 - status button; Q,W,E,A,S,D,Z,X,C selects which galaxy to visit 40. Super Space Status: Works, some small gfx issues near the bottom Config: Buttons Acetronic: (dumps are compatible) ------------ * Shooting Gallery Status: works but screen flickers Config: Buttons * Planet Defender Status: Works Config: Paddle (NAC) * Laser Attack Status: Works Config: Buttons Public Domain: (written for emulators, may not work on real hardware) --------------- * Picture (no controls) - works * Wincadia Stub (no controls) - works, small graphic error */ #include "emu.h" #include "rom.h" //------------------------------------------------- // vc4000_rom_device - constructor //------------------------------------------------- DEFINE_DEVICE_TYPE(VC4000_ROM_STD, vc4000_rom_device, "vc4000_rom", "VC 4000 Standard Carts") DEFINE_DEVICE_TYPE(VC4000_ROM_ROM4K, vc4000_rom4k_device, "vc4000_rom4k", "VC 4000 Carts w/4K ROM") DEFINE_DEVICE_TYPE(VC4000_ROM_RAM1K, vc4000_ram1k_device, "vc4000_ram1k", "VC 4000 Carts w/1K RAM") DEFINE_DEVICE_TYPE(VC4000_ROM_CHESS2, vc4000_chess2_device, "vc4000_chess2", "VC 4000 Chess II Cart") vc4000_rom_device::vc4000_rom_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock), device_vc4000_cart_interface(mconfig, *this) { } vc4000_rom_device::vc4000_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : vc4000_rom_device(mconfig, VC4000_ROM_STD, tag, owner, clock) { } vc4000_rom4k_device::vc4000_rom4k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : vc4000_rom_device(mconfig, VC4000_ROM_ROM4K, tag, owner, clock) { } vc4000_ram1k_device::vc4000_ram1k_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : vc4000_rom_device(mconfig, VC4000_ROM_RAM1K, tag, owner, clock) { } vc4000_chess2_device::vc4000_chess2_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : vc4000_rom_device(mconfig, VC4000_ROM_CHESS2, tag, owner, clock) { } /*------------------------------------------------- mapper specific handlers -------------------------------------------------*/ uint8_t vc4000_rom_device::read_rom(offs_t offset) { if (offset < m_rom_size) return m_rom[offset]; else return 0xff; } uint8_t vc4000_ram1k_device::read_ram(offs_t offset) { return m_ram[offset & (m_ram.size() - 1)]; } void vc4000_ram1k_device::write_ram(offs_t offset, uint8_t data) { m_ram[offset & (m_ram.size() - 1)] = data; } uint8_t vc4000_chess2_device::extra_rom(offs_t offset) { if (offset < (m_rom_size - 0x2000)) return m_rom[offset + 0x2000]; else return 0xff; } uint8_t vc4000_chess2_device::read_ram(offs_t offset) { return m_ram[offset & (m_ram.size() - 1)]; } void vc4000_chess2_device::write_ram(offs_t offset, uint8_t data) { m_ram[offset & (m_ram.size() - 1)] = data; }
/* * Copyright (c) 2017, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, 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. */ L0: (W&~f0.1)jmpi L720 L16: mov (8|M0) r17.0<1>:ud r25.0<8;8,1>:ud mov (1|M0) r16.2<1>:ud 0xE000:ud cmp (1|M0) (eq)f1.0 null.0<1>:w r24.2<0;1,0>:ub 0x1:uw mov (16|M0) r82.0<1>:uw 0xFFFF:uw mov (16|M0) r83.0<1>:uw 0xFFFF:uw mov (16|M0) r90.0<1>:uw 0xFFFF:uw mov (16|M0) r91.0<1>:uw 0xFFFF:uw add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x42EC100:ud (~f1.0) mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r10.7<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r10.6<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r10.7<0;1,0>:f send (1|M0) r80:uw r16:ub 0x2 a0.0 (~f1.0) mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r10.4<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r10.6<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r10.4<0;1,0>:f send (1|M0) r88:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x42EC201:ud (~f1.0) mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r10.7<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r10.6<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r10.7<0;1,0>:f send (1|M0) r84:uw r16:ub 0x2 a0.0 (~f1.0) mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r10.4<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r10.6<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r10.4<0;1,0>:f send (1|M0) r92:uw r16:ub 0x2 a0.0 add (1|M0) a0.0<1>:ud r23.5<0;1,0>:ud 0x42EC302:ud (~f1.0) mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r10.7<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r10.6<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r10.7<0;1,0>:f send (1|M0) r86:uw r16:ub 0x2 a0.0 (~f1.0) mov (1|M0) r17.2<1>:f r10.1<0;1,0>:f (~f1.0) mov (1|M0) r17.3<1>:f r10.4<0;1,0>:f (f1.0) mov (1|M0) r17.2<1>:f r10.6<0;1,0>:f (f1.0) mov (1|M0) r17.3<1>:f r10.4<0;1,0>:f send (1|M0) r94:uw r16:ub 0x2 a0.0 mov (1|M0) a0.8<1>:uw 0xA00:uw mov (1|M0) a0.9<1>:uw 0xA80:uw mov (1|M0) a0.10<1>:uw 0xAC0:uw add (4|M0) a0.12<1>:uw a0.8<4;4,1>:uw 0x100:uw L720: nop
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r8 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x2dee, %rsi lea addresses_WC_ht+0x6e8e, %rdi nop nop inc %rbx mov $52, %rcx rep movsl and %rax, %rax lea addresses_A_ht+0x8b3e, %r10 nop nop nop nop nop and %r8, %r8 movb (%r10), %al xor %r10, %r10 lea addresses_normal_ht+0x1504e, %rsi sub $7474, %rcx movups (%rsi), %xmm0 vpextrq $0, %xmm0, %rdi nop nop nop nop nop add %r8, %r8 lea addresses_WC_ht+0x1386e, %r10 nop nop nop nop add %rdi, %rdi movw $0x6162, (%r10) cmp %rsi, %rsi lea addresses_WC_ht+0x1bf8e, %r8 nop nop nop nop nop xor $19785, %rcx mov (%r8), %si nop add $24903, %rdi lea addresses_WT_ht+0xe8e, %r10 nop nop nop cmp $39121, %r8 movups (%r10), %xmm1 vpextrq $0, %xmm1, %rax nop nop nop dec %rbx lea addresses_WC_ht+0x760e, %rax add %rdi, %rdi movb $0x61, (%rax) nop sub $31952, %rcx lea addresses_D_ht+0x1210e, %rsi lea addresses_UC_ht+0x126a2, %rdi nop nop nop nop xor %r12, %r12 mov $56, %rcx rep movsw nop nop nop nop nop add $39401, %r10 lea addresses_UC_ht+0x1dd0e, %rsi lea addresses_WT_ht+0x1890e, %rdi cmp $61352, %r10 mov $89, %rcx rep movsw nop and %r10, %r10 lea addresses_WC_ht+0x1e420, %r8 xor $38343, %rdi mov (%r8), %ebx add %rcx, %rcx lea addresses_WT_ht+0x1c0e, %rsi lea addresses_UC_ht+0x1e48e, %rdi nop nop nop nop and %r8, %r8 mov $29, %rcx rep movsb cmp $7920, %r8 lea addresses_WC_ht+0x1590e, %rsi clflush (%rsi) nop nop sub $20240, %rbx and $0xffffffffffffffc0, %rsi vmovaps (%rsi), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $0, %xmm5, %rdi nop nop nop nop sub $53906, %rsi lea addresses_WC_ht+0x850e, %rsi lea addresses_WC_ht+0x1a90e, %rdi and $58510, %r12 mov $47, %rcx rep movsw nop nop nop and %r8, %r8 pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r15 push %r9 push %rcx push %rdx // Store lea addresses_WT+0x1990e, %r9 nop nop nop xor %rdx, %rdx mov $0x5152535455565758, %r13 movq %r13, %xmm2 movups %xmm2, (%r9) nop nop nop nop nop sub $15090, %r13 // Store lea addresses_RW+0x1b14e, %rdx nop nop nop and $41139, %r9 mov $0x5152535455565758, %r10 movq %r10, (%rdx) nop nop nop nop xor $53891, %r13 // Load lea addresses_A+0xff8e, %r9 nop nop nop nop nop and $13788, %rcx mov (%r9), %r10d nop nop nop nop nop add %rdx, %rdx // Store mov $0x52a64a00000009de, %rdx nop and %r11, %r11 mov $0x5152535455565758, %rcx movq %rcx, (%rdx) nop nop nop nop nop add %rdx, %rdx // Store lea addresses_UC+0x11e35, %rdx nop add %rcx, %rcx mov $0x5152535455565758, %r13 movq %r13, (%rdx) inc %r9 // Faulty Load lea addresses_US+0x1a90e, %r9 nop nop nop nop nop sub %rdx, %rdx movaps (%r9), %xmm2 vpextrq $1, %xmm2, %rcx lea oracles, %r15 and $0xff, %rcx shlq $12, %rcx mov (%r15,%rcx,1), %rcx pop %rdx pop %rcx pop %r9 pop %r15 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_US', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WT', 'same': False, 'size': 16, 'congruent': 11, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_RW', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'src': {'type': 'addresses_A', 'same': False, 'size': 4, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_NC', 'same': False, 'size': 8, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_US', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'same': True, 'size': 1, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 2, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 2, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC_ht', 'same': True, 'size': 1, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'same': True, 'size': 32, 'congruent': 11, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}, 'OP': 'REPM'} {'49': 14, '00': 21801, '48': 2, '08': 1, '46': 11} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 49 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
PIC_WIDTH = 320 PIC_HEIGHT equ 256 DEBUG_LEVEL set 10 DOUBLE_BUFFER_1 = 1 AUTO_COMPLETE_2 = 1 dood2 = 1 entry: bsr init bsr main bsr exit rts init move.w #PIC_HEIGHT,d1 .looph move.w #PIC_WIDTH,d0 .loopw clr.b (a0)+ subq.w #1,d0 bne.s .loopw subq.w #1,d1 bne.s .looph move.w a1,d2 move.w e move.w exit move.w PIC_WIDTH move.w AUTO_COMPLETE_2 move.w DEBUG_LEVEL move.w AUTO_COMPLETE_2 move.w DOUBLE_BUFFER_1 rts main moveq.l #0,d0 rts exit illegal rts
; A269641: Number of length-4 0..n arrays with no repeated value differing from the previous repeated value by other than plus two or minus 1. ; 9,63,221,567,1209,2279,3933,6351,9737,14319,20349,28103,37881,50007,64829,82719,104073,129311,158877,193239,232889,278343,330141,388847,455049,529359,612413,704871,807417,920759,1045629,1182783,1333001,1497087,1675869,1870199,2080953,2309031,2555357,2820879,3106569,3413423,3742461,4094727,4471289,4873239,5301693,5757791,6242697,6757599,7303709,7882263,8494521,9141767,9825309,10546479,11306633,12107151,12949437,13834919,14765049,15741303,16765181,17838207,18961929,20137919,21367773,22653111 sub $2,$0 add $0,2 mul $2,$0 pow $0,2 bin $0,2 add $0,$2 sub $0,6 mul $0,2 add $0,9
; A076338: a(n) = 512*n + 1. ; 1,513,1025,1537,2049,2561,3073,3585,4097,4609,5121,5633,6145,6657,7169,7681,8193,8705,9217,9729,10241,10753,11265,11777,12289,12801,13313,13825,14337,14849,15361,15873,16385,16897,17409,17921,18433,18945,19457,19969,20481,20993,21505,22017,22529,23041,23553,24065,24577,25089,25601,26113,26625,27137,27649,28161,28673,29185,29697,30209,30721,31233,31745,32257,32769,33281,33793,34305,34817,35329,35841,36353,36865,37377,37889,38401,38913,39425,39937,40449,40961,41473,41985,42497,43009,43521,44033,44545,45057,45569,46081,46593,47105,47617,48129,48641,49153,49665,50177,50689,51201,51713,52225,52737,53249,53761,54273,54785,55297,55809,56321,56833,57345,57857,58369,58881,59393,59905,60417,60929,61441,61953,62465,62977,63489,64001,64513,65025,65537,66049,66561,67073,67585,68097,68609,69121,69633,70145,70657,71169,71681,72193,72705,73217,73729,74241,74753,75265,75777,76289,76801,77313,77825,78337,78849,79361,79873,80385,80897,81409,81921,82433,82945,83457,83969,84481,84993,85505,86017,86529,87041,87553,88065,88577,89089,89601,90113,90625,91137,91649,92161,92673,93185,93697,94209,94721,95233,95745,96257,96769,97281,97793,98305,98817,99329,99841,100353,100865,101377,101889,102401,102913,103425,103937,104449,104961,105473,105985,106497,107009,107521,108033,108545,109057,109569,110081,110593,111105,111617,112129,112641,113153,113665,114177,114689,115201,115713,116225,116737,117249,117761,118273,118785,119297,119809,120321,120833,121345,121857,122369,122881,123393,123905,124417,124929,125441,125953,126465,126977,127489 mov $1,$0 mul $1,512 add $1,1
/* * All Video Processing kernels * Copyright © <2010>, Intel Corporation. * * This program is licensed under the terms and conditions of the * Eclipse Public License (EPL), version 1.0. The full text of the EPL is at * http://www.opensource.org/licenses/eclipse-1.0.php. * * Authors: * Halley Zhao <halley.zhao@intel.com> */ // Module name: RGBX_Save_YUV_Float.asm //---------------------------------------------------------------- #include "RGBX_Load_16x8.inc" #if (0) // 8 grf reg for one row of pixel (2 pixel per grf) #define nTEMP0 34 #define nTEMP1 35 #define nTEMP2 36 #define nTEMP3 37 #define nTEMP4 38 #define nTEMP5 39 #define nTEMP6 40 #define nTEMP7 41 #define nTEMP8 42 // transformation coefficient #define nTEMP10 44 // transformation coefficient #define nTEMP12 46 // save Y/U/V in ub format #define nTEMP14 48 // save YUV in ud format #define nTEMP16 50 // dp4 result #define nTEMP17 51 #define nTEMP18 52 #define nTEMP24 58 #endif $for(0; <nY_NUM_OF_ROWS; 1) { // BGRX | B | G | R | X | // ###### save one row of pixel to temp grf with float format (required by dp4) // mov (8) doesn't work, puzzle mov (4) REG(r, nTEMP0)<1>:f r[SRC_RGBA_OFFSET_1,%1*32 + 0]<4,1>:ub mov (4) REG(r, nTEMP1)<1>:f r[SRC_RGBA_OFFSET_1,%1*32 + 8]<4,1>:ub mov (4) REG(r, nTEMP2)<1>:f r[SRC_RGBA_OFFSET_1,%1*32 + 16]<4,1>:ub mov (4) REG(r, nTEMP3)<1>:f r[SRC_RGBA_OFFSET_1,%1*32 + 24]<4,1>:ub mov (4) REG(r, nTEMP4)<1>:f r[SRC_RGBA_OFFSET_2,%1*32 + 0]<4,1>:ub mov (4) REG(r, nTEMP5)<1>:f r[SRC_RGBA_OFFSET_2,%1*32 + 8]<4,1>:ub mov (4) REG(r, nTEMP6)<1>:f r[SRC_RGBA_OFFSET_2,%1*32 + 16]<4,1>:ub mov (4) REG(r, nTEMP7)<1>:f r[SRC_RGBA_OFFSET_2,%1*32 + 24]<4,1>:ub mov (4) REG2(r, nTEMP0, 4)<1>:f r[SRC_RGBA_OFFSET_1,%1*32 + 4]<4,1>:ub mov (4) REG2(r, nTEMP1, 4)<1>:f r[SRC_RGBA_OFFSET_1,%1*32 + 12]<4,1>:ub mov (4) REG2(r, nTEMP2, 4)<1>:f r[SRC_RGBA_OFFSET_1,%1*32 + 20]<4,1>:ub mov (4) REG2(r, nTEMP3, 4)<1>:f r[SRC_RGBA_OFFSET_1,%1*32 + 28]<4,1>:ub mov (4) REG2(r, nTEMP4, 4)<1>:f r[SRC_RGBA_OFFSET_2,%1*32 + 4]<4,1>:ub mov (4) REG2(r, nTEMP5, 4)<1>:f r[SRC_RGBA_OFFSET_2,%1*32 + 12]<4,1>:ub mov (4) REG2(r, nTEMP6, 4)<1>:f r[SRC_RGBA_OFFSET_2,%1*32 + 20]<4,1>:ub mov (4) REG2(r, nTEMP7, 4)<1>:f r[SRC_RGBA_OFFSET_2,%1*32 + 24]<4,1>:ub // ###### do one row for Y // ##### dp4(nTEMP16) and save result to uw format(nTEMP12) dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(0, 0)<0;8,1> fRGB_to_Y_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:ud REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 0)<1>:ub REG2(r, nTEMP14, 0)<0;2,4>:ub dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(1, 0)<0;8,1> fRGB_to_Y_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:ud REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 2)<1>:ub REG2(r, nTEMP14, 0)<0;2,4>:ub dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(2, 0)<0;8,1> fRGB_to_Y_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:ud REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 4)<1>:ub REG2(r, nTEMP14, 0)<0;2,4>:ub dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(3, 0)<0;8,1> fRGB_to_Y_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:ud REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 6)<1>:ub REG2(r, nTEMP14, 0)<0;2,4>:ub dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(4, 0)<0;8,1> fRGB_to_Y_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:ud REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 8)<1>:ub REG2(r, nTEMP14, 0)<0;2,4>:ub dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(5, 0)<0;8,1> fRGB_to_Y_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:ud REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 10)<1>:ub REG2(r, nTEMP14, 0)<0;2,4>:ub dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(6, 0)<0;8,1> fRGB_to_Y_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:ud REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 12)<1>:ub REG2(r, nTEMP14, 0)<0;2,4>:ub dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(7, 0)<0;8,1> fRGB_to_Y_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:ud REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 14)<1>:ub REG2(r, nTEMP14, 0)<0;2,4>:ub // #### write Y to the 1 row mov (16) uwDEST_Y(%1)<1> REG2(r,nTEMP12, 0)<0;16,1>:ub // ###### do one row for U // ##### dp4(nTEMP16) and save result to uw format(nTEMP12) dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(0, 0)<0;8,1> fRGB_to_U_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 0)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(1, 0)<0;8,1> fRGB_to_U_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 2)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(2, 0)<0;8,1> fRGB_to_U_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 4)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(3, 0)<0;8,1> fRGB_to_U_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 6)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(4, 0)<0;8,1> fRGB_to_U_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 8)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(5, 0)<0;8,1> fRGB_to_U_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 10)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(6, 0)<0;8,1> fRGB_to_U_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 12)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(7, 0)<0;8,1> fRGB_to_U_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 14)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w add (16) REG2(r, nTEMP12, 0)<1>:w REG2(r, nTEMP12, 0)<0;16,1>:w 128:w // #### write U to the 1 row mov (16) uwDEST_U(%1)<1> REG2(r,nTEMP12, 0)<0;16,2>:ub // ###### do one row for V // ##### dp4(nTEMP16) and save result to uw format(nTEMP12) dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(0, 0)<0;8,1> fRGB_to_V_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 0)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(1, 0)<0;8,1> fRGB_to_V_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 2)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(2, 0)<0;8,1> fRGB_to_V_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 4)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(3, 0)<0;8,1> fRGB_to_V_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 6)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(4, 0)<0;8,1> fRGB_to_V_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 8)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(5, 0)<0;8,1> fRGB_to_V_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 10)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(6, 0)<0;8,1> fRGB_to_V_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 12)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w dp4 (8) REG2(r, nTEMP16, 0)<1>:f fROW_BGRX(7, 0)<0;8,1> fRGB_to_V_Coef_Float<0;4,1>:f mov (2) REG2(r, nTEMP14, 0)<1>:d REG2(r, nTEMP16, 0)<0;2,4>:f mov (2) REG2(r, nTEMP12, 14)<1>:w REG2(r, nTEMP14, 0)<0;2,2>:w add (16) REG2(r, nTEMP12, 0)<1>:w REG2(r, nTEMP12, 0)<0;16,1>:w 128:w // #### write V to the 1 row mov (16) uwDEST_V(%1)<1> REG2(r,nTEMP12, 0)<0;16,2>:ub }
test_device(): sub rsp, 24 call rand mov rdx, QWORD PTR [rsp] mov ecx, eax shr rdx, 12 and edx, 63 sal edx, cl and edx, 63 mov eax, edx mov edx, DWORD PTR [rsp] sal eax, 12 and edx, -258049 or edx, eax mov DWORD PTR [rsp], edx add rsp, 24 ret
;; ;; Copyright (c) 2018-2021, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %include "include/aesni_emu.inc" %define AES_CBC_ENC_X4 aes_cbc_enc_256_x4_no_aesni %include "sse/aes_cbc_enc_256_x4.asm"
; ----------------------------------------------------------------------------- ; ZX7 Backwards by Einar Saukas, Antonio Villena ; "Standard" version (156/177/184 bytes only) for R800 ; ----------------------------------------------------------------------------- ; Parameters: ; HL: source address (compressed data) ; DE: destination address (decompressing) ; ----------------------------------------------------------------------------- define speed 2 macro getbitm if speed=0 add a, a ; check next bit call z, getbit ; no more bits left? else add a, a ; check next bit jp nz, .gb1 ; no more bits left? ld a, (hl) ; load another group of 8 bits dec hl adc a, a .gb1 endif endm macro getbiteom odd if (odd)=1 add a,a else getbitm endif endm macro maicoeom odd if odd=1 mailab: ld a, (hl) ; save some cycles avoiding call getbit dec hl adc a, a jr nc, copbyo maicoo: else maicoe: endif ; determine number of bits used for length (Elias gamma coding) .maico: ld bc, 2 ; BC=$0002 .maisi: push de ; store destination on stack ld d, b ; D= 0 getbiteom odd^0 ; getbit with macro getbitm if speed=0 jr c, .conti else jp c, .conti ; jp is 2 cycles faster when jump not taken endif dec c .leval: getbiteom odd^1 rl c rl b ; insert bit on BC getbiteom odd^0 jr nc, .leval ; repeat, final length on BC ; check escape sequence inc c ; detect escape sequence jr z, exitdz ; end of algorithm ; determine offset .conti: ld e, (hl) ; load offset flag (1 bit) + offset value (7 bits) dec hl rl e jr nc, .offnd ; if offset flag is set, load 4 extra bits getbiteom odd^1 ; load 4 bits by code rl d ; odd bits don't need end of byte checking getbiteom odd^0 rl d getbiteom odd^1 rl d getbiteom odd^0 ccf jr c, .offnd inc d ; equivalent to adding 128 to DE .offnd: rr e ; insert inverted fourth bit into E ex (sp), hl ; store source, restore destination ex de, hl ; destination from HL to DE adc hl, de ; HL = destination + offset + 1 if speed>1 ldd endif lddr pop hl ; restore source address (compressed data) getbiteom 1 if odd=1 jr z, mailab jr c, maicoo jp copbyo else if speed=0 jr c, .maico jr copbye else if speed=1 jr c, .maico jp copbye else jr nc, copbye ld c, 2 jp .maisi endif endif endif endm dzx7: if speed>1 ldd ; copy literal byte scf maicoeom 1 exitdz: pop hl ; exit path ret else ld a, $80 ; set marker bit as MSB endif copbye: ldd ; copy literal byte add a, a ; read next bit, faster method jr z, mailab ; call routine only if need to load next byte jr c, maicoo ; next bit indicates either literal or sequence copbyo: ldd ; loop unrolling x2 add a, a jr nc, copbye ; next bit indicates either literal or sequence maicoeom 0 if speed>1 else exitdz: pop hl ; exit path if speed=0 getbit: ld a, (hl) ; load another group of 8 bits dec hl adc a, a endif ret maicoeom 1 endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright(c) 2011-2016 Intel Corporation All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; * Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; * Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in ; the documentation and/or other materials provided with the ; distribution. ; * Neither the name of Intel Corporation nor the names of its ; contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; default rel [bits 64] %include "reg_sizes.asm" extern isal_deflate_body_base extern isal_deflate_body_01 extern isal_deflate_body_02 extern isal_deflate_body_04 extern isal_deflate_finish_base extern isal_deflate_finish_01 extern isal_deflate_icf_body_hash_hist_base extern isal_deflate_icf_body_hash_hist_01 extern isal_deflate_icf_body_hash_hist_02 extern isal_deflate_icf_body_hash_hist_04 extern isal_deflate_icf_finish_hash_hist_base extern isal_deflate_icf_finish_hash_hist_01 extern isal_deflate_icf_finish_hash_map_base extern isal_update_histogram_base extern isal_update_histogram_01 extern isal_update_histogram_04 extern gen_icf_map_h1_base extern gen_icf_map_lh1_04 extern encode_deflate_icf_base extern encode_deflate_icf_04 extern set_long_icf_fg_base extern set_long_icf_fg_04 %ifdef HAVE_AS_KNOWS_AVX512 extern encode_deflate_icf_06 extern set_long_icf_fg_06 extern gen_icf_map_lh1_06 %endif extern adler32_base extern adler32_avx2_4 extern adler32_sse extern isal_deflate_hash_base extern isal_deflate_hash_crc_01 extern isal_deflate_hash_mad_base extern icf_body_hash1_fillgreedy_lazy extern icf_body_lazyhash1_fillgreedy_greedy section .text %include "multibinary.asm" mbin_interface isal_deflate_body mbin_dispatch_init5 isal_deflate_body, isal_deflate_body_base, isal_deflate_body_01, isal_deflate_body_02, isal_deflate_body_04 mbin_interface isal_deflate_finish mbin_dispatch_init5 isal_deflate_finish, isal_deflate_finish_base, isal_deflate_finish_01, isal_deflate_finish_01, isal_deflate_finish_01 mbin_interface isal_deflate_icf_body_lvl1 mbin_dispatch_init5 isal_deflate_icf_body_lvl1, isal_deflate_icf_body_hash_hist_base, isal_deflate_icf_body_hash_hist_01, isal_deflate_icf_body_hash_hist_02, isal_deflate_icf_body_hash_hist_04 mbin_interface isal_deflate_icf_body_lvl2 mbin_dispatch_init5 isal_deflate_icf_body_lvl2, isal_deflate_icf_body_hash_hist_base, isal_deflate_icf_body_hash_hist_01, isal_deflate_icf_body_hash_hist_02, isal_deflate_icf_body_hash_hist_04 mbin_interface isal_deflate_icf_body_lvl3 mbin_dispatch_init5 isal_deflate_icf_body_lvl3, icf_body_hash1_fillgreedy_lazy, icf_body_hash1_fillgreedy_lazy, icf_body_hash1_fillgreedy_lazy, icf_body_lazyhash1_fillgreedy_greedy mbin_interface isal_deflate_icf_finish_lvl1 mbin_dispatch_init5 isal_deflate_icf_finish_lvl1, isal_deflate_icf_finish_hash_hist_base, isal_deflate_icf_finish_hash_hist_01, isal_deflate_icf_finish_hash_hist_01, isal_deflate_icf_finish_hash_hist_01 mbin_interface isal_deflate_icf_finish_lvl2 mbin_dispatch_init5 isal_deflate_icf_finish_lvl2, isal_deflate_icf_finish_hash_hist_base, isal_deflate_icf_finish_hash_hist_01, isal_deflate_icf_finish_hash_hist_01, isal_deflate_icf_finish_hash_hist_01 mbin_interface isal_deflate_icf_finish_lvl3 mbin_dispatch_init5 isal_deflate_icf_finish_lvl3, isal_deflate_icf_finish_hash_map_base, isal_deflate_icf_finish_hash_map_base, isal_deflate_icf_finish_hash_map_base, isal_deflate_icf_finish_hash_map_base mbin_interface isal_update_histogram mbin_dispatch_init5 isal_update_histogram, isal_update_histogram_base, isal_update_histogram_01, isal_update_histogram_01, isal_update_histogram_04 mbin_interface encode_deflate_icf mbin_dispatch_init6 encode_deflate_icf, encode_deflate_icf_base, encode_deflate_icf_base, encode_deflate_icf_base, encode_deflate_icf_04, encode_deflate_icf_06 mbin_interface set_long_icf_fg mbin_dispatch_init6 set_long_icf_fg, set_long_icf_fg_base, set_long_icf_fg_base, set_long_icf_fg_base, set_long_icf_fg_04, set_long_icf_fg_06 mbin_interface gen_icf_map_lh1 mbin_dispatch_init6 gen_icf_map_lh1, gen_icf_map_h1_base, gen_icf_map_h1_base, gen_icf_map_h1_base, gen_icf_map_lh1_04, gen_icf_map_lh1_06 mbin_interface isal_adler32 mbin_dispatch_init5 isal_adler32, adler32_base, adler32_sse, adler32_sse, adler32_avx2_4 mbin_interface isal_deflate_hash_lvl0 mbin_dispatch_init5 isal_deflate_hash_lvl0, isal_deflate_hash_base, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01 mbin_interface isal_deflate_hash_lvl1 mbin_dispatch_init5 isal_deflate_hash_lvl1, isal_deflate_hash_base, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01 mbin_interface isal_deflate_hash_lvl2 mbin_dispatch_init5 isal_deflate_hash_lvl2, isal_deflate_hash_base, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01, isal_deflate_hash_crc_01 mbin_interface isal_deflate_hash_lvl3 mbin_dispatch_init5 isal_deflate_hash_lvl3, isal_deflate_hash_base, isal_deflate_hash_base, isal_deflate_hash_base, isal_deflate_hash_mad_base
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r9 push %rbp push %rcx push %rdi push %rsi lea addresses_WT_ht+0xe9b7, %rsi lea addresses_A_ht+0x15777, %rdi nop nop nop sub %r9, %r9 mov $28, %rcx rep movsl nop nop and %rsi, %rsi lea addresses_WC_ht+0xd6f7, %rdi nop nop nop nop nop and %r14, %r14 movb (%rdi), %r9b nop nop nop nop inc %rdi lea addresses_D_ht+0x12cc9, %rsi nop nop nop nop nop dec %r11 mov (%rsi), %r9w nop nop nop nop xor $22784, %rdi lea addresses_A_ht+0x116f7, %rcx clflush (%rcx) nop nop nop nop add $17644, %rbp movups (%rcx), %xmm3 vpextrq $1, %xmm3, %r14 nop nop nop xor $33181, %r9 pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r15 push %r8 push %r9 push %rax push %rbp // Store mov $0x7f7, %rbp nop nop nop nop nop add %r10, %r10 mov $0x5152535455565758, %r9 movq %r9, (%rbp) nop nop nop xor %r15, %r15 // Load lea addresses_WC+0xc2f7, %r8 nop nop nop cmp $10692, %rax vmovups (%r8), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $0, %xmm7, %r15 nop nop nop xor %r9, %r9 // Load lea addresses_PSE+0x30c7, %r15 nop nop cmp %rax, %rax mov (%r15), %r9d nop nop nop nop add %r9, %r9 // Store mov $0xc77, %rbp nop nop nop cmp %r10, %r10 mov $0x5152535455565758, %rax movq %rax, %xmm4 vmovups %ymm4, (%rbp) nop nop sub $54160, %r10 // Store lea addresses_UC+0x167f7, %r10 nop nop nop nop nop cmp $51487, %r8 mov $0x5152535455565758, %rax movq %rax, (%r10) nop nop nop xor %r9, %r9 // Store lea addresses_D+0xb6fa, %rax nop nop cmp $54203, %r10 mov $0x5152535455565758, %r9 movq %r9, %xmm2 movups %xmm2, (%rax) add %r11, %r11 // Store lea addresses_PSE+0xecf7, %rbp nop nop xor %rax, %rax mov $0x5152535455565758, %r15 movq %r15, (%rbp) nop nop xor $36047, %r9 // Load lea addresses_UC+0x12ef7, %r8 nop nop cmp $48161, %r15 vmovups (%r8), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $1, %xmm6, %rax nop nop nop sub $21694, %r10 // Load lea addresses_PSE+0x1ebf7, %r9 nop nop cmp $14681, %r11 vmovups (%r9), %ymm6 vextracti128 $0, %ymm6, %xmm6 vpextrq $0, %xmm6, %r15 nop nop nop dec %r8 // Faulty Load lea addresses_WC+0x1e6f7, %r8 nop nop nop and $15425, %r11 vmovaps (%r8), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $0, %xmm5, %rax lea oracles, %r9 and $0xff, %rax shlq $12, %rax mov (%r9,%rax,1), %rax pop %rbp pop %rax pop %r9 pop %r8 pop %r15 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_P', 'congruent': 8}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_WC', 'congruent': 10}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_PSE', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_P', 'congruent': 6}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_UC', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_PSE', 'congruent': 9}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_UC', 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_PSE', 'congruent': 8}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': True, 'AVXalign': True, 'size': 32, 'type': 'addresses_WC', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 11}} {'54': 5, 'e0': 1, '60': 8, '72': 2, '00': 21778, '53': 2, '03': 9, '49': 3, 'b8': 3, '3b': 18} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 3b 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
///////////////////////////////////////////////////////////////////////////// // Name: src/common/docmdi.cpp // Purpose: Frame classes for MDI document/view applications // Author: Julian Smart, Vadim Zeitlin // Created: 01/02/97 // Copyright: (c) 1997 Julian Smart // (c) 2010 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #if wxUSE_MDI_ARCHITECTURE #include "wx/docmdi.h" IMPLEMENT_CLASS(wxDocMDIParentFrame, wxMDIParentFrame) IMPLEMENT_CLASS(wxDocMDIChildFrame, wxMDIChildFrame) #endif // wxUSE_DOC_VIEW_ARCHITECTURE
; ; ZX 81 specific routines ; by Stefano Bodrato, Oct 2007 ; ; convert char to ASCII ; ; char zx_ascii(char character); ; ; ; $Id: zx_ascii.asm,v 1.5 2016-06-26 20:32:08 dom Exp $ ; SECTION code_clib PUBLIC zx_ascii PUBLIC _zx_ascii EXTERN zx81toasc zx_ascii: _zx_ascii: ld hl,zx81toasc+1 ld a,(hl) push af push hl ld a,229 ; push hl ld (hl),a ld hl,6 add hl,sp ; location of char call zx81toasc pop bc ld h,0 ld l,a pop af ld (bc),a ret
.size 8000 .text@50 jp ltimaint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: xor a, a ldff(0f), a ldff(ff), a ld a, fe ldff(05), a ldff(06), a ld a, 04 ldff(ff), a ld a, 04 ldff(07), a ei nop halt .text@1000 ltimaint: ld a, 00 ldff(07), a .text@10f0 ld a, 04 ldff(07), a .text@14f1 ldff a, (05) jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a ld bc, 7a00 ld hl, 8000 ld d, 00 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles pop af ld b, a srl a srl a srl a srl a ld(9800), a ld a, b and a, 0f ld(9801), a ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f 00 00 08 08 22 22 41 41 7f 7f 41 41 41 41 41 41 00 00 7e 7e 41 41 41 41 7e 7e 41 41 41 41 7e 7e 00 00 3e 3e 41 41 40 40 40 40 40 40 41 41 3e 3e 00 00 7e 7e 41 41 41 41 41 41 41 41 41 41 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 40 40 40 40 7f 7f 40 40 40 40 40 40
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r15 push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x16cfe, %r13 nop add %rbx, %rbx mov $0x6162636465666768, %r15 movq %r15, %xmm3 vmovups %ymm3, (%r13) nop nop nop nop and $62170, %r10 lea addresses_D_ht+0xa04a, %rsi lea addresses_normal_ht+0x13b0a, %rdi add %r11, %r11 mov $39, %rcx rep movsw nop nop nop nop inc %r13 lea addresses_D_ht+0xa16d, %rdi nop nop nop and $29791, %r10 movups (%rdi), %xmm3 vpextrq $1, %xmm3, %r11 nop inc %r13 pop %rsi pop %rdi pop %rcx pop %rbx pop %r15 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r14 push %r9 push %rcx push %rdi push %rdx push %rsi // REPMOV lea addresses_D+0x10a4a, %rsi lea addresses_PSE+0x39ea, %rdi nop add $48280, %r14 mov $21, %rcx rep movsb cmp %rcx, %rcx // Faulty Load lea addresses_WC+0xd84a, %rdx clflush (%rdx) nop nop nop nop add $8619, %r10 mov (%rdx), %esi lea oracles, %rcx and $0xff, %rsi shlq $12, %rsi mov (%rcx,%rsi,1), %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r14 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_WC', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 9, 'type': 'addresses_D'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_PSE'}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WC', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32}} {'src': {'same': False, 'congruent': 10, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'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 */
; A157517: a(n) = 7 + 12*n - 6*n^2. ; 7,13,7,-11,-41,-83,-137,-203,-281,-371,-473,-587,-713,-851,-1001,-1163,-1337,-1523,-1721,-1931,-2153,-2387,-2633,-2891,-3161,-3443,-3737,-4043,-4361,-4691,-5033,-5387,-5753,-6131,-6521,-6923,-7337,-7763,-8201,-8651,-9113,-9587,-10073,-10571,-11081,-11603,-12137,-12683,-13241,-13811,-14393,-14987,-15593,-16211,-16841,-17483,-18137,-18803,-19481,-20171,-20873,-21587,-22313,-23051,-23801,-24563,-25337,-26123,-26921,-27731,-28553,-29387,-30233,-31091,-31961,-32843,-33737,-34643,-35561,-36491,-37433 mov $1,2 sub $1,$0 mul $1,$0 mul $1,6 add $1,7 mov $0,$1
; A128059: a(n) = numerator((2*n-1)^2/(2*(2*n)!)). ; 1,1,3,5,7,1,11,13,1,17,19,1,23,1,1,29,31,1,1,37,1,41,43,1,47,1,1,53,1,1,59,61,1,1,67,1,71,73,1,1,79,1,83,1,1,89,1,1,1,97,1,101,103,1,107,109,1,113,1,1,1,1,1,1,127,1,131,1,1,137,139,1,1,1,1,149,151,1,1,157,1,1,163,1,167,1,1,173,1,1,179,181,1,1,1,1,191,193,1,197,199,1,1,1,1,1,211,1,1,1,1,1,223,1,227,229,1,233,1,1,239,241,1,1,1,1,251,1,1,257,1,1,263,1,1,269,271,1,1,277,1,281,283,1,1,1,1,293,1,1,1,1,1,1,307,1,311,313,1,317,1,1,1,1,1,1,331,1,1,337,1,1,1,1,347,349,1,353,1,1,359,1,1,1,367,1,1,373,1,1,379,1,383,1,1,389,1,1,1,397,1,401,1,1,1,409,1,1,1,1,419,421,1,1,1,1,431,433,1,1,439,1,443,1,1,449,1,1,1,457,1,461,463,1,467,1,1,1,1,1,479,1,1,1,487,1,491,1,1,1 sub $0,1 mul $0,2 mov $1,$0 add $1,1 cal $0,10051 ; Characteristic function of primes: 1 if n is prime, else 0. mul $0,$1 mov $1,$0 div $1,2 mul $1,2 add $1,1
; A164304: a(n) = 4*a(n-1) - 2*a(n-2) for n > 1; a(0) = 3, a(1) = 14. ; 3,14,50,172,588,2008,6856,23408,79920,272864,931616,3180736,10859712,37077376,126590080,432205568,1475642112,5038157312,17201345024,58729065472,200513571840,684596156416,2337357481984,7980237615104,27246235496448,93024466755584,317605396029440,1084372650606592,3702279810367488,12640373940256768,43156936140292096,147346996680654848,503074114442035200,1717602464406831104,5864261628743254016,20021841586159353856,68358843087150907392,233391689176284921856,796849070530837872640,2720612903770781646848,9288753474021450842112,31713788088544240074752,108277645406134058614784,369683005447447754309632,1262176730977522900008960,4309340913015196091416576,14713010190105738565648384,50233358934392562079760384,171507415357358771187744768,585562943560649960591458304,1999236943527882299990343680,6825821886990229278778458112,23304813660905152515133145088,79567610869640151502975664128,271660816156750300981636366336,927508042887720900920594137088,3166710539237383001719103815680,10811826071174090205035226988544,36913883206221594816702700322816,126031880682538198856740347314176,430299756317709605793555988611072,1469135263905762025460743259815936,5015941542987628890255861062041600,17125495644138991510101957728534528,58470099490580708259896108790054912,199629406674044850019380519703150592,681577427715017983557729861232492544 mov $1,3 mov $2,4 lpb $0 sub $0,1 add $1,$2 add $2,$1 mul $1,2 lpe mov $0,$1
; A044535: Numbers n such that string 2,2 occurs in the base 7 representation of n but not of n+1. ; 16,65,118,163,212,261,310,359,408,461,506,555,604,653,702,751,832,849,898,947,996,1045,1094,1147,1192,1241,1290,1339,1388,1437,1490,1535,1584,1633,1682,1731,1780,1833,1878,1927,1976 mov $5,$0 mul $0,2 mov $4,$0 mul $0,2 add $4,2 add $4,$0 mov $0,8 mov $2,3 gcd $4,98 lpb $0 div $0,$2 mov $2,1 div $4,6 mul $4,2 lpe mov $1,$4 add $1,16 mov $3,$5 mul $3,49 add $1,$3 mov $0,$1
; A017469: a(n) = (11*n + 6)^9. ; 10077696,118587876497,10578455953408,208728361158759,1953125000000000,11694146092834141,51998697814228992,186940255267540403,572994802228616704,1551328215978515625,3802961274698203136,8594754748609397887,18151468971815029248,36197319879620191349,68719476736000000000,125015825667824393931,219100057666451666432,371548729913362368193,611887395134623186944,981626195189146484375,1538069472247945355776,2359038963725876372877,3548666015583712575488,5244424972726797792739,7625597484987000000000,10923375902587206152921,15432833226052183785472,21527007222246275614383,29673367320587092457984,40452954761505126953125,54582509182892025839616,72939918399605131977467,96593352556072838768128,126834469112674289266929,165216101262848000000000,213594869369817095335111,274179182859404002202112,349583128708644677014973,442886772228801716813824,557703426255917044921875,698254476132238257798656,869452379987698174267657,1076992496812124640903168,1327454428646007218077919,1628413597910449000000000,1988563816445385509004501,2417851639229258349412352,2927623333013089109425963,3530785328217308860798464,4241979061410760525390625,5077771155518005355216896,6056859925583430808179447,7200299239458675195396608,8531740805173554627849709,10077696000000000000000000,11867818400323486016065091,13935208216397060590792192,16316739881869361340823353,19053414094649936325115904,22190735653202768693359375,25779118480742139459918336,29874319279043849237528837,34537901303679358439784448,39837729803430596194366299,45848500718449031000000000,52652304284384091009260881,60339225243223168726597632,69007981415958243876303143,78766602447422609218630144,89733150589725287173828125,102036485447650480253566976,115817074667184805497011827,131227852606986122364722688,148435129092114474857571689,167619550409708032000000000,188977114767504926257175871,212720244498185556943964672,239078917355439245230081333,268301859311444098950365184,300657801330089569091796875,336436802655767455549666816,375951643223909047524204417,419539287866653663765987328,467562425055097089773569879,520411082988487293000000000,578504325910509333136234061,642292033603431572608909312,712256767082371132557493923,788915723584278031741505024,872822784019434590072265625,964570656127319474765561856,1064793116653594215471562607,1174167355940734115156474368,1293416428401445235986624869,1423311812421484544000000000,1564676083316831352942699451,1718385703049344916298327552,1885373930485085377246996913,2066633856060373299057393664,2263221564802416663240234375 mul $0,11 add $0,6 pow $0,9
; A053164: 4th root of largest 4th power dividing n. ; 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1 seq $0,57918 ; Number of pairs of numbers (a,b) each less than n where (a,b,n) is in geometric progression. seq $0,188 ; (1) Number of solutions to x^2 == 0 (mod n). (2) Also square root of largest square dividing n. (3) Also max_{ d divides n } gcd(d, n/d).
; A293810 o=1: The truncated kernel function of n: the product of distinct primes dividing n, but excluding the largest prime divisor of n. ; Coded manually 2021-02-25 by Antti Karttunen, https://github.com/karttu ; Essentially implementing A007947 without taking its largest prime divisor into the product ; Note that A293810(n) = A007947(n)/A006530(n). add $0,1 ; Add one, because A293810 is offset=1 sequence. mov $1,1 ; Initialize the result-register, eventually a product of dividing primes mov $2,2 ; Will contain candidates for successive numbers (primes) that will divide what's remaining of n, after all earlier divisors have been divided out. mov $3,$0 ; Make a copy of an argument, for later use as a loop counter (outer loop) mov $4,$3 ; also another copy (for the inner loop) lpb $3 mov $5,$4 ; Get a fresh copy of orig n for the the inner loop counter mov $6,0 ; will be valuation(n,$2) lpb $5 add $6,1 mov $7,$0 mod $7,$2 ; Does our prime candidate divide what is remaining of n? div $0,$2 ; Divide it really (the last iteration is discarded, so $0 is not corrupted as $0 = floor($0/$2) when $2 does not divide $0) cmp $7,0 ; now $7 = 1 if $2 really did divide, 0 if not. sub $5,$7 ; Thus we will fall out of this inner loop when all instances of $2 has been divided out of $0. lpe cmp $6,0 cmp $6,0 mov $7,$2 pow $7,$6 ; Now $7 = either $2^1 = $2 or $2^0 = 1 depending on whether $2 is a divisor or n. mul $1,$7 ; Update the product, with one instance of each prime-divisor add $2,1 ; Obtain the next divisor candidate of n mov $7,$0 ; Check whether $0 has reached one... cmp $7,1 cmp $7,0 sub $3,$7 ; then either decrement the loop counter by one, or fall out if $0 has reached one. lpe mov $0,$1
; A142168: Primes congruent to 16 mod 39. ; Submitted by Christian Krause ; 211,367,523,601,757,991,1069,1303,1381,1459,1693,2083,2161,2239,2473,2551,2707,3019,3253,3331,3643,3877,4111,4423,4657,4813,4969,5281,5437,5749,5827,6217,6373,6451,6529,6607,6763,6841,6997,7309,7621,7699,7933,8011,8089,8167,8713,9103,9181,9337,9649,9883,10039,10273,10429,10663,11131,11287,11443,11677,11833,12301,12379,12457,12613,13003,13159,13627,14173,14251,14407,14563,14797,15031,15187,15733,15889,16747,16903,16981,17137,17293,17449,17683,17761,17839,18229,18307,18541,19009,19087,19477,19867 mov $1,43 mov $2,$0 add $2,2 pow $2,2 lpb $2 sub $1,16 sub $2,1 mov $3,$1 mul $3,2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,55 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mov $0,$1 mul $0,2 sub $0,109
/* Copyright (c) 2017-2020, Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable Energy, LLC. See the top-level NOTICE for additional details. All rights reserved. SPDX-License-Identifier: BSD-3-Clause */ #include "InprocCore.h" #include "../NetworkCore_impl.hpp" #include "InprocComms.h" namespace helics { template class NetworkCore<inproc::InprocComms, interface_type::inproc>; } // namespace helics
; A261120: The number of distinct triple points in the set of function values FLSN(m/6/7^n), m in 0, 1, 2... 6*7^n, where FLSN:[0,1] is the "flowsnake" plane filling curve. ; Submitted by Jamie Morken(s1) ; 2,17,134,989,7082,50057,351854,2467349,17284562,121031297,847337174,5931714509,41523064442,290664639737,2034662044094,14242663006469,99698727138722,697891348251377,4885240212600614,34196683812727229,239376793662659402,1675637576559322217,11729463098677374734,82106241879027980789,574743693718054938482,4023205857720961788257,28162441009130464174454,197137087079164444191149,1379959609599904694247962,9659717267336593614465497,67618020871767937565447774,473326146103610909750702309 mov $2,3 pow $2,$0 mov $3,7 pow $3,$0 mul $3,2 sub $3,$2 mov $0,$3 div $0,2 mul $0,3 add $0,2
; Substitute for z80 cpir instruction ; aralbrec 02.2008 ; flag-perfect emulation of cpir SECTION code_crt0_sccz80 PUBLIC __z80asm__cpir .__z80asm__cpir jr nc, enterloop call enterloop ; scf clears N and H - must set carry the hard way push af ex (sp),hl set 0,l ; set carry jr retflags .loop inc hl .enterloop dec bc cp (hl) ; compare, set flags jr z, match inc c dec c jr nz, loop inc b djnz loop ; .nomatch cp (hl) ; compare, set flags inc hl push af .joinbc0 ex (sp),hl res 0,l ; clear carry res 2,l ; clear P/V -> BC == 0 jr retflags .match inc hl push af ld a,b or c jr z, joinbc0 ex (sp),hl res 0,l ; clear carry set 2,l ; set P/V -> BC != 0 .retflags ex (sp),hl pop af ret
%ifdef CONFIG { "RegData": { "RBX": "0x0003", "RCX": "0x0002", "RDX": "0x0001", "RSI": "0x0000", "R8": "0x0", "R9": "0x0", "R10": "0x1", "R11": "0x1" } } %endif mov rbx, 0x0001 mov rcx, 0x0001 mov rdx, 0x8000 mov rsi, 0x8000 stc rcl bx, 1 lahf mov r8w, ax shr r8, 8 and r8, 1 ; We only care about carry flag here clc rcl cx, 1 lahf mov r9w, ax shr r9, 8 and r9, 1 ; We only care about carry flag here stc rcl dx, 1 lahf mov r10w, ax shr r10, 8 and r10, 1 ; We only care about carry flag here clc rcl si, 1 lahf mov r11w, ax shr r11, 8 and r11, 1 ; We only care about carry flag here hlt
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %r8 push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x294b, %r14 nop and %rdx, %rdx mov $0x6162636465666768, %rdi movq %rdi, %xmm2 and $0xffffffffffffffc0, %r14 movaps %xmm2, (%r14) nop nop inc %r10 lea addresses_WC_ht+0x3ec1, %rsi lea addresses_UC_ht+0x1c2c1, %rdi add %r8, %r8 mov $35, %rcx rep movsq nop and %rcx, %rcx lea addresses_UC_ht+0x13ec1, %rsi lea addresses_A_ht+0x1d9fd, %rdi nop nop nop nop sub $49210, %r13 mov $16, %rcx rep movsw sub %rdi, %rdi lea addresses_normal_ht+0xb2c1, %r13 add %rdx, %rdx mov (%r13), %r14w nop nop nop cmp $21393, %rdx lea addresses_normal_ht+0xd480, %rsi lea addresses_UC_ht+0x112c1, %rdi clflush (%rdi) nop nop nop nop xor $34663, %r14 mov $71, %rcx rep movsb nop nop nop nop nop add %rdx, %rdx lea addresses_WC_ht+0x2529, %rsi lea addresses_D_ht+0xcdc1, %rdi nop nop nop inc %r13 mov $47, %rcx rep movsw nop nop nop nop and %rcx, %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r15 push %rbx push %rcx push %rsi // Store lea addresses_A+0x4c1, %rbx nop sub %rsi, %rsi mov $0x5152535455565758, %r13 movq %r13, (%rbx) nop nop add $16388, %r13 // Load lea addresses_A+0xd125, %r13 nop nop nop nop nop and $35227, %r12 mov (%r13), %ebx nop nop nop nop nop add $7786, %r13 // Faulty Load lea addresses_WT+0x76c1, %r12 nop nop nop nop dec %r10 movups (%r12), %xmm5 vpextrq $0, %xmm5, %r15 lea oracles, %r10 and $0xff, %r15 shlq $12, %r15 mov (%r10,%r15,1), %r15 pop %rsi pop %rcx pop %rbx pop %r15 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 2, 'size': 4, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': True, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': True}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 10, 'size': 2, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// // detail/kqueue_reactor.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) // Copyright (c) 2005 Stefan Arentz (stefan at soze dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_DETAIL_KQUEUE_REACTOR_HPP #define BOOST_ASIO_DETAIL_KQUEUE_REACTOR_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include <boost/asio/detail/config.hpp> #if defined(BOOST_ASIO_HAS_KQUEUE) #include <cstddef> #include <sys/types.h> #include <sys/event.h> #include <sys/time.h> #include <boost/asio/detail/limits.hpp> #include <boost/asio/detail/mutex.hpp> #include <boost/asio/detail/object_pool.hpp> #include <boost/asio/detail/op_queue.hpp> #include <boost/asio/detail/reactor_op.hpp> #include <boost/asio/detail/select_interrupter.hpp> #include <boost/asio/detail/socket_types.hpp> #include <boost/asio/detail/timer_queue_base.hpp> #include <boost/asio/detail/timer_queue_set.hpp> #include <boost/asio/detail/wait_op.hpp> #include <boost/asio/error.hpp> #include <boost/asio/execution_context.hpp> // Older versions of Mac OS X may not define EV_OOBAND. #if !defined(EV_OOBAND) # define EV_OOBAND EV_FLAG1 #endif // !defined(EV_OOBAND) #include <boost/asio/detail/push_options.hpp> namespace boost { namespace asio { namespace detail { class scheduler; class kqueue_reactor : public execution_context_service_base<kqueue_reactor> { private: // The mutex type used by this reactor. typedef conditionally_enabled_mutex mutex; public: enum op_types { read_op = 0, write_op = 1, connect_op = 1, except_op = 2, max_ops = 3 }; // Per-descriptor queues. struct descriptor_state { descriptor_state(bool locking) : mutex_(locking) {} friend class kqueue_reactor; friend class object_pool_access; descriptor_state* next_; descriptor_state* prev_; mutex mutex_; int descriptor_; int num_kevents_; // 1 == read only, 2 == read and write op_queue<reactor_op> op_queue_[max_ops]; bool shutdown_; }; // Per-descriptor data. typedef descriptor_state* per_descriptor_data; // Constructor. BOOST_ASIO_DECL kqueue_reactor(boost::asio::execution_context& ctx); // Destructor. BOOST_ASIO_DECL ~kqueue_reactor(); // Destroy all user-defined handler objects owned by the service. BOOST_ASIO_DECL void shutdown(); // Recreate internal descriptors following a fork. BOOST_ASIO_DECL void notify_fork( boost::asio::execution_context::fork_event fork_ev); // Initialise the task. BOOST_ASIO_DECL void init_task(); // Register a socket with the reactor. Returns 0 on success, system error // code on failure. BOOST_ASIO_DECL int register_descriptor(socket_type descriptor, per_descriptor_data& descriptor_data); // Register a descriptor with an associated single operation. Returns 0 on // success, system error code on failure. BOOST_ASIO_DECL int register_internal_descriptor( int op_type, socket_type descriptor, per_descriptor_data& descriptor_data, reactor_op* op); // Move descriptor registration from one descriptor_data object to another. BOOST_ASIO_DECL void move_descriptor(socket_type descriptor, per_descriptor_data& target_descriptor_data, per_descriptor_data& source_descriptor_data); // Post a reactor operation for immediate completion. void post_immediate_completion(reactor_op* op, bool is_continuation) { scheduler_.post_immediate_completion(op, is_continuation); } // Start a new operation. The reactor operation will be performed when the // given descriptor is flagged as ready, or an error has occurred. BOOST_ASIO_DECL void start_op(int op_type, socket_type descriptor, per_descriptor_data& descriptor_data, reactor_op* op, bool is_continuation, bool allow_speculative); // Cancel all operations associated with the given descriptor. The // handlers associated with the descriptor will be invoked with the // operation_aborted error. BOOST_ASIO_DECL void cancel_ops(socket_type descriptor, per_descriptor_data& descriptor_data); // Cancel any operations that are running against the descriptor and remove // its registration from the reactor. The reactor resources associated with // the descriptor must be released by calling cleanup_descriptor_data. BOOST_ASIO_DECL void deregister_descriptor(socket_type descriptor, per_descriptor_data& descriptor_data, bool closing); // Remove the descriptor's registration from the reactor. The reactor // resources associated with the descriptor must be released by calling // cleanup_descriptor_data. BOOST_ASIO_DECL void deregister_internal_descriptor( socket_type descriptor, per_descriptor_data& descriptor_data); // Perform any post-deregistration cleanup tasks associated with the // descriptor data. BOOST_ASIO_DECL void cleanup_descriptor_data( per_descriptor_data& descriptor_data); // Add a new timer queue to the reactor. template <typename Time_Traits> void add_timer_queue(timer_queue<Time_Traits>& queue); // Remove a timer queue from the reactor. template <typename Time_Traits> void remove_timer_queue(timer_queue<Time_Traits>& queue); // Schedule a new operation in the given timer queue to expire at the // specified absolute time. template <typename Time_Traits> void schedule_timer(timer_queue<Time_Traits>& queue, const typename Time_Traits::time_type& time, typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op); // Cancel the timer operations associated with the given token. Returns the // number of operations that have been posted or dispatched. template <typename Time_Traits> std::size_t cancel_timer(timer_queue<Time_Traits>& queue, typename timer_queue<Time_Traits>::per_timer_data& timer, std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)()); // Move the timer operations associated with the given timer. template <typename Time_Traits> void move_timer(timer_queue<Time_Traits>& queue, typename timer_queue<Time_Traits>::per_timer_data& target, typename timer_queue<Time_Traits>::per_timer_data& source); // Run the kqueue loop. BOOST_ASIO_DECL void run(long usec, op_queue<operation>& ops); // Interrupt the kqueue loop. BOOST_ASIO_DECL void interrupt(); private: // Create the kqueue file descriptor. Throws an exception if the descriptor // cannot be created. BOOST_ASIO_DECL static int do_kqueue_create(); // Allocate a new descriptor state object. BOOST_ASIO_DECL descriptor_state* allocate_descriptor_state(); // Free an existing descriptor state object. BOOST_ASIO_DECL void free_descriptor_state(descriptor_state* s); // Helper function to add a new timer queue. BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue); // Helper function to remove a timer queue. BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue); // Get the timeout value for the kevent call. BOOST_ASIO_DECL timespec* get_timeout(long usec, timespec& ts); // The scheduler used to post completions. scheduler& scheduler_; // Mutex to protect access to internal data. mutex mutex_; // The kqueue file descriptor. int kqueue_fd_; // The interrupter is used to break a blocking kevent call. select_interrupter interrupter_; // The timer queues. timer_queue_set timer_queues_; // Whether the service has been shut down. bool shutdown_; // Mutex to protect access to the registered descriptors. mutex registered_descriptors_mutex_; // Keep track of all registered descriptors. object_pool<descriptor_state> registered_descriptors_; }; } // namespace detail } // namespace asio } // namespace boost #include <boost/asio/detail/pop_options.hpp> #include <boost/asio/detail/impl/kqueue_reactor.hpp> #if defined(BOOST_ASIO_HEADER_ONLY) # include <boost/asio/detail/impl/kqueue_reactor.ipp> #endif // defined(BOOST_ASIO_HEADER_ONLY) #endif // defined(BOOST_ASIO_HAS_KQUEUE) #endif // BOOST_ASIO_DETAIL_KQUEUE_REACTOR_HPP
; fat12.asm ; FAT12 filesystem read only function %ifndef __FAT12_ASM_INCLUDED__ %define __FAT12_ASM_INCLUDED__ [BITS 16] %include "boot/bpb.asm" %include "boot/common.asm" ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ; ; Variables ; ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ KernelImageCluster DW 0x0000 datasector DW 0x0000 cluster DW 0x0000 filesize_h DW 0x0000 filesize_l DW 0x0000 physicalSector DB 0x00 physicalHead DB 0x00 physicalTrack DB 0x00 ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ; ; Define ; ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ BX_FAT_ADDR DW 0x0200 BX_RTDIR_ADDR DW 0x2600 ReadSectorFailMessage DB "FAIL to Read Sector", 0x00 ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ; ; Find Kernel File ; ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ Find_Kernel: PUSHA MOV BX, WORD [ES_BASE_SEG] MOV ES, BX MOV BX, WORD [BX_RTDIR_ADDR] MOV CX, WORD [BPB_RootEntCnt] MOV SI, KernelImageName Finding_File: MOV DI, BX PUSH CX MOV CX, 0x000B PUSH DI PUSH SI REPE CMPSB POP SI POP DI JCXZ Found_File ADD BX, 0x0020 POP CX ; 次のエントリへ LOOP Finding_File JMP FAILURE FAILURE: POPA MOV AX, -1 RET Found_File: POP CX MOV AX, WORD [ES:BX+0x001A] MOV WORD [KernelImageCluster], AX POPA MOV AX, 0 RET ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ; ; Load Kernel File ; ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ Load_Kernel: PUSHA MOV WORD [datasector], 0x0021 MOV BX, [KERNEL_RMODE_BASE_SEG] MOV ES, BX MOV BX, [KERNEL_RMODE_BASE_ADDR] PUSH BX MOV AX, WORD [KernelImageCluster] MOV WORD [cluster], AX Load_Image: MOV AX, WORD [cluster] POP BX CALL ClusterLBA CALL ReadSector PUSH BX MOV BX, ES ADD BX, 0x0020 MOV ES, BX ES_ADDED: ; 次のクラスタ番号取得 MOV AX, WORD [cluster] MOV CX, AX MOV DX, AX SHR DX, 0x0001 ADD CX, DX PUSH ES MOV BX, [ES_BASE_SEG] MOV ES, BX MOV BX, [BX_FAT_ADDR] ADD BX, CX MOV DX, WORD [ES:BX] POP ES TEST AX, 0x0001 JNZ ODD_CLUSTER EVEN_CLUSTER: AND DX, 0x0FFF JMP LOCAL_DONE ODD_CLUSTER: SHR DX, 0x0004 LOCAL_DONE: MOV WORD [cluster], DX CMP DX, 0x0FF0 JB Load_Image POP BX ALL_DONE: XOR BX, BX MOV WORD [ImageSizeBX], BX MOV BX, ES SUB BX, [KERNEL_RMODE_BASE_SEG] MOV WORD [ImageSizeES], BX POPA RET ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ; ; ReadSector ; Input ; ES:BX: 読み込んだセクタを格納するアドレス ; AX: 読み込みたい論理セクタ(LBA) ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ReadSector: MOV DI, 0x0005 ; エラーカウンタ5回まで再試行 SECTORLOOP: PUSH AX PUSH BX PUSH CX CALL LBA2CHS ; 論理セクタを物理セクタに変換 MOV AH, 0x02 ; セクタ読み込みモード MOV AL, 0x01 ; 1つのセクタだけ読み込み MOV CH, BYTE [physicalTrack] ; Track MOV CL, BYTE [physicalSector] ; Sector MOV DH, BYTE [physicalHead] ; Head MOV DL, BYTE [BS_DrvNum] ; Drive INT 0x13 ; BIOS処理呼び出し JNC ReadSectorSuccess ; MOV AH, 0x01 ; INT 0x13 XOR AX, AX INT 0x13 ; ヘッドを初期位置に戻す DEC DI POP CX POP BX POP AX JNZ SECTORLOOP ; Retry MOV SI, ReadSectorFailMessage CALL PrintLine INT 0x18 HLT ReadSectorSuccess: POP CX POP BX POP AX RET ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ; ; PROCEDURE Cluster LBA ; convert FAT cluster into LBA adressing scheme ; LBA = (cluster - 2) * sectors per cluster ; ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ClusterLBA: SUB AX, 0x0002 XOR CX, CX MOV CL, BYTE [BPB_SecPerClus] MUL CX ADD AX, WORD [datasector] RET ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ ; LBA2CHS ; input AX: sector number (LBA) ; output AX: quotient DX:Remainder ; convert logical address to physical address ; physical sector = (LBA MOD sectors per track) + 1 ; physical head = (LBA / sectors per track) MOD number of headds ; physical track = LBA / (sectors per track * number of heads) ;/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ LBA2CHS: XOR DX, DX ; initialize DX DIV WORD [BPB_SecPerTrk] ; calculate INC DL ; +1 MOV BYTE [physicalSector], DL XOR DX, DX ; initialize DX DIV WORD [BPB_NumHeads] ; calculate MOV BYTE [physicalHead], DL MOV BYTE [physicalTrack], AL RET %endif
#include "CaesarCrypt.h" #include <string.h> #include <malloc.h> const char* UCASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVXYZ"; const char* LCASE_LETTERS = "abcdefghijklmnopqrstuvxyz"; int numShifts = 0; int getIndex(const char* letters, const char ch) { for (int i = 0; i < strlen(letters); i++) { if (letters[i] == ch) return i; } return -1; } /* * Class: cipher_implementation_CaesarCipher * Method: setNumShifts * Signature: (I)V */ JNIEXPORT void JNICALL Java_cipher_implementation_CaesarCipher_setNumShifts (JNIEnv* env, jobject obj, jint num) { numShifts = num % strlen(UCASE_LETTERS); } /* * Class: cipher_implementation_CaesarCipher * Method: encrypt * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_cipher_implementation_CaesarCipher_encrypt (JNIEnv* env, jobject obj, jstring str) { const char* str1 = (*env).GetStringUTFChars(str, NULL); char* str2 = (char*) malloc(strlen(str1)+2); for (int i = 0; i < strlen(str1); i++) { int pos = getIndex(UCASE_LETTERS, str1[i]); if (pos != -1) { pos = (pos + numShifts) % strlen(UCASE_LETTERS); str2[i] = UCASE_LETTERS[pos]; } else { pos = getIndex(LCASE_LETTERS, str1[i]); if (pos != -1) { pos = (pos + numShifts) % strlen(LCASE_LETTERS); str2[i] = LCASE_LETTERS[pos]; } else { str2[i] = str1[i]; } } } // Set zero as "end of string" str2[strlen(str1)] = '\0'; jstring result = (*env).NewStringUTF(str2); free(str2); return result; } /* * Class: cipher_implementation_CaesarCipher * Method: decrypt * Signature: (Ljava/lang/String;)Ljava/lang/String; */ JNIEXPORT jstring JNICALL Java_cipher_implementation_CaesarCipher_decrypt (JNIEnv* env, jobject obj, jstring str) { const char* str1 = (*env).GetStringUTFChars(str, NULL); char* str2 = (char*)malloc(strlen(str1) + 2); for (int i = 0; i < strlen(str1); i++) { int pos = getIndex(UCASE_LETTERS, str1[i]); if (pos != -1) { pos -= numShifts; if (pos < 0) pos += strlen(UCASE_LETTERS); str2[i] = UCASE_LETTERS[pos]; } else { pos = getIndex(LCASE_LETTERS, str1[i]); if (pos != -1) { pos -= numShifts; if (pos < 0) pos += strlen(UCASE_LETTERS); str2[i] = LCASE_LETTERS[pos]; } else { str2[i] = str1[i]; } } } // Set zero as "end of string" str2[strlen(str1)] = '\0'; jstring result = (*env).NewStringUTF(str2); free(str2); return result; }
lc r4, 0x00008000 lc r5, 0x0000006d gtu r6, r4, r5 halt #@expected values #r4 = 0x00008000 #r5 = 0x0000006d #r6 = 0x00000001 #pc = -2147483628 #e0 = 0 #e1 = 0 #e2 = 0 #e3 = 0
SECTION "ROM Bank 05", ROMX[$4000], BANK[$05] db $FF, $02, $00, $00, $00, $AE, $42, $05 db $00, $00, $00, $AE, $42, $05, $FF, $02 db $00, $00, $00, $4E, $43, $05, $00, $00 db $00, $4E, $43, $05, $FF, $02, $9B, $4D db $03, $33, $4E, $03, $00, $00, $00, $2A db $4F, $03, $FF, $02, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $F9, $0A, $F9, $06, $F4, $FF, $AC, $00 db $24, $00, $44, $00, $64, $00, $28, $00 db $48, $00, $68, $00, $1C, $84, $84, $1C db $E0, $C0, $FE, $40, $60, $60, $40, $00 db $FD, $18, $10, $00, $01, $80, $FE, $18 db $02, $03, $00, $02, $01, $00, $18, $88 db $84, $70, $1C, $30, $05, $04, $03, $03 db $04, $05, $01, $03, $04, $04, $03, $01 db $02, $01, $03, $03, $01, $02, $80, $FF db $E0, $C0, $00, $20, $FD, $14, $3C, $80 db $00, $60, $FC, $14, $44, $00, $01, $20 db $FE, $10, $3C, $C0, $00, $78, $FE, $14 db $37, $80, $00, $40, $FE, $18, $3C, $17 db $72, $1E, $0F, $44, $FF, $0D, $5F, $22 db $0D, $72, $22, $0D, $0F, $20, $08, $0B db $2D, $0D, $FF, $47, $0D, $23, $48, $0D db $5C, $49, $28, $13, $20, $F6, $40, $13 db $60, $38, $41, $13, $90, $C6, $41, $06 db $5C, $42, $08, $00, $00, $26, $40, $02 db $0D, $32, $10, $D0, $0F, $26, $10, $03 db $C6, $44, $45, $19, $04, $0A, $19, $05 db $06, $19, $04, $10, $19, $05, $08, $19 db $04, $10, $0C, $0D, $FF, $47, $0D, $23 db $48, $05, $20, $06, $B7, $40, $0D, $BA db $22, $33, $06, $0D, $BA, $22, $33, $0A db $0F, $39, $60, $0B, $CA, $40, $26, $00 db $01, $03, $ED, $44, $45, $0D, $4B, $48 db $19, $00, $08, $19, $01, $08, $19, $02 db $08, $06, $10, $41, $0D, $5E, $21, $50 db $40, $01, $03, $03, $37, $45, $45, $00 db $03, $25, $45, $45, $19, $00, $08, $19 db $01, $08, $19, $02, $08, $06, $2C, $41 db $0D, $BA, $22, $33, $06, $0D, $BA, $22 db $33, $0A, $0B, $CA, $40, $0D, $67, $48 db $03, $6E, $45, $45, $26, $00, $01, $19 db $00, $08, $19, $01, $08, $19, $02, $08 db $06, $4F, $41, $03, $91, $45, $45, $0D db $32, $10, $F8, $01, $05, $09, $04, $24 db $23, $0D, $BA, $22, $33, $00, $05, $03 db $0A, $19, $04, $10, $09, $02, $19, $04 db $08, $19, $05, $08, $0A, $0D, $85, $48 db $0E, $04, $8B, $41, $8B, $41, $B1, $41 db $B1, $41, $16, $24, $17, $26, $80, $00 db $0D, $CA, $20, $57, $40, $03, $B9, $45 db $45, $19, $04, $10, $19, $00, $08, $01 db $01, $00, $08, $00, $00, $0D, $5E, $21 db $5A, $40, $03, $11, $46, $45, $01, $02 db $00, $26, $80, $00, $0D, $CA, $20, $5D db $40, $03, $4B, $46, $45, $19, $04, $10 db $19, $00, $08, $01, $01, $00, $0D, $B8 db $48, $0D, $BA, $22, $33, $0B, $0B, $CA db $40, $26, $00, $01, $28, $14, $40, $EC db $41, $0D, $E8, $48, $03, $4F, $47, $45 db $19, $00, $08, $19, $01, $08, $19, $02 db $08, $06, $E0, $41, $0D, $D6, $48, $03 db $0A, $47, $45, $19, $00, $08, $19, $01 db $08, $19, $02, $08, $06, $F3, $41, $18 db $29, $00, $03, $3A, $47, $45, $19, $05 db $20, $09, $04, $26, $80, $FF, $0D, $32 db $10, $40, $19, $02, $04, $0D, $32, $10 db $C0, $19, $05, $04, $0A, $03, $B7, $44 db $45, $19, $05, $08, $24, $5C, $0D, $1E db $49, $0D, $3E, $49, $0D, $51, $49, $19 db $04, $08, $19, $05, $08, $0D, $3E, $49 db $0D, $51, $49, $19, $04, $08, $19, $05 db $08, $0D, $3E, $49, $0D, $51, $49, $19 db $04, $20, $26, $00, $01, $06, $28, $41 db $0D, $5E, $21, $50, $40, $01, $03, $03 db $7F, $47, $45, $00, $0D, $5C, $49, $28 db $13, $50, $85, $42, $13, $A0, $73, $42 db $09, $03, $0D, $BA, $22, $33, $08, $0A db $06, $95, $42, $0D, $BA, $22, $33, $07 db $28, $14, $60, $8F, $42, $0D, $BA, $22 db $33, $07, $06, $8F, $42, $0D, $BA, $22 db $33, $06, $0D, $E6, $22, $33, $09, $0F db $39, $40, $06, $03, $41, $03, $B5, $47 db $45, $00, $0F, $41, $01, $1C, $F6, $7C db $04, $09, $06, $19, $06, $02, $19, $07 db $02, $0A, $0F, $41, $00, $00, $0D, $B9 db $42, $1C, $85, $47, $03, $0D, $67, $23 db $16, $21, $E4, $4C, $3E, $03, $CD, $CF db $05, $C9, $17, $FF, $0D, $0F, $61, $00 db $0D, $0F, $20, $08, $08, $00, $0F, $4C db $01, $04, $0E, $7A, $0C, $0D, $F9, $1F db $10, $5B, $0E, $0C, $F5, $42, $1D, $43 db $1D, $43, $1D, $43, $1D, $43, $1D, $43 db $89, $43, $AF, $43, $BA, $43, $72, $44 db $C3, $43, $38, $44, $16, $0D, $D1, $1F db $F6, $08, $03, $CD, $47, $45, $04, $52 db $6F, $0B, $0F, $46, $00, $26, $80, $FF db $0D, $32, $10, $E0, $0D, $CA, $20, $7E db $40, $19, $05, $04, $19, $04, $02, $0F db $47, $10, $05, $02, $16, $01, $0C, $0D db $D1, $1F, $08, $04, $0F, $60, $08, $0D db $03, $49, $03, $D6, $47, $45, $00, $24 db $22, $18, $03, $F0, $47, $45, $19, $0E db $02, $19, $0C, $02, $19, $0D, $02, $19 db $0C, $02, $19, $0E, $02, $19, $0C, $02 db $19, $0D, $02, $19, $0C, $02, $03, $83 db $43, $45, $0F, $47, $10, $0D, $0F, $20 db $0C, $0C, $BF, $0F, $4C, $00, $04, $83 db $77, $0B, $0F, $46, $00, $24, $11, $09 db $04, $19, $00, $02, $19, $01, $02, $19 db $02, $02, $19, $03, $02, $19, $04, $02 db $19, $05, $02, $19, $06, $02, $19, $07 db $02, $0A, $16, $01, $2A, $40, $C3, $5B db $25, $05, $44, $0D, $D1, $1F, $00, $04 db $0F, $4B, $00, $0F, $4A, $10, $0D, $D4 db $49, $03, $F6, $47, $45, $26, $00, $01 db $19, $09, $06, $19, $0A, $06, $26, $E0 db $00, $19, $0B, $06, $06, $9D, $43, $05 db $2E, $0D, $68, $49, $0D, $7F, $49, $06 db $90, $43, $0D, $FF, $47, $0D, $C2, $49 db $06, $90, $43, $28, $14, $20, $C9, $43 db $16, $13, $40, $D0, $43, $1F, $3E, $44 db $0F, $4B, $00, $0F, $4A, $10, $0D, $68 db $49, $0D, $7F, $49, $0D, $D4, $49, $03 db $F6, $47, $45, $28, $13, $40, $26, $44 db $13, $80, $14, $44, $13, $C0, $02, $44 db $26, $40, $01, $19, $09, $06, $19, $0A db $06, $26, $00, $01, $19, $0B, $04, $06 db $F0, $43, $26, $C0, $00, $19, $09, $08 db $19, $0A, $08, $26, $A0, $00, $19, $0B db $08, $06, $02, $44, $26, $E0, $00, $19 db $09, $06, $19, $0A, $06, $26, $C0, $00 db $19, $0B, $06, $06, $14, $44, $26, $00 db $01, $19, $09, $06, $19, $0A, $06, $26 db $E0, $00, $19, $0B, $06, $06, $26, $44 db $1F, $5C, $44, $06, $D0, $43, $21, $58 db $44, $1E, $27, $1A, $FE, $70, $38, $0B db $23, $FE, $A0, $38, $06, $23, $FE, $D0 db $38, $01, $23, $7E, $1E, $24, $12, $C9 db $20, $30, $38, $48, $CD, $47, $06, $E6 db $03, $21, $6E, $44, $85, $6F, $30, $01 db $24, $7E, $1E, $24, $12, $C9, $60, $80 db $A0, $C0, $0F, $60, $08, $0D, $68, $49 db $0D, $7F, $49, $08, $00, $FE, $2A, $20 db $26, $20, $01, $03, $AB, $44, $45, $19 db $0C, $20, $08, $00, $FE, $2A, $20, $26 db $20, $01, $05, $20, $08, $00, $FF, $2A db $10, $26, $80, $00, $05, $20, $08, $80 db $FF, $2A, $08, $26, $40, $00, $05, $20 db $06, $4E, $43, $CD, $D3, $1E, $CD, $A4 db $0D, $01, $0E, $40, $C3, $5B, $25, $01 db $00, $40, $CD, $3C, $23, $D0, $1E, $05 db $01, $9A, $42, $C3, $46, $08, $CD, $E6 db $1E, $CD, $A4, $0D, $01, $00, $40, $CD db $3C, $23, $38, $11, $2E, $26, $62, $35 db $C0, $62, $2E, $1F, $36, $45, $2C, $36 db $44, $2C, $36, $B7, $C9, $1E, $05, $01 db $9A, $42, $C3, $46, $08, $CD, $A4, $0D db $01, $00, $40, $CD, $3C, $23, $38, $25 db $1E, $04, $1A, $2E, $3F, $62, $BE, $C0 db $CD, $47, $06, $62, $2E, $39, $BE, $38 db $0C, $62, $2E, $1F, $36, $45, $2C, $36 db $45, $2C, $36, $25, $C9, $1E, $05, $01 db $1C, $41, $C3, $46, $08, $1E, $05, $01 db $9A, $42, $C3, $46, $08, $CD, $A4, $0D db $01, $00, $40, $CD, $3C, $23, $D0, $1E db $05, $01, $9A, $42, $C3, $46, $08, $01 db $00, $40, $CD, $3C, $23, $38, $27, $CD db $E6, $1E, $CD, $A4, $0D, $62, $2E, $0D db $2A, $B6, $28, $13, $3A, $47, $7E, $2E db $3B, $BE, $C0, $2C, $78, $BE, $C0, $1E db $05, $01, $28, $41, $C3, $46, $08, $1E db $45, $1A, $EE, $80, $12, $C9, $1E, $05 db $01, $9A, $42, $C3, $46, $08, $CD, $A4 db $0D, $01, $00, $40, $CD, $3C, $23, $38 db $10, $1E, $04, $1A, $2E, $3F, $62, $BE db $C0, $1E, $05, $01, $5B, $41, $C3, $46 db $08, $1E, $05, $01, $9A, $42, $C3, $46 db $08, $01, $00, $40, $CD, $3C, $23, $38 db $18, $CD, $E6, $1E, $CD, $A4, $0D, $62 db $2E, $0D, $2A, $B6, $C0, $62, $2E, $1F db $36, $45, $2C, $36, $44, $2C, $36, $B7 db $C9, $1E, $05, $01, $9A, $42, $C3, $46 db $08, $01, $00, $40, $CD, $3C, $23, $38 db $48, $CD, $D3, $1E, $CD, $A4, $0D, $01 db $38, $40, $CD, $CD, $24, $CB, $7F, $C8 db $1E, $22, $21, $99, $42, $3E, $1E, $CD db $CF, $05, $F0, $9A, $57, $1E, $27, $1A db $B7, $28, $0A, $AF, $12, $1E, $05, $01 db $8B, $41, $C3, $46, $08, $CD, $47, $06 db $FE, $40, $30, $0D, $3E, $02, $1E, $27 db $12, $1E, $05, $01, $B1, $41, $C3, $46 db $08, $1E, $05, $01, $A2, $41, $C3, $46 db $08, $1E, $05, $01, $9A, $42, $C3, $46 db $08, $CD, $E6, $1E, $CD, $A4, $0D, $01 db $00, $40, $CD, $3C, $23, $38, $24, $1E db $3B, $1A, $4F, $1C, $1A, $47, $1E, $45 db $1A, $07, $1E, $0D, $1A, $38, $0D, $91 db $1C, $1A, $98, $D8, $1E, $05, $01, $28 db $41, $C3, $46, $08, $91, $1C, $1A, $98 db $D0, $18, $F1, $1E, $05, $01, $9A, $42 db $C3, $46, $08, $01, $00, $40, $CD, $3C db $23, $38, $1C, $CD, $D3, $1E, $CD, $A4 db $0D, $62, $2E, $0F, $2A, $B6, $C0, $2E db $26, $36, $14, $62, $2E, $1F, $36, $45 db $2C, $36, $46, $2C, $36, $77, $C9, $1E db $05, $01, $9A, $42, $C3, $46, $08, $01 db $00, $40, $CD, $3C, $23, $38, $2A, $CD db $D3, $1E, $CD, $A4, $0D, $1E, $07, $1A db $21, $53, $DB, $96, $FE, $64, $30, $11 db $62, $2E, $26, $35, $C0, $62, $2E, $1F db $36, $45, $2C, $36, $46, $2C, $36, $B1 db $C9, $1E, $05, $01, $A2, $41, $C3, $46 db $08, $1E, $05, $01, $9A, $42, $C3, $46 db $08, $01, $00, $40, $CD, $3C, $23, $38 db $49, $CD, $D3, $1E, $CD, $A4, $0D, $01 db $38, $40, $CD, $CD, $24, $CB, $7F, $C8 db $1E, $22, $21, $99, $42, $3E, $1E, $CD db $CF, $05, $F0, $9A, $57, $1E, $27, $1A db $D6, $02, $28, $0B, $3E, $02, $12, $1E db $05, $01, $B1, $41, $C3, $46, $08, $CD db $47, $06, $FE, $40, $30, $0C, $AF, $1E db $27, $12, $1E, $05, $01, $8B, $41, $C3 db $46, $08, $1E, $05, $01, $A2, $41, $C3 db $46, $08, $1E, $05, $01, $9A, $42, $C3 db $46, $08, $CD, $A4, $0D, $01, $00, $40 db $CD, $3C, $23, $38, $1D, $2E, $3A, $62 db $1E, $45, $1A, $07, $1E, $04, $1A, $38 db $0D, $FE, $B4, $D0, $BE, $D8, $1E, $05 db $01, $FF, $41, $C3, $46, $08, $BE, $D0 db $18, $F4, $1E, $05, $01, $9A, $42, $C3 db $46, $08, $CD, $E6, $1E, $CD, $A4, $0D db $01, $00, $40, $CD, $3C, $23, $D0, $1E db $05, $01, $9A, $42, $C3, $46, $08, $CD db $A4, $0D, $01, $00, $40, $CD, $3C, $23 db $38, $1D, $2E, $3F, $62, $1E, $45, $1A db $07, $1E, $04, $1A, $38, $0D, $FE, $B4 db $D0, $BE, $D8, $1E, $05, $01, $50, $42 db $C3, $46, $08, $BE, $D0, $18, $F4, $1E db $05, $01, $9A, $42, $C3, $46, $08, $01 db $00, $40, $CD, $3C, $23, $38, $26, $CD db $E6, $1E, $CD, $A4, $0D, $62, $2E, $0D db $2A, $4F, $B6, $28, $11, $1E, $3B, $1A db $B9, $C0, $1C, $1A, $BE, $C0, $1E, $05 db $01, $EF, $41, $C3, $46, $08, $1E, $45 db $1A, $EE, $80, $12, $C9, $1E, $05, $01 db $9A, $42, $C3, $46, $08, $1E, $03, $0E db $00, $21, $04, $DD, $2A, $47, $0A, $FE db $FF, $C0, $1D, $20, $F7, $1E, $05, $01 db $EB, $40, $C3, $46, $08, $CD, $E6, $1E db $CD, $D3, $1E, $C3, $A4, $0D, $CD, $D3 db $1E, $CD, $A4, $0D, $01, $0E, $40, $CD db $5B, $25, $D8, $2E, $26, $62, $35, $C0 db $1E, $05, $01, $2F, $43, $C3, $46, $08 db $01, $0E, $40, $C3, $5B, $25, $CD, $A4 db $0D, $01, $1C, $40, $C3, $5B, $25, $CD db $47, $06, $21, $3C, $40, $FE, $80, $38 db $06, $3E, $C0, $23, $23, $18, $02, $3E db $40, $1E, $45, $12, $1E, $04, $FA, $51 db $DB, $86, $23, $12, $1C, $FA, $52, $DB db $8E, $12, $C9, $CD, $47, $06, $2E, $00 db $D6, $56, $38, $03, $2C, $18, $F9, $7D db $1E, $40, $12, $07, $21, $40, $40, $85 db $6F, $30, $01, $24, $1E, $07, $FA, $53 db $DB, $86, $12, $1C, $23, $FA, $54, $DB db $8E, $12, $C9, $CD, $47, $06, $E6, $03 db $21, $4C, $40, $B7, $28, $01, $23, $1E db $45, $1A, $07, $30, $02, $23, $23, $1E db $3F, $FA, $51, $DB, $86, $12, $C9, $CD db $47, $06, $E6, $01, $6F, $1E, $45, $1A db $E6, $80, $07, $07, $85, $21, $53, $40 db $85, $6F, $30, $01, $24, $1E, $3F, $FA db $51, $DB, $86, $12, $C9, $C5, $1E, $40 db $1A, $07, $4F, $CD, $47, $06, $E6, $07 db $47, $26, $A0, $2E, $07, $7E, $21, $53 db $DB, $96, $FE, $44, $38, $08, $78, $FE db $06, $30, $09, $0C, $18, $06, $78, $FE db $06, $38, $01, $0C, $21, $60, $40, $06 db $00, $09, $7E, $1E, $27, $12, $C1, $C9 db $26, $A0, $2E, $04, $7E, $21, $51, $DB db $96, $FE, $50, $1E, $45, $21, $3C, $40 db $38, $04, $3E, $40, $18, $04, $3E, $C0 db $23, $23, $12, $C3, $14, $48, $21, $66 db $40, $1E, $45, $1A, $07, $30, $01, $23 db $1E, $3A, $FA, $51, $DB, $86, $12, $C9 db $21, $68, $40, $1E, $45, $1A, $07, $30 db $02, $23, $23, $1E, $3F, $FA, $51, $DB db $86, $23, $12, $1E, $3A, $FA, $51, $DB db $86, $12, $C9, $1E, $5B, $1A, $3D, $07 db $5F, $07, $83, $21, $81, $40, $85, $6F db $30, $01, $24, $CD, $F9, $20, $CD, $BE db $20, $1E, $26, $7E, $12, $C9, $CD, $47 db $06, $E6, $01, $6F, $1E, $40, $1A, $07 db $5F, $07, $83, $5F, $7D, $07, $85, $83 db $21, $6C, $40, $85, $30, $01, $24, $1E db $3D, $12, $1C, $7C, $12, $C9, $1E, $3D db $1A, $6F, $1C, $1A, $67, $2A, $1E, $27 db $12, $1E, $3D, $7D, $12, $1C, $7C, $12 db $C9, $C5, $1E, $27, $1A, $1E, $33, $CD db $0F, $23, $C1, $C9, $AF, $21, $02, $DD db $77, $21, $04, $DD, $22, $22, $22, $C9 db $1E, $48, $1A, $67, $2E, $45, $7E, $2F db $3C, $5D, $12, $07, $21, $3C, $40, $D2 db $14, $48, $23, $23, $C3, $14, $48, $C5 db $1E, $48, $1A, $47, $0E, $40, $0A, $4F db $CD, $47, $06, $E6, $01, $5F, $21, $02 db $DD, $2A, $B7, $28, $20, $83, $3C, $FE db $03, $38, $02, $D6, $03, $B9, $28, $F6 db $BE, $28, $F3, $32, $34, $1E, $40, $12 db $07, $21, $46, $40, $85, $6F, $30, $01 db $24, $C1, $C3, $3C, $48, $7B, $B9, $38 db $EA, $3C, $FE, $03, $38, $E5, $D6, $03 db $18, $E1, $21, $02, $DD, $7E, $34, $21 db $46, $40, $07, $85, $6F, $D2, $3C, $48 db $24, $D2, $3C, $48, $21, $04, $DD, $7E db $B7, $28, $03, $23, $18, $F9, $72, $C9 db $C5, $1E, $03, $0E, $00, $21, $04, $DD db $2A, $FE, $A8, $38, $15, $47, $0A, $FE db $FF, $28, $0F, $C5, $E5, $D5, $60, $1E db $03, $01, $66, $49, $CD, $49, $08, $D1 db $E1, $C1, $1D, $20, $E3, $C1, $C9, $FF db $02, $C0, $4B, $05, $33, $4E, $03, $00 db $00, $00, $2A, $4F, $03, $FF, $02, $9B db $4D, $03, $33, $4E, $03, $00, $00, $00 db $2A, $4F, $03, $FF, $02, $00, $00, $00 db $33, $4E, $03, $00, $00, $00, $2A, $4F db $03, $20, $00, $40, $00, $20, $80, $01 db $00, $FF, $20, $80, $01, $30, $80, $01 db $90, $FF, $90, $FF, $FF, $02, $9B, $4D db $03, $33, $4E, $03, $00, $00, $00, $2A db $4F, $03, $14, $80, $02, $18, $00, $03 db $40, $00, $60, $00, $40, $00, $01, $80 db $00, $01, $00, $FF, $00, $FE, $70, $FF db $70, $FF, $06, $90, $00, $09, $90, $00 db $40, $00, $80, $00, $2F, $1F, $0C, $60 db $00, $10, $80, $00, $80, $FD, $00, $FD db $14, $80, $02, $18, $00, $03, $80, $00 db $C0, $00, $FF, $02, $9B, $4D, $03, $33 db $4E, $03, $00, $00, $00, $2A, $4F, $03 db $14, $80, $02, $18, $00, $03, $18, $00 db $02, $18, $00, $02, $80, $FE, $80, $FE db $18, $80, $02, $18, $80, $02, $C0, $FD db $E0, $FD, $00, $FE, $20, $00, $02, $20 db $00, $02, $20, $00, $02, $40, $00, $80 db $00, $C0, $00, $80, $00, $80, $00, $FE db $80, $00, $FE, $80, $00, $40, $01, $00 db $00, $FB, $00, $C0, $00, $40, $FF, $FD db $03, $00, $00, $C0, $FE, $00, $05, $40 db $FF, $40, $FF, $03, $03, $C0, $FE, $00 db $00, $05, $00, $40, $FF, $C0, $00, $03 db $FD, $00, $00, $40, $01, $00, $FB, $C0 db $00, $C0, $00, $FD, $FD, $80, $01, $00 db $00, $FA, $00, $C0, $00, $40, $FF, $FD db $03, $00, $00, $80, $FE, $00, $06, $40 db $FF, $40, $FF, $03, $03, $80, $FE, $00 db $00, $06, $00, $40, $FF, $C0, $00, $03 db $FD, $00, $00, $80, $01, $00, $FA, $C0 db $00, $C0, $00, $FD, $FD, $17, $FF, $0D db $27, $18, $0D, $80, $1F, $11, $5D, $4B db $0F, $60, $00, $0D, $7C, $20, $38, $4A db $0D, $5F, $20, $3A, $4A, $0D, $D3, $20 db $31, $4A, $10, $5B, $11, $56, $4B, $03 db $7E, $4C, $45, $01, $02, $00, $03, $31 db $4C, $45, $01, $00, $00, $10, $5B, $11 db $67, $4B, $01, $03, $06, $69, $4B, $01 db $01, $03, $CF, $4B, $45, $0D, $5F, $20 db $35, $4A, $00, $08, $00, $00, $2A, $00 db $27, $06, $38, $4B, $03, $7E, $4C, $45 db $18, $2A, $00, $05, $14, $0F, $60, $00 db $0F, $5B, $01, $27, $06, $38, $4B, $0D db $23, $4D, $0F, $60, $08, $0F, $61, $00 db $0F, $4C, $01, $0F, $4A, $10, $17, $FF db $0D, $04, $0E, $71, $0C, $03, $00, $4C db $45, $08, $80, $FD, $0D, $5F, $20, $3D db $4A, $27, $0D, $D3, $20, $40, $4A, $19 db $02, $04, $19, $03, $04, $06, $B7, $4B db $01, $04, $0D, $50, $0F, $1A, $A8, $B2 db $0D, $03, $20, $1B, $9B, $4D, $03, $CD db $EB, $21, $CD, $A4, $0D, $1E, $5B, $1A db $A7, $20, $20, $01, $07, $4A, $CD, $5B db $25, $D8, $CD, $85, $23, $CD, $75, $23 db $CD, $25, $1A, $CB, $6F, $C4, $F9, $1E db $CB, $7F, $C8, $1E, $05, $01, $73, $4B db $C3, $46, $08, $01, $15, $4A, $18, $DE db $CD, $EB, $21, $CD, $A4, $0D, $01, $23 db $4A, $CD, $5B, $25, $D8, $CD, $85, $23 db $CD, $75, $23, $CD, $25, $1A, $CB, $6F db $C2, $F9, $1E, $CB, $77, $20, $0B, $CB db $7F, $C8, $1E, $05, $01, $7C, $4B, $C3 db $46, $08, $1E, $0F, $AF, $12, $1C, $12 db $C9, $CD, $EB, $21, $CD, $A4, $0D, $01 db $07, $4A, $CD, $5B, $25, $D8, $CD, $85 db $23, $CD, $75, $23, $CD, $25, $1A, $62 db $CB, $6F, $20, $1A, $CB, $77, $20, $05 db $CB, $7F, $20, $15, $C9, $2E, $0F, $AF db $22, $77, $62, $2E, $1F, $36, $45, $2C db $36, $4B, $2C, $36, $CF, $C9, $C3, $F9 db $1E, $1E, $3D, $2E, $0F, $1A, $22, $1C db $1A, $77, $1E, $15, $1A, $A7, $28, $03 db $3D, $12, $C9, $3C, $12, $C9, $CD, $EB db $21, $CD, $A4, $0D, $01, $15, $4A, $CD db $5B, $25, $D8, $CD, $85, $23, $CD, $75 db $23, $CD, $25, $1A, $62, $CB, $6F, $20 db $1A, $CB, $77, $20, $05, $CB, $7F, $20 db $15, $C9, $2E, $0F, $AF, $22, $77, $62 db $2E, $1F, $36, $45, $2C, $36, $4B, $2C db $36, $CF, $C9, $C3, $F9, $1E, $1E, $3D db $2E, $0F, $1A, $22, $1C, $1A, $77, $1E db $15, $1A, $FE, $02, $28, $03, $3D, $12 db $C9, $3C, $12, $C9, $0A, $6F, $03, $0A db $67, $03, $1E, $5C, $1A, $5F, $87, $83 db $85, $30, $01, $24, $6F, $1E, $12, $2A db $12, $1E, $39, $2A, $12, $1C, $7E, $12 db $C9, $0A, $6F, $03, $0A, $67, $03, $1E db $27, $1A, $5F, $87, $83, $85, $30, $01 db $24, $6F, $1E, $12, $2A, $12, $1E, $39 db $2A, $12, $1C, $7E, $12, $C9, $0A, $6F db $03, $0A, $67, $03, $1E, $27, $1A, $87 db $85, $30, $01, $24, $6F, $1E, $0F, $2A db $12, $1E, $3D, $12, $7E, $1C, $12, $1E db $10, $12, $C9, $1E, $48, $1A, $67, $2E db $5C, $5D, $7E, $12, $1E, $4A, $3E, $10 db $12, $AF, $1C, $12, $C9, $21, $2C, $DD db $7E, $CB, $57, $C9, $17, $FF, $0D, $27 db $18, $0D, $3E, $50, $12, $C9, $4D, $0D db $80, $1F, $11, $BD, $4D, $0F, $3F, $02 db $27, $0D, $90, $20, $62, $4A, $0D, $CC db $4C, $5C, $4A, $0D, $D3, $20, $58, $4A db $03, $14, $4E, $45, $00, $03, $66, $4E db $45, $18, $29, $00, $2A, $00, $10, $5C db $11, $98, $4D, $19, $04, $06, $19, $06 db $06, $19, $05, $0C, $19, $06, $03, $19 db $05, $0C, $19, $06, $03, $19, $05, $18 db $19, $01, $06, $19, $00, $06, $19, $02 db $06, $19, $03, $06, $0F, $3F, $01, $00 db $19, $04, $08, $19, $06, $08, $19, $05 db $10, $19, $06, $04, $19, $05, $10, $19 db $06, $04, $19, $05, $20, $19, $01, $08 db $19, $00, $08, $19, $02, $08, $19, $03 db $08, $0F, $3F, $01, $00, $01, $04, $03 db $7C, $4E, $45, $0D, $CC, $4C, $52, $4A db $00, $27, $0D, $7C, $20, $66, $4A, $0D db $CC, $4C, $6A, $4A, $0D, $D3, $20, $70 db $4A, $0F, $40, $00, $03, $AB, $4E, $45 db $01, $01, $00, $08, $40, $01, $0F, $40 db $00, $0F, $3F, $08, $03, $19, $4F, $45 db $0D, $CC, $4C, $76, $4A, $19, $01, $10 db $19, $00, $10, $06, $F5, $4D, $27, $0D db $90, $20, $7C, $4A, $0D, $CC, $4C, $80 db $4A, $0D, $D3, $20, $86, $4A, $03, $FF db $4F, $45, $00, $16, $CD, $EB, $21, $CD db $A4, $0D, $01, $44, $4A, $CD, $5B, $25 db $D8, $CD, $50, $50, $CD, $25, $1A, $CB db $6F, $C4, $F9, $1E, $CB, $77, $20, $0C db $CB, $7F, $20, $0F, $1E, $F8, $CD, $C1 db $1A, $28, $23, $C9, $62, $2E, $0F, $AF db $22, $77, $C9, $62, $1E, $3D, $2E, $0F db $1A, $22, $1C, $1A, $77, $1E, $3F, $1A db $A7, $28, $03, $3D, $12, $C9, $1E, $05 db $01, $65, $4D, $C3, $46, $08, $1E, $05 db $01, $C9, $4D, $C3, $46, $08, $01, $44 db $4A, $CD, $5B, $25, $D8, $1E, $3F, $1A db $A7, $20, $01, $C9, $1E, $05, $01, $4D db $4D, $C3, $46, $08, $CD, $EB, $21, $CD db $A4, $0D, $01, $44, $4A, $CD, $5B, $25 db $D8, $1E, $F8, $CD, $C1, $1A, $28, $13 db $CD, $25, $1A, $CB, $6F, $C4, $F9, $1E db $CB, $7F, $C8, $1E, $05, $01, $4D, $4D db $C3, $46, $08, $1E, $05, $01, $C9, $4D db $C3, $46, $08, $CD, $EB, $21, $CD, $A4 db $0D, $01, $44, $4A, $CD, $5B, $25, $D8 db $1E, $5B, $1A, $A7, $20, $08, $06, $30 db $48, $CD, $14, $1F, $38, $40, $1E, $5C db $1A, $21, $74, $4A, $85, $30, $01, $24 db $6F, $1E, $40, $1A, $3C, $12, $BE, $CC db $F9, $4E, $CD, $61, $50, $CD, $B3, $1A db $20, $10, $CD, $25, $1A, $CB, $6F, $C4 db $F9, $1E, $CD, $25, $1A, $CB, $7F, $20 db $01, $C9, $AF, $1E, $0F, $12, $1C, $12 db $C9, $AF, $12, $62, $1E, $3D, $2E, $0F db $1A, $22, $1C, $1A, $77, $C9, $CD, $25 db $1A, $AF, $62, $2E, $0D, $22, $22, $22 db $77, $1E, $05, $01, $E6, $4D, $C3, $46 db $08, $1E, $3F, $1A, $3C, $12, $FE, $09 db $20, $47, $AF, $1E, $3F, $12, $1E, $40 db $1A, $CB, $87, $CB, $A7, $47, $CD, $C0 db $1E, $1E, $45, $1A, $CB, $7F, $28, $0A db $CB, $58, $20, $02, $CB, $C0, $CB, $D8 db $18, $08, $CB, $58, $28, $02, $CB, $C0 db $CB, $98, $CD, $1D, $20, $1E, $27, $1A db $A7, $28, $0A, $CB, $78, $20, $02, $CB db $E0, $CB, $F8, $18, $08, $CB, $78, $28 db $02, $CB, $E0, $CB, $B8, $1E, $40, $78 db $12, $1E, $40, $1A, $CB, $5F, $20, $14 db $62, $2E, $12, $5E, $CB, $47, $28, $02 db $1E, $00, $2E, $39, $4E, $2C, $46, $CD db $B4, $0C, $18, $12, $62, $2E, $12, $5E db $CB, $47, $28, $02, $1E, $00, $2E, $39 db $4E, $2C, $46, $CD, $E5, $0C, $1E, $40 db $1A, $CB, $7F, $28, $14, $62, $2E, $12 db $5E, $CB, $67, $28, $02, $1E, $00, $2E db $39, $4E, $2C, $46, $CD, $35, $0D, $18 db $12, $62, $2E, $12, $5E, $CB, $67, $28 db $02, $1E, $00, $2E, $39, $4E, $2C, $46 db $CD, $66, $0D, $CD, $A4, $0D, $01, $44 db $4A, $CD, $5B, $25, $D8, $CD, $25, $1A db $CB, $6F, $C4, $ED, $4F, $CB, $77, $C4 db $F6, $4F, $CB, $7F, $C4, $F6, $4F, $CD db $B3, $1A, $20, $01, $C9, $1E, $05, $01 db $FE, $4D, $C3, $46, $08, $47, $AF, $1E db $0D, $12, $1C, $12, $78, $C9, $47, $AF db $1E, $0F, $12, $1C, $12, $78, $C9, $CD db $EB, $21, $CD, $A4, $0D, $01, $44, $4A db $CD, $5B, $25, $D8, $CD, $72, $50, $CD db $62, $1A, $CB, $77, $20, $11, $CB, $7F db $20, $1C, $CB, $6F, $C4, $F9, $1E, $1E db $F8, $CD, $C1, $1A, $28, $08, $C9, $1E db $0F, $AF, $12, $1C, $12, $C9, $1E, $05 db $01, $E3, $4D, $C3, $46, $08, $1E, $05 db $01, $4D, $4D, $C3, $46, $08, $1E, $F8 db $C5, $CD, $C1, $1A, $C1, $28, $03, $AF db $18, $02, $3E, $01, $1E, $27, $12, $C9 db $1E, $10, $1A, $CB, $7F, $1E, $15, $20 db $04, $3E, $04, $12, $C9, $3E, $03, $12 db $C9, $1E, $10, $1A, $CB, $7F, $1E, $15 db $20, $04, $3E, $00, $12, $C9, $3E, $01 db $12, $C9, $1E, $10, $1A, $CB, $7F, $1E db $15, $20, $04, $3E, $03, $12, $C9, $3E db $02, $12, $C9, $17, $FF, $0D, $27, $18 db $0D, $3E, $50, $12, $18, $51, $0D, $80 db $1F, $11, $E9, $50, $18, $03, $96, $51 db $45, $01, $00, $10, $5C, $12, $A5, $50 db $05, $20, $06, $A7, $50, $05, $10, $0D db $0D, $53, $0E, $02, $C0, $50, $B3, $50 db $06, $94, $50, $05, $10, $0D, $25, $53 db $05, $10, $0D, $25, $53, $06, $94, $50 db $10, $5C, $12, $CB, $50, $19, $02, $08 db $06, $CE, $50, $19, $02, $04, $12, $D7 db $50, $19, $03, $10, $06, $DA, $50, $19 db $03, $08, $0D, $7C, $20, $A4, $4A, $0D db $CC, $4C, $A8, $4A, $03, $54, $51, $45 db $00, $01, $00, $03, $C1, $51, $45, $0D db $CC, $4C, $98, $4A, $00, $27, $03, $54 db $51, $45, $0D, $2C, $53, $0D, $06, $4D db $AE, $4A, $0D, $E9, $4C, $B4, $4A, $0D db $DC, $20, $BD, $4A, $00, $01, $02, $27 db $0D, $95, $53, $03, $F3, $51, $45, $00 db $03, $1D, $52, $45, $27, $18, $19, $02 db $08, $19, $03, $10, $01, $01, $0D, $D3 db $20, $C3, $4A, $0D, $3A, $21, $C7, $4A db $03, $28, $52, $45, $00, $27, $03, $F1 db $52, $45, $19, $02, $08, $19, $03, $10 db $01, $01, $0D, $9C, $53, $03, $72, $52 db $45, $00, $0D, $CC, $4C, $9E, $4A, $03 db $54, $51, $45, $00, $CD, $EB, $21, $CD db $A4, $0D, $01, $8A, $4A, $CD, $5B, $25 db $D8, $CD, $85, $23, $CD, $FC, $52, $CD db $62, $1A, $CB, $77, $20, $11, $CB, $7F db $20, $1C, $CB, $6F, $C2, $F9, $1E, $1E db $F8, $CD, $C1, $1A, $28, $08, $C9, $1E db $0F, $AF, $12, $1C, $12, $C9, $1E, $05 db $01, $0D, $51, $C3, $46, $08, $1E, $05 db $01, $94, $50, $C3, $46, $08, $01, $8A db $4A, $CD, $5B, $25, $D8, $CD, $85, $23 db $06, $38, $0E, $30, $CD, $14, $1F, $38 db $08, $CD, $64, $19, $CB, $7F, $28, $09 db $C9, $1E, $05, $01, $F5, $50, $C3, $46 db $08, $1E, $05, $01, $E9, $50, $C3, $46 db $08, $CD, $EB, $21, $CD, $A4, $0D, $01 db $8A, $4A, $CD, $5B, $25, $D8, $CD, $85 db $23, $1E, $F8, $CD, $C1, $1A, $28, $13 db $CD, $25, $1A, $CB, $6F, $C2, $F9, $1E db $CB, $7F, $C8, $1E, $05, $01, $94, $50 db $C3, $46, $08, $1E, $05, $01, $0D, $51 db $C3, $46, $08, $CD, $91, $0C, $CD, $A4 db $0D, $01, $8A, $4A, $CD, $5B, $25, $D8 db $CD, $85, $23, $CD, $25, $1A, $CB, $6F db $C2, $F9, $1E, $CB, $7F, $20, $06, $1E db $10, $1A, $CB, $7F, $C8, $1E, $05, $01 db $18, $51, $C3, $46, $08, $01, $8A, $4A db $CD, $5B, $25, $D8, $CD, $85, $23, $C9 db $CD, $80, $0C, $CD, $A4, $0D, $01, $8A db $4A, $CD, $5B, $25, $D8, $CD, $85, $23 db $CD, $62, $1A, $CB, $6F, $20, $2A, $CB db $7F, $20, $26, $CB, $77, $20, $22, $1E db $0D, $1A, $A7, $C0, $1C, $1A, $A7, $C0 db $06, $38, $0E, $30, $CD, $14, $1F, $38 db $08, $1E, $05, $01, $18, $51, $C3, $46 db $08, $1E, $05, $01, $35, $51, $C3, $46 db $08, $1E, $11, $1A, $2F, $3C, $12, $C3 db $F9, $1E, $1E, $11, $1A, $CD, $83, $0C db $1E, $12, $1A, $CD, $94, $0C, $CD, $A4 db $0D, $01, $8A, $4A, $CD, $5B, $25, $D8 db $CD, $85, $23, $CD, $B3, $1A, $20, $4E db $CD, $62, $1A, $F5, $CB, $6F, $C4, $C9 db $52, $F1, $CB, $7F, $20, $35, $1E, $0D db $1A, $A7, $C0, $1C, $1A, $A7, $C0, $1E db $0F, $1A, $A7, $C0, $1C, $1A, $A7, $C0 db $06, $38, $0E, $30, $CD, $14, $1F, $38 db $08, $1E, $05, $01, $18, $51, $C3, $46 db $08, $1E, $05, $01, $35, $51, $C3, $46 db $08, $1E, $11, $1A, $2F, $3C, $12, $CD db $F9, $1E, $C9, $1E, $0F, $AF, $12, $1C db $12, $1E, $12, $12, $18, $C0, $1E, $0F db $1A, $D6, $80, $12, $1C, $1A, $DE, $01 db $12, $1E, $05, $01, $4A, $51, $C3, $46 db $08, $01, $8A, $4A, $CD, $5B, $25, $D8 db $CD, $85, $23, $C9, $1E, $10, $1A, $CB db $7F, $1E, $15, $20, $04, $3E, $02, $12 db $C9, $3E, $01, $12, $C9, $CD, $47, $06 db $1E, $27, $FE, $40, $38, $08, $FE, $80 db $38, $07, $3E, $02, $12, $C9, $AF, $12 db $C9, $3E, $01, $12, $C9, $1E, $45, $1A db $EE, $80, $12, $C9, $C5, $D5, $1E, $04 db $6B, $26, $A0, $1A, $4F, $1C, $1A, $47 db $5E, $2C, $56, $79, $93, $78, $9A, $38 db $0C, $79, $93, $FE, $10, $38, $12, $FE db $24, $38, $1B, $18, $26, $7B, $91, $FE db $10, $38, $06, $FE, $24, $38, $0F, $18 db $1A, $CD, $47, $06, $FE, $A0, $38, $2E db $FE, $E0, $38, $22, $18, $18, $CD, $47 db $06, $FE, $40, $38, $21, $FE, $C0, $38 db $15, $18, $0B, $CD, $47, $06, $FE, $40 db $38, $14, $FE, $A0, $38, $08, $D1, $3E db $02, $1E, $27, $12, $C1, $C9, $D1, $3E db $01, $1E, $27, $12, $C1, $C9, $D1, $AF db $1E, $27, $12, $C1, $C9, $1E, $12, $1A db $2F, $3C, $12, $C9, $C5, $CD, $A2, $53 db $C1, $C9, $26, $A0, $1E, $0B, $6B, $1A db $96, $CB, $7F, $21, $84, $FF, $36, $00 db $28, $04, $36, $01, $2F, $3C, $4F, $26 db $A0, $1E, $09, $6B, $1A, $96, $CB, $7F db $21, $84, $FF, $28, $04, $CB, $CE, $2F db $3C, $47, $69, $AF, $CB, $25, $17, $CB db $25, $17, $67, $0E, $00, $A7, $7D, $90 db $6F, $30, $06, $7C, $D6, $01, $38, $09 db $67, $0C, $79, $D6, $0C, $20, $EE, $18 db $27, $79, $D6, $02, $30, $0B, $21, $84 db $FF, $CB, $4E, $28, $26, $3E, $00, $18 db $30, $21, $84, $FF, $CB, $4E, $28, $08 db $CB, $46, $20, $23, $3E, $01, $18, $21 db $CB, $46, $20, $13, $3E, $03, $18, $19 db $21, $84, $FF, $CB, $46, $20, $0C, $3E db $02, $18, $0E, $3E, $04, $18, $0A, $3E db $05, $18, $06, $3E, $06, $18, $02, $3E db $07, $87, $5F, $87, $83, $47, $1E, $5C db $1A, $A7, $78, $28, $02, $C6, $30, $21 db $CD, $4A, $85, $30, $01, $24, $6F, $1E db $0D, $2A, $12, $1C, $2A, $12, $1C, $2A db $12, $1C, $2A, $12, $1C, $2A, $12, $1C db $7E, $12, $C9, $FF, $02, $9B, $4D, $03 db $33, $4E, $03, $00, $00, $00, $2A, $4F db $03, $14, $80, $02, $18, $00, $03, $40 db $00, $60, $00, $20, $00, $30, $00, $80 db $FE, $F0, $FD, $08, $80, $01, $0B, $10 db $02, $40, $00, $60, $00, $40, $FE, $00 db $FE, $08, $C0, $01, $0B, $00, $02, $40 db $00, $80, $00, $20, $00, $30, $00, $30 db $00, $48, $00, $FF, $02, $00, $00, $00 db $33, $4E, $03, $00, $00, $00, $2A, $4F db $03, $30, $00, $40, $00, $30, $00, $FF db $40, $00, $FF, $FF, $02, $4D, $5E, $05 db $5C, $5E, $05, $00, $00, $00, $2A, $4F db $03, $FF, $02, $9B, $4D, $03, $33, $4E db $03, $00, $00, $00, $2A, $4F, $03, $20 db $00, $40, $00, $00, $FF, $80, $FE, $20 db $80, $01, $30, $80, $01, $30, $00, $40 db $00, $80, $FE, $00, $FE, $18, $80, $01 db $20, $00, $02, $C0, $40, $00, $B0, $50 db $00, $04, $80, $00, $04, $80, $00, $40 db $00, $40, $00, $18, $80, $01, $20, $00 db $02, $18, $80, $01, $18, $80, $01, $FF db $02, $00, $00, $00, $18, $61, $05, $00 db $00, $00, $2A, $4F, $03, $40, $01, $C0 db $01, $C0, $FE, $40, $FE, $00, $01, $00 db $02, $00, $FF, $00, $FE, $F0, $00, $01 db $E0, $00, $02, $10, $00, $FF, $20, $00 db $FE, $08, $80, $00, $0C, $C0, $00, $FF db $02, $8C, $64, $05, $33, $4E, $03, $00 db $00, $00, $2A, $4F, $03, $FF, $02, $9B db $4D, $03, $33, $4E, $03, $00, $00, $00 db $2A, $4F, $03, $80, $FD, $80, $FD, $10 db $00, $02, $10, $00, $02, $00, $01, $00 db $01, $60, $00, $A0, $00, $03, $05, $40 db $00, $60, $00, $02, $03, $80, $FE, $00 db $FE, $10, $80, $01, $10, $80, $01, $00 db $FF, $00, $FF, $10, $80, $01, $10, $80 db $01, $80, $00, $80, $00, $10, $80, $01 db $10, $80, $01, $FF, $02, $9B, $4D, $03 db $33, $4E, $03, $00, $00, $00, $2A, $4F db $03, $FF, $0C, $9B, $4D, $03, $89, $68 db $05, $00, $00, $00, $2A, $4F, $03, $FF db $0C, $9B, $4D, $03, $69, $68, $05, $00 db $00, $00, $2A, $4F, $03, $40, $00, $40 db $00, $C0, $FF, $C0, $FF, $FE, $40, $00 db $FE, $40, $00, $02, $C0, $FF, $02, $C0 db $FF, $10, $C0, $00, $10, $00, $01, $10 db $20, $FF, $02, $9B, $4D, $03, $33, $4E db $03, $00, $00, $00, $2A, $4F, $03, $40 db $00, $40, $00, $30, $00, $30, $00, $10 db $00, $02, $10, $00, $02, $FF, $02, $9B db $4D, $03, $33, $4E, $03, $00, $00, $00 db $2A, $4F, $03, $F8, $09, $F8, $08, $10 db $00, $02, $10, $40, $02, $10, $00, $02 db $10, $00, $02, $40, $00, $60, $00, $00 db $FE, $00, $FE, $10, $80, $02, $10, $80 db $02, $50, $00, $70, $00, $80, $FD, $80 db $FD, $00, $FF, $00, $FF, $FF, $02, $9B db $4D, $03, $33, $4E, $03, $00, $00, $00 db $2A, $4F, $03, $FF, $02, $9B, $4D, $03 db $33, $4E, $03, $00, $00, $00, $2A, $4F db $03, $F8, $15, $F8, $08, $F5, $07, $F8 db $08, $10, $00, $02, $10, $00, $02, $40 db $00, $60, $00, $30, $00, $40, $00, $00 db $01, $00, $01, $00, $FF, $00, $FF, $20 db $80, $01, $20, $80, $01, $80, $00, $80 db $00, $40, $FF, $40, $FF, $20, $80, $01 db $20, $80, $01, $80, $FF, $80, $FF, $08 db $80, $01, $08, $80, $01, $80, $FE, $80 db $FE, $0C, $80, $01, $0C, $80, $01, $FF db $02, $9B, $4D, $03, $33, $4E, $03, $00 db $00, $00, $2A, $4F, $03, $FF, $02, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $FF, $02, $00, $00, $00 db $01, $7A, $05, $00, $00, $00, $00, $00 db $00, $10, $80, $01, $10, $00, $02, $30 db $00, $50, $00, $20, $00, $38, $00, $50 db $00, $70, $00, $38, $00, $50, $00, $80 db $00, $C0, $00, $50, $00, $A0, $00, $C0 db $00, $00, $01, $80, $00, $C0, $00, $C0 db $FF, $C0, $FF, $D0, $FF, $D0, $FF, $C0 db $FF, $C0, $FF, $D0, $FF, $D0, $FF, $00 db $FF, $00, $FF, $40, $40, $00, $FE, $80 db $FD, $00, $FE, $80, $FD, $00, $03, $80 db $03, $E8, $E4, $00, $01, $20, $01, $10 db $00, $02, $14, $80, $02, $00, $FE, $80 db $FD, $C0, $00, $E0, $00, $10, $00, $02 db $14, $80, $02, $00, $FF, $C0, $FE, $C0 db $01, $00, $02, $E4, $E0, $00, $01, $00 db $01, $00, $03, $80, $03, $E8, $E4, $00 db $03, $80, $03, $A0, $90, $80, $02, $C0 db $02, $D8, $D4, $D4, $C0, $02, $D4, $C0 db $02, $C0, $02, $C0, $02, $C0, $01, $00 db $02, $E4, $E0, $D4, $C0, $02, $D4, $C0 db $02, $C0, $02, $C0, $02, $1C, $80, $03 db $1E, $C0, $03, $80, $FC, $40, $FC, $80 db $03, $C0, $03, $17, $FF, $0D, $27, $18 db $0D, $3E, $50, $12, $FB, $57, $0D, $80 db $1F, $11, $9F, $57, $10, $5B, $12, $84 db $57, $0F, $40, $60, $03, $E7, $58, $45 db $27, $0D, $D3, $20, $67, $54, $19, $02 db $10, $0D, $D3, $20, $6B, $54, $19, $03 db $10, $06, $70, $57, $0F, $40, $20, $03 db $33, $59, $45, $27, $0D, $D3, $20, $67 db $54, $19, $02, $10, $0D, $D3, $20, $6B db $54, $19, $03, $10, $06, $8B, $57, $01 db $00, $03, $7F, $59, $45, $0D, $CC, $4C db $61, $54, $00, $27, $19, $01, $08, $03 db $B7, $59, $45, $0D, $90, $20, $6F, $54 db $0D, $5F, $20, $73, $54, $0D, $D3, $20 db $79, $54, $01, $00, $00, $27, $18, $19 db $01, $08, $03, $F3, $59, $45, $0D, $90 db $20, $7D, $54, $0D, $5F, $20, $81, $54 db $0D, $D3, $20, $87, $54, $01, $00, $00 db $18, $29, $00, $2A, $00, $0D, $81, $5B db $12, $AB, $57, $19, $01, $08, $06, $64 db $57, $2A, $F0, $07, $00, $00, $03, $27 db $5A, $45, $00, $07, $00, $00, $10, $5B db $12, $23, $58, $03, $5D, $5A, $45, $08 db $40, $FF, $2A, $0C, $19, $00, $10, $19 db $01, $04, $08, $00, $00, $2A, $00, $05 db $06, $10, $5C, $12, $07, $58, $05, $06 db $06, $07, $58, $03, $5D, $5A, $45, $08 db $00, $FF, $2A, $08, $19, $00, $20, $19 db $01, $08, $08, $00, $00, $2A, $00, $05 db $18, $06, $27, $58, $03, $98, $5A, $45 db $10, $5B, $12, $4D, $58, $0D, $D3, $20 db $8B, $54, $06, $52, $58, $0D, $D3, $20 db $8F, $54, $08, $00, $00, $2A, $08, $19 db $01, $04, $12, $63, $58, $19, $03, $0C db $06, $66, $58, $19, $03, $1C, $01, $00 db $03, $BB, $5A, $45, $0D, $39, $5B, $0E db $04, $79, $58, $88, $58, $97, $58, $A6 db $58, $10, $5B, $12, $83, $58, $05, $18 db $06, $B5, $58, $05, $10, $06, $B5, $58 db $10, $5B, $12, $92, $58, $05, $20, $06 db $B5, $58, $05, $18, $06, $B5, $58, $10 db $5B, $12, $A1, $58, $05, $28, $06, $B5 db $58, $05, $20, $06, $B5, $58, $10, $5B db $12, $B0, $58, $05, $30, $06, $B5, $58 db $05, $28, $06, $B5, $58, $03, $D8, $5A db $45, $2A, $F8, $10, $5B, $12, $C5, $58 db $05, $1C, $06, $FB, $57, $05, $3C, $06 db $FB, $57, $03, $07, $5B, $45, $18, $29 db $00, $2A, $00, $19, $01, $08, $01, $00 db $10, $5C, $12, $E3, $58, $05, $08, $08 db $C0, $FD, $00, $08, $80, $FD, $00, $CD db $A4, $0D, $01, $53, $54, $CD, $5B, $25 db $D8, $1E, $40, $1A, $3D, $A7, $12, $20 db $0A, $3E, $60, $12, $06, $10, $CD, $11 db $5B, $30, $28, $CD, $F3, $19, $CB, $6F db $C2, $F9, $1E, $CB, $7F, $28, $14, $CB db $67, $20, $18, $1E, $F8, $CD, $C1, $1A db $28, $01, $C9, $1E, $05, $01, $F1, $57 db $C3, $46, $08, $1E, $05, $01, $9F, $57 db $C3, $46, $08, $1E, $05, $01, $AB, $57 db $C3, $46, $08, $CD, $A4, $0D, $01, $53 db $54, $CD, $5B, $25, $D8, $1E, $40, $1A db $3D, $A7, $12, $20, $0A, $3E, $20, $12 db $06, $30, $CD, $4C, $5B, $38, $28, $CD db $F3, $19, $CB, $6F, $C2, $F9, $1E, $CB db $7F, $28, $14, $CB, $67, $20, $18, $1E db $F8, $CD, $C1, $1A, $28, $01, $C9, $1E db $05, $01, $F1, $57, $C3, $46, $08, $1E db $05, $01, $9F, $57, $C3, $46, $08, $1E db $05, $01, $AB, $57, $C3, $46, $08, $62 db $2E, $12, $5E, $2E, $39, $4E, $2C, $46 db $CD, $35, $0D, $CD, $A4, $0D, $01, $53 db $54, $CD, $5B, $25, $D8, $1E, $F8, $CD db $C1, $1A, $28, $13, $CD, $25, $1A, $CB db $6F, $C2, $F9, $1E, $CB, $7F, $C8, $1E db $05, $01, $64, $57, $C3, $46, $08, $1E db $05, $01, $F1, $57, $C3, $46, $08, $CD db $EB, $21, $CD, $A4, $0D, $01, $53, $54 db $CD, $5B, $25, $D8, $CD, $25, $1A, $CB db $77, $20, $11, $CB, $7F, $20, $1C, $CB db $6F, $C4, $F9, $1E, $1E, $F8, $CD, $C1 db $1A, $28, $08, $C9, $1E, $0F, $AF, $12 db $1C, $12, $C9, $1E, $05, $01, $F1, $57 db $C3, $46, $08, $1E, $05, $01, $E0, $57 db $C3, $46, $08, $CD, $EB, $21, $CD, $A4 db $0D, $01, $53, $54, $CD, $5B, $25, $D8 db $CD, $25, $1A, $CB, $77, $20, $11, $CB db $7F, $20, $14, $CB, $6F, $C2, $F9, $1E db $1E, $F8, $CD, $C1, $1A, $28, $08, $C9 db $1E, $0F, $AF, $12, $1C, $12, $C9, $1E db $05, $01, $CA, $58, $C3, $46, $08, $1E db $12, $1A, $CD, $94, $0C, $CD, $A4, $0D db $01, $53, $54, $CD, $5B, $25, $D8, $1E db $F8, $CD, $C1, $1A, $20, $17, $CD, $25 db $1A, $CB, $7F, $20, $08, $62, $2E, $0F db $2A, $B6, $28, $01, $C9, $1E, $05, $01 db $FB, $57, $C3, $46, $08, $1E, $05, $01 db $AB, $57, $C3, $46, $08, $1E, $12, $1A db $CD, $94, $0C, $CD, $A4, $0D, $01, $53 db $54, $CD, $5B, $25, $D8, $1E, $00, $CD db $C1, $1A, $20, $0E, $CD, $25, $1A, $CB db $77, $C8, $1E, $05, $01, $3C, $58, $C3 db $46, $08, $1E, $5B, $1A, $A7, $20, $08 db $1E, $05, $01, $AB, $57, $C3, $46, $08 db $1E, $05, $01, $C5, $57, $C3, $46, $08 db $1E, $12, $1A, $CD, $94, $0C, $CD, $A4 db $0D, $01, $53, $54, $CD, $5B, $25, $D8 db $CD, $25, $1A, $CB, $6F, $C2, $F9, $1E db $CB, $7F, $C8, $1E, $05, $01, $FB, $57 db $C3, $46, $08, $CD, $A4, $0D, $01, $53 db $54, $CD, $5B, $25, $D8, $CD, $25, $1A db $CB, $6F, $C2, $F9, $1E, $CB, $7F, $C8 db $1E, $05, $01, $FB, $57, $C3, $46, $08 db $1E, $12, $1A, $CD, $94, $0C, $CD, $A4 db $0D, $01, $53, $54, $CD, $5B, $25, $D8 db $CD, $25, $1A, $CB, $77, $20, $10, $CB db $6F, $C2, $F9, $1E, $CB, $7F, $C8, $1E db $05, $01, $FB, $57, $C3, $46, $08, $1E db $05, $01, $3C, $58, $C3, $46, $08, $CD db $A4, $0D, $01, $53, $54, $CD, $5B, $25 db $C9, $D5, $C5, $1E, $07, $6B, $26, $A0 db $1A, $4F, $1C, $1A, $47, $5E, $2C, $56 db $79, $93, $78, $9A, $38, $10, $79, $93 db $4F, $78, $BA, $28, $04, $3E, $FF, $81 db $4F, $79, $C1, $D1, $B8, $C9, $C1, $D1 db $C9, $D5, $C5, $CD, $47, $06, $C1, $5F db $AF, $CB, $13, $17, $CB, $13, $17, $D1 db $1E, $27, $12, $C9, $D5, $C5, $1E, $04 db $6B, $26, $A0, $1A, $4F, $1C, $1A, $47 db $5E, $2C, $56, $79, $93, $78, $9A, $38 db $10, $79, $93, $4F, $78, $BA, $28, $04 db $3E, $FF, $81, $4F, $79, $C1, $D1, $B8 db $C9, $7B, $91, $5F, $78, $BA, $28, $04 db $3E, $FF, $83, $5F, $7B, $C1, $D1, $B8 db $C9, $CD, $35, $22, $1E, $27, $12, $C9 db $17, $FF, $0D, $27, $18, $0D, $3E, $50 db $12, $14, $5C, $0F, $60, $08, $01, $FF db $03, $36, $5C, $45, $00, $27, $03, $44 db $5C, $45, $09, $03, $19, $00, $02, $19 db $FF, $02, $0A, $10, $5C, $12, $BC, $5B db $19, $00, $02, $19, $FF, $02, $19, $00 db $02, $19, $FF, $02, $03, $45, $5C, $45 db $0F, $40, $00, $0D, $1D, $20, $11, $CF db $5B, $08, $18, $00, $06, $D2, $5B, $08 db $E8, $FF, $0D, $D3, $20, $A1, $54, $0D db $1B, $5D, $27, $19, $00, $10, $10, $5C db $12, $E9, $5B, $05, $08, $27, $06, $EA db $5B, $27, $19, $01, $10, $12, $DA, $5B db $05, $08, $06, $DA, $5B, $03, $78, $5C db $45, $27, $0D, $BB, $5C, $A5, $54, $19 db $01, $18, $10, $5C, $12, $09, $5C, $05 db $08, $19, $00, $18, $12, $F9, $5B, $05 db $08, $06, $F9, $5B, $16, $03, $97, $5C db $45, $27, $18, $19, $00, $02, $19, $03 db $02, $19, $00, $02, $19, $02, $02, $19 db $01, $02, $19, $04, $02, $19, $01, $02 db $19, $05, $02, $06, $1B, $5C, $06, $48 db $CD, $4C, $5B, $D0, $1E, $05, $01, $9D db $5B, $C3, $46, $08, $C9, $CD, $2C, $5D db $CD, $80, $0C, $CD, $A4, $0D, $01, $93 db $54, $CD, $5B, $25, $D8, $CD, $75, $23 db $CD, $0D, $1F, $28, $08, $1E, $05, $01 db $15, $5C, $C3, $46, $08, $CD, $25, $1A db $CB, $7F, $C2, $4A, $5D, $1E, $08, $CD db $C1, $1A, $CA, $4A, $5D, $C3, $5F, $5D db $CD, $80, $0C, $CD, $91, $0C, $CD, $A4 db $0D, $01, $93, $54, $CD, $5B, $25, $D8 db $CD, $75, $23, $CD, $0D, $1F, $C8, $1E db $05, $01, $15, $5C, $C3, $46, $08, $01 db $93, $54, $CD, $5B, $25, $D8, $CD, $75 db $23, $CD, $0D, $1F, $C0, $1E, $5B, $1A db $A7, $28, $08, $1E, $05, $01, $F5, $5B db $C3, $46, $08, $1E, $05, $01, $BC, $5B db $C3, $46, $08, $0A, $6F, $03, $0A, $67 db $03, $1E, $5C, $1A, $5F, $87, $83, $85 db $6F, $30, $01, $24, $D5, $C5, $E5, $CD db $2B, $20, $E1, $E5, $1E, $0F, $30, $0B db $2A, $12, $1C, $2A, $12, $1E, $12, $7E db $12, $18, $11, $2A, $2F, $C6, $01, $12 db $1C, $2A, $2F, $CE, $00, $12, $1E, $12 db $7E, $2F, $3C, $12, $CD, $3D, $20, $1E db $0D, $E1, $30, $0B, $2A, $12, $1C, $2A db $12, $1E, $11, $7E, $12, $18, $11, $2A db $2F, $C6, $01, $12, $1C, $2A, $2F, $CE db $00, $12, $1E, $11, $7E, $2F, $3C, $12 db $C1, $D1, $C9, $1E, $0E, $1A, $1E, $11 db $CB, $7F, $20, $04, $3E, $FF, $12, $C9 db $3E, $01, $12, $C9, $1E, $5C, $1A, $1E db $40, $A7, $20, $0B, $1A, $3C, $FE, $60 db $12, $C0, $AF, $12, $C3, $1B, $5D, $1A db $3C, $FE, $80, $12, $C0, $AF, $12, $C3 db $1B, $5D, $1E, $0F, $1A, $2F, $C6, $01 db $12, $1C, $1A, $2F, $CE, $00, $12, $C9 db $1E, $11, $1A, $2F, $3C, $12, $C9, $1E db $5B, $1A, $A7, $C8, $06, $28, $CD, $4C db $5B, $30, $08, $1E, $05, $01, $F5, $5B db $C3, $46, $08, $06, $38, $CD, $4C, $5B db $D0, $1E, $5C, $1A, $A7, $20, $08, $CD db $47, $06, $FE, $80, $D0, $18, $E4, $CD db $47, $06, $FE, $C0, $D0, $18, $DC, $17 db $FF, $0D, $27, $18, $0D, $3E, $50, $12 db $14, $5C, $0D, $80, $1F, $11, $C8, $5D db $27, $03, $B0, $5E, $45, $0F, $40, $00 db $0D, $90, $20, $CB, $54, $0D, $5F, $20 db $CF, $54, $0D, $D3, $20, $C7, $54, $01 db $03, $24, $0D, $00, $03, $95, $5E, $45 db $18, $01, $02, $05, $10, $06, $A1, $5D db $01, $03, $0F, $40, $00, $03, $0F, $60 db $45, $0D, $CC, $4C, $61, $54, $00, $03 db $52, $60, $45, $08, $80, $FE, $2A, $18 db $05, $20, $06, $5C, $5E, $17, $FF, $0D db $03, $E1, $5F, $45, $04, $E1, $72, $0D db $27, $0F, $60, $08, $0F, $61, $00, $0F db $5E, $08, $0F, $5F, $08, $0F, $4C, $01 db $0F, $4A, $15, $18, $0D, $5F, $60, $29 db $00, $0D, $5F, $20, $F9, $54, $08, $80 db $FE, $0F, $3F, $00, $00, $27, $0D, $F9 db $1E, $0F, $60, $00, $18, $03, $12, $5F db $45, $0F, $3E, $00, $0F, $3F, $00, $0F db $40, $00, $0D, $90, $20, $D9, $54, $0D db $5F, $20, $DD, $54, $0D, $D3, $20, $D5 db $54, $01, $01, $05, $20, $0D, $5F, $20 db $E3, $54, $24, $0D, $19, $00, $04, $19 db $01, $04, $06, $44, $5E, $24, $60, $0D db $50, $0F, $38, $A8, $B2, $0D, $03, $20 db $1B, $9B, $4D, $03, $01, $FF, $24, $60 db $0D, $50, $0F, $38, $A8, $B2, $0D, $03 db $20, $05, $01, $0F, $1F, $80, $1B, $33 db $4E, $03, $03, $7A, $5F, $45, $0D, $5F db $20, $E9, $54, $0D, $D3, $20, $EF, $54 db $09, $06, $19, $00, $04, $19, $01, $04 db $0A, $03, $A8, $5F, $45, $0D, $5F, $20 db $F3, $54, $01, $00, $00, $01, $AB, $54 db $CD, $5B, $25, $D8, $CD, $80, $60, $CD db $75, $23, $CD, $CB, $19, $CB, $7F, $C0 db $1E, $05, $01, $C8, $5D, $C3, $46, $08 db $1E, $40, $1A, $3C, $12, $62, $2E, $12 db $5E, $2E, $39, $4E, $2C, $46, $CD, $35 db $0D, $CD, $A4, $0D, $CD, $25, $1A, $1E db $44, $12, $01, $AB, $54, $CD, $5B, $25 db $D8, $CD, $80, $60, $CD, $75, $23, $1E db $44, $1A, $CB, $77, $20, $0A, $CB, $7F db $20, $0D, $CB, $6F, $C4, $F9, $1E, $C9 db $1E, $0F, $AF, $12, $1C, $12, $C9, $1E db $5C, $1A, $A7, $1E, $40, $1A, $20, $06 db $FE, $21, $30, $0E, $18, $04, $FE, $1B db $30, $08, $1E, $05, $01, $BC, $5D, $C3 db $46, $08, $1E, $05, $01, $5C, $5E, $C3 db $46, $08, $CD, $EB, $21, $CD, $A4, $0D db $01, $B9, $54, $CD, $5B, $25, $D8, $CD db $70, $60, $28, $3B, $CD, $85, $23, $CD db $75, $23, $CD, $25, $1A, $CB, $77, $20 db $15, $CB, $7F, $20, $18, $CB, $6F, $20 db $01, $C9, $1E, $3F, $3E, $01, $12, $1E db $0D, $AF, $12, $1C, $12, $C9, $1E, $0F db $AF, $12, $1C, $12, $C9, $1E, $3F, $1A db $A7, $28, $04, $1D, $3E, $01, $12, $1E db $05, $01, $15, $5E, $C3, $46, $08, $1E db $15, $AF, $12, $1E, $3F, $1A, $A7, $28 db $BB, $AF, $12, $1D, $1A, $A7, $28, $B4 db $AF, $12, $1E, $05, $01, $72, $5E, $C3 db $46, $08, $CD, $F7, $21, $CD, $A4, $0D db $01, $B9, $54, $CD, $5B, $25, $D8, $CD db $85, $23, $CD, $75, $23, $CD, $25, $1A db $CB, $77, $20, $05, $CB, $7F, $20, $08 db $C9, $1E, $0F, $AF, $12, $1C, $12, $C9 db $1E, $05, $01, $15, $5E, $C3, $46, $08 db $CD, $EB, $21, $CD, $A4, $0D, $01, $B9 db $54, $CD, $5B, $25, $D8, $CD, $85, $23 db $CD, $75, $23, $CD, $25, $1A, $CB, $77 db $20, $09, $CB, $7F, $20, $0C, $CB, $6F db $20, $10, $C9, $1E, $0F, $AF, $12, $1C db $12, $C9, $1E, $05, $01, $15, $5E, $C3 db $46, $08, $1E, $0D, $AF, $12, $1C, $12 db $C9, $1E, $10, $1A, $CB, $7F, $1E, $15 db $20, $04, $3E, $00, $18, $02, $3E, $01 db $12, $CD, $EB, $21, $CD, $A4, $0D, $01 db $B9, $54, $CD, $5B, $25, $D8, $CD, $75 db $23, $CD, $25, $1A, $CB, $7F, $C8, $1E db $05, $01, $15, $5E, $C3, $46, $08, $1E db $40, $1A, $3C, $12, $62, $2E, $12, $5E db $2E, $39, $4E, $2C, $46, $CD, $35, $0D db $CD, $A4, $0D, $01, $AB, $54, $CD, $5B db $25, $D8, $CD, $80, $60, $CD, $75, $23 db $CD, $25, $1A, $CB, $6F, $C2, $F9, $1E db $CB, $7F, $C8, $1E, $40, $1A, $FE, $10 db $30, $08, $1E, $05, $01, $A1, $5D, $C3 db $46, $08, $1E, $05, $01, $D7, $5D, $C3 db $46, $08, $CD, $91, $0C, $CD, $A4, $0D db $01, $AB, $54, $CD, $5B, $25, $C9, $1E db $48, $1A, $67, $2E, $5C, $5D, $7E, $12 db $C9, $21, $2C, $DD, $7E, $CB, $4F, $C9 db $1E, $0F, $1A, $A7, $C0, $1C, $1A, $A7 db $C9, $1E, $45, $1A, $2F, $3C, $12, $C9 db $CD, $97, $1A, $C0, $1E, $05, $01, $5C db $5E, $CD, $46, $08, $E1, $C9, $17, $FF db $0D, $27, $0F, $60, $08, $0D, $5A, $63 db $12, $E0, $60, $03, $E5, $61, $45, $0D db $1D, $20, $12, $AF, $60, $0D, $90, $20 db $11, $55, $01, $00, $06, $B6, $60, $0D db $90, $20, $0D, $55, $01, $01, $00, $03 db $1A, $62, $45, $0D, $91, $63, $12, $D0 db $60, $10, $5C, $12, $CB, $60, $2A, $14 db $06, $DF, $60, $2A, $1C, $06, $DF, $60 db $10, $5C, $12, $DA, $60, $2A, $EC, $06 db $DF, $60, $2A, $E4, $06, $DF, $60, $00 db $0D, $1D, $20, $1A, $40, $0F, $3E, $00 db $18, $03, $48, $62, $45, $10, $40, $12 db $01, $61, $01, $01, $0D, $90, $20, $15 db $55, $0D, $68, $20, $1D, $55, $06, $0D db $61, $01, $00, $0D, $90, $20, $19, $55 db $0D, $68, $20, $23, $55, $05, $10, $27 db $05, $10, $0D, $A8, $63, $06, $0D, $61 db $0F, $5E, $0C, $0F, $5F, $0C, $1B, $4E db $43, $05, $03, $6C, $62, $45, $18, $27 db $0D, $37, $20, $12, $36, $61, $07, $00 db $01, $29, $F8, $06, $3B, $61, $07, $00 db $FF, $29, $08, $09, $02, $19, $01, $01 db $19, $05, $02, $19, $01, $01, $19, $04 db $02, $0A, $09, $02, $19, $03, $01, $19 db $09, $02, $19, $03, $01, $19, $08, $02 db $0A, $19, $02, $01, $19, $06, $02, $19 db $02, $01, $19, $07, $02, $19, $02, $01 db $19, $06, $01, $18, $19, $06, $01, $19 db $02, $01, $19, $07, $02, $10, $5C, $19 db $02, $0B, $12, $7F, $61, $05, $05, $19 db $03, $03, $12, $87, $61, $05, $01, $19 db $02, $0A, $12, $8F, $61, $05, $02, $0F db $3E, $00, $0F, $40, $00, $0F, $3F, $0B db $27, $03, $7D, $62, $45, $0D, $68, $20 db $29, $55, $19, $02, $07, $19, $03, $05 db $06, $A2, $61, $18, $06, $8F, $61, $03 db $DE, $61, $45, $29, $00, $2A, $00, $18 db $10, $5C, $09, $04, $19, $02, $01, $19 db $06, $02, $19, $02, $01, $19, $07, $02 db $0A, $12, $18, $61, $09, $02, $19, $02 db $01, $19, $06, $02, $19, $02, $01, $19 db $07, $02, $0A, $06, $18, $61, $01, $FF db $54, $CD, $5B, $25, $C9, $CD, $A4, $0D db $01, $FF, $54, $CD, $5B, $25, $D8, $CD db $0D, $1F, $20, $1E, $CD, $75, $23, $CD db $2B, $20, $30, $08, $1E, $10, $1A, $CB db $7F, $20, $07, $C9, $1E, $10, $1A, $CB db $7F, $C0, $1E, $05, $01, $B7, $60, $C3 db $46, $08, $1E, $05, $01, $22, $61, $C3 db $46, $08, $CD, $91, $0C, $CD, $A4, $0D db $01, $FF, $54, $CD, $5B, $25, $D8, $CD db $0D, $1F, $20, $14, $CD, $75, $23, $1E db $0F, $1A, $A7, $C0, $1C, $1A, $A7, $C0 db $1E, $05, $01, $E5, $60, $C3, $46, $08 db $1E, $05, $01, $22, $61, $C3, $46, $08 db $CD, $91, $0C, $CD, $A4, $0D, $01, $FF db $54, $CD, $5B, $25, $D8, $CD, $75, $23 db $CD, $0D, $1F, $C8, $1E, $05, $01, $22 db $61, $C3, $46, $08, $1E, $05, $01, $AB db $61, $C3, $46, $08, $CD, $80, $0C, $CD db $A4, $0D, $01, $FF, $54, $CD, $5B, $25 db $D8, $CD, $75, $23, $C9, $1E, $3F, $1A db $3C, $12, $FE, $0C, $20, $4B, $AF, $1E db $3F, $12, $1D, $1A, $3C, $12, $1E, $40 db $1A, $CB, $87, $CB, $A7, $47, $CD, $C0 db $1E, $1E, $45, $1A, $CB, $7F, $28, $0A db $CB, $58, $20, $02, $CB, $C0, $CB, $D8 db $18, $08, $CB, $58, $28, $02, $CB, $C0 db $CB, $98, $CD, $1D, $20, $1E, $27, $1A db $A7, $28, $0A, $CB, $78, $20, $02, $CB db $E0, $CB, $F8, $18, $08, $CB, $78, $28 db $02, $CB, $E0, $CB, $B8, $1E, $40, $78 db $12, $1E, $40, $1A, $CB, $5F, $20, $14 db $62, $2E, $12, $5E, $CB, $47, $28, $02 db $1E, $00, $2E, $39, $4E, $2C, $46, $CD db $B4, $0C, $18, $12, $62, $2E, $12, $5E db $CB, $47, $28, $02, $1E, $00, $2E, $39 db $4E, $2C, $46, $CD, $E5, $0C, $1E, $40 db $1A, $CB, $7F, $28, $14, $62, $2E, $12 db $5E, $CB, $67, $28, $02, $1E, $00, $2E db $39, $4E, $2C, $46, $CD, $35, $0D, $18 db $12, $62, $2E, $12, $5E, $CB, $67, $28 db $02, $1E, $00, $2E, $39, $4E, $2C, $46 db $CD, $66, $0D, $CD, $A4, $0D, $01, $FF db $54, $CD, $5B, $25, $D8, $CD, $75, $23 db $1E, $3E, $1A, $FE, $0C, $28, $13, $1E db $10, $1A, $E6, $80, $47, $1E, $12, $1A db $E6, $80, $A8, $C0, $1E, $15, $3E, $02 db $12, $C9, $1E, $05, $01, $AF, $61, $C3 db $46, $08, $C5, $21, $53, $DB, $1E, $07 db $2A, $D6, $08, $4F, $7E, $DE, $00, $47 db $1A, $91, $1C, $1A, $98, $38, $14, $21 db $53, $DB, $1E, $07, $2A, $C6, $88, $4F db $7E, $CE, $00, $47, $1A, $91, $1C, $1A db $98, $38, $07, $1E, $27, $3E, $00, $12 db $C1, $C9, $1E, $27, $3E, $01, $12, $C1 db $C9, $1E, $10, $1A, $CB, $7F, $1E, $27 db $20, $07, $3E, $01, $12, $1E, $40, $12 db $C9, $3E, $00, $12, $1E, $40, $12, $C9 db $1E, $12, $1A, $2F, $3C, $12, $1E, $15 db $1A, $A7, $28, $04, $3E, $00, $12, $C9 db $3E, $01, $12, $C9, $17, $FF, $0D, $27 db $0F, $47, $80, $0D, $F1, $64, $0F, $60 db $88, $0D, $FF, $64, $0F, $47, $80, $03 db $96, $64, $45, $01, $00, $00, $0F, $60 db $08, $0F, $47, $80, $03, $C8, $64, $45 db $08, $C0, $FE, $2A, $0A, $01, $02, $05 db $20, $18, $0F, $60, $00, $2A, $00, $09 db $08, $19, $00, $04, $19, $01, $04, $0A db $19, $00, $20, $0D, $6E, $66, $80, $12 db $0E, $64, $09, $08, $19, $00, $04, $19 db $01, $04, $0A, $19, $00, $20, $2A, $0A db $19, $02, $20, $18, $2A, $00, $01, $00 db $0D, $6E, $66, $80, $12, $21, $64, $05 db $20, $0F, $47, $80, $0F, $60, $00, $06 db $C6, $63, $0F, $60, $08, $0F, $47, $80 db $03, $C8, $64, $45, $08, $E0, $FE, $2A db $09, $01, $02, $05, $2C, $18, $2A, $00 db $0F, $60, $00, $09, $03, $19, $00, $04 db $19, $01, $04, $0A, $19, $00, $08, $2A db $09, $19, $02, $0C, $18, $2A, $00, $03 db $D8, $64, $45, $27, $0F, $60, $00, $0D db $90, $20, $4B, $55, $0D, $5F, $20, $4F db $55, $0D, $D3, $20, $55, $55, $0F, $27 db $00, $19, $00, $02, $19, $01, $02, $0F db $47, $00, $19, $00, $02, $19, $01, $02 db $11, $7A, $64, $19, $02, $04, $19, $03 db $04, $06, $83, $64, $01, $03, $27, $0F db $47, $00, $1B, $9B, $4D, $03, $01, $2F db $55, $CD, $5B, $25, $D8, $CD, $C0, $1E db $06, $30, $CD, $4C, $5B, $D0, $1E, $5B db $1A, $A7, $20, $0E, $1E, $05, $01, $D6 db $63, $CD, $46, $08, $1E, $47, $3E, $80 db $12, $C9, $1E, $05, $01, $2A, $64, $CD db $46, $08, $1E, $47, $3E, $80, $12, $C9 db $CD, $C0, $1E, $CD, $91, $0C, $CD, $A4 db $0D, $01, $2F, $55, $CD, $5B, $25, $C9 db $CD, $EB, $21, $CD, $A4, $0D, $01, $2F db $55, $CD, $5B, $25, $D8, $1E, $10, $1A db $CB, $7F, $C0, $1E, $27, $3E, $01, $12 db $C9, $1E, $41, $62, $2E, $06, $2A, $12 db $1C, $2A, $12, $1C, $7E, $12, $C9, $2E db $41, $62, $1E, $06, $2A, $12, $1C, $2A db $12, $1C, $7E, $12, $C9, $17, $FF, $0D db $27, $18, $0D, $80, $1F, $11, $90, $65 db $0F, $3F, $00, $03, $A2, $65, $45, $09 db $04, $0D, $D3, $20, $59, $55, $0D, $15 db $21, $5D, $55, $19, $02, $04, $19, $01 db $0C, $19, $00, $08, $19, $02, $04, $19 db $03, $04, $18, $29, $00, $05, $08, $0A db $0D, $6E, $66, $40, $11, $18, $65, $03 db $43, $66, $45, $0D, $90, $20, $65, $55 db $0D, $5F, $20, $69, $55, $07, $00, $00 db $00, $03, $43, $66, $45, $0D, $90, $20 db $6F, $55, $0D, $5F, $20, $73, $55, $0D db $D3, $20, $79, $55, $00, $03, $0E, $66 db $45, $0D, $D3, $20, $5F, $55, $0D, $15 db $21, $63, $55, $19, $02, $04, $19, $01 db $0C, $19, $00, $08, $19, $02, $04, $19 db $03, $04, $18, $05, $08, $06, $71, $65 db $0F, $5E, $08, $0F, $5F, $08, $01, $00 db $03, $43, $66, $45, $0D, $5F, $20, $7D db $55, $00, $CD, $80, $0C, $CD, $A4, $0D db $01, $3D, $55, $CD, $5B, $25, $D8, $CD db $85, $23, $CD, $75, $23, $CD, $35, $22 db $A7, $28, $0D, $CD, $82, $66, $20, $3D db $1E, $05, $01, $6D, $65, $C3, $46, $08 db $CD, $F3, $19, $CB, $6F, $20, $2E, $CB db $7F, $28, $33, $1E, $3F, $1A, $A7, $C0 db $CD, $F3, $19, $CB, $67, $C8, $CD, $82 db $66, $20, $1A, $CD, $2B, $20, $30, $15 db $CD, $47, $06, $FE, $40, $38, $06, $1E db $3F, $3E, $01, $12, $C9, $1E, $05, $01 db $59, $65, $C3, $46, $08, $1E, $11, $1A db $2F, $3C, $12, $C3, $F9, $1E, $1E, $05 db $01, $90, $65, $C3, $46, $08, $CD, $80 db $0C, $CD, $A4, $0D, $01, $3D, $55, $CD db $5B, $25, $D8, $CD, $85, $23, $CD, $75 db $23, $CD, $35, $22, $A7, $20, $08, $1E db $05, $01, $18, $65, $C3, $46, $08, $CD db $F3, $19, $CB, $6F, $20, $01, $C9, $1E db $11, $1A, $2F, $3C, $12, $CD, $C0, $1E db $C3, $F9, $1E, $CD, $EB, $21, $CD, $A4 db $0D, $01, $3D, $55, $CD, $5B, $25, $D8 db $CD, $85, $23, $CD, $75, $23, $CD, $25 db $1A, $47, $CB, $6F, $C4, $F9, $1E, $78 db $CB, $7F, $C8, $CD, $C0, $1E, $1E, $05 db $01, $18, $65, $C3, $46, $08, $0A, $03 db $67, $E5, $CD, $47, $06, $E1, $BC, $1E db $27, $38, $03, $AF, $12, $C9, $3E, $01 db $12, $C9, $CD, $3D, $20, $1E, $45, $1A db $38, $01, $2F, $CB, $7F, $C9, $17, $FF db $0D, $01, $00, $00, $17, $FF, $0D, $27 db $0F, $60, $00, $0D, $A9, $6A, $11, $A4 db $66, $0F, $60, $08, $0F, $3E, $00, $03 db $CA, $68, $45, $0D, $1D, $20, $11, $C0 db $66, $01, $01, $0D, $90, $20, $AD, $55 db $0D, $68, $20, $B5, $55, $06, $CC, $66 db $01, $00, $0D, $90, $20, $B1, $55, $0D db $68, $20, $BB, $55, $09, $06, $19, $00 db $06, $19, $01, $02, $19, $02, $06, $19 db $01, $02, $0A, $09, $02, $19, $03, $06 db $19, $04, $02, $19, $05, $06, $19, $04 db $02, $0A, $06, $CC, $66, $03, $1A, $69 db $45, $18, $19, $06, $06, $19, $07, $02 db $19, $08, $06, $19, $07, $02, $09, $04 db $0D, $6E, $66, $80, $12, $22, $67, $19 db $00, $06, $19, $01, $02, $19, $05, $06 db $19, $04, $02, $19, $03, $06, $19, $04 db $02, $19, $02, $06, $19, $01, $02, $06 db $3A, $67, $19, $06, $06, $19, $07, $02 db $19, $08, $06, $19, $07, $02, $19, $06 db $06, $19, $07, $02, $19, $08, $06, $19 db $07, $02, $0A, $19, $00, $06, $19, $01 db $02, $19, $05, $06, $19, $04, $02, $19 db $03, $06, $19, $04, $02, $19, $02, $06 db $19, $01, $02, $09, $0A, $19, $00, $06 db $19, $01, $02, $19, $02, $06, $19, $01 db $02, $0A, $09, $02, $19, $03, $06, $19 db $04, $02, $19, $05, $06, $19, $04, $02 db $0A, $06, $98, $66, $0F, $5E, $10, $0F db $5F, $10, $0D, $8D, $67, $50, $01, $1B db $4E, $43, $05, $0F, $5E, $10, $0F, $5F db $10, $1B, $4E, $43, $05, $0A, $67, $03 db $0A, $03, $C5, $47, $4C, $26, $01, $CD db $E0, $30, $C1, $C9, $0F, $60, $08, $0F db $42, $0C, $03, $21, $69, $45, $18, $27 db $29, $00, $2A, $00, $19, $06, $06, $19 db $07, $02, $19, $0B, $06, $19, $0A, $02 db $0F, $3E, $00, $0F, $40, $00, $0F, $3F db $0F, $27, $03, $67, $69, $45, $0D, $68 db $20, $C1, $55, $19, $09, $02, $0F, $47 db $10, $19, $09, $01, $19, $0A, $01, $0F db $47, $00, $19, $0B, $02, $0F, $47, $10 db $19, $0B, $01, $19, $0A, $01, $0F, $47 db $00, $06, $CB, $67, $03, $28, $69, $45 db $18, $29, $00, $09, $06, $19, $09, $02 db $0F, $47, $10, $19, $09, $01, $19, $0A db $01, $0F, $47, $00, $19, $0B, $02, $0F db $47, $10, $19, $0B, $01, $19, $0A, $01 db $0F, $47, $00, $0A, $27, $0D, $15, $21 db $C7, $55, $19, $09, $02, $0F, $47, $10 db $19, $09, $01, $19, $0A, $01, $0F, $47 db $00, $19, $0B, $02, $0F, $47, $10, $19 db $0B, $01, $19, $0A, $01, $0F, $47, $00 db $06, $1A, $68, $29, $00, $2A, $00, $0F db $4A, $75, $0D, $C2, $6A, $03, $41, $69 db $45, $19, $06, $06, $19, $07, $02, $19 db $08, $06, $19, $07, $02, $06, $49, $68 db $0F, $60, $08, $03, $B4, $68, $45, $18 db $19, $0C, $02, $19, $0D, $02, $06, $60 db $68, $18, $0F, $60, $08, $0D, $A0, $68 db $12, $74, $67, $03, $B0, $68, $45, $09 db $04, $19, $0C, $02, $0F, $47, $10, $19 db $0D, $02, $0F, $47, $00, $0A, $06, $B8 db $67, $18, $0F, $4A, $00, $0F, $60, $08 db $03, $B0, $68, $45, $09, $02, $19, $0C db $02, $19, $0D, $02, $0A, $06, $9C, $67 db $1E, $42, $1A, $3D, $12, $1E, $27, $28 db $03, $AF, $12, $C9, $3E, $01, $12, $C9 db $CD, $A4, $0D, $C9, $CD, $A4, $0D, $01 db $9F, $55, $CD, $5B, $25, $D8, $CD, $0D db $1F, $C0, $1E, $05, $01, $B8, $67, $C3 db $46, $08, $CD, $91, $0C, $CD, $A4, $0D db $FA, $71, $A0, $A7, $20, $09, $01, $83 db $55, $CD, $5B, $25, $D8, $18, $0B, $1E db $4A, $AF, $12, $01, $91, $55, $CD, $5B db $25, $D8, $1E, $3E, $1A, $3C, $12, $FE db $40, $20, $05, $AF, $12, $CD, $9B, $6A db $06, $30, $CD, $4C, $5B, $38, $01, $C9 db $FA, $71, $A0, $A7, $20, $08, $1E, $05 db $01, $ED, $66, $C3, $46, $08, $1E, $4A db $AF, $12, $1E, $05, $01, $9C, $67, $C3 db $46, $08, $01, $83, $55, $CD, $5B, $25 db $C9, $01, $9F, $55, $CD, $5B, $25, $C9 db $CD, $80, $0C, $CD, $A4, $0D, $01, $9F db $55, $CD, $5B, $25, $D8, $CD, $0D, $1F db $C8, $1E, $05, $01, $58, $68, $C3, $46 db $08, $CD, $80, $0C, $CD, $91, $0C, $CD db $A4, $0D, $01, $83, $55, $CD, $5B, $25 db $D8, $1E, $0E, $1A, $A7, $C0, $1E, $11 db $AF, $12, $1E, $10, $1A, $A7, $C0, $1E db $05, $01, $98, $66, $C3, $46, $08, $1E db $3F, $1A, $3C, $12, $FE, $10, $20, $50 db $AF, $1E, $3F, $12, $1D, $1A, $3C, $12 db $1E, $3E, $1A, $3C, $12, $1E, $40, $1A db $CB, $87, $CB, $A7, $47, $CD, $C0, $1E db $1E, $45, $1A, $CB, $7F, $28, $0A, $CB db $58, $20, $02, $CB, $C0, $CB, $D8, $18 db $08, $CB, $58, $28, $02, $CB, $C0, $CB db $98, $CD, $1D, $20, $1E, $27, $1A, $A7 db $28, $0A, $CB, $78, $20, $02, $CB, $E0 db $CB, $F8, $18, $08, $CB, $78, $28, $02 db $CB, $E0, $CB, $B8, $1E, $40, $78, $12 db $1E, $40, $1A, $CB, $5F, $20, $14, $62 db $2E, $12, $5E, $CB, $47, $28, $02, $1E db $00, $2E, $39, $4E, $2C, $46, $CD, $B4 db $0C, $18, $12, $62, $2E, $12, $5E, $CB db $47, $28, $02, $1E, $00, $2E, $39, $4E db $2C, $46, $CD, $E5, $0C, $1E, $40, $1A db $CB, $7F, $28, $14, $62, $2E, $12, $5E db $CB, $67, $28, $02, $1E, $00, $2E, $39 db $4E, $2C, $46, $CD, $35, $0D, $18, $12 db $62, $2E, $12, $5E, $CB, $67, $28, $02 db $1E, $00, $2E, $39, $4E, $2C, $46, $CD db $66, $0D, $1E, $F8, $CD, $C1, $1A, $CC db $63, $6A, $CD, $A4, $0D, $FA, $71, $A0 db $A7, $20, $08, $1E, $05, $01, $3B, $68 db $C3, $46, $08, $01, $9F, $55, $CD, $5B db $25, $D8, $CD, $0D, $1F, $20, $1C, $1E db $12, $62, $2E, $10, $1A, $E6, $80, $47 db $7E, $E6, $80, $A8, $C8, $1E, $3E, $1A db $FE, $20, $D8, $1E, $05, $01, $EC, $67 db $C3, $46, $08, $1E, $05, $01, $58, $68 db $C3, $46, $08, $1E, $0E, $1A, $CB, $7F db $20, $09, $AF, $12, $1D, $1A, $E6, $7F db $12, $18, $0C, $3E, $FF, $12, $1D, $1A db $2F, $3C, $E6, $7F, $2F, $3C, $12, $1E db $10, $1A, $CB, $7F, $20, $08, $AF, $12 db $1D, $1A, $E6, $7F, $12, $C9, $3E, $FF db $12, $1D, $1A, $2F, $3C, $E6, $7F, $2F db $3C, $12, $C9, $1E, $12, $1A, $2F, $3C db $12, $C9, $1E, $11, $1A, $2F, $3C, $12 db $C9, $FA, $71, $A0, $A7, $1E, $27, $20 db $08, $AF, $12, $1E, $4A, $3E, $75, $12 db $C9, $3E, $01, $12, $1E, $4A, $3E, $00 db $12, $C9, $1E, $0E, $1A, $A7, $28, $0E db $CB, $7F, $1E, $11, $20, $05, $3E, $F8 db $12, $18, $03, $3E, $08, $12, $1E, $10 db $1A, $A7, $C8, $CB, $7F, $1E, $12, $20 db $04, $3E, $F8, $12, $C9, $3E, $08, $12 db $C9, $17, $FF, $0D, $03, $4E, $6B, $45 db $01, $00, $00, $03, $6C, $6B, $45, $09 db $04, $07, $00, $FF, $05, $02, $07, $00 db $01, $05, $04, $07, $00, $FF, $05, $02 db $0A, $18, $24, $47, $03, $76, $6B, $45 db $0D, $5F, $20, $DF, $55, $00, $24, $41 db $03, $94, $6B, $45, $27, $10, $5C, $11 db $27, $6B, $0D, $D3, $20, $D7, $55, $08 db $00, $FF, $2A, $10, $00, $24, $41, $03 db $C6, $6B, $45, $0D, $D3, $20, $DB, $55 db $08, $40, $FF, $2A, $10, $00, $10, $5B db $12, $4A, $6B, $0F, $1F, $80, $1B, $33 db $4E, $03, $1B, $4E, $43, $05, $CD, $A4 db $0D, $01, $C9, $55, $CD, $5B, $25, $D8 db $06, $30, $CD, $4C, $5B, $D0, $06, $24 db $CD, $E4, $6B, $D0, $1E, $05, $01, $F3 db $6A, $C3, $46, $08, $CD, $A4, $0D, $01 db $C9, $55, $CD, $5B, $25, $C9, $CD, $EB db $21, $CD, $A4, $0D, $01, $C9, $55, $CD db $5B, $25, $D8, $CD, $75, $23, $CD, $25 db $1A, $CB, $7F, $C8, $1E, $05, $01, $16 db $6B, $C3, $46, $08, $CD, $91, $0C, $CD db $A4, $0D, $01, $C9, $55, $CD, $5B, $25 db $D8, $CD, $75, $23, $CD, $25, $1A, $CB db $7F, $C8, $1E, $5B, $1A, $A7, $20, $0E db $1E, $5C, $1A, $A7, $28, $08, $1E, $05 db $01, $2D, $6B, $C3, $46, $08, $1E, $05 db $01, $3E, $6B, $C3, $46, $08, $CD, $91 db $0C, $CD, $A4, $0D, $01, $C9, $55, $CD db $5B, $25, $D8, $CD, $75, $23, $CD, $25 db $1A, $CB, $7F, $C8, $1E, $05, $01, $3E db $6B, $C3, $46, $08, $D5, $C5, $1E, $07 db $6B, $26, $A0, $1A, $4F, $1C, $1A, $47 db $5E, $2C, $56, $79, $C6, $34, $4F, $78 db $CE, $00, $47, $79, $93, $78, $9A, $38 db $10, $79, $93, $4F, $78, $BA, $28, $04 db $3E, $FF, $81, $4F, $79, $C1, $D1, $B8 db $C9, $7B, $91, $5F, $78, $BA, $28, $04 db $3E, $FF, $83, $5F, $7B, $C1, $D1, $B8 db $C9, $17, $FF, $0D, $27, $01, $00, $18 db $0D, $80, $1F, $11, $F1, $6C, $03, $2C db $6D, $45, $18, $27, $10, $5C, $01, $02 db $05, $10, $12, $3F, $6C, $05, $08, $0D db $6E, $66, $40, $12, $BE, $6C, $03, $44 db $6D, $45, $24, $0D, $0D, $5F, $20, $FD db $55, $0D, $D3, $20, $03, $56, $0D, $90 db $20, $07, $56, $19, $00, $04, $19, $01 db $38, $01, $00, $00, $01, $02, $03, $2C db $6D, $45, $10, $5C, $05, $08, $12, $73 db $6C, $05, $04, $03, $75, $6D, $45, $24 db $0D, $0D, $5F, $20, $FD, $55, $0D, $D3 db $20, $03, $56, $0D, $90, $20, $07, $56 db $19, $00, $04, $19, $01, $38, $01, $00 db $00, $01, $02, $03, $2C, $6D, $45, $10 db $5C, $05, $08, $12, $A0, $6C, $05, $04 db $03, $A6, $6D, $45, $24, $0D, $0D, $5F db $20, $0B, $56, $0D, $D3, $20, $11, $56 db $0D, $90, $20, $15, $56, $19, $00, $04 db $19, $01, $48, $01, $00, $00, $0F, $40 db $00, $10, $5C, $11, $C9, $6C, $0F, $40 db $01, $03, $2C, $6D, $45, $01, $02, $10 db $5C, $05, $0C, $12, $D8, $6C, $05, $06 db $03, $D7, $6D, $45, $24, $0D, $0D, $5F db $20, $0B, $56, $0D, $90, $20, $19, $56 db $19, $00, $04, $19, $01, $18, $01, $00 db $00, $03, $FB, $6C, $45, $0D, $5F, $20 db $F7, $55, $00, $CD, $EB, $21, $CD, $A4 db $0D, $01, $E5, $55, $CD, $5B, $25, $D8 db $CD, $75, $23, $01, $F3, $55, $CD, $CD db $24, $CB, $77, $20, $10, $CB, $6F, $C2 db $F9, $1E, $CB, $7F, $C8, $1E, $05, $01 db $2E, $6C, $C3, $46, $08, $1E, $0F, $AF db $12, $1C, $12, $C9, $01, $E5, $55, $CD db $5B, $25, $D8, $01, $F3, $55, $CD, $A5 db $24, $CB, $7F, $C0, $1E, $05, $01, $F1 db $6C, $C3, $46, $08, $CD, $EB, $21, $CD db $A4, $0D, $01, $E5, $55, $CD, $5B, $25 db $D8, $CD, $75, $23, $01, $F3, $55, $CD db $CD, $24, $CB, $77, $20, $10, $CB, $6F db $C2, $F9, $1E, $CB, $7F, $C8, $1E, $05 db $01, $64, $6C, $C3, $46, $08, $1E, $0F db $AF, $12, $1C, $12, $C9, $CD, $EB, $21 db $CD, $A4, $0D, $01, $E5, $55, $CD, $5B db $25, $D8, $CD, $75, $23, $01, $F3, $55 db $CD, $CD, $24, $CB, $77, $20, $10, $CB db $6F, $C2, $F9, $1E, $CB, $7F, $C8, $1E db $05, $01, $91, $6C, $C3, $46, $08, $1E db $0F, $AF, $12, $1C, $12, $C9, $CD, $EB db $21, $CD, $A4, $0D, $01, $E5, $55, $CD db $5B, $25, $D8, $CD, $75, $23, $01, $F3 db $55, $CD, $CD, $24, $CB, $77, $20, $10 db $CB, $6F, $C2, $F9, $1E, $CB, $7F, $C8 db $1E, $05, $01, $2E, $6C, $C3, $46, $08 db $1E, $0F, $AF, $12, $1C, $12, $C9, $CD db $EB, $21, $CD, $A4, $0D, $01, $E5, $55 db $CD, $5B, $25, $D8, $CD, $75, $23, $01 db $F3, $55, $CD, $CD, $24, $CB, $77, $20 db $21, $CB, $6F, $C2, $F9, $1E, $CB, $7F db $C8, $1E, $40, $1A, $3C, $12, $FE, $03 db $30, $08, $1E, $05, $01, $C9, $6C, $C3 db $46, $08, $1E, $05, $01, $2E, $6C, $C3 db $46, $08, $1E, $0F, $AF, $12, $1C, $12 db $C9, $17, $0B, $0E, $0D, $99, $72, $18 db $0F, $60, $08, $0F, $3F, $00, $0F, $43 db $00, $0D, $1A, $24, $41, $A8, $B2, $12 db $33, $6E, $16, $0D, $80, $1F, $27, $11 db $6B, $6E, $10, $5C, $12, $97, $6F, $03 db $9C, $70, $45, $0D, $BE, $23, $47, $56 db $10, $5B, $12, $5C, $6E, $19, $02, $08 db $19, $03, $08, $19, $04, $08, $19, $05 db $08, $06, $4D, $6E, $19, $06, $08, $19 db $07, $08, $19, $08, $08, $19, $09, $08 db $06, $5C, $6E, $0F, $10, $00, $10, $5C db $12, $88, $6E, $27, $03, $B5, $6F, $45 db $0D, $5F, $20, $41, $56, $10, $5B, $12 db $85, $6E, $01, $02, $00, $01, $06, $00 db $01, $01, $0F, $60, $00, $0F, $61, $00 db $27, $03, $FE, $71, $45, $0D, $5F, $20 db $41, $56, $00, $17, $FF, $0D, $03, $1B db $70, $45, $0F, $60, $08, $10, $5B, $11 db $AD, $6E, $0F, $61, $C0, $0F, $4A, $05 db $27, $0D, $F9, $1E, $0D, $5F, $20, $57 db $56, $0D, $D3, $20, $4F, $56, $0D, $90 db $20, $53, $56, $10, $5B, $12, $D7, $6E db $19, $02, $08, $19, $03, $08, $19, $04 db $08, $19, $05, $08, $06, $C8, $6E, $19 db $06, $08, $19, $07, $08, $19, $08, $08 db $19, $09, $08, $06, $D7, $6E, $03, $4C db $70, $45, $0D, $5F, $20, $65, $56, $0D db $D3, $20, $5D, $56, $0D, $90, $20, $61 db $56, $10, $5B, $12, $0D, $6F, $19, $02 db $08, $19, $03, $08, $19, $04, $08, $19 db $05, $08, $06, $FE, $6E, $19, $06, $08 db $19, $07, $08, $19, $08, $08, $19, $09 db $08, $06, $0D, $6F, $03, $7D, $70, $45 db $0F, $60, $00, $0F, $61, $00, $18, $10 db $5B, $11, $40, $6F, $0F, $5B, $00, $0F db $5C, $01, $0F, $4C, $00, $04, $42, $75 db $0C, $0F, $49, $FF, $1B, $DD, $7A, $03 db $00, $17, $F6, $0D, $0D, $F9, $1F, $0D db $9F, $72, $0F, $60, $80, $0F, $61, $C0 db $0F, $5E, $08, $0F, $5F, $08, $0F, $4C db $01, $0F, $4A, $10, $27, $04, $06, $53 db $10, $01, $00, $03, $50, $71, $45, $10 db $5C, $12, $14, $5C, $00, $03, $90, $71 db $45, $0D, $5F, $20, $6F, $56, $0D, $90 db $20, $6B, $56, $00, $03, $6C, $72, $45 db $18, $0D, $5F, $20, $79, $56, $0D, $90 db $20, $75, $56, $0F, $60, $07, $05, $04 db $0F, $60, $00, $0F, $61, $00, $00, $17 db $FF, $0D, $0F, $60, $00, $0F, $61, $00 db $27, $03, $2F, $72, $45, $0D, $5F, $20 db $6F, $56, $0D, $90, $20, $6B, $56, $0D db $D3, $20, $47, $56, $00, $62, $2E, $12 db $5E, $2E, $39, $4E, $2C, $46, $CD, $35 db $0D, $CD, $A4, $0D, $1E, $07, $1A, $D6 db $03, $12, $30, $04, $1C, $1A, $3D, $12 db $01, $1D, $56, $CD, $5B, $25, $D8, $1E db $07, $1A, $C6, $03, $12, $30, $04, $1C db $1A, $3C, $12, $FA, $2C, $DD, $CB, $57 db $28, $08, $1E, $05, $01, $9B, $6E, $C3 db $46, $08, $CD, $75, $23, $CD, $85, $23 db $CD, $25, $1A, $CB, $77, $20, $15, $CB db $6F, $C2, $F9, $1E, $CB, $7F, $C8, $1E db $3F, $3E, $01, $12, $1E, $05, $01, $3F db $6E, $C3, $46, $08, $1E, $0F, $AF, $12 db $1C, $12, $C9, $CD, $EB, $21, $CD, $A4 db $0D, $01, $1D, $56, $CD, $5B, $25, $D8 db $CD, $75, $23, $CD, $85, $23, $CD, $62 db $1A, $CB, $77, $20, $10, $CB, $6F, $C2 db $F9, $1E, $CB, $7F, $C8, $1E, $05, $01 db $E6, $6E, $C3, $46, $08, $1E, $0F, $AF db $12, $1C, $12, $C9, $CD, $EB, $21, $CD db $A4, $0D, $01, $1D, $56, $CD, $5B, $25 db $D8, $CD, $75, $23, $CD, $85, $23, $CD db $62, $1A, $CB, $77, $20, $10, $CB, $6F db $C2, $F9, $1E, $CB, $7F, $C8, $1E, $05 db $01, $1C, $6F, $C3, $46, $08, $1E, $0F db $AF, $12, $1C, $12, $C9, $01, $1D, $56 db $CD, $5B, $25, $D8, $CD, $75, $23, $CD db $85, $23, $CD, $CB, $19, $CB, $7F, $C0 db $1E, $3F, $AF, $12, $1E, $05, $01, $6B db $6E, $C3, $46, $08, $CD, $35, $22, $1E db $40, $12, $21, $47, $56, $CD, $CA, $23 db $CD, $A4, $0D, $1E, $07, $1A, $D6, $03 db $12, $30, $04, $1C, $1A, $3D, $12, $01 db $1D, $56, $CD, $5B, $25, $D8, $1E, $07 db $1A, $C6, $03, $12, $30, $04, $1C, $1A db $3C, $12, $FA, $2C, $DD, $CB, $57, $28 db $08, $1E, $05, $01, $9B, $6E, $C3, $46 db $08, $CD, $75, $23, $CD, $85, $23, $CD db $B5, $72, $20, $08, $1E, $05, $01, $9B db $6E, $C3, $46, $08, $CD, $CB, $19, $CB db $6F, $C2, $F9, $1E, $CB, $7F, $28, $07 db $CD, $0B, $71, $DA, $F9, $1E, $C9, $1E db $3F, $AF, $12, $1E, $05, $01, $6B, $6E db $C3, $46, $08, $D5, $CD, $EA, $1A, $C5 db $7B, $D6, $18, $5F, $30, $01, $15, $79 db $C6, $09, $4F, $30, $01, $04, $D5, $CD db $46, $16, $D1, $C1, $FE, $FF, $28, $0A db $CB, $57, $20, $21, $E6, $03, $FE, $01 db $28, $1B, $79, $D6, $09, $4F, $30, $01 db $05, $CD, $46, $16, $FE, $FF, $28, $0A db $CB, $57, $20, $09, $E6, $03, $FE, $01 db $28, $03, $D1, $A7, $C9, $D1, $37, $C9 db $1E, $07, $1A, $C6, $0D, $12, $30, $04 db $1C, $1A, $3C, $12, $01, $2B, $56, $CD db $5B, $25, $D8, $1E, $07, $1A, $D6, $0D db $12, $30, $04, $1D, $1A, $3C, $12, $CD db $B5, $72, $20, $08, $1E, $05, $01, $7C db $6F, $C3, $46, $08, $CD, $75, $23, $CD db $85, $23, $CD, $BE, $72, $A7, $C8, $1E db $05, $01, $6D, $6F, $C3, $46, $08, $C9 db $1E, $10, $1A, $CB, $7F, $1E, $15, $3E db $00, $28, $02, $3E, $01, $12, $62, $2E db $12, $5E, $2E, $39, $4E, $2C, $46, $CD db $35, $0D, $CD, $A4, $0D, $1E, $07, $1A db $C6, $0D, $12, $30, $04, $1C, $1A, $3C db $12, $01, $2B, $56, $CD, $5B, $25, $D8 db $1E, $07, $1A, $D6, $0D, $12, $30, $04 db $1C, $1A, $3D, $12, $CD, $B5, $72, $20 db $08, $1E, $05, $01, $7C, $6F, $C3, $46 db $08, $CD, $75, $23, $CD, $85, $23, $01 db $39, $56, $CD, $CD, $24, $CB, $7F, $20 db $0D, $CD, $DE, $72, $A7, $C0, $1E, $05 db $01, $41, $6F, $C3, $46, $08, $1E, $05 db $01, $6D, $6F, $C3, $46, $08, $CD, $EB db $21, $CD, $A4, $0D, $01, $1D, $56, $CD db $5B, $25, $D8, $CD, $75, $23, $CD, $85 db $23, $CD, $25, $1A, $CB, $77, $20, $10 db $CB, $6F, $C2, $F9, $1E, $CB, $7F, $C8 db $1E, $05, $01, $97, $6F, $C3, $46, $08 db $1E, $0F, $AF, $12, $1C, $12, $C9, $1E db $10, $1A, $CB, $7F, $1E, $15, $3E, $00 db $28, $02, $3E, $01, $12, $62, $2E, $12 db $5E, $2E, $39, $4E, $2C, $46, $CD, $35 db $0D, $CD, $A4, $0D, $01, $1D, $56, $CD db $5B, $25, $D8, $CD, $75, $23, $CD, $85 db $23, $CD, $25, $1A, $CB, $6F, $C2, $F9 db $1E, $CB, $7F, $C8, $1E, $05, $01, $A1 db $6F, $C3, $46, $08, $1E, $10, $1A, $CB db $7F, $1E, $15, $AF, $28, $01, $3C, $12 db $CD, $EB, $21, $CD, $A4, $0D, $01, $2B db $56, $CD, $5B, $25, $D8, $CD, $75, $23 db $CD, $85, $23, $CD, $25, $1A, $CB, $7F db $C8, $1E, $05, $01, $97, $6F, $C3, $46 db $08, $21, $2D, $DD, $36, $00, $C9, $1E db $48, $1A, $67, $6B, $72, $2E, $5B, $5D db $7E, $12, $2E, $5C, $5D, $7E, $12, $2E db $45, $5D, $7E, $12, $C9, $1E, $48, $1A db $67, $2E, $4C, $7E, $A7, $C9, $1E, $48 db $1A, $67, $2E, $03, $5D, $2A, $12, $1C db $2A, $12, $1C, $2A, $12, $1C, $2A, $12 db $1C, $2A, $D6, $0F, $12, $1C, $7E, $DE db $00, $12, $2E, $3F, $7E, $C9, $1E, $48 db $1A, $67, $2E, $03, $5D, $2A, $12, $1C db $2A, $12, $1C, $7E, $12, $1E, $45, $6B db $7E, $12, $2E, $3F, $7E, $C9, $17, $FF db $0D, $27, $18, $0D, $80, $1F, $11, $6D db $73, $06, $0F, $73, $03, $11, $7B, $45 db $18, $0F, $12, $00, $19, $02, $04, $03 db $A0, $7A, $45, $18, $0F, $40, $00, $0F db $3F, $00, $0D, $BE, $23, $AF, $56, $19 db $00, $10, $0D, $22, $7E, $12, $8D, $73 db $0F, $3F, $08, $0D, $BE, $23, $B7, $56 db $19, $01, $10, $0D, $22, $7E, $12, $8D db $73, $03, $C1, $7B, $45, $18, $10, $5C db $12, $58, $73, $19, $00, $0C, $19, $01 db $04, $0D, $F9, $1E, $19, $01, $04, $0D db $22, $7E, $12, $8D, $73, $06, $0F, $73 db $19, $00, $08, $19, $01, $02, $0D, $F9 db $1E, $19, $01, $02, $0D, $22, $7E, $12 db $8D, $73, $06, $0F, $73, $27, $0F, $60 db $08, $0D, $5F, $20, $A9, $56, $03, $12 db $7A, $45, $01, $02, $00, $27, $0F, $60 db $08, $0D, $5F, $20, $A9, $56, $03, $59 db $7A, $45, $01, $03, $00, $18, $0D, $5C db $7E, $12, $E1, $73, $03, $E9, $7B, $45 db $18, $27, $0F, $40, $00, $0F, $3F, $00 db $0D, $BE, $23, $BF, $56, $19, $00, $0C db $0D, $36, $7E, $12, $E1, $73, $0F, $3F db $08, $0D, $BE, $23, $C7, $56, $19, $01 db $0C, $06, $E1, $73, $03, $5A, $7C, $45 db $18, $27, $0F, $40, $00, $0F, $3F, $00 db $0F, $3E, $00, $0D, $BE, $23, $CF, $56 db $19, $00, $0C, $0F, $3F, $08, $0D, $BE db $23, $D7, $56, $19, $01, $0C, $06, $E1 db $73, $10, $5B, $0E, $03, $EB, $73, $7C db $75, $65, $78, $03, $32, $7D, $45, $27 db $0D, $CB, $7E, $0E, $04, $FD, $73, $35 db $74, $6A, $74, $B8, $74, $19, $01, $02 db $19, $02, $10, $10, $5C, $12, $0B, $74 db $19, $02, $08, $24, $3A, $0D, $50, $0F db $48, $A8, $B2, $19, $03, $02, $19, $04 db $02, $19, $05, $08, $10, $5C, $12, $24 db $74, $19, $05, $04, $19, $07, $04, $19 db $00, $10, $10, $5C, $12, $32, $74, $19 db $00, $10, $06, $F8, $78, $19, $07, $04 db $19, $05, $10, $10, $5C, $12, $43, $74 db $19, $05, $08, $24, $3A, $0D, $50, $0F db $48, $A8, $B2, $19, $03, $02, $19, $04 db $02, $19, $02, $08, $10, $5C, $12, $5C db $74, $19, $02, $08, $19, $00, $10, $10 db $5C, $12, $67, $74, $19, $00, $10, $06 db $F8, $78, $19, $01, $04, $19, $02, $10 db $10, $5C, $12, $78, $74, $19, $02, $08 db $24, $3A, $0D, $50, $0F, $48, $A8, $B2 db $19, $03, $02, $19, $04, $02, $19, $05 db $04, $10, $5C, $12, $91, $74, $19, $05 db $04, $24, $3A, $0D, $50, $0F, $48, $A8 db $B2, $19, $03, $02, $19, $04, $02, $19 db $02, $08, $10, $5C, $12, $AA, $74, $19 db $02, $08, $19, $00, $0C, $10, $5C, $12 db $B5, $74, $19, $00, $0C, $06, $F8, $78 db $19, $07, $04, $19, $05, $08, $10, $5C db $12, $C6, $74, $19, $05, $08, $03, $4D db $7D, $45, $18, $0D, $90, $20, $E5, $56 db $2A, $10, $09, $02, $24, $3A, $0D, $50 db $0F, $48, $A8, $B2, $19, $03, $02, $19 db $04, $02, $0A, $19, $02, $18, $10, $5C db $11, $EE, $74, $19, $02, $08, $09, $02 db $10, $45, $24, $3A, $0D, $50, $0F, $48 db $A8, $B2, $19, $03, $02, $19, $04, $02 db $0A, $01, $05, $00, $18, $03, $32, $7D db $45, $19, $00, $10, $10, $5C, $11, $14 db $75, $19, $00, $10, $06, $F8, $78, $18 db $03, $32, $7D, $45, $19, $07, $01, $19 db $05, $01, $10, $5C, $12, $2A, $75, $19 db $05, $01, $09, $03, $24, $3A, $0D, $50 db $0F, $48, $A8, $B2, $19, $03, $02, $19 db $04, $02, $0A, $19, $02, $06, $10, $5C db $12, $46, $75, $19, $02, $02, $19, $00 db $08, $10, $5C, $12, $51, $75, $19, $00 db $08, $06, $0F, $73, $17, $FF, $0D, $0D db $F9, $1F, $0D, $9F, $72, $0D, $24, $7F db $0F, $60, $3F, $0F, $61, $00, $0F, $5E db $08, $0F, $5F, $0C, $0F, $4C, $01, $04 db $74, $53, $10, $01, $FF, $03, $C9, $7D db $45, $05, $08, $16, $03, $EF, $7C, $45 db $27, $18, $0D, $CB, $7E, $0E, $04, $8F db $75, $DA, $75, $2B, $76, $A6, $76, $10 db $5C, $12, $B7, $75, $19, $03, $02, $19 db $02, $18, $19, $03, $04, $24, $3F, $0D db $50, $0F, $49, $A8, $B2, $19, $04, $40 db $19, $03, $02, $19, $02, $18, $19, $03 db $04, $19, $00, $10, $06, $F8, $78, $19 db $03, $02, $19, $02, $10, $19, $03, $02 db $24, $3F, $0D, $50, $0F, $49, $A8, $B2 db $19, $04, $40, $19, $03, $02, $19, $02 db $10, $19, $03, $02, $19, $00, $08, $06 db $F8, $78, $10, $5C, $12, $05, $76, $19 db $03, $02, $19, $02, $18, $19, $03, $02 db $19, $06, $20, $24, $3F, $0D, $50, $0F db $4A, $A8, $B2, $19, $04, $40, $19, $06 db $02, $19, $05, $04, $19, $01, $02, $19 db $00, $10, $06, $F8, $78, $19, $03, $02 db $19, $02, $10, $19, $03, $02, $19, $06 db $20, $24, $3F, $0D, $50, $0F, $4A, $A8 db $B2, $19, $04, $30, $19, $06, $02, $19 db $05, $04, $19, $01, $02, $19, $00, $08 db $06, $F8, $78, $10, $5C, $12, $6B, $76 db $19, $00, $10, $19, $01, $04, $0D, $F9 db $1E, $19, $01, $02, $19, $03, $02, $19 db $02, $18, $19, $03, $04, $24, $3F, $0D db $50, $0F, $4B, $A8, $B2, $19, $04, $40 db $19, $06, $02, $19, $05, $04, $19, $01 db $02, $19, $00, $10, $19, $01, $02, $0D db $F9, $1E, $19, $00, $10, $19, $01, $02 db $06, $F8, $78, $19, $00, $08, $19, $01 db $02, $0D, $F9, $1E, $19, $01, $02, $19 db $03, $02, $19, $02, $10, $19, $03, $02 db $24, $3F, $0D, $50, $0F, $4B, $A8, $B2 db $19, $04, $40, $19, $06, $02, $19, $05 db $04, $19, $01, $02, $19, $00, $08, $19 db $01, $02, $0D, $F9, $1E, $19, $00, $10 db $19, $01, $02, $06, $F8, $78, $10, $5C db $12, $E9, $76, $19, $00, $10, $19, $01 db $08, $18, $03, $0A, $7D, $45, $0D, $90 db $20, $E9, $56, $2A, $10, $19, $03, $02 db $19, $02, $1E, $18, $03, $2B, $7D, $45 db $19, $03, $04, $24, $3F, $0D, $50, $0F db $4C, $A8, $B2, $03, $0A, $7D, $45, $19 db $04, $20, $19, $06, $02, $19, $05, $04 db $19, $01, $02, $19, $00, $10, $06, $F8 db $78, $19, $00, $08, $19, $01, $08, $18 db $03, $0A, $7D, $45, $0D, $90, $20, $E9 db $56, $2A, $10, $19, $03, $02, $19, $02 db $26, $18, $03, $2B, $7D, $45, $19, $03 db $02, $24, $3F, $0D, $50, $0F, $4C, $A8 db $B2, $03, $0A, $7D, $45, $19, $04, $28 db $03, $11, $7B, $45, $19, $06, $02, $19 db $05, $04, $19, $01, $02, $19, $00, $08 db $06, $F8, $78, $0D, $F9, $1F, $0D, $9F db $72, $0D, $A0, $7E, $0D, $49, $7F, $17 db $FF, $0D, $0F, $60, $08, $0F, $61, $00 db $0F, $5E, $08, $0F, $5F, $08, $0F, $4C db $01, $04, $F4, $53, $10, $03, $DF, $7D db $45, $2A, $FA, $0D, $D3, $20, $ED, $56 db $0D, $15, $21, $F1, $56, $09, $08, $19 db $07, $02, $19, $08, $02, $0A, $18, $2A db $00, $09, $08, $19, $07, $02, $19, $08 db $02, $0A, $16, $0D, $F9, $1F, $0D, $9F db $72, $0D, $A0, $7E, $0D, $49, $7F, $17 db $FF, $0D, $0F, $60, $08, $0F, $61, $00 db $0F, $5E, $08, $0F, $5F, $08, $0F, $4C db $01, $04, $F4, $53, $10, $03, $EF, $7D db $45, $0D, $D3, $20, $F3, $56, $0D, $5F db $20, $F7, $56, $0D, $90, $20, $FD, $56 db $19, $07, $02, $19, $08, $02, $06, $A8 db $77, $03, $FF, $7D, $45, $0D, $D3, $20 db $01, $57, $0D, $5F, $20, $05, $57, $0D db $90, $20, $0B, $57, $19, $07, $02, $19 db $08, $02, $06, $C4, $77, $0D, $F9, $1F db $0D, $9F, $72, $0D, $A0, $7E, $0D, $49 db $7F, $17, $FF, $0D, $0F, $60, $08, $0F db $61, $00, $0F, $5E, $08, $0F, $5F, $08 db $0F, $4C, $01, $04, $F4, $53, $10, $03 db $DF, $7D, $45, $0D, $D3, $20, $0F, $57 db $0D, $15, $21, $13, $57, $0D, $90, $20 db $15, $57, $2A, $F8, $09, $08, $19, $07 db $02, $19, $08, $02, $0A, $29, $00, $09 db $04, $19, $07, $02, $19, $08, $02, $0A db $2A, $00, $09, $04, $19, $07, $02, $19 db $08, $02, $0A, $06, $83, $67, $0D, $F9 db $1F, $0D, $9F, $72, $0D, $A0, $7E, $0D db $49, $7F, $17, $FF, $0D, $0D, $49, $7F db $0F, $60, $08, $0F, $61, $00, $0F, $5E db $08, $0F, $5F, $08, $0F, $4C, $01, $04 db $F4, $53, $10, $03, $DF, $7D, $45, $0D db $D3, $20, $19, $57, $0D, $15, $21, $1D db $57, $09, $08, $19, $07, $02, $19, $08 db $02, $0A, $06, $83, $67, $03, $CF, $7C db $45, $27, $0F, $44, $00, $18, $19, $02 db $02, $19, $03, $04, $19, $02, $10, $0D db $50, $0F, $43, $A8, $B2, $0D, $03, $20 db $09, $02, $19, $04, $0A, $19, $05, $03 db $19, $06, $03, $19, $07, $0A, $19, $06 db $03, $19, $05, $03, $0A, $10, $5C, $12 db $AC, $78, $19, $04, $0A, $19, $05, $03 db $19, $06, $03, $19, $07, $0A, $19, $06 db $03, $19, $05, $03, $0D, $6F, $7E, $12 db $B8, $78, $19, $08, $40, $06, $DE, $78 db $19, $08, $20, $19, $07, $02, $19, $06 db $02, $19, $05, $02, $19, $04, $08, $19 db $05, $1C, $19, $02, $04, $19, $03, $02 db $19, $02, $10, $10, $5C, $12, $F8, $78 db $19, $02, $10, $06, $F8, $78, $03, $6E db $7D, $45, $0F, $3E, $00, $18, $29, $00 db $0D, $15, $21, $E3, $56, $0D, $D3, $20 db $DF, $56, $19, $01, $04, $19, $00, $04 db $18, $27, $0D, $48, $7E, $12, $0F, $73 db $0D, $B7, $7E, $11, $94, $73, $06, $BC db $73, $0D, $F9, $1F, $0D, $9F, $72, $0D db $AA, $7E, $17, $FF, $0D, $0F, $60, $3F db $0F, $61, $00, $0F, $5E, $08, $0F, $5F db $08, $0F, $4C, $01, $04, $7B, $54, $10 db $01, $0A, $03, $A3, $7D, $45, $18, $2A db $00, $0D, $D3, $20, $1F, $57, $0D, $15 db $21, $23, $57, $24, $23, $05, $10, $0D db $A2, $6A, $24, $23, $05, $10, $0D, $A2 db $6A, $24, $23, $05, $10, $0D, $A2, $6A db $24, $23, $05, $10, $10, $5C, $12, $67 db $79, $0D, $A2, $6A, $24, $23, $05, $10 db $0D, $A2, $6A, $24, $23, $05, $10, $24 db $36, $0D, $96, $7E, $12, $94, $79, $18 db $29, $00, $0D, $D3, $20, $25, $57, $0D db $5F, $20, $2B, $57, $0D, $90, $20, $31 db $57, $05, $10, $2A, $00, $08, $00, $00 db $0D, $15, $21, $29, $57, $05, $20, $29 db $00, $05, $10, $16, $18, $29, $00, $0D db $D3, $20, $35, $57, $0D, $5F, $20, $3B db $57, $0D, $90, $20, $41, $57, $05, $10 db $2A, $00, $08, $00, $00, $0D, $15, $21 db $39, $57, $05, $10, $0D, $5F, $20, $45 db $57, $0D, $90, $20, $4B, $57, $05, $10 db $29, $00, $05, $10, $2A, $00, $07, $00 db $00, $0D, $90, $20, $4F, $57, $05, $0A db $16, $03, $5B, $7B, $45, $06, $DC, $79 db $03, $83, $7B, $45, $10, $5B, $0E, $03 db $E6, $79, $EF, $79, $F8, $79, $19, $06 db $02, $19, $07, $02, $06, $E6, $79, $19 db $05, $02, $19, $06, $02, $06, $EF, $79 db $19, $01, $02, $19, $09, $02, $06, $F8 db $79, $04, $52, $6F, $0B, $0F, $46, $00 db $19, $04, $02, $19, $05, $04, $19, $04 db $02, $16, $62, $2E, $12, $5E, $2E, $39 db $4E, $2C, $46, $CD, $35, $0D, $CD, $A4 db $0D, $01, $7F, $56, $CD, $5B, $25, $D8 db $CD, $85, $23, $CD, $75, $23, $CD, $25 db $1A, $CB, $77, $20, $11, $CB, $6F, $C2 db $F9, $1E, $CB, $7F, $28, $0F, $1E, $05 db $01, $0F, $73, $C3, $46, $08, $1E, $0F db $AF, $12, $1C, $12, $C9, $CD, $0D, $1F db $C8, $1E, $05, $01, $D8, $79, $C3, $46 db $08, $62, $2E, $12, $5E, $2E, $39, $4E db $2C, $46, $CD, $35, $0D, $CD, $A4, $0D db $01, $7F, $56, $CD, $5B, $25, $D8, $CD db $85, $23, $CD, $75, $23, $CD, $25, $1A db $CB, $77, $20, $11, $CB, $6F, $C2, $F9 db $1E, $CB, $7F, $28, $0F, $1E, $05, $01 db $04, $73, $C3, $46, $08, $1E, $0F, $AF db $12, $1C, $12, $C9, $CD, $0D, $1F, $C8 db $1E, $05, $01, $D8, $79, $C3, $46, $08 db $CD, $35, $22, $1E, $40, $12, $1E, $3F db $1A, $21, $AF, $56, $85, $30, $01, $24 db $6F, $CD, $CA, $23, $CD, $A4, $0D, $01 db $7F, $56, $CD, $5B, $25, $D8, $1E, $5B db $1A, $A7, $20, $1C, $CD, $6E, $7F, $30 db $17, $2E, $5A, $7E, $1E, $44, $FE, $01 db $20, $04, $3E, $01, $18, $01, $AF, $12 db $1E, $05, $01, $17, $75, $C3, $46, $08 db $CD, $85, $23, $CD, $75, $23, $CD, $F3 db $19, $CB, $67, $20, $10, $CB, $6F, $20 db $0C, $CB, $7F, $20, $10, $1E, $05, $01 db $6D, $73, $C3, $46, $08, $1E, $05, $01 db $39, $73, $C3, $46, $08, $CD, $0D, $1F db $C8, $1E, $05, $01, $D1, $79, $C3, $46 db $08, $01, $7F, $56, $CD, $5B, $25, $D8 db $1E, $5B, $1A, $A7, $20, $1C, $CD, $6E db $7F, $30, $17, $2E, $5A, $7E, $1E, $44 db $FE, $01, $20, $04, $3E, $01, $18, $01 db $AF, $12, $1E, $05, $01, $17, $75, $C3 db $46, $08, $CD, $85, $23, $CD, $75, $23 db $CD, $F3, $19, $CB, $7F, $20, $08, $1E db $05, $01, $6D, $73, $C3, $46, $08, $CD db $0D, $1F, $C8, $1E, $05, $01, $D1, $79 db $C3, $46, $08, $01, $7F, $56, $CD, $5B db $25, $D8, $CD, $85, $23, $CD, $75, $23 db $CD, $F3, $19, $CB, $7F, $20, $08, $1E db $05, $01, $6D, $73, $C3, $46, $08, $CD db $0D, $1F, $C0, $1E, $05, $01, $0F, $73 db $C3, $46, $08, $CD, $EB, $21, $CD, $A4 db $0D, $01, $7F, $56, $CD, $5B, $25, $D8 db $CD, $85, $23, $CD, $75, $23, $CD, $25 db $1A, $CB, $77, $20, $11, $CB, $6F, $C2 db $F9, $1E, $CB, $7F, $28, $0F, $1E, $05 db $01, $0F, $73, $C3, $46, $08, $1E, $0F db $AF, $12, $1C, $12, $C9, $CD, $0D, $1F db $C0, $1E, $05, $01, $76, $73, $C3, $46 db $08, $01, $7F, $56, $CD, $5B, $25, $D8 db $CD, $85, $23, $CD, $75, $23, $CD, $F3 db $19, $CB, $7F, $20, $08, $1E, $05, $01 db $6D, $73, $C3, $46, $08, $CD, $0D, $1F db $C8, $1E, $05, $01, $D1, $79, $C3, $46 db $08, $CD, $35, $22, $1E, $40, $12, $1E db $3F, $1A, $21, $BF, $56, $85, $30, $01 db $24, $6F, $CD, $CA, $23, $CD, $A4, $0D db $01, $7F, $56, $CD, $5B, $25, $D8, $1E db $5B, $1A, $A7, $20, $1C, $CD, $6E, $7F db $30, $17, $2E, $5A, $7E, $1E, $44, $FE db $01, $20, $04, $3E, $01, $18, $01, $AF db $12, $1E, $05, $01, $17, $75, $C3, $46 db $08, $CD, $85, $23, $CD, $75, $23, $CD db $F3, $19, $CB, $67, $20, $10, $CB, $6F db $20, $0C, $CB, $7F, $20, $10, $1E, $05 db $01, $6D, $73, $C3, $46, $08, $1E, $05 db $01, $BC, $73, $C3, $46, $08, $CD, $0D db $1F, $C8, $1E, $05, $01, $D1, $79, $C3 db $46, $08, $CD, $35, $22, $1E, $40, $12 db $1E, $3F, $1A, $21, $CF, $56, $85, $30 db $01, $24, $6F, $CD, $CA, $23, $1E, $3E db $1A, $A7, $20, $03, $CD, $A4, $0D, $01 db $7F, $56, $CD, $5B, $25, $D8, $1E, $5B db $1A, $A7, $20, $1C, $CD, $6E, $7F, $30 db $17, $2E, $5A, $7E, $1E, $44, $FE, $01 db $20, $04, $3E, $01, $18, $01, $AF, $12 db $1E, $05, $01, $17, $75, $C3, $46, $08 db $CD, $85, $23, $CD, $75, $23, $CD, $F3 db $19, $CB, $67, $20, $10, $CB, $6F, $20 db $0C, $CB, $7F, $20, $0E, $1E, $05, $01 db $6D, $73, $C3, $46, $08, $1E, $3E, $3E db $01, $12, $C9, $CD, $0D, $1F, $C8, $1E db $05, $01, $D1, $79, $C3, $46, $08, $01 db $7F, $56, $CD, $5B, $25, $D8, $CD, $85 db $23, $CD, $75, $23, $CD, $F3, $19, $CB db $7F, $C0, $1E, $44, $3E, $01, $12, $1E db $05, $01, $7D, $73, $C3, $46, $08, $01 db $7F, $56, $CD, $5B, $25, $D8, $CD, $85 db $23, $CD, $75, $23, $CD, $F3, $19, $CB db $7F, $C0, $1E, $05, $01, $6D, $73, $C3 db $46, $08, $CD, $91, $0C, $CD, $A4, $0D db $01, $7F, $56, $CD, $5B, $25, $D8, $CD db $85, $23, $CD, $75, $23, $CD, $25, $1A db $CB, $7F, $C8, $1E, $05, $01, $18, $77 db $C3, $46, $08, $01, $7F, $56, $CD, $5B db $25, $C9, $01, $7F, $56, $CD, $5B, $25 db $D8, $CD, $85, $23, $CD, $75, $23, $CD db $F3, $19, $CB, $7F, $C0, $1E, $05, $01 db $6D, $73, $C3, $46, $08, $CD, $91, $0C db $CD, $A4, $0D, $01, $7F, $56, $CD, $5B db $25, $D8, $CD, $85, $23, $CD, $75, $23 db $CD, $25, $1A, $CB, $7F, $C8, $1E, $05 db $01, $04, $75, $C3, $46, $08, $1E, $3E db $1A, $A7, $20, $06, $CD, $80, $0C, $CD db $A4, $0D, $01, $7F, $56, $CD, $5B, $25 db $D8, $CD, $85, $23, $CD, $75, $23, $CD db $F3, $19, $CB, $67, $20, $0F, $CB, $6F db $20, $0B, $CB, $7F, $C0, $1E, $05, $01 db $6D, $73, $C3, $46, $08, $1E, $3E, $3E db $01, $12, $C9, $CD, $91, $0C, $CD, $80 db $0C, $CD, $A4, $0D, $01, $8D, $56, $CD db $5B, $25, $D8, $1E, $48, $1A, $67, $2E db $44, $7E, $A7, $20, $04, $CD, $B5, $72 db $C0, $1E, $05, $01, $14, $5C, $C3, $46 db $08, $CD, $6E, $7F, $2E, $5A, $7E, $FE db $00, $20, $05, $1E, $60, $3E, $3F, $12 db $01, $8D, $56, $CD, $5B, $25, $C9, $CD db $91, $0C, $CD, $80, $0C, $CD, $A4, $0D db $01, $9B, $56, $CD, $5B, $25, $C9, $CD db $91, $0C, $CD, $80, $0C, $CD, $A4, $0D db $01, $9B, $56, $CD, $5B, $25, $C9, $CD db $91, $0C, $CD, $80, $0C, $CD, $A4, $0D db $01, $8D, $56, $CD, $5B, $25, $D8, $CD db $25, $1A, $CB, $6F, $C2, $F9, $1E, $CB db $7F, $C8, $1E, $05, $01, $83, $67, $C3 db $46, $08, $C5, $06, $40, $0E, $48, $CD db $14, $1F, $C1, $1E, $27, $38, $03, $AF db $12, $C9, $3E, $01, $12, $C9, $C5, $06 db $30, $CD, $14, $1F, $C1, $1E, $27, $38 db $03, $AF, $12, $C9, $3E, $01, $12, $C9 db $C5, $06, $40, $0E, $28, $CD, $14, $1F db $C1, $1E, $27, $30, $03, $AF, $12, $C9 db $3E, $01, $12, $C9, $C5, $06, $34, $CD db $4C, $5B, $C1, $1E, $27, $30, $04, $3E db $01, $12, $C9, $3E, $00, $12, $C9, $C5 db $D5, $CD, $47, $06, $D1, $FE, $40, $38 db $09, $06, $20, $CD, $11, $5B, $38, $10 db $18, $07, $06, $20, $CD, $11, $5B, $30 db $07, $1E, $27, $3E, $01, $12, $C1, $C9 db $1E, $27, $AF, $12, $C1, $C9, $1E, $48 db $1A, $67, $2E, $27, $5D, $7E, $12, $C9 db $1E, $48, $1A, $67, $2E, $45, $5D, $7E db $12, $C9, $1E, $07, $1A, $D6, $14, $12 db $30, $04, $1C, $1A, $3D, $12, $C9, $C5 db $06, $20, $CD, $4C, $5B, $C1, $30, $06 db $1E, $27, $3E, $01, $12, $C9, $1E, $27 db $AF, $12, $C9, $C5, $D5, $1E, $07, $6B db $26, $A0, $1A, $4F, $1C, $1A, $47, $5E db $2C, $56, $79, $93, $4F, $78, $9A, $D1 db $38, $22, $79, $FE, $10, $38, $1D, $1E db $5C, $1A, $A7, $20, $09, $CD, $47, $06 db $FE, $80, $30, $10, $18, $07, $CD, $47 db $06, $FE, $C0, $30, $07, $1E, $27, $3E db $03, $12, $C1, $C9, $CD, $47, $06, $FE db $40, $38, $12, $FE, $A0, $38, $07, $1E db $27, $3E, $00, $12, $C1, $C9, $1E, $27 db $3E, $01, $12, $C1, $C9, $1E, $27, $3E db $02, $12, $C1, $C9, $1E, $48, $1A, $67 db $2E, $45, $7E, $CB, $7F, $20, $0D, $1E db $04, $1A, $C6, $10, $12, $30, $04, $1C db $1A, $3C, $12, $C9, $1E, $04, $1A, $D6 db $10, $12, $30, $04, $1C, $1A, $3D, $12 db $C9, $1E, $48, $1A, $67, $2E, $45, $7E db $CB, $7F, $20, $0D, $1E, $04, $1A, $C6 db $10, $12, $30, $04, $1C, $1A, $3C, $12 db $C9, $1E, $04, $1A, $D6, $10, $12, $30 db $04, $1C, $1A, $3D, $12, $C9, $26, $A5 db $0E, $03, $C5, $2E, $00, $7E, $FE, $FF db $28, $1B, $2E, $4C, $7E, $B7, $28, $15 db $1E, $04, $06, $30, $CD, $9E, $1F, $30 db $0C, $1E, $07, $06, $20, $CD, $9E, $1F db $30, $03, $C1, $37, $C9, $C1, $0D, $C8 db $24, $18, $D7, $FF, $FF, $FF, $FF, $FF db $00, $20, $00, $08, $00, $00, $20, $00 db $04, $04, $00, $80, $10, $00, $00, $08 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $40, $00 db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF db $FF, $FF, $FF, $F7, $FF, $FF, $FF, $FF db $FF, $FF, $7F, $FF, $FF, $FF, $FF, $FF db $A0, $00, $80, $80, $08, $00, $00, $68 db $04, $00, $00, $02, $40, $00, $80, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00
;PARTSWAP.ASM ;1581 PARTITION LIST AND SWAP ;AKX 2021 ;--------------------------------------- ;SET UP BASIC SYS *= $0801 ;END $080C ;LINE $000A ;SYS (TOKEN $9E) ;" 2560" ;END LINE (000) .BYTE $0C,$08,$0A,$00,$9E,$20 .BYTE $32,$35,$36,$30,$00,$00 .BYTE $00 ;--------------------------------------- ;VARIABLES *= $0820 DRIVE .BYTE $00 TYPE .BYTE $00 STAT .BYTE $00 FOUND .BYTE $00 PRES .BYTE $00 INDIR .BYTE $00 SCRPOS .BYTE $00 NUMPART .BYTE $00 DIRPOSL .BYTE $00 DIRPOSH .BYTE $00 DIRBUFF .BYTE $00,$00,$00,$00,$00,$00 .BYTE $00,$00,$00,$00,$00,$00 .BYTE $00,$00,$00,$00,$00,$00 .BYTE $00,$00,$00,$00 NAMEBUFF .BYTE $00,$00,$00,$00,$00,$00 .BYTE $00,$00,$00,$00,$00,$00 .BYTE $00,$00,$00,$00 XTEN .BYTE $00,$0A,$14,$1E,$28,$32 .BYTE $3C,$46,$50,$5A ;--------------------------------------- ;DATA S1 .TEXT " " .TEXT "FINDING 1581 DRIVE" LS1 = *-S1 S2 .TEXT " " .TEXT "LISTING PARTITIONS" LS2 = *-S2 S3 .TEXT " " .TEXT "CHANGING PARTITION" LS3 = *-S3 MSGNP .TEXT "1581 DRIVE NOT PRESENT" .BYTE $0D LMSGNP = *-MSGNP RPMSG .TEXT "1581 DRIVE FOUND ON" .TEXT " DEVICE" .BYTE $20 LRPMSG = *-RPMSG UDMSG .TEXT "USE THIS DRIVE? (Y/N)" .BYTE $0D LUDMSG = *-UDMSG MRTYPE .TEXT "M-R" .BYTE $C6,$E5,$01 LMRTYPE = *-MRTYPE PCMSG .TEXT "CONTINUE? (Y/N)" .BYTE $0D LPCMSG = *-PCMSG ENTMSG .TEXT "ENTER A PARTITION? " .TEXT "(Y/N)" .BYTE $0D LENTMSG = *-ENTMSG PNMSG .TEXT "TYPE QUIT TO EXIT" .TEXT " " .BYTE $0D .TEXT "NAME OF PARTITION: " LPNMSG = *-PNMSG ROOT .TEXT "/" .BYTE $0D LROOT = *-ROOT QUIT .TEXT "QUIT" LQUIT = *-QUIT NOPAMSG .TEXT "NO PARTITIONS-" .TEXT "INITIALIZING..." .BYTE $0D LNOPAMSG = *-NOPAMSG AGMSG .TEXT "CHANGE AGAIN? (Y/N)" .BYTE $0D LAGMSG = *-AGMSG DNAME .TEXT "$0" LDNAME = *-DNAME INIT .TEXT "I0" LINIT = *-INIT CD .TEXT "/0:" LCD = *-CD ;--------------------------------------- ;BEGIN CODE *= $0A00 ;JUMP TABLE LDA #$00 STA $D020 ;BORDER = BLACK STA $D021 ;BCKGND = BLACK LDA #$93 JSR $FFD2 ;CLS LDA #$05 JSR $FFD2 ;WHITE TEXT JSR SPROBE ;PROBE DRIVS 8->30 LDA FOUND BEQ EXIT ;IF NO 1581 JSR CLS CHGDIR JSR SLIST ;LIST PARTITIONS LDA STAT CMP #$4A BEQ DINIT ;DRIVE NOT RDY JSR GPART ;INPUT PARTITION LDA STAT CMP #$4A BEQ EXIT JSR CPART ;CHANGE PARTITION LDA STAT CMP #$4A BEQ EXIT JMP AGAIN EXIT RTS ;RETURN TO BASIC AGAIN LDY #$00 AGLOOP1 LDA AGMSG,Y JSR $FFD2 INY CPY #LAGMSG BNE AGLOOP1 AGLOOP2 JSR $FFE4 CMP #$4E ;N BEQ EXIT CMP #$59 ;Y BNE AGLOOP2 JSR CLS JMP CHGDIR DINIT JSR OCOMM ;OPEN COMM CHN LDX #$0F JSR $FFC9 ;CHKOUT LDY #$00 DILOOP LDA INIT,Y JSR $FFD2 ;CHROUT INY CPY #LINIT BNE DILOOP JSR $FFCC ;CLRCHN JSR CCOMM ;CLOSE COMM CHN JMP EXIT ;--------------------------------------- ;PROBE DRIVES 8->30 FOR 1581 SPROBE LDA #$08 ;DEVICE 8 STA DRIVE JSR PRINTS1 ;STAT BAR LDX #$01 LDY #$00 JSR $FFF0 ;PLOT - SET CSR PROBE JSR CHKPRES ;IS DRV PRESENT? LDA PRES BNE PAHEAD ;IF NOT, SKIP JSR OCOMM ;OPEN COMM CHNL JSR GTYPE ;GET DRIVE TYPE JSR CCOMM ;CLOSE COMM CHNL LDA TYPE ;1=1581,0=OTHER BNE RPROBE ;RETURN PAHEAD INC DRIVE LDA DRIVE CMP #$1F ;DRIVE <31 BNE PROBE JMP NPRES ;USE RTS IN SUB GTYPE LDX #$0F JSR $FFC9 ;CHKOUT LDY #$00 GTLOOP LDA MRTYPE,Y JSR $FFD2 ;CHROUT INY CPY #LMRTYPE BNE GTLOOP JSR $FFCC ;CLRCHN LDX #$0F JSR $FFC6 ;CHKIN JSR $FFCF ;CHRIN TAY JSR $FFCC ;CLRCHN TYA ADC #$00 ;PROTECT NULL$ CMP #$FF ;255=1581 BEQ DPRES LDA #$00 ;0=OTHER DRIVE STA TYPE RTS DPRES LDA #$01 ;1=1581 STA TYPE RTS NPRES LDY #$00 NPLOOP LDA MSGNP,Y JSR $FFD2 ;CHROUT INY CPY #LMSGNP BNE NPLOOP RTS RPROBE LDA #$01 ;DRIVE FOUND STA FOUND LDY #$00 RPLOOP LDA RPMSG,Y ;PRINT MESSAGE JSR $FFD2 INY CPY #LRPMSG BNE RPLOOP TYA PHA LDA DRIVE JSR NUMCHAR ;PRINT DRIVE # PLA TAY LDA #$0D JSR $FFD2 ;PRINT RETURN JSR RERR JMP UDRIVE ;USE RTS IN SUB UDRIVE LDY #$00 UDLOOP LDA UDMSG,Y JSR $FFD2 INY CPY #LUDMSG BNE UDLOOP UDKBD JSR $FFE4 ;SCAN KBD CMP #$4E ;N BEQ UDNO CMP #$59 ;Y BEQ UDYES JMP UDKBD UDNO LDA #$00 STA FOUND LDA #$0D JSR $FFD2 JMP PAHEAD UDYES LDA #$0D JMP $FFD2 ;USE RTS IN SUB PRINTS1 JSR POSSTAT ;SETUP STAT BAR S1LOOP1 LDA S1,Y JSR $FFD2 LDA #$03 STA $D800,Y ;CYAN INY CPY #LS1 BNE S1LOOP1 JMP CLRSTAT ;END STAT BAR ;USE RTS IN SUB ;--------------------------------------- ;LIST PARTITIONS SLIST JSR PRINTS2 ;STAT BAR JSR OCOMM ;OPEN COMM CHN LDA #LDNAME LDX #<DNAME LDY #>DNAME JSR $FFBD ;SETNAM LDA #$60 ;96,DRIVE,96 LDX DRIVE LDY #$60 JSR $FFBA ;SETLFS JSR $FFC0 ;OPEN DATA CHN JSR RSTAT LDA STAT CMP #$4A ;74 = NOT RDY BEQ LEXIT LDA STAT CMP #$14 ;NO ERRORS < 20 BCC PLIST LEXIT LDA #$60 JSR $FFC3 ;CLOSE DATA CHN JMP CCOMM ;CLOSE COMM CHN ;USE RTS IN SUB PLIST CLC LDX #$01 LDY #$00 JSR $FFF0 ;PLOT - SET CSR LDY #$00 LDA #$20 PSPLOOP JSR $FFD2 ;? SPC(4) INY CPY #$04 BNE PSPLOOP LDA #$12 ;REV ON JSR $FFD2 LDA #$22 ;? QUOTES JSR $FFD2 JSR FNDQUOTE ;FIND NEXT QUOTES JSR READHEAD ;? DISK HEADER LDA #$92 ;REV OFF JSR $FFD2 LDA #$0D JSR $FFD2 PENTRY LDA #$00 STA DIRPOSL ;LOW INDEX STA DIRPOSH ;HIGH INDEX STA SCRPOS ;POS ON SCR <14 STA NUMPART ;TOTAL PARTITIONS DIRLOOP JSR FNDQUOTE LDA INDIR ;1=IN DIR 0=DONE BEQ LEXIT JSR READDIR ;READ 1 ENTRY INC DIRPOSL ;NEXT ENTRY LDA DIRPOSL CMP #$29 ;$29+$FF=296 BNE DIRLOOP INC DIRPOSH ;NEXT BANK LDA DIRPOSH CMP #$02 ;+$FF BNE DIRLOOP JMP LEXIT FNDQUOTE LDA #$01 STA INDIR ;SET INDIR TRUE LDX #$60 JSR $FFC6 ;CHKIN FNDLOOP JSR $FFCF ;CHRIN TAY JSR $FFB7 ;CHECK STAT BNE EXITDIR TYA CMP #$22 ;QUOTES BNE FNDLOOP RTS READHEAD LDY #$16 ;22 CHARS HEADLOOP JSR $FFCF ;CHRIN JSR $FFD2 ;CHROUT DEY BPL HEADLOOP JMP $FFCC ;CLRCHN ;USE RTS IN FFCC EXITDIR DEC INDIR ;INDIR FALSE JMP $FFCC ;CLRCHN ;USE RTS IN FFCC READDIR LDY #$15 RLOOP1 JSR $FFCF ;CHRIN STA DIRBUFF,Y DEY BPL RLOOP1 JSR $FFCC ;CLRCHN LDA DIRBUFF+1 CMP #$4D ;"M" FROM CBM BNE DIRRET INC SCRPOS INC NUMPART LDA SCRPOS CMP #$0E ;SCRPOS=14? BEQ PRMTCONT ;PROMPT FOR CONT RDCONT LDY #$05 ;?SPC(5) LDA #$20 RLOOP2 JSR $FFD2 DEY BNE RLOOP2 LDA #$22 ;? QUOTES JSR $FFD2 LDY #$15 RLOOP3 LDA DIRBUFF,Y JSR $FFD2 ;CHROUT DEY BPL RLOOP3 LDA #$0D ;RETURN JSR $FFD2 DIRRET RTS PRMTCONT LDA #$00 STA SCRPOS LDY #$00 PCLOOP LDA PCMSG,Y JSR $FFD2 ;CHROUT INY CPY #LPCMSG BNE PCLOOP PCKBD JSR $FFE4 ;SCAN KBD CMP #$4E ;N BNE PCFWDY LDA #$28 ;SET END OF DIR STA DIRPOSL LDA #$01 STA DIRPOSH RTS PCFWDY CMP #$59 ;Y BNE PCKBD JSR CLRDIR JMP RDCONT CLRDIR LDX #$02 LDY #$00 CLC JSR $FFF0 ;PLOT - SET CSR LDX #$00 CLRLOOP1 LDY #$00 LDA #$20 CLRLOOP2 JSR $FFD2 INY CPY #$1B ;27 SPACES BNE CLRLOOP2 LDA #$0D ;RETURN JSR $FFD2 INX CPX #$0E ;14 LINES BNE CLRLOOP1 LDX #$02 LDY #$00 CLC JMP $FFF0 ;PLOT - SET CSR ;USE RTS IN SUB PRINTS2 JSR POSSTAT ;SETUP STAT BAR PS2L1 LDA S2,Y JSR $FFD2 LDA #$03 STA $D800,Y ;CYAN INY CPY #LS2 BNE PS2L1 JMP CLRSTAT ;END STAT BAR ;USE RTS IN SUB ;--------------------------------------- ;CHOOSE PARTITION GPART SEC JSR $FFF0 ;PLOT - GET CSR TAY PHA ;PUSH HORIZ TXA PHA ;PUSH VERT JSR PRINTS3 ;STAT BAR JSR SETBUFF ;DEFAULT ROOT PLA TAX ;PULL VERT PLA TAY ;PULL HORIZ CLC JSR $FFF0 ;PLOT - SET CSR LDY #$00 GPLOOP1 LDA ENTMSG,Y JSR $FFD2 INY CPY #LENTMSG BNE GPLOOP1 GPLOOP2 JSR $FFE4 ;SCAN KBD CMP #$4E ;N BNE GPFWY LDA #$4A ;SET NOT RDY STAT STA STAT RTS GPFWY CMP #$59 ;Y BNE GPLOOP2 LDA #$91 ;CSR UP JSR $FFD2 LDY #$00 GPLOOP3 LDA PNMSG,Y JSR $FFD2 INY CPY #LPNMSG BNE GPLOOP3 LDY #$00 GPLOOP4 LDA ROOT,Y JSR $FFD2 INY CPY #$01 BNE GPLOOP4 LDA #$9D ;CSR LEFT TO START GPLOOP5 JSR $FFD2 DEY BNE GPLOOP5 GPLOOP6 JSR $FFCF ;CHRIN CMP #$0D ;CHK FOR RETURN BEQ GPFWD STA NAMEBUFF,Y INY CPY #$10 ;16 CHR MAX BNE GPLOOP6 GPFWD RTS SETBUFF LDY #$00 ;SET NAMEBUFF TO SBLOOP1 LDA ROOT,Y ;ROOT AS DEFAULT STA NAMEBUFF,Y INY CPY #LROOT BNE SBLOOP1 LDA #$00 SBLOOP2 STA NAMEBUFF,Y INY CPY #$10 BNE SBLOOP2 RTS PRINTS3 JSR POSSTAT ;SETUP STAT BAR PS3L1 LDA S3,Y JSR $FFD2 LDA #$03 STA $D800,Y ;CYAN INY CPY #LS3 BNE PS3L1 JMP CLRSTAT ;END STAT BAR ;USE RTS IN SUB ;--------------------------------------- ;CHANGE PARTITION CPART LDY #$00 ;CHECK FOR QUIT LDA #$0D JSR $FFD2 CQLOOP LDA NAMEBUFF,Y CMP QUIT,Y BNE CPROOT INY CPY #LQUIT BNE CQLOOP LDA #$4A STA STAT RTS CPROOT LDY #$00 ;CHECK FOR ROOT CRLOOP LDA NAMEBUFF,Y CMP ROOT,Y BNE CPNAME INY CPY #LROOT BNE CRLOOP JMP GOROOT CPNAME LDA NUMPART BEQ NOPARTS JSR OCOMM ;OPEN COMM CHN LDX #$0F JSR $FFC9 ;CHKOUT LDY #$00 CPNLOOP1 LDA CD,Y JSR $FFD2 ;CHROUT INY CPY #LCD BNE CPNLOOP1 LDY #$00 CPNLOOP2 LDA NAMEBUFF,Y BEQ CPNEXIT ;IF CHR = $00 JSR $FFD2 INY CPY #$10 BNE CPNLOOP2 CPNEXIT JSR $FFCC ;CLRCHN JSR RSTAT ;READ STAT JMP CCOMM ;CLOSE COMM CHN ;USE RTS IN CCOMM NOPARTS LDY #$00 NPALOOP LDA NOPAMSG,Y JSR $FFD2 INY CPY #LNOPAMSG BNE NPALOOP GOROOT JSR OCOMM ;OPEN COMM CHN LDX #$0F JSR $FFC9 ;CHKOUT LDA CD ;/ (ROOT) JSR $FFD2 ;CHROUT JSR $FFCC ;CLRCHN JSR RSTAT ;READ STAT JMP CCOMM ;CLOSE COMM CHN ;USE RTS IN CCOMM ;--------------------------------------- ;GENERAL FUNCTIONS CLS LDA #$20 ;CLEAR ALL EXCEPT LDY #$28 ;STAT AND ERR ROW CLOOP1 STA $0400,Y INY BNE CLOOP1 CLOOP2 STA $0500,Y INY BNE CLOOP2 CLOOP3 STA $0600,Y INY BNE CLOOP3 CLOOP4 STA $0700,Y INY CPY #$C0 BNE CLOOP4 RTS OCOMM LDA #$00 ;NO FILENAME LDX #$00 LDY #$00 JSR $FFBD ;SETNAM LDA #$0F LDX DRIVE LDY #$0F JSR $FFBA ;SETLFS JMP $FFC0 ;OPEN ;USE JSR IN $FFC0 CCOMM LDA #$0F JMP $FFC3 ;CLOSE ;USE JSR IN $FFC3 RSTAT LDA #$01 ;1=RSTAT JMP RSTAT1 RERR JSR OCOMM LDA #$00 ;0=RERR PHA ;PUSH MARKER RSTAT1 BEQ RESKIP ;SKIP IF RSTAT PHA ;PUSH MARKER RESKIP SEC JSR $FFF0 ;PLOT - GET CSR TYA PHA ;PUSH HORIZ TXA PHA ;PUSH VERT CLC LDX #$18 LDY #$00 JSR $FFF0 ;SET CURSOR LDA #$12 JSR $FFD2 ;RVS ON LDA #$9E JSR $FFD2 ;YELLOW LDX #$0F JSR $FFC6 ;CHKIN JSR $FFCF ;CHRIN PHA ;PUSH TENS DIGIT JSR $FFD2 ;CHROUT JSR $FFCF ;CHRIN JSR $FFD2 ;CHROUT PHA ;PUSH ONES DIGIT ELOOP JSR $FFB7 ;READST BNE ECLOSE JSR $FFCF ;CHRIN CMP #$0D BEQ ECLOSE JSR $FFD2 ;CHROUT JMP ELOOP ECLOSE SEC JSR $FFF0 ;PLOT - GET CSR INY ;NEXT HORIZ PELOOP LDA #$A0 ;INV SPACE STA $07BF,Y LDA #$07 ;YELLOW STA $DBBF,Y INY CPY #$29 ;LAST SCR POS BNE PELOOP PLA ;PULL ONES DIGIT SEC SBC #$30 ;CHR->NUM STA STAT PLA ;PULL TENS DIGIT SBC #$30 ;CHR->NUM TAY LDA XTEN,Y ;MULTIPLY BY 10 CLC ADC STAT ;TENSÛONES STA STAT LDA #$92 ;RVS OFF JSR $FFD2 LDA #$05 ;WHITE TEXT JSR $FFD2 CLC PLA ;PULL VERT TAX PLA ;PULL HORIZ TAY JSR $FFF0 ;PLOT - SET CSR JSR $FFCC ;CLRCHN PLA ;PULL MARKER BNE RSEXIT ;SKIP IF RSTAT JMP CCOMM ;CLOSE COMM CHN RSEXIT RTS CHKPRES LDA #$00 ;NO FILENAME LDX #$00 LDY #$00 JSR $FFBD ;SETNAM LDA #$01 LDX DRIVE LDY #$01 JSR $FFBA ;SETLFS JSR $FFC0 ;OPEN LDA #$01 JSR $FFC3 ;CLOSE JSR $FFB7 ;READ STAT STA PRES ;ST=0 IF SUCCESS RTS POSSTAT LDA #$12 ;RVS ON JSR $FFD2 LDY #$00 LDX #$00 CLC JMP $FFF0 ;PLOT - SET CSR ;USE RTS IN $FFF0 CLRSTAT LDA #$A0 ;INV SPACE STA $0400,Y LDA #$03 ;CYAN STA $D800,Y INY CPY #$28 ;END OF SCR BNE CLRSTAT LDA #$92 ;INV OFF JMP $FFD2 ;USE RTS IN $FFD2 NUMCHAR CMP #$0A BCC NCAHEAD ;IF < 10 1 DIGIT TAX ;STORE NUMBER LDY #$09 NCLOOP CMP XTEN,Y ;90->1X BCS TENS ;IF XTEN,Y > A DEY JMP NCLOOP TENS TYA ;INDEX Y=TENS CLC ADC #$30 ;CONV TO CHAR JSR $FFD2 TXA ;RETURN NUMBER SEC ;SET CARRY SBC XTEN,Y ;SUBTRACT TENS CLC NCAHEAD ADC #$30 ;OFFSET FOR CHAR JMP $FFD2 ;USE RTS IN $FFD2 ;--------------------------------------- ;END OF CODE
; A083559: Nearest integer to 1/(Sum_{k>=n} 1/k^4). ; 1,12,50,134,280,507,834,1277,1855,2586,3489,4580,5878,7401,9168,11195,13501,16104,19023,22274,25876,29847,34206,38969,44155,49782,55869,62432,69490,77061,85164,93815,103033,112836,123243,134270,145936,158259,171258,184949,199351,214482,230361,247004,264430,282657,301704,321587,342325,363936,386439,409850,434188,459471,485718,512945,541171,570414,600693,632024,664426,697917,732516,768239,805105,843132,882339,922742,964360,1007211,1051314,1096685,1143343,1191306,1240593,1291220,1343206,1396569,1451328,1507499,1565101,1624152,1684671,1746674,1810180,1875207,1941774,2009897,2079595,2150886,2223789,2298320,2374498,2452341,2531868,2613095,2696041,2780724,2867163,2955374 mov $4,$0 mul $0,2 add $0,1 seq $0,24195 ; Integer part of (4th elementary symmetric function of S(n))/(3rd elementary symmetric of S(n)), where S(n) = {3,4, ..., n+5}. sub $0,1 add $0,$4 mov $3,$4 mul $3,$4 mov $2,$3 mul $2,4 add $0,$2 mul $3,$4 mov $2,$3 mul $2,3 add $0,$2
; A322462: Numbers on the 0-1-12 line in a spiral on a grid of equilateral triangles. ; 0,1,12,13,36,37,72,73,120,121,180,181,252,253,336,337,432,433,540,541,660,661,792,793,936,937,1092,1093,1260,1261,1440,1441,1632,1633,1836,1837,2052,2053,2280,2281,2520,2521,2772,2773,3036,3037,3312,3313,3600,3601,3900,3901,4212,4213,4536,4537,4872,4873,5220,5221,5580,5581,5952,5953,6336,6337,6732,6733,7140,7141,7560,7561,7992,7993,8436,8437,8892,8893,9360,9361,9840,9841,10332,10333,10836,10837,11352,11353,11880,11881,12420,12421,12972,12973,13536,13537,14112,14113,14700,14701,15300,15301,15912,15913,16536,16537,17172,17173,17820,17821,18480,18481,19152,19153,19836,19837,20532,20533,21240,21241,21960,21961,22692,22693,23436,23437,24192,24193,24960,24961,25740,25741,26532,26533,27336,27337,28152,28153,28980,28981,29820,29821,30672,30673,31536,31537,32412,32413,33300,33301,34200,34201,35112,35113,36036,36037,36972,36973,37920,37921,38880,38881,39852,39853,40836,40837,41832,41833,42840,42841,43860,43861,44892,44893,45936,45937,46992,46993,48060,48061,49140,49141,50232,50233,51336,51337,52452,52453,53580,53581,54720,54721,55872,55873,57036,57037,58212,58213,59400,59401,60600,60601,61812,61813,63036,63037,64272,64273,65520,65521,66780,66781,68052,68053,69336,69337,70632,70633,71940,71941,73260,73261,74592,74593,75936,75937,77292,77293,78660,78661,80040,80041,81432,81433,82836,82837,84252,84253,85680,85681,87120,87121,88572,88573,90036,90037,91512,91513,93000,93001 add $0,1 mov $1,$0 mov $2,1 mov $3,2 lpb $0 sub $0,1 trn $0,1 add $1,$3 add $1,$3 sub $1,$2 mov $2,6 add $3,6 lpe add $0,1 sub $1,3 sub $1,$0
[bits 16] ; INPUT: al = char putch: pusha mov ah, 0x0e int 0x10 popa ret ; INPUT: si = ptr to string printf: pusha mov ah, 0x0e .print_string_loop: lodsb cmp al, 0x0 je .print_string_done int 0x10 jmp .print_string_loop .print_string_done: popa ret print_nl: pusha mov ah, 0x0e mov al, 0x0a int 0x10 mov al, 0x0d int 0x10 popa ret ; INPUT: dx = decimal number hex_print: pusha mov cx, 0 ; our index variable ; Strategy: get the last char of 'dx', then convert to ASCII ; Numeric ASCII values: '0' (ASCII 0x30) to '9' (0x39), so just add 0x30 to byte N. ; For alphabetic characters A-F: 'A' (ASCII 0x41) to 'F' (0x46) we'll add 0x40 ; Then, move the ASCII byte to the correct position on the resulting string hex_loop: cmp cx, 4 ; loop 4 times je end ; 1. convert last char of 'dx' to ascii mov ax, dx ; we will use 'ax' as our working register and ax, 0x000f ; 0x1234 -> 0x0004 by masking first three to zeros add al, 0x30 ; add 0x30 to N to convert it to ASCII "N" cmp al, 0x39 ; if > 9, add extra 8 to represent 'A' to 'F' jle step2 add al, 7 ; 'A' is ASCII 65 instead of 58, so 65-58=7 step2: ; 2. get the correct position of the string to place our ASCII char ; bx <- base address + string length - index of char mov bx, HEX_OUT + 5 ; base + length sub bx, cx ; our index variable mov [bx], al ; copy the ASCII char on 'al' to the position pointed by 'bx' ror dx, 4 ; 0x1234 -> 0x4123 -> 0x3412 -> 0x2341 -> 0x1234 ;call putch ; increment index and loop add cx, 1 jmp hex_loop end: ; prepare the parameter and call the function ; remember that print receives parameters in 'bx' mov si, HEX_OUT call printf popa ret HEX_OUT: db '0x0000',0 ; reserve memory for our new string ; Clear Screen ; Assumes Text Page 0 and 80x50 text mode, if this is not the case edit the annoteded lines clear_screen: pusha mov ah, 0x07 mov al, 50 mov bh, 0x0F mov ch, 0 mov cl, 0 ; VIDEO MODE FORMAT: AAxBB, example mode 0x03 is 80x25, and we use 80x50 mov dh, 50 ; BB mov dl, 80 ; AA int 0x10 mov ah, 0x02 mov bh, 0 ; TEXT PAGE NUMBER mov dh, 0x00 mov dl, 0x00 int 0x10 popa ret
include xlibproc.inc include Wintab.inc PROC_TEMPLATE WTMgrCsrPressureResponse, 6, Wintab, -, 184
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r8 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_WC_ht+0x17a60, %rcx nop sub %r10, %r10 mov (%rcx), %rax and $44789, %rdi lea addresses_A_ht+0x1e160, %r8 nop nop nop nop and %rbp, %rbp mov (%r8), %r12 nop nop nop cmp $57023, %rax lea addresses_WT_ht+0x9160, %rbp nop and %rcx, %rcx mov (%rbp), %r10d dec %r8 lea addresses_normal_ht+0xc86c, %rsi lea addresses_A_ht+0x15020, %rdi nop nop xor $40001, %rbp mov $67, %rcx rep movsw nop dec %rbp lea addresses_normal_ht+0x801b, %r8 nop nop add %rsi, %rsi movw $0x6162, (%r8) cmp %r8, %r8 lea addresses_normal_ht+0xd860, %rsi lea addresses_A_ht+0xf060, %rdi nop inc %r10 mov $53, %rcx rep movsw nop nop nop nop nop add $26233, %rcx lea addresses_WC_ht+0x146a0, %r12 nop nop nop nop cmp %r8, %r8 movb (%r12), %al nop nop nop nop nop sub $15752, %rsi pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r8 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %rax push %rbp push %rcx push %rdi push %rsi // REPMOV mov $0x660, %rsi lea addresses_WT+0x97a0, %rdi nop nop nop add %r12, %r12 mov $123, %rcx rep movsb nop nop nop nop and $8014, %r10 // Store lea addresses_WC+0x3660, %r12 dec %rax mov $0x5152535455565758, %r10 movq %r10, %xmm6 movaps %xmm6, (%r12) nop nop nop nop and $34720, %rsi // Store lea addresses_UC+0x17860, %r10 nop nop nop nop cmp %r12, %r12 mov $0x5152535455565758, %rax movq %rax, %xmm7 vmovups %ymm7, (%r10) nop nop nop nop nop cmp $13755, %r10 // Faulty Load lea addresses_normal+0x1ee60, %rdi nop sub $36023, %r10 movups (%rdi), %xmm6 vpextrq $0, %xmm6, %rax lea oracles, %rbp and $0xff, %rax shlq $12, %rax mov (%rbp,%rax,1), %rax pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_P', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_WT', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC', 'same': False, 'size': 16, 'congruent': 10, 'NT': False, 'AVXalign': True}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC', 'same': False, 'size': 32, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_normal', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_WC_ht', 'same': True, 'size': 8, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A_ht', 'same': False, 'size': 8, 'congruent': 8, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'34': 11040} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
addi $x1, $x0, 0 addi $x2, $x0, 0 addi $x3, $x0, 0 addi $x4, $x0, 0 addi $x5, $x0, 0 addi $x6, $x0, 0 addi $x7, $x0, 0 addi $x8, $x0, 0 addi $x9, $x0, 0 addi $x10, $x0, 0 addi $x11, $x0, 0 addi $x12, $x0, 0 addi $x13, $x0, 0 addi $x14, $x0, 0 addi $x15, $x0, 0 addi $x16, $x0, 0 addi $x17, $x0, 0 addi $x18, $x0, 0 addi $x19, $x0, 0 addi $x20, $x0, 0 addi $x21, $x0, 0 addi $x22, $x0, 0 addi $x23, $x0, 0 addi $x24, $x0, 0 addi $x25, $x0, 0 addi $x26, $x0, 0 addi $x27, $x0, 0 addi $x28, $x0, 0 addi $x29, $x0, 0 addi $x30, $x0, 0 addi $x31, $x0, 0 # # # Begin Test li.e $e0, 0.5 li.e $e1, 0.5 li.e $e2, 0.5 li.e $e3, 2.5 li.e $e4, 1.5 li.e $e5, 3.5 ecol $x1, $x2
// ------------------------------------------------------------------------------------------------- // Copyright 2017 - NumScale SAS // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // ------------------------------------------------------------------------------------------------- /// bench for functor min in simd mode for std::uint32_t type with pedantic_. #include <simd_bench.hpp> #include <boost/simd/function/min.hpp> namespace nsb = ns::bench; namespace bs = boost::simd; DEFINE_BENCH_MAIN() { using T = bs::pack<std::uint32_t>; run<T>(bs::pedantic_(bs::min), nsbg::rand<T>(0, 10), nsbg::rand<T>(0, 10)); }
PUBLIC load_tiles ;============================================================== ; load_tiles(unsigned char *data, int index, int count, int bpp) ;============================================================== ; Loads the specified tileset into VRAM ;============================================================== .load_tiles ld hl, 2 add hl, sp ld a, (hl) ; bits per pixel inc hl inc hl ld c, (hl) ; number of tiles to load inc hl ld b, (hl) inc hl ld e, (hl) ; initial tile index inc hl ld d, (hl) inc hl push de ld e, (hl) ; location of tile data inc hl ld d, (hl) inc hl push de pop ix ; tile data pop hl ; initial index ld d, a ; bpp ; falls through to LoadTiles ;============================================================== ; Tile loader ;============================================================== ; Parameters: ; hl = tile number to start at ; ix = location of tile data ; bc = No. of tiles to load ; d = bits per pixel ;============================================================== LoadTiles: push af push bc push de push hl push ix ; Tell VDP where I want to write (hl<<5) sla l rl h sla l rl h sla l rl h sla l rl h sla l rl h ld a,l out ($bf),a ld a,h or $40 out ($bf),a ; I need to output bc*8 bytes so I need to modify bc (<<3) sla c rl b sla c rl b sla c rl b ; Write data _Loop: ; Restore counter ld e,d _DataLoop: ; Write byte ld a,(ix+0) out ($be),a dec e inc ix jp nz,_DataLoop ; Restore counter ld e,d _BlankLoop: ; Write blank data to fill up the rest of the tile definition inc e ld a,e cp 5 jp z,_NoMoreBlanks ld a,0 out ($be),a jp _BlankLoop _NoMoreBlanks: dec bc ld a,b or c jp nz,_Loop pop ix pop hl pop de pop bc pop af ret
; int ferror(FILE *stream) INCLUDE "clib_cfg.asm" SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _ferror EXTERN _ferror_fastcall _ferror: pop af pop hl push hl push af jp _ferror_fastcall ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _ferror EXTERN _ferror_unlocked defc _ferror = _ferror_unlocked ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
%DEFINE SANDBOX %include "var_header.inc" ; Header has global variable definitions for other modules %include "func_header.inc" ; Header has global function definitions for other modules ;------------------------------------------------------------- ; ; SINGLE THREAD FLOATING POINT MULTI-PRECISION CALCULATOR ; ; Sandbox area for temporary experiments ; ; File: sandbox.asm ; Module: sandbox.asm, sandbox.o ; Exec: calc-pi ; ;-------------------------------------------------------------- ; MIT License ; ; Copyright 2014-2020 David Bolenbaugh ; ; 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. ;------------------------------------------------------------- ; SandBox: ;------------------------------------------------- SECTION .data ; Section containing initialized data SandboxMsg: db 0xD, 0xA, " - - Sandbox Loaded - -", 0xD, 0xA, 0xA, db "Program: Calculate e result stored in X-Reg", 0xD, 0xA, 0xA, 00 SECTION .bss ; Section containing uninitialized data SandVar: resq 1 SECTION .text ; Section containing code ;------------------- ; ; Tiny Sandbox ; ;------------------- Sand: ; ------------------ ; Function goes here ; ------------------ mov rax, .sandmsg call StrOut ret .sandmsg: db "Sand: Tiny Sand Box - No program loaded", 0xD, 0xA, 0 ;------------------------------------------------- ; ; * * * S A N D B O X * * * * ; ; ;------------------------------------------------- SandBox: ;for breakpoint nop ;---- ; jmp BenchMark ; jmp TestFastPrint ;---- cmp rax, 1 je Sandbox_test_1 cmp rax, 2 je Sandbox_test_2 cmp rax, 3 je Timingloop mov rax, .Msg call StrOut ret .Msg: db "Sandbox: No function specified", 0xD, 0xA, 0 Sandbox_test_1: ; Generic register push push rax push rbx push rcx push rdx push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 ; ----------------------------------------------- ; ----------------------------------------------- ; Generic register pop pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rdx pop rcx pop rbx pop rax ret Sandbox_test_2: ; Generic register push push rax push rbx push rcx push rdx push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 ; ----------------------------------------------- ; ----------------------------------------------- ; Generic register pop pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rdi pop rsi pop rdx pop rcx pop rbx pop rax ret ;-------------------------------------- ; Benchmark time of functions ; ; Registers Reg0 and Ret1 are used ; to test arithmetic functions. ; Example long division time ; ------------------------------------ Timingloop: mov rcx, 1 ; get counter value ; ; ; Timing Loop ; .loop: ;------------------------------ ; mov rsi, HAND_ACC ; mov rdi, HAND_OPR ; call Right1BitAdjExp ;------------------------------ mov rsi, HAND_REG1 mov rdi, HAND_OPR call CopyVariable ; mov rsi, HAND_REG0 mov rdi, HAND_ACC call CopyVariable ;--------------------------------- ; mov rsi, HAND_ACC ; call ClearVariable ; mov rbx, FP_Acc+MAN_MSW_OFST ; Ruler-->FEDCBA9876543210 ; mov rax, 0x4000000000000000 ; and [rbx], rax call FP_Division loop .loop mov rsi, HAND_ACC mov rdi, HAND_XREG call CopyVariable ret
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 012C0A move.l A0, ($6ac,A5) 012C0E tst.b ($4dc,A5) [base+6AC, base+6AE] 012C90 movea.l ($6ac,A5), A0 012C94 move.w ($e,A0), D0 [base+6AC, base+6AE] 012CA6 move.l A0, ($6ac,A5) 012CAA rts [base+6AC, base+6AE] 012FEC movea.l ($6ac,A5), A0 012FF0 move.w ($8,A6), D2 [base+6AC, base+6AE] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, base+6FFE, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
; ; This file is automatically generated ; ; Do not edit!!! ; ; djm 12/2/2000 ; ; ZSock Lib function: sock_settos SECTION code_clib PUBLIC sock_settos PUBLIC _sock_settos EXTERN no_zsock INCLUDE "packages.def" INCLUDE "zsock.def" .sock_settos ._sock_settos ld a,r_sock_settos call_pkg(tcp_all) ret nc ; We failed..are we installed? cp rc_pnf scf ;signal error ret nz ;Internal error call_pkg(tcp_ayt) jr nc,sock_settos jp no_zsock
; A050506: Nearest integer to log(Fibonacci(n)). ; 1,1,2,2,3,3,4,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,30,30,30,31,31,32,32,33,33 mov $2,1 mul $2,$0 mov $0,3 mov $1,3 lpb $0,1 sub $0,1 add $1,$2 div $1,3 lpe add $1,1
section .text global _start _start: mov eax, 4 mov ebx, 1 mov ecx, wlcm_msg mov edx, wlc_len int 0x80 ; %eax Name %ebx %ecx %edx %esx %edi ; 3 sys_read unsigned int char * size_t - - mov eax, 3 mov ebx, 0 ; STDIN descriptor mov ecx, buff mov edx, 64 ; size for read int 0x80 mov eax, 4 mov ebx, 1 mov ecx, out_msg mov edx, out_len int 0x80 mov eax, 4 mov ebx, 1 mov ecx, buff mov edx, 64 ;size for write int 0x80 ; ret mov eax, 1 int 0x80 section .data wlcm_msg db "Please enter a msg:", 0xA wlc_len equ $ - wlcm_msg out_msg db "You entered this: " out_len equ $ - out_msg ; buffer: resb 64 ; reserve 64 bytes ; wordvar: resw 1 ; reserve a word ; realarray resq 10 ; array of ten reals ; ymmval: resy 1 ; one YMM register ; zmmvals: resz 32 ; 32 ZMM registers section .bss ; buff mem for vars, initialized by zeros buff resb 64 ; request N-bytes
#include <stdint.h> // this is the secret key stored inside the protected enclave memory uint64_t key[] = {0,-1llu,-1llu,0,0,-1llu, 2}; extern "C" int callback(); // stringify #define STR(x) #x // this is a macro wrapper to gernate code that behaves similar to // sgx-step zero and single stepping #define _SIM(_label, _out, _x) \ "mov " _out ", %%rbx \n" \ STR(_label)": \n" \ "mov %%rbx," _out " \n" \ _x "\n" \ "call callback \n" \ "cmp $0, %%rax \n" \ "jne " STR(_label)"b \n" // a wrapper for the _SIM macro which automatically creates a unique label per line #define SIM(_out, _x) _SIM(__LINE__, _out, _x) uint64_t victim() { uint64_t result = 0; asm volatile(R"( lea key(%%rip), %%r12 /* base pointer for the key array */ mov $0xdeadbeaf, %%r13 /* move in some constant X */ mov $1, %%r15 /* init Y */ loop: )" SIM("%%r14", "mov (%%r12), %%r14") /* read the key bit */ "cmp $0, %%r14 \n" /* conditional UNSAFE branch! */ "je .zero \n" ".one:" SIM("%%r15", "imul %%r15, %%r15") /* square */ SIM("%%r15", "imul %%r13, %%r15") /* multiply */ "jmp .end \n" /* end */ ".zero:" SIM("%%r15", "imul %%r13, %%r15") /* multiply */ ".end:" SIM("%%r12", "add $8, %%r12") /* increment key index */ R"( cmpq $2, (%%r12) jne loop mov %%r15, %[result] /* store result */ )" :[result]"=r"(result) : : "rbx", "rax", "r12", "r13", "r14", "r15" ); return result; }