text
stringlengths
1
1.05M
; A063087: Dimension of the space of weight 2n cusp forms for Gamma_0( 19 ). ; 1,4,8,10,14,18,20,24,28,30,34,38,40,44,48,50,54,58,60,64,68,70,74,78,80,84,88,90,94,98,100,104,108,110,114,118,120,124,128,130,134,138,140,144,148,150,154,158,160,164 mul $0,2 mov $1,1 trn $1,$0 add $1,$0 lpb $0 trn $0,3 add $1,2 lpe mov $0,$1
; A037593: Base 7 digits are, in order, the first n terms of the periodic sequence with initial period 1,0,3. ; Submitted by Jamie Morken(s4) ; 1,7,52,365,2555,17888,125217,876519,6135636,42949453,300646171,2104523200,14731662401,103121636807,721851457652,5052960203565,35370721424955,247595049974688,1733165349822817 seq $0,37548 ; Base 7 digits are, in order, the first n terms of the periodic sequence with initial period 1,2,2. add $0,4 mul $0,8 div $0,5 sub $0,6 div $0,2
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ #include <chrono> #include <thread> #include <vta/dpi/tsim.h> #if VM_TRACE #ifdef VM_TRACE_FST #include <verilated_fst_c.h> #else #include <verilated_vcd_c.h> #endif #endif #if VM_TRACE #define STRINGIZE(x) #x #define STRINGIZE_VALUE_OF(x) STRINGIZE(x) #endif static VTAContextHandle _ctx = nullptr; static VTASimDPIFunc _sim_dpi = nullptr; static VTAHostDPIFunc _host_dpi = nullptr; static VTAMemDPIFunc _mem_dpi = nullptr; void VTASimDPI(dpi8_t* wait, dpi8_t* exit) { assert(_sim_dpi != nullptr); (*_sim_dpi)(_ctx, wait, exit); } void VTAHostDPI(dpi8_t* req_valid, dpi8_t* req_opcode, dpi8_t* req_addr, dpi32_t* req_value, dpi8_t req_deq, dpi8_t resp_valid, dpi32_t resp_value) { assert(_host_dpi != nullptr); (*_host_dpi)(_ctx, req_valid, req_opcode, req_addr, req_value, req_deq, resp_valid, resp_value); } void VTAMemDPI(dpi8_t req_valid, dpi8_t req_opcode, dpi8_t req_len, dpi64_t req_addr, dpi8_t wr_valid, dpi64_t wr_value, dpi8_t* rd_valid, dpi64_t* rd_value, dpi8_t rd_ready) { assert(_mem_dpi != nullptr); (*_mem_dpi)(_ctx, req_valid, req_opcode, req_len, req_addr, wr_valid, wr_value, rd_valid, rd_value, rd_ready); } void VTADPIInit(VTAContextHandle handle, VTASimDPIFunc sim_dpi, VTAHostDPIFunc host_dpi, VTAMemDPIFunc mem_dpi) { _ctx = handle; _sim_dpi = sim_dpi; _host_dpi = host_dpi; _mem_dpi = mem_dpi; } // Override Verilator finish definition // VL_USER_FINISH needs to be defined when compiling Verilator code void vl_finish(const char* filename, int linenum, const char* hier) { Verilated::gotFinish(true); } int VTADPISim() { uint64_t trace_count = 0; Verilated::flushCall(); Verilated::gotFinish(false); #if VM_TRACE uint64_t start = 0; #endif VL_TSIM_NAME* top = new VL_TSIM_NAME; #if VM_TRACE Verilated::traceEverOn(true); #ifdef VM_TRACE_FST VerilatedFstC* tfp = new VerilatedFstC; #else VerilatedVcdC* tfp = new VerilatedVcdC; #endif // VM_TRACE_FST top->trace(tfp, 99); tfp->open(STRINGIZE_VALUE_OF(TSIM_TRACE_FILE)); #endif // reset for (int i = 0; i < 10; i++) { top->reset = 1; top->clock = 0; top->eval(); #if VM_TRACE if (trace_count >= start) tfp->dump(static_cast<vluint64_t>(trace_count * 2)); #endif top->clock = 1; top->eval(); #if VM_TRACE if (trace_count >= start) tfp->dump(static_cast<vluint64_t>(trace_count * 2 + 1)); #endif trace_count++; } top->reset = 0; // start simulation while (!Verilated::gotFinish()) { top->sim_clock = 0; top->clock = 0; top->eval(); #if VM_TRACE if (trace_count >= start) tfp->dump(static_cast<vluint64_t>(trace_count * 2)); #endif top->sim_clock = 1; top->clock = 1; top->eval(); #if VM_TRACE if (trace_count >= start) tfp->dump(static_cast<vluint64_t>(trace_count * 2 + 1)); #endif trace_count++; if ((trace_count % 1000000) == 1) fprintf(stderr, "[traced %luM cycles]\n", trace_count / 1000000); while (top->sim_wait) { top->clock = 0; std::this_thread::sleep_for(std::chrono::milliseconds(100)); top->sim_clock = 0; top->eval(); top->sim_clock = 1; top->eval(); } } #if VM_TRACE tfp->close(); #endif delete top; return 0; }
CNZ_Header: smpsHeaderStartSong 2, 1 smpsHeaderVoice CNZ_Voices smpsHeaderChan $06, $03 smpsHeaderTempo $01, $48 smpsHeaderDAC CNZ_DAC smpsHeaderFM CNZ_FM1, $0C, $08 smpsHeaderFM CNZ_FM2, $F4, $0A smpsHeaderFM CNZ_FM3, $F4, $12 smpsHeaderFM CNZ_FM4, $F4, $12 smpsHeaderFM CNZ_FM5, $F4, $0F smpsHeaderPSG CNZ_PSG1, $DC, $05, $00, $00 smpsHeaderPSG CNZ_PSG2, $DC, $05, $00, $00 smpsHeaderPSG CNZ_PSG3, $00, $04, $00, $00 ; FM1 Data CNZ_FM1: smpsSetvoice $00 dc.b nRst, $18 CNZ_Jump04: dc.b nC3, $06, nC2, nC3, nC2, nC3, nC2, nC3, nC2, nRst, nG1, $04 dc.b nRst, $02, nBb1, $04, nAb1, $06, nG1, $04, nRst, $02, nG2, $02 dc.b nG1, $06, nA1, nB1, nC2, $06, nB1, nA1, nG1, nC2, nG1, nC2 dc.b nD2, nE2, nD2, nC2, nB1, nE1, nFs1, nAb1, nE1, nA1, nA1, nE2 dc.b nE2, nA1, nB1, nC2, nA1, nAb1, nBb1, nC2, nD2, nEb2, $04, $02 dc.b nAb1, $06, nC2, nAb1, nC2, nC2, nD2, nEb2, nE2, $04, $02, nE1 dc.b $06, nFs1, nAb1, nA1, nA1, nG1, nG1, nF1, nC2, nF1, nA1, nRst dc.b nC2, nRst, nC2, nRst, nF2, nRst, nF2, nAb1, $0C, $06, nRst, $04 dc.b nG1, $04, nRst, $02, nG2, nF2, $06, nE2, nD2, nC2, $04, $02 dc.b nE1, $06, nF1, nFs1, nG1, nB1, nC2, nD2, nE2, nB1, nAb1, nFs1 dc.b nE1, nB1, nE2, nE1, nA1, nB1, nC2, nB1, nA1, nC2, nE2, nA1 dc.b nAb1, nBb1, nC2, nBb1, nAb1, nA1, nBb1, nB1, nC2, nB1, nC2, nD2 dc.b nE2, $04, $02, nB1, $06, nE1, nAb1, nA1, nB1, nC2, nE2, nF2 dc.b $04, nA1, $08, nBb1, $06, nB1, nRst, nC2, nRst, nC2, nRst, nF2 dc.b nRst, nF2 smpsAlterVol $04 dc.b nRst, nC2, nRst, nC2, nRst, nF2, nRst, nF2 smpsAlterVol $FC dc.b nRst, nC2, nRst, nC2, nRst, nF2, nRst, nF2, $04, nC2, $02, nRst dc.b $18, nC2, $02, nRst, nC2, nB1, $06, nA1, nG1 smpsJump CNZ_Jump04 ; FM3 Data CNZ_FM3: smpsSetvoice $02 smpsPan panLeft, $00 dc.b nRst, $18 CNZ_Jump03: smpsSetvoice $02 dc.b nRst, $06, nG5, nRst, nG5, nRst, nG5, nRst, nG5, nRst, nF5, $02 dc.b nRst, $04, nF5, $04, $02, nRst, $04, nF5, $02, nRst, $18 smpsCall CNZ_Call02 smpsSetvoice $01 smpsAlterPitch $F4 smpsAlterVol $FC smpsCall CNZ_Call03 dc.b nE6, $18, nD6, $0C, nE6, $06, nD6, nC6, $18, nF6, nRst, $06 dc.b nG5, nRst, nG5, nRst, nA5, nRst, nA5 smpsAlterVol $04 dc.b nRst, nG5, nRst, nG5, nRst, nA5, nRst, nA5 smpsAlterVol $FC dc.b nRst, nG5, nRst, nG5, nRst, nA5, $0C, $04, nG5, $02, nRst, $30 smpsAlterPitch $0C smpsAlterVol $04 smpsJump CNZ_Jump03 CNZ_Call02: dc.b nRst, $06, nG4, $02, nRst, $08, nG4, $02, nRst, $06, nG4, $08 dc.b nRst, $02, nG4, $06, nRst, $02, nG4, $04, $02, nRst, $06, nAb4 dc.b $02, nRst, $08, nAb4, $02, nRst, $06, nAb4, $08, nRst, $02, nAb4 dc.b $06, nRst, $02, nAb4, $04, $02, nRst, $06, nA4, $02, nRst, $08 dc.b nA4, $02, nRst, $06, nA4, $08, nRst, $02, nA4, $06, nRst, $02 dc.b nA4, $04, $02, nRst, $06, nAb4, $02, nRst, $08, nAb4, $02, nRst dc.b $06, nAb4, $08, nRst, $02, nAb4, $06, nRst, $02, nAb4, $04, $02 dc.b nRst, $06, nG4, $02, nRst, $08, nG4, $02, nRst, $06, nAb4, $08 dc.b nRst, $02, nAb4, $06, nRst, $02, nAb4, $04, $02, nRst, $06, nA4 dc.b $02, nRst, $08, nA4, $02, nRst, $06, nA4, $08, nRst, $02, nA4 dc.b $06, nRst, $02, nA4, $04, $02, nRst, $06, nG4, nRst, nG4, nRst dc.b nA4, nRst, nA4, nC5, $0C, $06, $04, nB4, $02, nRst, $18 smpsReturn CNZ_Call03: dc.b nRst, $06, nE6, $02, nRst, $08, nE6, $02, nRst, $06, nE6, $06 dc.b nF6, $04, nE6, $02, nRst, $0C, nRst, $06, nD6, $02, nRst, $08 dc.b nD6, $02, nRst, $06, nD6, $06, nE6, $04, nD6, $02, nRst, $0C dc.b nRst, $06, nC6, $02, nRst, $08, nC6, $02, nRst, $06, nC6, $06 dc.b nD6, $04, nC6, $02, nRst, $0C, nRst, $06, nC6, $02, nRst, $08 dc.b nC6, $02, nRst, $06, nC6, $06, nD6, $04, nC6, $02, nRst, $0C smpsReturn ; FM4 Data CNZ_FM4: smpsSetvoice $02 smpsPan panRight, $00 dc.b nRst, $18 CNZ_Jump02: smpsSetvoice $02 dc.b nRst, $06, nEb5, nRst, nEb5, nRst, nEb5, nRst, nEb5, nRst, nD5, $02 dc.b nRst, $04, nD5, $04, $02, nRst, $04, nD5, $02, nRst, $18 smpsCall CNZ_Call00 smpsSetvoice $01 smpsAlterPitch $F4 smpsAlterVol $FC smpsCall CNZ_Call01 dc.b nC6, $18, nB5, $0C, nC6, $06, nB5, nA5, $18, nC6, nRst, $06 dc.b nE5, nRst, nE5, nRst, nF5, nRst, nF5 smpsAlterVol $04 dc.b nRst, nE5, nRst, nE5, nRst, nF5, nRst, nF5 smpsAlterVol $FC dc.b nRst, nE5, nRst, nE5, nRst, nF5, $0C, $04, nE5, $02, nRst, $30 smpsAlterPitch $0C smpsAlterVol $04 smpsJump CNZ_Jump02 CNZ_Call00: dc.b nRst, $06, nE4, $02, nRst, $08, nE4, $02, nRst, $06, nE4, $08 dc.b nRst, $02, nE4, $06, nRst, $02, nE4, $04, $02 smpsLoop $00, $03, CNZ_Call00 dc.b nRst, $06, nEb4, $02, nRst, $08, nEb4, $02, nRst, $06, nEb4, $08 dc.b nRst, $02, nEb4, $06, nRst, $02, nEb4, $04, $02, nRst, $06, nE4 dc.b $02, nRst, $08, nE4, $02, nRst, $06, nE4, $08, nRst, $02, nE4 dc.b $06, nRst, $02, nE4, $04, $02, nRst, $06, nE4, $02, nRst, $08 dc.b nE4, $02, nRst, $06, nF4, $08, nRst, $02, nF4, $06, nRst, $02 dc.b nF4, $04, $02, nRst, $06, nE4, nRst, nE4, nRst, nF4, nRst, nF4 dc.b nAb4, $0C, $06, $04, nG4, $02, nRst, $18 smpsReturn CNZ_Call01: dc.b nRst, $06, nC6, $02, nRst, $08, nC6, $02, nRst, $06, nC6, $06 dc.b nD6, $04, nC6, $02, nRst, $0C, nRst, $06, nB5, $02, nRst, $08 dc.b nB5, $02, nRst, $06, nB5, $06, nC6, $04, nB5, $02, nRst, $0C dc.b nRst, $06, nA5, $02, nRst, $08, nA5, $02, nRst, $06, nA5, $06 dc.b nB5, $04, nA5, $02, nRst, $0C, nRst, $06, nAb5, $02, nRst, $08 dc.b nAb5, $02, nRst, $06, nAb5, $06, nBb5, $04, nAb5, $02, nRst, $0C smpsReturn ; FM2 Data CNZ_FM2: smpsSetvoice $01 smpsModSet $1C, $01, $06, $04 dc.b nRst, $18 CNZ_Jump01: smpsSetvoice $01 dc.b nRst, $06, nEb5, $0C, nC5, $02, nRst, $04, nFs5, nF5, $02, nRst dc.b $04, nEb5, $02, nRst, $04, nC5, $08, nRst, $06, nG4, $02, nRst dc.b $04, nBb4, nAb4, $02, nRst, $04, nG4, $02, nRst, $0C, nE4, $04 dc.b nRst, $02, nE4, $04, nRst, $02, nE4, $18, nRst, $06, nE4, $04 dc.b nRst, $02, nF4, $04, nE4, $08, nAb4, $04, $02, nRst, $04, nE4 dc.b $1A, nRst, $06, nE4, nA4, $04, $02, nRst, $04, nE4, $02, nC4 dc.b $12, nRst, $06, nC4, $04, nRst, $02, nD4, $04, nC4, $02, nEb4 dc.b $06, nD4, $04, nC4, $26, nRst, $06, nE4, $04, nRst, $02, nF4 dc.b $04, nRst, $02, nE4, $04, nRst, $02, nAb4, $04, $02, nRst, $04 dc.b nE4, $0E, nRst, $06, nA4, $0C, nB4, $04, nA4, $02, nC5, $0C dc.b nRst, $06, nA4, $02, nRst, $04, nG4, $0C, nE4, nC4, nD4, nEb4 dc.b nF4, $04, nEb4, $02, nF4, $04, nG4, $02, nRst, $10, nG3, $02 dc.b nA3, $04, nC4, $02, nE4, $18, nRst, $06, nE4, $04, nRst, $02 dc.b nF4, $04, nE4, $08, nAb4, $04, $02, nRst, $04, nE4, $1A, nRst dc.b $06, nE4, nA4, $04, $02, nRst, $04, nE4, $02, nC4, $12, nRst dc.b $06, nC4, $04, nRst, $02, nD4, $04, nC4, $02, nEb4, $06, nD4 dc.b $04, nC4, $26, nRst, $06, nE4, $04, nRst, $02, nF4, $04, nRst dc.b $02, nE4, $04, nRst, $02, nAb4, $04, $02, nRst, $04, nE4, $0E dc.b nRst, $06, nA4, $0C, nB4, $04, nA4, $02, nC5, $0C, nRst, $06 dc.b nA4, $02, nRst, $04, nG4, $0C, nE4, nC4, nD4, $06 smpsAlterVol $04 dc.b nA4, $02, nRst, $04, nG4, $0C, nE4, nC4, nD4, $06 smpsAlterVol $FC dc.b nA4, $02, nRst, $04, nG4, $0C, nE4, nC4, nD4, $0A, nC4, $02 dc.b nRst, $30 smpsJump CNZ_Jump01 ; FM5 Data CNZ_FM5: smpsSetvoice $01 dc.b nRst, $18 smpsModSet $1C, $01, $06, $04 CNZ_Jump00: smpsSetvoice $01 dc.b nRst, $06, nC5, $0C, nG4, $02, nRst, $04, nEb5, nD5, $02, nRst dc.b $04, nC5, $02, nRst, $04, nG4, $08, nRst, $06, nD4, $02, nRst dc.b $04, nF4, nEb4, $02, nRst, $04, nD4, $02, nRst, $0C, nA3, $04 dc.b nRst, $02, nB3, $04, nRst, $02, nC4, $18, nRst, $06, nC4, $04 dc.b nRst, $02, nD4, $04, nC4, $08, nE4, $04, nE4, $02, nRst, $04 dc.b nB3, $1A, nRst, $06, nB3, nE4, $04, $02, nRst, $04, nC4, $02 dc.b nA3, $12, nRst, $06, nA3, $04, nRst, $02, nB3, $04, nA3, $02 dc.b nC4, $06, nBb3, $04, nAb3, $26, nRst, $06, nC4, $04, nRst, $02 dc.b nD4, $04, nRst, $02, nC4, $04, nRst, $02, nE4, $04, nE4, $02 dc.b nRst, $04, nB3, $0E, nRst, $06, nE4, $0C, nG4, $04, nE4, $02 dc.b nA4, $0C, nRst, $06, nF4, $02, nRst, $04, nE4, $0C, nC4, nA3 dc.b nB3, nC4, nD4, $04, nC4, $02, nD4, $04, nD4, $02, nRst, $10 dc.b nD3, $02, nE3, $04, nG3, $02, nC4, $18, nRst, $06, nC4, $04 dc.b nRst, $02, nD4, $04, nC4, $08, nE4, $04, nE4, $02, nRst, $04 dc.b nB3, $1A, nRst, $06, nB3, nE4, $04, $02, nRst, $04, nC4, $02 dc.b nA3, $12, nRst, $06, nA3, $04, nRst, $02, nB3, $04, nA3, $02 dc.b nC4, $06, nBb3, $04, nAb3, $26, nRst, $06, nC4, $04, nRst, $02 dc.b nD4, $04, nRst, $02, nC4, $04, nRst, $02, nE4, $04, nE4, $02 dc.b nRst, $04, nB3, $0E, nRst, $06, nE4, $0C, nG4, $04, nE4, $02 dc.b nA4, $0C, nRst, $06, nF4, $02, nRst, $04, nE4, $0C, nC4, nA3 dc.b nB3, $06 smpsAlterVol $04 dc.b nF4, $02, nRst, $04, nE4, $0C, nC4, nA3, nB3, $06 smpsAlterVol $F8 dc.b nF4, $02, nRst, $04, nE4, $0C, nC4, nA3, nF3, $0A, nE3, $02 dc.b nRst, $30 smpsAlterVol $04 smpsJump CNZ_Jump00 ; PSG1 Data CNZ_PSG1: dc.b nRst, $18 CNZ_Jump06: dc.b nRst, $06, nG4, $0C, nEb4, $02, nRst, $04, nA4, nAb4, $02, nRst dc.b $04, nG4, $02, nRst, $04, nEb4, $08, nRst, $06, nB3, $02, nRst dc.b $04, nD4, nC4, $02, nRst, $04, nB3, $02, nRst, $18 smpsPSGvoice fTone_01 smpsPSGAlterVol $FF smpsCall CNZ_Call02 smpsPSGAlterVol $01 smpsPSGvoice $00 smpsAlterPitch $E8 smpsCall CNZ_Call03 smpsAlterPitch $18 smpsPSGAlterVol $02 dc.b nE4, $18, nD4, $0C, nE4, $06, nD4, nC4, $18, nF4 smpsPSGAlterVol $FE dc.b nRst, $06, nG4, nRst, nG4, nRst, nA4, nRst, nA4 smpsPSGAlterVol $03 dc.b nG5, $0C, nE5, nC5, nD5, $06, nRst smpsPSGAlterVol $FC dc.b nRst, nG4, nRst, nG4, nRst, nA4, $0C, $04, nG4, $02, nRst, $30 smpsPSGAlterVol $01 smpsJump CNZ_Jump06 ; PSG2 Data CNZ_PSG2: dc.b nRst, $18 CNZ_Jump05: dc.b nRst, $06, nEb5, $0C, nC5, $02, nRst, $04, nFs5, nF5, $02, nRst dc.b $04, nEb5, $02, nRst, $04, nC5, $08, nRst, $06, nG4, $02, nRst dc.b $04, nBb4, nAb4, $02, nRst, $04, nG4, $02, nRst, $18 smpsPSGvoice fTone_01 smpsPSGAlterVol $FF smpsCall CNZ_Call00 smpsPSGAlterVol $01 smpsPSGvoice $00 smpsAlterPitch $E8 smpsCall CNZ_Call01 smpsAlterPitch $18 smpsPSGAlterVol $02 dc.b nC4, $18, nB3, $0C, nC4, $06, nB3, nA3, $18, nC4 smpsPSGAlterVol $FE dc.b nRst, $06, nE4, nRst, nE4, nRst, nF4, nRst, nF4 smpsPSGAlterVol $03 dc.b nRst, nC4, nRst, nC4, nRst, nC4, nRst, nC4 smpsPSGAlterVol $FC dc.b nRst, nC4, nRst, nC4, nRst, nC4, $0C, $04, nC4, $02 smpsPSGAlterVol $01 dc.b nRst, $30 smpsJump CNZ_Jump05 ; PSG3 Data CNZ_PSG3: smpsPSGform $E7 dc.b nRst, $18 CNZ_Loop03: smpsCall CNZ_Call04 smpsLoop $01, $07, CNZ_Loop03 dc.b $04, $02, $04, $02 CNZ_Loop04: smpsCall CNZ_Call04 smpsLoop $01, $1F, CNZ_Loop04 dc.b $04, $02, $04, $02 CNZ_Loop05: smpsCall CNZ_Call04 smpsLoop $01, $24, CNZ_Loop05 dc.b nRst, $30 smpsJump CNZ_Loop03 CNZ_Call04: smpsPSGvoice fTone_01 dc.b nMaxPSG, $06 smpsPSGvoice fTone_02 smpsPSGAlterVol $FF dc.b $04 smpsPSGvoice fTone_01 smpsPSGAlterVol $01 dc.b $02 smpsReturn ; DAC Data CNZ_DAC: dc.b dKick, $06, dKick, dKick, $04, dSnare, $02, $06 CNZ_Loop00: dc.b dKick, $06, dSnare smpsLoop $00, $04, CNZ_Loop00 dc.b dKick, $06, dSnare, dSnare, $04, $06, $06, dKick, $02, $06, $06, dSnare CNZ_Loop01: dc.b dKick, dSnare smpsLoop $00, $1C, CNZ_Loop01 dc.b dKick, dSnare, dSnare, $04, $06, $06, dKick, $02, $06, $06, dSnare CNZ_Loop02: dc.b dKick, dSnare smpsLoop $00, $20, CNZ_Loop02 dc.b dKick, dSnare, dKick, dSnare, dKick, dSnare, dSnare, $04, $06, $02, nRst, $28 dc.b dSnare, $02, $06 smpsJump CNZ_Loop00 CNZ_Voices: ; Voice $00 ; $3A ; $20, $23, $60, $01, $1E, $1F, $1F, $1F, $0A, $0A, $0B, $0A ; $05, $07, $0A, $08, $A4, $85, $96, $78, $21, $25, $28, $00 smpsVcAlgorithm $02 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $00, $06, $02, $02 smpsVcCoarseFreq $01, $00, $03, $00 smpsVcRateScale $00, $00, $00, $00 smpsVcAttackRate $1F, $1F, $1F, $1E smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $0A, $0B, $0A, $0A smpsVcDecayRate2 $08, $0A, $07, $05 smpsVcDecayLevel $07, $09, $08, $0A smpsVcReleaseRate $08, $06, $05, $04 smpsVcTotalLevel $00, $28, $25, $21 ; Voice $01 ; $3A ; $32, $56, $32, $42, $8D, $4F, $15, $52, $06, $08, $07, $04 ; $02, $00, $00, $00, $18, $18, $28, $28, $19, $20, $2A, $00 smpsVcAlgorithm $02 smpsVcFeedback $07 smpsVcUnusedBits $00 smpsVcDetune $04, $03, $05, $03 smpsVcCoarseFreq $02, $02, $06, $02 smpsVcRateScale $01, $00, $01, $02 smpsVcAttackRate $12, $15, $0F, $0D smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $04, $07, $08, $06 smpsVcDecayRate2 $00, $00, $00, $02 smpsVcDecayLevel $02, $02, $01, $01 smpsVcReleaseRate $08, $08, $08, $08 smpsVcTotalLevel $00, $2A, $20, $19 ; Voice $02 ; $2C ; $61, $03, $01, $33, $5F, $94, $5F, $94, $05, $05, $05, $07 ; $02, $02, $02, $02, $1F, $6F, $1F, $AF, $1E, $80, $1E, $80 smpsVcAlgorithm $04 smpsVcFeedback $05 smpsVcUnusedBits $00 smpsVcDetune $03, $00, $00, $06 smpsVcCoarseFreq $03, $01, $03, $01 smpsVcRateScale $02, $01, $02, $01 smpsVcAttackRate $14, $1F, $14, $1F smpsVcAmpMod $00, $00, $00, $00 smpsVcDecayRate1 $07, $05, $05, $05 smpsVcDecayRate2 $02, $02, $02, $02 smpsVcDecayLevel $0A, $01, $06, $01 smpsVcReleaseRate $0F, $0F, $0F, $0F smpsVcTotalLevel $80, $1E, $80, $1E
TITLE cast-586.asm IF @Version LT 800 ECHO MASM version 8.00 or later is strongly recommended. ENDIF .686 .MODEL FLAT OPTION DOTNAME IF @Version LT 800 .text$ SEGMENT PAGE 'CODE' ELSE .text$ SEGMENT ALIGN(64) 'CODE' ENDIF EXTERN _CAST_S_table0:NEAR EXTERN _CAST_S_table1:NEAR EXTERN _CAST_S_table2:NEAR EXTERN _CAST_S_table3:NEAR ALIGN 16 _CAST_encrypt PROC PUBLIC $L_CAST_encrypt_begin:: ; push ebp push ebx mov ebx,DWORD PTR 12[esp] mov ebp,DWORD PTR 16[esp] push esi push edi ; Load the 2 words mov edi,DWORD PTR [ebx] mov esi,DWORD PTR 4[ebx] ; Get short key flag mov eax,DWORD PTR 128[ebp] push eax xor eax,eax ; round 0 mov edx,DWORD PTR [ebp] mov ecx,DWORD PTR 4[ebp] add edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor edi,ecx ; round 1 mov edx,DWORD PTR 8[ebp] mov ecx,DWORD PTR 12[ebp] xor edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor esi,ecx ; round 2 mov edx,DWORD PTR 16[ebp] mov ecx,DWORD PTR 20[ebp] sub edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor edi,ecx ; round 3 mov edx,DWORD PTR 24[ebp] mov ecx,DWORD PTR 28[ebp] add edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor esi,ecx ; round 4 mov edx,DWORD PTR 32[ebp] mov ecx,DWORD PTR 36[ebp] xor edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor edi,ecx ; round 5 mov edx,DWORD PTR 40[ebp] mov ecx,DWORD PTR 44[ebp] sub edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor esi,ecx ; round 6 mov edx,DWORD PTR 48[ebp] mov ecx,DWORD PTR 52[ebp] add edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor edi,ecx ; round 7 mov edx,DWORD PTR 56[ebp] mov ecx,DWORD PTR 60[ebp] xor edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor esi,ecx ; round 8 mov edx,DWORD PTR 64[ebp] mov ecx,DWORD PTR 68[ebp] sub edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor edi,ecx ; round 9 mov edx,DWORD PTR 72[ebp] mov ecx,DWORD PTR 76[ebp] add edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor esi,ecx ; round 10 mov edx,DWORD PTR 80[ebp] mov ecx,DWORD PTR 84[ebp] xor edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor edi,ecx ; round 11 mov edx,DWORD PTR 88[ebp] mov ecx,DWORD PTR 92[ebp] sub edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor esi,ecx ; test short key flag pop edx or edx,edx jnz $L000cast_enc_done ; round 12 mov edx,DWORD PTR 96[ebp] mov ecx,DWORD PTR 100[ebp] add edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor edi,ecx ; round 13 mov edx,DWORD PTR 104[ebp] mov ecx,DWORD PTR 108[ebp] xor edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor esi,ecx ; round 14 mov edx,DWORD PTR 112[ebp] mov ecx,DWORD PTR 116[ebp] sub edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor edi,ecx ; round 15 mov edx,DWORD PTR 120[ebp] mov ecx,DWORD PTR 124[ebp] add edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor esi,ecx $L000cast_enc_done: nop mov eax,DWORD PTR 20[esp] mov DWORD PTR 4[eax],edi mov DWORD PTR [eax],esi pop edi pop esi pop ebx pop ebp ret _CAST_encrypt ENDP EXTERN _CAST_S_table0:NEAR EXTERN _CAST_S_table1:NEAR EXTERN _CAST_S_table2:NEAR EXTERN _CAST_S_table3:NEAR ALIGN 16 _CAST_decrypt PROC PUBLIC $L_CAST_decrypt_begin:: ; push ebp push ebx mov ebx,DWORD PTR 12[esp] mov ebp,DWORD PTR 16[esp] push esi push edi ; Load the 2 words mov edi,DWORD PTR [ebx] mov esi,DWORD PTR 4[ebx] ; Get short key flag mov eax,DWORD PTR 128[ebp] or eax,eax jnz $L001cast_dec_skip xor eax,eax ; round 15 mov edx,DWORD PTR 120[ebp] mov ecx,DWORD PTR 124[ebp] add edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor edi,ecx ; round 14 mov edx,DWORD PTR 112[ebp] mov ecx,DWORD PTR 116[ebp] sub edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor esi,ecx ; round 13 mov edx,DWORD PTR 104[ebp] mov ecx,DWORD PTR 108[ebp] xor edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor edi,ecx ; round 12 mov edx,DWORD PTR 96[ebp] mov ecx,DWORD PTR 100[ebp] add edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor esi,ecx $L001cast_dec_skip: ; round 11 mov edx,DWORD PTR 88[ebp] mov ecx,DWORD PTR 92[ebp] sub edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor edi,ecx ; round 10 mov edx,DWORD PTR 80[ebp] mov ecx,DWORD PTR 84[ebp] xor edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor esi,ecx ; round 9 mov edx,DWORD PTR 72[ebp] mov ecx,DWORD PTR 76[ebp] add edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor edi,ecx ; round 8 mov edx,DWORD PTR 64[ebp] mov ecx,DWORD PTR 68[ebp] sub edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor esi,ecx ; round 7 mov edx,DWORD PTR 56[ebp] mov ecx,DWORD PTR 60[ebp] xor edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor edi,ecx ; round 6 mov edx,DWORD PTR 48[ebp] mov ecx,DWORD PTR 52[ebp] add edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor esi,ecx ; round 5 mov edx,DWORD PTR 40[ebp] mov ecx,DWORD PTR 44[ebp] sub edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor edi,ecx ; round 4 mov edx,DWORD PTR 32[ebp] mov ecx,DWORD PTR 36[ebp] xor edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor esi,ecx ; round 3 mov edx,DWORD PTR 24[ebp] mov ecx,DWORD PTR 28[ebp] add edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor edi,ecx ; round 2 mov edx,DWORD PTR 16[ebp] mov ecx,DWORD PTR 20[ebp] sub edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] sub ecx,ebx xor esi,ecx ; round 1 mov edx,DWORD PTR 8[ebp] mov ecx,DWORD PTR 12[ebp] xor edx,esi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] add ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] xor ecx,ebx xor edi,ecx ; round 0 mov edx,DWORD PTR [ebp] mov ecx,DWORD PTR 4[ebp] add edx,edi rol edx,cl mov ebx,edx xor ecx,ecx mov cl,dh and ebx,255 shr edx,16 xor eax,eax mov al,dh and edx,255 mov ecx,DWORD PTR _CAST_S_table0[ecx*4] mov ebx,DWORD PTR _CAST_S_table1[ebx*4] xor ecx,ebx mov ebx,DWORD PTR _CAST_S_table2[eax*4] sub ecx,ebx mov ebx,DWORD PTR _CAST_S_table3[edx*4] add ecx,ebx xor esi,ecx nop mov eax,DWORD PTR 20[esp] mov DWORD PTR 4[eax],edi mov DWORD PTR [eax],esi pop edi pop esi pop ebx pop ebp ret _CAST_decrypt ENDP ALIGN 16 _CAST_cbc_encrypt PROC PUBLIC $L_CAST_cbc_encrypt_begin:: ; push ebp push ebx push esi push edi mov ebp,DWORD PTR 28[esp] ; getting iv ptr from parameter 4 mov ebx,DWORD PTR 36[esp] mov esi,DWORD PTR [ebx] mov edi,DWORD PTR 4[ebx] push edi push esi push edi push esi mov ebx,esp mov esi,DWORD PTR 36[esp] mov edi,DWORD PTR 40[esp] ; getting encrypt flag from parameter 5 mov ecx,DWORD PTR 56[esp] ; get and push parameter 3 mov eax,DWORD PTR 48[esp] push eax push ebx cmp ecx,0 jz $L002decrypt and ebp,4294967288 mov eax,DWORD PTR 8[esp] mov ebx,DWORD PTR 12[esp] jz $L003encrypt_finish $L004encrypt_loop: mov ecx,DWORD PTR [esi] mov edx,DWORD PTR 4[esi] xor eax,ecx xor ebx,edx bswap eax bswap ebx mov DWORD PTR 8[esp],eax mov DWORD PTR 12[esp],ebx call $L_CAST_encrypt_begin mov eax,DWORD PTR 8[esp] mov ebx,DWORD PTR 12[esp] bswap eax bswap ebx mov DWORD PTR [edi],eax mov DWORD PTR 4[edi],ebx add esi,8 add edi,8 sub ebp,8 jnz $L004encrypt_loop $L003encrypt_finish: mov ebp,DWORD PTR 52[esp] and ebp,7 jz $L005finish call $L006PIC_point $L006PIC_point: pop edx lea ecx,DWORD PTR ($L007cbc_enc_jmp_table-$L006PIC_point)[edx] mov ebp,DWORD PTR [ebp*4+ecx] add ebp,edx xor ecx,ecx xor edx,edx jmp ebp $L008ej7: mov dh,BYTE PTR 6[esi] shl edx,8 $L009ej6: mov dh,BYTE PTR 5[esi] $L010ej5: mov dl,BYTE PTR 4[esi] $L011ej4: mov ecx,DWORD PTR [esi] jmp $L012ejend $L013ej3: mov ch,BYTE PTR 2[esi] shl ecx,8 $L014ej2: mov ch,BYTE PTR 1[esi] $L015ej1: mov cl,BYTE PTR [esi] $L012ejend: xor eax,ecx xor ebx,edx bswap eax bswap ebx mov DWORD PTR 8[esp],eax mov DWORD PTR 12[esp],ebx call $L_CAST_encrypt_begin mov eax,DWORD PTR 8[esp] mov ebx,DWORD PTR 12[esp] bswap eax bswap ebx mov DWORD PTR [edi],eax mov DWORD PTR 4[edi],ebx jmp $L005finish $L002decrypt: and ebp,4294967288 mov eax,DWORD PTR 16[esp] mov ebx,DWORD PTR 20[esp] jz $L016decrypt_finish $L017decrypt_loop: mov eax,DWORD PTR [esi] mov ebx,DWORD PTR 4[esi] bswap eax bswap ebx mov DWORD PTR 8[esp],eax mov DWORD PTR 12[esp],ebx call $L_CAST_decrypt_begin mov eax,DWORD PTR 8[esp] mov ebx,DWORD PTR 12[esp] bswap eax bswap ebx mov ecx,DWORD PTR 16[esp] mov edx,DWORD PTR 20[esp] xor ecx,eax xor edx,ebx mov eax,DWORD PTR [esi] mov ebx,DWORD PTR 4[esi] mov DWORD PTR [edi],ecx mov DWORD PTR 4[edi],edx mov DWORD PTR 16[esp],eax mov DWORD PTR 20[esp],ebx add esi,8 add edi,8 sub ebp,8 jnz $L017decrypt_loop $L016decrypt_finish: mov ebp,DWORD PTR 52[esp] and ebp,7 jz $L005finish mov eax,DWORD PTR [esi] mov ebx,DWORD PTR 4[esi] bswap eax bswap ebx mov DWORD PTR 8[esp],eax mov DWORD PTR 12[esp],ebx call $L_CAST_decrypt_begin mov eax,DWORD PTR 8[esp] mov ebx,DWORD PTR 12[esp] bswap eax bswap ebx mov ecx,DWORD PTR 16[esp] mov edx,DWORD PTR 20[esp] xor ecx,eax xor edx,ebx mov eax,DWORD PTR [esi] mov ebx,DWORD PTR 4[esi] $L018dj7: ror edx,16 mov BYTE PTR 6[edi],dl shr edx,16 $L019dj6: mov BYTE PTR 5[edi],dh $L020dj5: mov BYTE PTR 4[edi],dl $L021dj4: mov DWORD PTR [edi],ecx jmp $L022djend $L023dj3: ror ecx,16 mov BYTE PTR 2[edi],cl shl ecx,16 $L024dj2: mov BYTE PTR 1[esi],ch $L025dj1: mov BYTE PTR [esi],cl $L022djend: jmp $L005finish $L005finish: mov ecx,DWORD PTR 60[esp] add esp,24 mov DWORD PTR [ecx],eax mov DWORD PTR 4[ecx],ebx pop edi pop esi pop ebx pop ebp ret ALIGN 64 $L007cbc_enc_jmp_table: DD 0 DD $L015ej1-$L006PIC_point DD $L014ej2-$L006PIC_point DD $L013ej3-$L006PIC_point DD $L011ej4-$L006PIC_point DD $L010ej5-$L006PIC_point DD $L009ej6-$L006PIC_point DD $L008ej7-$L006PIC_point ALIGN 64 _CAST_cbc_encrypt ENDP .text$ ENDS END
; A286690: Positions of 1 in A286688; complement of A286689. ; 5,11,19,25,33,39,45,53,59,67,73,79,87,93,101,107,115,121,127,135,141,149,155,161,169,175,183,189,197,203,209,217,223,231,237,243,251,257,265,271,277,285,291,299,305,313,319,325,333,339,347,353,359,367,373,381,387,395,401,407,415,421,429,435,441,449,455,463,469,475,483,489,497,503,511,517,523,531,537,545,551,557,565,571,579,585,593,599,605,613,619,627,633,639,647,653,661,667,675,681 mov $2,$0 seq $0,80754 ; a(n) = ceiling(n*(1+sqrt(2))). add $0,$2 mul $0,2 sub $0,1
; A022361: Fibonacci sequence beginning 0, 27. ; Submitted by Jon Maiga ; 0,27,27,54,81,135,216,351,567,918,1485,2403,3888,6291,10179,16470,26649,43119,69768,112887,182655,295542,478197,773739,1251936,2025675,3277611,5303286,8580897,13884183,22465080,36349263,58814343,95163606,153977949,249141555,403119504,652261059,1055380563,1707641622,2763022185,4470663807,7233685992,11704349799,18938035791,30642385590,49580421381,80222806971,129803228352,210026035323,339829263675,549855298998,889684562673,1439539861671,2329224424344,3768764286015,6097988710359,9866752996374 mov $3,1 lpb $0 sub $0,1 mov $2,$3 add $3,$1 mov $1,$2 lpe mov $0,$1 mul $0,27
; A064090: Generalized Catalan numbers C(7; n). ; Submitted by Jon Maiga ; 1,1,8,113,1982,38886,817062,17981769,409186310,9549411950,227307541448,5497312072330,134696099554276,3336563455537768,83419226227330722,2102274863070771033,53347639317495439302,1361987551028758981398,34958891897202640071552,901599097646780732893758,23352055996133415589441572,607168375989915952569780228,15841926233176310380622177292,414653540675476140286231898538,10884854946555482350381104045852,286494186567344137072356078407436,7559155343293426804604473064499152 mov $1,1 mov $3,$0 lpb $3 mov $0,$1 mul $0,-14 mul $1,7 sub $3,1 mul $1,$3 add $2,1 div $1,$2 add $4,$1 sub $1,$0 lpe mov $0,$4 add $0,1
; A320524: Number of chiral pairs of a row of n colors using 6 or fewer colors. ; 0,15,90,630,3780,23220,139320,839160,5034960,30229200,181375200,1088367840,6530207040,39181942080,235091652480,1410554113920,8463324683520,50779973295360,304679839772160,1828079189798400,10968475138790400,65810851739735040,394865110438410240,2369190668072417280,14215144008434503680,85290864083258757120 mov $3,$0 div $0,2 mov $1,6 pow $1,$3 mov $2,6 pow $2,$0 sub $1,$2 div $1,5 mul $1,15 mov $0,$1
//===- Utils.cpp ---- Misc utilities for code and data transformation -----===// // // Copyright 2019 The MLIR Authors. // // 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. // ============================================================================= // // This file implements miscellaneous transformation routines for non-loop IR // structures. // //===----------------------------------------------------------------------===// #include "mlir/Transforms/Utils.h" #include "mlir/AffineOps/AffineOps.h" #include "mlir/Analysis/AffineAnalysis.h" #include "mlir/Analysis/AffineStructures.h" #include "mlir/Analysis/Dominance.h" #include "mlir/Analysis/Utils.h" #include "mlir/IR/Builders.h" #include "mlir/IR/Function.h" #include "mlir/IR/Module.h" #include "mlir/StandardOps/Ops.h" #include "mlir/Support/MathExtras.h" #include "llvm/ADT/DenseMap.h" using namespace mlir; /// Return true if this operation dereferences one or more memref's. // Temporary utility: will be replaced when this is modeled through // side-effects/op traits. TODO(b/117228571) static bool isMemRefDereferencingOp(Operation &op) { if (isa<AffineLoadOp>(op) || isa<AffineStoreOp>(op) || isa<AffineDmaStartOp>(op) || isa<AffineDmaWaitOp>(op)) return true; return false; } /// Return the AffineMapAttr associated with memory 'op' on 'memref'. static NamedAttribute getAffineMapAttrForMemRef(Operation *op, Value *memref) { if (auto loadOp = dyn_cast<AffineLoadOp>(op)) return loadOp.getAffineMapAttrForMemRef(memref); else if (auto storeOp = dyn_cast<AffineStoreOp>(op)) return storeOp.getAffineMapAttrForMemRef(memref); else if (auto dmaStart = dyn_cast<AffineDmaStartOp>(op)) return dmaStart.getAffineMapAttrForMemRef(memref); assert(isa<AffineDmaWaitOp>(op)); return cast<AffineDmaWaitOp>(op).getAffineMapAttrForMemRef(memref); } bool mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef, ArrayRef<Value *> extraIndices, AffineMap indexRemap, ArrayRef<Value *> extraOperands, Operation *domInstFilter, Operation *postDomInstFilter) { unsigned newMemRefRank = newMemRef->getType().cast<MemRefType>().getRank(); (void)newMemRefRank; // unused in opt mode unsigned oldMemRefRank = oldMemRef->getType().cast<MemRefType>().getRank(); (void)newMemRefRank; if (indexRemap) { assert(indexRemap.getNumSymbols() == 0 && "pure dimensional map expected"); assert(indexRemap.getNumInputs() == extraOperands.size() + oldMemRefRank); assert(indexRemap.getNumResults() + extraIndices.size() == newMemRefRank); } else { assert(oldMemRefRank + extraIndices.size() == newMemRefRank); } // Assert same elemental type. assert(oldMemRef->getType().cast<MemRefType>().getElementType() == newMemRef->getType().cast<MemRefType>().getElementType()); std::unique_ptr<DominanceInfo> domInfo; std::unique_ptr<PostDominanceInfo> postDomInfo; if (domInstFilter) domInfo = std::make_unique<DominanceInfo>( domInstFilter->getParentOfType<FuncOp>()); if (postDomInstFilter) postDomInfo = std::make_unique<PostDominanceInfo>( postDomInstFilter->getParentOfType<FuncOp>()); // The ops where memref replacement succeeds are replaced with new ones. SmallVector<Operation *, 8> opsToErase; // Walk all uses of old memref. Operation using the memref gets replaced. for (auto *opInst : llvm::make_early_inc_range(oldMemRef->getUsers())) { // Skip this use if it's not dominated by domInstFilter. if (domInstFilter && !domInfo->dominates(domInstFilter, opInst)) continue; // Skip this use if it's not post-dominated by postDomInstFilter. if (postDomInstFilter && !postDomInfo->postDominates(postDomInstFilter, opInst)) continue; // Skip dealloc's - no replacement is necessary, and a replacement doesn't // hurt dealloc's. if (isa<DeallocOp>(opInst)) continue; // Check if the memref was used in a non-deferencing context. It is fine for // the memref to be used in a non-deferencing way outside of the region // where this replacement is happening. if (!isMemRefDereferencingOp(*opInst)) // Failure: memref used in a non-deferencing op (potentially escapes); no // replacement in these cases. return false; auto getMemRefOperandPos = [&]() -> unsigned { unsigned i, e; for (i = 0, e = opInst->getNumOperands(); i < e; i++) { if (opInst->getOperand(i) == oldMemRef) break; } assert(i < opInst->getNumOperands() && "operand guaranteed to be found"); return i; }; OpBuilder builder(opInst); unsigned memRefOperandPos = getMemRefOperandPos(); NamedAttribute oldMapAttrPair = getAffineMapAttrForMemRef(opInst, oldMemRef); AffineMap oldMap = oldMapAttrPair.second.cast<AffineMapAttr>().getValue(); unsigned oldMapNumInputs = oldMap.getNumInputs(); SmallVector<Value *, 4> oldMapOperands( opInst->operand_begin() + memRefOperandPos + 1, opInst->operand_begin() + memRefOperandPos + 1 + oldMapNumInputs); SmallVector<Value *, 4> affineApplyOps; // Apply 'oldMemRefOperands = oldMap(oldMapOperands)'. SmallVector<Value *, 4> oldMemRefOperands; oldMemRefOperands.reserve(oldMemRefRank); if (oldMap != builder.getMultiDimIdentityMap(oldMap.getNumDims())) { for (auto resultExpr : oldMap.getResults()) { auto singleResMap = builder.getAffineMap( oldMap.getNumDims(), oldMap.getNumSymbols(), resultExpr); auto afOp = builder.create<AffineApplyOp>(opInst->getLoc(), singleResMap, oldMapOperands); oldMemRefOperands.push_back(afOp); affineApplyOps.push_back(afOp); } } else { oldMemRefOperands.append(oldMapOperands.begin(), oldMapOperands.end()); } // Construct new indices as a remap of the old ones if a remapping has been // provided. The indices of a memref come right after it, i.e., // at position memRefOperandPos + 1. SmallVector<Value *, 4> remapOperands; remapOperands.reserve(extraOperands.size() + oldMemRefRank); remapOperands.append(extraOperands.begin(), extraOperands.end()); remapOperands.append(oldMemRefOperands.begin(), oldMemRefOperands.end()); SmallVector<Value *, 4> remapOutputs; remapOutputs.reserve(oldMemRefRank); if (indexRemap && indexRemap != builder.getMultiDimIdentityMap(indexRemap.getNumDims())) { // Remapped indices. for (auto resultExpr : indexRemap.getResults()) { auto singleResMap = builder.getAffineMap( indexRemap.getNumDims(), indexRemap.getNumSymbols(), resultExpr); auto afOp = builder.create<AffineApplyOp>(opInst->getLoc(), singleResMap, remapOperands); remapOutputs.push_back(afOp); affineApplyOps.push_back(afOp); } } else { // No remapping specified. remapOutputs.append(remapOperands.begin(), remapOperands.end()); } SmallVector<Value *, 4> newMapOperands; newMapOperands.reserve(newMemRefRank); // Prepend 'extraIndices' in 'newMapOperands'. for (auto *extraIndex : extraIndices) { assert(extraIndex->getDefiningOp()->getNumResults() == 1 && "single result op's expected to generate these indices"); assert((isValidDim(extraIndex) || isValidSymbol(extraIndex)) && "invalid memory op index"); newMapOperands.push_back(extraIndex); } // Append 'remapOutputs' to 'newMapOperands'. newMapOperands.append(remapOutputs.begin(), remapOutputs.end()); // Create new fully composed AffineMap for new op to be created. assert(newMapOperands.size() == newMemRefRank); auto newMap = builder.getMultiDimIdentityMap(newMemRefRank); // TODO(b/136262594) Avoid creating/deleting temporary AffineApplyOps here. fullyComposeAffineMapAndOperands(&newMap, &newMapOperands); newMap = simplifyAffineMap(newMap); canonicalizeMapAndOperands(&newMap, &newMapOperands); // Remove any affine.apply's that became dead as a result of composition. for (auto *value : affineApplyOps) if (value->use_empty()) value->getDefiningOp()->erase(); // Construct the new operation using this memref. OperationState state(opInst->getLoc(), opInst->getName()); state.setOperandListToResizable(opInst->hasResizableOperandsList()); state.operands.reserve(opInst->getNumOperands() + extraIndices.size()); // Insert the non-memref operands. state.operands.append(opInst->operand_begin(), opInst->operand_begin() + memRefOperandPos); // Insert the new memref value. state.operands.push_back(newMemRef); // Insert the new memref map operands. state.operands.append(newMapOperands.begin(), newMapOperands.end()); // Insert the remaining operands unmodified. state.operands.append(opInst->operand_begin() + memRefOperandPos + 1 + oldMapNumInputs, opInst->operand_end()); // Result types don't change. Both memref's are of the same elemental type. state.types.reserve(opInst->getNumResults()); for (auto *result : opInst->getResults()) state.types.push_back(result->getType()); // Add attribute for 'newMap', other Attributes do not change. auto newMapAttr = builder.getAffineMapAttr(newMap); for (auto namedAttr : opInst->getAttrs()) { if (namedAttr.first == oldMapAttrPair.first) { state.attributes.push_back({namedAttr.first, newMapAttr}); } else { state.attributes.push_back(namedAttr); } } // Create the new operation. auto *repOp = builder.createOperation(state); opInst->replaceAllUsesWith(repOp); // Collect and erase at the end since one of these op's could be // domInstFilter or postDomInstFilter as well! opsToErase.push_back(opInst); } for (auto *opInst : opsToErase) opInst->erase(); return true; } /// Given an operation, inserts one or more single result affine /// apply operations, results of which are exclusively used by this operation /// operation. The operands of these newly created affine apply ops are /// guaranteed to be loop iterators or terminal symbols of a function. /// /// Before /// /// affine.for %i = 0 to #map(%N) /// %idx = affine.apply (d0) -> (d0 mod 2) (%i) /// "send"(%idx, %A, ...) /// "compute"(%idx) /// /// After /// /// affine.for %i = 0 to #map(%N) /// %idx = affine.apply (d0) -> (d0 mod 2) (%i) /// "send"(%idx, %A, ...) /// %idx_ = affine.apply (d0) -> (d0 mod 2) (%i) /// "compute"(%idx_) /// /// This allows applying different transformations on send and compute (for eg. /// different shifts/delays). /// /// Returns nullptr either if none of opInst's operands were the result of an /// affine.apply and thus there was no affine computation slice to create, or if /// all the affine.apply op's supplying operands to this opInst did not have any /// uses besides this opInst; otherwise returns the list of affine.apply /// operations created in output argument `sliceOps`. void mlir::createAffineComputationSlice( Operation *opInst, SmallVectorImpl<AffineApplyOp> *sliceOps) { // Collect all operands that are results of affine apply ops. SmallVector<Value *, 4> subOperands; subOperands.reserve(opInst->getNumOperands()); for (auto *operand : opInst->getOperands()) if (isa_and_nonnull<AffineApplyOp>(operand->getDefiningOp())) subOperands.push_back(operand); // Gather sequence of AffineApplyOps reachable from 'subOperands'. SmallVector<Operation *, 4> affineApplyOps; getReachableAffineApplyOps(subOperands, affineApplyOps); // Skip transforming if there are no affine maps to compose. if (affineApplyOps.empty()) return; // Check if all uses of the affine apply op's lie only in this op op, in // which case there would be nothing to do. bool localized = true; for (auto *op : affineApplyOps) { for (auto *result : op->getResults()) { for (auto *user : result->getUsers()) { if (user != opInst) { localized = false; break; } } } } if (localized) return; OpBuilder builder(opInst); SmallVector<Value *, 4> composedOpOperands(subOperands); auto composedMap = builder.getMultiDimIdentityMap(composedOpOperands.size()); fullyComposeAffineMapAndOperands(&composedMap, &composedOpOperands); // Create an affine.apply for each of the map results. sliceOps->reserve(composedMap.getNumResults()); for (auto resultExpr : composedMap.getResults()) { auto singleResMap = builder.getAffineMap( composedMap.getNumDims(), composedMap.getNumSymbols(), resultExpr); sliceOps->push_back(builder.create<AffineApplyOp>( opInst->getLoc(), singleResMap, composedOpOperands)); } // Construct the new operands that include the results from the composed // affine apply op above instead of existing ones (subOperands). So, they // differ from opInst's operands only for those operands in 'subOperands', for // which they will be replaced by the corresponding one from 'sliceOps'. SmallVector<Value *, 4> newOperands(opInst->getOperands()); for (unsigned i = 0, e = newOperands.size(); i < e; i++) { // Replace the subOperands from among the new operands. unsigned j, f; for (j = 0, f = subOperands.size(); j < f; j++) { if (newOperands[i] == subOperands[j]) break; } if (j < subOperands.size()) { newOperands[i] = (*sliceOps)[j]; } } for (unsigned idx = 0, e = newOperands.size(); idx < e; idx++) { opInst->setOperand(idx, newOperands[idx]); } }
; ; ZX81 clock() function ; By Stefano Bodrato - Oct. 2011 ; Back to default FRAMES counter + 1 extra byte ;) ; ; -------- ; $Id: clock.asm,v 1.9 2015/01/19 01:33:25 pauloscustodio Exp $ PUBLIC clock ; XREF frames3 EXTERN _FRAMES .clock IF FORzx81 ld hl,-1 ;ld de,($4034) ld de,(_FRAMES) and a sbc hl,de ELSE ;ld hl,($401E) ld hl,(_FRAMES) ENDIF ld de,0 ret
[BotW_ExtendedMemory_V208] moduleMatches = 0x6267BFD0 .origin = codecave 0x02C5E660 = lis r9, 0x8B60 ; add 0x50000000 to main gameheap which by default has a fixed size of 0x3B600000. Can't make it larger due to overlay arena being in the way SaveAreaHeapSize = 8 * 1024 * 1024 ; 8MiB (default is 2312KiB) TriggerParamHeapSize = 8 * 1024 * 1024 ; 8MiB (default is around 2616KiB) HavokMainHeapSize = 80 * 1024 * 1024 ; 80MiB (default is 30MiB) PhysicsTempLowHeapSize = 512 * 1024; 512KiB (default is 128KiB) PhysicsSystemHeapSize = 512 * 1024; 512KiB (default is 128KiB) ; GameDataHeap 0x032015E0 = lis r3, (SaveAreaHeapSize@ha + TriggerParamHeapSize@ha) ; GameDataHeap -> SaveArea heap 0x03201A44 = lis r3, SaveAreaHeapSize@ha 0x03201A5C = addi r3, r3, SaveAreaHeapSize@l ; GameDataHeap -> TriggerParam ; Uses the remaining allocatable size of GameDataHeap ; Physics Memory System -> HavokMainHeap 0x037FD6A4 = lis r6, HavokMainHeapSize@ha ; Physics Memory System -> PhysicsTempDefault ; Physics Memory System -> PhysicsTempLow 0x037fd758 = lis r3, PhysicsTempLowHeapSize@ha ; Physics Memory System -> PhysicsSystem 0x037fd6d4 = lis r3, PhysicsSystemHeapSize@ha ; Terrain Scene 0x02C5A208 = lis r3, 0x400 #lis r3, 0x140 ; KingSystem -> ForestRenderer 0x0338cdbc = lis r3,0x80 # lis r3,0x30 ; KingSystem -> ForestRenderer -> ForestRenderer - WorkHeap 0x033C9D80 = lis r3, 0x20 # lis r3, 0xC ; Overlay arena 0x030AA5F4 = lis r7, 0x4000 ; expand overlay arena root heap size to 0x40000000 (1GiB) from default 0x1C000000 (448MiB). Can't make it larger due to forground bucket memory being in the way (starts at 0xE0000000) ; Extra size for overlay arena from rules.txt is 0x24000000 (576MiB) ; Overlay arena -> FixedHeap ; FixedHeap seems to store terrain renderer among other things 0x034ED614 = lis r3, 0x0C20 + 0x1000 ; add 256MiB ; Overlay arena -> MoveableMemoryHeap ; For resource textures? 0x034ED66C = lis r3, 0x0FD0 + 0x1000 ; add 256MiB ; Overlay arena -> FixedHeap -> GameDataWork 0x034ed55c = lis r3, 0x40 + 0x20; ; Overlay arena -> FixedHeap -> TexArcWork 0x034eced8 = lis r3, 0x200 + 0x200 ; add 32MiB ; Overlay arena -> FixedHeap -> Audio(OverlayArena) 0x034ed1e4 = lis r6, 0x1a0 + 0x200 ; add 32MiB ; Overlay arena -> FixedHeap -> TexArcWork 0x034ECED8 = lis r3, 0x200 + 0x400 ; add 64MiB ; 'Main' (unsure what this is responsible for) 0x0340F31C = li r7, 0x87 + 0x20 ; add 32MiB (register stores size in MiB) 0x0340f320 = nop 0x0340f324 = nop 0x0340f328 = nop 0x0340f32C = nop ; MovableMemory ;0x0340F334 = li r9, 0xFB + 0x180 ; add 384MiB -> Too much 0x0340F334 = li r9, 0xFB + 0x100 ; add 256MiB 0x0340f338 = nop 0x0340f33C = nop ; ForResourceS 0x0340f3f4 = lis r0,0x940 + 0x1000 ; add 256MiB ; ForResourceL ; 0340F370 addis r26, r26, 0x20 ; size seems to have extra space added dynamically based on unknown parameters? ; ends up as 0x10f00000 0x340F370 = lis r26, 0x2200 ; add around 288MiB ; PlacementMgr heap 0x037c0f30 = li r28,0x5a + 0x40 ; in MiB ; Increase the size of the resource heap for small resources. When using mods like e.g. draw distance this would likely be the reason why it would spawn panic moons. ;;_increaseResourceSmallHeap: ;;lwz r10, 0x70(r24) ;;addis r10, r10, 0x500 ;;stw r10, 0x70(r24) ;;blr ;;0x037EAADC = bla _increaseResourceSmallHeap ; Increase the size of the resource heap for large resources. When using mods like e.g. draw distance this would likely be the reason why it would spawn panic moons. ;;_increaseResourceLargeHeap: ;;lwz r11, 0x6C(r24) ;;addis r11, r11, 0x500 ;;stw r11, 0x6C(r24) ;;blr ;;0x037EAB84 = bla _increaseResourceLargeHeap ; Some notes on potential further heaps ; The function at 0x030A5FA0 is the sead::ExpHeap::create function, which is used for pretty much all of BotW's heap creations. ; 0x02C235A0 = KingSystem -> uking::frm::System -> StageBinder ; 0x030A9E7C = Could be used to increase the sead::Arena size. Might already be increased. ; A lot of heaps inside the function at 0x034ED524 are used to initialize individual heaps ; 0x034ED55C = Overlay arena -> FixedHeap -> GameDataWork ; 0x034ECFCC = Overlay arena -> FixedHeap -> ForOverlayArena ; 0x034ECED8 = Overlay arena -> FixedHeap -> TexArcWork ; 0x034ED4EC = Overlay arena -> FixedHeap -> PlacementTree ; 0x034ED884 = Overlay arena -> SZSDecompressorInst ; 0x0309F1AC = ? -> SeadResourceMgr ; 0x037A19B0 = ? -> ActorFactory Related 1 - This could be used to increase the size that a heap can have. ; 0x037AE978 = ? -> ActorFactory Related 2 - This could be used to increase the size that a heap can have. ; 0x03B3EA40 = ? -> AglWorkHeap ; Heap creation is near 0x03201174
/* * Copyright 2017 MapD Technologies, Inc. * * 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 <mutex> #include <string> #include <vector> #include <limits> #include <algorithm> #include <boost/variant.hpp> #include <boost/variant/get.hpp> #include "Fragmenter/InsertOrderFragmenter.h" #include "Shared/TypedDataAccessors.h" #include "Shared/thread_count.h" #include "DataMgr/DataMgr.h" #include "Catalog/Catalog.h" namespace Fragmenter_Namespace { void InsertOrderFragmenter::updateColumn(const Catalog_Namespace::Catalog* catalog, const std::string& tabName, const std::string& colName, const int fragmentId, const std::vector<uint64_t>& fragOffsets, const std::vector<ScalarTargetValue>& rhsValues, const SQLTypeInfo& rhsType, const Data_Namespace::MemoryLevel memoryLevel, UpdelRoll& updelRoll) { const auto td = catalog->getMetadataForTable(tabName); CHECK(td); const auto cd = catalog->getMetadataForColumn(td->tableId, colName); CHECK(cd); td->fragmenter->updateColumn(catalog, td, cd, fragmentId, fragOffsets, rhsValues, rhsType, memoryLevel, updelRoll); } inline bool is_integral(const SQLTypeInfo& t) { return t.is_integer() || t.is_boolean() || t.is_time() || t.is_timeinterval(); } void InsertOrderFragmenter::updateColumn(const Catalog_Namespace::Catalog* catalog, const TableDescriptor* td, const ColumnDescriptor* cd, const int fragmentId, const std::vector<uint64_t>& fragOffsets, const ScalarTargetValue& rhsValue, const SQLTypeInfo& rhsType, const Data_Namespace::MemoryLevel memoryLevel, UpdelRoll& updelRoll) { updateColumn(catalog, td, cd, fragmentId, fragOffsets, std::vector<ScalarTargetValue>(1, rhsValue), rhsType, memoryLevel, updelRoll); } void InsertOrderFragmenter::updateColumn(const Catalog_Namespace::Catalog* catalog, const TableDescriptor* td, const ColumnDescriptor* cd, const int fragmentId, const std::vector<uint64_t>& fragOffsets, const std::vector<ScalarTargetValue>& rhsValues, const SQLTypeInfo& rhsType, const Data_Namespace::MemoryLevel memoryLevel, UpdelRoll& updelRoll) { updelRoll.catalog = catalog; updelRoll.logicalTableId = catalog->getLogicalTableId(td->tableId); updelRoll.memoryLevel = memoryLevel; const auto nrow = fragOffsets.size(); const auto nval = rhsValues.size(); if (0 == nrow) return; CHECK(nrow == nval || 1 == nval); auto fragment_it = std::find_if(fragmentInfoVec_.begin(), fragmentInfoVec_.end(), [=](FragmentInfo& f) -> bool { return f.fragmentId == fragmentId; }); CHECK(fragment_it != fragmentInfoVec_.end()); auto& fragment = *fragment_it; auto chunk_meta_it = fragment.getChunkMetadataMapPhysical().find(cd->columnId); CHECK(chunk_meta_it != fragment.getChunkMetadataMapPhysical().end()); ChunkKey chunk_key{catalog->get_currentDB().dbId, td->tableId, cd->columnId, fragment.fragmentId}; auto chunk = Chunk_NS::Chunk::getChunk(cd, &catalog->get_dataMgr(), chunk_key, Data_Namespace::CPU_LEVEL, 0, chunk_meta_it->second.numBytes, chunk_meta_it->second.numElements); const auto ncore = (size_t)cpu_threads(); std::vector<bool> null(ncore, false); std::vector<double> dmax(ncore, std::numeric_limits<double>::min()); std::vector<double> dmin(ncore, std::numeric_limits<double>::max()); std::vector<int64_t> lmax(ncore, std::numeric_limits<int64_t>::min()); std::vector<int64_t> lmin(ncore, std::numeric_limits<int64_t>::max()); // parallel update elements std::vector<std::future<void>> threads; std::exception_ptr failed_any_chunk; std::mutex mtx; auto wait_cleanup_threads = [&] { try { for (auto& t : threads) t.wait(); for (auto& t : threads) t.get(); } catch (...) { std::unique_lock<std::mutex> lck(mtx); failed_any_chunk = std::current_exception(); } threads.clear(); }; const auto segsz = (nrow + ncore - 1) / ncore; auto dbuf = chunk->get_buffer(); auto d0 = dbuf->getMemoryPtr(); dbuf->setUpdated(); { std::lock_guard<std::mutex> lck(updelRoll.mutex); if (updelRoll.dirtyChunks.count(chunk.get()) == 0) updelRoll.dirtyChunks.emplace(chunk.get(), chunk); ChunkKey chunkey{updelRoll.catalog->get_currentDB().dbId, cd->tableId, cd->columnId, fragment.fragmentId}; updelRoll.dirtyChunkeys.insert(chunkey); } for (size_t rbegin = 0, c = 0; rbegin < nrow; ++c, rbegin += segsz) { threads.emplace_back( std::async(std::launch::async, [=, &null, &lmin, &lmax, &dmin, &dmax, &fragOffsets, &rhsValues] { SQLTypeInfo lctype = cd->columnType; // !! not sure if this is a undocumented convention or a bug, but for a sharded table // the dictionary id of a encoded string column is not specified by comp_param in physical // table but somehow in logical table :) comp_param in physical table is always 0, so // need to adapt accordingly... auto cdl = (shard_ < 0) ? cd : catalog->getMetadataForColumn(catalog->getLogicalTableId(td->tableId), cd->columnId); CHECK(cdl); StringDictionary* stringDict{nullptr}; if (lctype.is_string()) { CHECK(kENCODING_DICT == lctype.get_compression()); auto dictDesc = const_cast<DictDescriptor*>(catalog->getMetadataForDict(cdl->columnType.get_comp_param())); CHECK(dictDesc); stringDict = dictDesc->stringDict.get(); CHECK(stringDict); } for (size_t r = rbegin; r < std::min(rbegin + segsz, nrow); r++) { const auto roffs = fragOffsets[r]; auto dptr = d0 + roffs * get_uncompressed_element_size(lctype); auto sv = &rhsValues[1 == nval ? 0 : r]; ScalarTargetValue sv2; // Subtle here is on the two cases of string-to-string assignments, when upstream // passes RHS string as a string index instead of a preferred "real string". // case #1. For "SET str_col = str_literal", it is hard to resolve temp str index // in this layer, so if upstream passes a str idx here, an exception is thrown. // case #2. For "SET str_col1 = str_col2", RHS str idx is converted to LHS str idx. if (rhsType.is_string()) if (const auto vp = boost::get<int64_t>(sv)) { auto dictDesc = const_cast<DictDescriptor*>(catalog->getMetadataForDict(rhsType.get_comp_param())); if (nullptr == dictDesc) throw std::runtime_error("UPDATE does not support cast from string literal to string column."); auto stringDict = dictDesc->stringDict.get(); CHECK(stringDict); sv2 = NullableString(stringDict->getString(*vp)); sv = &sv2; } if (const auto vp = boost::get<int64_t>(sv)) { auto v = *vp; if (lctype.is_string()) #ifdef ENABLE_STRING_CONVERSION_AT_STORAGE_LAYER v = stringDict->getOrAdd( DatumToString(rhsType.is_time() ? Datum{.timeval = v} : Datum{.bigintval = v}, rhsType)); #else throw std::runtime_error("UPDATE does not support cast to string."); #endif put_scalar<int64_t>(dptr, lctype, v, &rhsType); if (lctype.is_decimal()) { int64_t decimal; get_scalar<int64_t>(dptr, lctype, decimal); set_minmax<int64_t>(lmin[c], lmax[c], decimal); if (!((v >= 0) ^ (decimal < 0))) throw std::runtime_error( "Data conversion overflow on " + std::to_string(v) + " from DECIMAL(" + std::to_string(rhsType.get_dimension()) + ", " + std::to_string(rhsType.get_scale()) + ") to (" + std::to_string(lctype.get_dimension()) + ", " + std::to_string(lctype.get_scale()) + ")"); } else if (is_integral(lctype)) set_minmax<int64_t>(lmin[c], lmax[c], rhsType.is_decimal() ? round(decimal_to_double(rhsType, v)) : v); else set_minmax<double>(dmin[c], dmax[c], rhsType.is_decimal() ? decimal_to_double(rhsType, v) : v); } else if (const auto vp = boost::get<double>(sv)) { auto v = *vp; if (lctype.is_string()) #ifdef ENABLE_STRING_CONVERSION_AT_STORAGE_LAYER v = stringDict->getOrAdd(DatumToString(Datum{.doubleval = v}, rhsType)); #else throw std::runtime_error("UPDATE does not support cast to string."); #endif put_scalar<double>(dptr, lctype, v); if (lctype.is_integer()) set_minmax<int64_t>(lmin[c], lmax[c], v); else set_minmax<double>(dmin[c], dmax[c], v); } else if (const auto vp = boost::get<float>(sv)) { auto v = *vp; if (lctype.is_string()) #ifdef ENABLE_STRING_CONVERSION_AT_STORAGE_LAYER v = stringDict->getOrAdd(DatumToString(Datum{.floatval = v}, rhsType)); #else throw std::runtime_error("UPDATE does not support cast to string."); #endif put_scalar<float>(dptr, lctype, v); if (lctype.is_integer()) set_minmax<int64_t>(lmin[c], lmax[c], v); else set_minmax<double>(dmin[c], dmax[c], v); } else if (const auto vp = boost::get<NullableString>(sv)) { const auto s = boost::get<std::string>(vp); const auto sval = s ? *s : std::string(""); if (lctype.is_string()) { decltype(stringDict->getOrAdd(sval)) sidx; { std::unique_lock<std::mutex> lock(temp_mutex_); sidx = stringDict->getOrAdd(sval); } put_scalar<int32_t>(dptr, lctype, sidx); set_minmax<int64_t>(lmin[c], lmax[c], sidx); } else if (sval.size() > 0) { auto dval = std::atof(sval.data()); if (lctype.is_boolean()) dval = sval == "t" || sval == "true" || sval == "T" || sval == "True"; else if (lctype.is_time()) dval = StringToDatum(sval, lctype).timeval; if (lctype.is_fp() || lctype.is_decimal()) { put_scalar<double>(dptr, lctype, dval); set_minmax<double>(dmin[c], dmax[c], dval); } else { put_scalar<int64_t>(dptr, lctype, dval); set_minmax<int64_t>(lmin[c], lmax[c], dval); } } else { put_null(dptr, lctype, cd->columnName); null[c] = true; } } else CHECK(false); } })); if (threads.size() >= (size_t)cpu_threads()) wait_cleanup_threads(); if (failed_any_chunk) break; } wait_cleanup_threads(); if (failed_any_chunk) std::rethrow_exception(failed_any_chunk); bool lc_null{false}; double lc_dmax{std::numeric_limits<double>::min()}; double lc_dmin{std::numeric_limits<double>::max()}; int64_t lc_lmax{std::numeric_limits<int64_t>::min()}; int64_t lc_lmin{std::numeric_limits<int64_t>::max()}; for (size_t c = 0; c < ncore; ++c) { lc_null |= null[c]; lc_dmax = std::max<double>(lc_dmax, dmax[c]); lc_dmin = std::min<double>(lc_dmin, dmin[c]); lc_lmax = std::max<int64_t>(lc_lmax, lmax[c]); lc_lmin = std::min<int64_t>(lc_lmin, lmin[c]); } updateColumnMetadata(cd, fragment, chunk, lc_null, lc_dmax, lc_dmin, lc_lmax, lc_lmin, cd->columnType, updelRoll); } void InsertOrderFragmenter::updateColumnMetadata(const ColumnDescriptor* cd, FragmentInfo& fragment, std::shared_ptr<Chunk_NS::Chunk> chunk, const bool null, const double dmax, const double dmin, const int64_t lmax, const int64_t lmin, const SQLTypeInfo& rhsType, UpdelRoll& updelRoll) { auto td = updelRoll.catalog->getMetadataForTable(cd->tableId); auto key = std::make_pair(td, &fragment); std::lock_guard<std::mutex> lck(updelRoll.mutex); if (0 == updelRoll.chunkMetadata.count(key)) updelRoll.chunkMetadata[key] = fragment.getChunkMetadataMapPhysical(); if (0 == updelRoll.numTuples.count(key)) updelRoll.numTuples[key] = fragment.shadowNumTuples; auto& chunkMetadata = updelRoll.chunkMetadata[key]; auto buffer = chunk->get_buffer(); const auto& lctype = cd->columnType; if (is_integral(lctype) || (lctype.is_decimal() && rhsType.is_decimal())) { buffer->encoder->updateStats(lmax, null); buffer->encoder->updateStats(lmin, null); } else if (lctype.is_fp()) { buffer->encoder->updateStats(dmax, null); buffer->encoder->updateStats(dmin, null); } else if (lctype.is_decimal()) { buffer->encoder->updateStats((int64_t)(dmax * pow(10, lctype.get_scale())), null); buffer->encoder->updateStats((int64_t)(dmin * pow(10, lctype.get_scale())), null); } else if (!lctype.is_array() && !(lctype.is_string() && kENCODING_DICT != lctype.get_compression())) { buffer->encoder->updateStats(lmax, null); buffer->encoder->updateStats(lmin, null); } buffer->encoder->getMetadata(chunkMetadata[cd->columnId]); // removed as @alex suggests. keep it commented in case of any chance to revisit it // once after vacuum code is introduced. // fragment.invalidateChunkMetadataMap(); } void InsertOrderFragmenter::updateMetadata(const Catalog_Namespace::Catalog* catalog, const MetaDataKey& key, UpdelRoll& updelRoll) { mapd_unique_lock<mapd_shared_mutex> writeLock(fragmentInfoMutex_); if (updelRoll.chunkMetadata.count(key)) { auto& fragmentInfo = *key.second; const auto& chunkMetadata = updelRoll.chunkMetadata[key]; fragmentInfo.shadowChunkMetadataMap = chunkMetadata; fragmentInfo.setChunkMetadataMap(chunkMetadata); fragmentInfo.shadowNumTuples = updelRoll.numTuples[key]; fragmentInfo.setPhysicalNumTuples(fragmentInfo.shadowNumTuples); // TODO(ppan): When fragment-level compaction is enable, the following code should suffice. // When not (ie. existing code), we'll revert to update InsertOrderFragmenter::varLenColInfo_ /* for (const auto cit : chunkMetadata) { const auto& cd = *catalog->getMetadataForColumn(td->tableId, cit.first); if (cd.columnType.get_size() < 0) fragmentInfo.varLenColInfox[cd.columnId] = cit.second.numBytes; } */ } } } // namespace Fragmenter_Namespace void UpdelRoll::commitUpdate() { if (nullptr == catalog) return; const auto td = catalog->getMetadataForTable(logicalTableId); CHECK(td); // checkpoint all shards regardless, or epoch becomes out of sync if (td->persistenceLevel == Data_Namespace::MemoryLevel::DISK_LEVEL) catalog->checkpoint(logicalTableId); // for each dirty fragment for (auto& cm : chunkMetadata) cm.first.first->fragmenter->updateMetadata(catalog, cm.first, *this); dirtyChunks.clear(); // flush gpu dirty chunks if update was not on gpu if (memoryLevel != Data_Namespace::MemoryLevel::GPU_LEVEL) for (const auto& chunkey : dirtyChunkeys) catalog->get_dataMgr().deleteChunksWithPrefix(chunkey, Data_Namespace::MemoryLevel::GPU_LEVEL); } void UpdelRoll::cancelUpdate() { if (nullptr == catalog) return; const auto td = catalog->getMetadataForTable(logicalTableId); CHECK(td); if (td->persistenceLevel != memoryLevel) for (auto dit : dirtyChunks) { catalog->get_dataMgr().free(dit.first->get_buffer()); dit.first->set_buffer(nullptr); } }
SECTION code_clib SECTION code_fp_math48 PUBLIC asm_atanh EXTERN am48_atanh defc asm_atanh = am48_atanh
section .text global_start ;must be declared for linker (ld) _start: ;tells linker entry point mov edx,len ;message length mov ecx,msg ;message to write mov ebx,1 ;file descriptor (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Hello world!', 0xa ;string to be printed len equ $ - msg ;length of the string
; A059125: A self-generated dragon-like folding sequence. ; 0,0,1,0,0,1,1,1,0,0,1,1,0,1,1,0,0,0,1,0,0,1,1,0,0,0,1,1,0,1,1,0,0,0,1,0,0,1,1,1,0,0,1,1,0,1,1,1,0,0,1,0,0,1,1,0,0,0,1,1,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,1,0,1,1,0,0,0,1,0,0,1,1,0,0,0,1,1,0,1,1,1,0,0,1,0 mov $1,$0 mul $0,6 add $0,80 seq $1,59159 ; A hierarchical sequence (W'2{2}*c) - see A059126). div $0,$1 mod $0,2
.386 .model flat, c .code slp_switch_raw PROC save_state:DWORD, restore_state:DWORD, extra:DWORD ;save registers. EAX ECX and EDX are available for function use and thus ;do not have to be stored. push ebx push esi push edi push ebp mov esi, restore_state ; /* save 'restore_state' for later */ mov edi, extra ; /* save 'extra' for later */ mov eax, esp push edi ; /* arg 2: extra */ push eax ; /* arg 1: current (old) stack pointer */ mov ecx, save_state call ecx ; /* call save_state() */ test eax, eax; /* skip the restore if the return value is null */ jz exit mov esp, eax; /* change the stack pointer */ push edi ; /* arg 2: extra */ push eax ; /* arg 1: current (new) stack pointer */ call esi ; /* call restore_state() */ exit: add esp, 8 pop ebp pop edi pop esi pop ebx ret slp_switch_raw ENDP end
#include<bits/stdc++.h> using namespace std; int solve(int arr[],int n,int target){ int ans=0; int low=0; int high=n-1; while(low<=high){ int mid=low+(high-low)/2; if(arr[mid]==target){ return arr[mid]; } else if(arr[mid]>target){ high=mid-1; } else{ ans=arr[mid]; low=mid+1; } } return ans; } int main(){ int n; cin>>n; int arr[n]; for(int i=0;i<n;i++){ cin>>arr[i]; } int target; cin>>target; int ans=solve(arr,n,target); cout<<"floor of "<<target<<"element is "<<ans<<endl; return 0; }
; A047515: Numbers that are congruent to {0, 3, 4, 6, 7} mod 8. ; 0,3,4,6,7,8,11,12,14,15,16,19,20,22,23,24,27,28,30,31,32,35,36,38,39,40,43,44,46,47,48,51,52,54,55,56,59,60,62,63,64,67,68,70,71,72,75,76,78,79,80,83,84,86,87,88 add $0,4 mov $1,$0 mul $0,2 add $0,11 div $0,5 mul $0,6 div $0,4 add $0,$1 sub $0,8
char *getenv(const char *name); void sink(const char *sinkparam); // $ ast,ir=global1 ast,ir=global2 void throughLocal() { char * local = getenv("VAR"); sink(local); } char * global1 = 0; void readWriteGlobal1() { sink(global1); // $ ast,ir=global1 global1 = getenv("VAR"); } static char * global2 = 0; void readGlobal2() { sink(global2); // $ ast,ir=global2 } void writeGlobal2() { global2 = getenv("VAR"); }
; unsigned char p3dos_edrv_from_pdrv(unsigned char pdrv) SECTION code_esxdos PUBLIC _p3dos_edrv_from_pdrv EXTERN asm_p3dos_edrv_from_pdrv _p3dos_edrv_from_pdrv: pop af pop hl push hl push af jp asm_p3dos_edrv_from_pdrv
#include "SctpTimer.h" #include <algorithm> namespace sctp { bool Timer::hasExpired(uint64_t timestamp) const { if (!isRunning()) { return false; } return remainingTime(timestamp) == 0; } void Timer::expireAt(uint64_t timestamp) { _expires = timestamp; _armed = true; } void Timer::stop() { _armed = false; } void Timer::startMs(uint64_t timestamp, uint32_t timeoutMs) { _expires = timestamp + std::min(_maxTimeout, timeoutMs * timer::ms); _armed = true; } void Timer::startNs(uint64_t timestamp, uint64_t timeoutNs) { _expires = timestamp + timeoutNs; _armed = true; } int64_t Timer::remainingTime(uint64_t timestamp) const { if (!isRunning()) { return std::numeric_limits<int64_t>::max(); } return std::max(static_cast<int64_t>(_expires - timestamp), int64_t(0)); } } // namespace sctp
; A283551: a(n) = -1 + 5*n/6 + n^3/6. ; -1,0,2,6,13,24,40,62,91,128,174,230,297,376,468,574,695,832,986,1158,1349,1560,1792,2046,2323,2624,2950,3302,3681,4088,4524,4990,5487,6016,6578,7174,7805,8472,9176,9918,10699,11520,12382,13286,14233,15224,16260 add $0,1 mov $1,$0 bin $1,3 add $1,$0 sub $1,2
SECTION .text GLOBAL square_p448_solinas square_p448_solinas: sub rsp, 0x270 ; last 0x30 (6) for Caller - save regs mov [ rsp + 0x240 ], rbx; saving to stack mov [ rsp + 0x248 ], rbp; saving to stack mov [ rsp + 0x250 ], r12; saving to stack mov [ rsp + 0x258 ], r13; saving to stack mov [ rsp + 0x260 ], r14; saving to stack mov [ rsp + 0x268 ], r15; saving to stack mov rax, [ rsi + 0x38 ]; load m64 x2 to register64 mov r10, [ rsi + 0x28 ]; load m64 x12 to register64 imul r11, rax, 0x2; x4 <- x2 * 0x2 mov rbx, [ rsi + 0x30 ]; load m64 x6 to register64 mov rdx, [ rsi + 0x0 ]; arg1[0] to rdx mulx rbp, r12, [ rsi + 0x0 ]; x133, x132<- arg1[0] * arg1[0] mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx mulx r13, r14, r11; x103, x102<- arg1[1] * x4 imul r15, rbx, 0x2; x8 <- x6 * 0x2 imul rdx, r10, 0x2; x14 <- x12 * 0x2 mov rcx, [ rsi + 0x38 ]; load m64 x1 to register64 mov r8, [ rsi + 0x30 ]; load m64 x7 to register64 imul r9, r8, 0x2; x9 <- x7 * 0x2 mov [ rsp + 0x0 ], rdi; spilling out1 to mem mov [ rsp + 0x8 ], rax; spilling x2 to mem mulx rdi, rax, [ rsi + 0x18 ]; x79, x78<- arg1[3] * x14 mov [ rsp + 0x10 ], rbp; spilling x133 to mem mov rbp, rdx; preserving value of x14 into a new reg mov rdx, [ rsi + 0x10 ]; saving arg1[2] in rdx. mov [ rsp + 0x18 ], r13; spilling x103 to mem mov [ rsp + 0x20 ], rdi; spilling x79 to mem mulx r13, rdi, r9; x91, x90<- arg1[2] * x9 imul rdx, rcx, 0x2; x3 <- x1 * 0x2 mov [ rsp + 0x28 ], r13; spilling x91 to mem mov r13, rdx; preserving value of x3 into a new reg mov rdx, [ rsi + 0x30 ]; saving arg1[6] in rdx. mov [ rsp + 0x30 ], r12; spilling x132 to mem mov [ rsp + 0x38 ], r15; spilling x8 to mem mulx r12, r15, rbx; x27, x26<- arg1[6] * x6 mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx mov [ rsp + 0x40 ], r11; spilling x4 to mem mov [ rsp + 0x48 ], r12; spilling x27 to mem mulx r11, r12, r13; x29, x28<- arg1[5] * x3 mov rdx, [ rsi + 0x20 ]; load m64 x17 to register64 add r15, r12; could be done better, if r0 has been u8 as well mulx rdx, r12, [ rsi + 0x20 ]; x67, x66<- arg1[4] * x17 mov [ rsp + 0x50 ], r10; spilling x12 to mem setc r10b; spill CF x305 to reg (r10) mov [ rsp + 0x58 ], rdx; spilling x67 to mem imul rdx, [ rsi + 0x38 ], 0x2; x5 <- arg1[7] * 0x2 mov [ rsp + 0x60 ], r11; spilling x29 to mem xor r11, r11 adox r15, r12 mulx rdx, r12, [ rsi + 0x0 ]; x119, x118<- arg1[0] * x5 adcx r15, rax setc al; spill CF x313 to reg (rax) seto r11b; spill OF x309 to reg (r11) mov [ rsp + 0x68 ], rdx; spilling x119 to mem imul rdx, [ rsi + 0x30 ], 0x2; x10 <- arg1[6] * 0x2 mov [ rsp + 0x70 ], r8; spilling x7 to mem xor r8, r8 adox r15, rdi mulx rdi, r8, [ rsi + 0x8 ]; x107, x106<- arg1[1] * x10 adcx r15, r14 mov r14, rdx; preserving value of x10 into a new reg mov rdx, [ rsi + 0x28 ]; saving arg1[5] in rdx. mov byte [ rsp + 0x78 ], al; spilling byte x313 to mem mov [ rsp + 0x80 ], r12; spilling x118 to mem mulx rax, r12, [ rsp + 0x38 ]; x49, x48<- arg1[5] * x8 mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx mov [ rsp + 0x88 ], rbp; spilling x14 to mem mov byte [ rsp + 0x90 ], r11b; spilling byte x309 to mem mulx rbp, r11, r13; x57, x56<- arg1[4] * x3 setc dl; spill CF x321 to reg (rdx) mov byte [ rsp + 0x98 ], r10b; spilling byte x305 to mem seto r10b; spill OF x317 to reg (r10) mov [ rsp + 0xa0 ], rdi; spilling x107 to mem imul rdi, [ rsi + 0x28 ], 0x2; x15 <- arg1[5] * 0x2 add r15, [ rsp + 0x30 ]; could be done better, if r0 has been u8 as well mov [ rsp + 0xa8 ], r15; spilling x324 to mem setc r15b; spill CF x325 to reg (r15) mov [ rsp + 0xb0 ], r9; spilling x9 to mem imul r9, [ rsi + 0x20 ], 0x2; x18 <- arg1[4] * 0x2 add r12, r11; could be done better, if r0 has been u8 as well adcx rbp, rax mov al, dl; preserving value of x321 into a new reg mov rdx, [ rsi + 0x10 ]; saving arg1[2] in rdx. mov [ rsp + 0xb8 ], rcx; spilling x1 to mem mulx r11, rcx, rdi; x95, x94<- arg1[2] * x15 mov rdx, r9; x18 to rdx mov byte [ rsp + 0xc0 ], r15b; spilling byte x325 to mem mulx r9, r15, [ rsi + 0x18 ]; x83, x82<- arg1[3] * x18 add r12, r15; could be done better, if r0 has been u8 as well adcx r9, rbp xor rbp, rbp adox r12, rcx adcx r12, r8 adox r11, r9 adcx r11, [ rsp + 0xa0 ] mov r8, [ rsp + 0x48 ]; load m64 x27 to register64 sar byte [ rsp + 0x98 ], 1 adcx r8, [ rsp + 0x60 ] sar byte [ rsp + 0x90 ], 1 adcx r8, [ rsp + 0x58 ] adox r12, [ rsp + 0x80 ] adox r11, [ rsp + 0x68 ] mov rcx, r12; x331, copying x164 here, cause x164 is needed in a reg for other than x331, namely all: , x331, x332, size: 2 shrd rcx, r11, 56; x331 <- x166||x164 >> 56 sar byte [ rsp + 0x78 ], 1 adcx r8, [ rsp + 0x20 ] sar r10b, 1 adcx r8, [ rsp + 0x28 ] sar al, 1 adcx r8, [ rsp + 0x18 ] imul r10, [ rsi + 0x8 ], 0x2; x21 <- arg1[1] * 0x2 mov rax, rdx; preserving value of x18 into a new reg mov rdx, [ rsi + 0x18 ]; saving arg1[3] in rdx. mulx r15, r9, [ rsp + 0xb0 ]; x75, x74<- arg1[3] * x9 sar byte [ rsp + 0xc0 ], 1 adcx r8, [ rsp + 0x10 ] mov rdx, rcx; x338, copying x331 here, cause x331 is needed in a reg for other than x338, namely all: , x338--x339, x333--x334, size: 2 adox rdx, [ rsp + 0xa8 ] adox r8, rbp mov r11, rdx; preserving value of x338 into a new reg mov rdx, [ rsi + 0x10 ]; saving arg1[2] in rdx. mov [ rsp + 0xc8 ], rbx; spilling x6 to mem mulx rbp, rbx, [ rsp + 0x40 ]; x87, x86<- arg1[2] * x4 mov rdx, [ rsi + 0x0 ]; arg1[0] to rdx mov [ rsp + 0xd0 ], rbp; spilling x87 to mem mulx r10, rbp, r10; x131, x130<- arg1[0] * x21 mov rdx, r11; x344, copying x338 here, cause x338 is needed in a reg for other than x344, namely all: , x345, x344, size: 2 shrd rdx, r8, 56; x344 <- x340||x338 >> 56 mov r8, rdx; preserving value of x344 into a new reg mov rdx, [ rsi + 0x30 ]; saving arg1[6] in rdx. mov [ rsp + 0xd8 ], r10; spilling x131 to mem mov [ rsp + 0xe0 ], rbp; spilling x130 to mem mulx r10, rbp, r13; x25, x24<- arg1[6] * x3 mov rdx, [ rsp + 0x88 ]; x14 to rdx mov [ rsp + 0xe8 ], r8; spilling x344 to mem mulx rdx, r8, [ rsi + 0x20 ]; x63, x62<- arg1[4] * x14 add rbp, r8; could be done better, if r0 has been u8 as well adcx rdx, r10 xor r10, r10 adox rbp, r9 adox r15, rdx adcx rbp, rbx adcx r15, [ rsp + 0xd0 ] mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx mulx r9, rbx, [ rsp + 0xb8 ]; x23, x22<- arg1[7] * x1 test al, al adox rbp, [ rsp + 0xe0 ] adox r15, [ rsp + 0xd8 ] mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx mulx r8, r10, [ rsi + 0x8 ]; x117, x116<- arg1[1] * arg1[1] adcx rbp, [ rsp + 0xe8 ] adc r15, 0x0 imul rdx, [ rsi + 0x10 ], 0x2; x20 <- arg1[2] * 0x2 mov [ rsp + 0xf0 ], r14; spilling x10 to mem mov [ rsp + 0xf8 ], r8; spilling x117 to mem mulx r14, r8, [ rsi + 0x0 ]; x129, x128<- arg1[0] * x20 mov [ rsp + 0x100 ], r14; spilling x129 to mem mov r14, rbp; x354, copying x346 here, cause x346 is needed in a reg for other than x354, namely all: , x355, x354, size: 2 shrd r14, r15, 56; x354 <- x348||x346 >> 56 mov r15, rdx; preserving value of x20 into a new reg mov rdx, [ rsi + 0x20 ]; saving arg1[4] in rdx. mov [ rsp + 0x108 ], r14; spilling x354 to mem mov [ rsp + 0x110 ], r8; spilling x128 to mem mulx r14, r8, [ rsp + 0xb0 ]; x59, x58<- arg1[4] * x9 mov rdx, [ rsp + 0x50 ]; x12 to rdx mov [ rsp + 0x118 ], r10; spilling x116 to mem mulx rdx, r10, [ rsi + 0x28 ]; x51, x50<- arg1[5] * x12 add rbx, r10; could be done better, if r0 has been u8 as well adcx rdx, r9 add rbx, r8; could be done better, if r0 has been u8 as well adcx r14, rdx mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx mulx r9, r8, [ rsp + 0x40 ]; x71, x70<- arg1[3] * x4 xor rdx, rdx adox rbx, r8 adox r9, r14 adcx rbx, [ rsp + 0x118 ] adcx r9, [ rsp + 0xf8 ] xor r10, r10 adox rbx, [ rsp + 0x110 ] adcx rbx, [ rsp + 0x108 ] adox r9, [ rsp + 0x100 ] mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx mulx r14, r8, [ rsp + 0x40 ]; x55, x54<- arg1[4] * x4 adc r9, 0x0 mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx mov [ rsp + 0x120 ], r14; spilling x55 to mem mulx r10, r14, [ rsp + 0xb0 ]; x47, x46<- arg1[5] * x9 mov rdx, rbx; x362, copying x356 here, cause x356 is needed in a reg for other than x362, namely all: , x363, x362, size: 2 shrd rdx, r9, 56; x362 <- x358||x356 >> 56 imul r9, [ rsi + 0x18 ], 0x2; x19 <- arg1[3] * 0x2 mov [ rsp + 0x128 ], rdx; spilling x362 to mem mov rdx, 0xffffffffffffff ; moving imm to reg and r11, rdx; x345 <- x338&0xffffffffffffff adox r14, r8 mov r8, rdx; preserving value of 0xffffffffffffff into a new reg mov rdx, [ rsi + 0x0 ]; saving arg1[0] in rdx. mov [ rsp + 0x130 ], r11; spilling x345 to mem mov [ rsp + 0x138 ], rdi; spilling x15 to mem mulx r11, rdi, r9; x127, x126<- arg1[0] * x19 mov rdx, r15; x20 to rdx mulx rdx, r15, [ rsi + 0x8 ]; x115, x114<- arg1[1] * x20 adcx r14, r15 setc r15b; spill CF x139 to reg (r15) clc; adcx r14, rdi adox r10, [ rsp + 0x120 ] setc dil; spill CF x143 to reg (rdi) mov [ rsp + 0x140 ], rax; spilling x18 to mem mov rax, r14; x147, copying x142 here, cause x142 is needed in a reg for other than x147, namely all: , x147, x146, size: 2 and rax, r8; x147 <- x142&0xffffffffffffff add rax, [ rsp + 0x128 ] sar r15b, 1 adcx rdx, r10 mov r15, rax; x368, copying x364 here, cause x364 is needed in a reg for other than x368, namely all: , x367, x368, size: 2 and r15, r8; x368 <- x364&0xffffffffffffff sar dil, 1 adcx r11, rdx mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx mulx rdi, r10, r9; x113, x112<- arg1[1] * x19 mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx mov [ rsp + 0x148 ], r15; spilling x368 to mem mulx r8, r15, [ rsi + 0x10 ]; x101, x100<- arg1[2] * arg1[2] mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx mov [ rsp + 0x150 ], rdi; spilling x113 to mem mov [ rsp + 0x158 ], r10; spilling x112 to mem mulx rdi, r10, r13; x105, x104<- arg1[1] * x3 mov rdx, [ rsi + 0x28 ]; load m64 x11 to register64 shrd r14, r11, 56; x146 <- x144||x142 >> 56 imul r11, rdx, 0x2; x13 <- x11 * 0x2 mov [ rsp + 0x160 ], r14; spilling x146 to mem mov r14, rdx; preserving value of x11 into a new reg mov rdx, [ rsi + 0x0 ]; saving arg1[0] in rdx. mov [ rsp + 0x168 ], rdi; spilling x105 to mem mov [ rsp + 0x170 ], r10; spilling x104 to mem mulx rdi, r10, [ rsp + 0x140 ]; x125, x124<- arg1[0] * x18 mov rdx, r11; x13 to rdx mov [ rsp + 0x178 ], rdi; spilling x125 to mem mulx r11, rdi, [ rsi + 0x18 ]; x81, x80<- arg1[3] * x13 mov [ rsp + 0x180 ], r10; spilling x124 to mem mov r10, [ rsi + 0x20 ]; load m64 x16 to register64 mov [ rsp + 0x188 ], r8; spilling x101 to mem mov r8, rdx; preserving value of x13 into a new reg mov rdx, [ rsi + 0x28 ]; saving arg1[5] in rdx. mov [ rsp + 0x190 ], r15; spilling x100 to mem mov [ rsp + 0x198 ], r11; spilling x81 to mem mulx r15, r11, r13; x37, x36<- arg1[5] * x3 mov rdx, [ rsi + 0x28 ]; arg1[5] to rdx mov [ rsp + 0x1a0 ], rdi; spilling x80 to mem mov [ rsp + 0x1a8 ], r15; spilling x37 to mem mulx rdi, r15, [ rsp + 0x40 ]; x45, x44<- arg1[5] * x4 mov rdx, [ rsi + 0x30 ]; arg1[6] to rdx mov [ rsp + 0x1b0 ], rdi; spilling x45 to mem mov [ rsp + 0x1b8 ], r15; spilling x44 to mem mulx rdi, r15, [ rsp + 0x70 ]; x43, x42<- arg1[6] * x7 mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx mov [ rsp + 0x1c0 ], rdi; spilling x43 to mem mov [ rsp + 0x1c8 ], r15; spilling x42 to mem mulx rdi, r15, [ rsp + 0x38 ]; x93, x92<- arg1[2] * x8 mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx mov [ rsp + 0x1d0 ], rdi; spilling x93 to mem mulx r10, rdi, r10; x69, x68<- arg1[4] * x16 mov rdx, [ rsp + 0xc8 ]; x6 to rdx mov [ rsp + 0x1d8 ], r15; spilling x92 to mem mulx rdx, r15, [ rsi + 0x30 ]; x35, x34<- arg1[6] * x6 add r15, r11; could be done better, if r0 has been u8 as well adcx rdx, [ rsp + 0x1a8 ] add r15, [ rsp + 0x1c8 ]; could be done better, if r0 has been u8 as well adcx rdx, [ rsp + 0x1c0 ] add r15, [ rsp + 0x1b8 ]; could be done better, if r0 has been u8 as well adcx rdx, [ rsp + 0x1b0 ] test al, al adox r15, rdi adox r10, rdx adcx r15, [ rsp + 0x1a0 ] mov r11, -0x2 ; moving imm to reg inc r11; OF<-0x0, preserve CF (debug: 6; load -2, increase it, save as -1) adox r15, [ rsp + 0x1d8 ] adcx r10, [ rsp + 0x198 ] clc; adcx r15, [ rsp + 0x190 ] adox r10, [ rsp + 0x1d0 ] adcx r10, [ rsp + 0x188 ] test al, al adox r15, [ rsp + 0x170 ] mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx mulx rdi, r11, [ rsp + 0x38 ]; x77, x76<- arg1[3] * x8 adcx r15, [ rsp + 0x158 ] mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx mov [ rsp + 0x1e0 ], r12; spilling x164 to mem mov [ rsp + 0x1e8 ], rdi; spilling x77 to mem mulx r12, rdi, r13; x89, x88<- arg1[2] * x3 adox r10, [ rsp + 0x168 ] adcx r10, [ rsp + 0x150 ] add r15, [ rsp + 0x180 ]; could be done better, if r0 has been u8 as well adcx r10, [ rsp + 0x178 ] xor rdx, rdx adox r15, [ rsp + 0x160 ] mov [ rsp + 0x1f0 ], r12; spilling x89 to mem mov r12, rdx; preserving value of 0x0 into a new reg mov rdx, [ rsi + 0x30 ]; saving arg1[6] in rdx. mov [ rsp + 0x1f8 ], rdi; spilling x88 to mem mov [ rsp + 0x200 ], r11; spilling x76 to mem mulx rdi, r11, [ rsp + 0x40 ]; x41, x40<- arg1[6] * x4 adox r10, r12 adcx rcx, r15 adc r10, 0x0 mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx mulx r8, r15, r8; x65, x64<- arg1[4] * x13 mov rdx, [ rsi + 0x10 ]; arg1[2] to rdx mulx r9, r12, r9; x99, x98<- arg1[2] * x19 mov rdx, rcx; x336, copying x333 here, cause x333 is needed in a reg for other than x336, namely all: , x337, x336, size: 2 shrd rdx, r10, 56; x336 <- x335||x333 >> 56 mov r10, rdx; preserving value of x336 into a new reg mov rdx, [ rsi + 0x30 ]; saving arg1[6] in rdx. mov [ rsp + 0x208 ], r9; spilling x99 to mem mov [ rsp + 0x210 ], r12; spilling x98 to mem mulx r9, r12, r13; x33, x32<- arg1[6] * x3 add r12, r11; could be done better, if r0 has been u8 as well adcx rdi, r9 add r12, r15; could be done better, if r0 has been u8 as well mov rdx, [ rsi + 0x8 ]; arg1[1] to rdx mulx r11, r15, [ rsp + 0x140 ]; x111, x110<- arg1[1] * x18 mov rdx, [ rsp + 0x140 ]; x18 to rdx mulx rdx, r9, [ rsi + 0x10 ]; x97, x96<- arg1[2] * x18 adcx r8, rdi add r12, [ rsp + 0x200 ]; could be done better, if r0 has been u8 as well adcx r8, [ rsp + 0x1e8 ] add r12, [ rsp + 0x1f8 ]; could be done better, if r0 has been u8 as well adcx r8, [ rsp + 0x1f0 ] xor rdi, rdi adox r12, [ rsp + 0x210 ] adcx r12, r15 adox r8, [ rsp + 0x208 ] adcx r11, r8 mov r15, rdx; preserving value of x97 into a new reg mov rdx, [ rsi + 0x38 ]; saving arg1[7] in rdx. mulx r8, rdi, [ rsp + 0xb8 ]; x31, x30<- arg1[7] * x1 mov rdx, [ rsp + 0x138 ]; x15 to rdx mov [ rsp + 0x218 ], r15; spilling x97 to mem mov [ rsp + 0x220 ], r9; spilling x96 to mem mulx r15, r9, [ rsi + 0x0 ]; x123, x122<- arg1[0] * x15 test al, al adox r12, r9 adox r15, r11 adcx r12, r10 mulx rdx, r10, [ rsi + 0x8 ]; x109, x108<- arg1[1] * x15 mov r11, rdx; preserving value of x109 into a new reg mov rdx, [ rsi + 0x18 ]; saving arg1[3] in rdx. mov [ rsp + 0x228 ], r10; spilling x108 to mem mulx r9, r10, [ rsi + 0x18 ]; x85, x84<- arg1[3] * arg1[3] mov rdx, [ rsi + 0x38 ]; arg1[7] to rdx mov [ rsp + 0x230 ], r11; spilling x109 to mem mov [ rsp + 0x238 ], r9; spilling x85 to mem mulx r11, r9, [ rsp + 0x8 ]; x39, x38<- arg1[7] * x2 adc r15, 0x0 mov rdx, r12; x349, copying x341 here, cause x341 is needed in a reg for other than x349, namely all: , x350, x349, size: 2 shrd rdx, r15, 56; x349 <- x343||x341 >> 56 add rdi, r9; could be done better, if r0 has been u8 as well mov r9, rdx; preserving value of x349 into a new reg mov rdx, [ rsi + 0x28 ]; saving arg1[5] in rdx. mulx r14, r15, r14; x53, x52<- arg1[5] * x11 adcx r11, r8 add rdi, r15; could be done better, if r0 has been u8 as well mov rdx, [ rsi + 0x18 ]; arg1[3] to rdx mulx r13, r8, r13; x73, x72<- arg1[3] * x3 adcx r14, r11 mov rdx, [ rsi + 0x20 ]; arg1[4] to rdx mulx r15, r11, [ rsp + 0x38 ]; x61, x60<- arg1[4] * x8 add rdi, r11; could be done better, if r0 has been u8 as well adcx r15, r14 add rdi, r8; could be done better, if r0 has been u8 as well mov rdx, [ rsp + 0xf0 ]; x10 to rdx mulx rdx, r8, [ rsi + 0x0 ]; x121, x120<- arg1[0] * x10 adcx r13, r15 test al, al adox rdi, r10 adcx rdi, [ rsp + 0x220 ] adox r13, [ rsp + 0x238 ] adcx r13, [ rsp + 0x218 ] add rdi, [ rsp + 0x228 ]; could be done better, if r0 has been u8 as well adcx r13, [ rsp + 0x230 ] add rdi, r8; could be done better, if r0 has been u8 as well adcx rdx, r13 add rdi, r9; could be done better, if r0 has been u8 as well adc rdx, 0x0 mov r10, rdi; x359, copying x351 here, cause x351 is needed in a reg for other than x359, namely all: , x359, x360, size: 2 shrd r10, rdx, 56; x359 <- x353||x351 >> 56 mov r9, 0xffffffffffffff ; moving imm to reg mov r14, [ rsp + 0x1e0 ]; x332, copying x164 here, cause x164 is needed in a reg for other than x332, namely all: , x332, size: 1 and r14, r9; x332 <- x164&0xffffffffffffff lea r10, [ r10 + r14 ] and rcx, r9; x337 <- x333&0xffffffffffffff and rdi, r9; x360 <- x351&0xffffffffffffff shr rax, 56; x367 <- x364>> 56 mov r11, r10; x365, copying x361 here, cause x361 is needed in a reg for other than x365, namely all: , x365, x366, size: 2 shr r11, 56; x365 <- x361>> 56 lea rcx, [ rcx + r11 ] add r11, [ rsp + 0x130 ] and rbp, r9; x355 <- x346&0xffffffffffffff and r10, r9; x366 <- x361&0xffffffffffffff lea rax, [ rax + rcx ] mov r15, [ rsp + 0x0 ]; load m64 out1 to register64 mov [ r15 + 0x30 ], rdi; out1[6] = x360 mov [ r15 + 0x38 ], r10; out1[7] = x366 mov r8, r11; x375, copying x370 here, cause x370 is needed in a reg for other than x375, namely all: , x376, x375, size: 2 shr r8, 56; x375 <- x370>> 56 and r12, r9; x350 <- x341&0xffffffffffffff mov r13, rax; x373, copying x371 here, cause x371 is needed in a reg for other than x373, namely all: , x372, x373, size: 2 and r13, r9; x373 <- x371&0xffffffffffffff and r11, r9; x376 <- x370&0xffffffffffffff lea r8, [ r8 + rbp ] shr rax, 56; x372 <- x371>> 56 lea rax, [ rax + r12 ] and rbx, r9; x363 <- x356&0xffffffffffffff mov rdx, [ rsp + 0x148 ]; TMP = x368 mov [ r15 + 0x18 ], rdx; out1[3] = TMP mov [ r15 + 0x10 ], rbx; out1[2] = x363 mov [ r15 + 0x8 ], r8; out1[1] = x377 mov [ r15 + 0x28 ], rax; out1[5] = x374 mov [ r15 + 0x20 ], r13; out1[4] = x373 mov [ r15 + 0x0 ], r11; out1[0] = x376 mov rbx, [ rsp + 0x240 ]; restoring from stack mov rbp, [ rsp + 0x248 ]; restoring from stack mov r12, [ rsp + 0x250 ]; restoring from stack mov r13, [ rsp + 0x258 ]; restoring from stack mov r14, [ rsp + 0x260 ]; restoring from stack mov r15, [ rsp + 0x268 ]; restoring from stack add rsp, 0x270 ret ; cpu Intel(R) Core(TM) i7-6770HQ CPU @ 2.60GHz ; clocked at 2600 MHz ; first cyclecount 171.81, best 126.3125, lastGood 127.13541666666667 ; seed 3468290092887263 ; CC / CFLAGS clang / -march=native -mtune=native -O3 ; time needed: 3176720 ms / 60000 runs=> 52.94533333333333ms/run ; Time spent for assembling and measureing (initial batch_size=96, initial num_batches=101): 235110 ms ; Ratio (time for assembling + measure)/(total runtime for 60000runs): 0.07401029993200534 ; number reverted permutation/ tried permutation: 23709 / 29947 =79.170% ; number reverted decision/ tried decision: 23886 / 30054 =79.477%
#include <iostream> #include <string> #include <vector> template <typename T> std::istream& operator >>(std::istream& input, std::vector<T>& v) { for (T& a : v) input >> a; return input; } void answer(unsigned v) { std::cout << v << '\n'; } void no_answer() { std::cout << -1 << '\n'; } void solve(const std::vector<std::string>& s) { const size_t n = s.size(), m = s[0].length(); std::pair<size_t, size_t> lb = { n, m }, ub = { 0, 0 }; for (size_t i = 0; i < n; ++i) { for (size_t j = 0; j < m; ++j) { if (s[i][j] == 'B') { lb.first = std::min(lb.first, i); lb.second = std::min(lb.second, j); ub.first = std::max(ub.first, i); ub.second = std::max(ub.second, j); } } } if (lb.first == n && lb.second == m && ub.first == 0 && ub.second == 0) return answer(1); const size_t r = ub.first - lb.first + 1, c = ub.second - lb.second + 1, d = std::max(r, c); if (d > std::min(n, m)) return no_answer(); unsigned k = 0; for (size_t i = lb.first; i <= ub.first; ++i) { for (size_t j = lb.second; j <= ub.second; ++j) k += (s[i][j] == 'W'); } answer(k + d * d - r * c); } int main() { size_t n, m; std::cin >> n >> m; std::vector<std::string> s(n); std::cin >> s; solve(s); return 0; }
/* * Source code for the NPGR019 lab practices. Copyright Martin Kahoun 2021. * Licensed under the zlib license, see LICENSE.txt in the root directory. */ #include <Textures.h> #define STB_IMAGE_IMPLEMENTATION #include <stb/stb_image.h> Textures::Textures() : _samplers{0} { stbi_set_flip_vertically_on_load(true); } Textures::~Textures() { // Release samplers glDeleteSamplers((GLsizei)Sampler::NumSamplers, _samplers); } Textures& Textures::GetInstance() { static Textures instance; return instance; } GLuint Textures::CreateCheckerBoardTexture(unsigned int textureSize, unsigned int checkerSize, glm::vec3 oddColor, glm::vec3 evenColor, bool sRGB) { // Generate the texture name GLuint tex; glGenTextures(1, &tex); // Create the texture object (first bind call for this name) glBindTexture(GL_TEXTURE_2D, tex); // Generate texture RGB data const int stride = 3; unsigned char *data = new unsigned char[stride * textureSize * textureSize]; for (unsigned int y = 0; y < textureSize; ++y) { for (unsigned int x = 0; x < textureSize; ++x) { const bool odd = ((x / checkerSize + y / checkerSize) & 1) > 0; unsigned char r = (unsigned char)((odd ? oddColor.x : evenColor.x) * 255.0f + 0.5f); unsigned char g = (unsigned char)((odd ? oddColor.y : evenColor.y) * 255.0f + 0.5f); unsigned char b = (unsigned char)((odd ? oddColor.z : evenColor.z) * 255.0f + 0.5f); int i = y * stride * textureSize + x * stride; data[i] = r; data[i + 1] = g; data[i + 2] = b; } } // Upload texture data: 2D texture, mip level 0, internal format RGB, width, height, border, input format RGB, type, data glTexImage2D(GL_TEXTURE_2D, 0, sRGB ? GL_SRGB : GL_RGB, textureSize, textureSize, 0, GL_RGB, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); // Unbind the texture glBindTexture(GL_TEXTURE_2D, 0); // Delete the temporary buffer delete[] data; // Note: the caller is now responsible for handling this resource return tex; } GLuint Textures::CreateSingleColorTexture(unsigned char r, unsigned char g, unsigned char b) { // Generate the texture name GLuint tex; glGenTextures(1, &tex); // Create the texture object (first bind call for this name) glBindTexture(GL_TEXTURE_2D, tex); unsigned char data[] = {r, g, b}; // Upload texture data: 2D texture, mip level 0, internal format RGB, width, height, border, input format RGB, type, data glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1, 1, 0, GL_RGB, GL_UNSIGNED_BYTE, data); // Unbind the texture glBindTexture(GL_TEXTURE_2D, 0); return tex; } GLuint Textures::CreateMipMapTestTexture() { // Generate the texture name GLuint tex; glGenTextures(1, &tex); // Create the texture object (first bind call for this name) glBindTexture(GL_TEXTURE_2D, tex); const unsigned int stride = 3; unsigned char colors[] = { 255, 0, 0, 0, 255, 0, 0, 0, 255, 255, 255, 0, 255, 0, 255, 0, 255, 255, 255, 255, 255, 127, 127, 127, 0, 0, 0 }; for (unsigned int size = 256, mip = 0; size > 0; size >>= 1, ++mip) { // Create intermediate buffer and fill it with colors unsigned char *data = new unsigned char[stride * size * size]; for (unsigned int y = 0; y < size; ++y) { for (unsigned int x = 0; x < size; ++x) { int i = y * stride * size + x * stride; data[i] = colors[mip * stride]; data[i + 1] = colors[mip * stride + 1]; data[i + 2] = colors[mip * stride + 2]; } } // Upload texture data: 2D texture, mip level, internal format RGB, width, height, border, input format RGB, type, data glTexImage2D(GL_TEXTURE_2D, mip, GL_RGB, size, size, 0, GL_RGB, GL_UNSIGNED_BYTE, data); // Delete the intermediate buffer delete[] data; } // Unbind the texture glBindTexture(GL_TEXTURE_2D, 0); return tex; } GLuint Textures::LoadTexture(const char name[], bool sRGB) { // Load stored texture on the disk int width, height, numChannels; unsigned char *data = stbi_load(name, &width, &height, &numChannels, 0); // Early return when we failed to load the texture if (!data) { printf("Failed to load texture: %s\n", name); return 0; } // Generate the texture name GLuint tex; glGenTextures(1, &tex); // Create the texture object (first bind call for this name) glBindTexture(GL_TEXTURE_2D, tex); // Upload texture data: 2D texture, mip level 0, internal format RGB, width, height, border, input format RGB, type, data glTexImage2D(GL_TEXTURE_2D, 0, sRGB ? GL_SRGB : GL_RGB, width, height, 0, numChannels == 4 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, data); glGenerateMipmap(GL_TEXTURE_2D); // Free the image data, we don't need them anymore stbi_image_free(data); // Unbind the texture glBindTexture(GL_TEXTURE_2D, 0); return tex; } void Textures::CreateSamplers() { // Generate symbolic names for all samplers glGenSamplers((GLsizei)Sampler::NumSamplers, _samplers); // Query max anisotropy level - should be 16 on modern HW float maxAnistropy; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY, &maxAnistropy); // Set filtering modes: // Nearest neighbour or point filtering glSamplerParameteri(_samplers[(int)Sampler::Nearest], GL_TEXTURE_MAG_FILTER, GL_NEAREST); glSamplerParameteri(_samplers[(int)Sampler::Nearest], GL_TEXTURE_MIN_FILTER, GL_NEAREST); // Bilienar filtering, don't care about mip-maps glSamplerParameteri(_samplers[(int)Sampler::Bilinear], GL_TEXTURE_MAG_FILTER, GL_LINEAR); glSamplerParameteri(_samplers[(int)Sampler::Bilinear], GL_TEXTURE_MIN_FILTER, GL_LINEAR); // Trilinear filtering, do bilinar samples in two nearest mip-maps, linearly filter between the two samples glSamplerParameteri(_samplers[(int)Sampler::Trilinear], GL_TEXTURE_MAG_FILTER, GL_LINEAR); glSamplerParameteri(_samplers[(int)Sampler::Trilinear], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // Use mip-maps and anisotropic filter to obtain maxAnisotropy samples glSamplerParameteri(_samplers[(int)Sampler::Anisotropic], GL_TEXTURE_MAG_FILTER, GL_LINEAR); glSamplerParameteri(_samplers[(int)Sampler::Anisotropic], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glSamplerParameterf(_samplers[(int)Sampler::Anisotropic], GL_TEXTURE_MAX_ANISOTROPY, maxAnistropy); // Same as above glSamplerParameteri(_samplers[(int)Sampler::AnisotropicClamp], GL_TEXTURE_MAG_FILTER, GL_LINEAR); glSamplerParameteri(_samplers[(int)Sampler::AnisotropicClamp], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glSamplerParameterf(_samplers[(int)Sampler::AnisotropicClamp], GL_TEXTURE_MAX_ANISOTROPY, maxAnistropy); // Same as above glSamplerParameteri(_samplers[(int)Sampler::AnisotropicMirrored], GL_TEXTURE_MAG_FILTER, GL_LINEAR); glSamplerParameteri(_samplers[(int)Sampler::AnisotropicMirrored], GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glSamplerParameterf(_samplers[(int)Sampler::AnisotropicMirrored], GL_TEXTURE_MAX_ANISOTROPY, maxAnistropy); // -------------------------------------------------------------------------- // Set texture addressing mode: // Want to have the first modes to repeat outside [0, 1] range for (int i = 0; i <= (int)Sampler::Anisotropic; ++i) { glSamplerParameteri(_samplers[i], GL_TEXTURE_WRAP_S, GL_REPEAT); glSamplerParameteri(_samplers[i], GL_TEXTURE_WRAP_T, GL_REPEAT); } glSamplerParameteri(_samplers[(int)Sampler::Bilinear], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glSamplerParameteri(_samplers[(int)Sampler::Bilinear], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // This one should clamp the texture to edge glSamplerParameteri(_samplers[(int)Sampler::AnisotropicClamp], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glSamplerParameteri(_samplers[(int)Sampler::AnisotropicClamp], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // This one should repeat but in mirrored fashion glSamplerParameteri(_samplers[(int)Sampler::AnisotropicMirrored], GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glSamplerParameteri(_samplers[(int)Sampler::AnisotropicMirrored], GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); }
// Copyright (c) 2012-2017 The Bitcoin Core developers // Copyright (c) 2016-2019 The PIVX developers // Copyright (c) 2021 The DECENOMY Core Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "clientversion.h" #include "tinyformat.h" /** * Name of client reported in the 'version' message. Report the same name * for both oneworldd and oneworld-qt, to make it harder for attackers to * target servers or GUI users specifically. */ const std::string CLIENT_NAME("OneWorld Core"); /** * Client version number */ #define CLIENT_VERSION_SUFFIX "" /** * The following part of the code determines the CLIENT_BUILD variable. * Several mechanisms are used for this: * * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is * generated by the build environment, possibly containing the output * of git-describe in a macro called BUILD_DESC * * secondly, if this is an exported version of the code, GIT_ARCHIVE will * be defined (automatically using the export-subst git attribute), and * GIT_COMMIT will contain the commit id. * * then, three options exist for determining CLIENT_BUILD: * * if BUILD_DESC is defined, use that literally (output of git-describe) * * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit] * * otherwise, use v[maj].[min].[rev].[build]-unk * finally CLIENT_VERSION_SUFFIX is added */ //! First, include build.h if requested #ifdef HAVE_BUILD_INFO #include "obj/build.h" #endif //! git will put "#define GIT_ARCHIVE 1" on the next line inside archives. $Format:%n#define GIT_ARCHIVE 1$ #ifdef GIT_ARCHIVE #define GIT_COMMIT_ID "$Format:%H$" #define GIT_COMMIT_DATE "$Format:%cD$" #endif #define BUILD_DESC_WITH_SUFFIX(maj, min, rev, build, suffix) \ "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-" DO_STRINGIZE(suffix) #define BUILD_DESC_FROM_COMMIT(maj, min, rev, build, commit) \ "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit #define BUILD_DESC_FROM_UNKNOWN(maj, min, rev, build) \ "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk" #ifndef BUILD_DESC #ifdef BUILD_SUFFIX #define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX) #elif defined(GIT_COMMIT_ID) #define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID) #else #define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD) #endif #endif #ifndef BUILD_DATE #ifdef GIT_COMMIT_DATE #define BUILD_DATE GIT_COMMIT_DATE #else #define BUILD_DATE __DATE__ ", " __TIME__ #endif #endif const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); const std::string CLIENT_DATE(BUILD_DATE); static std::string FormatVersion(int nVersion) { if (nVersion % 100 == 0) return strprintf("%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100); else return strprintf("%d.%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100, nVersion % 100); } std::string FormatFullVersion() { return CLIENT_BUILD; } std::string FormatVersionFriendly() { return FormatVersion(CLIENT_VERSION); } /** * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) */ std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector<std::string>& comments) { std::ostringstream ss; ss << "/"; ss << name << ":" << FormatVersion(nClientVersion); if (!comments.empty()) { std::vector<std::string>::const_iterator it(comments.begin()); ss << "(" << *it; for (++it; it != comments.end(); ++it) ss << "; " << *it; ss << ")"; } ss << "/"; return ss.str(); }
;Parallel Ports & LED Display ;Daniel Noyes, Andrew Haas, Benjamin Doiron ;Group 11, Lab 5, March 13th, 2013 ;*************************************************************************** ;Revision Notes; ; ; Revised Lab 4 and created Lab 5 routines [Dan:March-8-2013] ; ;*************************************************************************** ; export symbols XDEF Entry, _Startup ; export 'Entry' symbol ABSENTRY Entry ; for absolute assembly: mark this as entry point ;*************************************************************************** ; equates RAMStart: EQU $1000 ; absoolute address of the start of RAM: Variables ROMSTART: EQU $C000 ; absolute Address to place code/constant Data RAM_END: EQU $3FFF ; absolute address of the End of RAM: Variables PTA: EQU $0000 ; Port A PTB: EQU $0001 ; Port B [LED display] PTP: EQU $0258 ; Port P [LED select] PTH: EQU $0260 DDRA: EQU $0002 ; enable port A [bit specific: 1 = output, 0 = input] DDRB: EQU $0003 ; enable port B [bit specific: 1 = output, 0 = input] DDRP: EQU $025A ; enable port P DDRH: EQU $0262 ATDCTL2: EQU $82 ATDCTL3: EQU $83 ATDCTL4: EQU $84 ATDCTL5: EQU $85 ATDCTL6: EQU $86 ATDDIEN: EQU $8D ATDDR0: EQU $90 ATDDR1: EQU $92 CRG_FLG: EQU $0037 ; to clear the interupt by writing 1 to RTIF (%10000000) CRG_INT: EQU $0038 ; enable the interrupt RTI_CTL: EQU $003B ; RTI clock rate ($40 ~ 1.024 ms) TSK_1: EQU $1 ; Output LCD Display TSK_2: EQU $2 ; Set the output for task 3 TSK_3: EQU $4 ; increment the time value (1s) MODE_FLG: EQU $8 ENTER_FLG: EQU $10 TMP_CON_FLG:EQU $20 T3COUNT: EQU 100 LED0 EQU $3F LED1 EQU $06 LED2 EQU $5B LED3 EQU $4F LED4 EQU $66 LED5 EQU $6D LED6 EQU $7D LED7 EQU $07 LED8 EQU $7F LED9 EQU $6F LEDA EQU $77 LEDB EQU $7C LEDC EQU $39 LEDD EQU $5E LEDE EQU $79 LEDF EQU $71 LED10 EQU $40 DS1 EQU $E DS2 EQU $D DS3 EQU $B DS4 EQU $7 DS0 EQU $F ;*************************************************************************** ;variable/data section ORG RAMStart NUM_2_DISPLAY: DS.B 2 ; Number Display (16-bit) LEDNUM: DS.B 1 T_FLG: DS.B 1 CNTA: DS.B 1 CNTB: DS.B 1 CNT2: DS.B 1 CNTC: DS.B 1 NUMBERS: DS.B 4 NUM_SELECT: DS.B 1 CURRENT_NUM: DS.B 1 CURRENT_KEY: DS.B 1 NEW_KEY: DS.B 1 KEY_COUNT: DS.B 1 NUM_TABLE: DC.B LED0 DC.B LED1 DC.B LED2 DC.B LED3 DC.B LED4 DC.B LED5 DC.B LED6 DC.B LED7 DC.B LED8 DC.B LED9 DC.B LEDA DC.B LEDB DC.B LEDC DC.B LEDD DC.B LEDE DC.B LEDF DC.B LED10 DS_TABLE: DC.B DS1 DC.B DS2 DC.B DS3 DC.B DS4 TEMP_TBL: ; Table with corresponding temperature values replacing the resistance values (0-255) DC.B $90 ; 0 DC.B $90 ; 1 DC.B $90 ; 2 DC.B $90 ; 3 DC.B $90 ; 4 DC.B $90 ; 5 DC.B $90 ; 6 DC.B $90 ; 7 DC.B $90 ; 8 DC.B $90 ; 9 DC.B $90 ; 10 DC.B $90 ; 11 DC.B $90 ; 12 DC.B $90 ; 13 DC.B $90 ; 14 DC.B $90 ; 15 DC.B $90 ; 16 DC.B $90 ; 17 DC.B $90 ; 18 DC.B $90 ; 19 DC.B $90 ; 20 DC.B $90 ; 21 DC.B $90 ; 22 DC.B $90 ; 23 DC.B $90 ; 24 DC.B $90 ; 25 DC.B $90 ; 26 DC.B $90 ; 27 DC.B $90 ; 28 DC.B $90 ; 29 DC.B $90 ; 30 DC.B $90 ; 31 DC.B $90 ; 32 DC.B $90 ; 33 DC.B $90 ; 34 DC.B $90 ; 35 DC.B $90 ; 36 DC.B $90 ; 37 DC.B $90 ; 38 DC.B $90 ; 39 DC.B $90 ; 40 DC.B $90 ; 41 DC.B $90 ; 42 DC.B $90 ; 43 DC.B $90 ; 44 DC.B $90 ; 45 DC.B $90 ; 46 DC.B $90 ; 47 DC.B $90 ; 48 DC.B $90 ; 49 DC.B $90 ; 50 DC.B $90 ; 51 DC.B $90 ; 52 DC.B $90 ; 53 DC.B $90 ; 54 DC.B $90 ; 55 DC.B $90 ; 56 DC.B $90 ; 57 DC.B $90 ; 58 DC.B $90 ; 59 DC.B $90 ; 60 DC.B $90 ; 61 DC.B $90 ; 62 DC.B $90 ; 63 DC.B $90 ; 64 DC.B $90 ; 65 DC.B $90 ; 66 DC.B $90 ; 67 DC.B $90 ; 68 DC.B $90 ; 69 DC.B $90 ; 70 DC.B $90 ; 71 DC.B $90 ; 72 DC.B $90 ; 73 DC.B $90 ; 74 DC.B $90 ; 75 DC.B $90 ; 76 DC.B $90 ; 77 DC.B $90 ; 78 DC.B $90 ; 79 DC.B $90 ; 80 DC.B $90 ; 81 DC.B $90 ; 82 DC.B $90 ; 83 DC.B $90 ; 84 DC.B $90 ; 85 DC.B $90 ; 86 DC.B $90 ; 87 DC.B $90 ; 88 DC.B $90 ; 89 DC.B $90 ; 90 DC.B $90 ; 91 DC.B $90 ; 92 DC.B $90 ; 93 DC.B $90 ; 94 DC.B $90 ; 95 DC.B $90 ; 96 DC.B $90 ; 97 DC.B $90 ; 98 DC.B $90 ; 99 DC.B $90 ; 100 DC.B $90 ; 101 DC.B $90 ; 102 DC.B $90 ; 103 DC.B $90 ; 104 DC.B $90 ; 105 DC.B $90 ; 106 DC.B $90 ; 107 DC.B $90 ; 108 DC.B $89 ; 109 DC.B $89 ; 110 DC.B $88 ; 111 DC.B $87 ; 112 DC.B $86 ; 113 DC.B $86 ; 114 DC.B $85 ; 115 DC.B $85 ; 116 DC.B $85 ; 117 DC.B $83 ; 118 DC.B $83 ; 119 DC.B $82 ; 120 DC.B $81 ; 121 DC.B $81 ; 122 DC.B $80 ; 123 DC.B $79 ; 124 DC.B $79 ; 125 DC.B $78 ; 126 DC.B $77 ; 127 DC.B $77 ; 128 DC.B $76 ; 129 DC.B $75 ; 130 DC.B $75 ; 131 DC.B $74 ; 132 DC.B $73 ; 133 DC.B $73 ; 134 DC.B $72 ; 135 DC.B $72 ; 136 DC.B $71 ; 137 DC.B $70 ; 138 DC.B $70 ; 139 DC.B $69 ; 140 DC.B $68 ; 141 DC.B $68 ; 142 DC.B $67 ; 143 DC.B $67 ; 144 DC.B $66 ; 145 DC.B $65 ; 146 DC.B $65 ; 147 DC.B $64 ; 148 DC.B $63 ; 149 DC.B $63 ; 150 DC.B $62 ; 151 DC.B $61 ; 152 DC.B $61 ; 153 DC.B $60 ; 154 DC.B $60 ; 155 DC.B $59 ; 156 DC.B $58 ; 157 DC.B $58 ; 158 DC.B $57 ; 159 DC.B $56 ; 160 DC.B $56 ; 161 DC.B $55 ; 162 DC.B $54 ; 163 DC.B $54 ; 164 DC.B $53 ; 165 DC.B $52 ; 166 DC.B $52 ; 167 DC.B $51 ; 168 DC.B $50 ; 169 DC.B $49 ; 170 DC.B $49 ; 171 DC.B $48 ; 172 DC.B $48 ; 173 DC.B $47 ; 174 DC.B $46 ; 175 DC.B $46 ; 176 DC.B $45 ; 177 DC.B $44 ; 178 DC.B $44 ; 179 DC.B $43 ; 180 DC.B $42 ; 181 DC.B $42 ; 182 DC.B $41 ; 183 DC.B $40 ; 184 DC.B $40 ; 185 DC.B $40 ; 186 DC.B $40 ; 187 DC.B $40 ; 188 DC.B $40 ; 189 DC.B $40 ; 190 DC.B $40 ; 191 DC.B $40 ; 192 DC.B $40 ; 193 DC.B $40 ; 194 DC.B $40 ; 195 DC.B $40 ; 196 DC.B $40 ; 197 DC.B $40 ; 198 DC.B $40 ; 199 DC.B $40 ; 200 DC.B $40 ; 201 DC.B $40 ; 202 DC.B $40 ; 203 DC.B $40 ; 204 DC.B $40 ; 205 DC.B $40 ; 206 DC.B $40 ; 207 DC.B $40 ; 208 DC.B $40 ; 209 DC.B $40 ; 210 DC.B $40 ; 211 DC.B $40 ; 212 DC.B $40 ; 213 DC.B $40 ; 214 DC.B $40 ; 215 DC.B $40 ; 216 DC.B $40 ; 217 DC.B $40 ; 218 DC.B $40 ; 219 DC.B $40 ; 220 DC.B $40 ; 221 DC.B $40 ; 222 DC.B $40 ; 223 DC.B $40 ; 224 DC.B $40 ; 225 DC.B $40 ; 226 DC.B $40 ; 227 DC.B $40 ; 228 DC.B $40 ; 229 DC.B $40 ; 230 DC.B $40 ; 231 DC.B $40 ; 232 DC.B $40 ; 233 DC.B $40 ; 234 DC.B $40 ; 235 DC.B $40 ; 236 DC.B $40 ; 237 DC.B $40 ; 238 DC.B $40 ; 239 DC.B $40 ; 240 DC.B $40 ; 241 DC.B $40 ; 242 DC.B $40 ; 243 DC.B $40 ; 244 DC.B $40 ; 245 DC.B $40 ; 246 DC.B $40 ; 247 DC.B $40 ; 248 DC.B $40 ; 249 DC.B $40 ; 250 DC.B $40 ; 251 DC.B $40 ; 252 DC.B $40 ; 253 DC.B $40 ; 254 DC.B $40 ; 255 ;*************************************************************************** ; Code section ORG ROMSTART Entry: _Startup: ;*************************************************************************** ; Inilitilizing the program LDS #RAM_END ; initialize the stack pointer. LDAA #%10000000 ; load the 1 in 7th bit to enable the ... STAA CRG_INT ; and set the period counter. LDAA #$40 ; loads a value (hex 40) to the clock ... STAA RTI_CTL ; for a 1 ms clock rate for the rti CLR T_FLG ; reset the task flag CLR CNTA ; reset the count variable A [rti-subroutine] CLR CNTB ; reset the count variable B [rti-subroutine] CLR NUM_2_DISPLAY CLR (NUM_2_DISPLAY+1) CLR LEDNUM CLR KEY_COUNT CLR CURRENT_KEY CLR (NUMBERS) ;clear all the numbers CLR (NUMBERS+1) CLR (NUMBERS+2) LDAA #$FF STAA (NUMBERS+3) ;set min as a $FF so it can change LDAA #%10000000 ;initilize the A/D converter STAA ATDCTL2 ;powerup LDAA #%00010000 STAA ATDCTL3 ;set the sequence LDAA #%10000000 STAA ATDCTL4 ;set 8 bit resolution LDAA #$FF STAA DDRB STAA DDRP CLI ; clear the i bit ;*************************************************************************** ; Subroutines ;*************************************************************************** ; Main Routine Main: LDAA T_FLG ; Loads the Task flag to check for a specific task flag BITA #TSK_1 ; Check the task flag towards the first task flag BEQ SKIP_1 ; if the flag is not checked will skip to next check JSR TASK_1 ; jumps to task 1 SKIP_1: BITA #TSK_2 ; BEQ SKIP_2 ; skip to task 2 JSR TASK_2 ; jumps to task 2 SKIP_2: BITA #TSK_3 ; BEQ SKIP_3 ; skip task 3 JSR TASK_3 ; jumps to task 3 SKIP_3: BITA #MODE_FLG BEQ SKIP_4 JSR MODE SKIP_4: BITA #ENTER_FLG BEQ SKIP_5 JSR ENTER SKIP_5: BITA #TMP_CON_FLG BEQ SKIP_6 JSR TMP_CON SKIP_6: BRA Main ; main loop to the beginning and check the flags again ;*************************************************************************** ;Task 1 ; ; Display the value of the LCD to the seven segment Display ; TASK_1: PSHA LDX #NUM_TABLE LDY #DS_TABLE LDAB LEDNUM ; goes through which LED to display CMPB #0 ; every time it will increment BNE T1.1 ; till it reaches 4 and restarts JSR DSET0 T1.1: CMPB #1 BNE T1.2 JSR DSET1 T1.2: CMPB #2 BNE T1.3 JSR DSET2 T1.3: CMPB #3 BNE T1.4 JSR DSET3 T1.4: LDAB LEDNUM INCB CMPB #$4 BNE T1.5 LDAB #$0 T1.5: STAB LEDNUM SEI PULA ; returns the task flag from the stack to A ANDA #(TSK_1 ^ $FF) ; Clears the task flag, prevent main from running this task again right after STAA T_FLG ; CLI ; allow rti RTS ; RETURN from stack ;*************************************************************************** ; Display ; This will display a given value ; Req: A: number ; B: LED Select ; X: number Select table ; Y: LED Select table ; ;disable display -> set LED val[a+x] -> enable display[b+y] ; DISPLAY: PSHB LDAB #DS0 STAB PTP LDAA A,X STAA PTB PULB LDAB B,Y STAB PTP RTS ;*************************************************************************** ; Set the Value based on which number to display ; ; SETN [0][1][2][3] ; DSET0: LDAA NUM_2_DISPLAY ;loads the 1st byt LSRA ;then move it right -> 4 bits LSRA ; to get they digit we want LSRA LSRA JSR DISPLAY ;display function RTS DSET1: LDAA NUM_2_DISPLAY ANDA #$F ;mask 1st nibble with a and JSR DISPLAY RTS DSET2: LDAA #$10 JSR DISPLAY RTS DSET3: LDAA (NUM_2_DISPLAY+1) ANDA #$F ;need to mask 1st nibble JSR DISPLAY RTS ;*************************************************************************** ;Task 2 ; for this operation we grab a variable from the memory. This variable was ; set to a 100 during initilization. Everytime task 2 starts, it checks to ; see if the value in the memory is 0. ; true = reset the value bask to 100 and flag task 3. ; false = decrease the memory and ends the routine ; TASK_2 ; pushes the task flag onto the stack to save it JSR KEY_DETECT JSR REFRESH T2.END SEI ; ANDA #(TSK_2 ^ $FF) ; Clears the task flag, prevent main from running this task again right after STAA T_FLG ; CLI ; RTS ; RETURN from stack ;*************************************************************************** ;Task 3 ; Will add one to the count ; TASK_3 JSR DECODE SEI ; LDAA T_FLG ; returns the task flag from the stack to A ANDA #(TSK_3 ^ $FF) ; Clears the task flag, prevent main from running this task again right after STAA T_FLG ; CLI ; RTS ; RETURN from stack ;*************************************************************************** ;Lab 5 Functions ; KEY_DETECT: PSHA LDAA PTH CMPA #$FF BEQ KEY_D.ER CMPA #$F7 BEQ KEY_D.1 CMPA #$FE BEQ KEY_D.1 KEY_D.ER: LDAB #$FF STAB NEW_KEY JSR DEBOUNCE PULA BRA KEY_D.END KEY_D.1: STAA NEW_KEY PULA JSR DEBOUNCE KEY_D.END: RTS ;************************************ DEBOUNCE: SEI PSHD CLI LDAA NEW_KEY CMPA CURRENT_KEY BNE DEB.1 LDAA #$0 STAA KEY_COUNT PULD BRA DEB.END DEB.1 LDAB KEY_COUNT INCB CMPB #$5 BEQ DEB.2 STAB KEY_COUNT SEI PULD CLI BRA DEB.END DEB.2 STAA CURRENT_KEY LDAB #$0 STAB KEY_COUNT SEI PULD EORA #TSK_3 ; set task 3 STAA T_FLG ; Store Task flag CLI DEB.END RTS ;************************************ DECODE: SEI PSHB CLI LDAB CURRENT_KEY CMPB #$F7 BNE DECODE.1 EORA #MODE_FLG DECODE.1: CMPB #$FE BNE DECODE.E EORA #ENTER_FLG DECODE.E: STAA T_FLG SEI PULB CLI RTS ;************************************ MODE: PSHA PSHX LDAA NUM_2_DISPLAY ;variable LDAB (NUM_2_DISPLAY+1) ;which variable INCB CMPB #$4 BLT MODE.1 CLRB MODE.1: STAB (NUM_2_DISPLAY+1) LDX #NUMBERS LDAA B,X STAA NUM_2_DISPLAY PULX PULA ANDA #(MODE_FLG ^ $FF) STAA T_FLG RTS ;************************************ REFRESH: PSHA PSHX LDAA NUM_2_DISPLAY ;variable LDAB (NUM_2_DISPLAY+1) ;which variable LDX #NUMBERS LDAA B,X STAA NUM_2_DISPLAY PULX PULA RTS ;************************************ ENTER: SEI PSHX PSHD CLR (NUMBERS+2) LDAA #$FF STAA (NUMBERS+3) PULD ANDA #(ENTER_FLG ^ $FF) STAA T_FLG PULX CLI RTS ;************************************* ;Temperature measurement and conversion routine ;save largest of chan 1 (inside to the max and min) TMP_CON: SEI PSHD PSHX LDX #TEMP_TBL LDAA #%00010010 ;start the A/D STAA ATDCTL5 TMP_CON_1: LDAA ATDCTL6 ;grabing AN2 BITA #%10000000 BNE TMP_CON_2 NOP BRA TMP_CON_1 TMP_CON_2: LDAA ATDDR0 LDAA A,X STAA NUMBERS LDAA ATDDR1 LDAA A,X STAA (NUMBERS+1) CMPA (NUMBERS+2) BLO TMP_CON_3 STAA (NUMBERS+2) TMP_CON_3: CMPA (NUMBERS+3) BHI TMP_CON_4 STAA (NUMBERS+3) TMP_CON_4: PULX PULD ANDA #(TMP_CON_FLG ^ $FF) STAA T_FLG CLI RTS ;*************************************************************************** ;RTI ; maintain two counters that will increment by 1 each time RTI is entered ; CNTA 0->4 : set task flag 1 ; CNTB 0->9 : set task flag 2 ; clear the interrupt when leaving the RTI ; RTI_ISR: LDAA CNTA ; LDAB CNTB ; loads CNTA & CNTB and proceed with the loop checks INCA ; add to count A and check to see if it is a 4 CMPA #4 ; true = flag task 1, reset count A BNE RTI_A1 ; false = skips and goes to count B LDAA #0 ; STAA CNTA ; LDAA T_FLG EORA #TSK_1 ; STAA T_FLG ; BRA RTI_B ; RTI_A1: STAA CNTA ; RTI_B: INCB ; adds to count B and check to see if it is a 9 CMPB #9 ; true = flag task 2, reset count B BNE RTI_B1 ; false = skip and return from the interupt LDAB #0 ; STAB CNTB ; LDAA T_FLG EORA #TSK_2 ; STAA T_FLG ; BRA RTI_C ; RTI_B1: STAB CNTB ; RTI_C: LDAA CNTC INCA CMPA #0 BNE RTI_C1 STAA CNTC LDAA T_FLG EORA #TMP_CON_FLG STAA T_FLG BRA RTI_END RTI_C1: STAA CNTC RTI_END: LDAA #%10000000 ; STAA CRG_FLG ; clear the interupt RTI ; RETURN from interupt ;*************************************************************************** ; catch-all isr ; if any onther task flags are enabled then will return from their interupts ; DFLT_ISR: NOP ; let cpu hang for a second RTI ; RETURN from the interupt routine ;*************************************************************************** ; Interrupt Vectors [rti interupts] ; writes the memory locations for various interrupts to prevent the system ; from hanging ; ORG $FFF0 ; DC.W RTI_ISR ;rti DC.W DFLT_ISR ;irq pin DC.W DFLT_ISR ;xirq pin DC.W DFLT_ISR ;swi DC.W DFLT_ISR ;non_inst DC.W DFLT_ISR ;cop fail DC.W DFLT_ISR ;clk fail DC.W Entry ;reset vector
.file "supersecret.c" .intel_syntax noprefix .def ___main; .scl 2; .type 32; .endef .section .rdata,"dr" .align 4 LC0: .ascii "Enter the super secret password:\0" .align 4 LC1: .ascii "Access granted.\12Hello, Batman!\0" .align 4 LC2: .ascii "Error: the CSI guys are now after you.\0" .text .globl _main .def _main; .scl 2; .type 32; .endef _main: push ebp mov ebp, esp and esp, -16 sub esp, 48 call ___main mov DWORD PTR [esp+38], 1919907699 mov DWORD PTR [esp+42], 1936287332 mov WORD PTR [esp+46], 104 mov DWORD PTR [esp], OFFSET FLAT:LC0 call _puts mov eax, DWORD PTR __imp___iob mov DWORD PTR [esp+8], eax mov DWORD PTR [esp+4], 16 lea eax, [esp+22] mov DWORD PTR [esp], eax call _fgets lea eax, [esp+22] mov DWORD PTR [esp], eax call _strlen sub eax, 1 mov BYTE PTR [esp+22+eax], 0 lea eax, [esp+22] mov DWORD PTR [esp+4], eax lea eax, [esp+38] mov DWORD PTR [esp], eax call _strcmp test eax, eax jne L2 mov DWORD PTR [esp], OFFSET FLAT:LC1 call _puts jmp L3 L2: mov DWORD PTR [esp], OFFSET FLAT:LC2 call _puts L3: mov eax, 0 leave ret .ident "GCC: (tdm64-1) 5.1.0" .def _puts; .scl 2; .type 32; .endef .def _fgets; .scl 2; .type 32; .endef .def _strlen; .scl 2; .type 32; .endef .def _strcmp; .scl 2; .type 32; .endef
; A066665: a(n) = #{(x,y) | 0<=y<=x<=n and x+y is prime}. ; 1,3,5,7,9,11,14,16,19,23,27,31,35,38,42,47,52,56,61,65,70,76,82,88,94,100,107,114,121,128,136,143,150,158,166,175,185,194,203,213,223,233,243,252,262,272,282,291,301,311,322,334,346 mov $2,$0 add $2,1 mov $3,$0 lpb $2 mov $0,$3 sub $2,1 sub $0,$2 seq $0,35250 ; Number of primes between n and 2n (inclusive). add $1,$0 lpe mov $0,$1
; A142134: Primes congruent to 25 mod 37. ; Submitted by Jamie Morken(w1) ; 173,617,691,839,1061,1283,1579,1801,1949,2393,2467,2689,2837,3947,4021,4243,4391,4909,5279,5501,6389,6833,6907,7129,7351,7499,7573,8017,8387,8461,8609,8831,9127,9349,9497,9719,9941,10163,10459,10607,10903,11273,11717,11939,12161,12457,13049,13567,13789,14011,14159,15121,15269,15787,16231,16453,16823,17341,17489,18229,18451,19709,21559,21929,22003,22447,22669,22817,23039,23557,24001,24223,24371,24593,24889,25037,25111,25703,25999,26591,26813,27109,27479,27701,27997,28219,28663,29033,29921,30661 mov $1,34 mov $2,$0 add $2,2 pow $2,2 lpb $2 sub $1,22 sub $2,1 mov $3,$1 mul $3,2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,59 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe mov $0,$1 mul $0,2 sub $0,117
; A244174: Number of compositions of 3n in which the minimal multiplicity of parts equals n. ; 1,3,7,21,71,253,925,3433,12871,48621,184757,705433,2704157,10400601,40116601,155117521,601080391,2333606221,9075135301,35345263801,137846528821,538257874441,2104098963721,8233430727601,32247603683101,126410606437753,495918532948105,1946939425648113,7648690600760441,30067266499541041,118264581564861425,465428353255261089,1832624140942590535,7219428434016265741,28453041475240576741,112186277816662845433,442512540276836779205,1746130564335626209833,6892620648693261354601,27217014869199032015601,107507208733336176461621,424784580848791721628841,1678910486211891090247321,6637553085023755473070801,26248505381684851188961801,103827421287553411369671121,410795449442059149332177041,1625701140345170250548615521,6435067013866298908421603101,25477612258980856902730428601,100891344545564193334812497257,399608854866744452032002440113,1583065848125949175357548128137,6272525058612251449529907677521,24857784491537440929618523018321,98527218530093856775578873054433,390590044887157789360330532465785,1548655265692941410446222812934513,6141219157058215937976400809912721,24356699707654619143838606602026721,96614908840363322603893139521372657,383291933432261050330199012527412833 mov $1,$0 mul $0,2 bin $0,$1 div $0,2 mul $0,2 add $0,1
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 5, 0x90 .globl _DecryptECB_RIJ128pipe_AES_NI _DecryptECB_RIJ128pipe_AES_NI: push %ebp mov %esp, %ebp push %ebx push %esi push %edi movl (8)(%ebp), %esi movl (12)(%ebp), %edi movl (20)(%ebp), %ecx movl (24)(%ebp), %edx movl (16)(%ebp), %eax sub $(64), %edx jl .Lshort_inputgas_1 lea (,%eax,4), %ebx lea (%ecx,%ebx,4), %ecx .Lblks_loopgas_1: movdqa (%ecx), %xmm4 lea (-16)(%ecx), %ebx movdqu (%esi), %xmm0 movdqu (16)(%esi), %xmm1 movdqu (32)(%esi), %xmm2 movdqu (48)(%esi), %xmm3 add $(64), %esi pxor %xmm4, %xmm0 pxor %xmm4, %xmm1 pxor %xmm4, %xmm2 pxor %xmm4, %xmm3 movdqa (%ebx), %xmm4 sub $(16), %ebx movl (16)(%ebp), %eax sub $(1), %eax .Lcipher_loopgas_1: aesdec %xmm4, %xmm0 aesdec %xmm4, %xmm1 aesdec %xmm4, %xmm2 aesdec %xmm4, %xmm3 movdqa (%ebx), %xmm4 sub $(16), %ebx dec %eax jnz .Lcipher_loopgas_1 aesdeclast %xmm4, %xmm0 movdqu %xmm0, (%edi) aesdeclast %xmm4, %xmm1 movdqu %xmm1, (16)(%edi) aesdeclast %xmm4, %xmm2 movdqu %xmm2, (32)(%edi) aesdeclast %xmm4, %xmm3 movdqu %xmm3, (48)(%edi) add $(64), %edi sub $(64), %edx jge .Lblks_loopgas_1 .Lshort_inputgas_1: add $(64), %edx jz .Lquitgas_1 movl (16)(%ebp), %eax movl (20)(%ebp), %ecx lea (,%eax,4), %ebx lea (%ecx,%ebx,4), %ebx .Lsingle_blk_loopgas_1: movdqu (%esi), %xmm0 add $(16), %esi pxor (%ebx), %xmm0 cmp $(12), %eax jl .Lkey_128_sgas_1 jz .Lkey_192_sgas_1 .Lkey_256_sgas_1: aesdec (208)(%ecx), %xmm0 aesdec (192)(%ecx), %xmm0 .Lkey_192_sgas_1: aesdec (176)(%ecx), %xmm0 aesdec (160)(%ecx), %xmm0 .Lkey_128_sgas_1: aesdec (144)(%ecx), %xmm0 aesdec (128)(%ecx), %xmm0 aesdec (112)(%ecx), %xmm0 aesdec (96)(%ecx), %xmm0 aesdec (80)(%ecx), %xmm0 aesdec (64)(%ecx), %xmm0 aesdec (48)(%ecx), %xmm0 aesdec (32)(%ecx), %xmm0 aesdec (16)(%ecx), %xmm0 aesdeclast (%ecx), %xmm0 movdqu %xmm0, (%edi) add $(16), %edi sub $(16), %edx jnz .Lsingle_blk_loopgas_1 .Lquitgas_1: pop %edi pop %esi pop %ebx pop %ebp ret
struct Foo_empty {}; struct Foo; struct Bar { Foo *f; }; void baz_struct(Foo* f); union Union; void baz_union(Union* u); class Quux; void baz_class(Quux* q);
; A178414: Least odd number in the Collatz (3x+1) preimage of odd numbers not a multiple of 3. ; 1,3,9,7,17,11,25,15,33,19,41,23,49,27,57,31,65,35,73,39,81,43,89,47,97,51,105,55,113,59,121,63,129,67,137,71,145,75,153,79,161,83,169,87,177,91,185,95,193,99,201,103,209,107,217,111,225,115,233,119,241,123,249,127,257,131,265,135,273,139,281,143,289,147,297,151,305,155,313,159,321,163,329,167,337,171,345,175,353,179,361,183,369,187,377,191,385,195,393,199,401,203,409,207,417,211,425,215,433,219,441,223,449,227,457,231,465,235,473,239,481,243,489,247,497,251,505,255,513,259,521,263,529,267,537,271,545,275,553,279,561,283,569,287,577,291,585,295,593,299,601,303,609,307,617,311,625,315,633,319,641,323,649,327,657,331,665,335,673,339,681,343,689,347,697,351,705,355,713,359,721,363,729,367,737,371,745,375,753,379,761,383,769,387,777,391,785,395,793,399,801,403,809,407,817,411,825,415,833,419,841,423,849,427,857,431,865,435,873,439,881,443,889,447,897,451,905,455,913,459,921,463,929,467,937,471,945,475,953,479,961,483,969,487,977,491,985,495,993,499 mov $1,$0 gcd $0,2 mul $1,2 mul $1,$0 add $1,1
; A344853: a(n) = n minus (sum of digits of n in base 3). ; 0,0,0,2,2,2,4,4,4,8,8,8,10,10,10,12,12,12,16,16,16,18,18,18,20,20,20,26,26,26,28,28,28,30,30,30,34,34,34,36,36,36,38,38,38,42,42,42,44,44,44,46,46,46,52,52,52,54,54,54,56,56,56,60,60,60,62,62,62 lpb $0 div $0,3 add $1,$0 lpe mul $1,2 mov $0,$1
[bits 32] VIDEO_MEMORY equ 0xb8000 print_string_pm: pusha mov edx, VIDEO_MEMORY mov ah, 0x0f .printchar: mov al, [ebx] cmp al, 0 je .done mov [edx], ax add edx, 2 inc ebx jmp .printchar .done: popa ret
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r8 push %r9 push %rcx push %rdi push %rsi lea addresses_D_ht+0x1b59a, %rsi lea addresses_UC_ht+0x1864a, %rdi clflush (%rsi) cmp $42664, %r12 mov $13, %rcx rep movsl nop cmp $40136, %r9 lea addresses_WT_ht+0x1624a, %rsi lea addresses_D_ht+0x149fa, %rdi clflush (%rdi) nop dec %r8 mov $104, %rcx rep movsl nop nop nop nop dec %r9 pop %rsi pop %rdi pop %rcx pop %r9 pop %r8 pop %r12 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r14 push %r15 push %rcx push %rdx push %rsi // Store lea addresses_WC+0x17e4a, %r12 clflush (%r12) nop nop nop nop dec %r13 movb $0x51, (%r12) and $14761, %r14 // Load mov $0xa52, %rsi nop add $62232, %r15 mov (%rsi), %ecx nop nop nop nop cmp $8160, %rcx // Load lea addresses_WT+0x1f8d2, %r12 sub %rdx, %rdx mov (%r12), %r14w nop nop nop nop nop xor %rdx, %rdx // Faulty Load lea addresses_A+0x7e4a, %r12 nop nop nop nop cmp $46582, %rdx movups (%r12), %xmm5 vpextrq $1, %xmm5, %r13 lea oracles, %r12 and $0xff, %r13 shlq $12, %r13 mov (%r12,%r13,1), %r13 pop %rsi pop %rdx pop %rcx pop %r15 pop %r14 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_A', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_WC', 'AVXalign': False, 'size': 1}} {'src': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_P', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_WT', 'AVXalign': True, 'size': 2}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_A', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}} {'src': {'same': False, 'congruent': 10, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}} {'20': 70, 'ab': 138, '3b': 35, '56': 4, 'e5': 1, '67': 52, '44': 26, 'fb': 36, '5b': 1287, '5e': 4, 'fd': 32, '00': 2228, '42': 395, 'f3': 1, 'c5': 1, '0e': 5, '61': 5, 'b3': 1104, '0f': 6, '8b': 83, 'fa': 33, '96': 1, '6c': 8, '5c': 407, '41': 222, 'd2': 22, 'c7': 7, '25': 9, 'fc': 18, 'f7': 11, '8f': 746, '68': 30, 'ed': 13, '22': 15, '46': 5873, 'e1': 83, '14': 28, '1c': 14, 'df': 108, '40': 129, 'e4': 70, 'ff': 6388, 'e9': 163, 'bc': 1, 'ac': 12, '98': 1, '08': 16, 'ce': 29, 'a7': 502, 'e3': 23, '37': 24, '77': 8, '2a': 10, 'cc': 533, '48': 28, 'a5': 1, '49': 59, '93': 1, '17': 11, 'af': 237, '81': 55, '66': 328, '1b': 1, '9b': 1, '76': 30, 'ba': 7} 00 00 25 00 25 00 25 00 25 00 25 00 25 00 25 00 25 00 25 00 00 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 5c 00 fb 00 fb 00 fb 00 fb 00 fb 5c 00 fb 00 fb 00 fb 5c 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 00 fb 5c 5c 00 5c 00 fb 00 fb 00 fb 00 fb 00 46 00 fb 00 fb 00 fb 00 fb 00 fb 00 00 00 00 00 00 00 00 00 00 fa 00 00 00 00 fa 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa 00 00 00 00 00 00 00 00 00 00 fa 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 42 ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa ff fa fa ff fa ff ff ff ff ff ff ff ff ff ff ff ff 46 ff 46 ff 46 ff 46 ff ff 46 ff 46 ff 46 ff ff 46 ff 46 ff ff ff 46 ff ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 ff ff 46 ff 46 ff 46 ff 46 ff 46 42 42 42 42 46 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 46 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 46 42 46 42 42 42 42 42 42 42 42 42 46 46 42 42 42 46 42 42 42 42 42 42 42 42 42 42 42 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 ff 46 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff b3 ff b3 ff b3 b3 ff b3 ff b3 ff b3 ff b3 ff b3 ff b3 ff b3 ff b3 b3 ff b3 ff b3 ff b3 ff b3 ff b3 ff b3 ff b3 ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 ff 46 ff 46 ff 46 ff 46 42 46 b3 46 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 46 b3 b3 b3 b3 b3 b3 46 b3 b3 b3 b3 b3 46 b3 b3 b3 b3 b3 b3 b3 b3 b3 46 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 46 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 42 42 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 46 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 46 b3 b3 46 b3 b3 00 00 00 00 00 00 00 00 00 00 00 00 00 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 46 ff 42 46 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 46 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 b3 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 */
// Copyright (c) 2017-2020, The Monero Project // // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, are // permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other // materials provided with the distribution. // // 3. Neither the name of the copyright holder 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 "device_default.hpp" #include "contrib/epee/include/int-util.h" #include "src/crypto/wallet/crypto.h" #include "src/cryptonote_basic/account.h" #include "src/cryptonote_basic/subaddress_index.h" #include "src/cryptonote_core/cryptonote_tx_utils.h" #include "src/ringct/rctOps.h" #include "src/cryptonote_config.h" namespace hw { namespace core { device_default::device_default() { } device_default::~device_default() { } /* ===================================================================== */ /* === Misc ==== */ /* ===================================================================== */ static inline unsigned char *operator &(crypto::ec_scalar &scalar) { return &reinterpret_cast<unsigned char &>(scalar); } static inline const unsigned char *operator &(const crypto::ec_scalar &scalar) { return &reinterpret_cast<const unsigned char &>(scalar); } /* ======================================================================= */ /* SETUP/TEARDOWN */ /* ======================================================================= */ bool device_default::set_name(const std::string &name) { this->name = name; return true; } const std::string device_default::get_name() const { return this->name; } bool device_default::init(void) { return true; } bool device_default::release() { return true; } bool device_default::connect(void) { return true; } bool device_default::disconnect() { return true; } bool device_default::set_mode(device_mode mode) { return device::set_mode(mode); } /* ======================================================================= */ /* LOCKER */ /* ======================================================================= */ void device_default::lock() { } bool device_default::try_lock() { return true; } void device_default::unlock() { } /* ======================================================================= */ /* WALLET & ADDRESS */ /* ======================================================================= */ bool device_default::generate_chacha_key(const cryptonote::account_keys &keys, crypto::chacha_key &key, uint64_t kdf_rounds) { const crypto::secret_key &view_key = keys.m_view_secret_key; const crypto::secret_key &spend_key = keys.m_spend_secret_key; epee::mlocked<tools::scrubbed_arr<char, sizeof(view_key) + sizeof(spend_key) + 1>> data; memcpy(data.data(), &view_key, sizeof(view_key)); memcpy(data.data() + sizeof(view_key), &spend_key, sizeof(spend_key)); data[sizeof(data) - 1] = config::HASH_KEY_WALLET; crypto::generate_chacha_key(data.data(), sizeof(data), key, kdf_rounds); return true; } bool device_default::get_public_address(cryptonote::account_public_address &pubkey) { dfns(); } bool device_default::get_secret_keys(crypto::secret_key &viewkey , crypto::secret_key &spendkey) { dfns(); } /* ======================================================================= */ /* SUB ADDRESS */ /* ======================================================================= */ bool device_default::derive_subaddress_public_key(const crypto::public_key &out_key, const crypto::key_derivation &derivation, const std::size_t output_index, crypto::public_key &derived_key) { return crypto::wallet::derive_subaddress_public_key(out_key, derivation, output_index,derived_key); } crypto::public_key device_default::get_subaddress_spend_public_key(const cryptonote::account_keys& keys, const cryptonote::subaddress_index &index) { if (index.is_zero()) return keys.m_account_address.m_spend_public_key; // m = Hs(a || index_major || index_minor) crypto::secret_key m = get_subaddress_secret_key(keys.m_view_secret_key, index); // M = m*G crypto::public_key M; crypto::secret_key_to_public_key(m, M); // D = B + M crypto::public_key D = rct::rct2pk(rct::addKeys(rct::pk2rct(keys.m_account_address.m_spend_public_key), rct::pk2rct(M))); return D; } std::vector<crypto::public_key> device_default::get_subaddress_spend_public_keys(const cryptonote::account_keys &keys, uint32_t account, uint32_t begin, uint32_t end) { CHECK_AND_ASSERT_THROW_MES(begin <= end, "begin > end"); std::vector<crypto::public_key> pkeys; pkeys.reserve(end - begin); cryptonote::subaddress_index index = {account, begin}; ge_p3 p3; ge_cached cached; CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&p3, (const unsigned char*)keys.m_account_address.m_spend_public_key.data) == 0, "ge_frombytes_vartime failed to convert spend public key"); ge_p3_to_cached(&cached, &p3); for (uint32_t idx = begin; idx < end; ++idx) { index.minor = idx; if (index.is_zero()) { pkeys.push_back(keys.m_account_address.m_spend_public_key); continue; } crypto::secret_key m = get_subaddress_secret_key(keys.m_view_secret_key, index); // M = m*G ge_scalarmult_base(&p3, (const unsigned char*)m.data); // D = B + M crypto::public_key D; ge_p1p1 p1p1; ge_add(&p1p1, &p3, &cached); ge_p1p1_to_p3(&p3, &p1p1); ge_p3_tobytes((unsigned char*)D.data, &p3); pkeys.push_back(D); } return pkeys; } cryptonote::account_public_address device_default::get_subaddress(const cryptonote::account_keys& keys, const cryptonote::subaddress_index &index) { if (index.is_zero()) return keys.m_account_address; crypto::public_key D = get_subaddress_spend_public_key(keys, index); // C = a*D crypto::public_key C = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(D), rct::sk2rct(keys.m_view_secret_key))); // result: (C, D) cryptonote::account_public_address address; address.m_view_public_key = C; address.m_spend_public_key = D; return address; } crypto::secret_key device_default::get_subaddress_secret_key(const crypto::secret_key &a, const cryptonote::subaddress_index &index) { char data[sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key) + 2 * sizeof(uint32_t)]; memcpy(data, config::HASH_KEY_SUBADDRESS, sizeof(config::HASH_KEY_SUBADDRESS)); memcpy(data + sizeof(config::HASH_KEY_SUBADDRESS), &a, sizeof(crypto::secret_key)); uint32_t idx = SWAP32LE(index.major); memcpy(data + sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key), &idx, sizeof(uint32_t)); idx = SWAP32LE(index.minor); memcpy(data + sizeof(config::HASH_KEY_SUBADDRESS) + sizeof(crypto::secret_key) + sizeof(uint32_t), &idx, sizeof(uint32_t)); crypto::secret_key m; crypto::hash_to_scalar(data, sizeof(data), m); return m; } /* ======================================================================= */ /* DERIVATION & KEY */ /* ======================================================================= */ bool device_default::verify_keys(const crypto::secret_key &secret_key, const crypto::public_key &public_key) { crypto::public_key calculated_pub; bool r = crypto::secret_key_to_public_key(secret_key, calculated_pub); return r && public_key == calculated_pub; } bool device_default::scalarmultKey(rct::key & aP, const rct::key &P, const rct::key &a) { rct::scalarmultKey(aP, P,a); return true; } bool device_default::scalarmultBase(rct::key &aG, const rct::key &a) { rct::scalarmultBase(aG,a); return true; } bool device_default::sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) { sc_add(&r, &a, &b); return true; } crypto::secret_key device_default::generate_keys(crypto::public_key &pub, crypto::secret_key &sec, const crypto::secret_key& recovery_key, bool recover) { return crypto::generate_keys(pub, sec, recovery_key, recover); } bool device_default::generate_key_derivation(const crypto::public_key &key1, const crypto::secret_key &key2, crypto::key_derivation &derivation) { return crypto::wallet::generate_key_derivation(key1, key2, derivation); } bool device_default::derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res){ crypto::derivation_to_scalar(derivation,output_index, res); return true; } bool device_default::derive_secret_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &base, crypto::secret_key &derived_key){ crypto::derive_secret_key(derivation, output_index, base, derived_key); return true; } bool device_default::derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &base, crypto::public_key &derived_key){ return crypto::derive_public_key(derivation, output_index, base, derived_key); } bool device_default::secret_key_to_public_key(const crypto::secret_key &sec, crypto::public_key &pub) { return crypto::secret_key_to_public_key(sec,pub); } bool device_default::generate_key_image(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_image &image){ crypto::generate_key_image(pub, sec,image); return true; } bool device_default::conceal_derivation(crypto::key_derivation &derivation, const crypto::public_key &tx_pub_key, const std::vector<crypto::public_key> &additional_tx_pub_keys, const crypto::key_derivation &main_derivation, const std::vector<crypto::key_derivation> &additional_derivations){ return true; } /* ======================================================================= */ /* TRANSACTION */ /* ======================================================================= */ void device_default::generate_tx_proof(const crypto::hash &prefix_hash, const crypto::public_key &R, const crypto::public_key &A, const boost::optional<crypto::public_key> &B, const crypto::public_key &D, const crypto::secret_key &r, crypto::signature &sig) { crypto::generate_tx_proof(prefix_hash, R, A, B, D, r, sig); } bool device_default::open_tx(crypto::secret_key &tx_key) { cryptonote::keypair txkey = cryptonote::keypair::generate(*this); tx_key = txkey.sec; return true; } void device_default::get_transaction_prefix_hash(const cryptonote::transaction_prefix& tx, crypto::hash& h) { cryptonote::get_transaction_prefix_hash(tx, h); } bool device_default::generate_output_ephemeral_keys(const size_t tx_version, const cryptonote::account_keys &sender_account_keys, const crypto::public_key &txkey_pub, const crypto::secret_key &tx_key, const cryptonote::tx_destination_entry &dst_entr, const boost::optional<cryptonote::account_public_address> &change_addr, const size_t output_index, const bool &need_additional_txkeys, const std::vector<crypto::secret_key> &additional_tx_keys, std::vector<crypto::public_key> &additional_tx_public_keys, std::vector<rct::key> &amount_keys, crypto::public_key &out_eph_public_key) { crypto::key_derivation derivation; // make additional tx pubkey if necessary cryptonote::keypair additional_txkey; if (need_additional_txkeys) { additional_txkey.sec = additional_tx_keys[output_index]; if (dst_entr.is_subaddress) additional_txkey.pub = rct::rct2pk(rct::scalarmultKey(rct::pk2rct(dst_entr.addr.m_spend_public_key), rct::sk2rct(additional_txkey.sec))); else additional_txkey.pub = rct::rct2pk(rct::scalarmultBase(rct::sk2rct(additional_txkey.sec))); } bool r; if (change_addr && dst_entr.addr == *change_addr) { // sending change to yourself; derivation = a*R r = generate_key_derivation(txkey_pub, sender_account_keys.m_view_secret_key, derivation); CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to generate_key_derivation(" << txkey_pub << ", " << sender_account_keys.m_view_secret_key << ")"); } else { // sending to the recipient; derivation = r*A (or s*C in the subaddress scheme) r = generate_key_derivation(dst_entr.addr.m_view_public_key, dst_entr.is_subaddress && need_additional_txkeys ? additional_txkey.sec : tx_key, derivation); CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to generate_key_derivation(" << dst_entr.addr.m_view_public_key << ", " << (dst_entr.is_subaddress && need_additional_txkeys ? additional_txkey.sec : tx_key) << ")"); } if (need_additional_txkeys) { additional_tx_public_keys.push_back(additional_txkey.pub); } if (tx_version > 1) { crypto::secret_key scalar1; derivation_to_scalar(derivation, output_index, scalar1); amount_keys.push_back(rct::sk2rct(scalar1)); } r = derive_public_key(derivation, output_index, dst_entr.addr.m_spend_public_key, out_eph_public_key); CHECK_AND_ASSERT_MES(r, false, "at creation outs: failed to derive_public_key(" << derivation << ", " << output_index << ", "<< dst_entr.addr.m_spend_public_key << ")"); return r; } bool device_default::encrypt_payment_id(crypto::hash8 &payment_id, const crypto::public_key &public_key, const crypto::secret_key &secret_key) { crypto::key_derivation derivation; crypto::hash hash; char data[33]; /* A hash, and an extra byte */ if (!generate_key_derivation(public_key, secret_key, derivation)) return false; memcpy(data, &derivation, 32); data[32] = config::HASH_KEY_ENCRYPTED_PAYMENT_ID; cn_fast_hash(data, 33, hash); for (size_t b = 0; b < 8; ++b) payment_id.data[b] ^= hash.data[b]; return true; } rct::key device_default::genCommitmentMask(const rct::key &amount_key) { return rct::genCommitmentMask(amount_key); } bool device_default::ecdhEncode(rct::ecdhTuple & unmasked, const rct::key & sharedSec, bool short_amount) { rct::ecdhEncode(unmasked, sharedSec, short_amount); return true; } bool device_default::ecdhDecode(rct::ecdhTuple & masked, const rct::key & sharedSec, bool short_amount) { rct::ecdhDecode(masked, sharedSec, short_amount); return true; } bool device_default::mlsag_prepare(const rct::key &H, const rct::key &xx, rct::key &a, rct::key &aG, rct::key &aHP, rct::key &II) { rct::skpkGen(a, aG); rct::scalarmultKey(aHP, H, a); rct::scalarmultKey(II, H, xx); return true; } bool device_default::mlsag_prepare(rct::key &a, rct::key &aG) { rct::skpkGen(a, aG); return true; } bool device_default::mlsag_prehash(const std::string &blob, size_t inputs_size, size_t outputs_size, const rct::keyV &hashes, const rct::ctkeyV &outPk, rct::key &prehash) { prehash = rct::cn_fast_hash(hashes); return true; } bool device_default::mlsag_hash(const rct::keyV &toHash, rct::key &c_old) { c_old = rct::hash_to_scalar(toHash); return true; } bool device_default::mlsag_sign(const rct::key &c, const rct::keyV &xx, const rct::keyV &alpha, const size_t rows, const size_t dsRows, rct::keyV &ss ) { CHECK_AND_ASSERT_THROW_MES(dsRows<=rows, "dsRows greater than rows"); CHECK_AND_ASSERT_THROW_MES(xx.size() == rows, "xx size does not match rows"); CHECK_AND_ASSERT_THROW_MES(alpha.size() == rows, "alpha size does not match rows"); CHECK_AND_ASSERT_THROW_MES(ss.size() == rows, "ss size does not match rows"); for (size_t j = 0; j < rows; j++) { sc_mulsub(ss[j].bytes, c.bytes, xx[j].bytes, alpha[j].bytes); } return true; } bool device_default::clsag_prepare(const rct::key &p, const rct::key &z, rct::key &I, rct::key &D, const rct::key &H, rct::key &a, rct::key &aG, rct::key &aH) { rct::skpkGen(a,aG); // aG = a*G rct::scalarmultKey(aH,H,a); // aH = a*H rct::scalarmultKey(I,H,p); // I = p*H rct::scalarmultKey(D,H,z); // D = z*H return true; } bool device_default::clsag_hash(const rct::keyV &data, rct::key &hash) { hash = rct::hash_to_scalar(data); return true; } bool device_default::clsag_sign(const rct::key &c, const rct::key &a, const rct::key &p, const rct::key &z, const rct::key &mu_P, const rct::key &mu_C, rct::key &s) { rct::key s0_p_mu_P; sc_mul(s0_p_mu_P.bytes,mu_P.bytes,p.bytes); rct::key s0_add_z_mu_C; sc_muladd(s0_add_z_mu_C.bytes,mu_C.bytes,z.bytes,s0_p_mu_P.bytes); sc_mulsub(s.bytes,c.bytes,s0_add_z_mu_C.bytes,a.bytes); return true; } bool device_default::close_tx() { return true; } /* ---------------------------------------------------------- */ static device_default *default_core_device = NULL; void register_all(std::map<std::string, std::unique_ptr<device>> &registry) { if (!default_core_device) { default_core_device = new device_default(); default_core_device->set_name("default_core_device"); } registry.insert(std::make_pair("default", std::unique_ptr<device>(default_core_device))); } } }
//////////////////////////////////////////////////////////////////////////////////////////////////// // // Project: Embedded Learning Library (ELL) // File: Scalar_test.cpp (value) // Authors: Kern Handa // //////////////////////////////////////////////////////////////////////////////////////////////////// #include "Scalar_test.h" #include "TestUtil.h" #include <testing/include/testing.h> #include <value/include/Reference.h> #include <value/include/Scalar.h> #include <utilities/include/MemoryLayout.h> using namespace ell::utilities; using namespace ell::value; namespace ell { Scalar Scalar_test1() { Scalar ok = Allocate(ValueType::Int32, ScalarLayout); ok = 0; Scalar s1 = 1; If(s1 != 1, [&] { ok = 1; DebugPrint("Scalar_test1 if 1 failed\n"); }); s1 += 2; If(s1 != 3, [&] { ok = 1; DebugPrint("Scalar_test1 if 2 failed\n"); }); Scalar s2 = s1 + 3; If(s1 != 3, [&] { ok = 1; DebugPrint("Scalar_test1 if 3 failed\n"); }); If(s2 != 6, [&] { ok = 1; DebugPrint("Scalar_test1 if 4 failed\n"); }); return ok; } Scalar Scalar_test2() { Scalar ok = Allocate(ValueType::Int32, ScalarLayout); Scalar x = 2.0; x = x * x; If(x != 4.0, [&] { ok = 1; DebugPrint("Scalar_test2 failed\n"); }); return ok; } Scalar ScalarRefTest() { Scalar result = Allocate<int>(ScalarLayout); Scalar x = Allocate<int>(ScalarLayout); x = 100; Scalar expected = Allocate<int>(ScalarLayout); expected = 100; auto scalarPtr = x.GetValue().Reference(); Scalar scalar = scalarPtr.Dereference(); If(scalar != expected, [&] { result = 1; }); return result; } Scalar ScalarRefRefTest() { Scalar result = Allocate<int>(ScalarLayout); Scalar x = Allocate<int>(ScalarLayout); x = 100; Scalar expected = Allocate<int>(ScalarLayout); expected = 100; auto scalarPtr = x.GetValue().Reference(); auto scalarPtrPtr = scalarPtr.Reference(); auto tmpValPtr = scalarPtrPtr.Dereference(); Scalar scalar = tmpValPtr.Dereference(); If(scalar != expected, [&] { result = 1; }); return result; } Scalar ScalarRefRefRefTest() { Scalar result = Allocate<int>(ScalarLayout); Scalar x = Allocate<int>(ScalarLayout); x = 100; Scalar expected = Allocate<int>(ScalarLayout); expected = 100; auto scalarPtr = x.GetValue().Reference(); auto scalarPtrPtr = scalarPtr.Reference(); auto scalarPtrPtrPtr = scalarPtrPtr.Reference(); auto tmpValPtrPtr = scalarPtrPtrPtr.Dereference(); auto tmpValPtr = tmpValPtrPtr.Dereference(); Scalar scalar = tmpValPtr.Dereference(); If(scalar != expected, [&] { result = 1; }); return result; } Scalar RefScalarRefTest() { Scalar result = Allocate<int>(ScalarLayout); Scalar x = Allocate<int>(ScalarLayout); x = 100; Scalar expected = Allocate<int>(ScalarLayout); expected = 100; Ref<Scalar> scalarPtr = x; Scalar scalar = *scalarPtr; If(scalar != expected, [&] { result = 1; }); return result; } Scalar RefScalarRefCtorsTest() { Scalar result = Allocate<int>(ScalarLayout); Scalar x = Allocate<int>(ScalarLayout); x = 100; Scalar expected = Allocate<int>(ScalarLayout); expected = 100; testing::ProcessTest("Value initial pointer level", expected.GetValue().PointerLevel() == 1); Ref<Scalar> scalarPtr = x; testing::ProcessTest("Ref ctor", scalarPtr.GetValue().PointerLevel() == 2); Ref<Scalar> scalarPtrCopy = x; testing::ProcessTest("Ref copy semantics", scalarPtr.GetValue().PointerLevel() == scalarPtrCopy.GetValue().PointerLevel()); Ref<Scalar> scalarPtrMove = std::move(scalarPtr); testing::ProcessTest("Ref move semantics", !scalarPtr.GetValue().IsDefined() && scalarPtrMove.GetValue().PointerLevel() == 2); return result; } Scalar RefScalarRefRefTest() { Scalar result = Allocate<int>(ScalarLayout); Scalar x = Allocate<int>(ScalarLayout); x = 100; Scalar expected = Allocate<int>(ScalarLayout); expected = 100; Ref<Scalar> scalarPtr = x; Ref<Scalar> scalarPtr2 = scalarPtr; Ref<Ref<Scalar>> scalarPtrPtr = scalarPtr; Ref<Scalar> tmpValPtr = *scalarPtrPtr; Scalar scalar = *tmpValPtr; If(scalar != expected, [&] { result = 1; }); return result; } Scalar RefScalarRefRefRefTest() { Scalar result = Allocate<int>(ScalarLayout); Scalar x = Allocate<int>(ScalarLayout); x = 100; Scalar expected = Allocate<int>(ScalarLayout); expected = 100; Ref<Scalar> scalarPtr = x; Ref<Ref<Scalar>> scalarPtrPtr = scalarPtr; Ref<Ref<Ref<Scalar>>> scalarPtrPtrPtr = scalarPtrPtr; Ref<Ref<Scalar>> tmpValPtrPtr = *scalarPtrPtrPtr; Ref<Scalar> tmpValPtr = *tmpValPtrPtr; Scalar scalar = *tmpValPtr; If(scalar != expected, [&] { result = 1; }); return result; } } // namespace ell
add hl, hl add hl, hl add hl, hl add hl, hl add hl, hl ld h, l ld l, 0 ---- ld h, l ld l, 0 add hl, hl add hl, hl add hl, hl add hl, hl add hl, hl
//============================================================================ // Author : Soheil Abbasloo // Version : 1.0 //============================================================================ /* MIT License Copyright (c) Soheil Abbasloo 2020 (ab.soheil@gmail.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include <cstdlib> #include <sys/select.h> #include "define.h" #include <iostream> //#define CHANGE_TARGET 1 #define MAX_CWND 10000 #define MIN_CWND 4 using namespace std; int main(int argc, char **argv) { DBGPRINT(DBGSERVER,4,"Main\n"); if(argc!=14) { DBGERROR("argc:%d\n",argc); for(int i=0;i<argc;i++) DBGERROR("argv[%d]:%s\n",i,argv[i]); usage(); return 0; } srand(raw_timestamp()); //signal函数:只要信号被传送(通过raise())就会执行该功能 signal(SIGSEGV, handler); // install our handler signal(SIGTERM, handler); // install our handler signal(SIGABRT, handler); // install our handler signal(SIGFPE, handler); // install our handler signal(SIGKILL,handler); // install our handler int flow_num; flow_num=FLOW_NUM; client_port=atoi(argv[1]); path=argv[2]; target=50; target_ratio=1; report_period=atoi(argv[3]); first_time=atoi(argv[4]); scheme=argv[5]; actor_id=atoi(argv[6]); downlink=argv[7]; uplink=argv[8]; delay_ms=atoi(argv[9]); log_file=argv[10]; duration=atoi(argv[11]); qsize=atoi(argv[12]); duration_steps=atoi(argv[13]); start_server(flow_num, client_port); DBGMARK(DBGSERVER,5,"DONE!\n"); shmdt(shared_memory);//将共享内存从当前进程中分离。 shmctl(shmid, IPC_RMID, NULL); shmdt(shared_memory_rl); shmctl(shmid_rl, IPC_RMID, NULL); return 0; } void usage() { DBGMARK(0,0,"./server [port] [path to ddpg.py] [Report Period: 20 msec] [First Time: 1=yes(learn), 0=no(continue learning), 2=evaluate] [actor id=0, 1, ...] [downlink] [uplink] [one-way delay]\n"); } void start_server(int flow_num, int client_port) { cFlow *flows; int num_lines=0; sInfo *info; info = new sInfo; flows = new cFlow[flow_num]; if(flows==NULL) { DBGMARK(0,0,"flow generation failed\n"); return; } //threads pthread_t data_thread; pthread_t cnt_thread; pthread_t timer_thread; //Server address struct sockaddr_in server_addr[FLOW_NUM]; //Client address struct sockaddr_in client_addr[FLOW_NUM]; //Controller address //struct sockaddr_in ctr_addr; for(int i=0;i<FLOW_NUM;i++) { memset(&server_addr[i],0,sizeof(server_addr[i])); //IP protocol server_addr[i].sin_family=AF_INET;//协议族为tcp/ip //Listen on "0.0.0.0" (Any IP address of this host) server_addr[i].sin_addr.s_addr=INADDR_ANY; //Specify port number server_addr[i].sin_port=htons(client_port+i); //Init socket if((sock[i]=socket(PF_INET,SOCK_STREAM,0))<0) { DBGMARK(0,0,"sockopt: %s\n",strerror(errno)); return; } int reuse = 1; if (setsockopt(sock[i], SOL_SOCKET, SO_REUSEADDR, (const char*)&reuse, sizeof(reuse)) < 0) perror("setsockopt(SO_REUSEADDR) failed"); //Bind socket on IP:Port if(bind(sock[i],(struct sockaddr *)&server_addr[i],sizeof(struct sockaddr))<0)//绑定socket { DBGMARK(0,0,"bind error srv_ctr_ip: 000000: %s\n",strerror(errno)); close(sock[i]); return; } if (scheme) { if (setsockopt(sock[i], IPPROTO_TCP, TCP_CONGESTION, scheme, strlen(scheme)) < 0) //设置拥塞控制协议为cubic { DBGMARK(0,0,"TCP congestion doesn't exist: %s\n",strerror(errno)); return; } } } char container_cmd[500]; sprintf(container_cmd,"sudo -u `whoami` %s/client $MAHIMAHI_BASE 1 %d",path,client_port); char cmd[1000]; char final_cmd[1000]; if (first_time==4 || first_time==2) sprintf(cmd, "sudo -u `whoami` mm-delay %d mm-link %s/../traces/%s %s/../traces/%s --downlink-log=%s/log/down-%s --uplink-queue=droptail --uplink-queue-args=\"packets=%d\" --downlink-queue=droptail --downlink-queue-args=\"packets=%d\" -- sh -c \'%s\' &",delay_ms,path,uplink,path,downlink,path,log_file,qsize,qsize,container_cmd); else sprintf(cmd, "sudo -u `whoami` mm-delay %d mm-link %s/../traces/%s %s/../traces/%s --uplink-queue=droptail --uplink-queue-args=\"packets=%d\" --downlink-queue=droptail --downlink-queue-args=\"packets=%d\" -- sh -c \'%s\' &",delay_ms,path,uplink,path,downlink,qsize,qsize,container_cmd); sprintf(final_cmd,"%s",cmd); //上面这几段应该是为了启动mahimahi DBGPRINT(DBGSERVER,0,"%s\n",final_cmd); info->trace=trace; info->num_lines=num_lines; /** *Setup Shared Memory */ key=(key_t) (actor_id*10000+rand()%10000+1); key_rl=(key_t) (actor_id*10000+rand()%10000+1); // Setup shared memory, 11 is the size if ((shmid = shmget(key, shmem_size, IPC_CREAT | 0666)) < 0)//用来创建共享内存 第一个参数是键 第二个参数是内存大小 第三个参数是权限标志 { printf("Error getting shared memory id"); return; } // Attached shared memory if ((shared_memory = (char*)shmat(shmid, NULL, 0)) == (char *) -1)//用来启动对该共享内存的访问,并把共享内存连接到当前进程的地址空间。 第一个参数是共享内存标志 第二个参数是指定共享内存连接到当前进程中的地址位置,通常为null表示让系统来选择共享内存的地址。 { printf("Error attaching shared memory id"); return; } // Setup shared memory, 11 is the size if ((shmid_rl = shmget(key_rl, shmem_size, IPC_CREAT | 0666)) < 0) { printf("Error getting shared memory id"); return; } // Attached shared memory if ((shared_memory_rl = (char*)shmat(shmid_rl, NULL, 0)) == (char *) -1) { printf("Error attaching shared memory id"); return; } if (first_time==1){ sprintf(cmd,"/home/`whoami`/venv/bin/python %s/d5.py --tb_interval=1 --base_path=%s --task=%d --job_name=actor --train_dir=%s --mem_r=%d --mem_w=%d &",path,path,actor_id,path,(int)key,(int)key_rl); DBGPRINT(0,0,"Starting RL Module (Without load) ...\n%s",cmd); } else if (first_time==2 || first_time==4){ sprintf(cmd,"/home/`whoami`/venv/bin/python %s/d5.py --tb_interval=1 --base_path=%s --load --eval --task=%d --job_name=actor --train_dir=%s --mem_r=%d --mem_w=%d &",path,path,actor_id,path,(int)key,(int)key_rl); DBGPRINT(0,0,"Starting RL Module (No learning) ...\n%s",cmd); } else { sprintf(cmd,"/home/`whoami`/venv/bin/python %s/d5.py --load --tb_interval=1 --base_path=%s --task=%d --job_name=actor --train_dir=%s --mem_r=%d --mem_w=%d &",path,path,actor_id,path,(int)key,(int)key_rl); DBGPRINT(0,0,"Starting RL Module (With load) ...\n%s",cmd); } initial_timestamp(); system(cmd); //Wait to get OK signal (alpha=OK_SIGNAL) bool got_ready_signal_from_rl=false; int signal; char *num; char*alpha; char *save_ptr; int signal_check_counter=0; while(!got_ready_signal_from_rl) { //Get alpha from RL-Module signal_check_counter++; // cout<<"matthew:shared_memory_rl:"<<shared_memory_rl<<endl; num=strtok_r(shared_memory_rl," ",&save_ptr); alpha=strtok_r(NULL," ",&save_ptr); // cout<<"matthew:num:"<<num<<endl; // cout<<"matthew:alpha:"<<alpha<<endl; if(num!=NULL && alpha!=NULL) { signal=atoi(alpha); if(signal==OK_SIGNAL) { got_ready_signal_from_rl=true; } else{ usleep(1000); } } else{ usleep(10000);//0.01us } if (signal_check_counter>18000) { DBGERROR("After 3 minutes, no response (OK_Signal) from the Actor %d is received! We are going down down down ...\n",actor_id); return; } } DBGPRINT(0,0,"RL Module is Ready. Let's Start ...\n\n"); usleep(actor_id*10000+10000); //Now its time to start the server-client app and tune C2TCP socket. system(final_cmd); //Start listen int maxfdp=-1; fd_set rset; FD_ZERO(&rset); //The maximum number of concurrent connections is 1 for(int i=0;i<FLOW_NUM;i++) { listen(sock[i],1); //To be used in select() function FD_SET(sock[i], &rset); if(sock[i]>maxfdp) maxfdp=sock[i]; } //Timeout {1Hour} if something goes wrong! (Maybe mahimahi error...!) maxfdp=maxfdp+1; struct timeval timeout; timeout.tv_sec = 60 * 60; timeout.tv_usec = 0; int rc = select(maxfdp, &rset, NULL, NULL, &timeout); /**********************************************************/ /* Check to see if the select call failed. */ /**********************************************************/ if (rc < 0) { DBGERROR("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=- select() failed =-=-=-=-=-=--=-=-=-=-=\n"); return; } /**********************************************************/ /* Check to see if the time out expired. */ /**********************************************************/ if (rc == 0) { DBGERROR("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=- select() Timeout! =-=-=-=-=-=--=-=-=-=-=\n"); return; } int sin_size=sizeof(struct sockaddr_in); while(flow_index<flow_num) { if (FD_ISSET(sock[flow_index], &rset)) //检查此sock[flow_index]是否在集合rset里面 { int value=accept(sock[flow_index],(struct sockaddr *)&client_addr[flow_index],(socklen_t*)&sin_size);//等待一个socket FD的connection,当新的connection到达时,开启一个新的socket去接它。 if(value<0) { perror("accept error\n"); DBGMARK(0,0,"sockopt: %s\n",strerror(errno)); DBGMARK(0,0,"sock::%d, index:%d\n",sock[flow_index],flow_index); close(sock[flow_index]); return; } sock_for_cnt[flow_index]=value;//value是新socket的描述(descriptor) flows[flow_index].flowinfo.sock=value; flows[flow_index].dst_addr=client_addr[flow_index]; if(pthread_create(&data_thread, NULL , DataThread, (void*)&flows[flow_index]) < 0)//开启一个数据thread { perror("could not create thread\n"); close(sock[flow_index]); return; } if (flow_index==0) { if(pthread_create(&cnt_thread, NULL , CntThread, (void*)info) < 0) { perror("could not create control thread\n"); close(sock[flow_index]); return; } if(pthread_create(&timer_thread, NULL , TimerThread, (void*)info) < 0) { perror("could not create timer thread\n"); close(sock[flow_index]); return; } } DBGPRINT(0,0,"Server is Connected to the client...\n"); flow_index++; } } pthread_join(data_thread, NULL); } void* TimerThread(void* information) { uint64_t start=timestamp(); unsigned int elapsed; if ((duration!=0)) { while(send_traffic) { sleep(1); elapsed=(unsigned int)((timestamp()-start)/1000000); //unit s if (elapsed>duration) { send_traffic=false; } } } return((void *)0); } void* CntThread(void* information) { /* struct sched_param param; param.__sched_priority=sched_get_priority_max(SCHED_RR); int policy=SCHED_RR; int s = pthread_setschedparam(pthread_self(), policy, &param); if (s!=0) { DBGPRINT(0,0,"Cannot set priority (%d) for the Main: %s\n",param.__sched_priority,strerror(errno)); } s = pthread_getschedparam(pthread_self(),&policy,&param); if (s!=0) { DBGPRINT(0,0,"Cannot get priority for the Data thread: %s\n",strerror(errno)); } */ int ret1; double min_rtt_=0.0; double pacing_rate=0.0; double lost_bytes=0.0; double lost_rate=0.0; double srtt_ms=0.0; double snd_ssthresh=0.0; double packets_out=0.0; double retrans_out=0.0; double max_packets_out=0.0; int reuse = 1; int pre_id=9230; int pre_id_tmp=0; int msg_id=657; bool got_alpha=false; bool slow_start_passed=0; for(int i=0;i<FLOW_NUM;i++) { cout<<"flow_num:"<<i<<" IPPROTO_TCP:"<<IPPROTO_TCP<<" TCP_NODELAY:"<<TCP_NODELAY<<" reuse:"<<reuse<<endl; if (setsockopt(sock_for_cnt[i], IPPROTO_TCP, TCP_NODELAY, &reuse, sizeof(reuse)) < 0) { DBGMARK(0,0,"ERROR: set TCP_NODELAY option %s\n",strerror(errno)); return((void *)0); } //Enable orca on this socket: //TCP_ORCA_ENABLE int enable_orca=2; if (setsockopt(sock_for_cnt[i], IPPROTO_TCP, TCP_ORCA_ENABLE, &enable_orca, sizeof(enable_orca)) < 0) { DBGERROR("CHECK KERNEL VERSION (0514+) ;CANNOT ENABLE ORCA %s\n",strerror(errno)); return ((void* )0); } } char message[1000]; char *num; char*alpha; char*save_ptr; int got_no_zero=0; uint64_t t0,t1; t0=timestamp(); //Time to start the Logic struct tcp_orca_info tcp_info_pre; tcp_info_pre.init(); int get_info_error_counter=0; int actor_is_dead_counter=0; int tmp_step=0; while(send_traffic) { for(int i=0;i<flow_index;i++) { got_no_zero=0; usleep(report_period*1000); while(!got_no_zero && send_traffic) { ret1= get_orca_info(sock_for_cnt[i],&orca_info); if(ret1<0) { DBGMARK(0,0,"setsockopt: for index:%d flow_index:%d TCP_C2TCP ... %s (ret1:%d)\n",i,flow_index,strerror(errno),ret1); return((void *)0); } if(orca_info.avg_urtt>0) { t1=timestamp(); double time_delta=(double)(t1-t0)/1000000.0; double delay=(double)orca_info.avg_urtt/1000.0; min_rtt_=(double)(orca_info.min_rtt/1000.0); lost_bytes=(double)(orca_info.lost_bytes); pacing_rate=(double)(orca_info.pacing_rate); lost_rate=lost_bytes/time_delta; //Rate in MBps srtt_ms=(double)((orca_info.srtt_us>>3)/1000.0); snd_ssthresh=(double)(orca_info.snd_ssthresh); packets_out=(double)(orca_info.packets_out); retrans_out=(double)(orca_info.retrans_out); max_packets_out=(double)(orca_info.max_packets_out); report_period=20; if (!slow_start_passed) //Just for the first Time slow_start_passed=(orca_info.snd_ssthresh<orca_info.cwnd)?1:0; if(!slow_start_passed)//如果慢启动没有结束 { //got_no_zero=1; tcp_info_pre=orca_info; t0=timestamp(); target_ratio=1.1*orca_info.cwnd; ret1 = setsockopt(sock_for_cnt[i], IPPROTO_TCP,TCP_CWND, &target_ratio,sizeof(target_ratio)); if(ret1<0) { DBGPRINT(0,0,"setsockopt: for index:%d flow_index:%d ... %s (ret1:%d)\n",i, flow_index,strerror(errno),ret1); return((void *)0); } continue; } sprintf(message,"%d %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f", msg_id,delay,(double)orca_info.thr,(double)orca_info.cnt,(double)time_delta, (double)target,(double)orca_info.cwnd, pacing_rate,lost_rate,srtt_ms,snd_ssthresh,packets_out ,retrans_out,max_packets_out,(double)orca_info.mss,min_rtt_); memcpy(shared_memory,message,sizeof(message)); if ((duration_steps!=0)) { step_it++; if(step_it>duration_steps) send_traffic=false; } msg_id=(msg_id+1)%1000; DBGPRINT(DBGSERVER,1,"%s\n",message); got_no_zero=1; tcp_info_pre=orca_info; t0=timestamp(); get_info_error_counter=0; } else { get_info_error_counter++; if(get_info_error_counter>30000) { DBGMARK(0,0,"No valid state for 1 min. We (server of Actor %d) are going down down down ...\n",actor_id); send_traffic=false; } usleep(report_period*100); } } got_alpha=false; int error_cnt=0; int error2_cnt=0; while(!got_alpha && send_traffic) { //Get alpha from RL-Module num=strtok_r(shared_memory_rl," ",&save_ptr); alpha=strtok_r(NULL," ",&save_ptr); // cout<<"matthew:num:"<<num<<endl; // cout<<"matthew:alpha:"<<alpha<<endl; if(num!=NULL && alpha!=NULL) { pre_id_tmp=atoi(num); target_ratio=atoi(alpha); if(pre_id!=pre_id_tmp /*&& target_ratio!=OK_SIGNAL*/) { got_alpha=true; pre_id=pre_id_tmp; target_ratio=atoi(alpha)*orca_info.cwnd/100; cout<<"matthew:target_ratio:"<<atoi(alpha)<< " pre_id:"<<pre_id_tmp<<endl; if (target_ratio<MIN_CWND) target_ratio=MIN_CWND; ret1 = setsockopt(sock_for_cnt[i], IPPROTO_TCP,TCP_CWND, &target_ratio, sizeof(target_ratio)); if(ret1<0) { DBGPRINT(0,0,"setsockopt: for index:%d flow_index:%d ... %s (ret1:%d)\n",i,flow_index,strerror(errno),ret1); return((void *)0); } error_cnt=0; } else{ if (error_cnt>1000) { DBGPRINT(DBGSERVER,0,"still no new value id:%d prev_id:%d\n",pre_id_tmp,pre_id); error_cnt=0; } error_cnt++; usleep(1000); } error2_cnt=0; } else{ if (error2_cnt==50) { DBGPRINT(0,0,"got null values: (downlink:%s delay:%d qs:%d) Actor: %d iteration:%d\n",downlink,delay_ms,qsize,actor_id,step_it); //FIXME: //A Hack for now! Let's send a new state to get new action in case we have missed previous action. Why it happens?! if((1+tmp_step)==(step_it)) { actor_is_dead_counter++; tmp_step=step_it; if(actor_is_dead_counter>120) { DBGMARK(0,0,"No valid action for 1 min. We (server of actor %d) are going down down down ...\n",actor_id); send_traffic=false; } } else { actor_is_dead_counter=0; tmp_step=step_it; } got_alpha=true; error2_cnt=0; } else{ error2_cnt++; usleep(10000); } } } } } shmdt(shared_memory); shmctl(shmid, IPC_RMID, NULL); shmdt(shared_memory_rl); shmctl(shmid_rl, IPC_RMID, NULL); return((void *)0); } void* DataThread(void* info) { /* struct sched_param param; param.__sched_priority=sched_get_priority_max(SCHED_RR); int policy=SCHED_RR; int s = pthread_setschedparam(pthread_self(), policy, &param); if (s!=0) { DBGERROR("Cannot set priority (%d) for the Main: %s\n",param.__sched_priority,strerror(errno)); } s = pthread_getschedparam(pthread_self(),&policy,&param); if (s!=0) { DBGERROR("Cannot get priority for the Data thread: %s\n",strerror(errno)); }*/ //pthread_t send_msg_thread; cFlow* flow = (cFlow*)info; int sock_local = flow->flowinfo.sock; char* src_ip; char write_message[BUFSIZ+1]; char read_message[1024]={0}; int len; char *savePtr; char* dst_addr; u64 loop; u64 remaining_size; memset(write_message,1,BUFSIZ); write_message[BUFSIZ]='\0'; /** * Get the RQ from client : {src_add} {flowid} {size} {dst_add} */ len=recv(sock_local,read_message,1024,0); if(len<=0) { DBGMARK(DBGSERVER,1,"recv failed! \n"); close(sock_local); return 0; } /** * For Now: we send the src IP in the RQ to! */ src_ip=strtok_r(read_message," ",&savePtr); if(src_ip==NULL) { //discard message: DBGMARK(DBGSERVER,1,"id: %d discarding this message:%s \n",flow->flowinfo.flowid,savePtr); close(sock_local); return 0; } char * isstr = strtok_r(NULL," ",&savePtr); if(isstr==NULL) { //discard message: DBGMARK(DBGSERVER,1,"id: %d discarding this message:%s \n",flow->flowinfo.flowid,savePtr); close(sock_local); return 0; } flow->flowinfo.flowid=atoi(isstr); char* size_=strtok_r(NULL," ",&savePtr); flow->flowinfo.size=1024*atoi(size_); DBGPRINT(DBGSERVER,4,"%s\n",size_); dst_addr=strtok_r(NULL," ",&savePtr); if(dst_addr==NULL) { //discard message: DBGMARK(DBGSERVER,1,"id: %d discarding this message:%s \n",flow->flowinfo.flowid,savePtr); close(sock_local); return 0; } char* time_s_=strtok_r(NULL," ",&savePtr); char *endptr; start_of_client=strtoimax(time_s_,&endptr,10); got_message=1; DBGPRINT(DBGSERVER,2,"Got message: %" PRIu64 " us\n",timestamp()); flow->flowinfo.rem_size=flow->flowinfo.size; DBGPRINT(DBGSERVER,2,"time_rcv:%" PRIu64 " get:%s\n",start_of_client,time_s_); //Get detailed address strtok_r(src_ip,".",&savePtr); if(dst_addr==NULL) { //discard message: DBGMARK(DBGSERVER,1,"id: %d discarding this message:%s \n",flow->flowinfo.flowid,savePtr); close(sock_local); return 0; } //Calculate loops. In each loop, we can send BUFSIZ (8192) bytes of data loop=flow->flowinfo.size/BUFSIZ*1024; //Calculate remaining size to be sent remaining_size=flow->flowinfo.size*1024-loop*BUFSIZ; //Send data with 8192 bytes each loop DBGPRINT(0,0,"Matthew: Server is sending the traffic ...\n"); // for(u64 i=0;i<loop;i++) while(send_traffic) { len=strlen(write_message); while(len>0) { DBGMARK(DBGSERVER,5,"++++++\n"); len-=send(sock_local,write_message,strlen(write_message),0); usleep(50); DBGMARK(DBGSERVER,5,"------\n"); } usleep(100); } flow->flowinfo.rem_size=0; done=true; DBGPRINT(DBGSERVER,1,"done=true\n"); close(sock_local); DBGPRINT(DBGSERVER,1,"done\n"); return((void *)0); }
.model small .stack 100h .data .code Main proc Mov ah ,1 Int 21h mov dl,al mov ah ,1 int 21h add al,dl mov dl,al sub dl,48 mov ah,2 int 21h mov ah, 4ch int 21h main endp end main
; A266797: a(n) = (6^n + 4^n + 3*2^n)/8. ; 2,8,38,200,1112,6368,37088,218240,1292672,7689728,45874688,274196480,1640978432,9829081088,58907353088,353175633920,2117979963392,12703584616448,76204327436288,457157244354560,2742668586647552,16454912005111808 add $0,1 mov $3,2 pow $3,$0 mov $1,$3 mov $2,$3 add $2,1 lpb $0 sub $0,1 mul $1,3 mul $2,2 add $2,2 mov $4,$2 lpe add $1,$4 div $1,48 mul $1,6 add $1,2
_echo: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 e4 f0 and $0xfffffff0,%esp 6: 57 push %edi 7: 56 push %esi 8: 53 push %ebx 9: 83 ec 14 sub $0x14,%esp c: 8b 75 08 mov 0x8(%ebp),%esi f: 8b 7d 0c mov 0xc(%ebp),%edi int i; for(i = 1; i < argc; i++) 12: 83 fe 01 cmp $0x1,%esi 15: 7e 60 jle 77 <main+0x77> 17: bb 01 00 00 00 mov $0x1,%ebx printf(1, "%s%s", argv[i], i+1 < argc ? " " : "\n"); 1c: 83 c3 01 add $0x1,%ebx 1f: 39 de cmp %ebx,%esi 21: 7e 30 jle 53 <main+0x53> 23: 90 nop 24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 28: c7 44 24 0c 76 07 00 movl $0x776,0xc(%esp) 2f: 00 30: 8b 44 9f fc mov -0x4(%edi,%ebx,4),%eax 34: 83 c3 01 add $0x1,%ebx 37: c7 44 24 04 78 07 00 movl $0x778,0x4(%esp) 3e: 00 3f: c7 04 24 01 00 00 00 movl $0x1,(%esp) 46: 89 44 24 08 mov %eax,0x8(%esp) 4a: e8 b1 03 00 00 call 400 <printf> 4f: 39 de cmp %ebx,%esi 51: 7f d5 jg 28 <main+0x28> 53: c7 44 24 0c 7d 07 00 movl $0x77d,0xc(%esp) 5a: 00 5b: 8b 44 b7 fc mov -0x4(%edi,%esi,4),%eax 5f: c7 44 24 04 78 07 00 movl $0x778,0x4(%esp) 66: 00 67: c7 04 24 01 00 00 00 movl $0x1,(%esp) 6e: 89 44 24 08 mov %eax,0x8(%esp) 72: e8 89 03 00 00 call 400 <printf> exit(); 77: e8 29 02 00 00 call 2a5 <exit> 7c: 66 90 xchg %ax,%ax 7e: 66 90 xchg %ax,%ax 00000080 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 80: 55 push %ebp 81: 31 d2 xor %edx,%edx 83: 89 e5 mov %esp,%ebp 85: 8b 45 08 mov 0x8(%ebp),%eax 88: 53 push %ebx 89: 8b 5d 0c mov 0xc(%ebp),%ebx 8c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi char *os; os = s; while((*s++ = *t++) != 0) 90: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 94: 88 0c 10 mov %cl,(%eax,%edx,1) 97: 83 c2 01 add $0x1,%edx 9a: 84 c9 test %cl,%cl 9c: 75 f2 jne 90 <strcpy+0x10> ; return os; } 9e: 5b pop %ebx 9f: 5d pop %ebp a0: c3 ret a1: eb 0d jmp b0 <strcmp> a3: 90 nop a4: 90 nop a5: 90 nop a6: 90 nop a7: 90 nop a8: 90 nop a9: 90 nop aa: 90 nop ab: 90 nop ac: 90 nop ad: 90 nop ae: 90 nop af: 90 nop 000000b0 <strcmp>: int strcmp(const char *p, const char *q) { b0: 55 push %ebp b1: 89 e5 mov %esp,%ebp b3: 53 push %ebx b4: 8b 4d 08 mov 0x8(%ebp),%ecx b7: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) ba: 0f b6 01 movzbl (%ecx),%eax bd: 84 c0 test %al,%al bf: 75 14 jne d5 <strcmp+0x25> c1: eb 25 jmp e8 <strcmp+0x38> c3: 90 nop c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi p++, q++; c8: 83 c1 01 add $0x1,%ecx cb: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) ce: 0f b6 01 movzbl (%ecx),%eax d1: 84 c0 test %al,%al d3: 74 13 je e8 <strcmp+0x38> d5: 0f b6 1a movzbl (%edx),%ebx d8: 38 d8 cmp %bl,%al da: 74 ec je c8 <strcmp+0x18> dc: 0f b6 db movzbl %bl,%ebx df: 0f b6 c0 movzbl %al,%eax e2: 29 d8 sub %ebx,%eax p++, q++; return (uchar)*p - (uchar)*q; } e4: 5b pop %ebx e5: 5d pop %ebp e6: c3 ret e7: 90 nop } int strcmp(const char *p, const char *q) { while(*p && *p == *q) e8: 0f b6 1a movzbl (%edx),%ebx eb: 31 c0 xor %eax,%eax ed: 0f b6 db movzbl %bl,%ebx f0: 29 d8 sub %ebx,%eax p++, q++; return (uchar)*p - (uchar)*q; } f2: 5b pop %ebx f3: 5d pop %ebp f4: c3 ret f5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000100 <strlen>: uint strlen(char *s) { 100: 55 push %ebp int n; for(n = 0; s[n]; n++) 101: 31 d2 xor %edx,%edx return (uchar)*p - (uchar)*q; } uint strlen(char *s) { 103: 89 e5 mov %esp,%ebp int n; for(n = 0; s[n]; n++) 105: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; } uint strlen(char *s) { 107: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 10a: 80 39 00 cmpb $0x0,(%ecx) 10d: 74 0c je 11b <strlen+0x1b> 10f: 90 nop 110: 83 c2 01 add $0x1,%edx 113: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 117: 89 d0 mov %edx,%eax 119: 75 f5 jne 110 <strlen+0x10> ; return n; } 11b: 5d pop %ebp 11c: c3 ret 11d: 8d 76 00 lea 0x0(%esi),%esi 00000120 <memset>: void* memset(void *dst, int c, uint n) { 120: 55 push %ebp 121: 89 e5 mov %esp,%ebp 123: 8b 55 08 mov 0x8(%ebp),%edx 126: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 127: 8b 4d 10 mov 0x10(%ebp),%ecx 12a: 8b 45 0c mov 0xc(%ebp),%eax 12d: 89 d7 mov %edx,%edi 12f: fc cld 130: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 132: 89 d0 mov %edx,%eax 134: 5f pop %edi 135: 5d pop %ebp 136: c3 ret 137: 89 f6 mov %esi,%esi 139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000140 <strchr>: char* strchr(const char *s, char c) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 8b 45 08 mov 0x8(%ebp),%eax 146: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 14a: 0f b6 10 movzbl (%eax),%edx 14d: 84 d2 test %dl,%dl 14f: 75 11 jne 162 <strchr+0x22> 151: eb 15 jmp 168 <strchr+0x28> 153: 90 nop 154: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 158: 83 c0 01 add $0x1,%eax 15b: 0f b6 10 movzbl (%eax),%edx 15e: 84 d2 test %dl,%dl 160: 74 06 je 168 <strchr+0x28> if(*s == c) 162: 38 ca cmp %cl,%dl 164: 75 f2 jne 158 <strchr+0x18> return (char*)s; return 0; } 166: 5d pop %ebp 167: c3 ret } char* strchr(const char *s, char c) { for(; *s; s++) 168: 31 c0 xor %eax,%eax if(*s == c) return (char*)s; return 0; } 16a: 5d pop %ebp 16b: 90 nop 16c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 170: c3 ret 171: eb 0d jmp 180 <atoi> 173: 90 nop 174: 90 nop 175: 90 nop 176: 90 nop 177: 90 nop 178: 90 nop 179: 90 nop 17a: 90 nop 17b: 90 nop 17c: 90 nop 17d: 90 nop 17e: 90 nop 17f: 90 nop 00000180 <atoi>: return r; } int atoi(const char *s) { 180: 55 push %ebp int n; n = 0; while('0' <= *s && *s <= '9') 181: 31 c0 xor %eax,%eax return r; } int atoi(const char *s) { 183: 89 e5 mov %esp,%ebp 185: 8b 4d 08 mov 0x8(%ebp),%ecx 188: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 189: 0f b6 11 movzbl (%ecx),%edx 18c: 8d 5a d0 lea -0x30(%edx),%ebx 18f: 80 fb 09 cmp $0x9,%bl 192: 77 1c ja 1b0 <atoi+0x30> 194: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi n = n*10 + *s++ - '0'; 198: 0f be d2 movsbl %dl,%edx 19b: 83 c1 01 add $0x1,%ecx 19e: 8d 04 80 lea (%eax,%eax,4),%eax 1a1: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 1a5: 0f b6 11 movzbl (%ecx),%edx 1a8: 8d 5a d0 lea -0x30(%edx),%ebx 1ab: 80 fb 09 cmp $0x9,%bl 1ae: 76 e8 jbe 198 <atoi+0x18> n = n*10 + *s++ - '0'; return n; } 1b0: 5b pop %ebx 1b1: 5d pop %ebp 1b2: c3 ret 1b3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001c0 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 56 push %esi 1c4: 8b 45 08 mov 0x8(%ebp),%eax 1c7: 53 push %ebx 1c8: 8b 5d 10 mov 0x10(%ebp),%ebx 1cb: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 1ce: 85 db test %ebx,%ebx 1d0: 7e 14 jle 1e6 <memmove+0x26> n = n*10 + *s++ - '0'; return n; } void* memmove(void *vdst, void *vsrc, int n) 1d2: 31 d2 xor %edx,%edx 1d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) *dst++ = *src++; 1d8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 1dc: 88 0c 10 mov %cl,(%eax,%edx,1) 1df: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 1e2: 39 da cmp %ebx,%edx 1e4: 75 f2 jne 1d8 <memmove+0x18> *dst++ = *src++; return vdst; } 1e6: 5b pop %ebx 1e7: 5e pop %esi 1e8: 5d pop %ebp 1e9: c3 ret 1ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000001f0 <stat>: return buf; } int stat(char *n, struct stat *st) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 83 ec 18 sub $0x18,%esp int fd; int r; fd = open(n, O_RDONLY); 1f6: 8b 45 08 mov 0x8(%ebp),%eax return buf; } int stat(char *n, struct stat *st) { 1f9: 89 5d f8 mov %ebx,-0x8(%ebp) 1fc: 89 75 fc mov %esi,-0x4(%ebp) int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) 1ff: be ff ff ff ff mov $0xffffffff,%esi stat(char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 204: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 20b: 00 20c: 89 04 24 mov %eax,(%esp) 20f: e8 d1 00 00 00 call 2e5 <open> if(fd < 0) 214: 85 c0 test %eax,%eax stat(char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 216: 89 c3 mov %eax,%ebx if(fd < 0) 218: 78 19 js 233 <stat+0x43> return -1; r = fstat(fd, st); 21a: 8b 45 0c mov 0xc(%ebp),%eax 21d: 89 1c 24 mov %ebx,(%esp) 220: 89 44 24 04 mov %eax,0x4(%esp) 224: e8 d4 00 00 00 call 2fd <fstat> close(fd); 229: 89 1c 24 mov %ebx,(%esp) int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; r = fstat(fd, st); 22c: 89 c6 mov %eax,%esi close(fd); 22e: e8 9a 00 00 00 call 2cd <close> return r; } 233: 89 f0 mov %esi,%eax 235: 8b 5d f8 mov -0x8(%ebp),%ebx 238: 8b 75 fc mov -0x4(%ebp),%esi 23b: 89 ec mov %ebp,%esp 23d: 5d pop %ebp 23e: c3 ret 23f: 90 nop 00000240 <gets>: return 0; } char* gets(char *buf, int max) { 240: 55 push %ebp 241: 89 e5 mov %esp,%ebp 243: 57 push %edi 244: 56 push %esi 245: 31 f6 xor %esi,%esi 247: 53 push %ebx 248: 83 ec 2c sub $0x2c,%esp 24b: 8b 7d 08 mov 0x8(%ebp),%edi int i, cc; char c; for(i=0; i+1 < max; ){ 24e: eb 06 jmp 256 <gets+0x16> cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; if(c == '\n' || c == '\r') 250: 3c 0a cmp $0xa,%al 252: 74 39 je 28d <gets+0x4d> 254: 89 de mov %ebx,%esi gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 256: 8d 5e 01 lea 0x1(%esi),%ebx 259: 3b 5d 0c cmp 0xc(%ebp),%ebx 25c: 7d 31 jge 28f <gets+0x4f> cc = read(0, &c, 1); 25e: 8d 45 e7 lea -0x19(%ebp),%eax 261: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 268: 00 269: 89 44 24 04 mov %eax,0x4(%esp) 26d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 274: e8 44 00 00 00 call 2bd <read> if(cc < 1) 279: 85 c0 test %eax,%eax 27b: 7e 12 jle 28f <gets+0x4f> break; buf[i++] = c; 27d: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 281: 88 44 1f ff mov %al,-0x1(%edi,%ebx,1) if(c == '\n' || c == '\r') 285: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 289: 3c 0d cmp $0xd,%al 28b: 75 c3 jne 250 <gets+0x10> 28d: 89 de mov %ebx,%esi break; } buf[i] = '\0'; 28f: c6 04 37 00 movb $0x0,(%edi,%esi,1) return buf; } 293: 89 f8 mov %edi,%eax 295: 83 c4 2c add $0x2c,%esp 298: 5b pop %ebx 299: 5e pop %esi 29a: 5f pop %edi 29b: 5d pop %ebp 29c: c3 ret 0000029d <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 29d: b8 01 00 00 00 mov $0x1,%eax 2a2: cd 40 int $0x40 2a4: c3 ret 000002a5 <exit>: SYSCALL(exit) 2a5: b8 02 00 00 00 mov $0x2,%eax 2aa: cd 40 int $0x40 2ac: c3 ret 000002ad <wait>: SYSCALL(wait) 2ad: b8 03 00 00 00 mov $0x3,%eax 2b2: cd 40 int $0x40 2b4: c3 ret 000002b5 <pipe>: SYSCALL(pipe) 2b5: b8 04 00 00 00 mov $0x4,%eax 2ba: cd 40 int $0x40 2bc: c3 ret 000002bd <read>: SYSCALL(read) 2bd: b8 05 00 00 00 mov $0x5,%eax 2c2: cd 40 int $0x40 2c4: c3 ret 000002c5 <write>: SYSCALL(write) 2c5: b8 10 00 00 00 mov $0x10,%eax 2ca: cd 40 int $0x40 2cc: c3 ret 000002cd <close>: SYSCALL(close) 2cd: b8 15 00 00 00 mov $0x15,%eax 2d2: cd 40 int $0x40 2d4: c3 ret 000002d5 <kill>: SYSCALL(kill) 2d5: b8 06 00 00 00 mov $0x6,%eax 2da: cd 40 int $0x40 2dc: c3 ret 000002dd <exec>: SYSCALL(exec) 2dd: b8 07 00 00 00 mov $0x7,%eax 2e2: cd 40 int $0x40 2e4: c3 ret 000002e5 <open>: SYSCALL(open) 2e5: b8 0f 00 00 00 mov $0xf,%eax 2ea: cd 40 int $0x40 2ec: c3 ret 000002ed <mknod>: SYSCALL(mknod) 2ed: b8 11 00 00 00 mov $0x11,%eax 2f2: cd 40 int $0x40 2f4: c3 ret 000002f5 <unlink>: SYSCALL(unlink) 2f5: b8 12 00 00 00 mov $0x12,%eax 2fa: cd 40 int $0x40 2fc: c3 ret 000002fd <fstat>: SYSCALL(fstat) 2fd: b8 08 00 00 00 mov $0x8,%eax 302: cd 40 int $0x40 304: c3 ret 00000305 <link>: SYSCALL(link) 305: b8 13 00 00 00 mov $0x13,%eax 30a: cd 40 int $0x40 30c: c3 ret 0000030d <mkdir>: SYSCALL(mkdir) 30d: b8 14 00 00 00 mov $0x14,%eax 312: cd 40 int $0x40 314: c3 ret 00000315 <chdir>: SYSCALL(chdir) 315: b8 09 00 00 00 mov $0x9,%eax 31a: cd 40 int $0x40 31c: c3 ret 0000031d <dup>: SYSCALL(dup) 31d: b8 0a 00 00 00 mov $0xa,%eax 322: cd 40 int $0x40 324: c3 ret 00000325 <getpid>: SYSCALL(getpid) 325: b8 0b 00 00 00 mov $0xb,%eax 32a: cd 40 int $0x40 32c: c3 ret 0000032d <sbrk>: SYSCALL(sbrk) 32d: b8 0c 00 00 00 mov $0xc,%eax 332: cd 40 int $0x40 334: c3 ret 00000335 <sleep>: SYSCALL(sleep) 335: b8 0d 00 00 00 mov $0xd,%eax 33a: cd 40 int $0x40 33c: c3 ret 0000033d <uptime>: SYSCALL(uptime) 33d: b8 0e 00 00 00 mov $0xe,%eax 342: cd 40 int $0x40 344: c3 ret 00000345 <date>: SYSCALL(date) 345: b8 16 00 00 00 mov $0x16,%eax 34a: cd 40 int $0x40 34c: c3 ret 0000034d <alarm>: SYSCALL(alarm) 34d: b8 17 00 00 00 mov $0x17,%eax 352: cd 40 int $0x40 354: c3 ret 355: 66 90 xchg %ax,%ax 357: 66 90 xchg %ax,%ax 359: 66 90 xchg %ax,%ax 35b: 66 90 xchg %ax,%ax 35d: 66 90 xchg %ax,%ax 35f: 90 nop 00000360 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 360: 55 push %ebp 361: 89 e5 mov %esp,%ebp 363: 57 push %edi 364: 89 cf mov %ecx,%edi 366: 56 push %esi 367: 89 c6 mov %eax,%esi 369: 53 push %ebx 36a: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 36d: 8b 4d 08 mov 0x8(%ebp),%ecx 370: 85 c9 test %ecx,%ecx 372: 74 04 je 378 <printint+0x18> 374: 85 d2 test %edx,%edx 376: 78 70 js 3e8 <printint+0x88> neg = 1; x = -xx; } else { x = xx; 378: 89 d0 mov %edx,%eax 37a: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 381: 31 c9 xor %ecx,%ecx 383: 8d 5d d7 lea -0x29(%ebp),%ebx 386: 66 90 xchg %ax,%ax } i = 0; do{ buf[i++] = digits[x % base]; 388: 31 d2 xor %edx,%edx 38a: f7 f7 div %edi 38c: 0f b6 92 86 07 00 00 movzbl 0x786(%edx),%edx 393: 88 14 0b mov %dl,(%ebx,%ecx,1) 396: 83 c1 01 add $0x1,%ecx }while((x /= base) != 0); 399: 85 c0 test %eax,%eax 39b: 75 eb jne 388 <printint+0x28> if(neg) 39d: 8b 45 c4 mov -0x3c(%ebp),%eax 3a0: 85 c0 test %eax,%eax 3a2: 74 08 je 3ac <printint+0x4c> buf[i++] = '-'; 3a4: c6 44 0d d7 2d movb $0x2d,-0x29(%ebp,%ecx,1) 3a9: 83 c1 01 add $0x1,%ecx while(--i >= 0) 3ac: 8d 79 ff lea -0x1(%ecx),%edi 3af: 01 fb add %edi,%ebx 3b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3b8: 0f b6 03 movzbl (%ebx),%eax 3bb: 83 ef 01 sub $0x1,%edi 3be: 83 eb 01 sub $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 3c1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3c8: 00 3c9: 89 34 24 mov %esi,(%esp) buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 3cc: 88 45 e7 mov %al,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 3cf: 8d 45 e7 lea -0x19(%ebp),%eax 3d2: 89 44 24 04 mov %eax,0x4(%esp) 3d6: e8 ea fe ff ff call 2c5 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 3db: 83 ff ff cmp $0xffffffff,%edi 3de: 75 d8 jne 3b8 <printint+0x58> putc(fd, buf[i]); } 3e0: 83 c4 4c add $0x4c,%esp 3e3: 5b pop %ebx 3e4: 5e pop %esi 3e5: 5f pop %edi 3e6: 5d pop %ebp 3e7: c3 ret uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 3e8: 89 d0 mov %edx,%eax 3ea: f7 d8 neg %eax 3ec: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 3f3: eb 8c jmp 381 <printint+0x21> 3f5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000400 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 400: 55 push %ebp 401: 89 e5 mov %esp,%ebp 403: 57 push %edi 404: 56 push %esi 405: 53 push %ebx 406: 83 ec 3c sub $0x3c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 409: 8b 45 0c mov 0xc(%ebp),%eax 40c: 0f b6 10 movzbl (%eax),%edx 40f: 84 d2 test %dl,%dl 411: 0f 84 c9 00 00 00 je 4e0 <printf+0xe0> char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 417: 8d 4d 10 lea 0x10(%ebp),%ecx 41a: 31 ff xor %edi,%edi 41c: 89 4d d4 mov %ecx,-0x2c(%ebp) 41f: 31 db xor %ebx,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 421: 8d 75 e7 lea -0x19(%ebp),%esi 424: eb 1e jmp 444 <printf+0x44> 426: 66 90 xchg %ax,%ax state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 428: 83 fa 25 cmp $0x25,%edx 42b: 0f 85 b7 00 00 00 jne 4e8 <printf+0xe8> 431: 66 bf 25 00 mov $0x25,%di int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 435: 83 c3 01 add $0x1,%ebx 438: 0f b6 14 18 movzbl (%eax,%ebx,1),%edx 43c: 84 d2 test %dl,%dl 43e: 0f 84 9c 00 00 00 je 4e0 <printf+0xe0> c = fmt[i] & 0xff; if(state == 0){ 444: 85 ff test %edi,%edi uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 446: 0f b6 d2 movzbl %dl,%edx if(state == 0){ 449: 74 dd je 428 <printf+0x28> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 44b: 83 ff 25 cmp $0x25,%edi 44e: 75 e5 jne 435 <printf+0x35> if(c == 'd'){ 450: 83 fa 64 cmp $0x64,%edx 453: 0f 84 47 01 00 00 je 5a0 <printf+0x1a0> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 459: 83 fa 70 cmp $0x70,%edx 45c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 460: 0f 84 aa 00 00 00 je 510 <printf+0x110> 466: 83 fa 78 cmp $0x78,%edx 469: 0f 84 a1 00 00 00 je 510 <printf+0x110> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 46f: 83 fa 73 cmp $0x73,%edx 472: 0f 84 c0 00 00 00 je 538 <printf+0x138> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 478: 83 fa 63 cmp $0x63,%edx 47b: 90 nop 47c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 480: 0f 84 42 01 00 00 je 5c8 <printf+0x1c8> putc(fd, *ap); ap++; } else if(c == '%'){ 486: 83 fa 25 cmp $0x25,%edx 489: 0f 84 01 01 00 00 je 590 <printf+0x190> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 48f: 8b 4d 08 mov 0x8(%ebp),%ecx 492: 89 55 cc mov %edx,-0x34(%ebp) 495: c6 45 e7 25 movb $0x25,-0x19(%ebp) 499: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4a0: 00 4a1: 89 74 24 04 mov %esi,0x4(%esp) 4a5: 89 0c 24 mov %ecx,(%esp) 4a8: e8 18 fe ff ff call 2c5 <write> 4ad: 8b 55 cc mov -0x34(%ebp),%edx 4b0: 88 55 e7 mov %dl,-0x19(%ebp) 4b3: 8b 45 08 mov 0x8(%ebp),%eax int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4b6: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4b9: 31 ff xor %edi,%edi 4bb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4c2: 00 4c3: 89 74 24 04 mov %esi,0x4(%esp) 4c7: 89 04 24 mov %eax,(%esp) 4ca: e8 f6 fd ff ff call 2c5 <write> 4cf: 8b 45 0c mov 0xc(%ebp),%eax int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4d2: 0f b6 14 18 movzbl (%eax,%ebx,1),%edx 4d6: 84 d2 test %dl,%dl 4d8: 0f 85 66 ff ff ff jne 444 <printf+0x44> 4de: 66 90 xchg %ax,%ax putc(fd, c); } state = 0; } } } 4e0: 83 c4 3c add $0x3c,%esp 4e3: 5b pop %ebx 4e4: 5e pop %esi 4e5: 5f pop %edi 4e6: 5d pop %ebp 4e7: c3 ret #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4e8: 8b 45 08 mov 0x8(%ebp),%eax state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4eb: 88 55 e7 mov %dl,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4ee: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4f5: 00 4f6: 89 74 24 04 mov %esi,0x4(%esp) 4fa: 89 04 24 mov %eax,(%esp) 4fd: e8 c3 fd ff ff call 2c5 <write> 502: 8b 45 0c mov 0xc(%ebp),%eax 505: e9 2b ff ff ff jmp 435 <printf+0x35> 50a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 510: 8b 45 d4 mov -0x2c(%ebp),%eax 513: b9 10 00 00 00 mov $0x10,%ecx ap++; 518: 31 ff xor %edi,%edi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 51a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 521: 8b 10 mov (%eax),%edx 523: 8b 45 08 mov 0x8(%ebp),%eax 526: e8 35 fe ff ff call 360 <printint> 52b: 8b 45 0c mov 0xc(%ebp),%eax ap++; 52e: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 532: e9 fe fe ff ff jmp 435 <printf+0x35> 537: 90 nop } else if(c == 's'){ s = (char*)*ap; 538: 8b 55 d4 mov -0x2c(%ebp),%edx ap++; if(s == 0) 53b: b9 7f 07 00 00 mov $0x77f,%ecx ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ s = (char*)*ap; 540: 8b 3a mov (%edx),%edi ap++; 542: 83 c2 04 add $0x4,%edx 545: 89 55 d4 mov %edx,-0x2c(%ebp) if(s == 0) 548: 85 ff test %edi,%edi 54a: 0f 44 f9 cmove %ecx,%edi s = "(null)"; while(*s != 0){ 54d: 0f b6 17 movzbl (%edi),%edx 550: 84 d2 test %dl,%dl 552: 74 33 je 587 <printf+0x187> 554: 89 5d d0 mov %ebx,-0x30(%ebp) 557: 8b 5d 08 mov 0x8(%ebp),%ebx 55a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi putc(fd, *s); s++; 560: 83 c7 01 add $0x1,%edi } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 563: 88 55 e7 mov %dl,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 566: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 56d: 00 56e: 89 74 24 04 mov %esi,0x4(%esp) 572: 89 1c 24 mov %ebx,(%esp) 575: e8 4b fd ff ff call 2c5 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 57a: 0f b6 17 movzbl (%edi),%edx 57d: 84 d2 test %dl,%dl 57f: 75 df jne 560 <printf+0x160> 581: 8b 5d d0 mov -0x30(%ebp),%ebx 584: 8b 45 0c mov 0xc(%ebp),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 587: 31 ff xor %edi,%edi 589: e9 a7 fe ff ff jmp 435 <printf+0x35> 58e: 66 90 xchg %ax,%ax s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; } else if(c == '%'){ 590: c6 45 e7 25 movb $0x25,-0x19(%ebp) 594: e9 1a ff ff ff jmp 4b3 <printf+0xb3> 599: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 5a0: 8b 45 d4 mov -0x2c(%ebp),%eax 5a3: b9 0a 00 00 00 mov $0xa,%ecx ap++; 5a8: 66 31 ff xor %di,%di } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 5ab: c7 04 24 01 00 00 00 movl $0x1,(%esp) 5b2: 8b 10 mov (%eax),%edx 5b4: 8b 45 08 mov 0x8(%ebp),%eax 5b7: e8 a4 fd ff ff call 360 <printint> 5bc: 8b 45 0c mov 0xc(%ebp),%eax ap++; 5bf: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 5c3: e9 6d fe ff ff jmp 435 <printf+0x35> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 5c8: 8b 55 d4 mov -0x2c(%ebp),%edx putc(fd, *ap); ap++; 5cb: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5cd: 8b 4d 08 mov 0x8(%ebp),%ecx s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 5d0: 8b 02 mov (%edx),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5d2: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 5d9: 00 5da: 89 74 24 04 mov %esi,0x4(%esp) 5de: 89 0c 24 mov %ecx,(%esp) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 5e1: 88 45 e7 mov %al,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5e4: e8 dc fc ff ff call 2c5 <write> 5e9: 8b 45 0c mov 0xc(%ebp),%eax putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; 5ec: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 5f0: e9 40 fe ff ff jmp 435 <printf+0x35> 5f5: 66 90 xchg %ax,%ax 5f7: 66 90 xchg %ax,%ax 5f9: 66 90 xchg %ax,%ax 5fb: 66 90 xchg %ax,%ax 5fd: 66 90 xchg %ax,%ax 5ff: 90 nop 00000600 <free>: static Header base; static Header *freep; void free(void *ap) { 600: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 601: a1 a0 07 00 00 mov 0x7a0,%eax static Header base; static Header *freep; void free(void *ap) { 606: 89 e5 mov %esp,%ebp 608: 57 push %edi 609: 56 push %esi 60a: 53 push %ebx 60b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; 60e: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 611: 39 c8 cmp %ecx,%eax 613: 73 1d jae 632 <free+0x32> 615: 8d 76 00 lea 0x0(%esi),%esi 618: 8b 10 mov (%eax),%edx 61a: 39 d1 cmp %edx,%ecx 61c: 72 1a jb 638 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 61e: 39 d0 cmp %edx,%eax 620: 72 08 jb 62a <free+0x2a> 622: 39 c8 cmp %ecx,%eax 624: 72 12 jb 638 <free+0x38> 626: 39 d1 cmp %edx,%ecx 628: 72 0e jb 638 <free+0x38> 62a: 89 d0 mov %edx,%eax free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 62c: 39 c8 cmp %ecx,%eax 62e: 66 90 xchg %ax,%ax 630: 72 e6 jb 618 <free+0x18> 632: 8b 10 mov (%eax),%edx 634: eb e8 jmp 61e <free+0x1e> 636: 66 90 xchg %ax,%ax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 638: 8b 71 04 mov 0x4(%ecx),%esi 63b: 8d 3c f1 lea (%ecx,%esi,8),%edi 63e: 39 d7 cmp %edx,%edi 640: 74 19 je 65b <free+0x5b> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 642: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 645: 8b 50 04 mov 0x4(%eax),%edx 648: 8d 34 d0 lea (%eax,%edx,8),%esi 64b: 39 ce cmp %ecx,%esi 64d: 74 23 je 672 <free+0x72> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 64f: 89 08 mov %ecx,(%eax) freep = p; 651: a3 a0 07 00 00 mov %eax,0x7a0 } 656: 5b pop %ebx 657: 5e pop %esi 658: 5f pop %edi 659: 5d pop %ebp 65a: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 65b: 03 72 04 add 0x4(%edx),%esi 65e: 89 71 04 mov %esi,0x4(%ecx) bp->s.ptr = p->s.ptr->s.ptr; 661: 8b 10 mov (%eax),%edx 663: 8b 12 mov (%edx),%edx 665: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 668: 8b 50 04 mov 0x4(%eax),%edx 66b: 8d 34 d0 lea (%eax,%edx,8),%esi 66e: 39 ce cmp %ecx,%esi 670: 75 dd jne 64f <free+0x4f> p->s.size += bp->s.size; 672: 03 51 04 add 0x4(%ecx),%edx 675: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 678: 8b 53 f8 mov -0x8(%ebx),%edx 67b: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; 67d: a3 a0 07 00 00 mov %eax,0x7a0 } 682: 5b pop %ebx 683: 5e pop %esi 684: 5f pop %edi 685: 5d pop %ebp 686: c3 ret 687: 89 f6 mov %esi,%esi 689: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000690 <malloc>: return freep; } void* malloc(uint nbytes) { 690: 55 push %ebp 691: 89 e5 mov %esp,%ebp 693: 57 push %edi 694: 56 push %esi 695: 53 push %ebx 696: 83 ec 2c sub $0x2c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 699: 8b 5d 08 mov 0x8(%ebp),%ebx if((prevp = freep) == 0){ 69c: 8b 0d a0 07 00 00 mov 0x7a0,%ecx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6a2: 83 c3 07 add $0x7,%ebx 6a5: c1 eb 03 shr $0x3,%ebx 6a8: 83 c3 01 add $0x1,%ebx if((prevp = freep) == 0){ 6ab: 85 c9 test %ecx,%ecx 6ad: 0f 84 9b 00 00 00 je 74e <malloc+0xbe> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6b3: 8b 01 mov (%ecx),%eax if(p->s.size >= nunits){ 6b5: 8b 50 04 mov 0x4(%eax),%edx 6b8: 39 d3 cmp %edx,%ebx 6ba: 76 27 jbe 6e3 <malloc+0x53> p->s.size -= nunits; p += p->s.size; p->s.size = nunits; } freep = prevp; return (void*)(p + 1); 6bc: 8d 3c dd 00 00 00 00 lea 0x0(,%ebx,8),%edi morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 6c3: be 00 80 00 00 mov $0x8000,%esi 6c8: 89 7d e4 mov %edi,-0x1c(%ebp) 6cb: 90 nop 6cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6d0: 3b 05 a0 07 00 00 cmp 0x7a0,%eax 6d6: 74 30 je 708 <malloc+0x78> 6d8: 89 c1 mov %eax,%ecx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 6da: 8b 01 mov (%ecx),%eax if(p->s.size >= nunits){ 6dc: 8b 50 04 mov 0x4(%eax),%edx 6df: 39 d3 cmp %edx,%ebx 6e1: 77 ed ja 6d0 <malloc+0x40> if(p->s.size == nunits) 6e3: 39 d3 cmp %edx,%ebx 6e5: 74 61 je 748 <malloc+0xb8> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 6e7: 29 da sub %ebx,%edx 6e9: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 6ec: 8d 04 d0 lea (%eax,%edx,8),%eax p->s.size = nunits; 6ef: 89 58 04 mov %ebx,0x4(%eax) } freep = prevp; 6f2: 89 0d a0 07 00 00 mov %ecx,0x7a0 return (void*)(p + 1); 6f8: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 6fb: 83 c4 2c add $0x2c,%esp 6fe: 5b pop %ebx 6ff: 5e pop %esi 700: 5f pop %edi 701: 5d pop %ebp 702: c3 ret 703: 90 nop 704: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 708: 8b 45 e4 mov -0x1c(%ebp),%eax 70b: 81 fb 00 10 00 00 cmp $0x1000,%ebx 711: bf 00 10 00 00 mov $0x1000,%edi 716: 0f 43 fb cmovae %ebx,%edi 719: 0f 42 c6 cmovb %esi,%eax nu = 4096; p = sbrk(nu * sizeof(Header)); 71c: 89 04 24 mov %eax,(%esp) 71f: e8 09 fc ff ff call 32d <sbrk> if(p == (char*)-1) 724: 83 f8 ff cmp $0xffffffff,%eax 727: 74 18 je 741 <malloc+0xb1> return 0; hp = (Header*)p; hp->s.size = nu; 729: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); 72c: 83 c0 08 add $0x8,%eax 72f: 89 04 24 mov %eax,(%esp) 732: e8 c9 fe ff ff call 600 <free> return freep; 737: 8b 0d a0 07 00 00 mov 0x7a0,%ecx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 73d: 85 c9 test %ecx,%ecx 73f: 75 99 jne 6da <malloc+0x4a> if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 741: 31 c0 xor %eax,%eax 743: eb b6 jmp 6fb <malloc+0x6b> 745: 8d 76 00 lea 0x0(%esi),%esi if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 748: 8b 10 mov (%eax),%edx 74a: 89 11 mov %edx,(%ecx) 74c: eb a4 jmp 6f2 <malloc+0x62> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 74e: c7 05 a0 07 00 00 98 movl $0x798,0x7a0 755: 07 00 00 base.s.size = 0; 758: b9 98 07 00 00 mov $0x798,%ecx Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 75d: c7 05 98 07 00 00 98 movl $0x798,0x798 764: 07 00 00 base.s.size = 0; 767: c7 05 9c 07 00 00 00 movl $0x0,0x79c 76e: 00 00 00 771: e9 3d ff ff ff jmp 6b3 <malloc+0x23>
; ; ZX Spectrum specific routines ; by Stefano Bodrato, Fall 2013 ; ; int set_psg(int reg, int val); ; ; Play a sound by PSG ; ; ; $Id: set_psg_callee.asm,v 1.5 2017-01-02 23:57:08 aralbrec Exp $ ; SECTION code_clib PUBLIC set_psg_callee PUBLIC _set_psg_callee EXTERN __psg_select_and_read_port EXTERN __psg_write_port PUBLIC asm_set_psg set_psg_callee: _set_psg_callee: pop hl pop de ex (sp),hl .asm_set_psg ld bc,(__psg_select_and_read_port) out (c),l ld bc,(__psg_write_port) out (c),e ; ZON-X ld a,l out ($ff),a ld a,e out ($7f),a ; ZXM and "William Stuart" ld a,l out ($9f),a ld a,e out ($df),a ret
; A261391: a(n) = n^5 + 5*n^3 + 5*n. ; 0,11,82,393,1364,3775,8886,18557,35368,62739,105050,167761,257532,382343,551614,776325,1069136,1444507,1918818,2510489,3240100,4130511,5206982,6497293,8031864,9843875,11969386,14447457,17320268,20633239,24435150,28778261,33718432,39315243,45632114,52736425,60699636,69597407,79509718,90520989,102720200,116201011,131061882,147406193,165342364,184983975,206449886,229864357,255357168,283063739,313125250,345688761,380907332,418940143,459952614,504116525,551610136,602618307,657332618,715951489,778680300,845731511,917324782,993687093,1075052864,1161664075,1253770386,1351629257,1455506068,1565674239,1682415350,1806019261,1936784232,2075017043,2221033114,2375156625,2537720636,2709067207,2889547518,3079521989,3279360400,3489442011,3710155682,3941899993,4185083364,4440124175,4707450886,4987502157,5280726968,5587584739,5908545450,6244089761,6594709132,6960905943,7343193614,7742096725,8158151136,8591904107,9043914418,9514752489,10005000500,10515252511,11046114582,11598204893,12172153864,12768604275,13388211386,14031643057,14699579868,15392715239,16111755550,16857420261,17630442032,18431566843,19261554114,20121176825,21011221636,21932489007,22885793318,23871962989,24891840600,25946283011,27036161482,28162361793,29325784364,30527344375,31767971886,33048611957,34370224768,35733785739,37140285650,38590730761,40086142932,41627559743,43216034614,44852636925,46538452136,48274581907,50062144218,51902273489,53796120700,55744853511,57749656382,59811730693,61932294864,64112584475,66353852386,68657368857,71024421668,73456316239,75954375750,78519941261,81154371832,83859044643,86635355114,89484717025,92408562636,95408342807,98485527118,101641603989,104878080800,108196484011,111598359282,115085271593,118658805364,122320564575,126072172886,129915273757,133851530568,137882626739,142010265850,146236171761,150562088732,154989781543,159521035614,164157657125,168901473136,173754331707,178718102018,183794674489,188985960900,194293894511,199720430182,205267544493,210937235864,216731524675,222652453386,228702086657,234882511468,241195837239,247644195950,254229742261,260954653632,267821130443,274831396114,281987697225,289292303636,296747508607,304355628918,312119004989,320040001000,328121005011,336364429082,344772709393,353348306364,362093704775,371011413886,380103967557,389373924368,398823867739,408456406050,418274172761,428279826532,438476051343,448865556614,459451077325,470235374136,481221233507,492411467818,503808915489,515416441100,527236935511,539273315982,551528526293,564005536864,576707344875,589636974386,602797476457,616191929268,629823438239,643695136150,657810183261,672171767432,686783104243,701647437114,716768037425,732148204636,747791266407,763700578718,779879525989,796331521200,813060006011,830068450882,847360355193,864939247364,882808684975,900972254886,919433573357,938196286168,957264068739 mov $1,$0 pow $1,4 add $1,4 mul $1,$0 add $1,$0 mov $3,$0 mul $3,$0 mul $3,$0 mov $2,$3 mul $2,5 add $1,$2
;***************************************************************************** ;* deblock-a.asm: x86 deblocking ;***************************************************************************** ;* Copyright (C) 2005-2017 x264 project ;* ;* Authors: Loren Merritt <lorenm@u.washington.edu> ;* Fiona Glaser <fiona@x264.com> ;* Oskar Arvidsson <oskar@irock.se> ;* ;* This program is free software; you can redistribute it and/or modify ;* it under the terms of the GNU General Public License as published by ;* the Free Software Foundation; either version 2 of the License, or ;* (at your option) any later version. ;* ;* This program is distributed in the hope that it will be useful, ;* but WITHOUT ANY WARRANTY; without even the implied warranty of ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;* GNU General Public License for more details. ;* ;* You should have received a copy of the GNU General Public License ;* along with this program; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA. ;* ;* This program is also available under a commercial proprietary license. ;* For more information, contact us at licensing@x264.com. ;***************************************************************************** %include "x86inc.asm" %include "x86util.asm" SECTION_RODATA 64 load_bytes_zmm_shuf: dd 0x50404032, 0x70606053, 0xd0c0c0b4, 0xf0e0e0d5 dd 0x50404036, 0x70606057, 0xd0c0c0b8, 0xf0e0e0d9 dd 0x50104001, 0x70306023, 0xd090c083, 0xf0b0e0a5 dd 0x50104005, 0x70306027, 0xd090c087, 0xf0b0e0a9 load_bytes_ymm_shuf: dd 0x06050403, 0x0e0d0c1b, 0x07060544, 0x0f0e0d5c dd 0x06050473, 0x0e0d0c2b, 0x07060534, 0x0f0e0d6c transpose_shuf: db 0,4,8,12,1,5,9,13,2,6,10,14,3,7,11,15 SECTION .text cextern pb_0 cextern pb_1 cextern pb_3 cextern pb_a1 cextern pw_2 cextern pw_4 cextern pw_00ff cextern pw_pixel_max cextern pb_unpackbd1 %if HIGH_BIT_DEPTH ; out: %4 = |%1-%2|-%3 ; clobbers: %5 %macro ABS_SUB 5 psubusw %5, %2, %1 psubusw %4, %1, %2 por %4, %5 psubw %4, %3 %endmacro ; out: %4 = |%1-%2|<%3 %macro DIFF_LT 5 psubusw %4, %2, %1 psubusw %5, %1, %2 por %5, %4 ; |%1-%2| pxor %4, %4 psubw %5, %3 ; |%1-%2|-%3 pcmpgtw %4, %5 ; 0 > |%1-%2|-%3 %endmacro %macro LOAD_AB 4 movd %1, %3 movd %2, %4 SPLATW %1, %1 SPLATW %2, %2 %endmacro ; in: %2=tc reg ; out: %1=splatted tc %macro LOAD_TC 2 %if mmsize == 8 pshufw %1, [%2-1], 0 %else movd %1, [%2] punpcklbw %1, %1 pshuflw %1, %1, q1100 pshufd %1, %1, q1100 %endif psraw %1, 8 %endmacro ; in: %1=p1, %2=p0, %3=q0, %4=q1 ; %5=alpha, %6=beta, %7-%9=tmp ; out: %7=mask %macro LOAD_MASK 9 ABS_SUB %2, %3, %5, %8, %7 ; |p0-q0| - alpha ABS_SUB %1, %2, %6, %9, %7 ; |p1-p0| - beta pand %8, %9 ABS_SUB %3, %4, %6, %9, %7 ; |q1-q0| - beta pxor %7, %7 pand %8, %9 pcmpgtw %7, %8 %endmacro ; in: %1=p0, %2=q0, %3=p1, %4=q1, %5=mask, %6=tmp, %7=tmp ; out: %1=p0', m2=q0' %macro DEBLOCK_P0_Q0 7 psubw %3, %4 pxor %7, %7 paddw %3, [pw_4] psubw %7, %5 psubw %6, %2, %1 psllw %6, 2 paddw %3, %6 psraw %3, 3 mova %6, [pw_pixel_max] CLIPW %3, %7, %5 pxor %7, %7 paddw %1, %3 psubw %2, %3 CLIPW %1, %7, %6 CLIPW %2, %7, %6 %endmacro ; in: %1=x2, %2=x1, %3=p0, %4=q0 %5=mask&tc, %6=tmp %macro LUMA_Q1 6 pavgw %6, %3, %4 ; (p0+q0+1)>>1 paddw %1, %6 pxor %6, %6 psraw %1, 1 psubw %6, %5 psubw %1, %2 CLIPW %1, %6, %5 paddw %1, %2 %endmacro %macro LUMA_DEBLOCK_ONE 3 DIFF_LT m5, %1, bm, m4, m6 pxor m6, m6 mova %3, m4 pcmpgtw m6, tcm pand m4, tcm pandn m6, m7 pand m4, m6 LUMA_Q1 m5, %2, m1, m2, m4, m6 %endmacro %macro LUMA_H_STORE 2 %if mmsize == 8 movq [r0-4], m0 movq [r0+r1-4], m1 movq [r0+r1*2-4], m2 movq [r0+%2-4], m3 %else movq [r0-4], m0 movhps [r0+r1-4], m0 movq [r0+r1*2-4], m1 movhps [%1-4], m1 movq [%1+r1-4], m2 movhps [%1+r1*2-4], m2 movq [%1+%2-4], m3 movhps [%1+r1*4-4], m3 %endif %endmacro %macro DEBLOCK_LUMA 0 ;----------------------------------------------------------------------------- ; void deblock_v_luma( uint16_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- cglobal deblock_v_luma, 5,5,8,0-5*mmsize %define tcm [rsp] %define ms1 [rsp+mmsize] %define ms2 [rsp+mmsize*2] %define am [rsp+mmsize*3] %define bm [rsp+mmsize*4] add r1, r1 LOAD_AB m4, m5, r2d, r3d mov r3, 32/mmsize mov r2, r0 sub r0, r1 mova am, m4 sub r0, r1 mova bm, m5 sub r0, r1 .loop: mova m0, [r0+r1] mova m1, [r0+r1*2] mova m2, [r2] mova m3, [r2+r1] LOAD_MASK m0, m1, m2, m3, am, bm, m7, m4, m6 LOAD_TC m6, r4 mova tcm, m6 mova m5, [r0] LUMA_DEBLOCK_ONE m1, m0, ms1 mova [r0+r1], m5 mova m5, [r2+r1*2] LUMA_DEBLOCK_ONE m2, m3, ms2 mova [r2+r1], m5 pxor m5, m5 mova m6, tcm pcmpgtw m5, tcm psubw m6, ms1 pandn m5, m7 psubw m6, ms2 pand m5, m6 DEBLOCK_P0_Q0 m1, m2, m0, m3, m5, m7, m6 mova [r0+r1*2], m1 mova [r2], m2 add r0, mmsize add r2, mmsize add r4, mmsize/8 dec r3 jg .loop RET cglobal deblock_h_luma, 5,6,8,0-7*mmsize %define tcm [rsp] %define ms1 [rsp+mmsize] %define ms2 [rsp+mmsize*2] %define p1m [rsp+mmsize*3] %define p2m [rsp+mmsize*4] %define am [rsp+mmsize*5] %define bm [rsp+mmsize*6] add r1, r1 LOAD_AB m4, m5, r2d, r3d mov r3, r1 mova am, m4 add r3, r1 mov r5, 32/mmsize mova bm, m5 add r3, r1 %if mmsize == 16 mov r2, r0 add r2, r3 %endif .loop: %if mmsize == 8 movq m2, [r0-8] ; y q2 q1 q0 movq m7, [r0+0] movq m5, [r0+r1-8] movq m3, [r0+r1+0] movq m0, [r0+r1*2-8] movq m6, [r0+r1*2+0] movq m1, [r0+r3-8] TRANSPOSE4x4W 2, 5, 0, 1, 4 SWAP 2, 7 movq m7, [r0+r3] TRANSPOSE4x4W 2, 3, 6, 7, 4 %else movu m5, [r0-8] ; y q2 q1 q0 p0 p1 p2 x movu m0, [r0+r1-8] movu m2, [r0+r1*2-8] movu m3, [r2-8] TRANSPOSE4x4W 5, 0, 2, 3, 6 mova tcm, m3 movu m4, [r2+r1-8] movu m1, [r2+r1*2-8] movu m3, [r2+r3-8] movu m7, [r2+r1*4-8] TRANSPOSE4x4W 4, 1, 3, 7, 6 mova m6, tcm punpcklqdq m6, m7 punpckhqdq m5, m4 SBUTTERFLY qdq, 0, 1, 7 SBUTTERFLY qdq, 2, 3, 7 %endif mova p2m, m6 LOAD_MASK m0, m1, m2, m3, am, bm, m7, m4, m6 LOAD_TC m6, r4 mova tcm, m6 LUMA_DEBLOCK_ONE m1, m0, ms1 mova p1m, m5 mova m5, p2m LUMA_DEBLOCK_ONE m2, m3, ms2 mova p2m, m5 pxor m5, m5 mova m6, tcm pcmpgtw m5, tcm psubw m6, ms1 pandn m5, m7 psubw m6, ms2 pand m5, m6 DEBLOCK_P0_Q0 m1, m2, m0, m3, m5, m7, m6 mova m0, p1m mova m3, p2m TRANSPOSE4x4W 0, 1, 2, 3, 4 LUMA_H_STORE r2, r3 add r4, mmsize/8 lea r0, [r0+r1*(mmsize/2)] lea r2, [r2+r1*(mmsize/2)] dec r5 jg .loop RET %endmacro %if ARCH_X86_64 ; in: m0=p1, m1=p0, m2=q0, m3=q1, m8=p2, m9=q2 ; m12=alpha, m13=beta ; out: m0=p1', m3=q1', m1=p0', m2=q0' ; clobbers: m4, m5, m6, m7, m10, m11, m14 %macro DEBLOCK_LUMA_INTER_SSE2 0 LOAD_MASK m0, m1, m2, m3, m12, m13, m7, m4, m6 LOAD_TC m6, r4 DIFF_LT m8, m1, m13, m10, m4 DIFF_LT m9, m2, m13, m11, m4 pand m6, m7 mova m14, m6 pxor m4, m4 pcmpgtw m6, m4 pand m6, m14 mova m5, m10 pand m5, m6 LUMA_Q1 m8, m0, m1, m2, m5, m4 mova m5, m11 pand m5, m6 LUMA_Q1 m9, m3, m1, m2, m5, m4 pxor m4, m4 psubw m6, m10 pcmpgtw m4, m14 pandn m4, m7 psubw m6, m11 pand m4, m6 DEBLOCK_P0_Q0 m1, m2, m0, m3, m4, m5, m6 SWAP 0, 8 SWAP 3, 9 %endmacro %macro DEBLOCK_LUMA_64 0 cglobal deblock_v_luma, 5,5,15 %define p2 m8 %define p1 m0 %define p0 m1 %define q0 m2 %define q1 m3 %define q2 m9 %define mask0 m7 %define mask1 m10 %define mask2 m11 add r1, r1 LOAD_AB m12, m13, r2d, r3d mov r2, r0 sub r0, r1 sub r0, r1 sub r0, r1 mov r3, 2 .loop: mova p2, [r0] mova p1, [r0+r1] mova p0, [r0+r1*2] mova q0, [r2] mova q1, [r2+r1] mova q2, [r2+r1*2] DEBLOCK_LUMA_INTER_SSE2 mova [r0+r1], p1 mova [r0+r1*2], p0 mova [r2], q0 mova [r2+r1], q1 add r0, mmsize add r2, mmsize add r4, 2 dec r3 jg .loop RET cglobal deblock_h_luma, 5,7,15 add r1, r1 LOAD_AB m12, m13, r2d, r3d mov r2, r1 add r2, r1 add r2, r1 mov r5, r0 add r5, r2 mov r6, 2 .loop: movu m8, [r0-8] ; y q2 q1 q0 p0 p1 p2 x movu m0, [r0+r1-8] movu m2, [r0+r1*2-8] movu m9, [r5-8] movu m5, [r5+r1-8] movu m1, [r5+r1*2-8] movu m3, [r5+r2-8] movu m7, [r5+r1*4-8] TRANSPOSE4x4W 8, 0, 2, 9, 10 TRANSPOSE4x4W 5, 1, 3, 7, 10 punpckhqdq m8, m5 SBUTTERFLY qdq, 0, 1, 10 SBUTTERFLY qdq, 2, 3, 10 punpcklqdq m9, m7 DEBLOCK_LUMA_INTER_SSE2 TRANSPOSE4x4W 0, 1, 2, 3, 4 LUMA_H_STORE r5, r2 add r4, 2 lea r0, [r0+r1*8] lea r5, [r5+r1*8] dec r6 jg .loop RET %endmacro INIT_XMM sse2 DEBLOCK_LUMA_64 INIT_XMM avx DEBLOCK_LUMA_64 %endif %macro SWAPMOVA 2 %ifnum sizeof%1 SWAP %1, %2 %else mova %1, %2 %endif %endmacro ; in: t0-t2: tmp registers ; %1=p0 %2=p1 %3=p2 %4=p3 %5=q0 %6=q1 %7=mask0 ; %8=mask1p %9=2 %10=p0' %11=p1' %12=p2' %macro LUMA_INTRA_P012 12 ; p0..p3 in memory %if ARCH_X86_64 paddw t0, %3, %2 mova t2, %4 paddw t2, %3 %else mova t0, %3 mova t2, %4 paddw t0, %2 paddw t2, %3 %endif paddw t0, %1 paddw t2, t2 paddw t0, %5 paddw t2, %9 paddw t0, %9 ; (p2 + p1 + p0 + q0 + 2) paddw t2, t0 ; (2*p3 + 3*p2 + p1 + p0 + q0 + 4) psrlw t2, 3 psrlw t1, t0, 2 psubw t2, %3 psubw t1, %2 pand t2, %8 pand t1, %8 paddw t2, %3 paddw t1, %2 SWAPMOVA %11, t1 psubw t1, t0, %3 paddw t0, t0 psubw t1, %5 psubw t0, %3 paddw t1, %6 paddw t1, %2 paddw t0, %6 psrlw t1, 2 ; (2*p1 + p0 + q1 + 2)/4 psrlw t0, 3 ; (p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4)>>3 pxor t0, t1 pxor t1, %1 pand t0, %8 pand t1, %7 pxor t0, t1 pxor t0, %1 SWAPMOVA %10, t0 SWAPMOVA %12, t2 %endmacro %macro LUMA_INTRA_INIT 1 %define t0 m4 %define t1 m5 %define t2 m6 %define t3 m7 %assign i 4 %rep %1 CAT_XDEFINE t, i, [rsp+mmsize*(i-4)] %assign i i+1 %endrep add r1, r1 %endmacro ; in: %1-%3=tmp, %4=p2, %5=q2 %macro LUMA_INTRA_INTER 5 LOAD_AB t0, t1, r2d, r3d mova %1, t0 LOAD_MASK m0, m1, m2, m3, %1, t1, t0, t2, t3 %if ARCH_X86_64 mova %2, t0 ; mask0 psrlw t3, %1, 2 %else mova t3, %1 mova %2, t0 ; mask0 psrlw t3, 2 %endif paddw t3, [pw_2] ; alpha/4+2 DIFF_LT m1, m2, t3, t2, t0 ; t2 = |p0-q0| < alpha/4+2 pand t2, %2 mova t3, %5 ; q2 mova %1, t2 ; mask1 DIFF_LT t3, m2, t1, t2, t0 ; t2 = |q2-q0| < beta pand t2, %1 mova t3, %4 ; p2 mova %3, t2 ; mask1q DIFF_LT t3, m1, t1, t2, t0 ; t2 = |p2-p0| < beta pand t2, %1 mova %1, t2 ; mask1p %endmacro %macro LUMA_H_INTRA_LOAD 0 %if mmsize == 8 movu t0, [r0-8] movu t1, [r0+r1-8] movu m0, [r0+r1*2-8] movu m1, [r0+r4-8] TRANSPOSE4x4W 4, 5, 0, 1, 2 mova t4, t0 ; p3 mova t5, t1 ; p2 movu m2, [r0] movu m3, [r0+r1] movu t0, [r0+r1*2] movu t1, [r0+r4] TRANSPOSE4x4W 2, 3, 4, 5, 6 mova t6, t0 ; q2 mova t7, t1 ; q3 %else movu t0, [r0-8] movu t1, [r0+r1-8] movu m0, [r0+r1*2-8] movu m1, [r0+r5-8] movu m2, [r4-8] movu m3, [r4+r1-8] movu t2, [r4+r1*2-8] movu t3, [r4+r5-8] TRANSPOSE8x8W 4, 5, 0, 1, 2, 3, 6, 7, t4, t5 mova t4, t0 ; p3 mova t5, t1 ; p2 mova t6, t2 ; q2 mova t7, t3 ; q3 %endif %endmacro ; in: %1=q3 %2=q2' %3=q1' %4=q0' %5=p0' %6=p1' %7=p2' %8=p3 %9=tmp %macro LUMA_H_INTRA_STORE 9 %if mmsize == 8 TRANSPOSE4x4W %1, %2, %3, %4, %9 movq [r0-8], m%1 movq [r0+r1-8], m%2 movq [r0+r1*2-8], m%3 movq [r0+r4-8], m%4 movq m%1, %8 TRANSPOSE4x4W %5, %6, %7, %1, %9 movq [r0], m%5 movq [r0+r1], m%6 movq [r0+r1*2], m%7 movq [r0+r4], m%1 %else TRANSPOSE2x4x4W %1, %2, %3, %4, %9 movq [r0-8], m%1 movq [r0+r1-8], m%2 movq [r0+r1*2-8], m%3 movq [r0+r5-8], m%4 movhps [r4-8], m%1 movhps [r4+r1-8], m%2 movhps [r4+r1*2-8], m%3 movhps [r4+r5-8], m%4 %ifnum %8 SWAP %1, %8 %else mova m%1, %8 %endif TRANSPOSE2x4x4W %5, %6, %7, %1, %9 movq [r0], m%5 movq [r0+r1], m%6 movq [r0+r1*2], m%7 movq [r0+r5], m%1 movhps [r4], m%5 movhps [r4+r1], m%6 movhps [r4+r1*2], m%7 movhps [r4+r5], m%1 %endif %endmacro %if ARCH_X86_64 ;----------------------------------------------------------------------------- ; void deblock_v_luma_intra( uint16_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- %macro DEBLOCK_LUMA_INTRA_64 0 cglobal deblock_v_luma_intra, 4,7,16 %define t0 m1 %define t1 m2 %define t2 m4 %define p2 m8 %define p1 m9 %define p0 m10 %define q0 m11 %define q1 m12 %define q2 m13 %define aa m5 %define bb m14 add r1, r1 lea r4, [r1*4] lea r5, [r1*3] ; 3*stride neg r4 add r4, r0 ; pix-4*stride mov r6, 2 mova m0, [pw_2] LOAD_AB aa, bb, r2d, r3d .loop: mova p2, [r4+r1] mova p1, [r4+2*r1] mova p0, [r4+r5] mova q0, [r0] mova q1, [r0+r1] mova q2, [r0+2*r1] LOAD_MASK p1, p0, q0, q1, aa, bb, m3, t0, t1 mova t2, aa psrlw t2, 2 paddw t2, m0 ; alpha/4+2 DIFF_LT p0, q0, t2, m6, t0 ; m6 = |p0-q0| < alpha/4+2 DIFF_LT p2, p0, bb, t1, t0 ; m7 = |p2-p0| < beta DIFF_LT q2, q0, bb, m7, t0 ; t1 = |q2-q0| < beta pand m6, m3 pand m7, m6 pand m6, t1 LUMA_INTRA_P012 p0, p1, p2, [r4], q0, q1, m3, m6, m0, [r4+r5], [r4+2*r1], [r4+r1] LUMA_INTRA_P012 q0, q1, q2, [r0+r5], p0, p1, m3, m7, m0, [r0], [r0+r1], [r0+2*r1] add r0, mmsize add r4, mmsize dec r6 jg .loop RET ;----------------------------------------------------------------------------- ; void deblock_h_luma_intra( uint16_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_h_luma_intra, 4,7,16 %define t0 m15 %define t1 m14 %define t2 m2 %define q3 m5 %define q2 m8 %define q1 m9 %define q0 m10 %define p0 m11 %define p1 m12 %define p2 m13 %define p3 m4 %define spill [rsp] %assign pad 24-(stack_offset&15) SUB rsp, pad add r1, r1 lea r4, [r1*4] lea r5, [r1*3] ; 3*stride add r4, r0 ; pix+4*stride mov r6, 2 mova m0, [pw_2] .loop: movu q3, [r0-8] movu q2, [r0+r1-8] movu q1, [r0+r1*2-8] movu q0, [r0+r5-8] movu p0, [r4-8] movu p1, [r4+r1-8] movu p2, [r4+r1*2-8] movu p3, [r4+r5-8] TRANSPOSE8x8W 5, 8, 9, 10, 11, 12, 13, 4, 1 LOAD_AB m1, m2, r2d, r3d LOAD_MASK q1, q0, p0, p1, m1, m2, m3, t0, t1 psrlw m1, 2 paddw m1, m0 ; alpha/4+2 DIFF_LT p0, q0, m1, m6, t0 ; m6 = |p0-q0| < alpha/4+2 DIFF_LT q2, q0, m2, t1, t0 ; t1 = |q2-q0| < beta DIFF_LT p0, p2, m2, m7, t0 ; m7 = |p2-p0| < beta pand m6, m3 pand m7, m6 pand m6, t1 mova spill, q3 LUMA_INTRA_P012 q0, q1, q2, q3, p0, p1, m3, m6, m0, m5, m1, q2 LUMA_INTRA_P012 p0, p1, p2, p3, q0, q1, m3, m7, m0, p0, m6, p2 mova m7, spill LUMA_H_INTRA_STORE 7, 8, 1, 5, 11, 6, 13, 4, 14 lea r0, [r0+r1*8] lea r4, [r4+r1*8] dec r6 jg .loop ADD rsp, pad RET %endmacro INIT_XMM sse2 DEBLOCK_LUMA_INTRA_64 INIT_XMM avx DEBLOCK_LUMA_INTRA_64 %endif %macro DEBLOCK_LUMA_INTRA 0 ;----------------------------------------------------------------------------- ; void deblock_v_luma_intra( uint16_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_v_luma_intra, 4,7,8,0-3*mmsize LUMA_INTRA_INIT 3 lea r4, [r1*4] lea r5, [r1*3] neg r4 add r4, r0 mov r6, 32/mmsize .loop: mova m0, [r4+r1*2] ; p1 mova m1, [r4+r5] ; p0 mova m2, [r0] ; q0 mova m3, [r0+r1] ; q1 LUMA_INTRA_INTER t4, t5, t6, [r4+r1], [r0+r1*2] LUMA_INTRA_P012 m1, m0, t3, [r4], m2, m3, t5, t4, [pw_2], [r4+r5], [r4+2*r1], [r4+r1] mova t3, [r0+r1*2] ; q2 LUMA_INTRA_P012 m2, m3, t3, [r0+r5], m1, m0, t5, t6, [pw_2], [r0], [r0+r1], [r0+2*r1] add r0, mmsize add r4, mmsize dec r6 jg .loop RET ;----------------------------------------------------------------------------- ; void deblock_h_luma_intra( uint16_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_h_luma_intra, 4,7,8,0-8*mmsize LUMA_INTRA_INIT 8 %if mmsize == 8 lea r4, [r1*3] mov r5, 32/mmsize %else lea r4, [r1*4] lea r5, [r1*3] ; 3*stride add r4, r0 ; pix+4*stride mov r6, 32/mmsize %endif .loop: LUMA_H_INTRA_LOAD LUMA_INTRA_INTER t8, t9, t10, t5, t6 LUMA_INTRA_P012 m1, m0, t3, t4, m2, m3, t9, t8, [pw_2], t8, t5, t11 mova t3, t6 ; q2 LUMA_INTRA_P012 m2, m3, t3, t7, m1, m0, t9, t10, [pw_2], m4, t6, m5 mova m2, t4 mova m0, t11 mova m1, t5 mova m3, t8 mova m6, t6 LUMA_H_INTRA_STORE 2, 0, 1, 3, 4, 6, 5, t7, 7 lea r0, [r0+r1*(mmsize/2)] %if mmsize == 8 dec r5 %else lea r4, [r4+r1*(mmsize/2)] dec r6 %endif jg .loop RET %endmacro %if ARCH_X86_64 == 0 INIT_MMX mmx2 DEBLOCK_LUMA DEBLOCK_LUMA_INTRA INIT_XMM sse2 DEBLOCK_LUMA DEBLOCK_LUMA_INTRA INIT_XMM avx DEBLOCK_LUMA DEBLOCK_LUMA_INTRA %endif %endif ; HIGH_BIT_DEPTH %if HIGH_BIT_DEPTH == 0 ; expands to [base],...,[base+7*stride] %define PASS8ROWS(base, base3, stride, stride3) \ [base], [base+stride], [base+stride*2], [base3], \ [base3+stride], [base3+stride*2], [base3+stride3], [base3+stride*4] %define PASS8ROWS(base, base3, stride, stride3, offset) \ PASS8ROWS(base+offset, base3+offset, stride, stride3) ; in: 4 rows of 8 bytes in m0..m3 ; out: 8 rows of 4 bytes in %1..%8 %macro TRANSPOSE8x4B_STORE 8 punpckhdq m4, m0, m0 punpckhdq m5, m1, m1 punpckhdq m6, m2, m2 punpcklbw m0, m1 punpcklbw m2, m3 punpcklwd m1, m0, m2 punpckhwd m0, m2 movd %1, m1 punpckhdq m1, m1 movd %2, m1 movd %3, m0 punpckhdq m0, m0 movd %4, m0 punpckhdq m3, m3 punpcklbw m4, m5 punpcklbw m6, m3 punpcklwd m5, m4, m6 punpckhwd m4, m6 movd %5, m5 punpckhdq m5, m5 movd %6, m5 movd %7, m4 punpckhdq m4, m4 movd %8, m4 %endmacro ; in: 8 rows of 4 bytes in %9..%10 ; out: 8 rows of 4 bytes in %1..%8 %macro STORE_8x4B 10 movd %1, %9 pextrd %2, %9, 1 pextrd %3, %9, 2 pextrd %4, %9, 3 movd %5, %10 pextrd %6, %10, 1 pextrd %7, %10, 2 pextrd %8, %10, 3 %endmacro ; in: 4 rows of 4 words in %1..%4 ; out: 4 rows of 4 word in m0..m3 ; clobbers: m4 %macro TRANSPOSE4x4W_LOAD 4-8 %if mmsize==8 SWAP 1, 4, 2, 3 movq m0, %1 movq m1, %2 movq m2, %3 movq m3, %4 TRANSPOSE4x4W 0, 1, 2, 3, 4 %else movq m0, %1 movq m2, %2 movq m1, %3 movq m3, %4 punpcklwd m0, m2 punpcklwd m1, m3 mova m2, m0 punpckldq m0, m1 punpckhdq m2, m1 MOVHL m1, m0 MOVHL m3, m2 %endif %endmacro ; in: 2 rows of 4 words in m1..m2 ; out: 4 rows of 2 words in %1..%4 ; clobbers: m0, m1 %macro TRANSPOSE4x2W_STORE 4-8 %if mmsize==8 punpckhwd m0, m1, m2 punpcklwd m1, m2 %else punpcklwd m1, m2 MOVHL m0, m1 %endif movd %3, m0 movd %1, m1 psrlq m1, 32 psrlq m0, 32 movd %2, m1 movd %4, m0 %endmacro ; in: 4/8 rows of 4 words in %1..%8 ; out: 4 rows of 4/8 word in m0..m3 ; clobbers: m4, m5, m6, m7 %macro TRANSPOSE4x8W_LOAD 8 %if mmsize==8 TRANSPOSE4x4W_LOAD %1, %2, %3, %4 %else movq m0, %1 movq m2, %2 movq m1, %3 movq m3, %4 punpcklwd m0, m2 punpcklwd m1, m3 punpckhdq m2, m0, m1 punpckldq m0, m1 movq m4, %5 movq m6, %6 movq m5, %7 movq m7, %8 punpcklwd m4, m6 punpcklwd m5, m7 punpckhdq m6, m4, m5 punpckldq m4, m5 punpckhqdq m1, m0, m4 punpckhqdq m3, m2, m6 punpcklqdq m0, m4 punpcklqdq m2, m6 %endif %endmacro ; in: 2 rows of 4/8 words in m1..m2 ; out: 4/8 rows of 2 words in %1..%8 ; clobbers: m0, m1 %macro TRANSPOSE8x2W_STORE 8 %if mmsize==8 TRANSPOSE4x2W_STORE %1, %2, %3, %4 %else punpckhwd m0, m1, m2 punpcklwd m1, m2 movd %5, m0 movd %1, m1 psrldq m1, 4 psrldq m0, 4 movd %2, m1 movd %6, m0 psrldq m1, 4 psrldq m0, 4 movd %3, m1 movd %7, m0 psrldq m1, 4 psrldq m0, 4 movd %4, m1 movd %8, m0 %endif %endmacro %macro SBUTTERFLY3 4 punpckh%1 %4, %2, %3 punpckl%1 %2, %3 %endmacro ; in: 8 rows of 8 (only the middle 6 pels are used) in %1..%8 ; out: 6 rows of 8 in [%9+0*16] .. [%9+5*16] %macro TRANSPOSE6x8_MEM 9 RESET_MM_PERMUTATION %if cpuflag(avx) ; input: ; _ABCDEF_ ; _GHIJKL_ ; _MNOPQR_ ; _STUVWX_ ; _YZabcd_ ; _efghij_ ; _klmnop_ ; _qrstuv_ movh m0, %1 movh m2, %2 movh m1, %3 movh m3, %4 punpcklbw m0, m2 ; __ AG BH CI DJ EK FL __ punpcklbw m1, m3 ; __ MS NT OU PV QW RX __ movh m2, %5 movh m3, %6 punpcklbw m2, m3 ; __ Ye Zf ag bh ci dj __ movh m3, %7 movh m4, %8 punpcklbw m3, m4 ; __ kq lr ms nt ou pv __ SBUTTERFLY wd, 0, 1, 4 ; __ __ AG MS BH NT CI OU ; DJ PV EK QW FL RX __ __ SBUTTERFLY wd, 2, 3, 4 ; __ __ Ye kq Zf lr ag ms ; bh nt ci ou dj pv __ __ SBUTTERFLY dq, 0, 2, 4 ; __ __ __ __ AG MS Ye kq ; BH NT Zf lr CI FL OU RX SBUTTERFLY dq, 1, 3, 4 ; DJ PV bh nt EK QW Zf lr ; FL RX dj pv __ __ __ __ movhps [%9+0x00], m0 movh [%9+0x10], m2 movhps [%9+0x20], m2 movh [%9+0x30], m1 movhps [%9+0x40], m1 movh [%9+0x50], m3 %else movq m0, %1 movq m1, %2 movq m2, %3 movq m3, %4 movq m4, %5 movq m5, %6 movq m6, %7 SBUTTERFLY bw, 0, 1, 7 SBUTTERFLY bw, 2, 3, 7 SBUTTERFLY bw, 4, 5, 7 movq [%9+0x10], m3 SBUTTERFLY3 bw, m6, %8, m7 SBUTTERFLY wd, 0, 2, 3 SBUTTERFLY wd, 4, 6, 3 punpckhdq m0, m4 movq [%9+0x00], m0 SBUTTERFLY3 wd, m1, [%9+0x10], m3 SBUTTERFLY wd, 5, 7, 0 SBUTTERFLY dq, 1, 5, 0 SBUTTERFLY dq, 2, 6, 0 punpckldq m3, m7 movq [%9+0x10], m2 movq [%9+0x20], m6 movq [%9+0x30], m1 movq [%9+0x40], m5 movq [%9+0x50], m3 %endif RESET_MM_PERMUTATION %endmacro ; in: 8 rows of 8 in %1..%8 ; out: 8 rows of 8 in %9..%16 %macro TRANSPOSE8x8_MEM 16 RESET_MM_PERMUTATION %if cpuflag(avx) movh m0, %1 movh m4, %2 movh m1, %3 movh m5, %4 movh m2, %5 movh m3, %7 punpcklbw m0, m4 punpcklbw m1, m5 movh m4, %6 movh m5, %8 punpcklbw m2, m4 punpcklbw m3, m5 SBUTTERFLY wd, 0, 1, 4 SBUTTERFLY wd, 2, 3, 4 SBUTTERFLY dq, 0, 2, 4 SBUTTERFLY dq, 1, 3, 4 movh %9, m0 movhps %10, m0 movh %11, m2 movhps %12, m2 movh %13, m1 movhps %14, m1 movh %15, m3 movhps %16, m3 %else movq m0, %1 movq m1, %2 movq m2, %3 movq m3, %4 movq m4, %5 movq m5, %6 movq m6, %7 SBUTTERFLY bw, 0, 1, 7 SBUTTERFLY bw, 2, 3, 7 SBUTTERFLY bw, 4, 5, 7 SBUTTERFLY3 bw, m6, %8, m7 movq %9, m5 SBUTTERFLY wd, 0, 2, 5 SBUTTERFLY wd, 4, 6, 5 SBUTTERFLY wd, 1, 3, 5 movq %11, m6 movq m6, %9 SBUTTERFLY wd, 6, 7, 5 SBUTTERFLY dq, 0, 4, 5 SBUTTERFLY dq, 1, 6, 5 movq %9, m0 movq %10, m4 movq %13, m1 movq %14, m6 SBUTTERFLY3 dq, m2, %11, m0 SBUTTERFLY dq, 3, 7, 4 movq %11, m2 movq %12, m0 movq %15, m3 movq %16, m7 %endif RESET_MM_PERMUTATION %endmacro ; out: %4 = |%1-%2|>%3 ; clobbers: %5 %macro DIFF_GT 5 %if avx_enabled == 0 mova %5, %2 mova %4, %1 psubusb %5, %1 psubusb %4, %2 %else psubusb %5, %2, %1 psubusb %4, %1, %2 %endif por %4, %5 psubusb %4, %3 %endmacro ; out: %4 = |%1-%2|>%3 ; clobbers: %5 %macro DIFF_GT2 5-6 %if %0<6 psubusb %4, %1, %2 psubusb %5, %2, %1 %else mova %4, %1 mova %5, %2 psubusb %4, %2 psubusb %5, %1 %endif psubusb %5, %3 psubusb %4, %3 pcmpeqb %4, %5 %endmacro ; in: m0=p1 m1=p0 m2=q0 m3=q1 %1=alpha %2=beta ; out: m5=beta-1, m7=mask, %3=alpha-1 ; clobbers: m4,m6 %macro LOAD_MASK 2-3 %if cpuflag(ssse3) movd m4, %1 movd m5, %2 pxor m6, m6 pshufb m4, m6 pshufb m5, m6 %else movd m4, %1 movd m5, %2 punpcklbw m4, m4 punpcklbw m5, m5 SPLATW m4, m4 SPLATW m5, m5 %endif mova m6, [pb_1] psubusb m4, m6 ; alpha - 1 psubusb m5, m6 ; beta - 1 %if %0>2 mova %3, m4 %endif DIFF_GT m1, m2, m4, m7, m6 ; |p0-q0| > alpha-1 DIFF_GT m0, m1, m5, m4, m6 ; |p1-p0| > beta-1 por m7, m4 DIFF_GT m3, m2, m5, m4, m6 ; |q1-q0| > beta-1 por m7, m4 pxor m6, m6 pcmpeqb m7, m6 %endmacro ; in: m0=p1 m1=p0 m2=q0 m3=q1 m7=(tc&mask) ; out: m1=p0' m2=q0' ; clobbers: m0,3-6 %macro DEBLOCK_P0_Q0 0 pxor m5, m1, m2 ; p0^q0 pand m5, [pb_1] ; (p0^q0)&1 pcmpeqb m4, m4 pxor m3, m4 pavgb m3, m0 ; (p1 - q1 + 256)>>1 pavgb m3, [pb_3] ; (((p1 - q1 + 256)>>1)+4)>>1 = 64+2+(p1-q1)>>2 pxor m4, m1 pavgb m4, m2 ; (q0 - p0 + 256)>>1 pavgb m3, m5 paddusb m3, m4 ; d+128+33 mova m6, [pb_a1] psubusb m6, m3 psubusb m3, [pb_a1] pminub m6, m7 pminub m3, m7 psubusb m1, m6 psubusb m2, m3 paddusb m1, m3 paddusb m2, m6 %endmacro ; in: m1=p0 m2=q0 ; %1=p1 %2=q2 %3=[q2] %4=[q1] %5=tc0 %6=tmp ; out: [q1] = clip( (q2+((p0+q0+1)>>1))>>1, q1-tc0, q1+tc0 ) ; clobbers: q2, tmp, tc0 %macro LUMA_Q1 6 pavgb %6, m1, m2 pavgb %2, %6 ; avg(p2,avg(p0,q0)) pxor %6, %3 pand %6, [pb_1] ; (p2^avg(p0,q0))&1 psubusb %2, %6 ; (p2+((p0+q0+1)>>1))>>1 psubusb %6, %1, %5 paddusb %5, %1 pmaxub %2, %6 pminub %2, %5 mova %4, %2 %endmacro %if ARCH_X86_64 ;----------------------------------------------------------------------------- ; void deblock_v_luma( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- %macro DEBLOCK_LUMA 0 cglobal deblock_v_luma, 5,5,10 movd m8, [r4] ; tc0 lea r4, [r1*3] neg r4 add r4, r0 ; pix-3*stride mova m0, [r4+r1] ; p1 mova m1, [r4+2*r1] ; p0 mova m2, [r0] ; q0 mova m3, [r0+r1] ; q1 LOAD_MASK r2d, r3d %if cpuflag(avx) pshufb m8, [pb_unpackbd1] pblendvb m9, m7, m6, m8 %else punpcklbw m8, m8 punpcklbw m8, m8 ; tc = 4x tc0[3], 4x tc0[2], 4x tc0[1], 4x tc0[0] pcmpeqb m9, m9 pcmpeqb m9, m8 pandn m9, m7 %endif pand m8, m9 mova m3, [r4] ; p2 DIFF_GT2 m1, m3, m5, m6, m7 ; |p2-p0| > beta-1 pand m6, m9 psubb m7, m8, m6 ; tc++ pand m6, m8 LUMA_Q1 m0, m3, [r4], [r4+r1], m6, m4 mova m4, [r0+2*r1] ; q2 DIFF_GT2 m2, m4, m5, m6, m3 ; |q2-q0| > beta-1 pand m6, m9 pand m8, m6 psubb m7, m6 mova m3, [r0+r1] LUMA_Q1 m3, m4, [r0+2*r1], [r0+r1], m8, m6 DEBLOCK_P0_Q0 mova [r4+2*r1], m1 mova [r0], m2 RET ;----------------------------------------------------------------------------- ; void deblock_h_luma( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- %if cpuflag(avx) INIT_XMM cpuname %else INIT_MMX cpuname %endif cglobal deblock_h_luma, 5,9,0,0x60+16*WIN64 lea r8, [r1*3] lea r6, [r0-4] lea r5, [r0-4+r8] %xdefine pix_tmp rsp+0x30*WIN64 ; shadow space + r4 ; transpose 6x16 -> tmp space TRANSPOSE6x8_MEM PASS8ROWS(r6, r5, r1, r8), pix_tmp lea r6, [r6+r1*8] lea r5, [r5+r1*8] TRANSPOSE6x8_MEM PASS8ROWS(r6, r5, r1, r8), pix_tmp+8 ; vertical filter ; alpha, beta, tc0 are still in r2d, r3d, r4 ; don't backup r6, r5, r7, r8 because deblock_v_luma_sse2 doesn't use them mov r7, r1 lea r0, [pix_tmp+0x30] mov r1d, 0x10 %if WIN64 mov [rsp+0x20], r4 %endif call deblock_v_luma ; transpose 16x4 -> original space (only the middle 4 rows were changed by the filter) add r6, 2 add r5, 2 %if cpuflag(sse4) mova m0, [pix_tmp+0x10] mova m1, [pix_tmp+0x20] mova m2, [pix_tmp+0x30] mova m3, [pix_tmp+0x40] SBUTTERFLY bw, 0, 1, 4 SBUTTERFLY bw, 2, 3, 4 SBUTTERFLY wd, 0, 2, 4 SBUTTERFLY wd, 1, 3, 4 STORE_8x4B PASS8ROWS(r6, r5, r7, r8), m1, m3 shl r7, 3 sub r6, r7 sub r5, r7 shr r7, 3 STORE_8x4B PASS8ROWS(r6, r5, r7, r8), m0, m2 %else movq m0, [pix_tmp+0x18] movq m1, [pix_tmp+0x28] movq m2, [pix_tmp+0x38] movq m3, [pix_tmp+0x48] TRANSPOSE8x4B_STORE PASS8ROWS(r6, r5, r7, r8) shl r7, 3 sub r6, r7 sub r5, r7 shr r7, 3 movq m0, [pix_tmp+0x10] movq m1, [pix_tmp+0x20] movq m2, [pix_tmp+0x30] movq m3, [pix_tmp+0x40] TRANSPOSE8x4B_STORE PASS8ROWS(r6, r5, r7, r8) %endif RET %endmacro INIT_XMM sse2 DEBLOCK_LUMA INIT_XMM avx DEBLOCK_LUMA %else %macro DEBLOCK_LUMA 2 ;----------------------------------------------------------------------------- ; void deblock_v8_luma( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- cglobal deblock_%1_luma, 5,5,8,2*%2 lea r4, [r1*3] neg r4 add r4, r0 ; pix-3*stride mova m0, [r4+r1] ; p1 mova m1, [r4+2*r1] ; p0 mova m2, [r0] ; q0 mova m3, [r0+r1] ; q1 LOAD_MASK r2d, r3d mov r3, r4mp movd m4, [r3] ; tc0 %if cpuflag(avx) pshufb m4, [pb_unpackbd1] mova [esp+%2], m4 ; tc pblendvb m4, m7, m6, m4 %else punpcklbw m4, m4 punpcklbw m4, m4 ; tc = 4x tc0[3], 4x tc0[2], 4x tc0[1], 4x tc0[0] mova [esp+%2], m4 ; tc pcmpeqb m3, m3 pcmpgtb m4, m3 pand m4, m7 %endif mova [esp], m4 ; mask mova m3, [r4] ; p2 DIFF_GT2 m1, m3, m5, m6, m7 ; |p2-p0| > beta-1 pand m6, m4 pand m4, [esp+%2] ; tc psubb m7, m4, m6 pand m6, m4 LUMA_Q1 m0, m3, [r4], [r4+r1], m6, m4 mova m4, [r0+2*r1] ; q2 DIFF_GT2 m2, m4, m5, m6, m3 ; |q2-q0| > beta-1 mova m5, [esp] ; mask pand m6, m5 mova m5, [esp+%2] ; tc pand m5, m6 psubb m7, m6 mova m3, [r0+r1] LUMA_Q1 m3, m4, [r0+2*r1], [r0+r1], m5, m6 DEBLOCK_P0_Q0 mova [r4+2*r1], m1 mova [r0], m2 RET ;----------------------------------------------------------------------------- ; void deblock_h_luma( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- %if cpuflag(avx) INIT_XMM cpuname %else INIT_MMX cpuname %endif cglobal deblock_h_luma, 1,5,8,0x60+12 mov r3, r1m lea r4, [r3*3] sub r0, 4 lea r1, [r0+r4] %define pix_tmp esp+12 ; esp is intentionally misaligned to make it aligned after pushing the arguments for deblock_%1_luma. ; transpose 6x16 -> tmp space TRANSPOSE6x8_MEM PASS8ROWS(r0, r1, r3, r4), pix_tmp lea r0, [r0+r3*8] lea r1, [r1+r3*8] TRANSPOSE6x8_MEM PASS8ROWS(r0, r1, r3, r4), pix_tmp+8 ; vertical filter lea r0, [pix_tmp+0x30] PUSH dword r4m PUSH dword r3m PUSH dword r2m PUSH dword 16 PUSH dword r0 call deblock_%1_luma %ifidn %1, v8 add dword [esp ], 8 ; pix_tmp+0x38 add dword [esp+16], 2 ; tc0+2 call deblock_%1_luma %endif ADD esp, 20 ; transpose 16x4 -> original space (only the middle 4 rows were changed by the filter) mov r0, r0mp sub r0, 2 lea r1, [r0+r4] %if cpuflag(avx) mova m0, [pix_tmp+0x10] mova m1, [pix_tmp+0x20] mova m2, [pix_tmp+0x30] mova m3, [pix_tmp+0x40] SBUTTERFLY bw, 0, 1, 4 SBUTTERFLY bw, 2, 3, 4 SBUTTERFLY wd, 0, 2, 4 SBUTTERFLY wd, 1, 3, 4 STORE_8x4B PASS8ROWS(r0, r1, r3, r4), m0, m2 lea r0, [r0+r3*8] lea r1, [r1+r3*8] STORE_8x4B PASS8ROWS(r0, r1, r3, r4), m1, m3 %else movq m0, [pix_tmp+0x10] movq m1, [pix_tmp+0x20] movq m2, [pix_tmp+0x30] movq m3, [pix_tmp+0x40] TRANSPOSE8x4B_STORE PASS8ROWS(r0, r1, r3, r4) lea r0, [r0+r3*8] lea r1, [r1+r3*8] movq m0, [pix_tmp+0x18] movq m1, [pix_tmp+0x28] movq m2, [pix_tmp+0x38] movq m3, [pix_tmp+0x48] TRANSPOSE8x4B_STORE PASS8ROWS(r0, r1, r3, r4) %endif RET %endmacro ; DEBLOCK_LUMA INIT_MMX mmx2 DEBLOCK_LUMA v8, 8 INIT_XMM sse2 DEBLOCK_LUMA v, 16 INIT_XMM avx DEBLOCK_LUMA v, 16 %endif ; ARCH %macro LUMA_INTRA_P012 4 ; p0..p3 in memory %if ARCH_X86_64 pavgb t0, p2, p1 pavgb t1, p0, q0 %else mova t0, p2 mova t1, p0 pavgb t0, p1 pavgb t1, q0 %endif pavgb t0, t1 ; ((p2+p1+1)/2 + (p0+q0+1)/2 + 1)/2 mova t5, t1 %if ARCH_X86_64 paddb t2, p2, p1 paddb t3, p0, q0 %else mova t2, p2 mova t3, p0 paddb t2, p1 paddb t3, q0 %endif paddb t2, t3 mova t3, t2 mova t4, t2 psrlw t2, 1 pavgb t2, mpb_0 pxor t2, t0 pand t2, mpb_1 psubb t0, t2 ; p1' = (p2+p1+p0+q0+2)/4; %if ARCH_X86_64 pavgb t1, p2, q1 psubb t2, p2, q1 %else mova t1, p2 mova t2, p2 pavgb t1, q1 psubb t2, q1 %endif paddb t3, t3 psubb t3, t2 ; p2+2*p1+2*p0+2*q0+q1 pand t2, mpb_1 psubb t1, t2 pavgb t1, p1 pavgb t1, t5 ; (((p2+q1)/2 + p1+1)/2 + (p0+q0+1)/2 + 1)/2 psrlw t3, 2 pavgb t3, mpb_0 pxor t3, t1 pand t3, mpb_1 psubb t1, t3 ; p0'a = (p2+2*p1+2*p0+2*q0+q1+4)/8 pxor t3, p0, q1 pavgb t2, p0, q1 pand t3, mpb_1 psubb t2, t3 pavgb t2, p1 ; p0'b = (2*p1+p0+q0+2)/4 pxor t1, t2 pxor t2, p0 pand t1, mask1p pand t2, mask0 pxor t1, t2 pxor t1, p0 mova %1, t1 ; store p0 mova t1, %4 ; p3 paddb t2, t1, p2 pavgb t1, p2 pavgb t1, t0 ; (p3+p2+1)/2 + (p2+p1+p0+q0+2)/4 paddb t2, t2 paddb t2, t4 ; 2*p3+3*p2+p1+p0+q0 psrlw t2, 2 pavgb t2, mpb_0 pxor t2, t1 pand t2, mpb_1 psubb t1, t2 ; p2' = (2*p3+3*p2+p1+p0+q0+4)/8 pxor t0, p1 pxor t1, p2 pand t0, mask1p pand t1, mask1p pxor t0, p1 pxor t1, p2 mova %2, t0 ; store p1 mova %3, t1 ; store p2 %endmacro %macro LUMA_INTRA_SWAP_PQ 0 %define q1 m0 %define q0 m1 %define p0 m2 %define p1 m3 %define p2 q2 %define mask1p mask1q %endmacro %macro DEBLOCK_LUMA_INTRA 1 %define p1 m0 %define p0 m1 %define q0 m2 %define q1 m3 %define t0 m4 %define t1 m5 %define t2 m6 %define t3 m7 %if ARCH_X86_64 %define p2 m8 %define q2 m9 %define t4 m10 %define t5 m11 %define mask0 m12 %define mask1p m13 %if WIN64 %define mask1q [rsp] %else %define mask1q [rsp-24] %endif %define mpb_0 m14 %define mpb_1 m15 %else %define spill(x) [esp+16*x] %define p2 [r4+r1] %define q2 [r0+2*r1] %define t4 spill(0) %define t5 spill(1) %define mask0 spill(2) %define mask1p spill(3) %define mask1q spill(4) %define mpb_0 [pb_0] %define mpb_1 [pb_1] %endif ;----------------------------------------------------------------------------- ; void deblock_v_luma_intra( uint8_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_%1_luma_intra, 4,6,16,0-(1-ARCH_X86_64)*0x50-WIN64*0x10 lea r4, [r1*4] lea r5, [r1*3] ; 3*stride neg r4 add r4, r0 ; pix-4*stride mova p1, [r4+2*r1] mova p0, [r4+r5] mova q0, [r0] mova q1, [r0+r1] %if ARCH_X86_64 pxor mpb_0, mpb_0 mova mpb_1, [pb_1] LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0 SWAP 7, 12 ; m12=mask0 pavgb t5, mpb_0 pavgb t5, mpb_1 ; alpha/4+1 movdqa p2, [r4+r1] movdqa q2, [r0+2*r1] DIFF_GT2 p0, q0, t5, t0, t3 ; t0 = |p0-q0| > alpha/4+1 DIFF_GT2 p0, p2, m5, t2, t5, 1 ; mask1 = |p2-p0| > beta-1 DIFF_GT2 q0, q2, m5, t4, t5, 1 ; t4 = |q2-q0| > beta-1 pand t0, mask0 pand t4, t0 pand t2, t0 mova mask1q, t4 mova mask1p, t2 %else LOAD_MASK r2d, r3d, t5 ; m5=beta-1, t5=alpha-1, m7=mask0 mova m4, t5 mova mask0, m7 pavgb m4, [pb_0] pavgb m4, [pb_1] ; alpha/4+1 DIFF_GT2 p0, q0, m4, m6, m7 ; m6 = |p0-q0| > alpha/4+1 pand m6, mask0 DIFF_GT2 p0, p2, m5, m4, m7, 1 ; m4 = |p2-p0| > beta-1 pand m4, m6 mova mask1p, m4 DIFF_GT2 q0, q2, m5, m4, m7, 1 ; m4 = |q2-q0| > beta-1 pand m4, m6 mova mask1q, m4 %endif LUMA_INTRA_P012 [r4+r5], [r4+2*r1], [r4+r1], [r4] LUMA_INTRA_SWAP_PQ LUMA_INTRA_P012 [r0], [r0+r1], [r0+2*r1], [r0+r5] .end: REP_RET %if cpuflag(avx) INIT_XMM cpuname %else INIT_MMX cpuname %endif %if ARCH_X86_64 ;----------------------------------------------------------------------------- ; void deblock_h_luma_intra( uint8_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_h_luma_intra, 4,9,0,0x80 lea r8, [r1*3] lea r6, [r0-4] lea r5, [r0-4+r8] %if WIN64 %define pix_tmp rsp+0x20 ; shadow space %else %define pix_tmp rsp %endif ; transpose 8x16 -> tmp space TRANSPOSE8x8_MEM PASS8ROWS(r6, r5, r1, r8), PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30) lea r6, [r6+r1*8] lea r5, [r5+r1*8] TRANSPOSE8x8_MEM PASS8ROWS(r6, r5, r1, r8), PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30) mov r7, r1 lea r0, [pix_tmp+0x40] mov r1, 0x10 call deblock_v_luma_intra ; transpose 16x6 -> original space (but we can't write only 6 pixels, so really 16x8) lea r5, [r6+r8] TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30), PASS8ROWS(r6, r5, r7, r8) shl r7, 3 sub r6, r7 sub r5, r7 shr r7, 3 TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30), PASS8ROWS(r6, r5, r7, r8) RET %else cglobal deblock_h_luma_intra, 2,4,8,0x80 lea r3, [r1*3] sub r0, 4 lea r2, [r0+r3] %define pix_tmp rsp ; transpose 8x16 -> tmp space TRANSPOSE8x8_MEM PASS8ROWS(r0, r2, r1, r3), PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30) lea r0, [r0+r1*8] lea r2, [r2+r1*8] TRANSPOSE8x8_MEM PASS8ROWS(r0, r2, r1, r3), PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30) lea r0, [pix_tmp+0x40] PUSH dword r3m PUSH dword r2m PUSH dword 16 PUSH r0 call deblock_%1_luma_intra %ifidn %1, v8 add dword [rsp], 8 ; pix_tmp+8 call deblock_%1_luma_intra %endif ADD esp, 16 mov r1, r1m mov r0, r0mp lea r3, [r1*3] sub r0, 4 lea r2, [r0+r3] ; transpose 16x6 -> original space (but we can't write only 6 pixels, so really 16x8) TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp, pix_tmp+0x30, 0x10, 0x30), PASS8ROWS(r0, r2, r1, r3) lea r0, [r0+r1*8] lea r2, [r2+r1*8] TRANSPOSE8x8_MEM PASS8ROWS(pix_tmp+8, pix_tmp+0x38, 0x10, 0x30), PASS8ROWS(r0, r2, r1, r3) RET %endif ; ARCH_X86_64 %endmacro ; DEBLOCK_LUMA_INTRA INIT_XMM sse2 DEBLOCK_LUMA_INTRA v INIT_XMM avx DEBLOCK_LUMA_INTRA v %if ARCH_X86_64 == 0 INIT_MMX mmx2 DEBLOCK_LUMA_INTRA v8 %endif %endif ; !HIGH_BIT_DEPTH %if HIGH_BIT_DEPTH ; in: %1=p0, %2=q0, %3=p1, %4=q1, %5=mask, %6=tmp, %7=tmp ; out: %1=p0', %2=q0' %macro CHROMA_DEBLOCK_P0_Q0_INTRA 7 mova %6, [pw_2] paddw %6, %3 paddw %6, %4 paddw %7, %6, %2 paddw %6, %1 paddw %6, %3 paddw %7, %4 psraw %6, 2 psraw %7, 2 psubw %6, %1 psubw %7, %2 pand %6, %5 pand %7, %5 paddw %1, %6 paddw %2, %7 %endmacro ; out: m0-m3 ; clobbers: m4-m7 %macro CHROMA_H_LOAD 0-1 movq m0, [r0-8] ; p1 p1 p0 p0 movq m2, [r0] ; q0 q0 q1 q1 movq m5, [r0+r1-8] movq m7, [r0+r1] %if mmsize == 8 mova m1, m0 mova m3, m2 punpckldq m0, m5 ; p1 punpckhdq m1, m5 ; p0 punpckldq m2, m7 ; q0 punpckhdq m3, m7 ; q1 %else movq m4, [r0+r1*2-8] movq m6, [r0+r1*2] movq m1, [r0+%1-8] movq m3, [r0+%1] punpckldq m0, m5 ; p1 ... p0 ... punpckldq m2, m7 ; q0 ... q1 ... punpckldq m4, m1 punpckldq m6, m3 punpckhqdq m1, m0, m4 ; p0 punpcklqdq m0, m4 ; p1 punpckhqdq m3, m2, m6 ; q1 punpcklqdq m2, m6 ; q0 %endif %endmacro %macro CHROMA_V_LOAD 1 mova m0, [r0] ; p1 mova m1, [r0+r1] ; p0 mova m2, [%1] ; q0 mova m3, [%1+r1] ; q1 %endmacro ; clobbers: m1, m2, m3 %macro CHROMA_H_STORE 0-1 SBUTTERFLY dq, 1, 2, 3 %if mmsize == 8 movq [r0-4], m1 movq [r0+r1-4], m2 %else movq [r0-4], m1 movq [r0+r1*2-4], m2 movhps [r0+r1-4], m1 movhps [r0+%1-4], m2 %endif %endmacro %macro CHROMA_V_STORE 0 mova [r0+1*r1], m1 mova [r0+2*r1], m2 %endmacro %macro DEBLOCK_CHROMA 0 cglobal deblock_inter_body LOAD_AB m4, m5, r2d, r3d LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4 pxor m4, m4 LOAD_TC m6, r4 pmaxsw m6, m4 pand m7, m6 DEBLOCK_P0_Q0 m1, m2, m0, m3, m7, m5, m6 ret ;----------------------------------------------------------------------------- ; void deblock_v_chroma( uint16_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- cglobal deblock_v_chroma, 5,7,8 FIX_STRIDES r1 mov r5, r0 sub r0, r1 sub r0, r1 mov r6, 32/mmsize .loop: CHROMA_V_LOAD r5 call deblock_inter_body CHROMA_V_STORE add r0, mmsize add r5, mmsize add r4, mmsize/8 dec r6 jg .loop RET ;----------------------------------------------------------------------------- ; void deblock_h_chroma( uint16_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma, 5,7,8 add r1, r1 mov r5, 32/mmsize %if mmsize == 16 lea r6, [r1*3] %endif .loop: CHROMA_H_LOAD r6 call deblock_inter_body CHROMA_H_STORE r6 lea r0, [r0+r1*(mmsize/4)] add r4, mmsize/8 dec r5 jg .loop RET cglobal deblock_intra_body LOAD_AB m4, m5, r2d, r3d LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4 CHROMA_DEBLOCK_P0_Q0_INTRA m1, m2, m0, m3, m7, m5, m6 ret ;----------------------------------------------------------------------------- ; void deblock_v_chroma_intra( uint16_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_v_chroma_intra, 4,6,8 add r1, r1 mov r5, 32/mmsize movd m5, r3d mov r4, r0 sub r0, r1 sub r0, r1 SPLATW m5, m5 .loop: CHROMA_V_LOAD r4 call deblock_intra_body CHROMA_V_STORE add r0, mmsize add r4, mmsize dec r5 jg .loop RET ;----------------------------------------------------------------------------- ; void deblock_h_chroma_intra( uint16_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma_intra, 4,6,8 add r1, r1 mov r4, 32/mmsize %if mmsize == 16 lea r5, [r1*3] %endif .loop: CHROMA_H_LOAD r5 call deblock_intra_body CHROMA_H_STORE r5 lea r0, [r0+r1*(mmsize/4)] dec r4 jg .loop RET ;----------------------------------------------------------------------------- ; void deblock_h_chroma_intra_mbaff( uint16_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma_intra_mbaff, 4,6,8 add r1, r1 %if mmsize == 8 mov r4, 16/mmsize .loop: %else lea r5, [r1*3] %endif CHROMA_H_LOAD r5 LOAD_AB m4, m5, r2d, r3d LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4 CHROMA_DEBLOCK_P0_Q0_INTRA m1, m2, m0, m3, m7, m5, m6 CHROMA_H_STORE r5 %if mmsize == 8 lea r0, [r0+r1*(mmsize/4)] dec r4 jg .loop %endif RET ;----------------------------------------------------------------------------- ; void deblock_h_chroma_mbaff( uint16_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma_mbaff, 5,7,8 add r1, r1 lea r6, [r1*3] %if mmsize == 8 mov r5, 16/mmsize .loop: %endif CHROMA_H_LOAD r6 LOAD_AB m4, m5, r2d, r3d LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4 movd m6, [r4] punpcklbw m6, m6 psraw m6, 8 punpcklwd m6, m6 pand m7, m6 DEBLOCK_P0_Q0 m1, m2, m0, m3, m7, m5, m6 CHROMA_H_STORE r6 %if mmsize == 8 lea r0, [r0+r1*(mmsize/4)] add r4, mmsize/4 dec r5 jg .loop %endif RET ;----------------------------------------------------------------------------- ; void deblock_h_chroma_422_intra( uint16_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma_422_intra, 4,6,8 add r1, r1 mov r4, 64/mmsize %if mmsize == 16 lea r5, [r1*3] %endif .loop: CHROMA_H_LOAD r5 call deblock_intra_body CHROMA_H_STORE r5 lea r0, [r0+r1*(mmsize/4)] dec r4 jg .loop RET ;----------------------------------------------------------------------------- ; void deblock_h_chroma_422( uint16_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma_422, 5,7,8 add r1, r1 mov r5, 64/mmsize lea r6, [r1*3] .loop: CHROMA_H_LOAD r6 LOAD_AB m4, m5, r2m, r3d LOAD_MASK m0, m1, m2, m3, m4, m5, m7, m6, m4 pxor m4, m4 movd m6, [r4-1] psraw m6, 8 SPLATW m6, m6 pmaxsw m6, m4 pand m7, m6 DEBLOCK_P0_Q0 m1, m2, m0, m3, m7, m5, m6 CHROMA_H_STORE r6 lea r0, [r0+r1*(mmsize/4)] %if mmsize == 16 inc r4 %else mov r2, r5 and r2, 1 add r4, r2 ; increment once every 2 iterations %endif dec r5 jg .loop RET %endmacro ; DEBLOCK_CHROMA %if ARCH_X86_64 == 0 INIT_MMX mmx2 DEBLOCK_CHROMA %endif INIT_XMM sse2 DEBLOCK_CHROMA INIT_XMM avx DEBLOCK_CHROMA %endif ; HIGH_BIT_DEPTH %if HIGH_BIT_DEPTH == 0 %macro CHROMA_V_START 0 mov t5, r0 sub t5, r1 sub t5, r1 %if mmsize==8 mov dword r0m, 2 .loop: %endif %endmacro %macro CHROMA_H_START 0 sub r0, 4 lea t6, [r1*3] mov t5, r0 add r0, t6 %endmacro %macro CHROMA_V_LOOP 1 %if mmsize==8 add r0, 8 add t5, 8 %if %1 add r4, 2 %endif dec dword r0m jg .loop %endif %endmacro %macro CHROMA_H_LOOP 1 %if mmsize==8 lea r0, [r0+r1*4] lea t5, [t5+r1*4] %if %1 add r4, 2 %endif dec dword r0m jg .loop %endif %endmacro %define t5 r5 %define t6 r6 %macro DEBLOCK_CHROMA 0 cglobal chroma_inter_body LOAD_MASK r2d, r3d movd m6, [r4] ; tc0 punpcklbw m6, m6 punpcklbw m6, m6 pand m7, m6 DEBLOCK_P0_Q0 ret ;----------------------------------------------------------------------------- ; void deblock_v_chroma( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- cglobal deblock_v_chroma, 5,6,8 CHROMA_V_START mova m0, [t5] mova m1, [t5+r1] mova m2, [r0] mova m3, [r0+r1] call chroma_inter_body mova [t5+r1], m1 mova [r0], m2 CHROMA_V_LOOP 1 RET ;----------------------------------------------------------------------------- ; void deblock_h_chroma( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma, 5,7,8 CHROMA_H_START %if mmsize==8 mov dword r0m, 2 .loop: %endif TRANSPOSE4x8W_LOAD PASS8ROWS(t5, r0, r1, t6) call chroma_inter_body TRANSPOSE8x2W_STORE PASS8ROWS(t5, r0, r1, t6, 2) CHROMA_H_LOOP 1 RET %endmacro ; DEBLOCK_CHROMA INIT_XMM sse2 DEBLOCK_CHROMA INIT_XMM avx DEBLOCK_CHROMA %if ARCH_X86_64 == 0 INIT_MMX mmx2 DEBLOCK_CHROMA %endif ;----------------------------------------------------------------------------- ; void deblock_h_chroma_mbaff( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 ) ;----------------------------------------------------------------------------- %macro DEBLOCK_H_CHROMA_420_MBAFF 0 cglobal deblock_h_chroma_mbaff, 5,7,8 CHROMA_H_START TRANSPOSE4x4W_LOAD PASS8ROWS(t5, r0, r1, t6) LOAD_MASK r2d, r3d movd m6, [r4] ; tc0 punpcklbw m6, m6 pand m7, m6 DEBLOCK_P0_Q0 TRANSPOSE4x2W_STORE PASS8ROWS(t5, r0, r1, t6, 2) RET %endmacro INIT_XMM sse2 DEBLOCK_H_CHROMA_420_MBAFF %if ARCH_X86_64 == 0 INIT_MMX mmx2 DEBLOCK_H_CHROMA_420_MBAFF %endif %macro DEBLOCK_H_CHROMA_422 0 cglobal deblock_h_chroma_422, 5,8,8 %if ARCH_X86_64 %define cntr r7 %else %define cntr dword r0m %endif CHROMA_H_START mov cntr, 32/mmsize .loop: TRANSPOSE4x8W_LOAD PASS8ROWS(t5, r0, r1, t6) LOAD_MASK r2d, r3d movd m6, [r4] ; tc0 punpcklbw m6, m6 %if mmsize == 16 punpcklbw m6, m6 punpcklbw m6, m6 %else pshufw m6, m6, q0000 %endif pand m7, m6 DEBLOCK_P0_Q0 TRANSPOSE8x2W_STORE PASS8ROWS(t5, r0, r1, t6, 2) lea r0, [r0+r1*(mmsize/2)] lea t5, [t5+r1*(mmsize/2)] add r4, mmsize/8 dec cntr jg .loop RET %endmacro INIT_MMX mmx2 DEBLOCK_H_CHROMA_422 INIT_XMM sse2 DEBLOCK_H_CHROMA_422 INIT_XMM avx DEBLOCK_H_CHROMA_422 ; in: %1=p0 %2=p1 %3=q1 ; out: p0 = (p0 + q1 + 2*p1 + 2) >> 2 %macro CHROMA_INTRA_P0 3 pxor m4, %1, %3 pand m4, [pb_1] ; m4 = (p0^q1)&1 pavgb %1, %3 psubusb %1, m4 pavgb %1, %2 ; dst = avg(p1, avg(p0,q1) - ((p0^q1)&1)) %endmacro %define t5 r4 %define t6 r5 %macro DEBLOCK_CHROMA_INTRA_BODY 0 cglobal chroma_intra_body LOAD_MASK r2d, r3d mova m5, m1 mova m6, m2 CHROMA_INTRA_P0 m1, m0, m3 CHROMA_INTRA_P0 m2, m3, m0 psubb m1, m5 psubb m2, m6 pand m1, m7 pand m2, m7 paddb m1, m5 paddb m2, m6 ret %endmacro %macro DEBLOCK_CHROMA_INTRA 0 ;----------------------------------------------------------------------------- ; void deblock_v_chroma_intra( uint8_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_v_chroma_intra, 4,5,8 CHROMA_V_START mova m0, [t5] mova m1, [t5+r1] mova m2, [r0] mova m3, [r0+r1] call chroma_intra_body mova [t5+r1], m1 mova [r0], m2 CHROMA_V_LOOP 0 RET ;----------------------------------------------------------------------------- ; void deblock_h_chroma_intra( uint8_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- cglobal deblock_h_chroma_intra, 4,6,8 CHROMA_H_START %if mmsize==8 mov dword r0m, 2 .loop: %endif TRANSPOSE4x8W_LOAD PASS8ROWS(t5, r0, r1, t6) call chroma_intra_body TRANSPOSE8x2W_STORE PASS8ROWS(t5, r0, r1, t6, 2) CHROMA_H_LOOP 0 RET cglobal deblock_h_chroma_422_intra, 4,7,8 CHROMA_H_START mov r6d, 32/mmsize .loop: TRANSPOSE4x8W_LOAD PASS8ROWS(t5, r0, r1, t6) call chroma_intra_body TRANSPOSE8x2W_STORE PASS8ROWS(t5, r0, r1, t6, 2) lea r0, [r0+r1*(mmsize/2)] lea t5, [t5+r1*(mmsize/2)] dec r6d jg .loop RET %endmacro ; DEBLOCK_CHROMA_INTRA INIT_XMM sse2 DEBLOCK_CHROMA_INTRA_BODY DEBLOCK_CHROMA_INTRA INIT_XMM avx DEBLOCK_CHROMA_INTRA_BODY DEBLOCK_CHROMA_INTRA INIT_MMX mmx2 DEBLOCK_CHROMA_INTRA_BODY %if ARCH_X86_64 == 0 DEBLOCK_CHROMA_INTRA %endif ;----------------------------------------------------------------------------- ; void deblock_h_chroma_intra_mbaff( uint8_t *pix, intptr_t stride, int alpha, int beta ) ;----------------------------------------------------------------------------- INIT_MMX mmx2 cglobal deblock_h_chroma_intra_mbaff, 4,6,8 CHROMA_H_START TRANSPOSE4x4W_LOAD PASS8ROWS(t5, r0, r1, t6) call chroma_intra_body TRANSPOSE4x2W_STORE PASS8ROWS(t5, r0, r1, t6, 2) RET %endif ; !HIGH_BIT_DEPTH ;----------------------------------------------------------------------------- ; static void deblock_strength( uint8_t nnz[48], int8_t ref[2][40], int16_t mv[2][40][2], ; uint8_t bs[2][4][4], int mvy_limit, int bframe ) ;----------------------------------------------------------------------------- %define scan8start (4+1*8) %define nnz r0+scan8start %define ref r1+scan8start %define mv r2+scan8start*4 %define bs0 r3 %define bs1 r3+32 %macro LOAD_BYTES_XMM 2 ; src, aligned %if %2 mova m2, [%1-4] mova m1, [%1+12] %else movu m2, [%1-4] movu m1, [%1+12] %endif psllq m0, m2, 8 shufps m2, m1, q3131 ; cur nnz, all rows psllq m1, 8 shufps m0, m1, q3131 ; left neighbors %if cpuflag(avx) || (%2 && cpuflag(ssse3)) palignr m1, m2, [%1-20], 12 %else pslldq m1, m2, 4 movd m3, [%1-8] por m1, m3 ; top neighbors %endif %endmacro %if UNIX64 DECLARE_REG_TMP 5 %else DECLARE_REG_TMP 4 %endif %macro DEBLOCK_STRENGTH_XMM 0 cglobal deblock_strength, 5,5,7 ; Prepare mv comparison register shl r4d, 8 add r4d, 3 - (1<<8) movd m6, r4d movifnidn t0d, r5m SPLATW m6, m6 pxor m4, m4 ; bs0 pxor m5, m5 ; bs1 .lists: ; Check refs LOAD_BYTES_XMM ref, 0 pxor m0, m2 pxor m1, m2 por m4, m0 por m5, m1 ; Check mvs %if cpuflag(ssse3) && notcpuflag(avx) mova m0, [mv+4*8*0] mova m1, [mv+4*8*1] palignr m3, m0, [mv+4*8*0-16], 12 palignr m2, m1, [mv+4*8*1-16], 12 psubw m0, m3 psubw m1, m2 packsswb m0, m1 mova m2, [mv+4*8*2] mova m1, [mv+4*8*3] palignr m3, m2, [mv+4*8*2-16], 12 psubw m2, m3 palignr m3, m1, [mv+4*8*3-16], 12 psubw m1, m3 packsswb m2, m1 %else movu m0, [mv-4+4*8*0] movu m1, [mv-4+4*8*1] movu m2, [mv-4+4*8*2] movu m3, [mv-4+4*8*3] psubw m0, [mv+4*8*0] psubw m1, [mv+4*8*1] psubw m2, [mv+4*8*2] psubw m3, [mv+4*8*3] packsswb m0, m1 packsswb m2, m3 %endif ABSB m0, m1 ABSB m2, m3 psubusb m0, m6 psubusb m2, m6 packsswb m0, m2 por m4, m0 mova m0, [mv+4*8*-1] mova m1, [mv+4*8* 0] mova m2, [mv+4*8* 1] mova m3, [mv+4*8* 2] psubw m0, m1 psubw m1, m2 psubw m2, m3 psubw m3, [mv+4*8* 3] packsswb m0, m1 packsswb m2, m3 ABSB m0, m1 ABSB m2, m3 psubusb m0, m6 psubusb m2, m6 packsswb m0, m2 por m5, m0 add r1, 40 add r2, 4*8*5 dec t0d jge .lists ; Check nnz LOAD_BYTES_XMM nnz, 1 por m0, m2 por m1, m2 mova m6, [pb_1] pminub m0, m6 pminub m1, m6 pminub m4, m6 ; mv ? 1 : 0 pminub m5, m6 paddb m0, m0 ; nnz ? 2 : 0 paddb m1, m1 pmaxub m4, m0 pmaxub m5, m1 %if cpuflag(ssse3) pshufb m4, [transpose_shuf] %else movhlps m3, m4 punpcklbw m4, m3 movhlps m3, m4 punpcklbw m4, m3 %endif mova [bs1], m5 mova [bs0], m4 RET %endmacro INIT_XMM sse2 DEBLOCK_STRENGTH_XMM INIT_XMM ssse3 DEBLOCK_STRENGTH_XMM INIT_XMM avx DEBLOCK_STRENGTH_XMM %macro LOAD_BYTES_YMM 1 movu m0, [%1-4] ; ___E FGHI ___J KLMN ___O PQRS ___T UVWX pshufb m0, m6 ; EFGH JKLM FGHI KLMN OPQR TUVW PQRS UVWX vpermq m1, m0, q3131 ; FGHI KLMN PQRS UVWX x2 vpbroadcastd m2, [%1-8] ; ABCD .... vpblendd m0, m0, m2, 0x80 vpermd m0, m7, m0 ; EFGH JKLM OPQR TUVW ABCD FGHI KLMN PQRS %endmacro INIT_YMM avx2 cglobal deblock_strength, 5,5,8 mova m6, [load_bytes_ymm_shuf] ; Prepare mv comparison register shl r4d, 8 add r4d, 3 - (1<<8) movd xm5, r4d movifnidn t0d, r5m vpbroadcastw m5, xm5 psrld m7, m6, 4 pxor m4, m4 ; bs0,bs1 .lists: ; Check refs LOAD_BYTES_YMM ref pxor m0, m1 por m4, m0 ; Check mvs movu xm0, [mv+0*4*8-4] vinserti128 m0, m0, [mv-1*4*8 ], 1 vbroadcasti128 m2, [mv+0*4*8 ] vinserti128 m1, m2, [mv+1*4*8-4], 0 psubw m0, m2 vbroadcasti128 m2, [mv+1*4*8 ] psubw m1, m2 packsswb m0, m1 vinserti128 m1, m2, [mv+2*4*8-4], 0 vbroadcasti128 m3, [mv+2*4*8 ] vinserti128 m2, m3, [mv+3*4*8-4], 0 psubw m1, m3 vbroadcasti128 m3, [mv+3*4*8 ] psubw m2, m3 packsswb m1, m2 pabsb m0, m0 pabsb m1, m1 psubusb m0, m5 psubusb m1, m5 packsswb m0, m1 por m4, m0 add r1, 40 add r2, 4*8*5 dec t0d jge .lists ; Check nnz LOAD_BYTES_YMM nnz mova m2, [pb_1] por m0, m1 pminub m0, m2 pminub m4, m2 ; mv ? 1 : 0 paddb m0, m0 ; nnz ? 2 : 0 pmaxub m0, m4 vextracti128 [bs1], m0, 1 pshufb xm0, [transpose_shuf] mova [bs0], xm0 RET %macro LOAD_BYTES_ZMM 1 vpermd m1, m6, [%1-12] pshufb m1, m7 ; EF FG GH HI JK KL LM MN OP PQ QR RS TU UV VW WX %endmacro ; AF BG CH DI FK GL HM IN KP LQ MR NS PU QV RW SX INIT_ZMM avx512 cglobal deblock_strength, 5,5 mova m6, [load_bytes_zmm_shuf] shl r4d, 8 add r4d, 3 - (1<<8) vpbroadcastw m5, r4d mov r4d, 0x34cc34cc ; {1,-1} * 11001100b kmovb k1, r4d vpbroadcastd m4, r4d movifnidn t0d, r5m psrld m7, m6, 4 pxor xm3, xm3 .lists: vbroadcasti64x2 m2, [mv+32] vinserti64x2 m0, m2, [mv-32], 2 vbroadcasti64x2 m1, [mv+ 0] vinserti64x2 m0, m0, [mv- 4], 0 vbroadcasti64x2 m1 {k1}, [mv+64] vinserti64x2 m0, m0, [mv+60], 1 psubw m0, m1 vinserti64x2 m1, m1, [mv+28], 0 vbroadcasti64x2 m2 {k1}, [mv+96] vinserti64x2 m1, m1, [mv+92], 1 psubw m1, m2 packsswb m0, m1 pabsb m0, m0 psubusb m0, m5 LOAD_BYTES_ZMM ref pmaddubsw m1, m4 ; E-F F-G G-H H-I ... vpternlogd m3, m0, m1, 0xfe ; m3 | m0 | m1 add r1, 40 add r2, 4*8*5 dec t0d jge .lists LOAD_BYTES_ZMM nnz mova ym2, [pb_1] vptestmw k1, m1, m1 vptestmw k2, m3, m3 vpaddb ym0 {k1}{z}, ym2, ym2 ; nnz ? 2 : 0 vpmaxub ym0 {k2}, ym2 ; mv ? 1 : 0 vextracti128 [bs1], ym0, 1 pshufb xm0, [transpose_shuf] mova [bs0], xm0 RET
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: icon editor FILE: documentUI.asm AUTHOR: Steve Yegge, Feb 24, 1993 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 2/24/93 Initial revision DESCRIPTION: Routines for updating the Add-icon dialog. $Id: documentUI.asm,v 1.1 97/04/04 16:06:02 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DocumentUI segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DBViewerUpdateAddDialogFormatList %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Sets up the list of format sizes & colors for the selected icon type, in the add-icon dialog. CALLED BY: MSG_DB_VIEWER_UPDATE_ADD_DIALOG_FORMAT_LIST PASS: *ds:si = DBViewer object ds:di = DBViewerInstance cx = identifier of person who called (CreateNewIconType) RETURN: nothing DESTROYED: ax, cx, dx, bp PSEUDO CODE/STRATEGY: We set-not-usable all the text, then set-usable the ones we want to show up (based on value in cx.) KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 8/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DBViewerUpdateAddDialogFormatList method dynamic DBViewerClass, MSG_DB_VIEWER_UPDATE_ADD_DIALOG_FORMAT_LIST .enter ; ; First set everything unusable. ; call SetAllGroupsUnusable ; ; Now set-usable the one we want. ; EC < cmp cx, CreateNewIconType > EC < ERROR_AE INVALID_CREATE_NEW_ICON_TYPE > mov bx, cx ; find out which one to do mov bx, cs:[typeTable][bx] call bx ; ; Force the geometry to be recalculated. ; mov bx, ds:[di].GDI_display mov si, offset AddDlgInfoGroup mov ax, MSG_GEN_RESET_TO_INITIAL_SIZE mov di, mask MF_CALL mov dl, VUM_NOW call ObjMessage .leave ret typeTable word \ offset DoFileIcon, offset DoToolIcon, offset DoPtrImage, offset DoCustomIcon DBViewerUpdateAddDialogFormatList endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetAllGroupsUnusable %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Goes through AddDlgInfoGroup and sets all children unusable CALLED BY: DBViewerUpdateAddDialogFormatList PASS: *ds:si = DBViewer object ds:di = DBViewerInstance RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 8/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetAllGroupsUnusable proc near class DBViewerClass uses ax,bx,cx,dx,si,di,bp .enter mov bx, ds:[di].GDI_display mov si, offset FileColorGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset FileSizeGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset FileNameGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset ToolColorGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset ToolSizeGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset ToolNameGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset PtrColorGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset PtrSizeGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset PtrNameGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage mov si, offset CustomGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_NOT_USABLE call ObjMessage .leave ret SetAllGroupsUnusable endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DoFileIcon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: sets-usable the glyphs for the file icon in the add dialog box CALLED BY: DBViewerUpdateAddDialogFormatList PASS: *ds:si = DBViewer object ds:di = DBViewerInstance RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 8/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DoFileIcon proc near class DBViewerClass uses ax,bx,cx,dx,si,di,bp .enter mov bx, ds:[di].GDI_display mov si, offset FileNameGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage mov si, offset FileSizeGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage mov si, offset FileColorGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage .leave ret DoFileIcon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DoToolIcon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: sets-usable the glyphs for the tool icon info (add dialog) CALLED BY: DBViewerUpdateAddDialogFormatList PASS: *ds:si = DBViewer object ds:di = DBViewerInstance RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 8/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DoToolIcon proc near class DBViewerClass uses ax,bx,cx,dx,si,di,bp .enter mov bx, ds:[di].GDI_display mov si, offset ToolNameGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage mov si, offset ToolSizeGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage mov si, offset ToolColorGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage .leave ret DoToolIcon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DoPtrImage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: sets-usable the glyphs for the cursor image info (add dialog) CALLED BY: DBViewerUpdateAddDialogFormatList PASS: *ds:si = DBViewer object ds:di = DBViewerInstance RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 8/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DoPtrImage proc near class DBViewerClass uses ax,bx,cx,dx,si,di,bp .enter mov bx, ds:[di].GDI_display mov si, offset PtrNameGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage mov si, offset PtrSizeGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage mov si, offset PtrColorGroup mov di, mask MF_FORCE_QUEUE mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage .leave ret DoPtrImage endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DoCustomIcon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: sets-usable the custom-icon group (add dialog) CALLED BY: DBViewerUpdateAddDialogFormatList PASS: *ds:si = DBViewer object ds:di = DBViewer instance RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: set the custom group usable REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 8/ 4/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DoCustomIcon proc near class DBViewerClass uses ax,bx,cx,dx,si,di,bp .enter mov bx, ds:[di].GDI_display mov si, offset CustomGroup mov di, mask MF_CALL mov dl, VUM_DELAYED_VIA_UI_QUEUE mov ax, MSG_GEN_SET_USABLE call ObjMessage .leave ret DoCustomIcon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DBViewerAddDialogTextModified %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: enables or disables the OK trigger in the add dialog. CALLED BY: MSG_DB_VIEWER_ADD_DIALOG_TEXT_MODIFIED PASS: *ds:si = DBViewerClass object ds:di = DBViewerClass instance data bp = zero if text is becoming empty, nonzero otherwise RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 2/24/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DBViewerAddDialogTextModified method dynamic DBViewerClass, MSG_DB_VIEWER_ADD_DIALOG_TEXT_MODIFIED uses ax, cx, dx, bp .enter mov bx, ds:[di].GDI_display mov si, offset AddDlgOKTrigger mov di, mask MF_CALL mov dl, VUM_NOW ; ; If text is becoming empty, we disable the apply trigger. ; mov ax, MSG_GEN_SET_ENABLED ; assume enable tst bp ; see if text is empty jnz doIt mov ax, MSG_GEN_SET_NOT_ENABLED doIt: call ObjMessage ; enable/disable trigger .leave ret DBViewerAddDialogTextModified endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EnableExportTokenDBTrigger %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Enable "Export to Token Database" trigger in File menu. CALLED BY: DBViewerStartSelect PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/14/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ EnableExportTokenDBTrigger proc far uses ax,bx,cx,dx,si,di,bp .enter GetResourceHandleNS ExportTokenDialog, bx mov si, offset ExportTokenDialog mov di, mask MF_CALL mov dl, VUM_NOW mov ax, MSG_GEN_SET_ENABLED call ObjMessage .leave ret EnableExportTokenDBTrigger endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DisableExportTokenDBTrigger %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Disable "Export To Token Database..." dialog. CALLED BY: DBViewerStartSelect PASS: nothing RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- stevey 6/14/94 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DisableExportTokenDBTrigger proc far uses ax,bx,cx,dx,si,di,bp .enter ; ; Set the thing disabled. ; GetResourceHandleNS ExportTokenDialog, bx mov si, offset ExportTokenDialog mov di, mask MF_CALL mov dl, VUM_NOW mov ax, MSG_GEN_SET_NOT_ENABLED call ObjMessage .leave ret DisableExportTokenDBTrigger endp DocumentUI ends
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * * * OBJECT POOL * * * * Copyright © 2013+ Ángel Rodriguez Ballesteros * * * * Distributed under the Boost Software License, version 1.0 * * See documents/LICENSE.TXT or www.boost.org/LICENSE_1_0.txt * * * * angel.rodriguez@esne.edu * * * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #ifndef TOOLKIT_OBJECT_POOL_HEADER #define TOOLKIT_OBJECT_POOL_HEADER #include <new> #include <cassert> #include "types.hpp" namespace toolkit { // Hacer que haya una clase base común. // Hacer que el tamaño de object_buffer sea múltiplo del tamaño del registro del procesador. // Hacer que cada Object_Pool herede del Object_Pool con tamaño de object_buffer múltiplo del tamaño del registro del procesador. template< typename TYPE, size_t SEGMENT_SIZE = 1024 > class Object_Pool { public: typedef size_t size_type; typedef TYPE object_type; typedef object_type * object_pointer; static const size_type segment_size = SEGMENT_SIZE; private: struct element_type; typedef element_type * element_pointer; struct segment_type; typedef segment_type * segment_pointer; typedef byte object_buffer[sizeof(object_type)]; private: struct element_type { object_buffer object_data; // This buffer is plain memory to avoid automatic constructors/destructors segment_pointer segment; // This pointer speeds up deallocation element_pointer next_free; // Pointer to the next free element element_pointer previous_free; // Pointer to the previous free element ~element_type() { // If the next and the previous elements are null and this is not a singleton element, // then this element has been left allocated and must be destructed: if (next_free == previous_free && this != segment->first_free_element) { destruct (); } } object_pointer object () { return (reinterpret_cast< object_pointer >(object_data)); } void destruct () { object ()->~object_type (); } }; struct segment_type { element_type elements[segment_size]; // Elements array element_pointer first_free_element; // Pointer to the first free element segment_pointer previous; // Pointer to the next segment along the list segment_pointer next; // Pointer to the previous segment along the list size_type number_of_elements_used; // Needed to know when a segment becomes void segment_type() { // Initialize the free element list: for (element_pointer element = elements, end = elements + segment_size; element != end; element++) { element->segment = this; element->previous_free = element - 1; element->next_free = element + 1; } // Mark both ends of the list: elements[0].previous_free = elements[segment_size - 1].next_free = null; // Initialize the pointers: previous = next = null; first_free_element = elements; } }; private: segment_pointer full_segments; segment_pointer free_segments; segment_pointer void_segments; size_type number_of_void_segments; size_type maximum_number_of_void_segments; public: Object_Pool(size_type desired_maximum_number_of_void_segments = 1) { full_segments = null; free_segments = null; void_segments = null; number_of_void_segments = 0; maximum_number_of_void_segments = desired_maximum_number_of_void_segments; } ~Object_Pool() { assert(full_segments == null); assert(free_segments == null); free_all (); } public: object_pointer allocate () { if (free_segments) { // Take the first free object of the first free segment: segment_pointer segment = free_segments; element_pointer element = segment->first_free_element; // Adjust the count of objects of the segment being used: segment->number_of_elements_used++; // Remove the element from the free element list and move the segment to // the full segment list if necessary: if ((segment->first_free_element = element->next_free) != null) { segment->first_free_element->previous_free = null; } else { unlink (segment, free_segments); link (segment, full_segments); } // An allocated element doesn't point to other elements: element->next_free = element->previous_free = null; return (element->object ()); } else { segment_pointer segment; if (void_segments) { // If there is a void segment, we will take its first object so it won't be // void anymore, then we can unlink it directly: unlink (segment = void_segments, void_segments); } else { // If there're no free or void segments, a new segment must be allocated: segment = new (std::nothrow) segment_type; // If the segment could not be allocated we notify it on debug builds: assert(segment); } if (segment) { // If there's a segment, we reserve its first object: element_pointer element = segment->elements; // Remove the element from the free element list and move the segment to // the free segment list: segment->number_of_elements_used = 1; segment->first_free_element = element->next_free; segment->first_free_element->previous_free = element->next_free = element->previous_free = null; link (segment, free_segments); return (element->object ()); } } // It was not possible allocating an object: assert (false); return (null ); } object_pointer allocate_new () { return (new (allocate ()) object_type()); } void free (object_pointer object) { if (object) { // Point to the element and to the segment: element_pointer element = reinterpret_cast< element_pointer >(object); segment_pointer segment = element->segment; // Validate the input in debug builds: assert(element >= segment->elements && element < segment->elements + segment_size); assert(element->previous_free == element->next_free); // Destruct the object: element->destruct (); // Adjust the count of objects of the segment being used: segment->number_of_elements_used--; if (segment->first_free_element) // The segment is part of the free segments list { // Insert the element at the beginning of the free element list: element->next_free = segment->first_free_element; segment->first_free_element = segment->first_free_element->previous_free = element; // If the segment is now void, move it to the void segment list or delete it: if (segment->number_of_elements_used == 0) { unlink (segment, free_segments); if (number_of_void_segments < maximum_number_of_void_segments) { link (segment, void_segments); number_of_void_segments++; } else { delete segment; } } } else // The segment is part of the full segments list { // The element will be the first and only free element of the segment: segment->first_free_element = element; // The segment is part of the full segments list but, after freeing one // object, it must be moved to the free segments list: unlink (segment, full_segments); link (segment, free_segments); } } } void free_all () { delete_all (full_segments); full_segments = null; delete_all (free_segments); free_segments = null; delete_all (void_segments); void_segments = null; } private: static void link (segment_pointer segment, segment_pointer & list_root) { // The segment->previous and segment->next pointers are supposed to be unlinked (null). if (list_root) { list_root->previous = segment; segment->next = list_root; } // We link the segment at be beginning of the list: list_root = segment; } static void unlink (segment_pointer segment, segment_pointer & list_root) { if (segment == list_root) { // The segment is the root node of the list. if (segment->next) { // In this case the next node will be the first node: segment->next->previous = null; list_root = segment->next; segment->next = null; } else { // Removing a single node leaves the list empty: list_root = null; } } else { // The segment is not the root node of the list. // In this case it has a previous node which we can relink directly: segment->previous->next = segment->next; // If there's a next node we relink it: if (segment->next) { segment->next->previous = segment->previous; } // Finally the links of the segment are cleared: segment->previous = segment->next = null; } } static void delete_all (segment_pointer segment) { while (segment) { segment_pointer next_segment = segment->next; delete segment; segment = next_segment; } } }; } #endif
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) Geoworks 1995 -- All Rights Reserved PROJECT: Socket MODULE: access point database FILE: accpntCApi.asm AUTHOR: Eric Weber, May 25, 1995 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial revision DESCRIPTION: C Stubs for Access Point $Id: accpntCApi.asm,v 1.1 97/04/04 17:41:38 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetGeosConvention ApiCode segment resource ; ; transform carry flag into a boolean ; ; carry set -> ax = BW_TRUE ; carry clear -> ax = BW_FALSE ; CarryToBoolean macro mov ax,0 rcl ax neg ax endm COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointCreateEntry C DECLARATION: extern word _pascal AccessPointCreateEntry(word loc, AccessPointType apt); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTCREATEENTRY proc far loc:word, apt:AccessPointType; .enter mov bx, loc mov ax, apt call AccessPointCreateEntry .leave ret ACCESSPOINTCREATEENTRY endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointDestroyEntry C DECLARATION: extern Boolean _pascal AccessPointDestroyEntry(word id); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTDESTROYENTRY proc far id:word .enter mov ax, id call AccessPointDestroyEntry CarryToBoolean .leave ret ACCESSPOINTDESTROYENTRY endp ACCESSPOINTDESTROYENTRYDIRECT proc far id:word .enter mov ax, id call AccessPointDestroyEntryDirect CarryToBoolean .leave ret ACCESSPOINTDESTROYENTRYDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointGetType C DECLARATION: extern AccessPointType _pascal AccessPointGetType(word id); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTGETTYPE proc far id:word .enter mov ax, id call AccessPointGetType mov ax, bx .leave ret ACCESSPOINTGETTYPE endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointSetStringProperty C DECLARATION: extern void _pascal AccessPointSetStringProperty(word id, char *prop, char *val); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTSETSTRINGPROPERTY proc far id:word, prop:fptr.char, val:fptr.char uses es,di .enter mov ax, id movdw cxdx, prop movdw esdi, val call AccessPointSetStringProperty CarryToBoolean .leave ret ACCESSPOINTSETSTRINGPROPERTY endp ACCESSPOINTSETSTRINGPROPERTYDIRECT proc far id:word, prop:fptr.char, val:fptr.char uses es,di .enter mov ax, id movdw cxdx, prop movdw esdi, val call AccessPointSetStringPropertyDirect CarryToBoolean .leave ret ACCESSPOINTSETSTRINGPROPERTYDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointSetIntegerProperty C DECLARATION: extern void _pascal AccessPointSetIntegerProperty(word id, char *prop, int val); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTSETINTEGERPROPERTY proc far id:word, prop:fptr.char, val:word .enter push bp mov ax, id movdw cxdx, prop mov bp, val call AccessPointSetIntegerProperty pop bp CarryToBoolean .leave ret ACCESSPOINTSETINTEGERPROPERTY endp ACCESSPOINTSETINTEGERPROPERTYDIRECT proc far id:word, prop:fptr.char, val:word .enter push bp mov ax, id movdw cxdx, prop mov bp, val call AccessPointSetIntegerPropertyDirect pop bp CarryToBoolean .leave ret ACCESSPOINTSETINTEGERPROPERTYDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointGetStringPropertyBlock C DECLARATION: extern Boolean _pascal AccessPointGetStringPropertyBlock(word id, char *prop, MemHandle *data, int *datalen); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTGETSTRINGPROPERTYBLOCK proc far id:word, prop:fptr.char, data:fptr.hptr, datalen:fptr.word uses ds, si .enter mov ax, id movdw cxdx, prop push bp clr bp call AccessPointGetStringProperty pop bp movdw dssi, data mov ds:[si], bx movdw dssi, datalen mov ds:[si], cx CarryToBoolean .leave ret ACCESSPOINTGETSTRINGPROPERTYBLOCK endp ACCESSPOINTGETSTRINGPROPERTYBLOCKDIRECT proc far id:word, prop:fptr.char, data:fptr.hptr, datalen:fptr.word uses ds, si .enter mov ax, id movdw cxdx, prop push bp clr bp call AccessPointGetStringPropertyDirect pop bp movdw dssi, data mov ds:[si], bx movdw dssi, datalen mov ds:[si], cx CarryToBoolean .leave ret ACCESSPOINTGETSTRINGPROPERTYBLOCKDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointGetStringPropertyBuffer C DECLARATION: extern Boolean _pascal AccessPointGetStringPropertyBuffer(word id, char *prop, char *buf, int *datalen); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTGETSTRINGPROPERTYBUFFER proc far id:word, prop:fptr.char, buf:fptr.char, datalen:fptr.word uses ds,si,es,di .enter mov ax, id movdw cxdx, prop movdw dssi, datalen movdw esdi, buf push bp mov bp, ds:[si] call AccessPointGetStringProperty pop bp mov ds:[si], cx CarryToBoolean .leave ret ACCESSPOINTGETSTRINGPROPERTYBUFFER endp ACCESSPOINTGETSTRINGPROPERTYBUFFERDIRECT proc far id:word, prop:fptr.char, buf:fptr.char, datalen:fptr.word uses ds,si,es,di .enter mov ax, id movdw cxdx, prop movdw dssi, datalen movdw esdi, buf push bp mov bp, ds:[si] call AccessPointGetStringPropertyDirect pop bp mov ds:[si], cx CarryToBoolean .leave ret ACCESSPOINTGETSTRINGPROPERTYBUFFERDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointGetIntegerProperty C DECLARATION: extern Boolean _pascal AccessPointGetIntegerProperty(word id, char *prop, int *val); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTGETINTEGERPROPERTY proc far id:word, prop:fptr.char, val:fptr.word uses ds,si .enter mov ax, id movdw cxdx, prop call AccessPointGetIntegerProperty movdw dssi, val mov ds:[si], ax CarryToBoolean .leave ret ACCESSPOINTGETINTEGERPROPERTY endp ACCESSPOINTGETINTEGERPROPERTYDIRECT proc far id:word, prop:fptr.char, val:fptr.word uses ds,si .enter mov ax, id movdw cxdx, prop call AccessPointGetIntegerPropertyDirect movdw dssi, val mov ds:[si], ax CarryToBoolean .leave ret ACCESSPOINTGETINTEGERPROPERTYDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointDestroyProperty C DECLARATION: extern Boolean _pascal AccessPointDestroyProperty(word id, char *prop); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTDESTROYPROPERTY proc far id:word, prop:fptr.char uses si, di .enter mov ax, id movdw cxdx, prop call AccessPointDestroyProperty CarryToBoolean .leave ret ACCESSPOINTDESTROYPROPERTY endp ACCESSPOINTDESTROYPROPERTYDIRECT proc far id:word, prop:fptr.char uses si, di .enter mov ax, id movdw cxdx, prop call AccessPointDestroyPropertyDirect CarryToBoolean .leave ret ACCESSPOINTDESTROYPROPERTYDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointGetEntries C DECLARATION: extern ChunkHandle _pascal AccessPointGetEntries(MemHandle mh, ChunkHandle chunk, AcessPointType apt); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTGETENTRIES proc far mh:hptr, chnk:lptr, apt:AccessPointType uses ds,si .enter mov bx, mh call MemDerefDS mov si, chnk mov ax, apt call AccessPointGetEntries mov ax, si .leave ret ACCESSPOINTGETENTRIES endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointCompareStandardProperty C DECLARATION: extern Boolean _pascal AccessPointCompareStandardProperty(AccessPointStandardProperty prop, char *str); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 5/25/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTCOMPARESTANDARDPROPERTY proc far prop:AccessPointStandardProperty, s:fptr.char uses si, di .enter clr ax mov dx, prop movdw esdi, s call AccessPointCompareStandardProperty jnz done mov ax, BW_TRUE done: .leave ret ACCESSPOINTCOMPARESTANDARDPROPERTY endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointIsEntryValid C DECLARATION: extern Boolean _pascal AccessPointIsEntryValid(word id); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- EW 11/21/95 Initial Revision ------------------------------------------------------------------------------@ ACCESSPOINTISENTRYVALID proc far id:word .enter mov ax, id call AccessPointIsEntryValid cmc CarryToBoolean .leave ret ACCESSPOINTISENTRYVALID endp ACCESSPOINTISENTRYVALIDDIRECT proc far id:word .enter mov ax, id call AccessPointIsEntryValidDirect cmc CarryToBoolean .leave ret ACCESSPOINTISENTRYVALIDDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointLock C DECLARATION: extern void _pascal AccessPointLock (word id); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 10/25/96 Initial version ------------------------------------------------------------------------------@ ACCESSPOINTLOCK proc far id:word .enter mov ax, id call AccessPointLock .leave ret ACCESSPOINTLOCK endp ACCESSPOINTLOCKDIRECT proc far id:word .enter mov ax, id call AccessPointLockDirect .leave ret ACCESSPOINTLOCKDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointUnlock C DECLARATION: extern void _pascal AccessPointUnlock (word id); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 10/25/96 Initial version ------------------------------------------------------------------------------@ ACCESSPOINTUNLOCK proc far id:word .enter mov ax, id call AccessPointUnlock .leave ret ACCESSPOINTUNLOCK endp ACCESSPOINTUNLOCKDIRECT proc far id:word .enter mov ax, id call AccessPointUnlockDirect .leave ret ACCESSPOINTUNLOCKDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointInUse C DECLARATION: extern Boolean _pascal AccessPointInUse (word id); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jwu 10/25/96 Initial version ------------------------------------------------------------------------------@ ACCESSPOINTINUSE proc far id:word .enter mov ax, id call AccessPointInUse CarryToBoolean .leave ret ACCESSPOINTINUSE endp ACCESSPOINTINUSEDIRECT proc far id:word .enter mov ax, id call AccessPointInUseDirect CarryToBoolean .leave ret ACCESSPOINTINUSEDIRECT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointSetActivePoint C DECLARATION: extern Boolean _pascal AccessPointSetActivePoint (word id, word tp); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- mzhu 2/2/99 Initial version ------------------------------------------------------------------------------@ ACCESSPOINTSETACTIVEPOINT proc far id:word, tp:word .enter mov ax, id mov dx, tp call AccessPointSetActivePoint CarryToBoolean .leave ret ACCESSPOINTSETACTIVEPOINT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointGetActivePoint C DECLARATION: extern word _pascal AccessPointGetActivePoint (word tp); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- mzhu 2/2/99 Initial version ------------------------------------------------------------------------------@ ACCESSPOINTGETACTIVEPOINT proc far tp:word .enter mov dx, tp call AccessPointGetActivePoint jnc done mov ax, 0 ; return 0 for error done: .leave ret ACCESSPOINTGETACTIVEPOINT endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointGetDialingOptions C DECLARATION: extern void _pascal AccessPointGetDialingOptions( AccessPointDialingOptions *pOptions); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 9/3/99 Initial version ------------------------------------------------------------------------------@ ACCESSPOINTGETDIALINGOPTIONS proc far pOptions:fptr.AccessPointDialingOptions .enter movdw cxdx, pOptions call AccessPointGetDialingOptions ; destroys: none .leave ret ACCESSPOINTGETDIALINGOPTIONS endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointSetDialingOptions C DECLARATION: extern void _pascal AccessPointSetDialingOptions( AccessPointDialingOptions *pOptions); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 9/3/99 Initial version ------------------------------------------------------------------------------@ ACCESSPOINTSETDIALINGOPTIONS proc far pOptions:fptr.AccessPointDialingOptions .enter movdw cxdx, pOptions call AccessPointSetDialingOptions ; destroys: none .leave ret ACCESSPOINTSETDIALINGOPTIONS endp COMMENT @---------------------------------------------------------------------- C FUNCTION: AccessPointGetPhoneStringWithOptions C DECLARATION: extern Boolean _pascal AccessPointGetPhoneStringWithOptions( word id, MemHandle *pStringHan, int *datalen); KNOWN BUGS/SIDE EFFECTS/CAVEATS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- JimG 9/3/99 Initial version ------------------------------------------------------------------------------@ ACCESSPOINTGETPHONESTRINGWITHOPTIONS proc far id:word, pHan:fptr.hptr, datalen:fptr.word uses ds, si .enter movdw dssi, pHan mov bx, ds:[si] mov ax, id call AccessPointGetPhoneStringWithOptions ; destroys: none mov ds:[si], bx mov ax, 0 jnc done dec ax ; success - return true movdw dssi, datalen ; return datalen mov ds:[si], cx done: .leave ret ACCESSPOINTGETPHONESTRINGWITHOPTIONS endp ApiCode ends SetDefaultConvention
; A169200: Number of reduced words of length n in Coxeter group on 43 generators S_i with relations (S_i)^2 = (S_i S_j)^27 = I. ; 1,43,1806,75852,3185784,133802928,5619722976,236028364992,9913191329664,416354035845888,17486869505527296,734448519232146432,30846837807750150144,1295567187925506306048,54413821892871264854016 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,42 lpe mov $0,$2 div $0,42
; A286191: a(n) = (2^n-1)^2 + 2*n. ; 3,13,55,233,971,3981,16143,65041,261139,1046549,4190231,16769049,67092507,268402717,1073676319,4294836257,17179607075,68718952485,274876858407,1099509530665,4398042316843,17592177655853,70368727400495,281474943156273,1125899839733811,4503599493152821,18014398241046583,72057593501057081,288230375077969979,1152921502459363389,4611686014132420671,18446744065119617089,73786976277658337347,295147905144993087557,1180591620648691826759,4722366482732206260297,18889465931203702947915 mov $1,2 pow $1,$0 bin $1,2 mul $1,2 add $0,$1 add $0,$1 mul $0,2 add $0,3
MVI A, FEH MVI B, 27H ADD B STA F100H MVI A, 00H JNC NC MVI A, 01H NC: STA F101H RST 1 HLT
/// @copyright /// Copyright (C) 2020 Assured Information Security, Inc. /// /// @copyright /// 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: /// /// @copyright /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// @copyright /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE /// SOFTWARE. #include "../../../../../src/x64/amd/vps_t.hpp" #include <bsl/ut.hpp> namespace example { /// <!-- description --> /// @brief Used to execute the actual checks. We put the checks in this /// function so that we can validate the tests both at compile-time /// and at run-time. If a bsl::ut_check fails, the tests will either /// fail fast at run-time, or will produce a compile-time error. /// /// <!-- inputs/outputs --> /// @return Always returns bsl::exit_success. /// [[nodiscard]] constexpr auto tests() noexcept -> bsl::exit_code { bsl::ut_scenario{"initialize twice fails"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.initialize({}, {}, {}, {}, {})); }; }; }; }; bsl::ut_scenario{"initialize invalid id #1"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_check(!mut_vps.initialize({}, {}, {}, {}, bsl::safe_uint16::failure())); }; }; }; bsl::ut_scenario{"initialize invalid id #2"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_check(!mut_vps.initialize({}, {}, {}, {}, syscall::BF_INVALID_ID)); }; }; }; bsl::ut_scenario{"initialize success"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_check(mut_vps.initialize({}, {}, {}, {}, {})); }; }; }; bsl::ut_scenario{"release executes without initialize"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; bsl::ut_when{} = [&]() noexcept { mut_vps.release({}, {}, {}, {}); }; }; }; bsl::ut_scenario{"release executes with initialize"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { mut_vps.release({}, {}, {}, {}); }; }; }; }; bsl::ut_scenario{"allocate not initialized"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.allocate({}, {}, mut_sys, {}, {}, {})); }; }; }; bsl::ut_scenario{"allocate already allocated"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_required_step(mut_vps.allocate({}, {}, mut_sys, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.allocate({}, {}, mut_sys, {}, {}, {})); }; }; }; }; bsl::ut_scenario{"allocate invalid vpid #1"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.allocate( {}, {}, mut_sys, {}, bsl::safe_uint16::failure(), {})); }; }; }; }; bsl::ut_scenario{"allocate invalid vpid #2"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { bsl::ut_check( !mut_vps.allocate({}, {}, mut_sys, {}, syscall::BF_INVALID_ID, {})); }; }; }; }; bsl::ut_scenario{"allocate invalid ppid #1"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.allocate( {}, {}, mut_sys, {}, {}, bsl::safe_uint16::failure())); }; }; }; }; bsl::ut_scenario{"allocate invalid ppid #2"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { bsl::ut_check( !mut_vps.allocate({}, {}, mut_sys, {}, {}, syscall::BF_INVALID_ID)); }; }; }; }; bsl::ut_scenario{"allocate bf_vps_op_init_as_root fails"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); mut_sys.set_bf_vps_op_init_as_root({}, bsl::errc_failure); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.allocate({}, {}, mut_sys, {}, {}, {})); }; }; }; }; bsl::ut_scenario{"allocate when ppid does not match mut_vpsid"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; constexpr auto ppid{42_u16}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(mut_vps.allocate({}, {}, mut_sys, {}, {}, ppid)); }; }; }; }; bsl::ut_scenario{"allocate bf_vps_op_write fails for asid"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; constexpr auto val{0x1_u64}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); mut_sys.set_bf_vps_op_write( {}, syscall::bf_reg_t::bf_reg_t_guest_asid, val, bsl::errc_failure); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.allocate({}, {}, mut_sys, {}, {}, {})); }; }; }; }; bsl::ut_scenario{"allocate bf_vps_op_write fails for intercept 1"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; constexpr auto val{0x00040000_u64}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); mut_sys.set_bf_vps_op_write( {}, syscall::bf_reg_t::bf_reg_t_intercept_instruction1, val, bsl::errc_failure); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.allocate({}, {}, mut_sys, {}, {}, {})); }; }; }; }; bsl::ut_scenario{"allocate bf_vps_op_write fails for intercept 2"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; constexpr auto val{0x00000001_u64}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); mut_sys.set_bf_vps_op_write( {}, syscall::bf_reg_t::bf_reg_t_intercept_instruction2, val, bsl::errc_failure); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(!mut_vps.allocate({}, {}, mut_sys, {}, {}, {})); }; }; }; }; bsl::ut_scenario{"allocate success"} = []() noexcept { bsl::ut_given{} = []() noexcept { vps_t mut_vps{}; syscall::bf_syscall_t mut_sys{}; bsl::ut_when{} = [&]() noexcept { bsl::ut_required_step(mut_vps.initialize({}, {}, {}, {}, {})); bsl::ut_then{} = [&]() noexcept { bsl::ut_check(mut_vps.allocate({}, {}, mut_sys, {}, {}, {})); }; }; }; }; return bsl::ut_success(); } } /// <!-- description --> /// @brief Main function for this unit test. If a call to bsl::ut_check() fails /// the application will fast fail. If all calls to bsl::ut_check() pass, this /// function will successfully return with bsl::exit_success. /// /// <!-- inputs/outputs --> /// @return Always returns bsl::exit_success. /// [[nodiscard]] auto main() noexcept -> bsl::exit_code { bsl::enable_color(); static_assert(example::tests() == bsl::ut_success()); return example::tests(); }
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Stubs Written by D Morris - 30/9/98 ; ; ; $Id: circle.asm,v 1.6 2016/04/13 21:09:09 dom Exp $ ; ;Usage: circle(struct *pixels) SECTION code_clib PUBLIC circle PUBLIC _circle EXTERN draw_circle EXTERN plotpixel EXTERN swapgfxbk EXTERN __graphics_end .circle ._circle push ix ld ix,2 add ix,sp ld e,(ix+2) ;skip ld d,(ix+4) ;radius ld c,(ix+6) ;y ld b,(ix+8) ;x ld ix,plotpixel call swapgfxbk call draw_circle jp __graphics_end
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r15 push %r8 push %rcx push %rdi lea addresses_normal_ht+0x15733, %r15 nop nop nop nop inc %r11 mov $0x6162636465666768, %r8 movq %r8, (%r15) nop nop nop nop nop cmp %r11, %r11 lea addresses_WT_ht+0x10ff3, %r10 sub %r13, %r13 movl $0x61626364, (%r10) nop nop inc %r10 lea addresses_D_ht+0x22d3, %r15 and %rdi, %rdi mov (%r15), %rcx nop nop nop nop and %r11, %r11 lea addresses_normal_ht+0x42f3, %r10 nop nop nop nop xor $49256, %r13 vmovups (%r10), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $0, %xmm3, %r8 inc %r15 pop %rdi pop %rcx pop %r8 pop %r15 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r8 push %rcx push %rdi push %rsi // REPMOV lea addresses_PSE+0xd3f3, %rsi lea addresses_PSE+0x263, %rdi nop nop nop and %r10, %r10 mov $3, %rcx rep movsw nop nop inc %r8 // REPMOV lea addresses_A+0x5aa3, %rsi lea addresses_normal+0x23f3, %rdi nop and %r11, %r11 mov $25, %rcx rep movsq nop nop mfence // Store lea addresses_PSE+0x19ff3, %rcx nop nop nop add %rdi, %rdi movw $0x5152, (%rcx) nop nop nop nop nop and $6121, %r11 // Faulty Load mov $0x7e56900000000bf3, %r13 xor %r10, %r10 mov (%r13), %r8w lea oracles, %rsi and $0xff, %r8 shlq $12, %r8 mov (%rsi,%r8,1), %r8 pop %rsi pop %rdi pop %rcx pop %r8 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_NC', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_PSE', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_PSE', 'congruent': 3, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_normal', 'congruent': 10, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_NC', 'same': True, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 8, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A169027: Number of reduced words of length n in Coxeter group on 14 generators S_i with relations (S_i)^2 = (S_i S_j)^24 = I. ; 1,14,182,2366,30758,399854,5198102,67575326,878479238,11420230094,148462991222,1930018885886,25090245516518,326173191714734,4240251492291542,55123269399790046,716602502197270598 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,13 lpe mov $0,$2 div $0,13
; A169355: Number of reduced words of length n in Coxeter group on 6 generators S_i with relations (S_i)^2 = (S_i S_j)^31 = I. ; 1,6,30,150,750,3750,18750,93750,468750,2343750,11718750,58593750,292968750,1464843750,7324218750,36621093750,183105468750,915527343750,4577636718750,22888183593750,114440917968750,572204589843750 mov $1,5 pow $1,$0 mul $1,6 div $1,5
; void *sms_memcpy_vram_to_mem_unsafe(void *dst, void *src, unsigned int n) SECTION code_clib SECTION code_arch PUBLIC _sms_memcpy_vram_to_mem_unsafe EXTERN asm_sms_memcpy_vram_to_mem_unsafe _sms_memcpy_vram_to_mem_unsafe: pop af pop de pop hl pop bc push bc push hl push de push af jp asm_sms_memcpy_vram_to_mem_unsafe
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r14 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x12c7e, %rax clflush (%rax) nop nop nop xor %rdx, %rdx mov (%rax), %r10d nop nop xor $56879, %r11 lea addresses_UC_ht+0x847e, %rsi lea addresses_WC_ht+0x89b3, %rdi nop nop nop dec %rdx mov $34, %rcx rep movsw sub $58897, %rsi lea addresses_D_ht+0x1923e, %rsi lea addresses_D_ht+0x1413e, %rdi nop nop xor $31363, %r14 mov $48, %rcx rep movsl nop nop nop sub $53051, %rsi lea addresses_A_ht+0xdc7e, %rdx nop nop add $16088, %rcx mov $0x6162636465666768, %r11 movq %r11, (%rdx) nop nop and $12420, %rsi lea addresses_UC_ht+0xc62e, %rsi lea addresses_UC_ht+0xff66, %rdi nop nop nop xor %r14, %r14 mov $118, %rcx rep movsw nop nop nop nop xor %r14, %r14 lea addresses_UC_ht+0x12c7e, %r11 nop nop nop sub $14283, %rdx vmovups (%r11), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %r10 nop nop add $21270, %rsi lea addresses_normal_ht+0x1628e, %rsi lea addresses_D_ht+0x205e, %rdi nop nop nop nop nop xor $14305, %rax mov $53, %rcx rep movsw nop nop xor $42386, %rax lea addresses_UC_ht+0x1831e, %rsi lea addresses_A_ht+0x1dd92, %rdi cmp $4948, %r11 mov $120, %rcx rep movsw nop nop xor %rsi, %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r14 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r15 push %r8 push %r9 push %rax push %rbp push %rbx // Store lea addresses_WT+0xda7e, %rbp nop sub %rbx, %rbx mov $0x5152535455565758, %rax movq %rax, %xmm7 vmovups %ymm7, (%rbp) nop nop xor $59109, %rbp // Store lea addresses_RW+0x60fe, %r8 nop nop nop nop and $12824, %rbx mov $0x5152535455565758, %rax movq %rax, %xmm3 vmovntdq %ymm3, (%r8) add $37899, %rax // Faulty Load lea addresses_PSE+0x747e, %rbx nop nop cmp %rbp, %rbp mov (%rbx), %eax lea oracles, %rbp and $0xff, %rax shlq $12, %rax mov (%rbp,%rax,1), %rax pop %rbx pop %rbp pop %rax pop %r9 pop %r8 pop %r15 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 0}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': True, 'AVXalign': False, 'size': 32, 'congruent': 6}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WC_ht'}} {'OP': 'REPM', 'src': {'same': True, 'congruent': 6, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_D_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': True, 'congruent': 4, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'dst': {'same': True, 'congruent': 0, 'type': 'addresses_A_ht'}} {'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 */
; A052713: E.g.f. (1-sqrt(1-8*x))/2. ; 0,2,8,96,1920,53760,1935360,85155840,4428103680,265686220800,18066663014400,1373066389094400,115337576683929600,10611057054921523200,1061105705492152320000,114599416193152450560000 lpb $0 trn $0,1 seq $0,144828 ; Partial products of successive terms of A017113; a(0)=1. mov $2,$0 mov $0,$1 lpe mov $0,$2 mul $0,2
; A010685: Period 2: repeat (1,4). ; Submitted by Christian Krause ; 1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4 mod $0,2 mul $0,3 add $0,1
// // detail/win_iocp_socket_send_op.hpp // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #ifndef BOOST_ASIO_DETAIL_WIN_IOCP_SOCKET_SEND_OP_HPP #define BOOST_ASIO_DETAIL_WIN_IOCP_SOCKET_SEND_OP_HPP #if defined(_MSC_VER) && (_MSC_VER >= 1200) # pragma once #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include <boost/asio/detail/config.hpp> #if defined(BOOST_ASIO_HAS_IOCP) #include <boost/asio/detail/addressof.hpp> #include <boost/asio/detail/bind_handler.hpp> #include <boost/asio/detail/buffer_sequence_adapter.hpp> #include <boost/asio/detail/fenced_block.hpp> #include <boost/asio/detail/handler_alloc_helpers.hpp> #include <boost/asio/detail/handler_invoke_helpers.hpp> #include <boost/asio/detail/operation.hpp> #include <boost/asio/detail/socket_ops.hpp> #include <boost/asio/error.hpp> #include <boost/asio/detail/push_options.hpp> namespace boost { namespace asio { namespace detail { template <typename ConstBufferSequence, typename Handler> class win_iocp_socket_send_op : public operation { public: BOOST_ASIO_DEFINE_HANDLER_PTR(win_iocp_socket_send_op); win_iocp_socket_send_op(socket_ops::weak_cancel_token_type cancel_token, const ConstBufferSequence& buffers, Handler& handler) : operation(&win_iocp_socket_send_op::do_complete), cancel_token_(cancel_token), buffers_(buffers), handler_(BOOST_ASIO_MOVE_CAST(Handler)(handler)) { } static void do_complete(io_service_impl* owner, operation* base, const boost::system::error_code& result_ec, std::size_t bytes_transferred) { boost::system::error_code ec(result_ec); // Take ownership of the operation object. win_iocp_socket_send_op* o(static_cast<win_iocp_socket_send_op*>(base)); ptr p = { boost::asio::detail::addressof(o->handler_), o, o }; BOOST_ASIO_HANDLER_COMPLETION((o)); #if defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) // Check whether buffers are still valid. if (owner) { buffer_sequence_adapter<boost::asio::const_buffer, ConstBufferSequence>::validate(o->buffers_); } #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING) socket_ops::complete_iocp_send(o->cancel_token_, ec); // Make a copy of the handler so that the memory can be deallocated before // the upcall is made. Even if we're not about to make an upcall, a // sub-object of the handler may be the true owner of the memory associated // with the handler. Consequently, a local copy of the handler is required // to ensure that any owning sub-object remains valid until after we have // deallocated the memory here. detail::binder2<Handler, boost::system::error_code, std::size_t> handler(o->handler_, ec, bytes_transferred); p.h = boost::asio::detail::addressof(handler.handler_); p.reset(); // Make the upcall if required. if (owner) { fenced_block b(fenced_block::half); BOOST_ASIO_HANDLER_INVOCATION_BEGIN((handler.arg1_, handler.arg2_)); boost_asio_handler_invoke_helpers::invoke(handler, handler.handler_); BOOST_ASIO_HANDLER_INVOCATION_END; } } private: socket_ops::weak_cancel_token_type cancel_token_; ConstBufferSequence buffers_; Handler handler_; }; } // namespace detail } // namespace asio } // namespace boost #include <boost/asio/detail/pop_options.hpp> #endif // defined(BOOST_ASIO_HAS_IOCP) #endif // BOOST_ASIO_DETAIL_WIN_IOCP_SOCKET_SEND_OP_HPP
// // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. // // By downloading, copying, installing or using the software you agree to this license. // If you do not agree to this license, do not download, install, // copy or use the software. // // // License Agreement // For Open Source Computer Vision Library // // Copyright (C) 2014, OpenCV Foundation, all rights reserved. // Third party copyrights are property of their respective owners. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // * Redistribution's of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // * Redistribution's 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. // // * The name of the copyright holders may not 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 Intel Corporation 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. // /** ** ppf_match_3d : Interfaces for matching 3d surfaces in 3d scenes. This module implements the algorithm from Bertram Drost and Slobodan Ilic. ** Use: Read a 3D model, load a 3D scene and match the model to the scene ** ** ** Creation - 2014 ** Author: Tolga Birdal (tbirdal@gmail.com) ** ** Refer to the following research paper for more information: ** B. Drost, Markus Ulrich, N. Navab, S. Ilic Model Globally, Match Locally: Efficient and Robust 3D Object Recognition IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR), San Francisco, California (USA), June 2010. ***/ /** @file @author Tolga Birdal <tbirdal AT gmail.com> */ #ifndef __OPENCV_SURFACE_MATCHING_PPF_MATCH_3D_HPP__ #define __OPENCV_SURFACE_MATCHING_PPF_MATCH_3D_HPP__ #include <opencv2/core.hpp> #include <vector> #include "pose_3d.hpp" #include "t_hash_int.hpp" namespace cv { namespace ppf_match_3d { //! @addtogroup surface_matching //! @{ /** * @brief Struct, holding a node in the hashtable */ typedef struct THash { int id; int i, ppfInd; } THash; /** * @brief Class, allowing the load and matching 3D models. * Typical Use: * @code * // Train a model * ppf_match_3d::PPF3DDetector detector(0.05, 0.05); * detector.trainModel(pc); * // Search the model in a given scene * vector<Pose3DPtr> results; * detector.match(pcTest, results, 1.0/5.0,0.05); * @endcode */ class CV_EXPORTS PPF3DDetector { public: /** * \brief Empty constructor. Sets default arguments */ PPF3DDetector(); /** * Constructor with arguments * @param [in] relativeSamplingStep Sampling distance relative to the object's diameter. Models are first sampled uniformly in order to improve efficiency. Decreasing this value leads to a denser model, and a more accurate pose estimation but the larger the model, the slower the training. Increasing the value leads to a less accurate pose computation but a smaller model and faster model generation and matching. Beware of the memory consumption when using small values. * @param [in] relativeDistanceStep The discretization distance of the point pair distance relative to the model's diameter. This value has a direct impact on the hashtable. Using small values would lead to too fine discretization, and thus ambiguity in the bins of hashtable. Too large values would lead to no discrimination over the feature vectors and different point pair features would be assigned to the same bin. This argument defaults to the value of RelativeSamplingStep. For noisy scenes, the value can be increased to improve the robustness of the matching against noisy points. * @param [in] numAngles Set the discretization of the point pair orientation as the number of subdivisions of the angle. This value is the equivalent of RelativeDistanceStep for the orientations. Increasing the value increases the precision of the matching but decreases the robustness against incorrect normal directions. Decreasing the value decreases the precision of the matching but increases the robustness against incorrect normal directions. For very noisy scenes where the normal directions can not be computed accurately, the value can be set to 25 or 20. */ PPF3DDetector(const double relativeSamplingStep, const double relativeDistanceStep=0.05, const double numAngles=30); virtual ~PPF3DDetector(); /** * Set the parameters for the search * @param [in] positionThreshold Position threshold controlling the similarity of translations. Depends on the units of calibration/model. * @param [in] rotationThreshold Position threshold controlling the similarity of rotations. This parameter can be perceived as a threshold over the difference of angles * @param [in] useWeightedClustering The algorithm by default clusters the poses without weighting. A non-zero value would indicate that the pose clustering should take into account the number of votes as the weights and perform a weighted averaging instead of a simple one. */ void setSearchParams(const double positionThreshold=-1, const double rotationThreshold=-1, const bool useWeightedClustering=false); /** * \brief Trains a new model. * * @param [in] Model The input point cloud with normals (Nx6) * * \details Uses the parameters set in the constructor to downsample and learn a new model. When the model is learnt, the instance gets ready for calling "match". */ void trainModel(const Mat& Model); /** * \brief Matches a trained model across a provided scene. * * @param [in] scene Point cloud for the scene * @param [out] results List of output poses * @param [in] relativeSceneSampleStep The ratio of scene points to be used for the matching after sampling with relativeSceneDistance. For example, if this value is set to 1.0/5.0, every 5th point from the scene is used for pose estimation. This parameter allows an easy trade-off between speed and accuracy of the matching. Increasing the value leads to less points being used and in turn to a faster but less accurate pose computation. Decreasing the value has the inverse effect. * @param [in] relativeSceneDistance Set the distance threshold relative to the diameter of the model. This parameter is equivalent to relativeSamplingStep in the training stage. This parameter acts like a prior sampling with the relativeSceneSampleStep parameter. */ void match(const Mat& scene, std::vector<Pose3DPtr> &results, const double relativeSceneSampleStep=1.0/5.0, const double relativeSceneDistance=0.03); void read(const FileNode& fn); void write(FileStorage& fs) const; protected: double angle_step, angle_step_radians, distance_step; double sampling_step_relative, angle_step_relative, distance_step_relative; Mat sampled_pc, ppf; int num_ref_points, ppf_step; hashtable_int* hash_table; THash* hash_nodes; double position_threshold, rotation_threshold; bool use_weighted_avg; int scene_sample_step; void clearTrainingModels(); private: void computePPFFeatures(const double p1[4], const double n1[4], const double p2[4], const double n2[4], double f[4]); bool matchPose(const Pose3D& sourcePose, const Pose3D& targetPose); void clusterPoses(std::vector<Pose3DPtr> poseList, int numPoses, std::vector<Pose3DPtr> &finalPoses); bool trained; }; //! @} } // namespace ppf_match_3d } // namespace cv #endif
; A061223: a(n) = n^3 + (n + 1)^4 + (n + 2)^5. ; 33,260,1113,3408,8465,18228,35385,63488,107073,171780,264473,393360,568113,799988,1101945,1488768,1977185,2585988,3336153,4250960,5356113,6679860,8253113,10109568,12285825,14821508,17759385,21145488,25029233,29463540,34504953,40213760,46654113,53894148,62006105,71066448,81155985,92359988,104768313,118475520,133580993,150189060,168409113,188355728,210148785,233913588,259780985,287887488,318375393,351392900,387094233,425639760,467196113,511936308,560039865,611692928,667088385,726425988,789912473 mov $2,$0 mov $6,$0 add $0,5 add $0,$2 lpb $0 add $1,$0 sub $0,1 sub $1,1 lpe mul $1,4 sub $1,7 mov $3,48 mov $7,$6 lpb $3 add $1,$7 sub $3,1 lpe mov $4,$6 lpb $4 sub $4,1 add $5,$7 lpe mov $3,78 mov $7,$5 lpb $3 add $1,$7 sub $3,1 lpe mov $4,$6 mov $5,0 lpb $4 sub $4,1 add $5,$7 lpe mov $3,45 mov $7,$5 lpb $3 add $1,$7 sub $3,1 lpe mov $4,$6 mov $5,0 lpb $4 sub $4,1 add $5,$7 lpe mov $3,11 mov $7,$5 lpb $3 add $1,$7 sub $3,1 lpe mov $4,$6 mov $5,0 lpb $4 sub $4,1 add $5,$7 lpe mov $3,1 mov $7,$5 lpb $3 add $1,$7 sub $3,1 lpe mov $0,$1
GLOBAL systemCallHandler extern systemCallDispatcher section .text systemCallHandler: pushState call systemCallDispatcher popState iretq %macro pushState 0 push rbx push rcx push rdx push rbp push rdi push rsi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 %endmacro %macro popState 0 pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rsi pop rdi pop rbp pop rdx pop rcx pop rbx %endmacro
;============================================================================== ; Contents of this file are copyright Phillip Stevens ; ; You have permission to use this for NON COMMERCIAL USE ONLY ; If you wish to use it elsewhere, please include an acknowledgement to myself. ; ; https://github.com/feilipu/ ; ; https://feilipu.me/ ; ; ; This work was authored in Marrakech, Morocco during May/June 2017. INCLUDE "config_private.inc" SECTION code_driver PUBLIC asm_i2c_interrupt_attach EXTERN z180_int_int1, z180_int_int2 ;attach an interrupt relevant for the specific device ;input HL = address of the interrupt service routine ;input A = device address, __IO_I2C1_PORT_MSB or __IO_I2C2_PORT_MSB .asm_i2c_interrupt_attach cp __IO_I2C2_PORT_MSB jr Z,i2c_int_at2 cp __IO_I2C1_PORT_MSB ret NZ ;no device address match, so exit ld (z180_int_int1),hl ;load the address of the PCA9665 INT1 routine ret .i2c_int_at2 ld (z180_int_int2),hl ;load the address of the PCA9665 INT2 routine ret EXTERN asm_i2c1_need EXTERN asm_i2c2_need DEFC NEED1 = asm_i2c1_need DEFC NEED2 = asm_i2c2_need
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r15 push %rax push %rcx push %rdi push %rsi lea addresses_normal_ht+0x16fbc, %rsi lea addresses_UC_ht+0x12e5c, %rdi add %r11, %r11 mov $98, %rcx rep movsb nop nop nop nop sub $23544, %rsi lea addresses_A_ht+0xf5c, %rsi lea addresses_WC_ht+0xc75c, %rdi nop nop nop nop sub %rax, %rax mov $122, %rcx rep movsb nop mfence lea addresses_A_ht+0x1c7c, %rsi add $47847, %r15 mov (%rsi), %cx nop nop nop nop add %r11, %r11 lea addresses_WC_ht+0x7e30, %rdi nop nop sub $53358, %r10 movb $0x61, (%rdi) cmp %r10, %r10 lea addresses_D_ht+0x1add9, %r11 add %rsi, %rsi mov $0x6162636465666768, %rdi movq %rdi, %xmm1 vmovups %ymm1, (%r11) nop nop nop nop nop xor %r15, %r15 lea addresses_D_ht+0xa01c, %r11 nop nop add %rsi, %rsi movb (%r11), %r10b nop nop nop nop nop sub $32333, %rax lea addresses_UC_ht+0x1b85c, %rsi lea addresses_normal_ht+0x1d95c, %rdi and %r11, %r11 mov $119, %rcx rep movsq nop nop nop nop nop and %rsi, %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r15 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r9 push %rax push %rdi // Store lea addresses_WC+0xeabc, %rdi nop nop inc %r12 movb $0x51, (%rdi) nop dec %rax // Faulty Load lea addresses_WC+0x1c75c, %r9 clflush (%r9) and $9423, %r11 movups (%r9), %xmm4 vpextrq $0, %xmm4, %r12 lea oracles, %rax and $0xff, %r12 shlq $12, %r12 mov (%rax,%r12,1), %r12 pop %rdi pop %rax pop %r9 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_WC', 'AVXalign': True, 'size': 1, 'NT': False, 'same': False, 'congruent': 5}} [Faulty Load] {'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}} {'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}} {'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': True, 'congruent': 4}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 0}} {'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 1, 'NT': False, 'same': False, 'congruent': 6}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 8, 'same': False}} {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
; ; MSX specific routines ; by Stefano Bodrato, December 2007 ; ; int msx_lpt(); ; ; Check if the line printer is ready (1=ready, 0 if not) ; ; $Id: msx_lpt.asm,v 1.4 2016-06-16 19:30:25 dom Exp $ ; SECTION code_clib PUBLIC msx_lpt PUBLIC _msx_lpt EXTERN msxbios INCLUDE "msxbios.def" msx_lpt: _msx_lpt: push ix ld ix,LPTSTT call msxbios pop ix ld hl,0 ret z inc l ret
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r14 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_UC_ht+0x9b3e, %rsi lea addresses_UC_ht+0x1cfe, %rdi nop nop sub $44730, %rax mov $68, %rcx rep movsw nop nop nop nop nop dec %rcx lea addresses_normal_ht+0x18f3e, %r12 nop nop nop add %r9, %r9 mov (%r12), %edi nop nop nop nop inc %rcx lea addresses_WT_ht+0x1e3e, %r9 nop nop nop cmp $52403, %rax vmovups (%r9), %ymm4 vextracti128 $0, %ymm4, %xmm4 vpextrq $1, %xmm4, %rdi nop nop cmp %rcx, %rcx lea addresses_D_ht+0x13ad0, %rsi lea addresses_WT_ht+0x4420, %rdi nop nop nop inc %r14 mov $67, %rcx rep movsq nop nop nop and %rcx, %rcx lea addresses_A_ht+0x14b1a, %rsi lea addresses_WT_ht+0x1503e, %rdi nop nop cmp $13554, %r12 mov $83, %rcx rep movsw nop nop dec %r12 lea addresses_D_ht+0x1e2be, %rax nop nop cmp %rsi, %rsi mov (%rax), %ecx nop nop xor $56226, %rcx lea addresses_UC_ht+0x1d7fe, %r9 nop and $56429, %rdi mov (%r9), %r12d nop nop nop nop and %rcx, %rcx pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r14 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r14 push %r8 push %r9 push %rcx push %rdi // Load lea addresses_A+0x1503e, %r9 nop xor $42445, %rcx mov (%r9), %r14w nop nop nop nop dec %rdi // Store lea addresses_A+0x1783e, %r8 clflush (%r8) nop nop nop nop nop xor $39670, %r9 mov $0x5152535455565758, %r14 movq %r14, %xmm4 movups %xmm4, (%r8) nop nop nop add $39493, %r8 // Faulty Load lea addresses_A+0x1503e, %r10 nop nop nop nop nop inc %r11 vmovups (%r10), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $1, %xmm5, %rcx lea oracles, %r9 and $0xff, %rcx shlq $12, %rcx mov (%r9,%rcx,1), %rcx pop %rdi pop %rcx pop %r9 pop %r8 pop %r14 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_A', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_A', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_A', 'AVXalign': False, 'size': 16}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_A', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 4}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 1, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}} {'src': {'same': False, 'congruent': 2, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 11, 'type': 'addresses_WT_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_UC_ht', 'AVXalign': True, 'size': 4}, 'OP': 'LOAD'} {'46': 21541, '49': 108, '08': 9, '00': 145, '45': 16, '72': 10} 49 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 00 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 00 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 49 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 00 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 49 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 45 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 46 */
; A273849: Partial sums of the number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 969", based on the 5-celled von Neumann neighborhood. ; 1,5,26,71,147,268,437,662,951,1312,1753,2282,2907,3636,4477,5438,6527,7752,9121,10642,12323,14172,16197,18406,20807,23408,26217,29242,32491,35972,39693,43662,47887,52376,57137,62178,67507,73132,79061,85302,91863,98752,105977,113546,121467,129748,138397,147422,156831,166632,176833,187442,198467,209916,221797,234118,246887,260112,273801,287962,302603,317732,333357,349486,366127,383288,400977,419202,437971,457292,477173,497622,518647,540256,562457,585258,608667,632692,657341,682622,708543,735112 lpb $0 mov $2,$0 sub $0,1 seq $2,273847 ; Number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 969", based on the 5-celled von Neumann neighborhood. add $1,$2 lpe add $1,1 mov $0,$1
;------------------------------------------------------------------------------ ; ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ; Module Name: ; ; CpuId.Asm ; ; Abstract: ; ; AsmCpuid function ; ; Notes: ; ;------------------------------------------------------------------------------ SECTION .text ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; AsmCpuid ( ; IN UINT32 RegisterInEax, ; OUT UINT32 *RegisterOutEax OPTIONAL, ; OUT UINT32 *RegisterOutEbx OPTIONAL, ; OUT UINT32 *RegisterOutEcx OPTIONAL, ; OUT UINT32 *RegisterOutEdx OPTIONAL ; ); ;------------------------------------------------------------------------------ global ASM_PFX(AsmCpuid) ASM_PFX(AsmCpuid): push ebx push ebp mov ebp, esp mov eax, [ebp + 12] cpuid push ecx mov ecx, [ebp + 16] jecxz .0 mov [ecx], eax .0: mov ecx, [ebp + 20] jecxz .1 mov [ecx], ebx .1: mov ecx, [ebp + 24] jecxz .2 pop DWORD [ecx] .2: mov ecx, [ebp + 28] jecxz .3 mov [ecx], edx .3: mov eax, [ebp + 12] leave pop ebx ret
/***************************************************************************************** * SGCT * * Simple Graphics Cluster Toolkit * * * * Copyright (c) 2012-2021 * * For conditions of distribution and use, see copyright notice in LICENSE.md * ****************************************************************************************/ #include <sgct/settings.h> #include <sgct/config.h> #include <sgct/engine.h> #include <sgct/log.h> #include <sgct/opengl.h> namespace sgct { Settings* Settings::_instance = nullptr; Settings& Settings::instance() { if (!_instance) { _instance = new Settings; } return *_instance; } void Settings::destroy() { delete _instance; _instance = nullptr; } void Settings::applySettings(const config::Settings& settings) { if (settings.useDepthTexture) { setUseDepthTexture(*settings.useDepthTexture); } if (settings.useNormalTexture) { setUseNormalTexture(*settings.useNormalTexture); } if (settings.usePositionTexture) { setUsePositionTexture(*settings.usePositionTexture); } if (settings.bufferFloatPrecision) { BufferFloatPrecision p = [](config::Settings::BufferFloatPrecision pr) { switch (pr) { case config::Settings::BufferFloatPrecision::Float16Bit: return BufferFloatPrecision::Float16Bit; case config::Settings::BufferFloatPrecision::Float32Bit: return BufferFloatPrecision::Float32Bit; default: throw std::logic_error("Unhandled case label"); } }(*settings.bufferFloatPrecision); setBufferFloatPrecision(p); } if (settings.display) { if (settings.display->swapInterval) { setSwapInterval(*settings.display->swapInterval); } if (settings.display->refreshRate) { setRefreshRateHint(*settings.display->refreshRate); } } } void Settings::applyCapture(const config::Capture& capture) { if (capture.path) { setCapturePath(*capture.path); } if (capture.format) { CaptureFormat f = [](config::Capture::Format format) { switch (format) { case config::Capture::Format::PNG: return CaptureFormat::PNG; case config::Capture::Format::JPG: return CaptureFormat::JPG; case config::Capture::Format::TGA: return CaptureFormat::TGA; default: throw std::logic_error("Unhandled case label"); } }(*capture.format); setCaptureFormat(f); } if (capture.range.has_value()) { _screenshot.limits = Capture::Limits(); _screenshot.limits->begin = capture.range->first; _screenshot.limits->end = capture.range->last; } } void Settings::setSwapInterval(int val) { _swapInterval = val; } int Settings::swapInterval() const { return _swapInterval; } void Settings::setRefreshRateHint(int freq) { _refreshRate = freq; } int Settings::refreshRateHint() const { return _refreshRate; } void Settings::setUseDepthTexture(bool state) { _useDepthTexture = state; } void Settings::setUseNormalTexture(bool state) { _useNormalTexture = state; } void Settings::setUsePositionTexture(bool state) { _usePositionTexture = state; } void Settings::setBufferFloatPrecision(BufferFloatPrecision bfp) { _bufferFloatPrecision = bfp; } void Settings::setNumberOfCaptureThreads(int count) { if (count <= 0) { Log::Error("Only positive number of capture threads allowed"); } else { _nCaptureThreads = count; } } bool Settings::useDepthTexture() const { return _useDepthTexture; } bool Settings::useNormalTexture() const { return _useNormalTexture; } bool Settings::usePositionTexture() const { return _usePositionTexture; } int Settings::numberCaptureThreads() const { return _nCaptureThreads; } Settings::DrawBufferType Settings::drawBufferType() const { if (_usePositionTexture) { if (_useNormalTexture) { return DrawBufferType::DiffuseNormalPosition; } else { return DrawBufferType::DiffusePosition; } } else { if (_useNormalTexture) { return DrawBufferType::DiffuseNormal; } else { return DrawBufferType::Diffuse; } } } void Settings::setCapturePath(std::string path) { if (path != _screenshot.capturePath) { // If we set a new path, we want to start counting from 0 again Engine::instance().setScreenShotNumber(0); } _screenshot.capturePath = std::move(path); } void Settings::setCaptureFormat(CaptureFormat format) { _captureFormat = format; } void Settings::setScreenshotPrefix(std::string prefix) { _screenshot.prefix = std::move(prefix); } const std::string& Settings::capturePath() const { return _screenshot.capturePath; } Settings::CaptureFormat Settings::captureFormat() const { return _captureFormat; } void Settings::setCaptureFromBackBuffer(bool state) { _captureBackBuffer = state; } void Settings::setExportWarpingMeshes(bool state) { _exportWarpingMeshes = state; } void Settings::setAddNodeNameToScreenshot(bool state) { _screenshot.addNodeName = state; } void Settings::setAddWindowNameToScreenshot(bool state) { _screenshot.addWindowName = state; } bool Settings::exportWarpingMeshes() const { return _exportWarpingMeshes; } bool Settings::captureFromBackBuffer() const { return _captureBackBuffer; } unsigned int Settings::bufferFloatPrecision() const { return _bufferFloatPrecision == BufferFloatPrecision::Float16Bit ? GL_RGB16F : GL_RGB32F; } bool Settings::addNodeNameToScreenshot() const { return _screenshot.addNodeName; } bool Settings::addWindowNameToScreenshot() const { return _screenshot.addWindowName; } const std::string& Settings::prefixScreenshot() const { return _screenshot.prefix; } bool Settings::hasScreenshotLimit() const { return _screenshot.limits.has_value(); } uint64_t Settings::screenshotLimitBegin() const { return _screenshot.limits.has_value() ? _screenshot.limits->begin : std::numeric_limits<uint64_t>::min(); } uint64_t Settings::screenshotLimitEnd() const { return _screenshot.limits.has_value() ? _screenshot.limits->end : std::numeric_limits<uint64_t>::max(); } } // namespace sgct
; ReadControllers ; Ring counters are used to store controller button state in the address 'Controller<N>' ; Adapted from https://wiki.nesdev.com/w/index.php/Controller_Reading .IF NUMBER_OF_PLAYERS!=0 ReadControllers: ; Set the strobe bit to get controller status LDA #$01 STA CONTROLLER_REGISTER_1 .IF NUMBER_OF_PLAYERS==1 STA Controller1 .ELSE STA Controller2 .ENDIF ; Clear the strobe bit to keep the controller status steady LSR a ; A is now 0 STA CONTROLLER_REGISTER_1 ; Clear the strobe bit - ; Loop to read the controller status LDA CONTROLLER_REGISTER_1 LSR a ; a[0] bit -> Carry ROL Controller1 ; Carry -> a[0] bit and a[7] bit -> Carry .IF NUMBER_OF_PLAYERS==2 LDA CONTROLLER_REGISTER_2 LSR a ; a[0] bit -> Carry ROL Controller2 ; Carry -> a[0] bit and a[7] bit -> Carry .ENDIF BCC - RTS .ENDIF
[BITS 16] [ORG 0] sectors equ 1 interrupt equ 0x13 fallback equ 0xa7 %include 'tests/bios_patches/interrupt_patch.asm' interrupt_handler: pushf cmp ah,0x42 ; ah=0x42 is disk read, which we want to fail je fail popf jmp fallback_handler fail: push bp mov bp,sp or word[ss:bp+8],1 pop bp popf iret ; Padding times (512*sectors)-($-$$)-1 db 0
############################################################################### # 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. ############################################################################### .text .p2align 5, 0x90 bswap128: .byte 3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12 rol_32_8: .byte 3,0,1,2, 7,4,5,6, 11,8,9,10, 15,12,13,14 bcast: .byte 0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3 wzzz: .byte 0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80, 0x80,0x80,0x80,0x80,12,13,14,15 .p2align 5, 0x90 .globl _UpdateSM3 _UpdateSM3: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 sub $(56), %rsp movslq %edx, %rdx movdqa bswap128(%rip), %xmm4 movdqa wzzz(%rip), %xmm7 movdqa bcast(%rip), %xmm8 movdqa rol_32_8(%rip), %xmm9 movq %rdi, (32)(%rsp) movq %rdx, (40)(%rsp) .p2align 5, 0x90 .Lsm3_loopgas_1: vmovdqu (%rsi), %xmm0 vpshufb %xmm4, %xmm0, %xmm0 vmovdqu (16)(%rsi), %xmm1 vpshufb %xmm4, %xmm1, %xmm1 vmovdqu (32)(%rsi), %xmm2 vpshufb %xmm4, %xmm2, %xmm2 vmovdqu (48)(%rsi), %xmm3 vpshufb %xmm4, %xmm3, %xmm3 add $(64), %rsi mov (%rdi), %r8d mov (4)(%rdi), %r9d mov (8)(%rdi), %r10d mov (12)(%rdi), %r11d mov (16)(%rdi), %r12d mov (20)(%rdi), %r13d mov (24)(%rdi), %r14d mov (28)(%rdi), %r15d vmovdqa %xmm0, (%rsp) vpxor %xmm1, %xmm0, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm0, %xmm1, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r8d, %eax mov (%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r12d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r15d, %ebx add %r11d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm3, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r9d, %ebp mov %r13d, %edx xor %r10d, %ebp xor %r14d, %edx xor %r8d, %ebp xor %r12d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r9d, %r9d shld $(19), %r13d, %r13d mov %eax, %r15d vpxor %xmm5, %xmm0, %xmm0 vpalignr $(12), %xmm1, %xmm2, %xmm5 vpxor %xmm5, %xmm0, %xmm0 mov %ebx, %r11d shld $(8), %r11d, %r11d xor %ebx, %r11d shld $(9), %r11d, %r11d xor %ebx, %r11d mov %r15d, %eax mov (4)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r11d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm0, %xmm5 vpxor %xmm0, %xmm5, %xmm5 add %r14d, %ebx add %r10d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm0, %xmm0 mov %r8d, %ebp mov %r12d, %edx xor %r9d, %ebp xor %r13d, %edx xor %r15d, %ebp xor %r11d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r8d, %r8d shld $(19), %r12d, %r12d mov %eax, %r14d mov %ebx, %r10d shld $(8), %r10d, %r10d xor %ebx, %r10d shld $(9), %r10d, %r10d xor %ebx, %r10d vpalignr $(8), %xmm2, %xmm3, %xmm5 vpxor %xmm4, %xmm0, %xmm0 vpxor %xmm5, %xmm0, %xmm0 mov %r14d, %eax mov (8)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r10d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r13d, %ebx add %r9d, %eax vpshufb %xmm8, %xmm0, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r15d, %ebp mov %r11d, %edx xor %r8d, %ebp xor %r12d, %edx xor %r14d, %ebp xor %r10d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r15d, %r15d shld $(19), %r11d, %r11d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r13d mov %ebx, %r9d shld $(8), %r9d, %r9d xor %ebx, %r9d shld $(9), %r9d, %r9d xor %ebx, %r9d mov %r13d, %eax mov (12)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r9d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r12d, %ebx add %r8d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r14d, %ebp mov %r10d, %edx xor %r15d, %ebp xor %r11d, %edx vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 xor %r13d, %ebp xor %r9d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r14d, %r14d shld $(19), %r10d, %r10d vpxor %xmm4, %xmm0, %xmm0 mov %eax, %r12d mov %ebx, %r8d shld $(8), %r8d, %r8d xor %ebx, %r8d shld $(9), %r8d, %r8d xor %ebx, %r8d vmovdqa %xmm1, (%rsp) vpxor %xmm2, %xmm1, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm1, %xmm2, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r12d, %eax mov (16)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r8d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r11d, %ebx add %r15d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm0, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r13d, %ebp mov %r9d, %edx xor %r14d, %ebp xor %r10d, %edx xor %r12d, %ebp xor %r8d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r13d, %r13d shld $(19), %r9d, %r9d mov %eax, %r11d vpxor %xmm5, %xmm1, %xmm1 vpalignr $(12), %xmm2, %xmm3, %xmm5 vpxor %xmm5, %xmm1, %xmm1 mov %ebx, %r15d shld $(8), %r15d, %r15d xor %ebx, %r15d shld $(9), %r15d, %r15d xor %ebx, %r15d mov %r11d, %eax mov (20)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r15d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm1, %xmm5 vpxor %xmm1, %xmm5, %xmm5 add %r10d, %ebx add %r14d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm1, %xmm1 mov %r12d, %ebp mov %r8d, %edx xor %r13d, %ebp xor %r9d, %edx xor %r11d, %ebp xor %r15d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r12d, %r12d shld $(19), %r8d, %r8d mov %eax, %r10d mov %ebx, %r14d shld $(8), %r14d, %r14d xor %ebx, %r14d shld $(9), %r14d, %r14d xor %ebx, %r14d vpalignr $(8), %xmm3, %xmm0, %xmm5 vpxor %xmm4, %xmm1, %xmm1 vpxor %xmm5, %xmm1, %xmm1 mov %r10d, %eax mov (24)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r14d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r9d, %ebx add %r13d, %eax vpshufb %xmm8, %xmm1, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r11d, %ebp mov %r15d, %edx xor %r12d, %ebp xor %r8d, %edx xor %r10d, %ebp xor %r14d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r11d, %r11d shld $(19), %r15d, %r15d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r9d mov %ebx, %r13d shld $(8), %r13d, %r13d xor %ebx, %r13d shld $(9), %r13d, %r13d xor %ebx, %r13d mov %r9d, %eax mov (28)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r13d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r8d, %ebx add %r12d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r10d, %ebp mov %r14d, %edx xor %r11d, %ebp xor %r15d, %edx vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 xor %r9d, %ebp xor %r13d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r10d, %r10d shld $(19), %r14d, %r14d vpxor %xmm4, %xmm1, %xmm1 mov %eax, %r8d mov %ebx, %r12d shld $(8), %r12d, %r12d xor %ebx, %r12d shld $(9), %r12d, %r12d xor %ebx, %r12d vmovdqa %xmm2, (%rsp) vpxor %xmm3, %xmm2, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm2, %xmm3, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r8d, %eax mov (32)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r12d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r15d, %ebx add %r11d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm1, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r9d, %ebp mov %r13d, %edx xor %r10d, %ebp xor %r14d, %edx xor %r8d, %ebp xor %r12d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r9d, %r9d shld $(19), %r13d, %r13d mov %eax, %r15d vpxor %xmm5, %xmm2, %xmm2 vpalignr $(12), %xmm3, %xmm0, %xmm5 vpxor %xmm5, %xmm2, %xmm2 mov %ebx, %r11d shld $(8), %r11d, %r11d xor %ebx, %r11d shld $(9), %r11d, %r11d xor %ebx, %r11d mov %r15d, %eax mov (36)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r11d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm2, %xmm5 vpxor %xmm2, %xmm5, %xmm5 add %r14d, %ebx add %r10d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm2, %xmm2 mov %r8d, %ebp mov %r12d, %edx xor %r9d, %ebp xor %r13d, %edx xor %r15d, %ebp xor %r11d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r8d, %r8d shld $(19), %r12d, %r12d mov %eax, %r14d mov %ebx, %r10d shld $(8), %r10d, %r10d xor %ebx, %r10d shld $(9), %r10d, %r10d xor %ebx, %r10d vpalignr $(8), %xmm0, %xmm1, %xmm5 vpxor %xmm4, %xmm2, %xmm2 vpxor %xmm5, %xmm2, %xmm2 mov %r14d, %eax mov (40)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r10d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r13d, %ebx add %r9d, %eax vpshufb %xmm8, %xmm2, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r15d, %ebp mov %r11d, %edx xor %r8d, %ebp xor %r12d, %edx xor %r14d, %ebp xor %r10d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r15d, %r15d shld $(19), %r11d, %r11d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r13d mov %ebx, %r9d shld $(8), %r9d, %r9d xor %ebx, %r9d shld $(9), %r9d, %r9d xor %ebx, %r9d mov %r13d, %eax mov (44)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r9d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r12d, %ebx add %r8d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r14d, %ebp mov %r10d, %edx xor %r15d, %ebp xor %r11d, %edx vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 xor %r13d, %ebp xor %r9d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r14d, %r14d shld $(19), %r10d, %r10d vpxor %xmm4, %xmm2, %xmm2 mov %eax, %r12d mov %ebx, %r8d shld $(8), %r8d, %r8d xor %ebx, %r8d shld $(9), %r8d, %r8d xor %ebx, %r8d vmovdqa %xmm3, (%rsp) vpxor %xmm0, %xmm3, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm3, %xmm0, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r12d, %eax mov (48)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r8d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r11d, %ebx add %r15d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm2, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r13d, %ebp mov %r9d, %edx xor %r14d, %ebp xor %r10d, %edx xor %r12d, %ebp xor %r8d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r13d, %r13d shld $(19), %r9d, %r9d mov %eax, %r11d vpxor %xmm5, %xmm3, %xmm3 vpalignr $(12), %xmm0, %xmm1, %xmm5 vpxor %xmm5, %xmm3, %xmm3 mov %ebx, %r15d shld $(8), %r15d, %r15d xor %ebx, %r15d shld $(9), %r15d, %r15d xor %ebx, %r15d mov %r11d, %eax mov (52)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r15d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm3, %xmm5 vpxor %xmm3, %xmm5, %xmm5 add %r10d, %ebx add %r14d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm3, %xmm3 mov %r12d, %ebp mov %r8d, %edx xor %r13d, %ebp xor %r9d, %edx xor %r11d, %ebp xor %r15d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r12d, %r12d shld $(19), %r8d, %r8d mov %eax, %r10d mov %ebx, %r14d shld $(8), %r14d, %r14d xor %ebx, %r14d shld $(9), %r14d, %r14d xor %ebx, %r14d vpalignr $(8), %xmm1, %xmm2, %xmm5 vpxor %xmm4, %xmm3, %xmm3 vpxor %xmm5, %xmm3, %xmm3 mov %r10d, %eax mov (56)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r14d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r9d, %ebx add %r13d, %eax vpshufb %xmm8, %xmm3, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r11d, %ebp mov %r15d, %edx xor %r12d, %ebp xor %r8d, %edx xor %r10d, %ebp xor %r14d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r11d, %r11d shld $(19), %r15d, %r15d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r9d mov %ebx, %r13d shld $(8), %r13d, %r13d xor %ebx, %r13d shld $(9), %r13d, %r13d xor %ebx, %r13d mov %r9d, %eax mov (60)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r13d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r8d, %ebx add %r12d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r10d, %ebp mov %r14d, %edx xor %r11d, %ebp xor %r15d, %edx vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 xor %r9d, %ebp xor %r13d, %edx add %edx, %ebx add %ebp, %eax shld $(9), %r10d, %r10d shld $(19), %r14d, %r14d vpxor %xmm4, %xmm3, %xmm3 mov %eax, %r8d mov %ebx, %r12d shld $(8), %r12d, %r12d xor %ebx, %r12d shld $(9), %r12d, %r12d xor %ebx, %r12d vmovdqa %xmm0, (%rsp) vpxor %xmm1, %xmm0, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm0, %xmm1, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r8d, %eax mov (64)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r12d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r15d, %ebx add %r11d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm3, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r9d, %edx mov %r9d, %ebp and %r10d, %edx xor %r10d, %ebp and %r8d, %ebp add %edx, %ebp mov %r13d, %edx xor %r14d, %edx and %r12d, %edx xor %r14d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r9d, %r9d shld $(19), %r13d, %r13d mov %eax, %r15d vpxor %xmm5, %xmm0, %xmm0 vpalignr $(12), %xmm1, %xmm2, %xmm5 vpxor %xmm5, %xmm0, %xmm0 mov %ebx, %r11d shld $(8), %r11d, %r11d xor %ebx, %r11d shld $(9), %r11d, %r11d xor %ebx, %r11d mov %r15d, %eax mov (68)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r11d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm0, %xmm5 vpxor %xmm0, %xmm5, %xmm5 add %r14d, %ebx add %r10d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm0, %xmm0 mov %r8d, %edx mov %r8d, %ebp and %r9d, %edx xor %r9d, %ebp and %r15d, %ebp add %edx, %ebp mov %r12d, %edx xor %r13d, %edx and %r11d, %edx xor %r13d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r8d, %r8d shld $(19), %r12d, %r12d mov %eax, %r14d mov %ebx, %r10d shld $(8), %r10d, %r10d xor %ebx, %r10d shld $(9), %r10d, %r10d xor %ebx, %r10d vpalignr $(8), %xmm2, %xmm3, %xmm5 vpxor %xmm4, %xmm0, %xmm0 vpxor %xmm5, %xmm0, %xmm0 mov %r14d, %eax mov (72)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r10d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r13d, %ebx add %r9d, %eax vpshufb %xmm8, %xmm0, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r15d, %edx mov %r15d, %ebp and %r8d, %edx xor %r8d, %ebp and %r14d, %ebp add %edx, %ebp mov %r11d, %edx xor %r12d, %edx and %r10d, %edx xor %r12d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r15d, %r15d shld $(19), %r11d, %r11d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r13d mov %ebx, %r9d shld $(8), %r9d, %r9d xor %ebx, %r9d shld $(9), %r9d, %r9d xor %ebx, %r9d mov %r13d, %eax mov (76)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r9d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r12d, %ebx add %r8d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r14d, %edx mov %r14d, %ebp and %r15d, %edx xor %r15d, %ebp and %r13d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r10d, %edx xor %r11d, %edx and %r9d, %edx xor %r11d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r14d, %r14d shld $(19), %r10d, %r10d vpxor %xmm4, %xmm0, %xmm0 mov %eax, %r12d mov %ebx, %r8d shld $(8), %r8d, %r8d xor %ebx, %r8d shld $(9), %r8d, %r8d xor %ebx, %r8d vmovdqa %xmm1, (%rsp) vpxor %xmm2, %xmm1, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm1, %xmm2, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r12d, %eax mov (80)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r8d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r11d, %ebx add %r15d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm0, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r13d, %edx mov %r13d, %ebp and %r14d, %edx xor %r14d, %ebp and %r12d, %ebp add %edx, %ebp mov %r9d, %edx xor %r10d, %edx and %r8d, %edx xor %r10d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r13d, %r13d shld $(19), %r9d, %r9d mov %eax, %r11d vpxor %xmm5, %xmm1, %xmm1 vpalignr $(12), %xmm2, %xmm3, %xmm5 vpxor %xmm5, %xmm1, %xmm1 mov %ebx, %r15d shld $(8), %r15d, %r15d xor %ebx, %r15d shld $(9), %r15d, %r15d xor %ebx, %r15d mov %r11d, %eax mov (84)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r15d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm1, %xmm5 vpxor %xmm1, %xmm5, %xmm5 add %r10d, %ebx add %r14d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm1, %xmm1 mov %r12d, %edx mov %r12d, %ebp and %r13d, %edx xor %r13d, %ebp and %r11d, %ebp add %edx, %ebp mov %r8d, %edx xor %r9d, %edx and %r15d, %edx xor %r9d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r12d, %r12d shld $(19), %r8d, %r8d mov %eax, %r10d mov %ebx, %r14d shld $(8), %r14d, %r14d xor %ebx, %r14d shld $(9), %r14d, %r14d xor %ebx, %r14d vpalignr $(8), %xmm3, %xmm0, %xmm5 vpxor %xmm4, %xmm1, %xmm1 vpxor %xmm5, %xmm1, %xmm1 mov %r10d, %eax mov (88)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r14d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r9d, %ebx add %r13d, %eax vpshufb %xmm8, %xmm1, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r11d, %edx mov %r11d, %ebp and %r12d, %edx xor %r12d, %ebp and %r10d, %ebp add %edx, %ebp mov %r15d, %edx xor %r8d, %edx and %r14d, %edx xor %r8d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r11d, %r11d shld $(19), %r15d, %r15d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r9d mov %ebx, %r13d shld $(8), %r13d, %r13d xor %ebx, %r13d shld $(9), %r13d, %r13d xor %ebx, %r13d mov %r9d, %eax mov (92)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r13d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r8d, %ebx add %r12d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r10d, %edx mov %r10d, %ebp and %r11d, %edx xor %r11d, %ebp and %r9d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r14d, %edx xor %r15d, %edx and %r13d, %edx xor %r15d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r10d, %r10d shld $(19), %r14d, %r14d vpxor %xmm4, %xmm1, %xmm1 mov %eax, %r8d mov %ebx, %r12d shld $(8), %r12d, %r12d xor %ebx, %r12d shld $(9), %r12d, %r12d xor %ebx, %r12d vmovdqa %xmm2, (%rsp) vpxor %xmm3, %xmm2, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm2, %xmm3, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r8d, %eax mov (96)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r12d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r15d, %ebx add %r11d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm1, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r9d, %edx mov %r9d, %ebp and %r10d, %edx xor %r10d, %ebp and %r8d, %ebp add %edx, %ebp mov %r13d, %edx xor %r14d, %edx and %r12d, %edx xor %r14d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r9d, %r9d shld $(19), %r13d, %r13d mov %eax, %r15d vpxor %xmm5, %xmm2, %xmm2 vpalignr $(12), %xmm3, %xmm0, %xmm5 vpxor %xmm5, %xmm2, %xmm2 mov %ebx, %r11d shld $(8), %r11d, %r11d xor %ebx, %r11d shld $(9), %r11d, %r11d xor %ebx, %r11d mov %r15d, %eax mov (100)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r11d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm2, %xmm5 vpxor %xmm2, %xmm5, %xmm5 add %r14d, %ebx add %r10d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm2, %xmm2 mov %r8d, %edx mov %r8d, %ebp and %r9d, %edx xor %r9d, %ebp and %r15d, %ebp add %edx, %ebp mov %r12d, %edx xor %r13d, %edx and %r11d, %edx xor %r13d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r8d, %r8d shld $(19), %r12d, %r12d mov %eax, %r14d mov %ebx, %r10d shld $(8), %r10d, %r10d xor %ebx, %r10d shld $(9), %r10d, %r10d xor %ebx, %r10d vpalignr $(8), %xmm0, %xmm1, %xmm5 vpxor %xmm4, %xmm2, %xmm2 vpxor %xmm5, %xmm2, %xmm2 mov %r14d, %eax mov (104)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r10d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r13d, %ebx add %r9d, %eax vpshufb %xmm8, %xmm2, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r15d, %edx mov %r15d, %ebp and %r8d, %edx xor %r8d, %ebp and %r14d, %ebp add %edx, %ebp mov %r11d, %edx xor %r12d, %edx and %r10d, %edx xor %r12d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r15d, %r15d shld $(19), %r11d, %r11d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r13d mov %ebx, %r9d shld $(8), %r9d, %r9d xor %ebx, %r9d shld $(9), %r9d, %r9d xor %ebx, %r9d mov %r13d, %eax mov (108)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r9d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r12d, %ebx add %r8d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r14d, %edx mov %r14d, %ebp and %r15d, %edx xor %r15d, %ebp and %r13d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r10d, %edx xor %r11d, %edx and %r9d, %edx xor %r11d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r14d, %r14d shld $(19), %r10d, %r10d vpxor %xmm4, %xmm2, %xmm2 mov %eax, %r12d mov %ebx, %r8d shld $(8), %r8d, %r8d xor %ebx, %r8d shld $(9), %r8d, %r8d xor %ebx, %r8d vmovdqa %xmm3, (%rsp) vpxor %xmm0, %xmm3, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm3, %xmm0, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r12d, %eax mov (112)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r8d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r11d, %ebx add %r15d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm2, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r13d, %edx mov %r13d, %ebp and %r14d, %edx xor %r14d, %ebp and %r12d, %ebp add %edx, %ebp mov %r9d, %edx xor %r10d, %edx and %r8d, %edx xor %r10d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r13d, %r13d shld $(19), %r9d, %r9d mov %eax, %r11d vpxor %xmm5, %xmm3, %xmm3 vpalignr $(12), %xmm0, %xmm1, %xmm5 vpxor %xmm5, %xmm3, %xmm3 mov %ebx, %r15d shld $(8), %r15d, %r15d xor %ebx, %r15d shld $(9), %r15d, %r15d xor %ebx, %r15d mov %r11d, %eax mov (116)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r15d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm3, %xmm5 vpxor %xmm3, %xmm5, %xmm5 add %r10d, %ebx add %r14d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm3, %xmm3 mov %r12d, %edx mov %r12d, %ebp and %r13d, %edx xor %r13d, %ebp and %r11d, %ebp add %edx, %ebp mov %r8d, %edx xor %r9d, %edx and %r15d, %edx xor %r9d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r12d, %r12d shld $(19), %r8d, %r8d mov %eax, %r10d mov %ebx, %r14d shld $(8), %r14d, %r14d xor %ebx, %r14d shld $(9), %r14d, %r14d xor %ebx, %r14d vpalignr $(8), %xmm1, %xmm2, %xmm5 vpxor %xmm4, %xmm3, %xmm3 vpxor %xmm5, %xmm3, %xmm3 mov %r10d, %eax mov (120)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r14d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r9d, %ebx add %r13d, %eax vpshufb %xmm8, %xmm3, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r11d, %edx mov %r11d, %ebp and %r12d, %edx xor %r12d, %ebp and %r10d, %ebp add %edx, %ebp mov %r15d, %edx xor %r8d, %edx and %r14d, %edx xor %r8d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r11d, %r11d shld $(19), %r15d, %r15d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r9d mov %ebx, %r13d shld $(8), %r13d, %r13d xor %ebx, %r13d shld $(9), %r13d, %r13d xor %ebx, %r13d mov %r9d, %eax mov (124)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r13d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r8d, %ebx add %r12d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r10d, %edx mov %r10d, %ebp and %r11d, %edx xor %r11d, %ebp and %r9d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r14d, %edx xor %r15d, %edx and %r13d, %edx xor %r15d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r10d, %r10d shld $(19), %r14d, %r14d vpxor %xmm4, %xmm3, %xmm3 mov %eax, %r8d mov %ebx, %r12d shld $(8), %r12d, %r12d xor %ebx, %r12d shld $(9), %r12d, %r12d xor %ebx, %r12d vmovdqa %xmm0, (%rsp) vpxor %xmm1, %xmm0, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm0, %xmm1, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r8d, %eax mov (128)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r12d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r15d, %ebx add %r11d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm3, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r9d, %edx mov %r9d, %ebp and %r10d, %edx xor %r10d, %ebp and %r8d, %ebp add %edx, %ebp mov %r13d, %edx xor %r14d, %edx and %r12d, %edx xor %r14d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r9d, %r9d shld $(19), %r13d, %r13d mov %eax, %r15d vpxor %xmm5, %xmm0, %xmm0 vpalignr $(12), %xmm1, %xmm2, %xmm5 vpxor %xmm5, %xmm0, %xmm0 mov %ebx, %r11d shld $(8), %r11d, %r11d xor %ebx, %r11d shld $(9), %r11d, %r11d xor %ebx, %r11d mov %r15d, %eax mov (132)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r11d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm0, %xmm5 vpxor %xmm0, %xmm5, %xmm5 add %r14d, %ebx add %r10d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm0, %xmm0 mov %r8d, %edx mov %r8d, %ebp and %r9d, %edx xor %r9d, %ebp and %r15d, %ebp add %edx, %ebp mov %r12d, %edx xor %r13d, %edx and %r11d, %edx xor %r13d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r8d, %r8d shld $(19), %r12d, %r12d mov %eax, %r14d mov %ebx, %r10d shld $(8), %r10d, %r10d xor %ebx, %r10d shld $(9), %r10d, %r10d xor %ebx, %r10d vpalignr $(8), %xmm2, %xmm3, %xmm5 vpxor %xmm4, %xmm0, %xmm0 vpxor %xmm5, %xmm0, %xmm0 mov %r14d, %eax mov (136)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r10d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r13d, %ebx add %r9d, %eax vpshufb %xmm8, %xmm0, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r15d, %edx mov %r15d, %ebp and %r8d, %edx xor %r8d, %ebp and %r14d, %ebp add %edx, %ebp mov %r11d, %edx xor %r12d, %edx and %r10d, %edx xor %r12d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r15d, %r15d shld $(19), %r11d, %r11d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r13d mov %ebx, %r9d shld $(8), %r9d, %r9d xor %ebx, %r9d shld $(9), %r9d, %r9d xor %ebx, %r9d mov %r13d, %eax mov (140)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r9d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r12d, %ebx add %r8d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r14d, %edx mov %r14d, %ebp and %r15d, %edx xor %r15d, %ebp and %r13d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r10d, %edx xor %r11d, %edx and %r9d, %edx xor %r11d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r14d, %r14d shld $(19), %r10d, %r10d vpxor %xmm4, %xmm0, %xmm0 mov %eax, %r12d mov %ebx, %r8d shld $(8), %r8d, %r8d xor %ebx, %r8d shld $(9), %r8d, %r8d xor %ebx, %r8d vmovdqa %xmm1, (%rsp) vpxor %xmm2, %xmm1, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm1, %xmm2, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r12d, %eax mov (144)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r8d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r11d, %ebx add %r15d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm0, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r13d, %edx mov %r13d, %ebp and %r14d, %edx xor %r14d, %ebp and %r12d, %ebp add %edx, %ebp mov %r9d, %edx xor %r10d, %edx and %r8d, %edx xor %r10d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r13d, %r13d shld $(19), %r9d, %r9d mov %eax, %r11d vpxor %xmm5, %xmm1, %xmm1 vpalignr $(12), %xmm2, %xmm3, %xmm5 vpxor %xmm5, %xmm1, %xmm1 mov %ebx, %r15d shld $(8), %r15d, %r15d xor %ebx, %r15d shld $(9), %r15d, %r15d xor %ebx, %r15d mov %r11d, %eax mov (148)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r15d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm1, %xmm5 vpxor %xmm1, %xmm5, %xmm5 add %r10d, %ebx add %r14d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm1, %xmm1 mov %r12d, %edx mov %r12d, %ebp and %r13d, %edx xor %r13d, %ebp and %r11d, %ebp add %edx, %ebp mov %r8d, %edx xor %r9d, %edx and %r15d, %edx xor %r9d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r12d, %r12d shld $(19), %r8d, %r8d mov %eax, %r10d mov %ebx, %r14d shld $(8), %r14d, %r14d xor %ebx, %r14d shld $(9), %r14d, %r14d xor %ebx, %r14d vpalignr $(8), %xmm3, %xmm0, %xmm5 vpxor %xmm4, %xmm1, %xmm1 vpxor %xmm5, %xmm1, %xmm1 mov %r10d, %eax mov (152)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r14d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r9d, %ebx add %r13d, %eax vpshufb %xmm8, %xmm1, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r11d, %edx mov %r11d, %ebp and %r12d, %edx xor %r12d, %ebp and %r10d, %ebp add %edx, %ebp mov %r15d, %edx xor %r8d, %edx and %r14d, %edx xor %r8d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r11d, %r11d shld $(19), %r15d, %r15d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r9d mov %ebx, %r13d shld $(8), %r13d, %r13d xor %ebx, %r13d shld $(9), %r13d, %r13d xor %ebx, %r13d mov %r9d, %eax mov (156)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r13d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r8d, %ebx add %r12d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r10d, %edx mov %r10d, %ebp and %r11d, %edx xor %r11d, %ebp and %r9d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r14d, %edx xor %r15d, %edx and %r13d, %edx xor %r15d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r10d, %r10d shld $(19), %r14d, %r14d vpxor %xmm4, %xmm1, %xmm1 mov %eax, %r8d mov %ebx, %r12d shld $(8), %r12d, %r12d xor %ebx, %r12d shld $(9), %r12d, %r12d xor %ebx, %r12d vmovdqa %xmm2, (%rsp) vpxor %xmm3, %xmm2, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm2, %xmm3, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r8d, %eax mov (160)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r12d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r15d, %ebx add %r11d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm1, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r9d, %edx mov %r9d, %ebp and %r10d, %edx xor %r10d, %ebp and %r8d, %ebp add %edx, %ebp mov %r13d, %edx xor %r14d, %edx and %r12d, %edx xor %r14d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r9d, %r9d shld $(19), %r13d, %r13d mov %eax, %r15d vpxor %xmm5, %xmm2, %xmm2 vpalignr $(12), %xmm3, %xmm0, %xmm5 vpxor %xmm5, %xmm2, %xmm2 mov %ebx, %r11d shld $(8), %r11d, %r11d xor %ebx, %r11d shld $(9), %r11d, %r11d xor %ebx, %r11d mov %r15d, %eax mov (164)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r11d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm2, %xmm5 vpxor %xmm2, %xmm5, %xmm5 add %r14d, %ebx add %r10d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm2, %xmm2 mov %r8d, %edx mov %r8d, %ebp and %r9d, %edx xor %r9d, %ebp and %r15d, %ebp add %edx, %ebp mov %r12d, %edx xor %r13d, %edx and %r11d, %edx xor %r13d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r8d, %r8d shld $(19), %r12d, %r12d mov %eax, %r14d mov %ebx, %r10d shld $(8), %r10d, %r10d xor %ebx, %r10d shld $(9), %r10d, %r10d xor %ebx, %r10d vpalignr $(8), %xmm0, %xmm1, %xmm5 vpxor %xmm4, %xmm2, %xmm2 vpxor %xmm5, %xmm2, %xmm2 mov %r14d, %eax mov (168)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r10d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r13d, %ebx add %r9d, %eax vpshufb %xmm8, %xmm2, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r15d, %edx mov %r15d, %ebp and %r8d, %edx xor %r8d, %ebp and %r14d, %ebp add %edx, %ebp mov %r11d, %edx xor %r12d, %edx and %r10d, %edx xor %r12d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r15d, %r15d shld $(19), %r11d, %r11d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r13d mov %ebx, %r9d shld $(8), %r9d, %r9d xor %ebx, %r9d shld $(9), %r9d, %r9d xor %ebx, %r9d mov %r13d, %eax mov (172)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r9d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r12d, %ebx add %r8d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r14d, %edx mov %r14d, %ebp and %r15d, %edx xor %r15d, %ebp and %r13d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r10d, %edx xor %r11d, %edx and %r9d, %edx xor %r11d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r14d, %r14d shld $(19), %r10d, %r10d vpxor %xmm4, %xmm2, %xmm2 mov %eax, %r12d mov %ebx, %r8d shld $(8), %r8d, %r8d xor %ebx, %r8d shld $(9), %r8d, %r8d xor %ebx, %r8d vmovdqa %xmm3, (%rsp) vpxor %xmm0, %xmm3, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm3, %xmm0, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r12d, %eax mov (176)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r8d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r11d, %ebx add %r15d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm2, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r13d, %edx mov %r13d, %ebp and %r14d, %edx xor %r14d, %ebp and %r12d, %ebp add %edx, %ebp mov %r9d, %edx xor %r10d, %edx and %r8d, %edx xor %r10d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r13d, %r13d shld $(19), %r9d, %r9d mov %eax, %r11d vpxor %xmm5, %xmm3, %xmm3 vpalignr $(12), %xmm0, %xmm1, %xmm5 vpxor %xmm5, %xmm3, %xmm3 mov %ebx, %r15d shld $(8), %r15d, %r15d xor %ebx, %r15d shld $(9), %r15d, %r15d xor %ebx, %r15d mov %r11d, %eax mov (180)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r15d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm3, %xmm5 vpxor %xmm3, %xmm5, %xmm5 add %r10d, %ebx add %r14d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm3, %xmm3 mov %r12d, %edx mov %r12d, %ebp and %r13d, %edx xor %r13d, %ebp and %r11d, %ebp add %edx, %ebp mov %r8d, %edx xor %r9d, %edx and %r15d, %edx xor %r9d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r12d, %r12d shld $(19), %r8d, %r8d mov %eax, %r10d mov %ebx, %r14d shld $(8), %r14d, %r14d xor %ebx, %r14d shld $(9), %r14d, %r14d xor %ebx, %r14d vpalignr $(8), %xmm1, %xmm2, %xmm5 vpxor %xmm4, %xmm3, %xmm3 vpxor %xmm5, %xmm3, %xmm3 mov %r10d, %eax mov (184)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r14d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r9d, %ebx add %r13d, %eax vpshufb %xmm8, %xmm3, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r11d, %edx mov %r11d, %ebp and %r12d, %edx xor %r12d, %ebp and %r10d, %ebp add %edx, %ebp mov %r15d, %edx xor %r8d, %edx and %r14d, %edx xor %r8d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r11d, %r11d shld $(19), %r15d, %r15d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r9d mov %ebx, %r13d shld $(8), %r13d, %r13d xor %ebx, %r13d shld $(9), %r13d, %r13d xor %ebx, %r13d mov %r9d, %eax mov (188)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r13d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r8d, %ebx add %r12d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r10d, %edx mov %r10d, %ebp and %r11d, %edx xor %r11d, %ebp and %r9d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r14d, %edx xor %r15d, %edx and %r13d, %edx xor %r15d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r10d, %r10d shld $(19), %r14d, %r14d vpxor %xmm4, %xmm3, %xmm3 mov %eax, %r8d mov %ebx, %r12d shld $(8), %r12d, %r12d xor %ebx, %r12d shld $(9), %r12d, %r12d xor %ebx, %r12d vmovdqa %xmm0, (%rsp) vpxor %xmm1, %xmm0, %xmm4 vmovdqa %xmm4, (16)(%rsp) vpalignr $(12), %xmm0, %xmm1, %xmm4 vpslld $(7), %xmm4, %xmm6 vpsrld $(25), %xmm4, %xmm4 vpxor %xmm6, %xmm4, %xmm4 mov %r8d, %eax mov (192)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r12d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r15d, %ebx add %r11d, %eax add (%rsp), %ebx add (16)(%rsp), %eax vpsrldq $(4), %xmm3, %xmm5 vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 mov %r9d, %edx mov %r9d, %ebp and %r10d, %edx xor %r10d, %ebp and %r8d, %ebp add %edx, %ebp mov %r13d, %edx xor %r14d, %edx and %r12d, %edx xor %r14d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r9d, %r9d shld $(19), %r13d, %r13d mov %eax, %r15d vpxor %xmm5, %xmm0, %xmm0 vpalignr $(12), %xmm1, %xmm2, %xmm5 vpxor %xmm5, %xmm0, %xmm0 mov %ebx, %r11d shld $(8), %r11d, %r11d xor %ebx, %r11d shld $(9), %r11d, %r11d xor %ebx, %r11d mov %r15d, %eax mov (196)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r11d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpshufb %xmm9, %xmm0, %xmm5 vpxor %xmm0, %xmm5, %xmm5 add %r14d, %ebx add %r10d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax vpslld $(15), %xmm5, %xmm6 vpsrld $(17), %xmm5, %xmm5 vpxor %xmm6, %xmm5, %xmm5 vpxor %xmm5, %xmm0, %xmm0 mov %r8d, %edx mov %r8d, %ebp and %r9d, %edx xor %r9d, %ebp and %r15d, %ebp add %edx, %ebp mov %r12d, %edx xor %r13d, %edx and %r11d, %edx xor %r13d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r8d, %r8d shld $(19), %r12d, %r12d mov %eax, %r14d mov %ebx, %r10d shld $(8), %r10d, %r10d xor %ebx, %r10d shld $(9), %r10d, %r10d xor %ebx, %r10d vpalignr $(8), %xmm2, %xmm3, %xmm5 vpxor %xmm4, %xmm0, %xmm0 vpxor %xmm5, %xmm0, %xmm0 mov %r14d, %eax mov (200)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r10d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r13d, %ebx add %r9d, %eax vpshufb %xmm8, %xmm0, %xmm4 vpsrlq $(17), %xmm4, %xmm4 add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r15d, %edx mov %r15d, %ebp and %r8d, %edx xor %r8d, %ebp and %r14d, %ebp add %edx, %ebp mov %r11d, %edx xor %r12d, %edx and %r10d, %edx xor %r12d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r15d, %r15d shld $(19), %r11d, %r11d vpshufb %xmm8, %xmm4, %xmm4 vpsllq $(15), %xmm4, %xmm5 mov %eax, %r13d mov %ebx, %r9d shld $(8), %r9d, %r9d xor %ebx, %r9d shld $(9), %r9d, %r9d xor %ebx, %r9d mov %r13d, %eax mov (204)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r9d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax vpxor %xmm5, %xmm4, %xmm4 vpsllq $(8), %xmm5, %xmm5 add %r12d, %ebx add %r8d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r14d, %edx mov %r14d, %ebp and %r15d, %edx xor %r15d, %ebp and %r13d, %ebp add %edx, %ebp vpxor %xmm5, %xmm4, %xmm4 vpshufb %xmm7, %xmm4, %xmm4 mov %r10d, %edx xor %r11d, %edx and %r9d, %edx xor %r11d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r14d, %r14d shld $(19), %r10d, %r10d vpxor %xmm4, %xmm0, %xmm0 mov %eax, %r12d mov %ebx, %r8d shld $(8), %r8d, %r8d xor %ebx, %r8d shld $(9), %r8d, %r8d xor %ebx, %r8d vmovdqa %xmm1, (%rsp) vpxor %xmm2, %xmm1, %xmm4 vmovdqa %xmm4, (16)(%rsp) mov %r12d, %eax mov (208)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r8d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r11d, %ebx add %r15d, %eax add (%rsp), %ebx add (16)(%rsp), %eax mov %r13d, %edx mov %r13d, %ebp and %r14d, %edx xor %r14d, %ebp and %r12d, %ebp add %edx, %ebp mov %r9d, %edx xor %r10d, %edx and %r8d, %edx xor %r10d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r13d, %r13d shld $(19), %r9d, %r9d mov %eax, %r11d mov %ebx, %r15d shld $(8), %r15d, %r15d xor %ebx, %r15d shld $(9), %r15d, %r15d xor %ebx, %r15d mov %r11d, %eax mov (212)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r15d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r10d, %ebx add %r14d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax mov %r12d, %edx mov %r12d, %ebp and %r13d, %edx xor %r13d, %ebp and %r11d, %ebp add %edx, %ebp mov %r8d, %edx xor %r9d, %edx and %r15d, %edx xor %r9d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r12d, %r12d shld $(19), %r8d, %r8d mov %eax, %r10d mov %ebx, %r14d shld $(8), %r14d, %r14d xor %ebx, %r14d shld $(9), %r14d, %r14d xor %ebx, %r14d mov %r10d, %eax mov (216)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r14d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r9d, %ebx add %r13d, %eax add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r11d, %edx mov %r11d, %ebp and %r12d, %edx xor %r12d, %ebp and %r10d, %ebp add %edx, %ebp mov %r15d, %edx xor %r8d, %edx and %r14d, %edx xor %r8d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r11d, %r11d shld $(19), %r15d, %r15d mov %eax, %r9d mov %ebx, %r13d shld $(8), %r13d, %r13d xor %ebx, %r13d shld $(9), %r13d, %r13d xor %ebx, %r13d mov %r9d, %eax mov (220)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r13d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r8d, %ebx add %r12d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r10d, %edx mov %r10d, %ebp and %r11d, %edx xor %r11d, %ebp and %r9d, %ebp add %edx, %ebp mov %r14d, %edx xor %r15d, %edx and %r13d, %edx xor %r15d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r10d, %r10d shld $(19), %r14d, %r14d mov %eax, %r8d mov %ebx, %r12d shld $(8), %r12d, %r12d xor %ebx, %r12d shld $(9), %r12d, %r12d xor %ebx, %r12d vmovdqa %xmm2, (%rsp) vpxor %xmm3, %xmm2, %xmm4 vmovdqa %xmm4, (16)(%rsp) mov %r8d, %eax mov (224)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r12d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r15d, %ebx add %r11d, %eax add (%rsp), %ebx add (16)(%rsp), %eax mov %r9d, %edx mov %r9d, %ebp and %r10d, %edx xor %r10d, %ebp and %r8d, %ebp add %edx, %ebp mov %r13d, %edx xor %r14d, %edx and %r12d, %edx xor %r14d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r9d, %r9d shld $(19), %r13d, %r13d mov %eax, %r15d mov %ebx, %r11d shld $(8), %r11d, %r11d xor %ebx, %r11d shld $(9), %r11d, %r11d xor %ebx, %r11d mov %r15d, %eax mov (228)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r11d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r14d, %ebx add %r10d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax mov %r8d, %edx mov %r8d, %ebp and %r9d, %edx xor %r9d, %ebp and %r15d, %ebp add %edx, %ebp mov %r12d, %edx xor %r13d, %edx and %r11d, %edx xor %r13d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r8d, %r8d shld $(19), %r12d, %r12d mov %eax, %r14d mov %ebx, %r10d shld $(8), %r10d, %r10d xor %ebx, %r10d shld $(9), %r10d, %r10d xor %ebx, %r10d mov %r14d, %eax mov (232)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r10d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r13d, %ebx add %r9d, %eax add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r15d, %edx mov %r15d, %ebp and %r8d, %edx xor %r8d, %ebp and %r14d, %ebp add %edx, %ebp mov %r11d, %edx xor %r12d, %edx and %r10d, %edx xor %r12d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r15d, %r15d shld $(19), %r11d, %r11d mov %eax, %r13d mov %ebx, %r9d shld $(8), %r9d, %r9d xor %ebx, %r9d shld $(9), %r9d, %r9d xor %ebx, %r9d mov %r13d, %eax mov (236)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r9d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r12d, %ebx add %r8d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r14d, %edx mov %r14d, %ebp and %r15d, %edx xor %r15d, %ebp and %r13d, %ebp add %edx, %ebp mov %r10d, %edx xor %r11d, %edx and %r9d, %edx xor %r11d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r14d, %r14d shld $(19), %r10d, %r10d mov %eax, %r12d mov %ebx, %r8d shld $(8), %r8d, %r8d xor %ebx, %r8d shld $(9), %r8d, %r8d xor %ebx, %r8d vmovdqa %xmm3, (%rsp) vpxor %xmm0, %xmm3, %xmm4 vmovdqa %xmm4, (16)(%rsp) mov %r12d, %eax mov (240)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r8d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r11d, %ebx add %r15d, %eax add (%rsp), %ebx add (16)(%rsp), %eax mov %r13d, %edx mov %r13d, %ebp and %r14d, %edx xor %r14d, %ebp and %r12d, %ebp add %edx, %ebp mov %r9d, %edx xor %r10d, %edx and %r8d, %edx xor %r10d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r13d, %r13d shld $(19), %r9d, %r9d mov %eax, %r11d mov %ebx, %r15d shld $(8), %r15d, %r15d xor %ebx, %r15d shld $(9), %r15d, %r15d xor %ebx, %r15d mov %r11d, %eax mov (244)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r15d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r10d, %ebx add %r14d, %eax add (4)(%rsp), %ebx add (20)(%rsp), %eax mov %r12d, %edx mov %r12d, %ebp and %r13d, %edx xor %r13d, %ebp and %r11d, %ebp add %edx, %ebp mov %r8d, %edx xor %r9d, %edx and %r15d, %edx xor %r9d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r12d, %r12d shld $(19), %r8d, %r8d mov %eax, %r10d mov %ebx, %r14d shld $(8), %r14d, %r14d xor %ebx, %r14d shld $(9), %r14d, %r14d xor %ebx, %r14d mov %r10d, %eax mov (248)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r14d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r9d, %ebx add %r13d, %eax add (8)(%rsp), %ebx add (24)(%rsp), %eax mov %r11d, %edx mov %r11d, %ebp and %r12d, %edx xor %r12d, %ebp and %r10d, %ebp add %edx, %ebp mov %r15d, %edx xor %r8d, %edx and %r14d, %edx xor %r8d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r11d, %r11d shld $(19), %r15d, %r15d mov %eax, %r9d mov %ebx, %r13d shld $(8), %r13d, %r13d xor %ebx, %r13d shld $(9), %r13d, %r13d xor %ebx, %r13d mov %r9d, %eax mov (252)(%rcx), %ebx shld $(12), %eax, %eax add %eax, %ebx add %r13d, %ebx shld $(7), %ebx, %ebx xor %ebx, %eax add %r8d, %ebx add %r12d, %eax add (12)(%rsp), %ebx add (28)(%rsp), %eax mov %r10d, %edx mov %r10d, %ebp and %r11d, %edx xor %r11d, %ebp and %r9d, %ebp add %edx, %ebp mov %r14d, %edx xor %r15d, %edx and %r13d, %edx xor %r15d, %edx add %ebp, %eax add %edx, %ebx shld $(9), %r10d, %r10d shld $(19), %r14d, %r14d mov %eax, %r8d mov %ebx, %r12d shld $(8), %r12d, %r12d xor %ebx, %r12d shld $(9), %r12d, %r12d xor %ebx, %r12d movq (32)(%rsp), %rdi xor %r8d, (%rdi) xor %r9d, (4)(%rdi) xor %r10d, (8)(%rdi) xor %r11d, (12)(%rdi) xor %r12d, (16)(%rdi) xor %r13d, (20)(%rdi) xor %r14d, (24)(%rdi) xor %r15d, (28)(%rdi) movdqa bswap128(%rip), %xmm4 subq $(64), (40)(%rsp) cmpq $(64), (40)(%rsp) jge .Lsm3_loopgas_1 add $(56), %rsp vzeroupper pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret
; stub.asm ; Copyright 2020 Robin Verhagen-Guest ; ; 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. LowerCodeStart equ Start ; This marks the end of the lower 8K of the dot command which is loaded LowerCodeLen equ $-Start ; automatically by NextZXOS. LowerCodeLen should always be smaller than $2000. align $8000 ; This section of the file is padded to start 8KB after the dot command and disp -$4000 UpperCodeStart: ; after allocating and paging two new 8K banks from NextZXOS. ESP8266StubText: import_bin "..\\..\\fw\\ESP8266_FULL_V3.3_SPUGS\\ESP8266_stub_text.bin" ESP8266StubTextLen equ $-1 ESP8266StubData: import_bin "..\\..\\fw\\ESP8266_FULL_V3.3_SPUGS\\ESP8266_stub_data.bin" ESP8266StubDataLen equ $-1 ; Anything after here has addresses allocated, but doesn't get appended to the dot command during assembly. ; It does, however, get padded to 24K by AppendFW.exe. Buffer proc ds 1024 Len equ $-Buffer pend Header proc Buffer: ds 1024 Len equ $-Header pend
.MODEL SMALL .STACK 100H .DATA PROMPT DB 'ENTER THE DIGIT:$' MSG DB 'THE ENTER DIGIT IS:$' .CODE MAIN PROC MOV AX, @DATA MOV DS, AX LEA DX, PROMPT MOV AH, 9 INT 21H MOV AH, 1 INT 21H MOV BL, AL MOV AH, 2 MOV DL, 0DH INT 21H MOV DL, 0AH INT 21H LEA DX, MSG MOV AH, 9 INT 21H CMP BL, 30H JZ @ZERO JG @POSITIVE JL @NEGATIVE @ZERO: MOV DL, 'Z' JMP @PRINT @POSITIVE: MOV DL, 'P' JMP @PRINT @NEGATIVE: MOV DL, 'N' JMP @PRINT @PRINT: MOV AH, 2 INT 21H MOV AH, 4CH INT 21H MAIN ENDP END MAIN
// // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20714 // // /// // Buffer Definitions: // // cbuffer cbPNTriangles // { // // float4x4 g_f4x4World; // Offset: 0 Size: 64 [unused] // float4x4 g_f4x4ViewProjection; // Offset: 64 Size: 64 // float4x4 g_f4x4WorldViewProjection;// Offset: 128 Size: 64 [unused] // float4 g_f4LightDir; // Offset: 192 Size: 16 // float4 g_f4Eye; // Offset: 208 Size: 16 [unused] // float4 g_f4ViewVector; // Offset: 224 Size: 16 [unused] // float4 g_f4TessFactors; // Offset: 240 Size: 16 [unused] // float4 g_f4ScreenParams; // Offset: 256 Size: 16 [unused] // float4 g_f4GUIParams1; // Offset: 272 Size: 16 [unused] // float4 g_f4GUIParams2; // Offset: 288 Size: 16 [unused] // float4 g_f4ViewFrustumPlanes[4]; // Offset: 304 Size: 64 [unused] // // } // // // Resource Bindings: // // Name Type Format Dim Slot Elements // ------------------------------ ---------- ------- ----------- ---- -------- // cbPNTriangles cbuffer NA NA 0 1 // // // // Patch Constant signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_TessFactor 0 x 0 TRIEDGE float // POSITION 3 yzw 0 NONE float yzw // SV_TessFactor 1 x 1 TRIEDGE float // POSITION 4 yzw 1 NONE float yzw // SV_TessFactor 2 x 2 TRIEDGE float // POSITION 5 yzw 2 NONE float yzw // SV_InsideTessFactor 0 x 3 TRIINT float // POSITION 6 yzw 3 NONE float yzw // POSITION 7 xyz 4 NONE float xyz // POSITION 8 xyz 5 NONE float xyz // CENTER 0 xyz 6 NONE float xyz // NORMAL 3 xyz 7 NONE float xyz // NORMAL 4 xyz 8 NONE float xyz // NORMAL 5 xyz 9 NONE float xyz // // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // POSITION 0 xyz 0 NONE float xyz // NORMAL 0 xyz 1 NONE float xyz // TEXCOORD 0 xy 2 NONE float xy // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Position 0 xyzw 0 POS float xyzw // TEXCOORD 0 xy 1 NONE float xy // COLOR 0 xyzw 2 NONE float xyzw // // Tessellation Domain # of control points // -------------------- -------------------- // Triangle 3 // ds_5_0 dcl_input_control_point_count 3 dcl_tessellator_domain domain_tri dcl_globalFlags refactoringAllowed dcl_constantbuffer cb0[13], immediateIndexed dcl_input vpc0.yzw dcl_input vpc1.yzw dcl_input vpc2.yzw dcl_input vpc3.yzw dcl_input vpc4.xyz dcl_input vpc5.xyz dcl_input vpc6.xyz dcl_input vpc7.xyz dcl_input vpc8.xyz dcl_input vpc9.xyz dcl_input vDomain.xyz dcl_input vicp[3][0].xyz dcl_input vicp[3][1].xyz dcl_input vicp[3][2].xy dcl_output_siv o0.xyzw, position dcl_output o1.xy dcl_output o2.xyzw dcl_temps 5 mul r0.xyz, vpc1.yzwy, vDomain.zzzz mul r1.xyz, vDomain.xyzx, vDomain.xyzx mul r2.xyz, r1.xxxx, vicp[1][0].xyzx mul r2.xyz, r2.xyzx, vDomain.xxxx mul r3.xyz, r1.zzzz, vicp[0][0].xyzx mad r2.xyz, r3.xyzx, vDomain.zzzz, r2.xyzx mul r3.xyz, r1.yyyy, vicp[2][0].xyzx mad r2.xyz, r3.xyzx, vDomain.yyyy, r2.xyzx mul r3.xyz, r1.xyzx, l(3.000000, 3.000000, 3.000000, 0.000000) mul r4.xyz, r3.zzzz, vpc0.yzwy mad r2.xyz, r4.xyzx, vDomain.xxxx, r2.xyzx mad r0.xyz, r0.xyzx, r3.xxxx, r2.xyzx mul r2.xyz, r3.zzzz, vpc5.xyzx mad r0.xyz, r2.xyzx, vDomain.yyyy, r0.xyzx mul r2.xyz, r3.xxxx, vpc2.yzwy mad r0.xyz, r2.xyzx, vDomain.yyyy, r0.xyzx mul r2.xyz, vpc4.xyzx, vDomain.zzzz mad r0.xyz, r2.xyzx, r3.yyyy, r0.xyzx mul r2.xyz, vpc3.yzwy, vDomain.xxxx mad r0.xyz, r2.xyzx, r3.yyyy, r0.xyzx mul r2.xyz, vpc6.xyzx, vDomain.zzzz mul r2.xyz, r2.xyzx, vDomain.xxxx mul r2.xyz, r2.xyzx, vDomain.yyyy mad r0.xyz, r2.xyzx, l(6.000000, 6.000000, 6.000000, 0.000000), r0.xyzx mov r0.w, l(1.000000) dp4 o0.x, r0.xyzw, cb0[4].xyzw dp4 o0.y, r0.xyzw, cb0[5].xyzw dp4 o0.z, r0.xyzw, cb0[6].xyzw dp4 o0.w, r0.xyzw, cb0[7].xyzw mul r0.xy, vDomain.xxxx, vicp[1][2].xyxx mad r0.xy, vicp[0][2].xyxx, vDomain.zzzz, r0.xyxx mad o1.xy, vicp[2][2].xyxx, vDomain.yyyy, r0.xyxx mul r0.xyz, r1.xxxx, vicp[1][1].xyzx mad r0.xyz, vicp[0][1].xyzx, r1.zzzz, r0.xyzx mad r0.xyz, vicp[2][1].xyzx, r1.yyyy, r0.xyzx mul r1.xyz, vpc7.xyzx, vDomain.zzzz mad r0.xyz, r1.xyzx, vDomain.xxxx, r0.xyzx mul r1.xyz, vpc8.xyzx, vDomain.xxxx mad r0.xyz, r1.xyzx, vDomain.yyyy, r0.xyzx mul r1.xyz, vpc9.xyzx, vDomain.zzzz mad r0.xyz, r1.xyzx, vDomain.yyyy, r0.xyzx dp3 r0.w, r0.xyzx, r0.xyzx rsq r0.w, r0.w mul r0.xyz, r0.wwww, r0.xyzx dp3 r0.x, r0.xyzx, cb0[12].xyzx max r0.x, r0.x, l(0.000000) add o2.xyz, r0.xxxx, l(0.200000, 0.200000, 0.200000, 0.000000) mov o2.w, l(1.000000) ret // Approximately 49 instruction slots used
; Student ID : SLAE64-1611 ; Student Name : Jonathan "Chops" Crosby ; Assignment 3 : Egg Hunter (Linux/x86_64) Assembly ; File Name : egghunter.nasm global _start section .text _start: xor rdx, rdx ; zero out rdx so we have a place to ; hold our memory address setup_page: or dx, 0xfff ; setting lower 16 bits to 4095 next_address: inc rdx ; moving it to 4096 while avoiding ; null characters 0x00 xor rax, rax ; zeroing out eax mov rsi, rax ; zero out int mode in param 2 add rax, 21 ; set rax to sys_access mov rdi, rdx ; moving memory address to param 1 syscall ; invoke sys_access cmp al, 0xf2 ; eax will contain 0xf2 if memory ; is not valid, ie. an EFAULT jz setup_page ; if the compare flag is zero then ; we don't have valid memory so reset ; to the next memory page and press on mov rax, 0xFCFCFCFCFCFCFCFC ; moving egg into eax in prep for searching mov rdi, rdx ; moving memory address into param 1 scasq ; comparing egg with memory location jnz next_address ; if it dosent match increase memory by one byte ; and try again scasq ; comparing egg with memory location jnz next_address ; if this is not zero it's not a match ; so on we will press increasing memory one more byte jmp rdi ; if we got this far then we found our egg and our ; memory address is already at the right place due ; to scasq so it's time to jump!
; A102613: Numerator of the reduced fractions of the ratios of the number of primes less than n over the number of composites less than n. ; Submitted by Jon Maiga ; 0,1,2,1,3,1,4,1,4,2,5,5,6,3,2,3,7,7,8,2,8,4,9,3,9,9,1,9,10,1,11,11,1,11,11,11,12,6,4,3,13,13,14,7,14,7,15,5,15,3,5,15,16,8,16,2,16,8,17,17,18,9,2,9,18,3,19,19,19,19,20,5,21,21,7,21,3,7,22,11,22,11,23,23,23,23 mov $2,$0 seq $0,720 ; pi(n), the number of primes <= n. Sometimes called PrimePi(n) to distinguish it from the number 3.14159... mov $1,$0 add $2,1 gcd $1,$2 div $0,$1
.text .globl main main: li $t0,23 li $t1,9 li $t2, -11 add $t1,$t0,$t1 add $t1,$t1,4 li $t3,14 sub $t2,$t3,$t0 sub $t2,$t1,$t2 sub $t0,$t1,$t2 sub $t0,$t0,15
#������ˮ�߲��ԣ�����ָ���������ԣ�һ��17��ָ�5����ˮ��ִ��������Ӧ����5+(17-1��=21 addi $s0,$zero, 0 addi $s1,$zero, 0 addi $s2,$zero, 0 addi $s3,$zero, 0 ori $s0,$s0, 0 ori $s1,$s1, 1 ori $s2,$s2, 2 ori $s3,$s3, 3 sw $s0, 0($s0) sw $s1, 4($s0) sw $s2, 8($s0) sw $s3, 12($s0) addi $v0,$zero,10 # system call for exit addi $s1,$zero, 0 #��������� addi $s2,$zero, 0 addi $s3,$zero, 0 syscall # we are out of here. sw $v0, 16($s0)
;nasm -f bin -o shutdown.com shutdown.asm org 100h section .text start: cli ; disable interrupts ;chke if APM is ok mov ax, 5300h xor bx, bx int 15h jc APM_error ;connect to APM API mov ax, 5301h xor bx, bx int 15h ;try to set APM version (to 1.2) mov ax, 530Eh mov cx, 0102h xor bx, bx int 15h ;turn off the system mov ax, 5307h mov bx, 0001h mov cx, 0003h int 15h APM_error: mov dx, msgAPMError ; the address of or message in dx mov ah, 9 ; ah=9 - "print string" sub-function int 21h ; call dos services exitError: mov ax, 4CFFh int 21h exit: mov ax, 4C00h int 21h msgAPMError db "APM error or not available",0 .end
; ; Copyright (c) 2010 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 "vpx_ports/x86_abi_support.asm" ;void vpx_plane_add_noise_sse2(uint8_t *start, const int8_t *noise, ; int blackclamp, int whiteclamp, ; int width, int height, int pitch) global sym(vpx_plane_add_noise_sse2) PRIVATE sym(vpx_plane_add_noise_sse2): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 GET_GOT rbx push rsi push rdi mov rdx, 0x01010101 mov rax, arg(2) mul rdx movq xmm3, rax pshufd xmm3, xmm3, 0 ; xmm3 is 16 copies of char in blackclamp mov rdx, 0x01010101 mov rax, arg(3) mul rdx movq xmm4, rax pshufd xmm4, xmm4, 0 ; xmm4 is 16 copies of char in whiteclamp movdqu xmm5, xmm3 ; both clamp = black clamp + white clamp paddusb xmm5, xmm4 .addnoise_loop: call sym(LIBVPX_RAND) WRT_PLT mov rcx, arg(1) ;noise and rax, 0xff add rcx, rax mov rdi, rcx movsxd rcx, dword arg(4) ;[Width] mov rsi, arg(0) ;Pos xor rax, rax .addnoise_nextset: movdqu xmm1,[rsi+rax] ; get the source psubusb xmm1, xmm3 ; subtract black clamp paddusb xmm1, xmm5 ; add both clamp psubusb xmm1, xmm4 ; subtract whiteclamp movdqu xmm2,[rdi+rax] ; get the noise for this line paddb xmm1,xmm2 ; add it in movdqu [rsi+rax],xmm1 ; store the result add rax,16 ; move to the next line cmp rax, rcx jl .addnoise_nextset movsxd rax, dword arg(6) ; Pitch add arg(0), rax ; Start += Pitch sub dword arg(5), 1 ; Height -= 1 jg .addnoise_loop ; begin epilog pop rdi pop rsi RESTORE_GOT UNSHADOW_ARGS pop rbp ret SECTION_RODATA align 16 rd42: times 8 dw 0x04 four8s: times 4 dd 8
/* Firmata.cpp - Firmata library Copyright (C) 2006-2008 Hans-Christoph Steiner. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. See file LICENSE.txt for further informations on licensing terms. */ //****************************************************************************** //* Includes //****************************************************************************** #include "WProgram.h" #include "HardwareSerial.h" #include "Firmata.h" extern "C" { #include <string.h> #include <stdlib.h> } //****************************************************************************** //* Support Functions //****************************************************************************** void sendValueAsTwo7bitBytes(int value) { Serial.print(value & B01111111, BYTE); // LSB Serial.print(value >> 7 & B01111111, BYTE); // MSB } void startSysex(void) { Serial.print(START_SYSEX, BYTE); } void endSysex(void) { Serial.print(END_SYSEX, BYTE); } //****************************************************************************** //* Constructors //****************************************************************************** FirmataClass::FirmataClass(void) { firmwareVersionCount = 0; systemReset(); } //****************************************************************************** //* Public Methods //****************************************************************************** /* begin method for overriding default serial bitrate */ void FirmataClass::begin(void) { begin(57600); } /* begin method for overriding default serial bitrate */ void FirmataClass::begin(long speed) { #if defined(__AVR_ATmega128__) // Wiring Serial.begin((uint32_t)speed); #else Serial.begin(speed); #endif blinkVersion(); delay(300); printVersion(); printFirmwareVersion(); } // output the protocol version message to the serial port void FirmataClass::printVersion(void) { Serial.print(REPORT_VERSION, BYTE); Serial.print(FIRMATA_MAJOR_VERSION, BYTE); Serial.print(FIRMATA_MINOR_VERSION, BYTE); } void FirmataClass::blinkVersion(void) { // flash the pin with the protocol version pinMode(VERSION_BLINK_PIN,OUTPUT); pin13strobe(FIRMATA_MAJOR_VERSION, 200, 400); delay(300); pin13strobe(2,1,4); // separator, a quick burst delay(300); pin13strobe(FIRMATA_MINOR_VERSION, 200, 400); } void FirmataClass::printFirmwareVersion(void) { byte i; if(firmwareVersionCount) { // make sure that the name has been set before reporting startSysex(); Serial.print(REPORT_FIRMWARE, BYTE); Serial.print(firmwareVersionVector[0]); // major version number Serial.print(firmwareVersionVector[1]); // minor version number for(i=2; i<firmwareVersionCount; ++i) { sendValueAsTwo7bitBytes(firmwareVersionVector[i]); } endSysex(); } } void FirmataClass::setFirmwareNameAndVersion(const char *name, byte major, byte minor) { const char *filename; char *extension; // parse out ".cpp" and "applet/" that comes from using __FILE__ extension = strstr(name, ".cpp"); filename = strrchr(name, '/') + 1; //points to slash, +1 gets to start of filename // add two bytes for version numbers if(extension && filename) { firmwareVersionCount = extension - filename + 2; } else { firmwareVersionCount = strlen(name) + 2; filename = name; } firmwareVersionVector = (byte *) malloc(firmwareVersionCount); firmwareVersionVector[firmwareVersionCount] = 0; firmwareVersionVector[0] = major; firmwareVersionVector[1] = minor; strncpy((char*)firmwareVersionVector + 2, filename, firmwareVersionCount - 2); // alas, no snprintf on Arduino // snprintf(firmwareVersionVector, MAX_DATA_BYTES, "%c%c%s", // (char)major, (char)minor, firmwareVersionVector); } //------------------------------------------------------------------------------ // Serial Receive Handling int FirmataClass::available(void) { return Serial.available(); } void FirmataClass::processSysexMessage(void) { switch(storedInputData[0]) { //first byte in buffer is command case REPORT_FIRMWARE: printFirmwareVersion(); break; case STRING_DATA: if(currentStringCallback) { byte bufferLength = (sysexBytesRead - 1) / 2; char *buffer = (char*)malloc(bufferLength * sizeof(char)); byte i = 1; byte j = 0; while(j < bufferLength) { buffer[j] = (char)storedInputData[i]; i++; buffer[j] += (char)(storedInputData[i] << 7); i++; j++; } (*currentStringCallback)(buffer); } break; default: if(currentSysexCallback) (*currentSysexCallback)(storedInputData[0], sysexBytesRead - 1, storedInputData + 1); } } void FirmataClass::processInput(void) { int inputData = Serial.read(); // this is 'int' to handle -1 when no data int command; // TODO make sure it handles -1 properly if (parsingSysex) { if(inputData == END_SYSEX) { //stop sysex byte parsingSysex = false; //fire off handler function processSysexMessage(); } else { //normal data byte - add to buffer storedInputData[sysexBytesRead] = inputData; sysexBytesRead++; } } else if( (waitForData > 0) && (inputData < 128) ) { waitForData--; storedInputData[waitForData] = inputData; if( (waitForData==0) && executeMultiByteCommand ) { // got the whole message switch(executeMultiByteCommand) { case ANALOG_MESSAGE: if(currentAnalogCallback) { (*currentAnalogCallback)(multiByteChannel, (storedInputData[0] << 7) + storedInputData[1]); } break; case DIGITAL_MESSAGE: if(currentDigitalCallback) { (*currentDigitalCallback)(multiByteChannel, (storedInputData[0] << 7) + storedInputData[1]); } break; case SET_PIN_MODE: if(currentPinModeCallback) (*currentPinModeCallback)(storedInputData[1], storedInputData[0]); break; case REPORT_ANALOG: if(currentReportAnalogCallback) (*currentReportAnalogCallback)(multiByteChannel,storedInputData[0]); break; case REPORT_DIGITAL: if(currentReportDigitalCallback) (*currentReportDigitalCallback)(multiByteChannel,storedInputData[0]); break; } executeMultiByteCommand = 0; } } else { // remove channel info from command byte if less than 0xF0 if(inputData < 0xF0) { command = inputData & 0xF0; multiByteChannel = inputData & 0x0F; } else { command = inputData; // commands in the 0xF* range don't use channel data } switch (command) { case ANALOG_MESSAGE: case DIGITAL_MESSAGE: case SET_PIN_MODE: waitForData = 2; // two data bytes needed executeMultiByteCommand = command; break; case REPORT_ANALOG: case REPORT_DIGITAL: waitForData = 1; // two data bytes needed executeMultiByteCommand = command; break; case START_SYSEX: parsingSysex = true; sysexBytesRead = 0; break; case SYSTEM_RESET: systemReset(); break; case REPORT_VERSION: Firmata.printVersion(); break; } } } //------------------------------------------------------------------------------ // Serial Send Handling // send an analog message void FirmataClass::sendAnalog(byte pin, int value) { // pin can only be 0-15, so chop higher bits Serial.print(ANALOG_MESSAGE | (pin & 0xF), BYTE); sendValueAsTwo7bitBytes(value); } // send a single digital pin in a digital message void FirmataClass::sendDigital(byte pin, int value) { /* TODO add single pin digital messages to the protocol, this needs to * track the last digital data sent so that it can be sure to change just * one bit in the packet. This is complicated by the fact that the * numbering of the pins will probably differ on Arduino, Wiring, and * other boards. The DIGITAL_MESSAGE sends 14 bits at a time, but it is * probably easier to send 8 bit ports for any board with more than 14 * digital pins. */ // TODO: the digital message should not be sent on the serial port every // time sendDigital() is called. Instead, it should add it to an int // which will be sent on a schedule. If a pin changes more than once // before the digital message is sent on the serial port, it should send a // digital message for each change. // if(value == 0) // sendDigitalPortPair(); } // send 14-bits in a single digital message (protocol v1) // send an 8-bit port in a single digital message (protocol v2) void FirmataClass::sendDigitalPort(byte portNumber, int portData) { Serial.print(DIGITAL_MESSAGE | (portNumber & 0xF),BYTE); Serial.print((byte)portData % 128, BYTE); // Tx bits 0-6 Serial.print(portData >> 7, BYTE); // Tx bits 7-13 } void FirmataClass::sendSysex(byte command, byte bytec, byte* bytev) { byte i; startSysex(); Serial.print(command, BYTE); for(i=0; i<bytec; i++) { sendValueAsTwo7bitBytes(bytev[i]); } endSysex(); } void FirmataClass::sendString(byte command, const char* string) { sendSysex(command, strlen(string), (byte *)string); } // send a string as the protocol string type void FirmataClass::sendString(const char* string) { sendString(STRING_DATA, string); } // Internal Actions///////////////////////////////////////////////////////////// // generic callbacks void FirmataClass::attach(byte command, callbackFunction newFunction) { switch(command) { case ANALOG_MESSAGE: currentAnalogCallback = newFunction; break; case DIGITAL_MESSAGE: currentDigitalCallback = newFunction; break; case REPORT_ANALOG: currentReportAnalogCallback = newFunction; break; case REPORT_DIGITAL: currentReportDigitalCallback = newFunction; break; case SET_PIN_MODE: currentPinModeCallback = newFunction; break; } } void FirmataClass::attach(byte command, systemResetCallbackFunction newFunction) { switch(command) { case SYSTEM_RESET: currentSystemResetCallback = newFunction; break; } } void FirmataClass::attach(byte command, stringCallbackFunction newFunction) { switch(command) { case STRING_DATA: currentStringCallback = newFunction; break; } } void FirmataClass::attach(byte command, sysexCallbackFunction newFunction) { currentSysexCallback = newFunction; } void FirmataClass::detach(byte command) { switch(command) { case SYSTEM_RESET: currentSystemResetCallback = NULL; break; case STRING_DATA: currentStringCallback = NULL; break; case START_SYSEX: currentSysexCallback = NULL; break; default: attach(command, (callbackFunction)NULL); } } // sysex callbacks /* * this is too complicated for analogReceive, but maybe for Sysex? void FirmataClass::attachSysex(sysexFunction newFunction) { byte i; byte tmpCount = analogReceiveFunctionCount; analogReceiveFunction* tmpArray = analogReceiveFunctionArray; analogReceiveFunctionCount++; analogReceiveFunctionArray = (analogReceiveFunction*) calloc(analogReceiveFunctionCount, sizeof(analogReceiveFunction)); for(i = 0; i < tmpCount; i++) { analogReceiveFunctionArray[i] = tmpArray[i]; } analogReceiveFunctionArray[tmpCount] = newFunction; free(tmpArray); } */ //****************************************************************************** //* Private Methods //****************************************************************************** // resets the system state upon a SYSTEM_RESET message from the host software void FirmataClass::systemReset(void) { byte i; waitForData = 0; // this flag says the next serial input will be data executeMultiByteCommand = 0; // execute this after getting multi-byte data multiByteChannel = 0; // channel data for multiByteCommands for(i=0; i<MAX_DATA_BYTES; i++) { storedInputData[i] = 0; } parsingSysex = false; sysexBytesRead = 0; if(currentSystemResetCallback) (*currentSystemResetCallback)(); //flush(); //TODO uncomment when Firmata is a subclass of HardwareSerial } // ============================================================================= // used for flashing the pin for the version number void FirmataClass::pin13strobe(int count, int onInterval, int offInterval) { byte i; pinMode(VERSION_BLINK_PIN, OUTPUT); for(i=0; i<count; i++) { delay(offInterval); digitalWrite(VERSION_BLINK_PIN, HIGH); delay(onInterval); digitalWrite(VERSION_BLINK_PIN, LOW); } } // make one instance for the user to use FirmataClass Firmata;
; A156279: 4 times the Lucas number A000032(n). ; 8,4,12,16,28,44,72,116,188,304,492,796,1288,2084,3372,5456,8828,14284,23112,37396,60508,97904,158412,256316,414728,671044,1085772,1756816,2842588,4599404,7441992,12041396,19483388,31524784,51008172,82532956,133541128,216074084,349615212,565689296,915304508,1480993804,2396298312,3877292116,6273590428,10150882544,16424472972,26575355516,42999828488,69575184004,112575012492,182150196496,294725208988,476875405484,771600614472,1248476019956,2020076634428,3268552654384,5288629288812,8557181943196,13845811232008,22402993175204,36248804407212,58651797582416,94900601989628,153552399572044,248453001561672,402005401133716,650458402695388,1052463803829104,1702922206524492,2755386010353596,4458308216878088,7213694227231684,11672002444109772,18885696671341456,30557699115451228,49443395786792684,80001094902243912,129444490689036596,209445585591280508,338890076280317104,548335661871597612,887225738151914716,1435561400023512328,2322787138175427044,3758348538198939372,6081135676374366416,9839484214573305788,15920619890947672204,25760104105520977992,41680723996468650196,67440828101989628188,109121552098458278384,176562380200447906572,285683932298906184956,462246312499354091528,747930244798260276484,1210176557297614368012,1958106802095874644496 mov $1,8 mov $2,4 lpb $0 sub $0,1 mov $3,$2 add $2,$1 mov $1,$3 lpe mov $0,$1
// TarHandlerOut.cpp #include "StdAfx.h" #include "Common/ComTry.h" #include "Common/StringConvert.h" #include "Windows/PropVariant.h" #include "Windows/Time.h" #include "TarHandler.h" #include "TarUpdate.h" using namespace NWindows; namespace NArchive { namespace NTar { STDMETHODIMP CHandler::GetFileTimeType(UInt32 *type) { *type = NFileTimeType::kUnix; return S_OK; } static HRESULT GetPropString(IArchiveUpdateCallback *callback, UInt32 index, PROPID propId, AString &res) { NCOM::CPropVariant prop; RINOK(callback->GetProperty(index, propId, &prop)); if (prop.vt == VT_BSTR) res = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP); else if (prop.vt != VT_EMPTY) return E_INVALIDARG; return S_OK; } STDMETHODIMP CHandler::UpdateItems(ISequentialOutStream *outStream, UInt32 numItems, IArchiveUpdateCallback *callback) { COM_TRY_BEGIN if ((_stream && !_errorMessage.IsEmpty()) || _seqStream) return E_NOTIMPL; CObjectVector<CUpdateItem> updateItems; for (UInt32 i = 0; i < numItems; i++) { CUpdateItem ui; Int32 newData; Int32 newProps; UInt32 indexInArchive; if (!callback) return E_FAIL; RINOK(callback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive)); ui.NewProps = IntToBool(newProps); ui.NewData = IntToBool(newData); ui.IndexInArchive = indexInArchive; ui.IndexInClient = i; if (IntToBool(newProps)) { { NCOM::CPropVariant prop; RINOK(callback->GetProperty(i, kpidIsDir, &prop)); if (prop.vt == VT_EMPTY) ui.IsDir = false; else if (prop.vt != VT_BOOL) return E_INVALIDARG; else ui.IsDir = (prop.boolVal != VARIANT_FALSE); } { NCOM::CPropVariant prop; RINOK(callback->GetProperty(i, kpidPosixAttrib, &prop)); if (prop.vt == VT_EMPTY) ui.Mode = 0777 | (ui.IsDir ? 0040000 : 0100000); else if (prop.vt != VT_UI4) return E_INVALIDARG; else ui.Mode = prop.ulVal; } { NCOM::CPropVariant prop; RINOK(callback->GetProperty(i, kpidMTime, &prop)); if (prop.vt == VT_EMPTY) ui.Time = 0; else if (prop.vt != VT_FILETIME) return E_INVALIDARG; else if (!NTime::FileTimeToUnixTime(prop.filetime, ui.Time)) ui.Time = 0; } { NCOM::CPropVariant prop; RINOK(callback->GetProperty(i, kpidPath, &prop)); if (prop.vt == VT_BSTR) ui.Name = UnicodeStringToMultiByte(NItemName::MakeLegalName(prop.bstrVal), CP_OEMCP); else if (prop.vt != VT_EMPTY) return E_INVALIDARG; if (ui.IsDir) ui.Name += '/'; } RINOK(GetPropString(callback, i, kpidUser, ui.User)); RINOK(GetPropString(callback, i, kpidGroup, ui.Group)); } if (IntToBool(newData)) { NCOM::CPropVariant prop; RINOK(callback->GetProperty(i, kpidSize, &prop)); if (prop.vt != VT_UI8) return E_INVALIDARG; ui.Size = prop.uhVal.QuadPart; /* // now we support GNU extension for big files if (ui.Size >= ((UInt64)1 << 33)) return E_INVALIDARG; */ } updateItems.Add(ui); } return UpdateArchive(_stream, outStream, _items, updateItems, callback); COM_TRY_END } }}
/* * This file is part of the Nautilus AeroKernel developed * by the Hobbes and V3VEE Projects with funding from the * United States National Science Foundation and the Department of Energy. * * The V3VEE Project is a joint project between Northwestern University * and the University of New Mexico. The Hobbes Project is a collaboration * led by Sandia National Laboratories that includes several national * laboratories and universities. You can find out more at: * http://www.v3vee.org and * http://xstack.sandia.gov/hobbes * * Copyright (c) 2020, Drew Kersnar <drewkersnar2021@u.northwestern.edu> * Copyright (c) 2020, Gaurav Chaudhary <gauravchaudhary2021@u.northwestern.edu> * Copyright (c) 2020, Souradip Ghosh <sgh@u.northwestern.edu> * Copyright (c) 2020, Brian Suchy <briansuchy2022@u.northwestern.edu> * Copyright (c) 2020, Peter Dinda <pdinda@northwestern.edu> * Copyright (c) 2020, The V3VEE Project <http://www.v3vee.org> * The Hobbes Project <http://xstack.sandia.gov/hobbes> * All rights reserved. * * Authors: Drew Kersnar, Gaurav Chaudhary, Souradip Ghosh, * Brian Suchy, Peter Dinda * * This is free software. You are permitted to use, * redistribute, and modify it as specified in the file "LICENSE.txt". */ #include "autoconf.h" #include "./include/Restrictions.hpp" #if NAUT_CONFIG_USE_NOELLE #include "./include/Protections.hpp" #else #include "./include/Escapes.hpp" #endif #define FetchAllocMethods(type) \ for (auto const &[ID, Name] : IDsTo##type##AllocMethods) \ { \ Function *AllocMethod = Utils::GetMethod(&M, Name); \ type##AllocNamesToMethods[Name] = AllocMethod; \ type##AllocMethodsToIDs[AllocMethod] = ID; \ } \ namespace { struct CAT : public ModulePass { static char ID; CAT() : ModulePass(ID) {} bool doInitialization(Module &M) override { /* * Debugging */ Utils::ExitOnInit(); /* * Fetch the "nocarat" annotation attribute --- necessary * to find user-marked functions in kernel code */ GlobalVariable *GV = M.getGlobalVariable(ANNOTATION); assert(!!GV && "doInitialization: 'nocarat' attribute not found!"); /* * Fetch the annotated functions */ Utils::FetchAnnotatedFunctions(GV); /* * Mark all annotated functions as noinline --- we * don't want marked functions to become instrumented * indirectly via inlining */ for (auto AF : AnnotatedFunctions) { /* * Sanity check the annotated function */ assert(!!AF && "Annotated function is nullptr!"); /* * Add attribute */ AF->addFnAttr(Attribute::NoInline); } /* * Now fetch all CARAT methods, stash them */ for (auto Name : CARATNames) { Function *CARATMethod = Utils::GetMethod(&M, Name); CARATNamesToMethods[Name] = CARATMethod; CARATMethods.insert(CARATMethod); } /* * Now fetch all kernel allocation methods, stash them */ if (InstrumentingUserCode) FetchAllocMethods(User) else FetchAllocMethods(Kernel) return false; } bool runOnModule(Module &M) override { /* * Debugging */ Utils::ExitOnInit(); if (Debug || true) { /* * Output all intrinsics that exist in the module */ errs() << "Now intrinsics!\n"; for (auto &F : M) if (F.isIntrinsic()) errs() << F.getName() << "\n"; /* * Vet allocation methods (of kernel OR userspace) */ Utils::VetAllocMethods(); } /* * --- Perform all CARAT instrumentation on the code --- */ #if NAUT_CONFIG_USE_NOELLE if (!NoProtections) { /* * Fetch Noelle and SCEV (HACK) * make a lambda that takes a function * and returns a scev * * the lambda invokes getAnalysis * pass the lambda to the protections pass -- just invoke the function */ auto FetchSE = [this](Function *F) -> ScalarEvolution * { ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>(*F).getSE(); return SE; } ; // std::unordered_map<Function *, ScalarEvolution *> SCEVs; // ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE(); // for (auto &F : M) // { // ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>(F).getSE(); // Protections P = Protections(SE); // } // for (auto &F : M) // { // ScalarEvolution *SE = &getAnalysis<ScalarEvolutionWrapperPass>(F).getSE(); // errs() << "VERIFYING SE FOR " << F.getName() << "...\n"; // SE->verify(); // SCEVs[&F] = SE; // } Noelle &NoelleAnalysis = getAnalysis<Noelle>(); /* * Protections */ ProtectionsHandler PH = ProtectionsHandler(&M, &NoelleAnalysis, FetchSE); PH.Protect(); } #endif /* * Allocation tracking */ AllocationHandler AH = AllocationHandler(&M); AH.Inject(); /* * Escapes tracking */ EscapesHandler EH = EscapesHandler(&M); EH.Inject(); /* * Analysis/transformation on prototype restrictions, * note that this functionality is per function */ for (auto &F : M) { if (Utils::IsInstrumentable(F)) { RestrictionsHandler RH = RestrictionsHandler(&F); RH.AnalyzeAllCalls(); RH.PinAllEscapingPointers(); RH.PrintAnalysis(); } } /* * Run verifier on each function instrumented */ Utils::Verify(M); /* * Add statistics call to the end of main() for user programs */ if (InstrumentingUserCode) Utils::InjectStats(M); return true; } void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired<ScalarEvolutionWrapperPass>(); #if NAUT_CONFIG_USE_NOELLE /* * Use NOELLE IFF we need protections only */ if (!NoProtections) AU.addRequired<Noelle>(); #endif return; } }; char CAT::ID = 0; static RegisterPass<CAT> X("karat", "KARAT"); static CAT *_PassMaker = NULL; static RegisterStandardPasses _RegPass1(PassManagerBuilder::EP_OptimizerLast, [](const PassManagerBuilder &, legacy::PassManagerBase &PM) { if(!_PassMaker){ PM.add(_PassMaker = new CAT());} }); // ** for -Ox static RegisterStandardPasses _RegPass2(PassManagerBuilder::EP_EnabledOnOptLevel0, [](const PassManagerBuilder &, legacy::PassManagerBase &PM) { if(!_PassMaker){ PM.add(_PassMaker = new CAT());} }); // ** for -O0 }
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r15 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x10837, %rbp add $20051, %r13 mov (%rbp), %rsi nop nop sub $11491, %r15 lea addresses_WC_ht+0x4ee7, %rdx nop nop cmp $50497, %r9 movl $0x61626364, (%rdx) nop nop nop nop nop add $54660, %r15 lea addresses_D_ht+0x1e3c3, %rsi lea addresses_WT_ht+0xc0c3, %rdi nop nop xor $733, %rbp mov $63, %rcx rep movsb nop nop nop nop nop dec %rsi lea addresses_WC_ht+0xf28, %rsi lea addresses_WT_ht+0x29c3, %rdi nop nop nop xor $30297, %rbp mov $8, %rcx rep movsb nop nop nop xor %rcx, %rcx lea addresses_normal_ht+0x1d8c3, %r13 nop and $18731, %rbp mov $0x6162636465666768, %rcx movq %rcx, %xmm4 movups %xmm4, (%r13) nop nop nop nop nop and $49314, %r13 lea addresses_A_ht+0x19a63, %rbp nop nop and %rdx, %rdx movb (%rbp), %r13b nop dec %rbp lea addresses_A_ht+0x102c3, %rbp add $20219, %rcx movb $0x61, (%rbp) nop nop cmp %rsi, %rsi lea addresses_WT_ht+0x1e79, %rdx clflush (%rdx) nop nop nop nop dec %rdi movb (%rdx), %r13b nop nop nop nop add %rdi, %rdi lea addresses_WC_ht+0x1e0b3, %rdi nop nop nop nop inc %rbp movl $0x61626364, (%rdi) dec %r15 lea addresses_normal_ht+0x19dc3, %r9 nop nop nop nop nop and %rsi, %rsi and $0xffffffffffffffc0, %r9 movntdqa (%r9), %xmm3 vpextrq $0, %xmm3, %rbp nop nop nop dec %rdx lea addresses_WC_ht+0x1bb83, %rsi lea addresses_normal_ht+0x4b8f, %rdi nop nop nop nop add %r15, %r15 mov $73, %rcx rep movsq nop inc %rcx lea addresses_A_ht+0x1ec62, %rcx clflush (%rcx) nop nop cmp $8432, %r13 mov (%rcx), %bp nop xor %r9, %r9 lea addresses_WC_ht+0x97c3, %rbp nop nop dec %rdx mov (%rbp), %r9d nop nop nop nop dec %r13 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r15 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r15 push %r9 push %rax push %rdx push %rsi // Store lea addresses_UC+0x2abb, %r11 nop nop nop nop nop dec %r15 mov $0x5152535455565758, %r12 movq %r12, %xmm4 vmovups %ymm4, (%r11) nop cmp %r9, %r9 // Store lea addresses_PSE+0xa383, %r9 nop nop nop nop sub $12224, %rax movl $0x51525354, (%r9) nop nop nop and %r12, %r12 // Faulty Load lea addresses_PSE+0x167c3, %r15 nop xor %r12, %r12 movb (%r15), %r11b lea oracles, %r12 and $0xff, %r11 shlq $12, %r11 mov (%r12,%r11,1), %r11 pop %rsi pop %rdx pop %rax pop %r9 pop %r15 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': True, 'same': False, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_UC', 'AVXalign': False, 'size': 32}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 4}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 2, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}} {'src': {'same': True, 'congruent': 10, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}} {'src': {'same': True, 'congruent': 0, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16}} {'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 1}} {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}} {'src': {'NT': True, 'same': False, 'congruent': 7, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 6, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_normal_ht'}} {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2}, 'OP': 'LOAD'} {'src': {'NT': True, 'same': False, 'congruent': 11, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'33': 12555} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; A243136: 512*n^10 - 1280*n^8 + 1120*n^6 - 400*n^4 + 50*n^2 - 1. ; Submitted by Jon Maiga ; -1,1,262087,22619537,457470751,4517251249,28860511751,137379191137,528572943487,1730726404001,4993116004999,13007560326001,31154649926687,69544807113937,146217791079751,291977237261249,557471159562751,1023286908188737,1814011722210887,3117419602578001,5210183616019999,8491781781142001,13528566242897287,21110301368514337,32321848554778751,48633085781281249,72010600134783751,105055183524172337,151169697461504287,214762453960362001,301491888156044999,418558976041008001,575054579591333887 mul $0,2 pow $0,2 mov $2,$0 bin $0,5 mul $0,120 add $0,$2 sub $0,2 div $0,2
// $Id: test_singleton.cpp 80826 2008-03-04 14:51:23Z wotte $ // This example illustrates the performance impact of using the // Double-Checked Locking pattern compared with using the "standard" // practice of acquiring and releasing a lock on every instance() // call. In addition, we compare the performance of using the // ACE_Singleton (which encapsulates the Double-Check Locking pattern) // vs. hand-coding the pattern. // // Here's the output from running this test on our SPARCstation 20, model 712s. // // ./test_singleton 1000000 // iterations = 1000000 // ACE_Singleton // real time = 0.193731 secs, user time = 0.190416 secs, system time = 0.000549 secs // time per call = 0.193731 usecs // DC_Singleton // real time = 0.176208 secs, user time = 0.176045 secs, system time = 0.000092 secs // time per call = 0.176208 usecs // Mutex_Singleton // real time = 3.160998 secs, user time = 3.121434 secs, system time = 0.000109 secs // time per call = 3.160998 usecs // // As you can see, both Double-Checked Locking implementations are about // 15 times faster than the standard mutex version. Moreover, // this test is run with only a single thread, so there's no contention // for the lock. If there were multiple threads contending for the lock, // the Mutex_Singleton performance would get increasing worse... #include "ace/OS_main.h" #include "ace/Guard_T.h" #include "ace/Profile_Timer.h" #include "ace/Singleton.h" #include "ace/Synch_Traits.h" #include "ace/Log_Msg.h" #include "test_singleton.h" ACE_RCSID(Misc, test_singleton, "$Id: test_singleton.cpp 80826 2008-03-04 14:51:23Z wotte $") #if defined (ACE_HAS_THREADS) static const int DEFAULT_ITERATIONS = 100000000; class Mutex_Singleton { public: Mutex_Singleton (void) {} void svc (void) {} static Mutex_Singleton *instance (void); private: static ACE_SYNCH_MUTEX lock_; static Mutex_Singleton *instance_; }; ACE_SYNCH_MUTEX Mutex_Singleton::lock_; Mutex_Singleton *Mutex_Singleton::instance_; Mutex_Singleton * Mutex_Singleton::instance (void) { // Acquire the lock every time in. ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, Mutex_Singleton::lock_, 0); if (Mutex_Singleton::instance_ == 0) ACE_NEW_RETURN (Mutex_Singleton::instance_, Mutex_Singleton, 0); return Mutex_Singleton::instance_; } ACE_SYNCH_MUTEX DC_Singleton::lock_; DC_Singleton *DC_Singleton::instance_; DC_Singleton * DC_Singleton::instance (void) { if (DC_Singleton::instance_ == 0) { // Only lock if instance_ isn't 0. ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, DC_Singleton::lock_, 0); // Perform the Double-Check. if (DC_Singleton::instance_ == 0) ACE_NEW_RETURN (DC_Singleton::instance_, DC_Singleton, 0); } return DC_Singleton::instance_; } typedef ACE_Singleton <DC_Singleton, ACE_SYNCH_MUTEX> My_Singleton; int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_Profile_Timer timer; int iterations = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_ITERATIONS; int i; ACE_DEBUG ((LM_DEBUG, "iterations = %d\n", iterations)); // Test the ACE_Singleton performance (which uses Double-Checked // Locking). timer.start (); for (i = 0; i < iterations; i++) My_Singleton::instance ()->svc (); timer.stop (); ACE_Profile_Timer::ACE_Elapsed_Time et; timer.elapsed_time (et); ACE_DEBUG ((LM_DEBUG, "ACE_Singleton\n")); ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", et.real_time, et.user_time, et.system_time)); ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000)); // Test the hand-coded Singleton performance (which uses // Double-Checked Locking). timer.start (); for (i = 0; i < iterations; i++) DC_Singleton::instance ()->svc (); timer.stop (); timer.elapsed_time (et); ACE_DEBUG ((LM_DEBUG, "DC_Singleton\n")); ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", et.real_time, et.user_time, et.system_time)); ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000)); // Test the Mutex_Singleton implementation (which does not use // Double-Checked Locking). timer.start (); for (i = 0; i < iterations; i++) Mutex_Singleton::instance ()->svc (); timer.stop (); timer.elapsed_time (et); ACE_DEBUG ((LM_DEBUG, "Mutex_Singleton\n")); ACE_DEBUG ((LM_DEBUG, "real time = %f secs, user time = %f secs, system time = %f secs\n", et.real_time, et.user_time, et.system_time)); ACE_DEBUG ((LM_DEBUG, "time per call = %f usecs\n", (et.real_time / double (iterations)) * 1000000)); return 0; } #if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION) template ACE_Singleton<DC_Singleton, ACE_SYNCH_MUTEX> * ACE_Singleton<DC_Singleton, ACE_SYNCH_MUTEX>::singleton_; #endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */ #else int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); return 0; } #endif /* ACE_HAS_THREADS */
%ifdef CONFIG { "RegData": { "XMM0": ["0x7172737475767778", "0x5152535455565758"], "XMM1": ["0x6162636465666768", "0x7172737475767778"] } } %endif mov rdx, 0xe0000000 mov rax, 0x4142434445464748 mov [rdx + 8 * 0], rax mov rax, 0x5152535455565758 mov [rdx + 8 * 1], rax mov rax, 0x6162636465666768 mov [rdx + 8 * 2], rax mov rax, 0x7172737475767778 mov [rdx + 8 * 3], rax movaps xmm0, [rdx + 8 * 0] movaps xmm1, [rdx + 8 * 2] movhlps xmm0, xmm1 hlt
/****************************************************************************** * * Project: MongoDB Translator * Purpose: Implements OGRMongoDBDriver. * Author: Even Rouault, even.rouault at spatialys.com * ****************************************************************************** * Copyright (c) 2015, Even Rouault <even.rouault at spatialys.com> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "mongocxx_headers.h" #include "gdal_priv.h" #include "ogrsf_frmts.h" #include "ogr_p.h" #include "cpl_time.h" #include <limits> // g++ -DDEBUG -g -Wall -fPIC -shared -o ogr_MongoDB.so -I/home/even/boost_1_53_0 -Iport -Igcore -Iogr -Iogr/ogrsf_frmts -Iogr/ogrsf_frmts/mongodb ogr/ogrsf_frmts/mongodb/*.c* -L. -lgdal -I/home/even/mongo-cxx-1.0.2-install/include -L/home/even/mongo-cxx-1.0.2-install/lib -lmongoclient -L/home/even/boost_1_53_0/stage/lib -lboost_system -lboost_thread -lboost_regex CPL_CVSID("$Id$") #define MAX_DOCS_IN_BULK 1000 extern "C" void RegisterOGRMongoDB(); using namespace mongo; using mongo::client::Options; #if __cplusplus >= 201103L #define UNIQUE_PTR std::unique_ptr #else #define UNIQUE_PTR std::auto_ptr #endif static int bMongoInitialized = -1; static CPLString osStaticPEMKeyFile; static CPLString osStaticPEMKeyPassword; static CPLString osStaticCAFile; static CPLString osStaticCRLFile; static int bStaticAllowInvalidCertificates = FALSE; static int bStaticAllowInvalidHostnames = FALSE; static int bStaticFIPSMode = FALSE; class OGRMongoDBDataSource; typedef struct _IntOrMap IntOrMap; struct _IntOrMap { int bIsMap; union { int nField; std::map< CPLString, IntOrMap*>* poMap; } u; }; class OGRMongoDBLayer: public OGRLayer { OGRMongoDBDataSource *m_poDS; OGRFeatureDefn *m_poFeatureDefn; CPLString m_osDatabase; CPLString m_osCollection; CPLString m_osQualifiedCollection; int m_bHasEstablishedFeatureDefn; GIntBig m_nIndex, m_nNextFID; UNIQUE_PTR<DBClientCursor> m_poCursor; int m_bCursorValid; BSONObj m_oQueryAttr, m_oQuerySpat; CPLString m_osFID; int m_bLayerMetadataUpdatable; int m_bUpdateLayerMetadata; int m_bDotAsNestedField; int m_bIgnoreSourceID; int m_bCreateSpatialIndex; BulkOperationBuilder* m_poBulkBuilder; int m_nFeaturesInBulk; std::vector< std::vector<CPLString> > m_aaosFieldPaths; std::vector< std::vector<CPLString> > m_aaosGeomFieldPaths; std::vector< CPLString > m_aosGeomIndexes; std::vector< OGRCoordinateTransformation* > m_apoCT; std::map< CPLString, CPLString> CollectGeomIndices(); int ReadOGRMetadata(std::map< CPLString, CPLString>& oMapIndices); void EstablishFeatureDefn(); void WriteOGRMetadata(); OGRFeature* Translate(BSONObj& obj); void AddOrUpdateField(const char* pszAttrName, const BSONElement* poElt, char chNestedAttributeSeparator, std::vector<CPLString>& aosPaths, std::map< CPLString, CPLString>& oMapIndices); void SerializeField(BSONObjBuilder& b, OGRFeature *poFeature, int iField, const char* pszJSonField); void SerializeGeometry(BSONObjBuilder& b, OGRGeometry* poGeom, int iField, const char* pszJSonField); void SerializeRecursive(BSONObjBuilder& b, OGRFeature *poFeature, std::map< CPLString, IntOrMap*>& aoMap ); static void InsertInMap(IntOrMap* rootMap, std::map< std::vector<CPLString>, IntOrMap*>& aoMap, const std::vector<CPLString>& aosFieldPathFull, int nField); BSONObj BuildBSONObjFromFeature(OGRFeature* poFeature, int bUpdate); BSONObj BuildQuery(); public: OGRMongoDBLayer(OGRMongoDBDataSource* m_poDS, const char* pszDatabase, const char* pszCollection); virtual ~OGRMongoDBLayer(); virtual OGRFeatureDefn* GetLayerDefn() override; virtual const char* GetName() override { return m_poFeatureDefn->GetName(); } virtual void ResetReading() override; virtual OGRFeature* GetNextFeature() override; virtual OGRFeature* GetFeature(GIntBig nFID) override; virtual OGRErr DeleteFeature(GIntBig nFID) override; virtual int TestCapability(const char* pszCap) override; virtual GIntBig GetFeatureCount(int bForce) override; virtual OGRErr SetAttributeFilter(const char* pszFilter) override; virtual void SetSpatialFilter( OGRGeometry *poGeom ) override { SetSpatialFilter(0, poGeom); } virtual void SetSpatialFilter( int iGeomField, OGRGeometry *poGeom ) override; virtual const char* GetFIDColumn() override; virtual OGRErr CreateField( OGRFieldDefn *poFieldIn, int bApproxOK ) override; virtual OGRErr CreateGeomField( OGRGeomFieldDefn *poFieldIn, int bApproxOK ) override; virtual OGRErr ICreateFeature(OGRFeature* poFeature) override; virtual OGRErr ISetFeature(OGRFeature* poFeature) override; virtual OGRErr SyncToDisk() override; const CPLString& GetDatabase() const { return m_osDatabase; } const CPLString& GetCollection() const { return m_osCollection; } const CPLString& GetQualifiedCollection() const { return m_osQualifiedCollection; } void SetFID(const CPLString& m_osFIDIn) { m_osFID = m_osFIDIn; } void SetCreateLayerMetadata(int bFlag) { m_bLayerMetadataUpdatable = bFlag; m_bUpdateLayerMetadata = bFlag; } void SetDotAsNestedField(int bFlag) { m_bDotAsNestedField = bFlag; } void SetIgnoreSourceID(int bFlag) { m_bIgnoreSourceID = bFlag; } void SetCreateSpatialIndex(int bFlag) { m_bCreateSpatialIndex = bFlag; } }; class OGRMongoDBDataSource: public GDALDataset { DBClientBase *m_poConn; CPLString m_osDatabase; std::vector<OGRMongoDBLayer*> m_apoLayers; int m_nBatchSize; bool m_bFlattenNestedAttributes; int m_nFeatureCountToEstablishFeatureDefn; int m_bJSonField; CPLString m_osFID; int m_bUseOGRMetadata; int m_bBulkInsert; static int Initialize(char** papszOpenOptions); int ListLayers(const char* pszDatabase); public: OGRMongoDBDataSource(); virtual ~OGRMongoDBDataSource(); int Open(const char* pszFilename, GDALAccess eAccess, char** papszOpenOptions); virtual int GetLayerCount() override { return (int)m_apoLayers.size(); } virtual OGRLayer* GetLayer(int nIdx) override; virtual int TestCapability(const char* pszCap) override; virtual OGRLayer *ICreateLayer( const char *pszName, OGRSpatialReference *poSpatialRef = nullptr, OGRwkbGeometryType eGType = wkbUnknown, char ** papszOptions = nullptr ) override; virtual OGRErr DeleteLayer( int iLayer ) override; virtual OGRLayer *GetLayerByName(const char* pszLayerName) override; virtual OGRLayer * ExecuteSQL( const char *pszSQLCommand, OGRGeometry *poSpatialFilter, const char *pszDialect ) override; virtual void ReleaseResultSet( OGRLayer * poLayer ) override; const CPLString& GetDatabase() const { return m_osDatabase; } DBClientBase *GetConn() const { return m_poConn; } int GetBatchSize() const { return m_nBatchSize; } bool GetFlattenNestedAttributes() const { return m_bFlattenNestedAttributes; } int GetFeatureCountToEstablishFeatureDefn() const { return m_nFeatureCountToEstablishFeatureDefn; } int JSonField() const { return m_bJSonField; } int UseOGRMetadata() const { return m_bUseOGRMetadata; } int BulkInsert() const { return m_bBulkInsert; } const CPLString& GetFID() const { return m_osFID; } }; /************************************************************************/ /* OGRMongoDBLayer() */ /************************************************************************/ OGRMongoDBLayer::OGRMongoDBLayer(OGRMongoDBDataSource* poDS, const char* pszDatabase, const char* pszCollection) : m_osDatabase( pszDatabase), m_osCollection( pszCollection ) { m_poDS = poDS; m_osQualifiedCollection = CPLSPrintf("%s.%s", m_osDatabase.c_str(), m_osCollection.c_str()); if( !m_poDS->GetDatabase().empty() ) m_poFeatureDefn = new OGRFeatureDefn(pszCollection); else m_poFeatureDefn = new OGRFeatureDefn(m_osQualifiedCollection); m_poFeatureDefn->SetGeomType(wkbNone); SetDescription(m_poFeatureDefn->GetName()); m_poFeatureDefn->Reference(); m_bHasEstablishedFeatureDefn = FALSE; m_bCursorValid = FALSE; m_nIndex = 0; m_nNextFID = 0; m_bLayerMetadataUpdatable = FALSE; m_bUpdateLayerMetadata = FALSE; m_bDotAsNestedField = TRUE; m_bIgnoreSourceID = FALSE; m_bCreateSpatialIndex = TRUE; m_poBulkBuilder = nullptr; m_nFeaturesInBulk = 0; OGRFieldDefn oFieldDefn("_id", OFTString); std::vector<CPLString> aosPath; aosPath.push_back("_id"); m_aaosFieldPaths.push_back(aosPath); m_poFeatureDefn->AddFieldDefn(&oFieldDefn); } /************************************************************************/ /* ~OGRMongoDBLayer() */ /************************************************************************/ OGRMongoDBLayer::~OGRMongoDBLayer() { SyncToDisk(); for(int i=0;i<(int)m_apoCT.size();i++) delete m_apoCT[i]; m_poFeatureDefn->Release(); } /************************************************************************/ /* WriteOGRMetadata() */ /************************************************************************/ void OGRMongoDBLayer::WriteOGRMetadata() { //CPLDebug("MongoDB", "WriteOGRMetadata(%s)", m_osQualifiedCollection.c_str()); if( !m_bUpdateLayerMetadata ) return; m_bUpdateLayerMetadata = FALSE; try { BSONObjBuilder b; b.append("layer", m_osCollection.c_str()); if( !m_osFID.empty() ) { b.append( "fid", m_osFID.c_str() ); } BSONArrayBuilder fields; CPLAssert( (int)m_aaosFieldPaths.size() == m_poFeatureDefn->GetFieldCount() ); for(int i=1;i<m_poFeatureDefn->GetFieldCount();i++) { OGRFieldDefn* poFieldDefn = m_poFeatureDefn->GetFieldDefn(i); const char* pszFieldName = poFieldDefn->GetNameRef(); if( EQUAL(pszFieldName, "_json") ) continue; BSONArrayBuilder path; for(int j=0;j<(int)m_aaosFieldPaths[i].size();j++) path.append(m_aaosFieldPaths[i][j]); OGRFieldType eType = poFieldDefn->GetType(); if( eType == OFTInteger && poFieldDefn->GetSubType() == OFSTBoolean ) fields.append(BSON("name" << pszFieldName << "type" << OGR_GetFieldTypeName(eType) << "subtype" << "Boolean" << "path" << path.arr())); else fields.append(BSON("name" << pszFieldName << "type" << OGR_GetFieldTypeName(eType) << "path" << path.arr())); } b.append("fields", fields.arr()); BSONArrayBuilder geomfields; CPLAssert( (int)m_aaosGeomFieldPaths.size() == m_poFeatureDefn->GetGeomFieldCount() ); for(int i=0;i<m_poFeatureDefn->GetGeomFieldCount();i++) { OGRGeomFieldDefn* poGeomFieldDefn = m_poFeatureDefn->GetGeomFieldDefn(i); const char* pszFieldName = poGeomFieldDefn->GetNameRef(); BSONArrayBuilder path; for(int j=0;j<(int)m_aaosGeomFieldPaths[i].size();j++) path.append(m_aaosGeomFieldPaths[i][j]); const char* pszGeomType = OGRToOGCGeomType(poGeomFieldDefn->GetType()); geomfields.append(BSON("name" << pszFieldName << "type" << pszGeomType << "path" << path.arr())); } b.append("geomfields", geomfields.arr()); m_poDS->GetConn()->findAndRemove( CPLSPrintf("%s._ogr_metadata", m_osDatabase.c_str()), BSON("layer" << m_osCollection.c_str()), BSONObj(), BSONObj()); m_poDS->GetConn()->insert( CPLSPrintf("%s._ogr_metadata", m_osDatabase.c_str()), b.obj() ); } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "WriteOGRMetadata()", e.what()); } } /************************************************************************/ /* SyncToDisk() */ /************************************************************************/ OGRErr OGRMongoDBLayer::SyncToDisk() { OGRErr eErr = OGRERR_NONE; if( m_poBulkBuilder != nullptr ) { WriteResult writeResult; try { m_poBulkBuilder->execute(nullptr, &writeResult); eErr = writeResult.hasErrors() ? OGRERR_FAILURE: OGRERR_NONE; } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "Bulk write", e.what()); eErr = OGRERR_FAILURE; } delete m_poBulkBuilder; m_poBulkBuilder = nullptr; m_nFeaturesInBulk = 0; } WriteOGRMetadata(); return eErr; } /************************************************************************/ /* ResetReading() */ /************************************************************************/ void OGRMongoDBLayer::ResetReading() { m_bCursorValid = FALSE; m_nIndex = 0; } /************************************************************************/ /* GetLayerDefn() */ /************************************************************************/ OGRFeatureDefn* OGRMongoDBLayer::GetLayerDefn() { if( !m_bHasEstablishedFeatureDefn ) EstablishFeatureDefn(); return m_poFeatureDefn; } /************************************************************************/ /* OGRMongoDBGetFieldTypeFromBSON() */ /************************************************************************/ static OGRFieldType OGRMongoDBGetFieldTypeFromBSON( const BSONElement* poElt, OGRFieldSubType& eSubType ) { eSubType = OFSTNone; BSONType eBSONType = poElt->type(); if( eBSONType == Bool ) { eSubType = OFSTBoolean; return OFTInteger; } else if( eBSONType == NumberDouble ) return OFTReal; else if( eBSONType == NumberInt ) return OFTInteger; else if( eBSONType == NumberLong ) return OFTInteger64; else if( eBSONType == String ) return OFTString; else if( eBSONType == Array ) { std::vector<BSONElement> oArray = poElt->Array(); int nSize = (int)oArray.size(); if (nSize == 0) return OFTStringList; /* we don't know, so let's assume it's a string list */ OGRFieldType eType = OFTIntegerList; int bOnlyBoolean = TRUE; for(int i=0;i<nSize;i++) { BSONElement& elt = oArray[i]; eBSONType = elt.type(); bOnlyBoolean &= (eBSONType == Bool); if (eBSONType == NumberDouble) eType = OFTRealList; else if (eType == OFTIntegerList && eBSONType == NumberLong) eType = OFTInteger64List; else if (eBSONType != NumberInt && eBSONType != NumberLong && eBSONType != Bool) return OFTStringList; } if( bOnlyBoolean ) eSubType = OFSTBoolean; return eType; } else if( eBSONType == Date ) return OFTDateTime; else if( eBSONType == BinData ) return OFTBinary; else return OFTString; /* null, object */ } /************************************************************************/ /* AddOrUpdateField() */ /************************************************************************/ void OGRMongoDBLayer::AddOrUpdateField(const char* pszAttrName, const BSONElement* poElt, char chNestedAttributeSeparator, std::vector<CPLString>& aosPaths, std::map< CPLString, CPLString>& oMapIndices) { BSONType eBSONType = poElt->type(); if( eBSONType == jstNULL || eBSONType == Undefined || eBSONType == MinKey || eBSONType == MaxKey ) return; if( eBSONType == Object ) { BSONObj obj(poElt->Obj()); BSONElement eltType = obj.getField("type"); if( !eltType.eoo() && eltType.type() == String ) { OGRwkbGeometryType eGeomType = OGRFromOGCGeomType(eltType.String().c_str()); if( eGeomType != wkbUnknown ) { int nIndex = m_poFeatureDefn->GetGeomFieldIndex(pszAttrName); if( nIndex < 0 ) { OGRGeomFieldDefn fldDefn( pszAttrName, eGeomType ); OGRSpatialReference* poSRS = new OGRSpatialReference(); poSRS->SetFromUserInput(SRS_WKT_WGS84); fldDefn.SetSpatialRef(poSRS); poSRS->Release(); m_poFeatureDefn->AddGeomFieldDefn( &fldDefn ); aosPaths.push_back(poElt->fieldName()); m_aaosGeomFieldPaths.push_back(aosPaths); if( oMapIndices.find(pszAttrName) == oMapIndices.end() ) m_aosGeomIndexes.push_back(oMapIndices[pszAttrName]); else m_aosGeomIndexes.push_back("none"); m_apoCT.push_back(nullptr); } else { OGRGeomFieldDefn* poFDefn = m_poFeatureDefn->GetGeomFieldDefn(nIndex); if( poFDefn->GetType() != eGeomType ) poFDefn->SetType(wkbUnknown); } } } else if( m_poDS->GetFlattenNestedAttributes() ) { if( m_poFeatureDefn->GetGeomFieldIndex(pszAttrName) >= 0 ) return; aosPaths.push_back(poElt->fieldName()); for( BSONObj::iterator i(obj); i.more(); ) { BSONElement elt(i.next()); char szSeparator[2]; szSeparator[0] = chNestedAttributeSeparator; szSeparator[1] = 0; CPLString osAttrName(CPLSPrintf("%s%s%s", pszAttrName, szSeparator, elt.fieldName())); std::vector<CPLString> aosNewPaths(aosPaths); AddOrUpdateField(osAttrName, &elt,chNestedAttributeSeparator, aosNewPaths, oMapIndices); } return; } } else if( eBSONType == Array ) { if( m_poFeatureDefn->GetGeomFieldIndex(pszAttrName) >= 0 ) return; if( oMapIndices.find(pszAttrName) != oMapIndices.end() && oMapIndices[pszAttrName] == "2d" ) { OGRGeomFieldDefn fldDefn( pszAttrName, wkbPoint ); OGRSpatialReference* poSRS = new OGRSpatialReference(); poSRS->SetFromUserInput(SRS_WKT_WGS84); fldDefn.SetSpatialRef(poSRS); poSRS->Release(); m_poFeatureDefn->AddGeomFieldDefn( &fldDefn ); aosPaths.push_back(poElt->fieldName()); m_aaosGeomFieldPaths.push_back(aosPaths); m_aosGeomIndexes.push_back("2d"); m_apoCT.push_back(nullptr); } } if( m_poFeatureDefn->GetGeomFieldIndex(pszAttrName) >= 0 ) return; OGRFieldSubType eNewSubType; OGRFieldType eNewType = OGRMongoDBGetFieldTypeFromBSON( poElt, eNewSubType ); int nIndex = m_poFeatureDefn->GetFieldIndex(pszAttrName); if( nIndex < 0 ) { OGRFieldDefn fldDefn( pszAttrName, eNewType ); fldDefn.SetSubType(eNewSubType); if( eNewSubType == OFSTBoolean ) fldDefn.SetWidth(1); m_poFeatureDefn->AddFieldDefn( &fldDefn ); aosPaths.push_back(poElt->fieldName()); m_aaosFieldPaths.push_back(aosPaths); } else { OGRFieldDefn* poFDefn = m_poFeatureDefn->GetFieldDefn(nIndex); OGRUpdateFieldType(poFDefn, eNewType, eNewSubType); } } /************************************************************************/ /* CollectGeomIndices() */ /************************************************************************/ std::map< CPLString, CPLString> OGRMongoDBLayer::CollectGeomIndices() { std::map< CPLString, CPLString> oMapIndices; try { UNIQUE_PTR<DBClientCursor> cursor = m_poDS->GetConn()->enumerateIndexes(m_osQualifiedCollection); if( cursor.get() == nullptr ) return oMapIndices; while( cursor->more() ) { BSONObj obj = cursor->nextSafe(); BSONElement key = obj.getField("key"); if( !key.eoo() && key.type() == Object ) { for( BSONObj::iterator i(key.Obj()); i.more(); ) { BSONElement elt(i.next()); if( elt.type() == String && (elt.String() == "2d" || elt.String() == "2dsphere") ) { //CPLDebug("MongoDB", "Index %s for %s of %s", // elt.String().c_str(), elt.fieldName(), m_osQualifiedCollection.c_str()); oMapIndices[elt.fieldName()] = elt.String().c_str(); } } } } } catch( const DBException &e ) { CPLDebug("MongoDB", "Error when listing indices: %s", e.what()); } return oMapIndices; } /************************************************************************/ /* ReadOGRMetadata() */ /************************************************************************/ int OGRMongoDBLayer::ReadOGRMetadata(std::map< CPLString, CPLString>& oMapIndices) { try { UNIQUE_PTR<DBClientCursor> cursor = m_poDS->GetConn()->query( CPLSPrintf("%s._ogr_metadata", m_osDatabase.c_str()), BSON("layer" << m_osCollection.c_str()), 1); if( cursor->more() ) { BSONObj obj = cursor->nextSafe(); BSONElement fid = obj.getField("fid"); if( !fid.eoo() && fid.type() == String ) m_osFID = fid.String(); BSONElement fields = obj.getField("fields"); if( !fields.eoo() && fields.type() == Array ) { std::vector<BSONElement> oArray = fields.Array(); int nSize = (int)oArray.size(); for(int i=0;i<nSize;i++) { BSONElement& elt = oArray[i]; if( elt.type() == Object ) { BSONObj obj2(elt.Obj()); BSONElement name = obj2.getField("name"); BSONElement type = obj2.getField("type"); BSONElement subtype = obj2.getField("subtype"); BSONElement path = obj2.getField("path"); if( !name.eoo() && name.type() == String && !type.eoo() && type.type() == String && !path.eoo() && path.type() == Array ) { if( name.String() == "_id" ) continue; OGRFieldType eType(OFTString); for(int j=0; j<=OFTMaxType;j++) { if( EQUAL(OGR_GetFieldTypeName((OGRFieldType)j), type.String().c_str()) ) { eType = (OGRFieldType)j; break; } } OGRFieldDefn oFieldDefn(name.String().c_str(), eType); if( !subtype.eoo() && subtype.type() == String && subtype.String() == "Boolean" ) oFieldDefn.SetSubType(OFSTBoolean); m_poFeatureDefn->AddFieldDefn(&oFieldDefn); std::vector<CPLString> aosPaths; std::vector<BSONElement> oPathArray = path.Array(); for(int j=0;j<(int)oPathArray.size();j++) { BSONElement& eltPath = oPathArray[j]; aosPaths.push_back(eltPath.String().c_str()); } m_aaosFieldPaths.push_back(aosPaths); } } } } BSONElement geomfields = obj.getField("geomfields"); if( !geomfields.eoo() && geomfields.type() == Array ) { std::vector<BSONElement> oArray = geomfields.Array(); int nSize = (int)oArray.size(); for(int i=0;i<nSize;i++) { BSONElement& elt = oArray[i]; if( elt.type() == Object ) { BSONObj obj2(elt.Obj()); BSONElement name = obj2.getField("name"); BSONElement type = obj2.getField("type"); BSONElement path = obj2.getField("path"); if( !name.eoo() && name.type() == String && !type.eoo() && type.type() == String && !path.eoo() && path.type() == Array ) { OGRwkbGeometryType eType(OGRFromOGCGeomType(type.String().c_str())); OGRGeomFieldDefn oFieldDefn(name.String().c_str(), eType); OGRSpatialReference* poSRS = new OGRSpatialReference(); poSRS->SetFromUserInput(SRS_WKT_WGS84); oFieldDefn.SetSpatialRef(poSRS); poSRS->Release(); m_poFeatureDefn->AddGeomFieldDefn(&oFieldDefn); std::vector<CPLString> aosPaths; std::vector<BSONElement> oPathArray = path.Array(); for(int j=0;j<(int)oPathArray.size();j++) { BSONElement& eltPath = oPathArray[j]; aosPaths.push_back(eltPath.String().c_str()); } m_aaosGeomFieldPaths.push_back(aosPaths); if( oMapIndices.find(oFieldDefn.GetNameRef()) != oMapIndices.end() ) m_aosGeomIndexes.push_back(oMapIndices[oFieldDefn.GetNameRef()]); else m_aosGeomIndexes.push_back("none"); //CPLDebug("MongoDB", "Layer %s: m_aosGeomIndexes[%d] = %s", // m_osQualifiedCollection.c_str(), // m_poFeatureDefn->GetGeomFieldCount()-1, // m_aosGeomIndexes[m_poFeatureDefn->GetGeomFieldCount()-1].c_str()); m_apoCT.push_back(nullptr); } } } } m_bLayerMetadataUpdatable = TRUE; return TRUE; } } catch( const DBException &e ) { CPLError(CE_Warning, CPLE_AppDefined, "%s: %s", "ReadOGRMetadata()", e.what()); } return FALSE; } /************************************************************************/ /* EstablishFeatureDefn() */ /************************************************************************/ void OGRMongoDBLayer::EstablishFeatureDefn() { if( m_bHasEstablishedFeatureDefn ) return; m_bHasEstablishedFeatureDefn = TRUE; std::map< CPLString, CPLString> oMapIndices(CollectGeomIndices()); int nCount = m_poDS->GetFeatureCountToEstablishFeatureDefn(); if( m_poDS->UseOGRMetadata() ) { if( ReadOGRMetadata(oMapIndices) ) nCount = 0; } if( nCount != 0 ) { if( nCount < 0 ) nCount = 0; /* unlimited */ try { UNIQUE_PTR<DBClientCursor> cursor = m_poDS->GetConn()->query( m_osQualifiedCollection, BSONObj(), nCount, 0, /* nToSkip */ nullptr, /* fieldsToReturn */ 0, /* queryOptions */ m_poDS->GetBatchSize()); while ( cursor->more() ) { BSONObj obj = cursor->nextSafe(); for( BSONObj::iterator i(obj); i.more(); ) { BSONElement elt(i.next()); if( EQUAL(elt.fieldName(), m_poDS->GetFID()) ) { m_osFID = elt.fieldName(); } else { std::vector<CPLString> aosPaths; AddOrUpdateField(elt.fieldName(), &elt, '.', aosPaths, oMapIndices); } } } } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "EstablishFeatureDefn()", e.what()); } } if( m_poDS->JSonField() ) { OGRFieldDefn fldDefn("_json", OFTString); m_poFeatureDefn->AddFieldDefn( &fldDefn ); std::vector<CPLString> aosPaths; m_aaosFieldPaths.push_back(aosPaths); } } /************************************************************************/ /* GetFIDColumn() */ /************************************************************************/ const char* OGRMongoDBLayer::GetFIDColumn() { if( !m_bHasEstablishedFeatureDefn ) EstablishFeatureDefn(); return m_osFID.c_str(); } /************************************************************************/ /* BuildQuery() */ /************************************************************************/ BSONObj OGRMongoDBLayer::BuildQuery() { BSONObjBuilder b; b.appendElements(m_oQueryAttr); b.appendElementsUnique(m_oQuerySpat); return b.obj(); } /************************************************************************/ /* GetFeatureCount() */ /************************************************************************/ GIntBig OGRMongoDBLayer::GetFeatureCount(int bForce) { if( m_poAttrQuery != nullptr || (m_poFilterGeom != nullptr && !TestCapability(OLCFastSpatialFilter)) ) { return OGRLayer::GetFeatureCount(bForce); } if( !m_bHasEstablishedFeatureDefn ) EstablishFeatureDefn(); if( m_poBulkBuilder ) SyncToDisk(); try { return (GIntBig) m_poDS->GetConn()->count(m_osQualifiedCollection, BuildQuery()); } catch( const DBException &e ) { CPLError(CE_Warning, CPLE_AppDefined, "%s: %s", "GetFeatureCount()", e.what()); return OGRLayer::GetFeatureCount(bForce); } } /************************************************************************/ /* Stringify() */ /************************************************************************/ static CPLString Stringify(const BSONElement& elt) { BSONType eBSONType = elt.type(); if( eBSONType == String ) return elt.String(); else if( eBSONType == NumberInt ) return CPLSPrintf("%d", elt.Int()); else if( eBSONType == NumberLong ) return CPLSPrintf(CPL_FRMT_GIB, elt.Long()); else if( eBSONType == NumberDouble ) return CPLSPrintf("%.16g", elt.Double()); else if( eBSONType == jstOID ) return elt.OID().toString().c_str(); else if( eBSONType == Bool ) return CPLSPrintf("%d", elt.Bool()); else if( eBSONType == Date ) { GIntBig secsandmillis = (GIntBig)elt.Date().millis; struct tm tm; GIntBig secs = secsandmillis / 1000; int millis = (int)(secsandmillis % 1000); if( millis < 0 ) { secs --; millis += 1000; } CPLUnixTimeToYMDHMS(secs, &tm); return CPLSPrintf("%04d-%02d-%02dT%02d:%02d:%02d.%03dZ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, millis); // Doesn't work with dates < 1970 //return dateToISOStringUTC(elt.Date()).c_str(); } else return elt.jsonString(Strict, false).c_str(); } /************************************************************************/ /* OGRMongoDBReaderSetField() */ /************************************************************************/ static void OGRMongoDBReaderSetField( OGRLayer* poLayer, OGRFeature* poFeature, const char* pszAttrName, const BSONElement* poElt, bool bFlattenNestedAttributes, char chNestedAttributeSeparator ) { int nGeomFieldIndex; if( poElt->type() == Object && (nGeomFieldIndex = poFeature->GetGeomFieldIndex(pszAttrName)) >= 0 ) { CPLPushErrorHandler(CPLQuietErrorHandler); OGRGeometry* poGeom = (OGRGeometry*)OGR_G_CreateGeometryFromJson( Stringify(*poElt) ); CPLPopErrorHandler(); if( poGeom != nullptr ) { poGeom->assignSpatialReference( poFeature->GetDefnRef()->GetGeomFieldDefn(nGeomFieldIndex)->GetSpatialRef() ); poFeature->SetGeomFieldDirectly(nGeomFieldIndex, poGeom); } return; } else if( poElt->type() == Array && (nGeomFieldIndex = poFeature->GetGeomFieldIndex(pszAttrName)) >= 0 ) { std::vector<BSONElement> oArray = poElt->Array(); int nSize = (int)oArray.size(); if( nSize == 2 ) { BSONElement& x = oArray[0]; BSONElement& y = oArray[1]; if( x.type() == NumberDouble && y.type() == NumberDouble ) { OGRGeometry* poGeom = new OGRPoint( x.Double(), y.Double() ); poGeom->assignSpatialReference( poFeature->GetDefnRef()->GetGeomFieldDefn(nGeomFieldIndex)->GetSpatialRef() ); poFeature->SetGeomFieldDirectly(nGeomFieldIndex, poGeom); } } return; } if( bFlattenNestedAttributes && poElt->type() == Object ) { BSONObj obj(poElt->Obj()); for( BSONObj::iterator i(obj); i.more(); ) { BSONElement elt(i.next()); char szSeparator[2]; szSeparator[0] = chNestedAttributeSeparator; szSeparator[1] = 0; CPLString osAttrName(CPLSPrintf("%s%s%s", pszAttrName, szSeparator, elt.fieldName())); OGRMongoDBReaderSetField(poLayer, poFeature, osAttrName, &elt, bFlattenNestedAttributes, chNestedAttributeSeparator); } return ; } int nField = poFeature->GetFieldIndex(pszAttrName); if( nField < 0 ) return; OGRFieldDefn* poFieldDefn = poFeature->GetFieldDefnRef(nField); CPLAssert( nullptr != poFieldDefn ); BSONType eBSONType = poElt->type(); OGRFieldType eType = poFieldDefn->GetType(); if( eBSONType == jstNULL ) poFeature->SetFieldNull( nField ); else if( eBSONType == NumberInt ) poFeature->SetField( nField, poElt->Int() ); else if( eBSONType == NumberLong ) poFeature->SetField( nField, poElt->Long() ); else if( eBSONType == NumberDouble ) poFeature->SetField( nField, poElt->Double() ); else if( eBSONType == MinKey && eType == OFTReal ) poFeature->SetField( nField, -std::numeric_limits<double>::infinity() ); else if( eBSONType == MaxKey && eType == OFTReal ) poFeature->SetField( nField, std::numeric_limits<double>::infinity() ); else if( eBSONType == MinKey && eType == OFTInteger ) poFeature->SetField( nField, INT_MIN ); else if( eBSONType == MaxKey && eType == OFTInteger ) poFeature->SetField( nField, INT_MAX ); else if( eBSONType == MinKey && eType == OFTInteger64 ) poFeature->SetField( nField, std::numeric_limits<GIntBig>::min() ); else if( eBSONType == MaxKey && eType == OFTInteger64 ) poFeature->SetField( nField, std::numeric_limits<GIntBig>::max() ); else if( eBSONType == Array ) { std::vector<BSONElement> oArray = poElt->Array(); int nSize = (int)oArray.size(); if( eType == OFTStringList ) { char** papszValues = (char**)CPLCalloc(nSize + 1, sizeof(char*)); for(int i=0;i<nSize;i++) { BSONElement& elt = oArray[i]; papszValues[i] = CPLStrdup(Stringify(elt)); } poFeature->SetField( nField, papszValues ); CSLDestroy(papszValues); } else if( eType == OFTRealList ) { double* padfValues = (double*)CPLMalloc(nSize * sizeof(double)); for(int i=0;i<nSize;i++) { BSONElement& elt = oArray[i]; eBSONType = elt.type(); if( eBSONType == NumberInt ) padfValues[i] = elt.Int(); else if( eBSONType == NumberLong ) padfValues[i] = (double)elt.Long(); else if( eBSONType == NumberDouble ) padfValues[i] = elt.Double(); else if( eBSONType == MinKey ) padfValues[i] = -std::numeric_limits<double>::infinity(); else if( eBSONType == MaxKey ) padfValues[i] = std::numeric_limits<double>::infinity(); else padfValues[i] = CPLAtof(Stringify(elt)); } poFeature->SetField( nField, nSize, padfValues ); CPLFree(padfValues); } else if( eType == OFTIntegerList ) { int* panValues = (int*)CPLMalloc(nSize * sizeof(int)); for(int i=0;i<nSize;i++) { BSONElement& elt = oArray[i]; eBSONType = elt.type(); if( eBSONType == NumberInt ) panValues[i] = elt.Int(); else if( eBSONType == NumberLong ) { GIntBig nVal = elt.Long(); if( nVal < INT_MIN ) panValues[i] = INT_MIN; else if( nVal > INT_MAX ) panValues[i] = INT_MAX; else panValues[i] = (int)nVal; } else if( eBSONType == NumberDouble ) { double dfVal = elt.Double(); if( dfVal < INT_MIN ) panValues[i] = INT_MIN; else if( dfVal > INT_MAX ) panValues[i] = INT_MAX; else panValues[i] = (int)dfVal; } else if( eBSONType == MinKey ) panValues[i] = INT_MIN; else if( eBSONType == MaxKey ) panValues[i] = INT_MAX; else panValues[i] = atoi(Stringify(elt)); } poFeature->SetField( nField, nSize, panValues ); CPLFree(panValues); } else if( eType == OFTInteger64List ) { GIntBig* panValues = (GIntBig*)CPLMalloc(nSize * sizeof(GIntBig)); for(int i=0;i<nSize;i++) { BSONElement& elt = oArray[i]; eBSONType = elt.type(); if( eBSONType == NumberInt ) panValues[i] = elt.Int(); else if( eBSONType == NumberLong ) panValues[i] = elt.Long(); else if( eBSONType == NumberDouble ) { double dfVal = elt.Double(); if( dfVal < std::numeric_limits<GIntBig>::min() ) panValues[i] = std::numeric_limits<GIntBig>::min(); else if( dfVal > static_cast<double>(std::numeric_limits<GIntBig>::max()) ) panValues[i] = std::numeric_limits<GIntBig>::max(); else panValues[i] = (int)dfVal; } else if( eBSONType == MinKey ) panValues[i] = std::numeric_limits<GIntBig>::min(); else if( eBSONType == MaxKey ) panValues[i] = std::numeric_limits<GIntBig>::max(); else panValues[i] = CPLAtoGIntBig(Stringify(elt)); } poFeature->SetField( nField, nSize, panValues ); CPLFree(panValues); } } else if( eBSONType == String ) poFeature->SetField( nField, poElt->String().c_str() ); else if( eBSONType == jstOID ) poFeature->SetField( nField, poElt->OID().toString().c_str() ); else if( eBSONType == Bool ) poFeature->SetField( nField, poElt->Bool() ); else if( eBSONType == BinData ) { int len; const char *pabyData = poElt->binDataClean(len); poFeature->SetField( nField, len, (GByte*)pabyData); } else poFeature->SetField( nField, Stringify(*poElt) ); } /************************************************************************/ /* Translate() */ /************************************************************************/ OGRFeature* OGRMongoDBLayer::Translate(BSONObj& obj) { OGRFeature* poFeature = new OGRFeature(GetLayerDefn()); try { for( BSONObj::iterator i(obj); i.more(); ) { BSONElement elt(i.next()); if( !m_osFID.empty() && EQUAL(m_osFID, elt.fieldName()) ) { BSONType eBSONType = elt.type(); if( eBSONType == NumberInt ) poFeature->SetFID(elt.Int()); else if( eBSONType == NumberLong ) poFeature->SetFID(elt.Long()); else if( eBSONType == NumberDouble ) poFeature->SetFID((GIntBig)elt.Double()); } else { OGRMongoDBReaderSetField(this, poFeature, elt.fieldName(), &elt, m_poDS->GetFlattenNestedAttributes(), '.'); } } if( m_poDS->JSonField() ) { poFeature->SetField("_json", obj.jsonString().c_str()); } } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "Translate()", e.what()); } return poFeature; } /************************************************************************/ /* GetNextFeature() */ /************************************************************************/ OGRFeature* OGRMongoDBLayer::GetNextFeature() { if( !m_bHasEstablishedFeatureDefn ) EstablishFeatureDefn(); if( m_poBulkBuilder ) SyncToDisk(); try { if( !m_bCursorValid ) { m_poCursor = m_poDS->GetConn()->query(m_osQualifiedCollection, BuildQuery(), 0, /* nToReturn */ 0, /* nToSkip */ nullptr, /* fieldsToReturn */ 0, /* queryOptions */ m_poDS->GetBatchSize()); m_bCursorValid = TRUE; } while( true ) { if( !m_poCursor->more() ) return nullptr; BSONObj obj = m_poCursor->nextSafe(); OGRFeature* poFeature = Translate(obj); if( poFeature->GetFID() < 0 ) poFeature->SetFID(++m_nIndex); if((m_poFilterGeom == nullptr || FilterGeometry( poFeature->GetGeometryRef() ) ) && (m_poAttrQuery == nullptr || m_poAttrQuery->Evaluate( poFeature )) ) { return poFeature; } else delete poFeature; } } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "GetNextFeature()", e.what()); return nullptr; } } /************************************************************************/ /* GetFeature() */ /************************************************************************/ OGRFeature* OGRMongoDBLayer::GetFeature(GIntBig nFID) { if( !m_bHasEstablishedFeatureDefn ) EstablishFeatureDefn(); if( m_poBulkBuilder ) SyncToDisk(); if( m_osFID.empty() ) { BSONObj oQueryAttrBak(m_oQueryAttr), oQuerySpatBak(m_oQuerySpat); OGRFeature* poFeature = OGRLayer::GetFeature(nFID); m_oQueryAttr = oQueryAttrBak; m_oQuerySpat = oQuerySpatBak; return poFeature; } try { UNIQUE_PTR<DBClientCursor> cursor = m_poDS->GetConn()->query( m_osQualifiedCollection, BSON(m_osFID.c_str() << nFID), 1); if( !cursor->more() ) return nullptr; BSONObj obj = cursor->nextSafe(); OGRFeature* poFeature = Translate(obj); poFeature->SetFID(nFID); return poFeature; } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "GetFeature()", e.what()); return nullptr; } } /************************************************************************/ /* DeleteFeature() */ /************************************************************************/ OGRErr OGRMongoDBLayer::DeleteFeature(GIntBig nFID) { if( m_poDS->GetAccess() != GA_Update ) { CPLError(CE_Failure, CPLE_AppDefined, "Dataset opened in read-only mode"); return OGRERR_FAILURE; } if( !m_bHasEstablishedFeatureDefn ) EstablishFeatureDefn(); if( m_poBulkBuilder ) SyncToDisk(); if( m_osFID.empty() ) return OGRERR_FAILURE; try { BSONObj obj = m_poDS->GetConn()->findAndRemove( m_osQualifiedCollection, BSON(m_osFID.c_str() << nFID), BSONObj(), BSONObj()); return (obj.isEmpty()) ? OGRERR_NON_EXISTING_FEATURE : OGRERR_NONE; } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "DeleteFeature()", e.what()); return OGRERR_FAILURE; } } /************************************************************************/ /* CreateField() */ /************************************************************************/ OGRErr OGRMongoDBLayer::CreateField( OGRFieldDefn *poFieldIn, CPL_UNUSED int bApproxOK ) { if( m_poDS->GetAccess() != GA_Update ) { CPLError(CE_Failure, CPLE_AppDefined, "Dataset opened in read-only mode"); return OGRERR_FAILURE; } if( m_poFeatureDefn->GetFieldIndex(poFieldIn->GetNameRef()) >= 0 ) { if( !EQUAL(poFieldIn->GetNameRef(), "_id") && !EQUAL(poFieldIn->GetNameRef(), "_json") ) { CPLError(CE_Failure, CPLE_AppDefined, "CreateField() called with an already existing field name: %s", poFieldIn->GetNameRef()); } return OGRERR_FAILURE; } m_poFeatureDefn->AddFieldDefn( poFieldIn ); std::vector<CPLString> aosPaths; if( m_bDotAsNestedField ) { char** papszTokens = CSLTokenizeString2(poFieldIn->GetNameRef(), ".", 0); for(int i=0; papszTokens[i]; i++ ) aosPaths.push_back(papszTokens[i]); CSLDestroy(papszTokens); } else aosPaths.push_back(poFieldIn->GetNameRef()); m_aaosFieldPaths.push_back(aosPaths); m_bUpdateLayerMetadata = m_bLayerMetadataUpdatable; return OGRERR_NONE; } /************************************************************************/ /* CreateGeomField() */ /************************************************************************/ OGRErr OGRMongoDBLayer::CreateGeomField( OGRGeomFieldDefn *poFieldIn, CPL_UNUSED int bApproxOK ) { if( m_poDS->GetAccess() != GA_Update ) { CPLError(CE_Failure, CPLE_AppDefined, "Dataset opened in read-only mode"); return OGRERR_FAILURE; } if( m_poFeatureDefn->GetGeomFieldIndex(poFieldIn->GetNameRef()) >= 0 ) { CPLError(CE_Failure, CPLE_AppDefined, "CreateGeomField() called with an already existing field name: %s", poFieldIn->GetNameRef()); return OGRERR_FAILURE; } OGRGeomFieldDefn oFieldDefn(poFieldIn); if( EQUAL(oFieldDefn.GetNameRef(), "") ) oFieldDefn.SetName("geometry"); m_poFeatureDefn->AddGeomFieldDefn( &oFieldDefn ); std::vector<CPLString> aosPaths; if( m_bDotAsNestedField ) { char** papszTokens = CSLTokenizeString2(oFieldDefn.GetNameRef(), ".", 0); for(int i=0; papszTokens[i]; i++ ) aosPaths.push_back(papszTokens[i]); CSLDestroy(papszTokens); } else aosPaths.push_back(oFieldDefn.GetNameRef()); m_aaosGeomFieldPaths.push_back(aosPaths); m_aosGeomIndexes.push_back("none"); OGRCoordinateTransformation* poCT = nullptr; if( oFieldDefn.GetSpatialRef() != nullptr ) { OGRSpatialReference oSRS_WGS84; oSRS_WGS84.SetFromUserInput(SRS_WKT_WGS84); if( !oSRS_WGS84.IsSame(oFieldDefn.GetSpatialRef()) ) { poCT = OGRCreateCoordinateTransformation( oFieldDefn.GetSpatialRef(), &oSRS_WGS84 ); if( poCT == nullptr ) { CPLError( CE_Warning, CPLE_AppDefined, "On-the-fly reprojection to WGS84 long/lat would be " "needed, but instantiation of transformer failed" ); } } } m_apoCT.push_back(poCT); if( m_bCreateSpatialIndex ) { //CPLDebug("MongoDB", "Create spatial index for %s of %s", // poFieldIn->GetNameRef(), m_osQualifiedCollection.c_str()); try { const char* pszIndexType; if( wkbFlatten(poFieldIn->GetType()) != wkbPoint ) pszIndexType = "2dsphere"; else pszIndexType = CPLGetConfigOption("OGR_MONGODB_SPAT_INDEX_TYPE", "2dsphere"); m_poDS->GetConn()->createIndex(m_osQualifiedCollection, BSON( oFieldDefn.GetNameRef() << pszIndexType )); m_aosGeomIndexes.back() = pszIndexType; } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "Index creation", e.what()); } } m_bUpdateLayerMetadata = m_bLayerMetadataUpdatable; return OGRERR_NONE; } /************************************************************************/ /* SerializeField() */ /************************************************************************/ void OGRMongoDBLayer::SerializeField(BSONObjBuilder& b, OGRFeature *poFeature, int iField, const char* pszJSonField) { OGRFieldType eType = m_poFeatureDefn->GetFieldDefn(iField)->GetType(); if( poFeature->IsFieldNull(iField) ) { b.appendNull( pszJSonField ); } else if( eType == OFTInteger ) { if( m_poFeatureDefn->GetFieldDefn(iField)->GetSubType() == OFSTBoolean ) b.append( pszJSonField, CPL_TO_BOOL(poFeature->GetFieldAsInteger(iField)) ); else b.append( pszJSonField, poFeature->GetFieldAsInteger(iField) ); } else if( eType == OFTInteger64 ) b.append( pszJSonField, poFeature->GetFieldAsInteger64(iField) ); else if( eType == OFTReal ) b.append( pszJSonField, poFeature->GetFieldAsDouble(iField) ); else if( eType == OFTString ) b.append( pszJSonField, poFeature->GetFieldAsString(iField) ); else if( eType == OFTStringList ) { char** papszValues = poFeature->GetFieldAsStringList(iField); BSONArrayBuilder arrayBuilder; for(int i=0; papszValues[i]; i++) arrayBuilder.append( papszValues[i] ); b.append( pszJSonField, arrayBuilder.arr() ); } else if( eType == OFTIntegerList ) { int nSize; const int* panValues = poFeature->GetFieldAsIntegerList(iField, &nSize); BSONArrayBuilder arrayBuilder; for(int i=0; i<nSize; i++) arrayBuilder.append( panValues[i] ); b.append( pszJSonField, arrayBuilder.arr() ); } else if( eType == OFTInteger64List ) { int nSize; const GIntBig* panValues = poFeature->GetFieldAsInteger64List(iField, &nSize); BSONArrayBuilder arrayBuilder; for(int i=0; i<nSize; i++) arrayBuilder.append( panValues[i] ); b.append( pszJSonField, arrayBuilder.arr() ); } else if( eType == OFTRealList ) { int nSize; const double* padfValues = poFeature->GetFieldAsDoubleList(iField, &nSize); BSONArrayBuilder arrayBuilder; for(int i=0; i<nSize; i++) arrayBuilder.append( padfValues[i] ); b.append( pszJSonField, arrayBuilder.arr() ); } else if( eType == OFTBinary ) { int nSize; const GByte* pabyData = poFeature->GetFieldAsBinary(iField, &nSize); b.appendBinData( pszJSonField, nSize, BinDataGeneral, (const void*)pabyData); } else if( eType == OFTDate || eType == OFTDateTime || eType == OFTTime ) { struct tm tm; int nYear, nMonth, nDay, nHour, nMinute, nTZ; float fSecond; poFeature->GetFieldAsDateTime(iField, &nYear, &nMonth, &nDay, &nHour, &nMinute, &fSecond, &nTZ); tm.tm_year = nYear - 1900; tm.tm_mon = nMonth - 1; tm.tm_mday = nDay; tm.tm_hour = nHour; tm.tm_min = nMinute; tm.tm_sec = (int)fSecond; GIntBig millis = 1000 * CPLYMDHMSToUnixTime(&tm) + (GIntBig)(1000 * fmod(fSecond, 1)); b.append( pszJSonField, Date_t((GUIntBig)millis) ); //char* pszDT = OGRGetXMLDateTime(poFeature->GetRawFieldRef(i)); //StatusWith<Date_t> d = dateFromISOString(pszDT); //if( d.isOK() ) // b.append( pszJSonField, d.getValue() ); //CPLFree(pszDT); } } /************************************************************************/ /* OGRLocaleSafeFromJSON() */ /************************************************************************/ static BSONObj OGRLocaleSafeFromJSON(const char* pszJSon) { CPLThreadLocaleC oCLocale; return fromjson(pszJSon); } /************************************************************************/ /* SerializeGeometry() */ /************************************************************************/ void OGRMongoDBLayer::SerializeGeometry(BSONObjBuilder& b, OGRGeometry* poGeom, int iField, const char* pszJSonField) { if( m_aosGeomIndexes[iField] == "2d" && wkbFlatten(poGeom->getGeometryType()) == wkbPoint ) { BSONArrayBuilder arrayBuilder; arrayBuilder.append( ((OGRPoint*)poGeom)->getX() ); arrayBuilder.append( ((OGRPoint*)poGeom)->getY() ); b.append( pszJSonField, arrayBuilder.arr() ); } else { char* pszJSon = OGR_G_ExportToJson((OGRGeometryH)poGeom); if( pszJSon ) b.append(pszJSonField, OGRLocaleSafeFromJSON(pszJSon)); CPLFree(pszJSon); } } /************************************************************************/ /* SerializeRecursive() */ /************************************************************************/ void OGRMongoDBLayer::SerializeRecursive(BSONObjBuilder& b, OGRFeature *poFeature, std::map< CPLString, IntOrMap*>& aoMap ) { std::map< CPLString, IntOrMap* >::iterator oIter = aoMap.begin(); for( ; oIter != aoMap.end(); ++oIter) { IntOrMap* intOrMap = oIter->second; if( intOrMap->bIsMap ) { BSONObjBuilder subB; SerializeRecursive(subB, poFeature, *(intOrMap->u.poMap)); b.append( oIter->first.c_str(), subB.obj() ); delete intOrMap->u.poMap; } else { int i = intOrMap->u.nField; if( i >= 0) { SerializeField(b, poFeature, i, oIter->first.c_str()); } else { i = -i - 1; OGRGeometry* poGeom = poFeature->GetGeomFieldRef(i); SerializeGeometry(b, poGeom, i, oIter->first.c_str()); } } delete intOrMap; } } /************************************************************************/ /* InsertInMap() */ /************************************************************************/ void OGRMongoDBLayer::InsertInMap(IntOrMap* rootMap, std::map< std::vector<CPLString>, IntOrMap*>& aoMap, const std::vector<CPLString>& aosFieldPathFull, int nField) { std::vector<CPLString> aosFieldPath; std::vector<CPLString> aosFieldPathPrev; for(int j=0; j<(int)aosFieldPathFull.size() - 1; j++) { aosFieldPath.push_back(aosFieldPathFull[j]); if( aoMap.find(aosFieldPath) == aoMap.end() ) { IntOrMap* intOrMap = new IntOrMap; intOrMap->bIsMap = TRUE; intOrMap->u.poMap = new std::map< CPLString, IntOrMap*>; aoMap[aosFieldPath] = intOrMap; } if( j > 0 ) { std::map< CPLString, IntOrMap* >* poPrevMap = aoMap[aosFieldPathPrev]->u.poMap; (*poPrevMap)[aosFieldPathFull[j]] = aoMap[aosFieldPath]; } else (*(rootMap->u.poMap))[aosFieldPathFull[j]] = aoMap[aosFieldPath]; aosFieldPathPrev.push_back(aosFieldPathFull[j]); } IntOrMap* intOrMap = new IntOrMap; intOrMap->bIsMap = FALSE; intOrMap->u.nField = nField; std::map< CPLString, IntOrMap* >* poPrevMap = aoMap[aosFieldPathPrev]->u.poMap; const CPLString& osLastComponent(aosFieldPathFull.back()); CPLAssert( (*poPrevMap).find(osLastComponent) == (*poPrevMap).end() ); (*(poPrevMap))[osLastComponent] = intOrMap; } /************************************************************************/ /* BuildBSONObjFromFeature() */ /************************************************************************/ BSONObj OGRMongoDBLayer::BuildBSONObjFromFeature(OGRFeature* poFeature, int bUpdate) { BSONObjBuilder b; int nJSonFieldIndex = m_poFeatureDefn->GetFieldIndex("_json"); if( nJSonFieldIndex >= 0 && poFeature->IsFieldSetAndNotNull(nJSonFieldIndex) ) { CPLString osJSon(poFeature->GetFieldAsString(nJSonFieldIndex)); // Workaround bug in JParse::dateObject() with { "$numberLong": "-123456" } // that cannot be parsed successfully while( true ) { size_t i = osJSon.find("{ \"$date\" : { \"$numberLong\" : \"-"); if( i == std::string::npos ) break; size_t j = osJSon.find("\" }", i+strlen("{ \"$date\" : { \"$numberLong\" : \"-")); if( j == std::string::npos ) break; GIntBig negNumber = CPLAtoGIntBig(osJSon.c_str() + i+strlen("{ \"$date\" : { \"$numberLong\" : \"-")-1); osJSon = osJSon.substr(0, i+strlen("{ \"$date\" : ")) + CPLSPrintf(CPL_FRMT_GIB, negNumber) + osJSon.substr(j+strlen("\" }")); } BSONObj obj(OGRLocaleSafeFromJSON(osJSon)); if( (m_bIgnoreSourceID || !obj.hasField("_id")) && !bUpdate ) { const OID generated = OID::gen(); b.append("_id", generated); poFeature->SetField(0, generated.toString().c_str()); } b.appendElementsUnique(obj); //BSONObj obj2(b.obj()); //printf("%s\n", obj2.jsonString(Strict).c_str()); //return obj2; return b.obj(); } if( poFeature->GetFID() >= 0 && !m_osFID.empty() ) { b.append( m_osFID.c_str(), poFeature->GetFID() ); } CPLAssert((int)m_aaosFieldPaths.size() == m_poFeatureDefn->GetFieldCount()); if( !poFeature->IsFieldSetAndNotNull(0) || (!bUpdate && m_bIgnoreSourceID) ) { const OID generated = OID::gen(); b.append("_id", generated); poFeature->SetField(0, generated.toString().c_str()); } else b.append("_id", OID(poFeature->GetFieldAsString(0)) ); IntOrMap* rootMap = new IntOrMap; rootMap->bIsMap = TRUE; rootMap->u.poMap = new std::map< CPLString, IntOrMap*>; std::map< std::vector<CPLString>, IntOrMap*> aoMap; for(int i=1;i<m_poFeatureDefn->GetFieldCount();i++) { if( !poFeature->IsFieldSet(i) ) continue; if( m_aaosFieldPaths[i].size() > 1 ) { InsertInMap(rootMap, aoMap, m_aaosFieldPaths[i], i); } else { const char* pszFieldName = m_poFeatureDefn->GetFieldDefn(i)->GetNameRef(); SerializeField(b, poFeature, i, pszFieldName); } } CPLAssert((int)m_aaosGeomFieldPaths.size() == m_poFeatureDefn->GetGeomFieldCount()); CPLAssert((int)m_apoCT.size() == m_poFeatureDefn->GetGeomFieldCount()); for(int i=0;i<m_poFeatureDefn->GetGeomFieldCount();i++) { OGRGeometry* poGeom = poFeature->GetGeomFieldRef(i); if( poGeom == nullptr ) continue; if( !bUpdate && m_apoCT[i] != nullptr ) poGeom->transform( m_apoCT[i] ); if( m_aaosGeomFieldPaths[i].size() > 1 ) { InsertInMap(rootMap, aoMap, m_aaosGeomFieldPaths[i], -i-1); } else { const char* pszFieldName = m_poFeatureDefn->GetGeomFieldDefn(i)->GetNameRef(); SerializeGeometry(b, poGeom, i, pszFieldName); } } SerializeRecursive(b, poFeature, *(rootMap->u.poMap)); delete rootMap->u.poMap; delete rootMap; return b.obj(); } /************************************************************************/ /* ICreateFeature() */ /************************************************************************/ OGRErr OGRMongoDBLayer::ICreateFeature( OGRFeature *poFeature ) { if( m_poDS->GetAccess() != GA_Update ) { CPLError(CE_Failure, CPLE_AppDefined, "Dataset opened in read-only mode"); return OGRERR_FAILURE; } if( !m_bHasEstablishedFeatureDefn ) EstablishFeatureDefn(); try { if( poFeature->GetFID() < 0 ) { if( m_nNextFID == 0 ) m_nNextFID = GetFeatureCount(FALSE); poFeature->SetFID(++m_nNextFID); } BSONObj bsonObj( BuildBSONObjFromFeature(poFeature, FALSE) ); if( m_poDS->BulkInsert() ) { if( m_nFeaturesInBulk == MAX_DOCS_IN_BULK ) SyncToDisk(); if( m_poBulkBuilder == nullptr ) m_poBulkBuilder = new BulkOperationBuilder( m_poDS->GetConn(), m_osQualifiedCollection, false); m_poBulkBuilder->insert( bsonObj ); m_nFeaturesInBulk ++; } else { m_poDS->GetConn()->insert( m_osQualifiedCollection, bsonObj ); } return OGRERR_NONE; } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "CreateFeature()", e.what()); return OGRERR_FAILURE; } } /************************************************************************/ /* ISetFeature() */ /************************************************************************/ OGRErr OGRMongoDBLayer::ISetFeature( OGRFeature *poFeature ) { if( m_poDS->GetAccess() != GA_Update ) { CPLError(CE_Failure, CPLE_AppDefined, "Dataset opened in read-only mode"); return OGRERR_FAILURE; } if( !m_bHasEstablishedFeatureDefn ) EstablishFeatureDefn(); if( m_poBulkBuilder ) SyncToDisk(); if( !poFeature->IsFieldSetAndNotNull(0) ) { CPLError(CE_Failure, CPLE_AppDefined, "_id field not set"); return OGRERR_FAILURE; } try { BSONObj obj( BuildBSONObjFromFeature(poFeature, TRUE) ); // TODO? we should theoretically detect if the provided _id doesn't exist m_poDS->GetConn()->update( m_osQualifiedCollection, MONGO_QUERY("_id" << obj.getField("_id")), obj, false, false ); return OGRERR_NONE; } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "SetFeature()", e.what()); return OGRERR_FAILURE; } } /************************************************************************/ /* TestCapability() */ /************************************************************************/ int OGRMongoDBLayer::TestCapability(const char* pszCap) { if( EQUAL(pszCap, OLCStringsAsUTF8) ) { return TRUE; } else if( EQUAL(pszCap,OLCRandomRead) ) { EstablishFeatureDefn(); return !m_osFID.empty(); } else if( EQUAL(pszCap, OLCFastSpatialFilter) ) { EstablishFeatureDefn(); for(int i=0;i<m_poFeatureDefn->GetGeomFieldCount();i++) { if( m_aosGeomIndexes[i] == "none" ) { return FALSE; } } return TRUE; } else if( EQUAL(pszCap, OLCCreateField) || EQUAL(pszCap, OLCCreateGeomField) || EQUAL(pszCap, OLCSequentialWrite) || EQUAL(pszCap, OLCRandomWrite) ) { return m_poDS->GetAccess() == GA_Update; } else if( EQUAL(pszCap,OLCDeleteFeature) ) { EstablishFeatureDefn(); return m_poDS->GetAccess() == GA_Update && !m_osFID.empty(); } return FALSE; } /************************************************************************/ /* SetAttributeFilter() */ /************************************************************************/ OGRErr OGRMongoDBLayer::SetAttributeFilter(const char* pszFilter) { m_oQueryAttr = BSONObj(); if( pszFilter != nullptr && pszFilter[0] == '{' ) { OGRLayer::SetAttributeFilter(nullptr); try { m_oQueryAttr = OGRLocaleSafeFromJSON(pszFilter); return OGRERR_NONE; } catch( const DBException &e ) { m_oQueryAttr = BSONObj(); CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "SetAttributeFilter()", e.what()); return OGRERR_FAILURE; } } return OGRLayer::SetAttributeFilter(pszFilter); } /************************************************************************/ /* SetSpatialFilter() */ /************************************************************************/ void OGRMongoDBLayer::SetSpatialFilter( int iGeomField, OGRGeometry * poGeomIn ) { if( iGeomField < 0 || iGeomField >= GetLayerDefn()->GetGeomFieldCount() || GetLayerDefn()->GetGeomFieldDefn(iGeomField)->GetType() == wkbNone ) { if( iGeomField != 0 ) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid geometry field index : %d", iGeomField); } return; } m_iGeomFieldFilter = iGeomField; m_oQuerySpat = BSONObj(); if( InstallFilter( poGeomIn ) && poGeomIn ) { OGREnvelope sEnvelope; poGeomIn->getEnvelope(&sEnvelope); if( sEnvelope.MaxX == sEnvelope.MinX ) sEnvelope.MaxX += 1e-10; if( sEnvelope.MaxY == sEnvelope.MinY ) sEnvelope.MaxY += 1e-10; if( sEnvelope.MinX < -180 ) sEnvelope.MinX = -180; if( sEnvelope.MinY < -90 ) sEnvelope.MinY = -90; if( sEnvelope.MaxX > 180 ) sEnvelope.MaxX = 180; if( sEnvelope.MaxY > 90 ) sEnvelope.MaxY = 90; if( sEnvelope.MinX == -180 && sEnvelope.MinY == -90 && sEnvelope.MaxX == 180 && sEnvelope.MaxY == 90 ) { return; } try { if( m_aosGeomIndexes[m_iGeomFieldFilter] == "2dsphere" ) { m_oQuerySpat = OGRLocaleSafeFromJSON(CPLSPrintf("{ \"%s\" : { $geoIntersects : " "{ $geometry : { type : \"Polygon\" , coordinates : [[" "[%.16g,%.16g],[%.16g,%.16g],[%.16g,%.16g],[%.16g,%.16g],[%.16g,%.16g]]] } } } }", m_poFeatureDefn->GetGeomFieldDefn(iGeomField)->GetNameRef(), sEnvelope.MinX, sEnvelope.MinY, sEnvelope.MaxX, sEnvelope.MinY, sEnvelope.MaxX, sEnvelope.MaxY, sEnvelope.MinX, sEnvelope.MaxY, sEnvelope.MinX, sEnvelope.MinY)); } else if( m_aosGeomIndexes[m_iGeomFieldFilter] == "2d" ) { m_oQuerySpat = OGRLocaleSafeFromJSON(CPLSPrintf("{ \"%s\" : { $geoWithin : " "{ $box : [ [ %.16g , %.16g ] , [ %.16g , %.16g ] ] } } }", m_poFeatureDefn->GetGeomFieldDefn(iGeomField)->GetNameRef(), sEnvelope.MinX, sEnvelope.MinY, sEnvelope.MaxX, sEnvelope.MaxY)); } } catch( const DBException &e ) { CPLError(CE_Failure, CPLE_AppDefined, "%s: %s", "SetSpatialFilter()", e.what()); } } } /************************************************************************/ /* OGRMongoDBDataSource() */ /************************************************************************/ OGRMongoDBDataSource::OGRMongoDBDataSource() { m_poConn = nullptr; m_nBatchSize = 0; m_nFeatureCountToEstablishFeatureDefn = 0; m_bJSonField = FALSE; m_bUseOGRMetadata = TRUE; m_bBulkInsert = TRUE; m_bFlattenNestedAttributes = TRUE; } /************************************************************************/ /* ~OGRMongoDBDataSource() */ /************************************************************************/ OGRMongoDBDataSource::~OGRMongoDBDataSource() { for(int i=0; i<(int)m_apoLayers.size(); i++ ) { delete m_apoLayers[i]; } delete m_poConn; } /************************************************************************/ /* GetLayer() */ /************************************************************************/ OGRLayer* OGRMongoDBDataSource::GetLayer(int nIdx) { if( nIdx < 0 || nIdx >= (int)m_apoLayers.size() ) return nullptr; return m_apoLayers[nIdx]; } /************************************************************************/ /* GetLayerByName() */ /************************************************************************/ OGRLayer *OGRMongoDBDataSource::GetLayerByName(const char* pszLayerName) { OGRLayer* poLayer = GDALDataset::GetLayerByName(pszLayerName); if( poLayer != nullptr ) return poLayer; for(int i=0; i<(int)m_apoLayers.size(); i++ ) { m_apoLayers[i]->SyncToDisk(); } CPLString osDatabase; if( m_osDatabase.empty() ) { const char* pszDot = strchr(pszLayerName, '.'); if( pszDot == nullptr ) return nullptr; osDatabase = pszLayerName; osDatabase.resize(pszDot - pszLayerName); pszLayerName = pszDot + 1; } else osDatabase = m_osDatabase; for(int i=0;i<2;i++) { try { std::list<std::string> l = m_poConn->getCollectionNames( osDatabase ); for ( std::list<std::string>::iterator oIter = l.begin(); oIter != l.end(); ++oIter ) { const std::string& osCollection(*oIter); if( EQUAL(osCollection.c_str(),pszLayerName) ) { OGRMongoDBLayer* l_poLayer = new OGRMongoDBLayer(this, osDatabase, osCollection.c_str()); m_apoLayers.push_back(l_poLayer); return l_poLayer; } } } catch( const DBException &e) { CPLError(CE_Failure, CPLE_AppDefined, "Command failed: %s", e.what()); } if( i == 0 ) { if( m_osDatabase.empty() ) break; const char* pszDot = strchr(pszLayerName, '.'); if( pszDot == nullptr ) break; osDatabase = pszLayerName; osDatabase.resize(pszDot - pszLayerName); pszLayerName = pszDot + 1; } } return nullptr; } /************************************************************************/ /* Initialize() */ /************************************************************************/ int OGRMongoDBDataSource::Initialize(char** papszOpenOptions) { CPLString osPEMKeyFile = CSLFetchNameValueDef(papszOpenOptions, "SSL_PEM_KEY_FILE", ""); CPLString osPEMKeyPassword = CSLFetchNameValueDef(papszOpenOptions, "SSL_PEM_KEY_PASSWORD", ""); CPLString osCAFile = CSLFetchNameValueDef(papszOpenOptions, "SSL_CA_FILE", ""); CPLString osCRLFile = CSLFetchNameValueDef(papszOpenOptions, "SSL_CRL_FILE", ""); int bAllowInvalidCertificates = CPLFetchBool(papszOpenOptions, "SSL_ALLOW_INVALID_CERTIFICATES", false); int bAllowInvalidHostnames = CPLFetchBool(papszOpenOptions, "SSL_ALLOW_INVALID_HOSTNAMES", false); int bFIPSMode = CPLFetchBool(papszOpenOptions, "FIPS_MODE", false); if( bMongoInitialized < 0 ) { Options options; osStaticPEMKeyFile = osPEMKeyFile; osStaticPEMKeyPassword = osPEMKeyPassword; osStaticCAFile = osCAFile; osStaticCRLFile = osCRLFile; bStaticAllowInvalidCertificates = bAllowInvalidCertificates; bStaticAllowInvalidHostnames = bAllowInvalidHostnames; bStaticFIPSMode = bFIPSMode; if( !osPEMKeyFile.empty() || !osPEMKeyPassword.empty() || !osCAFile.empty() || !osCRLFile.empty() ) { options.setSSLMode(Options::kSSLRequired); if( !osPEMKeyFile.empty() ) options.setSSLPEMKeyFile(osPEMKeyFile); if( osPEMKeyPassword ) options.setSSLPEMKeyPassword(osPEMKeyPassword); if( !osCAFile.empty() ) options.setSSLCAFile(osCAFile); if( !osCRLFile.empty() ) options.setSSLCRLFile(osCRLFile); if( bAllowInvalidCertificates ) options.setSSLAllowInvalidCertificates(true); if( bAllowInvalidHostnames ) options.setSSLAllowInvalidHostnames(true); } if( bFIPSMode ) options.setFIPSMode(true); Status status = client::initialize(options); bMongoInitialized = status.isOK(); if( !status.isOK() ) { CPLError(CE_Failure, CPLE_AppDefined, "Mongo initialization failed: %s", status.toString().c_str()); return FALSE; } } else if( !bMongoInitialized ) { CPLError(CE_Failure, CPLE_AppDefined, "Previous initialization of MongoDB failed"); return FALSE; } if( osPEMKeyFile != osStaticPEMKeyFile ) { CPLError(CE_Warning, CPLE_AppDefined, "Value of %s different from first initialization. Using initial value", "SSL_PEM_KEY_FILE"); } if( osPEMKeyPassword != osStaticPEMKeyPassword ) { CPLError(CE_Warning, CPLE_AppDefined, "Value of %s different from first initialization. Using initial value", "SSL_PEM_KEY_PASSWORD"); } if( osCAFile != osStaticCAFile ) { CPLError(CE_Warning, CPLE_AppDefined, "Value of %s different from first initialization. Using initial value", "SSL_CA_FILE"); } if( osCRLFile != osStaticCRLFile ) { CPLError(CE_Warning, CPLE_AppDefined, "Value of %s different from first initialization. Using initial value", "SSL_CRL_FILE"); } if( bAllowInvalidCertificates != bStaticAllowInvalidCertificates ) { CPLError(CE_Warning, CPLE_AppDefined, "Value of %s different from first initialization. Using initial value", "SSL_ALLOW_INVALID_CERTIFICATES"); } if( bAllowInvalidHostnames != bStaticAllowInvalidHostnames ) { CPLError(CE_Warning, CPLE_AppDefined, "Value of %s different from first initialization. Using initial value", "SSL_ALLOW_INVALID_HOSTNAMES"); } if( bFIPSMode != bStaticFIPSMode ) { CPLError(CE_Warning, CPLE_AppDefined, "Value of %s different from first initialization. Using initial value", "FIPS_MODE"); } return TRUE; } /************************************************************************/ /* Open() */ /************************************************************************/ int OGRMongoDBDataSource::Open(const char* pszFilename, GDALAccess eAccessIn, char** papszOpenOptionsIn) { if( !Initialize(papszOpenOptionsIn) ) return FALSE; this->eAccess = eAccessIn; const char* pszHost = CSLFetchNameValueDef(papszOpenOptionsIn, "HOST", "localhost"); const char* pszPort = CSLFetchNameValueDef(papszOpenOptionsIn, "PORT", "27017"); const char* pszURI = CSLFetchNameValue(papszOpenOptionsIn, "URI"); if( STARTS_WITH_CI(pszFilename, "mongodb://") ) pszURI = pszFilename; std::string errmsg; if( pszURI != nullptr ) { try { /** * ConnectionString can parse MongoDB URIs with the following format: * * mongodb://[usr:pwd@]host1[:port1]...[,hostN[:portN]]][/[db][?options]] * * For a complete list of URI string options, see * http://docs.mongodb.org/v2.6/reference/connection-string/ * * Examples: * * A replica set with three members (one running on default port 27017): * string uri = mongodb://localhost,localhost:27018,localhost:27019 * * Authenticated connection to db 'bedrock' with user 'barney' and pwd 'rubble': * string url = mongodb://barney:rubble@localhost/bedrock */ ConnectionString cs = ConnectionString::parse( pszURI, errmsg ); if( !cs.isValid() ) { CPLError(CE_Failure, CPLE_AppDefined, "Bad connection string: %s", errmsg.c_str()); return FALSE; } m_osDatabase = cs.getDatabase(); m_poConn = cs.connect( errmsg ); if( m_poConn == nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot connect: %s", errmsg.c_str()); return FALSE; } } catch( const DBException &e) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot connect: %s", e.what()); return FALSE; } } else { DBClientConnection* poConn = new DBClientConnection(); m_poConn = poConn; try { if( !poConn->connect(CPLSPrintf("%s:%s", pszHost, pszPort), errmsg ) ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot connect: %s", errmsg.c_str()); return FALSE; } } catch( const DBException &e) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot connect: %s", e.what()); return FALSE; } } if( m_osDatabase.empty() ) { m_osDatabase = CSLFetchNameValueDef(papszOpenOptionsIn, "DBNAME", ""); /*if( m_osDatabase.empty() ) { CPLError(CE_Failure, CPLE_AppDefined, "No database name specified"); return FALSE; }*/ } const char* pszAuthJSON = CSLFetchNameValue(papszOpenOptionsIn, "AUTH_JSON"); if( pszAuthJSON ) { try { /* The "params" BSONObj should be initialized with some of the fields below. Which fields * are required depends on the mechanism, which is mandatory. * * "mechanism": The string name of the sasl mechanism to use. Mandatory. const char kAuthMechMongoCR[] = "MONGODB-CR"; const char kAuthMechScramSha1[] = "SCRAM-SHA-1"; const char kAuthMechDefault[] = "DEFAULT"; * "user": The string name of the user to authenticate. Mandatory. * "db": The database target of the auth command, which identifies the location * of the credential information for the user. May be "$external" if * credential information is stored outside of the mongo cluster. Mandatory. * "pwd": The password data. * "digestPassword": Boolean, set to true if the "pwd" is undigested (default). * "serviceName": The GSSAPI service name to use. Defaults to "mongodb". * "serviceHostname": The GSSAPI hostname to use. Defaults to the name of the remote * host. */ m_poConn->auth(OGRLocaleSafeFromJSON(pszAuthJSON)); } catch( const DBException &e) { CPLError(CE_Failure, CPLE_AppDefined, "Authentication failed: %s", e.what()); return FALSE; } } else { const char* pszUser = CSLFetchNameValue(papszOpenOptionsIn, "USER"); const char* pszPassword = CSLFetchNameValue(papszOpenOptionsIn, "PASSWORD"); const char* pszAuthDBName = CSLFetchNameValue(papszOpenOptionsIn, "AUTH_DBNAME"); if( (pszUser != nullptr && pszPassword == nullptr) || (pszUser == nullptr && pszPassword != nullptr) ) { CPLError(CE_Failure, CPLE_AppDefined, "USER and PASSWORD open options must be both specified."); return FALSE; } if( pszUser && pszPassword ) { if( m_osDatabase.empty() && pszAuthDBName == nullptr) { CPLError(CE_Failure, CPLE_AppDefined, "No database or authentication database name specified."); return FALSE; } try { if( !m_poConn->auth(pszAuthDBName ? pszAuthDBName : m_osDatabase.c_str(), pszUser, pszPassword, errmsg) ) { CPLError(CE_Failure, CPLE_AppDefined, "Authentication failed: %s", errmsg.c_str()); return FALSE; } } catch( const DBException &e) { CPLError(CE_Failure, CPLE_AppDefined, "Authentication failed: %s", e.what()); return FALSE; } } else if( pszAuthDBName != nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "AUTH_DBNAME ignored when USER and PASSWORD open options are not specified."); } } m_nBatchSize = atoi(CSLFetchNameValueDef(papszOpenOptionsIn, "BATCH_SIZE", "0")); m_nFeatureCountToEstablishFeatureDefn = atoi(CSLFetchNameValueDef( papszOpenOptionsIn, "FEATURE_COUNT_TO_ESTABLISH_FEATURE_DEFN", "100")); m_bJSonField = CPLFetchBool(papszOpenOptionsIn, "JSON_FIELD", false); m_bFlattenNestedAttributes = CPLFetchBool(papszOpenOptionsIn, "FLATTEN_NESTED_ATTRIBUTES", true); m_osFID = CSLFetchNameValueDef(papszOpenOptionsIn, "FID", "ogc_fid"); m_bUseOGRMetadata = CPLFetchBool( papszOpenOptionsIn, "USE_OGR_METADATA", true); m_bBulkInsert = CPLFetchBool(papszOpenOptionsIn, "BULK_INSERT", true); int bRet = TRUE; if( m_osDatabase.empty() ) { try { std::list<std::string> l = m_poConn->getDatabaseNames(); for ( std::list<std::string>::iterator i = l.begin(); i != l.end(); ++i ) { bRet &= ListLayers((*i).c_str()); } } catch( const DBException &e) { if( e.getCode() == 10005 ) { try { BSONObj info; m_poConn->runCommand("admin", BSON("listDatabases" << 1), info, QueryOption_SlaveOk); CPLError(CE_Failure, CPLE_AppDefined, "Command failed: %s", info.jsonString().c_str()); } catch( const DBException &e2) { CPLError(CE_Failure, CPLE_AppDefined, "Command failed: %s", e2.what()); } } else { CPLError(CE_Failure, CPLE_AppDefined, "Command failed: %s", e.what()); } return FALSE; } } else { bRet = ListLayers(m_osDatabase); } return bRet; } /************************************************************************/ /* ListLayers() */ /************************************************************************/ int OGRMongoDBDataSource::ListLayers(const char* pszDatabase) { try { std::list<std::string> aoListNames = m_poConn->getCollectionNames( pszDatabase ); for ( std::list<std::string>::iterator oIter = aoListNames.begin(); oIter != aoListNames.end(); ++oIter ) { const std::string& osCollection(*oIter); if( !STARTS_WITH(osCollection.c_str(), "system.") && osCollection != "startup_log" && osCollection != "_ogr_metadata" ) { m_apoLayers.push_back(new OGRMongoDBLayer(this, pszDatabase, osCollection.c_str())); } } return TRUE; } catch( const DBException &e) { CPLError(CE_Failure, CPLE_AppDefined, "Command failed: %s", e.what()); return FALSE; } } /************************************************************************/ /* ICreateLayer() */ /************************************************************************/ OGRLayer* OGRMongoDBDataSource::ICreateLayer( const char *pszName, OGRSpatialReference *poSpatialRef, OGRwkbGeometryType eGType, char ** papszOptions ) { if( m_osDatabase.empty() ) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot create layer/collection when dataset opened without explicit database"); return nullptr; } if( eAccess != GA_Update ) { CPLError(CE_Failure, CPLE_AppDefined, "Dataset opened in read-only mode"); return nullptr; } for(int i=0; i<(int)m_apoLayers.size(); i++) { if( EQUAL(m_apoLayers[i]->GetName(), pszName) ) { if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != nullptr && !EQUAL(CSLFetchNameValue(papszOptions,"OVERWRITE"),"NO") ) { DeleteLayer( i ); } else { CPLError( CE_Failure, CPLE_AppDefined, "Layer %s already exists, CreateLayer failed.\n" "Use the layer creation option OVERWRITE=YES to " "replace it.", pszName ); return nullptr; } } } OGRMongoDBLayer* poLayer = new OGRMongoDBLayer(this, m_osDatabase, pszName); poLayer->SetFID(CSLFetchNameValueDef(papszOptions, "FID", "ogc_fid")); poLayer->SetCreateLayerMetadata( CPLFetchBool(papszOptions, "WRITE_OGR_METADATA", true)); poLayer->SetDotAsNestedField( CPLFetchBool(papszOptions, "DOT_AS_NESTED_FIELD", true)); poLayer->SetIgnoreSourceID( CPLFetchBool(papszOptions, "IGNORE_SOURCE_ID", false)); poLayer->SetCreateSpatialIndex( CPLFetchBool(papszOptions, "SPATIAL_INDEX", true)); if( eGType != wkbNone ) { const char* pszGeometryName = CSLFetchNameValueDef(papszOptions, "GEOMETRY_NAME", "geometry"); OGRGeomFieldDefn oFieldDefn(pszGeometryName, eGType); oFieldDefn.SetSpatialRef(poSpatialRef); poLayer->CreateGeomField(&oFieldDefn, FALSE); } m_apoLayers.push_back(poLayer); return poLayer; } /************************************************************************/ /* DeleteLayer() */ /************************************************************************/ OGRErr OGRMongoDBDataSource::DeleteLayer( int iLayer ) { if( eAccess != GA_Update ) { CPLError(CE_Failure, CPLE_AppDefined, "Dataset opened in read-only mode"); return OGRERR_FAILURE; } if( iLayer < 0 || iLayer >= (int)m_apoLayers.size() ) return OGRERR_FAILURE; /* -------------------------------------------------------------------- */ /* Blow away our OGR structures related to the layer. This is */ /* pretty dangerous if anything has a reference to this layer! */ /* -------------------------------------------------------------------- */ CPLString osLayerName = m_apoLayers[iLayer]->GetName(); CPLString l_osDatabase = m_apoLayers[iLayer]->GetDatabase(); CPLString l_osCollection = m_apoLayers[iLayer]->GetCollection(); CPLString l_osQualifiedCollection = m_apoLayers[iLayer]->GetQualifiedCollection(); CPLDebug( "MongoDB", "DeleteLayer(%s)", osLayerName.c_str() ); delete m_apoLayers[iLayer]; m_apoLayers.erase( m_apoLayers.begin() + iLayer ); try { m_poConn->findAndRemove( CPLSPrintf("%s._ogr_metadata", l_osDatabase.c_str()), BSON("layer" << l_osCollection.c_str()), BSONObj(), BSONObj()); return m_poConn->dropCollection(l_osQualifiedCollection) ? OGRERR_NONE: OGRERR_FAILURE; } catch( const DBException &e) { CPLError(CE_Failure, CPLE_AppDefined, "Command failed: %s", e.what()); return OGRERR_FAILURE; } } /************************************************************************/ /* TestCapability() */ /************************************************************************/ int OGRMongoDBDataSource::TestCapability( const char * pszCap ) { if( EQUAL(pszCap,ODsCCreateLayer) || EQUAL(pszCap,ODsCDeleteLayer) || EQUAL(pszCap,ODsCCreateGeomFieldAfterCreateLayer) ) return eAccess == GA_Update; else return FALSE; } /************************************************************************/ /* OGRMongoDBSingleFeatureLayer */ /************************************************************************/ class OGRMongoDBSingleFeatureLayer: public OGRLayer { OGRFeatureDefn *m_poFeatureDefn; CPLString osVal; int iNextShapeId; public: explicit OGRMongoDBSingleFeatureLayer( const char *pszVal ); ~OGRMongoDBSingleFeatureLayer() { m_poFeatureDefn->Release(); } void ResetReading() override { iNextShapeId = 0; } OGRFeature *GetNextFeature() override; OGRFeatureDefn *GetLayerDefn() override { return m_poFeatureDefn; } int TestCapability( const char * ) override { return FALSE; } }; /************************************************************************/ /* OGRMongoDBSingleFeatureLayer() */ /************************************************************************/ OGRMongoDBSingleFeatureLayer::OGRMongoDBSingleFeatureLayer( const char *pszVal ) { m_poFeatureDefn = new OGRFeatureDefn( "RESULT" ); m_poFeatureDefn->Reference(); OGRFieldDefn oField( "_json", OFTString ); m_poFeatureDefn->AddFieldDefn( &oField ); iNextShapeId = 0; osVal = pszVal; } /************************************************************************/ /* GetNextFeature() */ /************************************************************************/ OGRFeature * OGRMongoDBSingleFeatureLayer::GetNextFeature() { if (iNextShapeId != 0) return nullptr; OGRFeature* poFeature = new OGRFeature(m_poFeatureDefn); poFeature->SetField(0, osVal); poFeature->SetFID(iNextShapeId ++); return poFeature; } /************************************************************************/ /* ExecuteSQL() */ /************************************************************************/ OGRLayer* OGRMongoDBDataSource::ExecuteSQL( const char *pszSQLCommand, OGRGeometry *poSpatialFilter, const char *pszDialect ) { for(int i=0; i<(int)m_apoLayers.size(); i++ ) { m_apoLayers[i]->SyncToDisk(); } /* -------------------------------------------------------------------- */ /* Special case DELLAYER: command. */ /* -------------------------------------------------------------------- */ if( STARTS_WITH_CI(pszSQLCommand, "DELLAYER:") ) { const char *pszLayerName = pszSQLCommand + 9; while( *pszLayerName == ' ' ) pszLayerName++; for( int iLayer = 0; iLayer < (int)m_apoLayers.size(); iLayer++ ) { if( EQUAL(m_apoLayers[iLayer]->GetName(), pszLayerName )) { DeleteLayer( iLayer ); break; } } return nullptr; } /* -------------------------------------------------------------------- */ /* Special case WRITE_OGR_METADATA command. */ /* -------------------------------------------------------------------- */ if( STARTS_WITH_CI(pszSQLCommand, "WRITE_OGR_METADATA ") ) { if( eAccess != GA_Update ) { CPLError(CE_Failure, CPLE_AppDefined, "Dataset opened in read-only mode"); return nullptr; } const char* pszLayerName = pszSQLCommand + strlen("WRITE_OGR_METADATA "); OGRMongoDBLayer* poLayer = (OGRMongoDBLayer*) GetLayerByName(pszLayerName); if( poLayer == nullptr ) { CPLError(CE_Failure, CPLE_AppDefined, "Layer %s not found", pszLayerName); return nullptr; } poLayer->GetLayerDefn(); // force schema discovery poLayer->SetCreateLayerMetadata(TRUE); poLayer->SyncToDisk(); return nullptr; } if( pszDialect != nullptr && EQUAL(pszDialect, "MONGODB") ) { BSONObj info; try { m_poConn->runCommand(m_osDatabase, OGRLocaleSafeFromJSON(pszSQLCommand), info); return new OGRMongoDBSingleFeatureLayer(info.jsonString().c_str()); } catch( const DBException &e) { CPLError(CE_Failure, CPLE_AppDefined, "Command failed: %s", e.what()); return nullptr; } } else { return GDALDataset::ExecuteSQL(pszSQLCommand, poSpatialFilter, pszDialect); } } /************************************************************************/ /* ReleaseResultSet() */ /************************************************************************/ void OGRMongoDBDataSource::ReleaseResultSet( OGRLayer * poLayer ) { delete poLayer; } /************************************************************************/ /* OGRMongoDBDriverUnload() */ /************************************************************************/ extern "C" int GDALIsInGlobalDestructor(); static void OGRMongoDBDriverUnload( CPL_UNUSED GDALDriver* poDriver ) { if( bMongoInitialized != -1 && !GDALIsInGlobalDestructor() ) { client::shutdown(); } } /************************************************************************/ /* OGRMongoDBDriverIdentify() */ /************************************************************************/ static int OGRMongoDBDriverIdentify( GDALOpenInfo* poOpenInfo ) { if( STARTS_WITH_CI(poOpenInfo->pszFilename, "MongoDB:") ) { #ifdef DEBUG_BOOL // Defining -DDO_NOT_USE_DEBUG_BOOL doesn't solve runtime problems CPLError(CE_Failure, CPLE_AppDefined, "MongoDB incompatible at runtime with DEBUG_BOOL"); #else return TRUE; #endif } return FALSE; } /************************************************************************/ /* OGRMongoDBDriverOpen() */ /************************************************************************/ static GDALDataset* OGRMongoDBDriverOpen( GDALOpenInfo* poOpenInfo ) { if( !OGRMongoDBDriverIdentify(poOpenInfo) ) return nullptr; OGRMongoDBDataSource *m_poDS = new OGRMongoDBDataSource(); if( !m_poDS->Open( poOpenInfo->pszFilename, poOpenInfo->eAccess, poOpenInfo->papszOpenOptions ) ) { delete m_poDS; m_poDS = nullptr; } return m_poDS; } #if 0 /************************************************************************/ /* OGRMongoDBDriverCreate() */ /************************************************************************/ static GDALDataset* OGRMongoDBDriverCreate( const char * pszName, int nXSize, int nYSize, int nBands, GDALDataType eType, char ** papszOptions ) { OGRMongoDBDataSource *m_poDS = new OGRMongoDBDataSource(); if( !m_poDS->Open( pszName, papszOptions) ) { delete m_poDS; m_poDS = NULL; } return m_poDS; } #endif /************************************************************************/ /* RegisterOGRMongoDB() */ /************************************************************************/ void RegisterOGRMongoDB() { if( GDALGetDriverByName( "MongoDB" ) != nullptr ) return; GDALDriver *poDriver = new GDALDriver(); poDriver->SetDescription( "MongoDB" ); poDriver->SetMetadataItem( GDAL_DCAP_VECTOR, "YES" ); poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, "MongoDB" ); poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, "drv_mongodb.html" ); poDriver->SetMetadataItem( GDAL_DMD_CONNECTION_PREFIX, "MongoDB:" ); #if 0 poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST, "<CreationOptionList>" "</CreationOptionList>"); #endif poDriver->SetMetadataItem( GDAL_DS_LAYER_CREATIONOPTIONLIST, "<LayerCreationOptionList>" " <Option name='OVERWRITE' type='boolean' description='Whether to overwrite an existing collection with the layer name to be created' default='NO'/>" " <Option name='GEOMETRY_NAME' type='string' description='Name of geometry column.' default='geometry'/>" " <Option name='SPATIAL_INDEX' type='boolean' description='Whether to create a spatial index' default='YES'/>" " <Option name='FID' type='string' description='Field name, with integer values, to use as FID' default='ogc_fid'/>" " <Option name='WRITE_OGR_METADATA' type='boolean' description='Whether to create a description of layer fields in the _ogr_metadata collection' default='YES'/>" " <Option name='DOT_AS_NESTED_FIELD' type='boolean' description='Whether to consider dot character in field name as sub-document' default='YES'/>" " <Option name='IGNORE_SOURCE_ID' type='boolean' description='Whether to ignore _id field in features passed to CreateFeature()' default='NO'/>" "</LayerCreationOptionList>"); poDriver->SetMetadataItem( GDAL_DMD_OPENOPTIONLIST, "<OpenOptionList>" " <Option name='URI' type='string' description='Connection URI' />" " <Option name='HOST' type='string' description='Server hostname' />" " <Option name='PORT' type='integer' description='Server port' />" " <Option name='DBNAME' type='string' description='Database name' />" " <Option name='AUTH_DBNAME' type='string' description='Authentication database name' />" " <Option name='USER' type='string' description='User name' />" " <Option name='PASSWORD' type='string' description='User password' />" " <Option name='AUTH_JSON' type='string' description='Authentication elements as JSon object' />" " <Option name='SSL_PEM_KEY_FILE' type='string' description='SSL PEM certificate/key filename' />" " <Option name='SSL_PEM_KEY_PASSWORD' type='string' description='SSL PEM key password' />" " <Option name='SSL_CA_FILE' type='string' description='SSL Certification Authority filename' />" " <Option name='SSL_CRL_FILE' type='string' description='SSL Certification Revocation List filename' />" " <Option name='SSL_ALLOW_INVALID_CERTIFICATES' type='boolean' description='Whether to allow connections to servers with invalid certificates' default='NO'/>" " <Option name='SSL_ALLOW_INVALID_HOSTNAMES' type='boolean' description='Whether to allow connections to servers with non-matching hostnames' default='NO'/>" " <Option name='FIPS_MODE' type='boolean' description='Whether to activate FIPS 140-2 mode at startup' default='NO'/>" " <Option name='BATCH_SIZE' type='integer' description='Number of features to retrieve per batch'/>" " <Option name='FEATURE_COUNT_TO_ESTABLISH_FEATURE_DEFN' type='integer' description='Number of features to retrieve to establish feature definition. -1 = unlimited' default='100'/>" " <Option name='JSON_FIELD' type='boolean' description='Whether to include a field with the full document as JSON' default='NO'/>" " <Option name='FLATTEN_NESTED_ATTRIBUTES' type='boolean' description='Whether to recursively explore nested objects and produce flatten OGR attributes' default='YES'/>" " <Option name='FID' type='string' description='Field name, with integer values, to use as FID' default='ogc_fid'/>" " <Option name='USE_OGR_METADATA' type='boolean' description='Whether to use the _ogr_metadata collection to read layer metadata' default='YES'/>" " <Option name='BULK_INSERT' type='boolean' description='Whether to use bulk insert for feature creation' default='YES'/>" "</OpenOptionList>"); poDriver->SetMetadataItem( GDAL_DMD_CREATIONFIELDDATATYPES, "Integer Integer64 Real String Date DateTime Time IntegerList Integer64List RealList StringList Binary" ); poDriver->SetMetadataItem( GDAL_DMD_CREATIONFIELDDATASUBTYPES, "Boolean" ); poDriver->pfnOpen = OGRMongoDBDriverOpen; poDriver->pfnIdentify = OGRMongoDBDriverIdentify; poDriver->pfnUnloadDriver = OGRMongoDBDriverUnload; //poDriver->pfnCreate = OGRMongoDBDriverCreate; GetGDALDriverManager()->RegisterDriver( poDriver ); }
#include <gtest/gtest.h> #include "HE_Math.h" using namespace HE::Math; static_assert(!IsPow2(0), "HE::Math::IsPow2 failed to pass test"); static_assert(IsPow2(1), "HE::Math::IsPow2 failed to pass test"); static_assert(IsPow2(2), "HE::Math::IsPow2 failed to pass test"); static_assert(IsPow2(1024), "HE::Math::IsPow2 failed to pass test"); static_assert(Min(2, 3) == 2, "HE::Math::Min failed to pass test"); static_assert(Min(2, 3, 5, 1) == 1, "HE::Math::Min failed to pass test"); static_assert(Min(2, 2.4f, 1.0) == 1.0, "HE::Math::Min failed to pass test"); static_assert(Max(2, 3) == 3, "HE::Math::Max failed to pass test"); static_assert(Max(2, 3, 5, 1) == 5, "HE::Math::Max failed to pass test"); static_assert(Max(2, 2.4f, 1.0) == 2.4f, "HE::Math::Max failed to pass test"); static_assert(RoundUpToMultipleOf(1, 4) == 4, "HE::Math::RoundUpToMultipleOf failed to pass test"); static_assert(RoundUpToMultipleOf(13, 9) == 18, "HE::Math::RoundUpToMultipleOf failed to pass test"); //static_assert(RoundUpToMultipleOf(1, -2) == 4, "HE::Math::RoundUpToMultipleOf failed to pass test"); // Should not compile
; A120162: a(1)=3; a(n)=floor((14+sum(a(1) to a(n-1)))/4). ; 3,4,5,6,8,10,12,15,19,24,30,37,46,58,72,90,113,141,176,220,275,344,430,538,672,840,1050,1313,1641,2051,2564,3205,4006,5008,6260,7825,9781,12226,15283,19103 add $0,4 mov $2,2 mov $3,2 lpb $0,1 sub $0,$2 sub $0,1 mov $1,$3 add $1,2 sub $1,$2 div $1,4 add $3,2 trn $2,$3 add $3,$1 lpe add $1,2
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld a, 00 ldff(ff), a ld a, 30 ldff(00), a ld a, 01 ldff(4d), a stop, 00 ld a, ff ldff(45), a ld b, 91 call lwaitly_b ld hl, fe00 ld d, 10 ld a, d ld(hl++), a ld a, 08 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 09 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 0a ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 28 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 29 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 2a ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 48 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 49 ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 4a ld(hl++), a ld a, 40 ldff(41), a ld a, 02 ldff(ff), a xor a, a ldff(0f), a ei ld a, 01 ldff(45), a ld c, 41 ld a, 93 ldff(40), a ld a, 01 ldff(43), a .text@1000 lstatint: nop .text@1096 ldff a, (c) and a, 03 jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
; A040210: Continued fraction for sqrt(226). ; Submitted by Christian Krause ; 15,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30 min $0,1 add $0,1 mul $0,15
;***************************************************************************** ;* x86-optimized functions for yadif filter ;* ;* Copyright (C) 2006 Michael Niedermayer <michaelni@gmx.at> ;* Copyright (c) 2013 Daniel Kang <daniel.d.kang@gmail.com> ;* Copyright (c) 2011-2013 James Darnley <james.darnley@gmail.com> ;* ;* This file is part of FFmpeg. ;* ;* FFmpeg is free software; you can redistribute it and/or ;* modify it under the terms of the GNU Lesser General Public ;* License as published by the Free Software Foundation; either ;* version 2.1 of the License, or (at your option) any later version. ;* ;* FFmpeg 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 ;* Lesser General Public License for more details. ;* ;* You should have received a copy of the GNU Lesser General Public ;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** %include "libavutil/x86/x86util.asm" SECTION_RODATA pw_1: times 8 dw 1 pw_8000: times 8 dw 0x8000 pd_1: times 4 dd 1 pd_8000: times 4 dd 0x8000 SECTION .text %macro PABS 2 %if cpuflag(ssse3) pabsd %1, %1 %else pxor %2, %2 pcmpgtd %2, %1 pxor %1, %2 psubd %1, %2 %endif %endmacro %macro PACK 1 %if cpuflag(sse4) packusdw %1, %1 %else psubd %1, [pd_8000] packssdw %1, %1 paddw %1, [pw_8000] %endif %endmacro %macro PMINSD 3 %if cpuflag(sse4) pminsd %1, %2 %else mova %3, %2 pcmpgtd %3, %1 pand %1, %3 pandn %3, %2 por %1, %3 %endif %endmacro %macro PMAXSD 3 %if cpuflag(sse4) pmaxsd %1, %2 %else mova %3, %1 pcmpgtd %3, %2 pand %1, %3 pandn %3, %2 por %1, %3 %endif %endmacro %macro PMAXUW 2 %if cpuflag(sse4) pmaxuw %1, %2 %else psubusw %1, %2 paddusw %1, %2 %endif %endmacro %macro CHECK 2 movu m2, [curq+t1+%1*2] movu m3, [curq+t0+%2*2] mova m4, m2 mova m5, m2 pxor m4, m3 pavgw m5, m3 pand m4, [pw_1] psubusw m5, m4 RSHIFT m5, 2 punpcklwd m5, m7 mova m4, m2 psubusw m2, m3 psubusw m3, m4 PMAXUW m2, m3 mova m3, m2 mova m4, m2 RSHIFT m3, 2 RSHIFT m4, 4 punpcklwd m2, m7 punpcklwd m3, m7 punpcklwd m4, m7 paddd m2, m3 paddd m2, m4 %endmacro %macro CHECK1 0 mova m3, m0 pcmpgtd m3, m2 PMINSD m0, m2, m6 mova m6, m3 pand m5, m3 pandn m3, m1 por m3, m5 mova m1, m3 %endmacro %macro CHECK2 0 paddd m6, [pd_1] pslld m6, 30 paddd m2, m6 mova m3, m0 pcmpgtd m3, m2 PMINSD m0, m2, m4 pand m5, m3 pandn m3, m1 por m3, m5 mova m1, m3 %endmacro ; This version of CHECK2 has 3 fewer instructions on sets older than SSE4 but I ; am not sure whether it is any faster. A rewrite or refactor of the filter ; code should make it possible to eliminate the move instruction at the end. It ; exists to satisfy the expectation that the "score" values are in m1. ; %macro CHECK2 0 ; mova m3, m0 ; pcmpgtd m0, m2 ; pand m0, m6 ; mova m6, m0 ; pand m5, m6 ; pand m2, m0 ; pandn m6, m1 ; pandn m0, m3 ; por m6, m5 ; por m0, m2 ; mova m1, m6 ; %endmacro %macro LOAD 2 movh %1, %2 punpcklwd %1, m7 %endmacro %macro FILTER 3 .loop%1: pxor m7, m7 LOAD m0, [curq+t1] LOAD m1, [curq+t0] LOAD m2, [%2] LOAD m3, [%3] mova m4, m3 paddd m3, m2 psrad m3, 1 mova [rsp+ 0], m0 mova [rsp+16], m3 mova [rsp+32], m1 psubd m2, m4 PABS m2, m4 LOAD m3, [prevq+t1] LOAD m4, [prevq+t0] psubd m3, m0 psubd m4, m1 PABS m3, m5 PABS m4, m5 paddd m3, m4 psrld m2, 1 psrld m3, 1 PMAXSD m2, m3, m6 LOAD m3, [nextq+t1] LOAD m4, [nextq+t0] psubd m3, m0 psubd m4, m1 PABS m3, m5 PABS m4, m5 paddd m3, m4 psrld m3, 1 PMAXSD m2, m3, m6 mova [rsp+48], m2 paddd m1, m0 paddd m0, m0 psubd m0, m1 psrld m1, 1 PABS m0, m2 movu m2, [curq+t1-1*2] movu m3, [curq+t0-1*2] mova m4, m2 psubusw m2, m3 psubusw m3, m4 PMAXUW m2, m3 mova m3, m2 RSHIFT m3, 4 punpcklwd m2, m7 punpcklwd m3, m7 paddd m0, m2 paddd m0, m3 psubd m0, [pd_1] CHECK -2, 0 CHECK1 CHECK -3, 1 CHECK2 CHECK 0, -2 CHECK1 CHECK 1, -3 CHECK2 mova m6, [rsp+48] cmp DWORD r8m, 2 jge .end%1 LOAD m2, [%2+t1*2] LOAD m4, [%3+t1*2] LOAD m3, [%2+t0*2] LOAD m5, [%3+t0*2] paddd m2, m4 paddd m3, m5 psrld m2, 1 psrld m3, 1 mova m4, [rsp+ 0] mova m5, [rsp+16] mova m7, [rsp+32] psubd m2, m4 psubd m3, m7 mova m0, m5 psubd m5, m4 psubd m0, m7 mova m4, m2 PMINSD m2, m3, m7 PMAXSD m3, m4, m7 PMAXSD m2, m5, m7 PMINSD m3, m5, m7 PMAXSD m2, m0, m7 PMINSD m3, m0, m7 pxor m4, m4 PMAXSD m6, m3, m7 psubd m4, m2 PMAXSD m6, m4, m7 .end%1: mova m2, [rsp+16] mova m3, m2 psubd m2, m6 paddd m3, m6 PMAXSD m1, m2, m7 PMINSD m1, m3, m7 PACK m1 movh [dstq], m1 add dstq, mmsize/2 add prevq, mmsize/2 add curq, mmsize/2 add nextq, mmsize/2 sub DWORD r4m, mmsize/4 jg .loop%1 %endmacro %macro YADIF 0 %if ARCH_X86_32 cglobal yadif_filter_line_16bit, 4, 6, 8, 80, dst, prev, cur, next, w, \ prefs, mrefs, parity, mode %else cglobal yadif_filter_line_16bit, 4, 7, 8, 80, dst, prev, cur, next, w, \ prefs, mrefs, parity, mode %endif %if ARCH_X86_32 mov r4, r5mp mov r5, r6mp DECLARE_REG_TMP 4,5 %else movsxd r5, DWORD r5m movsxd r6, DWORD r6m DECLARE_REG_TMP 5,6 %endif cmp DWORD paritym, 0 je .parity0 FILTER 1, prevq, curq jmp .ret .parity0: FILTER 0, curq, nextq .ret: RET %endmacro INIT_XMM sse4 YADIF INIT_XMM ssse3 YADIF INIT_XMM sse2 YADIF %if ARCH_X86_32 INIT_MMX mmxext YADIF %endif