text
stringlengths
1
1.05M
; ; Old School Computer Architecture - SD Card driver ; Taken from the OSCA Bootcode by Phil Ruston 2011 ; ; Ported by Stefano Bodrato, 2012 ; ; Power on the sdcard slot ; ; $Id: sd_power_on.asm,v 1.2 2015-01-19 01:33:07 pauloscustodio Exp $ ; PUBLIC sd_power_on INCLUDE "target/osca/def/osca.def" sd_power_on: push af in a,(sys_sdcard_ctrl2) res sd_power,a ; pull power control low: Active - SD card powered up set sd_cs,a ; card deselected by default at power on out (sys_sdcard_ctrl2),a ld a,@01000000 ; (6) = 1 FPGA Output enabled, (7) = 0: 250Khz SPI clock out (sys_sdcard_ctrl1),a pop af ret
// Extend Eenie and Meenie's script to check the fusion result .align 2 ext_script_eenie: // Skip past call command if Kinstone fusion was cancelled .dh 0x0005|(2<<10) // skip command with length 2 .dh @@end-. // Mark Kinstone fusion as finished .dh 0x000B|(3<<10) // subroutine call command with length 3 .dw 0x806B73D @@end: // Jump back to Eenie script .dh 0x0007|(3<<10) // jump command with length 3 .dw hook_script_eenie_end
;/*---------------------------------------------------------------------------- ; * Copyright (c) <2013-2018>, <Huawei Technologies Co., Ltd> ; * 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. ; *---------------------------------------------------------------------------*/ ;/*---------------------------------------------------------------------------- ; * Notice of Export Control Law ; * =============================================== ; * Huawei LiteOS may be subject to applicable export control laws and regulations, which might ; * include those applicable to Huawei LiteOS of U.S. and the country in which you are located. ; * Import, export and usage of Huawei LiteOS in any manner by you shall be in compliance with such ; * applicable export control laws and regulations. ; *---------------------------------------------------------------------------*/ .cdecls C, LIST, "msp430.h" ; Include device header file .cdecls C, LIST, "ccsmacros.h" ; Include macros used ccs header file .data .global _los_heap_start .global _los_heap_end .asg 256, LOSCFG_MSP430_IRQ_SIZE .align 4 _los_heap_start: .ulong __HEAP_START _los_heap_end: .ulong __STACK_END - LOSCFG_MSP430_IRQ_SIZE .text .global LOS_IntLock .global LOS_IntUnLock .global LOS_IntRestore .global LOS_StartToRun .global osSchedule .ref g_bTaskScheduled .ref g_stLosTask .ref g_int_cnt .ref osTaskSwitchCheck .ref g_usLosTaskLock .ref osHwiDispatch .retain .retainrefs .asg 0x10, TASK_STATUS_RUNNING ;------------------------------------------------------------------------------- ; irq vectors ;------------------------------------------------------------------------------- .asg 0, irq .loop .if irq < 10 .sect ".int0:irq:" .else .sect ".int:irq:" .endif .short irq_stub:irq: .break ($symcmp (""".int:irq:""", SYSNMI_VECTOR) = 0) .eval irq + 1, irq .endloop ;------------------------------------------------------------------------------- ; irq entry stubs ;------------------------------------------------------------------------------- .sect ".text:_isr" .asg irq + 1, irqs .asg 0, irq irq_stubs: .loop irqs irq_stub:irq: FCALL #irq_handler .eval irq + 1, irq .endloop .unasg irq .unasg irqs irq_handler: ; ; now the stack: ; ; +-------------------------+----+----+ ; | irq_stubs + irq * 4 + 4 | SR | PC | ; +-------------------------+----+----+ ; XPUSH r14 XPUSH r13 XPUSH r12 XMOV (3 * REG_SIZE)(sp), r12 XMOV r15, (3 * REG_SIZE)(sp) ; ; now the stack: ; ; +-----+-----+-----+-----+----+----+ ; | R12 | R13 | R14 | R15 | SR | PC | ; +-----+-----+-----+-----+----+----+ ; ; now r12 = irq_stubs + irq * 4 + 4, ; ; ((r12 - (irq_stubs + 4)) / 4) is the irq number ; ((r12 - (irq_stubs + 4)) / 2) is the vector number ; INC.B &g_int_cnt CMP.B #1, &g_int_cnt JNE already_on_irq_stack XMOV sp, &__STACK_END - REG_SIZE XMOV #__STACK_END - REG_SIZE, sp already_on_irq_stack: SUB.W #irq_stubs + 4, r12 ; irq_stubs at CODE16 RRA.w r12 RRA.w r12 FCALL #osHwiDispatch ; interrupt can be enabld in osHwiDispatch DINT NOP ; required by architecture DEC.B &g_int_cnt CMP.B #0, &g_int_cnt JNE _rfi XMOV 0(sp), sp CMP.W #0, &g_usLosTaskLock JNE _rfi PCMP &g_stLosTask + PTR_SIZE, &g_stLosTask JEQ _rfi ; need schedule, save context XPUSHM #8, r11 ; save r4-r11 _switch_new: PMOV &g_stLosTask, r12 PMOV sp, 0(r12) BIC.W #TASK_STATUS_RUNNING, PTR_SIZE(r12) FCALL #osTaskSwitchCheck _load_new: PMOV &g_stLosTask + PTR_SIZE, r12 PMOV r12, &g_stLosTask PMOV 0(r12), sp BIS.W #TASK_STATUS_RUNNING, PTR_SIZE(r12) XPOPM #8, r11 _rfi: XPOPM #4, r15 RETI LOS_StartToRun: DINT NOP ; required by architecture MOV.W #1, &g_bTaskScheduled JMP _load_new osSchedule: MOV.W sr, r12 DINT NOP ; required by architecture PCMP &g_stLosTask + PTR_SIZE, &g_stLosTask JEQ _ret .if __LARGE_CODE_MODEL__ = 1 ; ; fake ra for calla as the same with interrupt: ; ; +---------+---------+ +----+----+ ; | ra00:15 | ra16:19 | -> | sr | ra | ; +---------+---------+ +----+----+ ; ; ra16:19 in sr16:19 ; MOV.W 2(sp), r13 RLA r13 RLA r13 RLA r13 RLA r13 SWPB r13 BIS.W r13, r12 MOV.W 0(sp), 2(sp) MOV.W r12, 0(sp) .else PUSH.W r12 .endif PSUB #4 * REG_SIZE, sp ; reserve space for r12-r15, needless save XPUSHM #8, r11 ; save r4-r11 JMP _switch_new _ret: NOP ; required by architecture MOV.W r12, sr NOP ; required by architecture FRET LOS_IntLock: MOV.W sr, r12 AND.W #GIE, r12 DINT NOP ; required by architecture FRET LOS_IntUnLock: MOV.W sr, r12 AND.W #GIE, r12 NOP ; required by architecture EINT NOP FRET LOS_IntRestore: AND.W #GIE, r12 NOP ; required by architecture BIS.W r12, sr NOP ; required by architecture FRET ;------------------------------------------------------------------------------- ; System HEAP ;------------------------------------------------------------------------------- .sect .sysmem .align 8 __HEAP_START: ;------------------------------------------------------------------------------- ; Stack Pointer definition ;------------------------------------------------------------------------------- .global __STACK_END .sect .stack .end
/* * Talk2WatchInterface.cpp * * Created on: 09.01.2014 * Author: benjaminsliwa */ #include "Talk2WatchInterface.h" #include <bb/system/InvokeQueryTargetsRequest> #include <bb/system/InvokeQueryTargetsReply> #include <bb/system/InvokeReply> #include "UdpModule.h" #include "Serializer.h" /* GENERAL INFORMATION * * * */ Talk2WatchInterface::Talk2WatchInterface(QObject *_parent) { m_udp = new UdpModule(this); m_udp->listenOnPort(8484); connect(m_udp, SIGNAL(reveivedData(QString)), this, SLOT(onDataReived(QString))); m_serializer = new Serializer(this); m_talk2WatchAvailable = false; m_talk2WatchProAvailable = false; m_talk2WatchProServiceAvailable = false; m_invokeManager = new bb::system::InvokeManager(this); m_appName = ""; m_appKey = ""; m_description = ""; m_protocol = ""; m_port = ""; m_target = ""; m_mimeType = ""; bb::system::InvokeQueryTargetsRequest request; request.setMimeType ("text/plain"); request.setAction("bb.action.SHARE"); const bb::system::InvokeQueryTargetsReply *reply = m_invokeManager->queryTargets(request); bool ok = connect(reply, SIGNAL(finished()), this, SLOT(onTalk2WatchLookup())); Q_ASSERT(ok); Q_UNUSED(ok); } Talk2WatchInterface::~Talk2WatchInterface() { } /************************************************************ * HELPER METHODS * ***********************************************************/ bool Talk2WatchInterface::isTalk2WatchInstalled() { return m_talk2WatchAvailable; } bool Talk2WatchInterface::isTalk2WatchProInstalled() { return m_talk2WatchProAvailable; } bool Talk2WatchInterface::isTalk2WatchProServiceInstalled() { return m_talk2WatchProServiceAvailable; } /************************************************************ * SENDING MESSAGES TO THE WATCH VIA TALK2WATCH * ***********************************************************/ void Talk2WatchInterface::sendSms(QString _sender, QString _text) { QStringList keys = QStringList() << "text" << "sender"; QVariantList values = QVariantList() << _text << _sender; sendCommand(m_serializer->serialize("SMS", "NOTIFICATIONS", keys, values)); } void Talk2WatchInterface::sendEmail(QString _sender, QString _subject, QString _text) { QStringList keys = QStringList() << "text" << "sender" << "subject"; QVariantList values = QVariantList() << _text << _sender << _subject; sendCommand(m_serializer->serialize("EMAIL", "NOTIFICATIONS", keys, values)); } /************************************************************ * RECEIVING ACTIONS FROM THE WATCH VIA TALK2WATCH * ***********************************************************/ /* RECEIVING MESSAGES - STEP 1 * * Chose one of the available receiver models, implement it and call the activation method with the correct parameters */ void Talk2WatchInterface::setAppValues(QString _appName, QString _appVersion, QString _appKey, QString _protocol, QString _port, QString _description) { m_appName = _appName; m_appVersion = _appVersion; m_appKey = _appKey; m_protocol = _protocol; m_port = _port; m_description = _description; } /* RECEIVING MESSAGES - STEP 2 * * Call the authorization method and wait for a reply. The reply will be passed to the receiver which was defined in STEP 1. * If the request was successful the value APP_RQ_SUCCESS will be returned */ void Talk2WatchInterface::sendAppAuthorizationRequest() { QStringList keys = QStringList() << "appVersion" << "port" << "description"; QVariantList values = QVariantList() << m_appVersion << m_port << m_description; sendAuthenticatedCommand("APP_AUTH_RQ", "APP_CONNECTION", keys, values); } /* RECEIVING MESSAGES - STEP 3 * * Use the creator methods to create the actions you want to add to Talk2Watch. */ void Talk2WatchInterface::createAction(QString _title, QString _command, QString _description) { QStringList keys = QStringList() << "title" << "command" << "description"; QVariantList values = QVariantList() << _title << _command << _description; sendAuthenticatedCommand("APP_CREATE_ACTION", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::createAction(QString _title, QString _folder, QString _command, QString _description) { QStringList keys = QStringList() << "title" << "folder" << "command" << "description"; QVariantList values = QVariantList() << _title << _folder << _command << _description; sendAuthenticatedCommand("APP_CREATE_ACTION", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::createFolder(QString _title) { createFolder(_title, "root"); } void Talk2WatchInterface::createFolder(QString _title, QString _parentFolder) { QStringList keys = QStringList() << "title" << "parentFolder"; QVariantList values = QVariantList() << _title << _parentFolder; sendAuthenticatedCommand("APP_CREATE_FOLDER", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::removeConnection() { QStringList keys; QVariantList values; sendAuthenticatedCommand("APP_REMOVE_CONNECTION", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::removeAction(const QString &_action) { QStringList keys = QStringList() << "action"; QVariantList values = QVariantList() << _action; sendAuthenticatedCommand("APP_REMOVE_ACTION", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::removeFolder(const QString &_folder) { QStringList keys = QStringList() << "folder"; QVariantList values = QVariantList() << _folder; sendAuthenticatedCommand("APP_REMOVE_FOLDER", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::renameAction(const QString &_oldTitle, const QString &_newTitle) { QStringList keys = QStringList() << "oldTitle" << "newTitle"; QVariantList values = QVariantList() << _oldTitle << _newTitle; sendAuthenticatedCommand("APP_RENAME_ACTION", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::renameFolder(const QString &_oldTitle, const QString &_newTitle) { QStringList keys = QStringList() << "oldTitle" << "newTitle"; QVariantList values = QVariantList() << _oldTitle << _newTitle; sendAuthenticatedCommand("APP_RENAME_FOLDER", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::forwardSourceCode() { bb::system::InvokeRequest request; request.setTarget("sys.pim.uib.email.hybridcomposer"); request.setAction("bb.action.SHARE"); request.setUri("file:///" + QDir::currentPath() + "/app/native/assets/T2W_API.zip"); m_invokeManager->invoke(request); } void Talk2WatchInterface::sendAppMessage(const QString &_uuid, const QHash<QString, QVariant> &_values) { QHash<QString, QVariant> values = _values; values.insert("uuid", _uuid); sendCommand(m_serializer->serialize("APPMESSAGE", "PEBBLE", values)); } void Talk2WatchInterface::sendAppLaunchRequest(const QString &_uuid) { QHash<QString, QVariant> values; values.insert("uuid", _uuid); sendCommand(m_serializer->serialize("LAUNCH_APP", "PEBBLE", values)); } void Talk2WatchInterface::registerAppMessageListener(const QString &_uuid) { QStringList keys = QStringList() << "uuid"; QVariantList values = QVariantList() << _uuid; sendAuthenticatedCommand("APP_REGISTER_UUID", "APP_CONNECTION", keys, values); } void Talk2WatchInterface::deregisterAppMessageListener(const QString &_uuid) { QStringList keys = QStringList() << "uuid"; QVariantList values = QVariantList() << _uuid; sendAuthenticatedCommand("APP_DEREGISTER_UUID", "APP_CONNECTION", keys, values); } /************************************************************ * PRIVATE METHODS * ***********************************************************/ // Transmission void Talk2WatchInterface::sendCommand(QString _command) { if(m_talk2WatchProServiceAvailable || m_talk2WatchProAvailable==true) m_udp->sendMessage("127.0.0.1", 9877, _command); else if(m_talk2WatchAvailable==true) sendCommandViaInvocation(_command, "com.Talk2Watch.invocation.msg"); else { qDebug() << "T2W not found"; } } void Talk2WatchInterface::sendCommandViaInvocation(QString _command, QString _target) { bb::system::InvokeRequest request; request.setTarget(_target.toStdString().c_str()); request.setAction("bb.action.SHARE"); request.setData(_command.toStdString().c_str()); request.setMimeType("text/plain"); m_invokeManager->invoke(request); } void Talk2WatchInterface::sendAuthenticatedCommand(const QString &_type, const QString &_category, const QStringList &_keys, const QVariantList &_values) { QStringList keys = QStringList() << "appName" << "appKey" << _keys; QVariantList values = QVariantList() << m_appName << m_appKey << _values; sendCommand(m_serializer->serialize(_type, _category, keys, values)); } void Talk2WatchInterface::handleMessage(const QString &_type, const QString &_category, const QHash<QString, QVariant> &_values) { if(_category=="PEBBLE") { if(_type=="APPMESSAGE_RECEIVED") { QHash<QString, QVariant> values = _values; QString uuid = _values.value("uuid").toString(); values.remove("uuid"); emit appMessageReceived(uuid, values); } else if(_type=="APP_STARTED") emit appStarted(_values.value("uuid").toString()); else if(_type=="APP_CLOSED") emit appClosed(_values.value("uuid").toString()); } else if(_category=="APP_CONNECTION") { qDebug() << "__RX__" << _type << _values; QString action = _values.value("action").toString(); QString error = _values.value("error").toString(); QString folder = _values.value("folder").toString(); QString uuid = _values.value("uuid").toString(); if(_type=="AUTH_SUCCESS") emit authSuccess(); else if(_type=="AUTH_ERROR") emit authError(error); else if(_type=="CREATE_ACTION_SUCCESS") emit actionCreationSuccess(action); else if(_type=="CREATE_ACTION_ERROR") emit actionCreationError(action, error); else if(_type=="REMOVE_ACTION_SUCCESS") emit actionRemovalSuccess(action); else if(_type=="REMOVE_ACTION_ERROR") emit actionRemovalError(action, error); else if(_type=="RENAME_ACTION_SUCCESS") emit actionRenamingSuccess(action); else if(_type=="RENAME_ACTION_ERROR") emit actionRenamingError(action, error); else if(_type=="ACTION_TRIGGERED") emit actionTriggered(_values.value("command").toString()); else if(_type=="REMOVE_CONNECTION_SUCCESS") emit connectionRemovalSuccess(); else if(_type=="CREATE_FOLDER_SUCCESS") emit folderCreationSuccess(folder); else if(_type=="CREATE_FOLDER_ERROR") emit folderCreationError(folder, error); else if(_type=="REMOVE_FOLDER_SUCCESS") emit folderRemovalSuccess(folder); else if(_type=="REMOVE_FOLDER_ERROR") emit folderRemovalError(folder, error); else if(_type=="RENAME_FOLDER_SUCCESS") emit folderRenamingSuccess(folder); else if(_type=="RENAME_FOLDER_ERROR") emit folderRenamingError(folder, error); else if(_type=="REGISTER_UUID_SUCCESS") emit uuidRegistrationSuccess(uuid); else if(_type=="DEREGISTER_UUID_SUCCESS") emit uuidDeregistrationSucess(uuid); } } /************************************************************ * SLOTS * ***********************************************************/ void Talk2WatchInterface::onDataReived(const QString &_data) { if(m_serializer->isValid(_data)) { QHash<QString, QVariant> data = m_serializer->deserialize(_data); QString category = data.value("EVENT_CATEGORY").toString(); QString type = data.value("EVENT_TYPE").toString(); data.remove("EVENT_CATEGORY"); data.remove("EVENT_TYPE"); handleMessage(type, category, data); } else emit receivedData(_data); } void Talk2WatchInterface::onTalk2WatchLookup() { bb::system::InvokeQueryTargetsReply *reply = qobject_cast<bb::system::InvokeQueryTargetsReply*>(sender()); if (reply && reply->error() == bb::system::InvokeReplyError::None) { QList<bb::system::InvokeAction> actions = reply->actions(); for(int i=0; i<actions.size(); i++) { QList<bb::system::InvokeTarget> targets = actions.at(i).targets(); for(int j=0; j<targets.size(); j++) { qDebug() << targets.at(j).name(); if(targets.at(j).name()=="com.Talk2WatchProService") { m_talk2WatchProServiceAvailable = true; qDebug() << "Talk2WatchProService found"; } if(targets.at(j).name()=="com.Talk2WatchPro") { m_talk2WatchProAvailable = true; qDebug() << "Talk2WatchPro found"; } if(targets.at(j).name()=="com.Talk2Watch.invocation.msg") { m_talk2WatchAvailable = true; qDebug() << "Talk2Watch found"; } } } emit transmissionReady(); reply->deleteLater(); } else if (reply && reply->error() != bb::system::InvokeReplyError::None){ qDebug() << "ERROR: " << reply->error(); reply->deleteLater(); } else { qDebug() << "reply not found"; } }
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft %> <%docstring>signalfd(fd, mask, flags) -> str Invokes the syscall signalfd. See 'man 2 signalfd' for more information. Arguments: fd(int): fd mask(sigset_t*): mask flags(int): flags Returns: int </%docstring> <%page args="fd=0, mask=0, flags=0"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = [] can_pushstr_array = [] argument_names = ['fd', 'mask', 'flags'] argument_values = [fd, mask, flags] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%r' % (name, arg)) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, str): string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_signalfd']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* signalfd(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=('\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
#include "py_server.hpp" #include "py_common.hpp" #include "py_config.hpp" #include "py_except.hpp" #include "py_message.hpp" #include <memory> #include <mutex> #include <spdlog/sinks/stdout_color_sinks.h> #ifdef WIN32 #include <process.h> #define getpid _getpid #elif defined(UNIX) #include <unistd.h> #endif namespace shmpy { Py_Server::Py_Server(std::string_view name) : name_(name) { this->logger_ = spdlog::stdout_color_mt(fmt::format("{}/server", name)); logger_->trace("initializing Py_Server ..."); this->mmgr_ = std::make_unique<mmgr_t>( this->name_, config::BatchBinSize, config::BatchBinCount, this->logger_); this->msgsvr_ = std::make_unique<msgsvr_t>(this->logger_); this->init_META(); this->pool_status_ = POOL_STATUS::OK; logger_->trace("Py_Server initialize complete!"); } Py_Server::~Py_Server() { std::error_code ec; this->pool_status_ = POOL_STATUS::TERMINATE; this->meta_->ref_count--; std::lock_guard __lock(this->mtx_); if (msgsvr_->connected_client_ids().size() > 0) { logger_->trace("begin to close Py_Client ..."); // 防止迭代器失效 std::vector<uint32_t> __tmp_vec(msgsvr_->connected_client_ids()); for (const auto& id : __tmp_vec) { this->Py_CloseClient(id, ec); } logger_->trace("Py_Client close complete!"); } spdlog::drop(this->logger_->name()); } void Py_Server::Py_CloseClient(const uint32_t client_id, std::error_code& ec) noexcept { ec.clear(); logger_->trace("begin to close Py_Client_{} ...", client_id); this->msgsvr_->command(client_id, static_cast<uint32_t>(Py_Commands::detach_pool)); msgsvr_->close_client(client_id, ec); if (ec) { logger_->error( "fail to close client socket! {}({}) {}", ec.category().name(), ec.value(), ec.message()); } } void Py_Server::init_CALLBACKS() {} void Py_Server::init_META() { logger_->trace("begin to intialize Py_Server's pool meta ..."); std::error_code ec; this->meta_shmhdl_ = std::make_shared<shm_t>(fmt::format("shmpy#{}", this->name_), sizeof(POOL_META)); // map pool meta this->meta_ = reinterpret_cast<POOL_META*>(this->meta_shmhdl_->map(ec)); if (ec) { logger_->critical("unable to initialize Py_Server's pool meta! {}({}) {}", ec.category().name(), ec.value(), ec.message()); throw ShmpyExcept(ec); } // configure pool meta this->meta_->msgsvr_pub_port = this->msgsvr_->pub_port(); this->meta_->msgsvr_rep_port = this->msgsvr_->rep_port(); this->meta_->ref_count = 1; this->meta_->owner_pid = getpid(); logger_->trace("Py_Server's pool meta initialize complete!"); } uint32_t Py_Server::id() const noexcept { return this->msgsvr_->id(); } uint32_t Py_Server::Py_Id() const noexcept { return this->msgsvr_->id(); } std::string_view Py_Server::Py_Name() const noexcept { return this->name_; } POOL_STATUS Py_Server::Py_Status() const noexcept { return this->pool_status_; } uint32_t Py_Server::Py_RefCount() const noexcept { return this->meta_->ref_count; } }
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ OR[280] - device desc. address @@ OR[281] - first sector - if valid: add sector back to the free-list, if 0xffff, allocate sectors from free-list @@ OR[282] - sector count @@ OR[283] - output parameter index OR[268+idx]: first sector of the newly allocated chain @@ @@ OR[284] - return value @@ OR[285] - 2k buffer 0x0000 (0x000000) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x0001 (0x000002) 0x291C- f:00024 d: 284 | OR[284] = A 0x0002 (0x000004) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x0003 (0x000006) 0x291D- f:00024 d: 285 | OR[285] = A @ Allocate 2k buffer in OR[285] 0x0004 (0x000008) 0x101A- f:00010 d: 26 | A = 26 (0x001A) 0x0005 (0x00000A) 0x2929- f:00024 d: 297 | OR[297] = A 0x0006 (0x00000C) 0x111D- f:00010 d: 285 | A = 285 (0x011D) 0x0007 (0x00000E) 0x292A- f:00024 d: 298 | OR[298] = A 0x0008 (0x000010) 0x1129- f:00010 d: 297 | A = 297 (0x0129) 0x0009 (0x000012) 0x5800- f:00054 d: 0 | B = A 0x000A (0x000014) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x000B (0x000016) 0x7C09- f:00076 d: 9 | R = OR[9] 0x000C (0x000018) 0x8602- f:00103 d: 2 | P = P + 2 (0x000E), A # 0 0x000D (0x00001A) 0x700B- f:00070 d: 11 | P = P + 11 (0x0018) 0x000E (0x00001C) 0x1007- f:00010 d: 7 | A = 7 (0x0007) 0x000F (0x00001E) 0x2929- f:00024 d: 297 | OR[297] = A 0x0010 (0x000020) 0x1001- f:00010 d: 1 | A = 1 (0x0001) 0x0011 (0x000022) 0x292A- f:00024 d: 298 | OR[298] = A 0x0012 (0x000024) 0x1129- f:00010 d: 297 | A = 297 (0x0129) 0x0013 (0x000026) 0x5800- f:00054 d: 0 | B = A 0x0014 (0x000028) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318) 0x0016 (0x00002C) 0x7C09- f:00076 d: 9 | R = OR[9] 0x0017 (0x00002E) 0x7213- f:00071 d: 19 | P = P - 19 (0x0004) @ Read sector 4 into the buffer 0x0018 (0x000030) 0x1004- f:00010 d: 4 | A = 4 (0x0004) 0x0019 (0x000032) 0x291E- f:00024 d: 286 | OR[286] = A 0x001A (0x000034) 0x74CE- f:00072 d: 206 | R = P + 206 (0x00E8) @ Call XDISK to read or write sector 4 - OR[286]: command code 3 - write 4 - read @ Is second parameter sepcified, or default? 0x001B (0x000036) 0x2119- f:00020 d: 281 | A = OR[281] 0x001C (0x000038) 0x1E00-0xFFFF f:00017 d: 0 | A = A - 65535 (0xFFFF) 0x001E (0x00003C) 0x8402- f:00102 d: 2 | P = P + 2 (0x0020), A = 0 0x001F (0x00003E) 0x702F- f:00070 d: 47 | P = P + 47 (0x004E) @ Second parameter is default 0x0020 (0x000040) 0x1008- f:00010 d: 8 | A = 8 (0x0008) 0x0021 (0x000042) 0x291F- f:00024 d: 287 | OR[287] = A 0x0022 (0x000044) 0x211D- f:00020 d: 285 | A = OR[285] @ Read entry 7 into OR[296] 0x0023 (0x000046) 0x1407- f:00012 d: 7 | A = A + 7 (0x0007) 0x0024 (0x000048) 0x2908- f:00024 d: 264 | OR[264] = A 0x0025 (0x00004A) 0x3108- f:00030 d: 264 | A = (OR[264]) 0x0026 (0x00004C) 0x2928- f:00024 d: 296 | OR[296] = A @ This is the loop head 0x0027 (0x00004E) 0x2128- f:00020 d: 296 | A = OR[296] 0x0028 (0x000050) 0x8425- f:00102 d: 37 | P = P + 37 (0x004D), A = 0 @ Return error-code 1089 if exhausted list 0x0029 (0x000052) 0x211D- f:00020 d: 285 | A = OR[285] @ Read current entry fields into OR[290] and OR[291] 0x002A (0x000054) 0x251F- f:00022 d: 287 | A = A + OR[287] 0x002B (0x000056) 0x2920- f:00024 d: 288 | OR[288] = A 0x002C (0x000058) 0x2120- f:00020 d: 288 | A = OR[288] 0x002D (0x00005A) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001) 0x002E (0x00005C) 0x2921- f:00024 d: 289 | OR[289] = A 0x002F (0x00005E) 0x3120- f:00030 d: 288 | A = (OR[288]) 0x0030 (0x000060) 0x2922- f:00024 d: 290 | OR[290] = A 0x0031 (0x000062) 0x3121- f:00030 d: 289 | A = (OR[289]) 0x0032 (0x000064) 0x2923- f:00024 d: 291 | OR[291] = A 0x0033 (0x000066) 0x211A- f:00020 d: 282 | A = OR[282] 0x0034 (0x000068) 0x2723- f:00023 d: 291 | A = A - OR[291] 0x0035 (0x00006A) 0x8402- f:00102 d: 2 | P = P + 2 (0x0037), A = 0 0x0036 (0x00006C) 0x7006- f:00070 d: 6 | P = P + 6 (0x003C) @ If requested chain size matches the current one, remove it from free array and return 0x0037 (0x00006E) 0x74F5- f:00072 d: 245 | R = P + 245 (0x012C) @ Remove specified entry from array - OR[287]: Sector 4 array index (each entry is two words long), starts at index 8 0x0038 (0x000070) 0x2122- f:00020 d: 290 | A = OR[290] 0x0039 (0x000072) 0x2919- f:00024 d: 281 | OR[281] = A 0x003A (0x000074) 0x7081- f:00070 d: 129 | P = P + 129 (0x00BB) @ Some final checks, write back sector 4 and return 0x003B (0x000076) 0x700E- f:00070 d: 14 | P = P + 14 (0x0049) @ If requested chain size is less than the current one, cut the chain into two, and return part of it 0x003C (0x000078) 0x211A- f:00020 d: 282 | A = OR[282] 0x003D (0x00007A) 0x2723- f:00023 d: 291 | A = A - OR[291] 0x003E (0x00007C) 0x8002- f:00100 d: 2 | P = P + 2 (0x0040), C = 0 0x003F (0x00007E) 0x700A- f:00070 d: 10 | P = P + 10 (0x0049) 0x0040 (0x000080) 0x2122- f:00020 d: 290 | A = OR[290] 0x0041 (0x000082) 0x251A- f:00022 d: 282 | A = A + OR[282] 0x0042 (0x000084) 0x3920- f:00034 d: 288 | (OR[288]) = A 0x0043 (0x000086) 0x2123- f:00020 d: 291 | A = OR[291] 0x0044 (0x000088) 0x271A- f:00023 d: 282 | A = A - OR[282] 0x0045 (0x00008A) 0x3921- f:00034 d: 289 | (OR[289]) = A 0x0046 (0x00008C) 0x2122- f:00020 d: 290 | A = OR[290] 0x0047 (0x00008E) 0x2919- f:00024 d: 281 | OR[281] = A 0x0048 (0x000090) 0x7073- f:00070 d: 115 | P = P + 115 (0x00BB) @ Some final checks, write back sector 4 and return @ Move on to the next entry 0x0049 (0x000092) 0x2F28- f:00027 d: 296 | OR[296] = OR[296] - 1 0x004A (0x000094) 0x1002- f:00010 d: 2 | A = 2 (0x0002) 0x004B (0x000096) 0x2B1F- f:00025 d: 287 | OR[287] = A + OR[287] 0x004C (0x000098) 0x7225- f:00071 d: 37 | P = P - 37 (0x0027) 0x004D (0x00009A) 0x706A- f:00070 d: 106 | P = P + 106 (0x00B7) @ Return error-code 1089 @ Second parameter is specified 0x004E (0x00009C) 0x2119- f:00020 d: 281 | A = OR[281] 0x004F (0x00009E) 0x251A- f:00022 d: 282 | A = A + OR[282] 0x0050 (0x0000A0) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001) 0x0051 (0x0000A2) 0x2924- f:00024 d: 292 | OR[292] = A 0x0052 (0x0000A4) 0x1008- f:00010 d: 8 | A = 8 (0x0008) 0x0053 (0x0000A6) 0x291F- f:00024 d: 287 | OR[287] = A 0x0054 (0x0000A8) 0x211D- f:00020 d: 285 | A = OR[285] 0x0055 (0x0000AA) 0x1407- f:00012 d: 7 | A = A + 7 (0x0007) 0x0056 (0x0000AC) 0x2908- f:00024 d: 264 | OR[264] = A 0x0057 (0x0000AE) 0x3108- f:00030 d: 264 | A = (OR[264]) 0x0058 (0x0000B0) 0x2928- f:00024 d: 296 | OR[296] = A 0x0059 (0x0000B2) 0x2128- f:00020 d: 296 | A = OR[296] 0x005A (0x0000B4) 0x845D- f:00102 d: 93 | P = P + 93 (0x00B7), A = 0 @ Return error-code 1089 0x005B (0x0000B6) 0x211D- f:00020 d: 285 | A = OR[285] 0x005C (0x0000B8) 0x251F- f:00022 d: 287 | A = A + OR[287] 0x005D (0x0000BA) 0x2920- f:00024 d: 288 | OR[288] = A 0x005E (0x0000BC) 0x2120- f:00020 d: 288 | A = OR[288] 0x005F (0x0000BE) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001) 0x0060 (0x0000C0) 0x2921- f:00024 d: 289 | OR[289] = A 0x0061 (0x0000C2) 0x3120- f:00030 d: 288 | A = (OR[288]) 0x0062 (0x0000C4) 0x2922- f:00024 d: 290 | OR[290] = A 0x0063 (0x0000C6) 0x3121- f:00030 d: 289 | A = (OR[289]) 0x0064 (0x0000C8) 0x2923- f:00024 d: 291 | OR[291] = A 0x0065 (0x0000CA) 0x2122- f:00020 d: 290 | A = OR[290] 0x0066 (0x0000CC) 0x2523- f:00022 d: 291 | A = A + OR[291] 0x0067 (0x0000CE) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001) 0x0068 (0x0000D0) 0x2925- f:00024 d: 293 | OR[293] = A 0x0069 (0x0000D2) 0x2119- f:00020 d: 281 | A = OR[281] 0x006A (0x0000D4) 0x2722- f:00023 d: 290 | A = A - OR[290] 0x006B (0x0000D6) 0x8003- f:00100 d: 3 | P = P + 3 (0x006E), C = 0 0x006C (0x0000D8) 0x8402- f:00102 d: 2 | P = P + 2 (0x006E), A = 0 0x006D (0x0000DA) 0x7002- f:00070 d: 2 | P = P + 2 (0x006F) 0x006E (0x0000DC) 0x7015- f:00070 d: 21 | P = P + 21 (0x0083) 0x006F (0x0000DE) 0x2124- f:00020 d: 292 | A = OR[292] 0x0070 (0x0000E0) 0x2725- f:00023 d: 293 | A = A - OR[293] 0x0071 (0x0000E2) 0x8002- f:00100 d: 2 | P = P + 2 (0x0073), C = 0 0x0072 (0x0000E4) 0x7011- f:00070 d: 17 | P = P + 17 (0x0083) 0x0073 (0x0000E6) 0x748F- f:00072 d: 143 | R = P + 143 (0x0102) @ Add space in free chain array at given offset - OR[287]: Free chain array offset 0x0074 (0x0000E8) 0x2119- f:00020 d: 281 | A = OR[281] 0x0075 (0x0000EA) 0x2722- f:00023 d: 290 | A = A - OR[290] 0x0076 (0x0000EC) 0x3921- f:00034 d: 289 | (OR[289]) = A 0x0077 (0x0000EE) 0x1002- f:00010 d: 2 | A = 2 (0x0002) 0x0078 (0x0000F0) 0x2B20- f:00025 d: 288 | OR[288] = A + OR[288] 0x0079 (0x0000F2) 0x1002- f:00010 d: 2 | A = 2 (0x0002) 0x007A (0x0000F4) 0x2B21- f:00025 d: 289 | OR[289] = A + OR[289] 0x007B (0x0000F6) 0x2124- f:00020 d: 292 | A = OR[292] 0x007C (0x0000F8) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001) 0x007D (0x0000FA) 0x3920- f:00034 d: 288 | (OR[288]) = A 0x007E (0x0000FC) 0x2125- f:00020 d: 293 | A = OR[293] 0x007F (0x0000FE) 0x2724- f:00023 d: 292 | A = A - OR[292] 0x0080 (0x000100) 0x3921- f:00034 d: 289 | (OR[289]) = A 0x0081 (0x000102) 0x703A- f:00070 d: 58 | P = P + 58 (0x00BB) 0x0082 (0x000104) 0x7031- f:00070 d: 49 | P = P + 49 (0x00B3) 0x0083 (0x000106) 0x2119- f:00020 d: 281 | A = OR[281] 0x0084 (0x000108) 0x2722- f:00023 d: 290 | A = A - OR[290] 0x0085 (0x00010A) 0x8003- f:00100 d: 3 | P = P + 3 (0x0088), C = 0 0x0086 (0x00010C) 0x8402- f:00102 d: 2 | P = P + 2 (0x0088), A = 0 0x0087 (0x00010E) 0x7002- f:00070 d: 2 | P = P + 2 (0x0089) 0x0088 (0x000110) 0x700A- f:00070 d: 10 | P = P + 10 (0x0092) 0x0089 (0x000112) 0x2124- f:00020 d: 292 | A = OR[292] 0x008A (0x000114) 0x2725- f:00023 d: 293 | A = A - OR[293] 0x008B (0x000116) 0x8402- f:00102 d: 2 | P = P + 2 (0x008D), A = 0 0x008C (0x000118) 0x7006- f:00070 d: 6 | P = P + 6 (0x0092) 0x008D (0x00011A) 0x2123- f:00020 d: 291 | A = OR[291] 0x008E (0x00011C) 0x271A- f:00023 d: 282 | A = A - OR[282] 0x008F (0x00011E) 0x3921- f:00034 d: 289 | (OR[289]) = A 0x0090 (0x000120) 0x702B- f:00070 d: 43 | P = P + 43 (0x00BB) 0x0091 (0x000122) 0x7022- f:00070 d: 34 | P = P + 34 (0x00B3) 0x0092 (0x000124) 0x2119- f:00020 d: 281 | A = OR[281] 0x0093 (0x000126) 0x2722- f:00023 d: 290 | A = A - OR[290] 0x0094 (0x000128) 0x8402- f:00102 d: 2 | P = P + 2 (0x0096), A = 0 0x0095 (0x00012A) 0x700D- f:00070 d: 13 | P = P + 13 (0x00A2) 0x0096 (0x00012C) 0x2124- f:00020 d: 292 | A = OR[292] 0x0097 (0x00012E) 0x2725- f:00023 d: 293 | A = A - OR[293] 0x0098 (0x000130) 0x8002- f:00100 d: 2 | P = P + 2 (0x009A), C = 0 0x0099 (0x000132) 0x7009- f:00070 d: 9 | P = P + 9 (0x00A2) 0x009A (0x000134) 0x2122- f:00020 d: 290 | A = OR[290] 0x009B (0x000136) 0x251A- f:00022 d: 282 | A = A + OR[282] 0x009C (0x000138) 0x3920- f:00034 d: 288 | (OR[288]) = A 0x009D (0x00013A) 0x2123- f:00020 d: 291 | A = OR[291] 0x009E (0x00013C) 0x271A- f:00023 d: 282 | A = A - OR[282] 0x009F (0x00013E) 0x3921- f:00034 d: 289 | (OR[289]) = A 0x00A0 (0x000140) 0x701B- f:00070 d: 27 | P = P + 27 (0x00BB) 0x00A1 (0x000142) 0x7012- f:00070 d: 18 | P = P + 18 (0x00B3) 0x00A2 (0x000144) 0x2119- f:00020 d: 281 | A = OR[281] 0x00A3 (0x000146) 0x2722- f:00023 d: 290 | A = A - OR[290] 0x00A4 (0x000148) 0x8402- f:00102 d: 2 | P = P + 2 (0x00A6), A = 0 0x00A5 (0x00014A) 0x7008- f:00070 d: 8 | P = P + 8 (0x00AD) 0x00A6 (0x00014C) 0x2124- f:00020 d: 292 | A = OR[292] 0x00A7 (0x00014E) 0x2725- f:00023 d: 293 | A = A - OR[293] 0x00A8 (0x000150) 0x8402- f:00102 d: 2 | P = P + 2 (0x00AA), A = 0 0x00A9 (0x000152) 0x7004- f:00070 d: 4 | P = P + 4 (0x00AD) 0x00AA (0x000154) 0x7482- f:00072 d: 130 | R = P + 130 (0x012C) 0x00AB (0x000156) 0x7010- f:00070 d: 16 | P = P + 16 (0x00BB) 0x00AC (0x000158) 0x7007- f:00070 d: 7 | P = P + 7 (0x00B3) 0x00AD (0x00015A) 0x2119- f:00020 d: 281 | A = OR[281] 0x00AE (0x00015C) 0x2722- f:00023 d: 290 | A = A - OR[290] 0x00AF (0x00015E) 0x8002- f:00100 d: 2 | P = P + 2 (0x00B1), C = 0 0x00B0 (0x000160) 0x7003- f:00070 d: 3 | P = P + 3 (0x00B3) 0x00B1 (0x000162) 0x1001- f:00010 d: 1 | A = 1 (0x0001) 0x00B2 (0x000164) 0x2928- f:00024 d: 296 | OR[296] = A 0x00B3 (0x000166) 0x2F28- f:00027 d: 296 | OR[296] = OR[296] - 1 0x00B4 (0x000168) 0x1002- f:00010 d: 2 | A = 2 (0x0002) 0x00B5 (0x00016A) 0x2B1F- f:00025 d: 287 | OR[287] = A + OR[287] 0x00B6 (0x00016C) 0x725D- f:00071 d: 93 | P = P - 93 (0x0059) @ Return error-code 1089 0x00B7 (0x00016E) 0x1800-0x0441 f:00014 d: 0 | A = 1089 (0x0441) 0x00B9 (0x000172) 0x291C- f:00024 d: 284 | OR[284] = A 0x00BA (0x000174) 0x7013- f:00070 d: 19 | P = P + 19 (0x00CD) @ Protect sectors below or equal to 6 - if that's what was specified --> FATAL 0x00BB (0x000176) 0x1006- f:00010 d: 6 | A = 6 (0x0006) 0x00BC (0x000178) 0x2719- f:00023 d: 281 | A = A - OR[281] 0x00BD (0x00017A) 0x8003- f:00100 d: 3 | P = P + 3 (0x00C0), C = 0 0x00BE (0x00017C) 0x8402- f:00102 d: 2 | P = P + 2 (0x00C0), A = 0 0x00BF (0x00017E) 0x7C34- f:00076 d: 52 | R = OR[52] 0x00C0 (0x000180) 0x0000- f:00000 d: 0 | PASS @ Sector number is greater than 6, make sure chain doesn't fall off of the end of the disk. If it does --> FATAL 0x00C1 (0x000182) 0x2119- f:00020 d: 281 | A = OR[281] 0x00C2 (0x000184) 0x251A- f:00022 d: 282 | A = A + OR[282] 0x00C3 (0x000186) 0x1601- f:00013 d: 1 | A = A - 1 (0x0001) 0x00C4 (0x000188) 0x2908- f:00024 d: 264 | OR[264] = A 0x00C5 (0x00018A) 0x1800-0x404B f:00014 d: 0 | A = 16459 (0x404B) 0x00C7 (0x00018E) 0x2708- f:00023 d: 264 | A = A - OR[264] 0x00C8 (0x000190) 0xB034- f:00130 d: 52 | R = OR[52], C = 0 0x00C9 (0x000192) 0x0000- f:00000 d: 0 | PASS @ Write back sector 4 0x00CA (0x000194) 0x1003- f:00010 d: 3 | A = 3 (0x0003) 0x00CB (0x000196) 0x291E- f:00024 d: 286 | OR[286] = A 0x00CC (0x000198) 0x741C- f:00072 d: 28 | R = P + 28 (0x00E8) @ Call XDISK to read or write sector 4 - OR[286]: command code 3 - write 4 - read @ Free up buffer, if allocated 0x00CD (0x00019A) 0x211D- f:00020 d: 285 | A = OR[285] 0x00CE (0x00019C) 0x8602- f:00103 d: 2 | P = P + 2 (0x00D0), A # 0 0x00CF (0x00019E) 0x7009- f:00070 d: 9 | P = P + 9 (0x00D8) 0x00D0 (0x0001A0) 0x101B- f:00010 d: 27 | A = 27 (0x001B) 0x00D1 (0x0001A2) 0x2929- f:00024 d: 297 | OR[297] = A 0x00D2 (0x0001A4) 0x211D- f:00020 d: 285 | A = OR[285] 0x00D3 (0x0001A6) 0x292A- f:00024 d: 298 | OR[298] = A 0x00D4 (0x0001A8) 0x1129- f:00010 d: 297 | A = 297 (0x0129) 0x00D5 (0x0001AA) 0x5800- f:00054 d: 0 | B = A 0x00D6 (0x0001AC) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x00D7 (0x0001AE) 0x7C09- f:00076 d: 9 | R = OR[9] @ Set output parameter from OR[281] 0x00D8 (0x0001B0) 0x2005- f:00020 d: 5 | A = OR[5] 0x00D9 (0x0001B2) 0x251B- f:00022 d: 283 | A = A + OR[283] 0x00DA (0x0001B4) 0x290D- f:00024 d: 269 | OR[269] = A 0x00DB (0x0001B6) 0x2119- f:00020 d: 281 | A = OR[281] 0x00DC (0x0001B8) 0x390D- f:00034 d: 269 | (OR[269]) = A @ Set return value from OR[284] and return from overlay 0x00DD (0x0001BA) 0x2005- f:00020 d: 5 | A = OR[5] 0x00DE (0x0001BC) 0x1406- f:00012 d: 6 | A = A + 6 (0x0006) 0x00DF (0x0001BE) 0x2908- f:00024 d: 264 | OR[264] = A 0x00E0 (0x0001C0) 0x211C- f:00020 d: 284 | A = OR[284] 0x00E1 (0x0001C2) 0x3908- f:00034 d: 264 | (OR[264]) = A 0x00E2 (0x0001C4) 0x102A- f:00010 d: 42 | A = 42 (0x002A) 0x00E3 (0x0001C6) 0x2929- f:00024 d: 297 | OR[297] = A 0x00E4 (0x0001C8) 0x1129- f:00010 d: 297 | A = 297 (0x0129) 0x00E5 (0x0001CA) 0x5800- f:00054 d: 0 | B = A 0x00E6 (0x0001CC) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x00E7 (0x0001CE) 0x7C09- f:00076 d: 9 | R = OR[9] @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ Call XDISK to access sector 4 @@ Input: @@ OR[286]: command code 3 - write 4 - read 0x00E8 (0x0001D0) 0x1028- f:00010 d: 40 | A = 40 (0x0028) 0x00E9 (0x0001D2) 0x2929- f:00024 d: 297 | OR[297] = A 0x00EA (0x0001D4) 0x1800-0x00A6 f:00014 d: 0 | A = 166 (0x00A6) 0x00EC (0x0001D8) 0x292A- f:00024 d: 298 | OR[298] = A 0x00ED (0x0001DA) 0x2118- f:00020 d: 280 | A = OR[280] @ Device desc. 0x00EE (0x0001DC) 0x292B- f:00024 d: 299 | OR[299] = A 0x00EF (0x0001DE) 0x211E- f:00020 d: 286 | A = OR[286] @ Command code 0x00F0 (0x0001E0) 0x292C- f:00024 d: 300 | OR[300] = A 0x00F1 (0x0001E2) 0x211D- f:00020 d: 285 | A = OR[285] @ Buffer 0x00F2 (0x0001E4) 0x292D- f:00024 d: 301 | OR[301] = A 0x00F3 (0x0001E6) 0x1000- f:00010 d: 0 | A = 0 (0x0000) @ Not used 0x00F4 (0x0001E8) 0x292E- f:00024 d: 302 | OR[302] = A 0x00F5 (0x0001EA) 0x1004- f:00010 d: 4 | A = 4 (0x0004) @ Sector number 0x00F6 (0x0001EC) 0x292F- f:00024 d: 303 | OR[303] = A 0x00F7 (0x0001EE) 0x1129- f:00010 d: 297 | A = 297 (0x0129) 0x00F8 (0x0001F0) 0x5800- f:00054 d: 0 | B = A 0x00F9 (0x0001F2) 0x1800-0x2318 f:00014 d: 0 | A = 8984 (0x2318) 0x00FB (0x0001F6) 0x7C09- f:00076 d: 9 | R = OR[9] 0x00FC (0x0001F8) 0x291C- f:00024 d: 284 | OR[284] = A 0x00FD (0x0001FA) 0x211C- f:00020 d: 284 | A = OR[284] 0x00FE (0x0001FC) 0x8602- f:00103 d: 2 | P = P + 2 (0x0100), A # 0 0x00FF (0x0001FE) 0x7002- f:00070 d: 2 | P = P + 2 (0x0101) 0x0100 (0x000200) 0x7233- f:00071 d: 51 | P = P - 51 (0x00CD) 0x0101 (0x000202) 0x0200- f:00001 d: 0 | EXIT @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ Add space in free chain array at given offset @@ @@ Input: @@ OR[287]: Free chain array offset @@ OR[285]: buffer address @ check if offset 2046 in buffer is 0 0x0102 (0x000204) 0x1800-0x0800 f:00014 d: 0 | A = 2048 (0x0800) 0x0104 (0x000208) 0x1602- f:00013 d: 2 | A = A - 2 (0x0002) 0x0105 (0x00020A) 0x2926- f:00024 d: 294 | OR[294] = A 0x0106 (0x00020C) 0x211D- f:00020 d: 285 | A = OR[285] 0x0107 (0x00020E) 0x2526- f:00022 d: 294 | A = A + OR[294] 0x0108 (0x000210) 0x2913- f:00024 d: 275 | OR[275] = A 0x0109 (0x000212) 0x3113- f:00030 d: 275 | A = (OR[275]) 0x010A (0x000214) 0x8602- f:00103 d: 2 | P = P + 2 (0x010C), A # 0 @ Offset 2046 is non-0: return from overlay with exit-code 1095 0x010B (0x000216) 0x7005- f:00070 d: 5 | P = P + 5 (0x0110) 0x010C (0x000218) 0x1800-0x0447 f:00014 d: 0 | A = 1095 (0x0447) 0x010E (0x00021C) 0x291C- f:00024 d: 284 | OR[284] = A 0x010F (0x00021E) 0x7242- f:00071 d: 66 | P = P - 66 (0x00CD) 0x0110 (0x000220) 0x2126- f:00020 d: 294 | A = OR[294] 0x0111 (0x000222) 0x271F- f:00023 d: 287 | A = A - OR[287] 0x0112 (0x000224) 0x8415- f:00102 d: 21 | P = P + 21 (0x0127), A = 0 0x0113 (0x000226) 0x2126- f:00020 d: 294 | A = OR[294] 0x0114 (0x000228) 0x1602- f:00013 d: 2 | A = A - 2 (0x0002) 0x0115 (0x00022A) 0x2926- f:00024 d: 294 | OR[294] = A 0x0116 (0x00022C) 0x211D- f:00020 d: 285 | A = OR[285] 0x0117 (0x00022E) 0x2526- f:00022 d: 294 | A = A + OR[294] 0x0118 (0x000230) 0x2920- f:00024 d: 288 | OR[288] = A 0x0119 (0x000232) 0x2120- f:00020 d: 288 | A = OR[288] 0x011A (0x000234) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001) 0x011B (0x000236) 0x2921- f:00024 d: 289 | OR[289] = A 0x011C (0x000238) 0x2120- f:00020 d: 288 | A = OR[288] 0x011D (0x00023A) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002) 0x011E (0x00023C) 0x2908- f:00024 d: 264 | OR[264] = A 0x011F (0x00023E) 0x3120- f:00030 d: 288 | A = (OR[288]) 0x0120 (0x000240) 0x3908- f:00034 d: 264 | (OR[264]) = A 0x0121 (0x000242) 0x2121- f:00020 d: 289 | A = OR[289] 0x0122 (0x000244) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002) 0x0123 (0x000246) 0x2908- f:00024 d: 264 | OR[264] = A 0x0124 (0x000248) 0x3121- f:00030 d: 289 | A = (OR[289]) 0x0125 (0x00024A) 0x3908- f:00034 d: 264 | (OR[264]) = A 0x0126 (0x00024C) 0x7216- f:00071 d: 22 | P = P - 22 (0x0110) 0x0127 (0x00024E) 0x211D- f:00020 d: 285 | A = OR[285] 0x0128 (0x000250) 0x1407- f:00012 d: 7 | A = A + 7 (0x0007) 0x0129 (0x000252) 0x2908- f:00024 d: 264 | OR[264] = A 0x012A (0x000254) 0x3D08- f:00036 d: 264 | (OR[264]) = (OR[264]) + 1 0x012B (0x000256) 0x0200- f:00001 d: 0 | EXIT @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ Remove specified entry from free chain array @@ @@ Input: @@ OR[287]: Free chain array offset @@ OR[285]: buffer address 0x012C (0x000258) 0x1800-0x0800 f:00014 d: 0 | A = 2048 (0x0800) 0x012E (0x00025C) 0x1602- f:00013 d: 2 | A = A - 2 (0x0002) 0x012F (0x00025E) 0x2908- f:00024 d: 264 | OR[264] = A 0x0130 (0x000260) 0x211F- f:00020 d: 287 | A = OR[287] 0x0131 (0x000262) 0x2708- f:00023 d: 264 | A = A - OR[264] 0x0132 (0x000264) 0x8414- f:00102 d: 20 | P = P + 20 (0x0146), A = 0 @ Terminate loop if we've finished updating the array 0x0133 (0x000266) 0x211D- f:00020 d: 285 | A = OR[285] 0x0134 (0x000268) 0x251F- f:00022 d: 287 | A = A + OR[287] 0x0135 (0x00026A) 0x2920- f:00024 d: 288 | OR[288] = A @ OR[288] points to the array element in memory 0x0136 (0x00026C) 0x2120- f:00020 d: 288 | A = OR[288] 0x0137 (0x00026E) 0x1401- f:00012 d: 1 | A = A + 1 (0x0001) 0x0138 (0x000270) 0x2921- f:00024 d: 289 | OR[289] = A @ OR[289] points to the second field of the array element in memory 0x0139 (0x000272) 0x2120- f:00020 d: 288 | A = OR[288] 0x013A (0x000274) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002) 0x013B (0x000276) 0x2908- f:00024 d: 264 | OR[264] = A @ OR[264] points to the next array element in memory 0x013C (0x000278) 0x3108- f:00030 d: 264 | A = (OR[264]) 0x013D (0x00027A) 0x3920- f:00034 d: 288 | (OR[288]) = A @ Copy the first field of the next entry into first field of the current one 0x013E (0x00027C) 0x2121- f:00020 d: 289 | A = OR[289] 0x013F (0x00027E) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002) 0x0140 (0x000280) 0x2908- f:00024 d: 264 | OR[264] = A @ OR[264] points to the seconf field of the next array element in memory 0x0141 (0x000282) 0x3108- f:00030 d: 264 | A = (OR[264]) 0x0142 (0x000284) 0x3921- f:00034 d: 289 | (OR[289]) = A @ Copy the second field of the next entry into the second field of the current one 0x0143 (0x000286) 0x1002- f:00010 d: 2 | A = 2 (0x0002) @ Increment entry index and loop 0x0144 (0x000288) 0x2B1F- f:00025 d: 287 | OR[287] = A + OR[287] 0x0145 (0x00028A) 0x7219- f:00071 d: 25 | P = P - 25 (0x012C) @ Finished updating the array - null-terminate the array 0x0146 (0x00028C) 0x2120- f:00020 d: 288 | A = OR[288] 0x0147 (0x00028E) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002) 0x0148 (0x000290) 0x2908- f:00024 d: 264 | OR[264] = A 0x0149 (0x000292) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x014A (0x000294) 0x3908- f:00034 d: 264 | (OR[264]) = A 0x014B (0x000296) 0x2121- f:00020 d: 289 | A = OR[289] 0x014C (0x000298) 0x1402- f:00012 d: 2 | A = A + 2 (0x0002) 0x014D (0x00029A) 0x2908- f:00024 d: 264 | OR[264] = A 0x014E (0x00029C) 0x1000- f:00010 d: 0 | A = 0 (0x0000) 0x014F (0x00029E) 0x3908- f:00034 d: 264 | (OR[264]) = A @ Decrement the number of fields in the array, stored at offset 7 0x0150 (0x0002A0) 0x211D- f:00020 d: 285 | A = OR[285] 0x0151 (0x0002A2) 0x1407- f:00012 d: 7 | A = A + 7 (0x0007) 0x0152 (0x0002A4) 0x2908- f:00024 d: 264 | OR[264] = A 0x0153 (0x0002A6) 0x3F08- f:00037 d: 264 | (OR[264]) = (OR[264]) - 1 0x0154 (0x0002A8) 0x0200- f:00001 d: 0 | EXIT 0x0155 (0x0002AA) 0x0000- f:00000 d: 0 | PASS 0x0156 (0x0002AC) 0x0000- f:00000 d: 0 | PASS 0x0157 (0x0002AE) 0x0000- f:00000 d: 0 | PASS
.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, 0c ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 10 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, 2c ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 30 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, 4c ld(hl++), a inc l inc l ld a, d ld(hl++), a ld a, 50 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@109b 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
;-- utility functions -- ;--- multiplication --- multiply: ; $a * $b mov $b $c ;counter mov $a $b ;multiplication base ldi $d 0 ;tmp cmp 0 jz .end .loop: mov $c $a ; counter equals 0 -> we're done cmp 0 jz .end mov $d $a add $b $d mov $c $a subi 1 $c j .loop .end: mov $d $a ret ;--- divide --- #bank ".data" _sign: #res 1 #bank ".instr" divide: ;$a / $b mov $a $c; c contains tmp value ldi $d 2; sign on st $d _sign ldi $d 0; counter cmp 0 jz .ret .loop: mov $c $a sub $b $a ;subtract the divisor mov $a $c jz .ret_zero ;check if the sign is positive. ;if sign is positive we'll check when goes negative and return. andi 128 $a jz .set_sign ;sign is not positive, check against old sign push $d ld $d _sign sub $d $a pop $d jz .ret ;sign went negative, returning .continue: mov $d $a addi 1 $d j .loop .ret_zero: mov $d $a addi 1 $d .ret: ;we're done! reminder is negative, get positive part and return mov $d $a ret .set_sign: ldi $a 128 ;set sign to 1, when we compare and it changes we're done. st $a _sign j .continue ;--- get division reminder --- reminder: ;$a % $b mov $a $c; c contains tmp value ldi $d 2; sign cmp 0 jz .ret_zero .loop: mov $c $a sub $b $a ;subtract the divisor and check if zero jz .ret_zero mov $a $c ;check if the sign is positive. ;if sign is positive we'll check when goes negative and return. andi 128 $a jz .set_sign ;sign is not positive, check against old sign sub $d $a jz .ret ;sign went negative, returning. j .loop .ret: ;we're done! reminder is negative, get positive part and return mov $c $a add $b $a .ret_zero: ret .set_sign: ldi $d 128 ;set sign to 1, when we compare and it changes we're done. j .loop ;--- compare --- compare: ;$a < $b sub $b $a add $b $a jc .ret_false ; a greater ldi $a 0 ret ; b greater .ret_false: ldi $a 1 ret
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r8 push %rbp push %rcx push %rdi push %rsi lea addresses_A_ht+0x1a39c, %r8 nop nop nop nop add $57283, %rbp mov $0x6162636465666768, %r13 movq %r13, %xmm3 vmovups %ymm3, (%r8) nop cmp %r10, %r10 lea addresses_WT_ht+0x15a1c, %rsi lea addresses_A_ht+0xdd5c, %rdi clflush (%rsi) and %r12, %r12 mov $119, %rcx rep movsq nop nop nop nop cmp $51095, %rcx lea addresses_D_ht+0x12044, %rsi lea addresses_D_ht+0x1088c, %rdi clflush (%rdi) nop nop nop nop nop inc %r12 mov $64, %rcx rep movsq nop nop nop dec %r13 lea addresses_UC_ht+0xbc1c, %rbp nop nop nop cmp $39413, %rcx movb $0x61, (%rbp) nop nop add %r8, %r8 lea addresses_normal_ht+0x12dc4, %rsi lea addresses_WC_ht+0x699c, %rdi nop nop sub $8174, %r13 mov $1, %rcx rep movsw nop xor $26324, %r12 pop %rsi pop %rdi pop %rcx pop %rbp pop %r8 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r8 push %rbp push %rdx // Faulty Load lea addresses_normal+0x1f09c, %rdx nop dec %r13 mov (%rdx), %r8 lea oracles, %rbp and $0xff, %r8 shlq $12, %r8 mov (%rbp,%r8,1), %r8 pop %rdx pop %rbp pop %r8 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 8, 'AVXalign': True, 'NT': True, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': True}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
; A219842: Number of ways to write n as x+y (0<x<=y) with 2x*y+1 prime. ; Submitted by Christian Krause ; 0,1,1,1,1,3,1,1,4,2,2,4,2,2,7,4,1,3,4,5,5,4,2,8,2,7,4,2,8,11,5,3,8,7,5,14,7,5,10,8,7,8,4,8,9,5,4,11,6,11,14,5,3,19,12,7,11,6,9,12,13,8,9,10,12,16,5,6,22,8,11,11,5,10,26,15,5,11,15,10,20,11,9,19,10,18,10,8,11,27,13,8,10,12,12,22,10,6,32,23 mov $3,$0 add $3,1 mov $5,$0 lpb $3 mov $2,$5 mul $2,2 seq $2,80339 ; Characteristic function of {1} union {primes}: 1 if n is 1 or a prime, else 0. sub $3,2 add $4,$2 add $5,$3 sub $5,1 lpe mov $0,$4
Route21_Script: call EnableAutoTextBoxDrawing ld hl, Route21TrainerHeader0 ld de, Route21_ScriptPointers ld a, [wRoute21CurScript] call ExecuteCurMapScriptInTable ld [wRoute21CurScript], a ret Route21_ScriptPointers: dw CheckFightingMapTrainers dw DisplayEnemyTrainerTextAndStartBattle dw EndTrainerBattle Route21_TextPointers: dw Route21Text1 dw Route21Text2 dw Route21Text3 dw Route21Text4 dw Route21Text5 dw Route21Text6 dw Route21Text7 dw Route21Text8 dw Route21Text9 Route21TrainerHeader0: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_0 db ($0 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_0 dw Route21BattleText1 ; TextBeforeBattle dw Route21AfterBattleText1 ; TextAfterBattle dw Route21EndBattleText1 ; TextEndBattle dw Route21EndBattleText1 ; TextEndBattle Route21TrainerHeader1: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_1 db ($0 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_1 dw Route21BattleText2 ; TextBeforeBattle dw Route21AfterBattleText2 ; TextAfterBattle dw Route21EndBattleText2 ; TextEndBattle dw Route21EndBattleText2 ; TextEndBattle Route21TrainerHeader2: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_2 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_2 dw Route21BattleText3 ; TextBeforeBattle dw Route21AfterBattleText3 ; TextAfterBattle dw Route21EndBattleText3 ; TextEndBattle dw Route21EndBattleText3 ; TextEndBattle Route21TrainerHeader3: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_3 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_3 dw Route21BattleText4 ; TextBeforeBattle dw Route21AfterBattleText4 ; TextAfterBattle dw Route21EndBattleText4 ; TextEndBattle dw Route21EndBattleText4 ; TextEndBattle Route21TrainerHeader4: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_4 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_4 dw Route21BattleText5 ; TextBeforeBattle dw Route21AfterBattleText5 ; TextAfterBattle dw Route21EndBattleText5 ; TextEndBattle dw Route21EndBattleText5 ; TextEndBattle Route21TrainerHeader5: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_5 db ($4 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_5 dw Route21BattleText6 ; TextBeforeBattle dw Route21AfterBattleText6 ; TextAfterBattle dw Route21EndBattleText6 ; TextEndBattle dw Route21EndBattleText6 ; TextEndBattle Route21TrainerHeader6: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_6 db ($3 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_6 dw Route21BattleText7 ; TextBeforeBattle dw Route21AfterBattleText7 ; TextAfterBattle dw Route21EndBattleText7 ; TextEndBattle dw Route21EndBattleText7 ; TextEndBattle Route21TrainerHeader7: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_7, 1 db ($0 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_7, 1 dw Route21BattleText8 ; TextBeforeBattle dw Route21AfterBattleText8 ; TextAfterBattle dw Route21EndBattleText8 ; TextEndBattle dw Route21EndBattleText8 ; TextEndBattle Route21TrainerHeader8: dbEventFlagBit EVENT_BEAT_ROUTE_21_TRAINER_8, 1 db ($0 << 4) ; trainer's view range dwEventFlagAddress EVENT_BEAT_ROUTE_21_TRAINER_8, 1 dw Route21BattleText9 ; TextBeforeBattle dw Route21AfterBattleText9 ; TextAfterBattle dw Route21EndBattleText9 ; TextEndBattle dw Route21EndBattleText9 ; TextEndBattle db $ff Route21Text1: TX_ASM ld hl, Route21TrainerHeader0 call TalkToTrainer jp TextScriptEnd Route21Text2: TX_ASM ld hl, Route21TrainerHeader1 call TalkToTrainer jp TextScriptEnd Route21Text3: TX_ASM ld hl, Route21TrainerHeader2 call TalkToTrainer jp TextScriptEnd Route21Text4: TX_ASM ld hl, Route21TrainerHeader3 call TalkToTrainer jp TextScriptEnd Route21Text5: TX_ASM ld hl, Route21TrainerHeader4 call TalkToTrainer jp TextScriptEnd Route21Text6: TX_ASM ld hl, Route21TrainerHeader5 call TalkToTrainer jp TextScriptEnd Route21Text7: TX_ASM ld hl, Route21TrainerHeader6 call TalkToTrainer jp TextScriptEnd Route21Text8: TX_ASM ld hl, Route21TrainerHeader7 call TalkToTrainer jp TextScriptEnd Route21Text9: TX_ASM ld hl, Route21TrainerHeader8 call TalkToTrainer jp TextScriptEnd Route21BattleText1: TX_FAR _Route21BattleText1 db "@" Route21EndBattleText1: TX_FAR _Route21EndBattleText1 db "@" Route21AfterBattleText1: TX_FAR _Route21AfterBattleText1 db "@" Route21BattleText2: TX_FAR _Route21BattleText2 db "@" Route21EndBattleText2: TX_FAR _Route21EndBattleText2 db "@" Route21AfterBattleText2: TX_FAR _Route21AfterBattleText2 db "@" Route21BattleText3: TX_FAR _Route21BattleText3 db "@" Route21EndBattleText3: TX_FAR _Route21EndBattleText3 db "@" Route21AfterBattleText3: TX_FAR _Route21AfterBattleText3 db "@" Route21BattleText4: TX_FAR _Route21BattleText4 db "@" Route21EndBattleText4: TX_FAR _Route21EndBattleText4 db "@" Route21AfterBattleText4: TX_FAR _Route21AfterBattleText4 db "@" Route21BattleText5: TX_FAR _Route21BattleText5 db "@" Route21EndBattleText5: TX_FAR _Route21EndBattleText5 db "@" Route21AfterBattleText5: TX_FAR _Route21AfterBattleText5 db "@" Route21BattleText6: TX_FAR _Route21BattleText6 db "@" Route21EndBattleText6: TX_FAR _Route21EndBattleText6 db "@" Route21AfterBattleText6: TX_FAR _Route21AfterBattleText6 db "@" Route21BattleText7: TX_FAR _Route21BattleText7 db "@" Route21EndBattleText7: TX_FAR _Route21EndBattleText7 db "@" Route21AfterBattleText7: TX_FAR _Route21AfterBattleText7 db "@" Route21BattleText8: TX_FAR _Route21BattleText8 db "@" Route21EndBattleText8: TX_FAR _Route21EndBattleText8 db "@" Route21AfterBattleText8: TX_FAR _Route21AfterBattleText8 db "@" Route21BattleText9: TX_FAR _Route21BattleText9 db "@" Route21EndBattleText9: TX_FAR _Route21EndBattleText9 db "@" Route21AfterBattleText9: TX_FAR _Route21AfterBattleText9 db "@"
.loadtable "data/flyover-table.tbl" .strn "\n" .strn "\n" .strn 01h, 1Ch, "You've traveled very far from\n" .strn 01h, 1Ch, "home...\n" .strn "\n" .strn "\n" .strn 01h, 1Ch, "Do you remember how your long\n" .strn 01h, 1Ch, "and winding journey began with\n" .strn 01h, 1Ch, "someone pounding at your door?\n" .strn 01h, 1Ch, "It was Pokey, the worst person in\n" .strn 01h, 1Ch, "your neighborhood, who knocked\n" .strn 01h, 1Ch, "on the door that fateful night.\n" .strn "\n" .strn "\n" .strn 01h, 1Ch, "On your way, you have walked,\n" .strn 01h, 1Ch, "thought and fought. Yet through\n" .strn 01h, 1Ch, "all this, you have never lost your\n" .strn 01h, 1Ch, "courage. You have grown steadily\n" .strn 01h, 1Ch, "stronger, though you have\n" .strn 01h, 1Ch, "experienced the pain of battle\n" .strn 01h, 1Ch, "many times.\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn 01h, 1Ch, "You are no longer alone in your\n" .strn 01h, 1Ch, "adventure, \cpaula who is\n" .strn 01h, 1Ch, "steadfast, kind and even pretty,\n" .strn 01h, 1Ch, "is always at your side.\n" .strn 01h, 1Ch, "\cjeff is with you as well.\n" .strn 01h, 1Ch, "Though he is timid, he came from\n" .strn 01h, 1Ch, "a distant land to help you.\n" .strn 01h, 1Ch, "\cness, as you certainly\n" .strn 01h, 1Ch, "know by now, you are not a\n" .strn 01h, 1Ch, "regular young man... You have\n" .strn 01h, 1Ch, "an awesome destiny to fulfill.\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn 01h, 1Ch, "The journey from this point will\n" .strn 01h, 1Ch, "be long, and it will be more\n" .strn 01h, 1Ch, "difficult than anything you have\n" .strn 01h, 1Ch, "undergone to this point. Yet, I\n" .strn 01h, 1Ch, "know you will be all right. When\n" .strn 01h, 1Ch, "good battles evil, which side do\n" .strn 01h, 1Ch, "you believe wins? Do you have\n" .strn 01h, 1Ch, "faith that good is triumphant?\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn 01h, 1Ch, "One thing you must never lose is\n" .strn 01h, 1Ch, "courage. If you believe in the\n" .strn 01h, 1Ch, "goal you are striving for, you will\n" .strn 01h, 1Ch, "be courageous. There are many\n" .strn 01h, 1Ch, "difficult times ahead, but you\n" .strn 01h, 1Ch, "must keep your sense of humor,\n" .strn 01h, 1Ch, "work through the tough\n" .strn 01h, 1Ch, "situations and enjoy yourself.\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn 01h, 1Ch, "When you have finished this cup\n" .strn 01h, 1Ch, "of coffee, your adventure will\n" .strn 01h, 1Ch, "begin again. Next, you must pass\n" .strn 01h, 1Ch, "through a vast desert and\n" .strn 01h, 1Ch, "proceed to the big city of\n" .strn 01h, 1Ch, "Fourside.\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn 01h, 1Ch, "\cness...\n" .strn 01h, 1Ch, " \cpaula...\n" .strn 01h, 1Ch, " \cjeff...\n" .strn "\n" .strn "\n" .strn 01h, 1Ch, "I wish you luck...\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .strn "\n" .str "\n"
#ifdef CH_LANG_CC /* * _______ __ * / ___/ / ___ __ _ / / ___ * / /__/ _ \/ _ \/ V \/ _ \/ _ \ * \___/_//_/\___/_/_/_/_.__/\___/ * Please refer to Copyright.txt, in Chombo's root directory. */ #endif #include "EBStencil.H" #include "EBCellFAB.H" #include "EBFaceFAB.H" #include "NamespaceHeader.H" /**************/ /**************/ /**************/ EBStencil::EBStencil(const Vector<VolIndex>& a_srcVofs, const BaseIVFAB<VoFStencil>& a_vofStencil, const Box& a_box, const EBISBox& a_ebisBox, const IntVect& a_ghostVectPhi, const IntVect& a_ghostVectLph, int a_varDest, bool a_doRelaxOpt, int nComp, IntVectSet a_setIrreg, bool a_useInputSet) : m_box( a_box ), m_ebisBox( a_ebisBox ), m_ghostVectPhi( a_ghostVectPhi ), m_ghostVectLph( a_ghostVectLph ), m_destVar(a_varDest), m_doRelaxOpt(a_doRelaxOpt), m_nComp(nComp), m_setIrreg(a_setIrreg), m_useInputSets(a_useInputSet) { CH_TIMERS("EBStencil::EBStencil"); CH_TIMER("computeOffsets", t1); CH_START(t1); computeOffsets(a_srcVofs, a_vofStencil); CH_STOP(t1); } /**************/ /**************/ EBStencil::EBStencil(const Vector<VolIndex>& a_srcVofs, const Vector<VoFStencil>& a_vofStencil, const Box& a_boxLph, const Box& a_boxPhi, const EBISBox& a_ebisBoxLph, const EBISBox& a_ebisBoxPhi, const IntVect& a_ghostVectLph, const IntVect& a_ghostVectPhi, int a_varDest, int nComp, IntVectSet a_setIrreg, bool a_useInputSet) : m_ghostVectPhi( a_ghostVectPhi ), m_ghostVectLph( a_ghostVectLph ), m_destVar(a_varDest), m_doRelaxOpt(false), m_nComp(nComp), m_setIrreg(a_setIrreg), m_useInputSets(a_useInputSet) { // CH_TIMERS("EBStencil::EBStencil"); // CH_TIMER("computeOffsets", t1); // CH_START(t1); Box boxPhi = grow(a_boxPhi, a_ghostVectPhi); Box boxLph = grow(a_boxLph, a_ghostVectLph); m_lphBox = boxLph; m_phiBox = boxPhi; //debugging hook //m_srcVoFs = a_srcVofs; const IntVectSet& ivsPhi = a_ebisBoxPhi.getMultiCells(boxPhi); const IntVectSet& ivsLph = a_ebisBoxLph.getMultiCells(boxLph); const EBGraph& ebgraphPhi = a_ebisBoxPhi.getEBGraph(); const EBGraph& ebgraphLph = a_ebisBoxLph.getEBGraph(); BaseIVFAB<Real> baseivfabPhi(ivsPhi, ebgraphPhi, m_nComp); BaseIVFAB<Real> baseivfabLph(ivsLph, ebgraphLph, m_nComp); const IntVect& smallendPhi = boxPhi.smallEnd(); const IntVect& smallendLph = boxLph.smallEnd(); IntVect ncellsPhi = boxPhi.size(); IntVect ncellsLph = boxLph.size(); m_ebstencil.resize(a_srcVofs.size()); m_destTerms.resize(a_srcVofs.size()); m_cacheLph.resize(a_srcVofs.size()); m_cachePhi.resize(a_srcVofs.size()); for (int isrc = 0; isrc < a_srcVofs.size(); isrc++) { const VolIndex& srcVof = a_srcVofs[isrc]; if (a_ebisBoxLph.numVoFs(srcVof.gridIndex()) > 1) {//multi-valued (the dataPtr(0) is correct--that is where we start from) m_destTerms[isrc].offset = baseivfabLph.getIndex(srcVof, m_destVar) - baseivfabLph.dataPtr(0); m_destTerms[isrc].multiValued = true; } else {//single-valued IntVect ivLph = srcVof.gridIndex() - smallendLph; IntVect ivPhi = srcVof.gridIndex() - smallendPhi; m_destTerms[isrc].offset = ivLph[0] + ivLph[1]*ncellsLph[0] ; #if CH_SPACEDIM==3 m_destTerms[isrc].offset += ivLph[2]*ncellsLph[0]*ncellsLph[1]; #endif //add in term due to variable number #if CH_SPACEDIM==2 m_destTerms[isrc].offset += m_destVar*ncellsLph[0]*ncellsLph[1]; #elif CH_SPACEDIM==3 m_destTerms[isrc].offset += m_destVar*ncellsLph[0]*ncellsLph[1]*ncellsLph[2]; #else bogus_spacedim(); #endif m_destTerms[isrc].multiValued = false; } const VoFStencil& sten = a_vofStencil[isrc]; for (int isten = 0; isten < sten.size(); isten++) { const VolIndex stencilVof = sten.vof(isten); int srcVar = sten.variable(isten); stencilTerm stenEntry; stenEntry.weight = sten.weight(isten); if (a_ebisBoxPhi.numVoFs(stencilVof.gridIndex()) > 1) {//multi-valued (the dataPtr(0) is correct--that is where we start from) stenEntry.offset = baseivfabPhi.getIndex(stencilVof, srcVar) - baseivfabPhi.dataPtr(0); m_ebstencil[isrc].multi.push_back(stenEntry); } else {//single-valued IntVect ivPhi = stencilVof.gridIndex() - smallendPhi; stenEntry.offset = ivPhi[0] + ivPhi[1]*ncellsPhi[0] ; #if CH_SPACEDIM==3 stenEntry.offset += ivPhi[2]*ncellsPhi[0]*ncellsPhi[1]; #endif //add in term due to variable number #if CH_SPACEDIM==2 stenEntry.offset += srcVar*ncellsPhi[0]*ncellsPhi[1]; #elif CH_SPACEDIM==3 stenEntry.offset += srcVar*ncellsPhi[0]*ncellsPhi[1]*ncellsPhi[2]; #else bogus_spacedim(); #endif m_ebstencil[isrc].single.push_back(stenEntry); } } } // CH_STOP(t1); } /**************/ /**************/ void EBStencil::apply(EBCellFAB& a_lofphi, const EBCellFAB& a_phi, bool a_incrementOnly, int a_ivar) const { CH_TIMERS("EBStencil::apply"); CH_TIMER("apply_loop_overvofs", t3); CH_TIMER("apply_header", t4); CH_START(t4); CH_assert(a_lofphi.getSingleValuedFAB().box() == m_lphBox); CH_assert(a_phi.getSingleValuedFAB().box() == m_phiBox); const Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(a_ivar); Real* singleValuedPtrLph = a_lofphi.getSingleValuedFAB().dataPtr(a_ivar); const Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(a_ivar); Real* multiValuedPtrLph = a_lofphi.getMultiValuedFAB().dataPtr(a_ivar); CH_STOP(t4); CH_START(t3); for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { //debugging hook //const VolIndex& srcVoF = m_srcVoFs[isrc]; const ebstencil_t& ebstencil = m_ebstencil[isrc]; Real* lphiPtr = NULL; if (m_destTerms[isrc].multiValued) { lphiPtr = multiValuedPtrLph + m_destTerms[isrc].offset; } else { lphiPtr = singleValuedPtrLph + m_destTerms[isrc].offset; } Real& lphi = *lphiPtr; if (!a_incrementOnly) { lphi = 0.; } //single-valued for (int isingle = 0; isingle < ebstencil.single.size(); isingle++) { const int & offset = ebstencil.single[isingle].offset; const Real& phiVal = *(singleValuedPtrPhi + offset); const Real& weight = ebstencil.single[isingle].weight; lphi += phiVal*weight; } //multi-valued for (int imulti = 0; imulti < ebstencil.multi.size(); imulti++) { const int & offset = ebstencil.multi[imulti].offset; const Real& phiVal = *(multiValuedPtrPhi + offset); const Real& weight = ebstencil.multi[imulti].weight; lphi += phiVal*weight; } } CH_STOP(t3); } void EBStencil::apply(EBCellFAB& a_lofphi, const EBCellFAB& a_phi, const BaseIVFAB<Real>& a_alphaWeight, Real a_alpha, Real a_beta, bool a_incrementOnly) const { if (!m_doRelaxOpt) { MayDay::Error("this ebstencil was not configured to deal with baseivfab alpha"); } CH_TIMERS("EBStencil::apply_alpha_beta"); CH_TIMER("apply_alpha_beta_loop_overvofs", t3); CH_TIMER("apply_alpha_beta_header", t4); CH_START(t4); CH_assert(a_lofphi.getSingleValuedFAB().box() == m_lphBox); CH_assert(a_phi.getSingleValuedFAB().box() == m_phiBox); const Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(0); Real* singleValuedPtrLph = a_lofphi.getSingleValuedFAB().dataPtr(0); const Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(0); Real* multiValuedPtrLph = a_lofphi.getMultiValuedFAB().dataPtr(0); const Real* alphaWeightPtr = a_alphaWeight.dataPtr(0); CH_STOP(t4); CH_START(t3); for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { //debugging hook //const VolIndex& srcVoF = m_srcVoFs[isrc]; const ebstencil_t& ebstencil = m_ebstencil[isrc]; Real* lphiPtr = NULL; const Real* sourPtr = NULL; int alphaOffset = m_alphaBeta[isrc]; const Real& alphaWeight = *(alphaWeightPtr + alphaOffset); if (m_destTerms[isrc].multiValued) { lphiPtr = multiValuedPtrLph + m_destTerms[isrc].offset; sourPtr = multiValuedPtrPhi + m_sourTerms[isrc].offset; } else { lphiPtr = singleValuedPtrLph + m_destTerms[isrc].offset; sourPtr = singleValuedPtrPhi + m_sourTerms[isrc].offset; } Real& lphi = *lphiPtr; const Real& sour = *sourPtr; if (!a_incrementOnly) { lphi = 0.; } //single-valued for (int isingle = 0; isingle < ebstencil.single.size(); isingle++) { const int & offset = ebstencil.single[isingle].offset; const Real& phiVal = *(singleValuedPtrPhi + offset); const Real& weight = ebstencil.single[isingle].weight; lphi += phiVal*weight; } //multi-valued for (int imulti = 0; imulti < ebstencil.multi.size(); imulti++) { const int & offset = ebstencil.multi[imulti].offset; const Real& phiVal = *(multiValuedPtrPhi + offset); const Real& weight = ebstencil.multi[imulti].weight; lphi += phiVal*weight; } lphi = a_alpha*alphaWeight*sour + a_beta*lphi; } CH_STOP(t3); } //For EB x domain where m_alpha, m_beta have changed since defineStencils //we need both alphaWeight and betaWeight to calculate the relaxation parameter: //lambdaDiagWeight = 1/(alpha*alphaWeight+beta*betaWeight) void EBStencil::apply(EBCellFAB& a_lofphi, const EBCellFAB& a_phi, const Real a_lambdaFactor, const Real a_alpha, const BaseIVFAB<Real>& a_alphaWeight, const Real a_beta, const BaseIVFAB<Real>& a_betaWeight, Real a_one, bool a_incrementOnly) const { if (!m_doRelaxOpt) { MayDay::Error("this ebstencil was not configured to deal with baseivfab alpha"); } CH_TIMERS("EBStencil::apply_alpha_beta"); CH_TIMER("apply_alpha_beta_loop_overvofs", t3); CH_TIMER("apply_alpha_beta_header", t4); CH_START(t4); CH_assert(a_lofphi.getSingleValuedFAB().box() == m_lphBox); CH_assert(a_phi.getSingleValuedFAB().box() == m_phiBox); const Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(0); Real* singleValuedPtrLph = a_lofphi.getSingleValuedFAB().dataPtr(0); const Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(0); Real* multiValuedPtrLph = a_lofphi.getMultiValuedFAB().dataPtr(0); const Real* alphaWeightPtr = a_alphaWeight.dataPtr(0); const Real* betaWeightPtr = a_betaWeight.dataPtr(0); CH_STOP(t4); CH_START(t3); for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { //debugging hook //const VolIndex& srcVoF = m_srcVoFs[isrc]; //const ebstencil_t& ebstencil = m_ebstencil[isrc]; Real* lphiPtr = NULL; const Real* sourPtr = NULL; int alphaOffset = m_alphaBeta[isrc]; int betaOffset = m_alphaBeta[isrc]; const Real& alphaWeight = *(alphaWeightPtr + alphaOffset); const Real& betaWeight = *(betaWeightPtr + betaOffset); Real product = a_alpha*alphaWeight+a_beta*betaWeight; Real lambdaWeight = 0.; if (Abs(product) > 1.e-15) lambdaWeight = 1./product; if (m_destTerms[isrc].multiValued) { lphiPtr = multiValuedPtrLph + m_destTerms[isrc].offset; sourPtr = multiValuedPtrPhi + m_sourTerms[isrc].offset; } else { lphiPtr = singleValuedPtrLph + m_destTerms[isrc].offset; sourPtr = singleValuedPtrPhi + m_sourTerms[isrc].offset; } Real& lphi = *lphiPtr; const Real& sour = *sourPtr; if (!a_incrementOnly) { lphi = 0.; } // //single-valued // for (int isingle = 0; isingle < ebstencil.single.size(); isingle++) // { // const int & offset = ebstencil.single[isingle].offset; // const Real& phiVal = *(singleValuedPtrPhi + offset); // const Real& weight = ebstencil.single[isingle].weight; // lphi += phiVal*weight; // } // //multi-valued // for (int imulti = 0; imulti < ebstencil.multi.size(); imulti++) // { // const int & offset = ebstencil.multi[imulti].offset; // const Real& phiVal = *(multiValuedPtrPhi + offset); // const Real& weight = ebstencil.multi[imulti].weight; // lphi += phiVal*weight; // } // if (sour != 0.) pout() << srcVoF << endl; // if (sour != 0.) pout() << " old phi " << lphi << endl; // lphi = a_lambdaFactor*lambdaWeight*sour + a_one*lphi; lphi += a_lambdaFactor*lambdaWeight*sour; } CH_STOP(t3); } void EBStencil::applyInhomDomBC(EBCellFAB& a_lofphi, const EBCellFAB& a_phi, const Real a_factor) const { CH_assert(a_lofphi.getSingleValuedFAB().box() == m_lphBox); CH_assert(a_phi.getSingleValuedFAB().box() == m_phiBox); const Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(0); Real* singleValuedPtrLph = a_lofphi.getSingleValuedFAB().dataPtr(0); const Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(0); Real* multiValuedPtrLph = a_lofphi.getMultiValuedFAB().dataPtr(0); for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { //debugging hook //const VolIndex& srcVoF = m_srcVoFs[isrc]; //const ebstencil_t& ebstencil = m_ebstencil[isrc]; Real* lphiPtr = NULL; const Real* sourPtr = NULL; if (m_destTerms[isrc].multiValued) { lphiPtr = multiValuedPtrLph + m_destTerms[isrc].offset; sourPtr = multiValuedPtrPhi + m_sourTerms[isrc].offset; } else { lphiPtr = singleValuedPtrLph + m_destTerms[isrc].offset; sourPtr = singleValuedPtrPhi + m_sourTerms[isrc].offset; } Real& lphi = *lphiPtr; const Real& sour = *sourPtr; lphi += a_factor*sour; } } void EBStencil::relax(EBCellFAB& a_phi, const EBCellFAB& a_rhs, const BaseIVFAB<Real>& a_alphaWeight, const BaseIVFAB<Real>& a_betaWeight, Real a_alpha, Real a_beta, Real a_safety) const { if (!m_doRelaxOpt) { MayDay::Error("ebstencil::relax this ebstencil was not configured to deal with baseivfab alpha and beta"); } CH_TIMERS("EBStencil::relax"); CH_TIMER("relax_loop_overvofs", t3); CH_TIMER("relax_header", t4); CH_START(t4); CH_assert(a_rhs.getSingleValuedFAB().box() == m_lphBox); CH_assert(a_phi.getSingleValuedFAB().box() == m_phiBox); Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(0); const Real* singleValuedPtrLph = a_rhs.getSingleValuedFAB().dataPtr(0); Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(0); const Real* multiValuedPtrLph = a_rhs.getMultiValuedFAB().dataPtr(0); const Real* alphaWeightPtr = a_alphaWeight.dataPtr(0); const Real* betaWeightPtr = a_betaWeight.dataPtr(0); CH_STOP(t4); CH_START(t3); for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { //debugging hook //const VolIndex& srcVoF = m_srcVoFs[isrc]; const ebstencil_t& ebstencil = m_ebstencil[isrc]; const Real* rhsPtr = NULL; Real* sourPtr = NULL; //alpha and beta get the same offset int alphaOffset = m_alphaBeta[isrc]; const Real& alphaWeight = *(alphaWeightPtr + alphaOffset); const Real& betaWeight = *( betaWeightPtr + alphaOffset); if (m_destTerms[isrc].multiValued) { rhsPtr = multiValuedPtrLph + m_destTerms[isrc].offset; sourPtr = multiValuedPtrPhi + m_sourTerms[isrc].offset; } else { rhsPtr = singleValuedPtrLph + m_destTerms[isrc].offset; sourPtr = singleValuedPtrPhi + m_sourTerms[isrc].offset; } Real& phi = *sourPtr; const Real& rhs = *rhsPtr; Real denom = a_alpha*alphaWeight + a_beta*betaWeight; Real lambda = 0; if (Abs(denom) > 1.0e-12) lambda = a_safety/(denom); Real lphi = a_alpha*alphaWeight*phi; //single-valued for (int isingle = 0; isingle < ebstencil.single.size(); isingle++) { const int & offset = ebstencil.single[isingle].offset; const Real& phiVal = *(singleValuedPtrPhi + offset); const Real& weight = ebstencil.single[isingle].weight; lphi += phiVal*weight*a_beta; } //multi-valued for (int imulti = 0; imulti < ebstencil.multi.size(); imulti++) { const int & offset = ebstencil.multi[imulti].offset; const Real& phiVal = *(multiValuedPtrPhi + offset); const Real& weight = ebstencil.multi[imulti].weight; lphi += phiVal*weight*a_beta; } phi = phi + lambda * (rhs - lphi); } CH_STOP(t3); } void EBStencil::relaxClone(EBCellFAB& a_phi, const EBCellFAB& a_phiOld, const EBCellFAB& a_rhs, const BaseIVFAB<Real>& a_alphaWeight, const BaseIVFAB<Real>& a_betaWeight, Real a_alpha, Real a_beta, Real a_safety) const { if (!m_doRelaxOpt) { MayDay::Error("ebstencil::relax this ebstencil was not configured to deal with baseivfab alpha and beta"); } CH_TIMERS("EBStencil::relaxClone"); CH_TIMER("relaxClone_loop_overvofs", t3); CH_TIMER("relaxClone_header", t4); CH_START(t4); CH_assert(a_rhs.getSingleValuedFAB().box() == m_lphBox); CH_assert(a_phi.getSingleValuedFAB().box() == m_phiBox); CH_assert(a_phiOld.getSingleValuedFAB().box() == m_phiBox); Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(0); const Real* singleValuedPtrPhiOld = a_phiOld.getSingleValuedFAB().dataPtr(0); const Real* singleValuedPtrLph = a_rhs.getSingleValuedFAB().dataPtr(0); Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(0); const Real* multiValuedPtrPhiOld = a_phiOld.getMultiValuedFAB().dataPtr(0); const Real* multiValuedPtrLph = a_rhs.getMultiValuedFAB().dataPtr(0); const Real* alphaWeightPtr = a_alphaWeight.dataPtr(0); const Real* betaWeightPtr = a_betaWeight.dataPtr(0); CH_STOP(t4); CH_START(t3); for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { //debugging hook //const VolIndex& srcVoF = m_srcVoFs[isrc]; const ebstencil_t& ebstencil = m_ebstencil[isrc]; const Real* rhsPtr = NULL; Real* sourPtr = NULL; const Real* sourOldPtr = NULL; //alpha and beta get the same offset int alphaOffset = m_alphaBeta[isrc]; const Real& alphaWeight = *(alphaWeightPtr + alphaOffset); const Real& betaWeight = *( betaWeightPtr + alphaOffset); if (m_destTerms[isrc].multiValued) { rhsPtr = multiValuedPtrLph + m_destTerms[isrc].offset; sourPtr = multiValuedPtrPhi + m_sourTerms[isrc].offset; sourOldPtr = multiValuedPtrPhiOld + m_sourTerms[isrc].offset; } else { rhsPtr = singleValuedPtrLph + m_destTerms[isrc].offset; sourPtr = singleValuedPtrPhi + m_sourTerms[isrc].offset; sourOldPtr = singleValuedPtrPhiOld + m_sourTerms[isrc].offset; } Real& phi = *sourPtr; const Real& phiOld = *sourOldPtr; const Real& rhs = *rhsPtr; Real denom = a_alpha*alphaWeight + a_beta*betaWeight; Real lambda = 0; if (Abs(denom) > 1.0e-12) lambda = a_safety/(denom); Real lphi = lambda*a_alpha*alphaWeight*phiOld; //single-valued for (int isingle = 0; isingle < ebstencil.single.size(); isingle++) { const int & offset = ebstencil.single[isingle].offset; const Real& phiVal = *(singleValuedPtrPhiOld + offset); const Real& weight = ebstencil.single[isingle].weight; lphi += lambda*phiVal*weight*a_beta; } //multi-valued for (int imulti = 0; imulti < ebstencil.multi.size(); imulti++) { const int & offset = ebstencil.multi[imulti].offset; const Real& phiVal = *(multiValuedPtrPhiOld + offset); const Real& weight = ebstencil.multi[imulti].weight; lphi += lambda*phiVal*weight*a_beta; } //lphi already has lambda multiplied in phi = phiOld + lambda*rhs - lphi; } CH_STOP(t3); } /**************/ /**************/ void EBStencil::computeOffsets(const Vector<VolIndex>& a_srcVofs, const BaseIVFAB<VoFStencil>& a_vofStencil) { CH_assert((SpaceDim == 2) || (SpaceDim == 3)); Box boxPhi = grow(m_box, m_ghostVectPhi); Box boxLph = grow(m_box, m_ghostVectLph); m_lphBox = boxLph; m_phiBox = boxPhi; const IntVectSet& ivsPhi = m_ebisBox.getMultiCells(boxPhi); const IntVectSet& ivsLph = m_ebisBox.getMultiCells(boxLph); const EBGraph& ebgraph = m_ebisBox.getEBGraph(); BaseIVFAB<Real> baseivfabPhi(ivsPhi, ebgraph, m_nComp); BaseIVFAB<Real> baseivfabLph(ivsLph, ebgraph, m_nComp); if (m_doRelaxOpt) { m_alphaBeta.resize(a_srcVofs.size()); IntVectSet ivsIrr = m_ebisBox.getIrregIVS(m_box); if (m_useInputSets) { ivsIrr = m_setIrreg; } BaseIVFAB<Real> baseivfabIrr(ivsIrr, ebgraph, 1); for (int isrc = 0; isrc < a_srcVofs.size(); isrc++) { const VolIndex& srcVof = a_srcVofs[isrc]; m_alphaBeta[isrc] = baseivfabIrr.getIndex(srcVof, 0) - baseivfabIrr.dataPtr(0); } } else { m_alphaBeta.resize(0); } const IntVect& smallendPhi = boxPhi.smallEnd(); const IntVect& smallendLph = boxLph.smallEnd(); IntVect ncellsPhi = boxPhi.size(); IntVect ncellsLph = boxLph.size(); m_ebstencil.resize(a_srcVofs.size()); m_destTerms.resize(a_srcVofs.size()); m_sourTerms.resize(a_srcVofs.size()); m_cacheLph.resize(a_srcVofs.size()); m_cachePhi.resize(a_srcVofs.size()); //debugging hook //m_srcVoFs = a_srcVofs; for (int isrc = 0; isrc < a_srcVofs.size(); isrc++) { const VolIndex& srcVof = a_srcVofs[isrc]; if (m_ebisBox.numVoFs(srcVof.gridIndex()) > 1) {//multi-valued (the dataPtr(0) is correct--that is where we start from) m_destTerms[isrc].offset = baseivfabLph.getIndex(srcVof, m_destVar) - baseivfabLph.dataPtr(0); m_destTerms[isrc].multiValued = true; m_sourTerms[isrc].offset = baseivfabPhi.getIndex(srcVof, m_destVar) - baseivfabPhi.dataPtr(0); m_sourTerms[isrc].multiValued = true; } else {//single-valued IntVect ivLph = srcVof.gridIndex() - smallendLph; IntVect ivPhi = srcVof.gridIndex() - smallendPhi; m_destTerms[isrc].offset = ivLph[0] + ivLph[1]*ncellsLph[0] ; m_sourTerms[isrc].offset = ivPhi[0] + ivPhi[1]*ncellsPhi[0] ; #if CH_SPACEDIM==3 m_destTerms[isrc].offset += ivLph[2]*ncellsLph[0]*ncellsLph[1]; m_sourTerms[isrc].offset += ivPhi[2]*ncellsPhi[0]*ncellsPhi[1]; #endif //add in term due to variable number #if CH_SPACEDIM==2 m_destTerms[isrc].offset += m_destVar*ncellsLph[0]*ncellsLph[1]; m_sourTerms[isrc].offset += m_destVar*ncellsPhi[0]*ncellsPhi[1]; #elif CH_SPACEDIM==3 m_destTerms[isrc].offset += m_destVar*ncellsLph[0]*ncellsLph[1]*ncellsLph[2]; m_sourTerms[isrc].offset += m_destVar*ncellsPhi[0]*ncellsPhi[1]*ncellsPhi[2]; #else bogus_spacedim(); #endif m_destTerms[isrc].multiValued = false; } const VoFStencil& sten = a_vofStencil(srcVof, 0); for (int isten = 0; isten < sten.size(); isten++) { const VolIndex stencilVof = sten.vof(isten); int srcVar = sten.variable(isten); stencilTerm stenEntry; stenEntry.weight = sten.weight(isten); //debugging hook //stenEntry.vof = stencilVof; if (m_ebisBox.numVoFs(stencilVof.gridIndex()) > 1) {//multi-valued(the dataPtr(0) is correct--that is where we start from) stenEntry.offset = baseivfabPhi.getIndex(stencilVof, srcVar) - baseivfabPhi.dataPtr(0); m_ebstencil[isrc].multi.push_back(stenEntry); } else {//single-valued IntVect ivPhi = stencilVof.gridIndex() - smallendPhi; stenEntry.offset = ivPhi[0] + ivPhi[1]*ncellsPhi[0] ; #if CH_SPACEDIM==3 stenEntry.offset += ivPhi[2]*ncellsPhi[0]*ncellsPhi[1]; #endif //add in term due to variable number #if CH_SPACEDIM==2 stenEntry.offset += srcVar*ncellsPhi[0]*ncellsPhi[1]; #elif CH_SPACEDIM==3 stenEntry.offset += srcVar*ncellsPhi[0]*ncellsPhi[1]*ncellsPhi[2]; #else bogus_spacedim(); #endif m_ebstencil[isrc].single.push_back(stenEntry); } } } } /**************/ /**************/ void EBStencil::cachePhi(const EBCellFAB& a_phi, int a_ivar) const { // CH_assert(m_cacheLph.size() == m_ebstencil.size()); CH_assert(a_phi.getSingleValuedFAB().box() == m_phiBox); const Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(a_ivar); const Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(a_ivar); for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { //debugging hook //const VolIndex& srcVoF = m_srcVoFs[isrc]; if (m_sourTerms[isrc].multiValued) { m_cachePhi[isrc] = *(multiValuedPtrPhi + m_sourTerms[isrc].offset); } else { m_cachePhi[isrc] = *(singleValuedPtrPhi + m_sourTerms[isrc].offset); } } } void EBStencil::cache(const EBCellFAB& a_lph, int a_ivar) const { // CH_assert(m_cacheLph.size() == m_ebstencil.size()); CH_assert(a_lph.getSingleValuedFAB().box() == m_lphBox); const Real* singleValuedPtrLph = a_lph.getSingleValuedFAB().dataPtr(a_ivar); const Real* multiValuedPtrLph = a_lph.getMultiValuedFAB().dataPtr(a_ivar); for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { if (m_destTerms[isrc].multiValued) { m_cacheLph[isrc] = *(multiValuedPtrLph + m_destTerms[isrc].offset); } else { m_cacheLph[isrc] = *(singleValuedPtrLph + m_destTerms[isrc].offset); } } } /**************/ /**************/ void EBStencil::uncachePhi(EBCellFAB& a_phi, int a_ivar) const { CH_assert(a_phi.getSingleValuedFAB().box() == m_phiBox); Real* singleValuedPtrPhi = a_phi.getSingleValuedFAB().dataPtr(a_ivar); Real* multiValuedPtrPhi = a_phi.getMultiValuedFAB().dataPtr(a_ivar); Real* phiPtr = NULL; for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { if (m_sourTerms[isrc].multiValued) { phiPtr = multiValuedPtrPhi + m_sourTerms[isrc].offset; } else { phiPtr = singleValuedPtrPhi + m_sourTerms[isrc].offset; } *phiPtr = m_cachePhi[isrc]; } } /**************/ void EBStencil::uncache(EBCellFAB& a_lph, int a_ivar) const { CH_assert(a_lph.getSingleValuedFAB().box() == m_lphBox); Real* singleValuedPtrLph = a_lph.getSingleValuedFAB().dataPtr(a_ivar); Real* multiValuedPtrLph = a_lph.getMultiValuedFAB().dataPtr(a_ivar); Real* lphiPtr = NULL; for (int isrc = 0; isrc < m_ebstencil.size(); isrc++) { if (m_destTerms[isrc].multiValued) { lphiPtr = multiValuedPtrLph + m_destTerms[isrc].offset; } else { lphiPtr = singleValuedPtrLph + m_destTerms[isrc].offset; } *lphiPtr = m_cacheLph[isrc]; } } /**************/ /**************/ EBStencil::~EBStencil() { } /**************/ #include "NamespaceFooter.H"
// // CollisionInfoTests.cpp // tests/physics/src // // Created by Andrew Meadows on 2/21/2014. // Copyright 2014 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include <iostream> #include <glm/glm.hpp> #include <glm/gtx/quaternion.hpp> #include <CollisionInfo.h> #include <SharedUtil.h> #include <StreamUtils.h> #include "CollisionInfoTests.h" /* static glm::vec3 xAxis(1.f, 0.f, 0.f); static glm::vec3 xZxis(0.f, 1.f, 0.f); static glm::vec3 xYxis(0.f, 0.f, 1.f); void CollisionInfoTests::rotateThenTranslate() { CollisionInfo collision; collision._penetration = xAxis; collision._contactPoint = yAxis; collision._addedVelocity = xAxis + yAxis + zAxis; glm::quat rotation = glm::angleAxis(PI_OVER_TWO, zAxis); float distance = 3.f; glm::vec3 translation = distance * yAxis; collision.rotateThenTranslate(rotation, translation); float error = glm::distance(collision._penetration, yAxis); if (error > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: collision._penetration = " << collision._penetration << " but we expected " << yAxis << std::endl; } glm::vec3 expectedContactPoint = -xAxis + translation; error = glm::distance(collision._contactPoint, expectedContactPoint); if (error > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: collision._contactPoint = " << collision._contactPoint << " but we expected " << expectedContactPoint << std::endl; } glm::vec3 expectedAddedVelocity = yAxis - xAxis + zAxis; error = glm::distance(collision._addedVelocity, expectedAddedVelocity); if (error > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: collision._addedVelocity = " << collision._contactPoint << " but we expected " << expectedAddedVelocity << std::endl; } } void CollisionInfoTests::translateThenRotate() { CollisionInfo collision; collision._penetration = xAxis; collision._contactPoint = yAxis; collision._addedVelocity = xAxis + yAxis + zAxis; glm::quat rotation = glm::angleAxis( -PI_OVER_TWO, zAxis); float distance = 3.f; glm::vec3 translation = distance * yAxis; collision.translateThenRotate(translation, rotation); float error = glm::distance(collision._penetration, -yAxis); if (error > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: collision._penetration = " << collision._penetration << " but we expected " << -yAxis << std::endl; } glm::vec3 expectedContactPoint = (1.f + distance) * xAxis; error = glm::distance(collision._contactPoint, expectedContactPoint); if (error > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: collision._contactPoint = " << collision._contactPoint << " but we expected " << expectedContactPoint << std::endl; } glm::vec3 expectedAddedVelocity = - yAxis + xAxis + zAxis; error = glm::distance(collision._addedVelocity, expectedAddedVelocity); if (error > EPSILON) { std::cout << __FILE__ << ":" << __LINE__ << " ERROR: collision._addedVelocity = " << collision._contactPoint << " but we expected " << expectedAddedVelocity << std::endl; } } */ void CollisionInfoTests::runAllTests() { // CollisionInfoTests::rotateThenTranslate(); // CollisionInfoTests::translateThenRotate(); }
;******************************************************************************* ;ulldvrm.asm - unsigned long divide and remainder routine ; ; Copyright (c) Microsoft Corporation. All rights reserved. ; ;Purpose: ; defines the unsigned long divide and remainder routine ; __aulldvrm ; ;Revision History: ; 10-06-98 SMK Initial version. ; ;******************************************************************************* include hal.inc ;*** ;ulldvrm - unsigned long divide and remainder ; ;Purpose: ; Does a unsigned long divide and remainder of the arguments. Arguments ; are not changed. ; ;Entry: ; Arguments are passed on the stack: ; 1st pushed: divisor (QWORD) ; 2nd pushed: dividend (QWORD) ; ;Exit: ; EDX:EAX contains the quotient (dividend/divisor) ; EBX:ECX contains the remainder (divided % divisor) ; NOTE: this routine removes the parameters from the stack. ; ;Uses: ; ECX ; ;Exceptions: ; ;******************************************************************************* __aulldvrm PROC NEAR push esi ; Set up the local stack and save the index registers. When this is done ; the stack frame will look as follows (assuming that the expression a/b will ; generate a call to aulldvrm(a, b)): ; ; ----------------- ; | | ; |---------------| ; | | ; |--divisor (b)--| ; | | ; |---------------| ; | | ; |--dividend (a)-| ; | | ; |---------------| ; | return addr** | ; |---------------| ; ESP---->| ESI | ; ----------------- ; DVND equ [esp + 8] ; stack address of dividend (a) DVSR equ [esp + 16] ; stack address of divisor (b) ; ; Now do the divide. First look to see if the divisor is less than 4194304K. ; If so, then we can use a simple algorithm with word divides, otherwise ; things get a little more complex. ; mov eax,HIWORD(DVSR) ; check to see if divisor < 4194304K or eax,eax jnz short L1 ; nope, gotta do this the hard way mov ecx,LOWORD(DVSR) ; load divisor mov eax,HIWORD(DVND) ; load high word of dividend xor edx,edx div ecx ; get high order bits of quotient mov ebx,eax ; save high bits of quotient mov eax,LOWORD(DVND) ; edx:eax <- remainder:lo word of dividend div ecx ; get low order bits of quotient mov esi,eax ; ebx:esi <- quotient ; ; Now we need to do a multiply so that we can compute the remainder. ; mov eax,ebx ; set up high word of quotient mul dword ptr LOWORD(DVSR) ; HIWORD(QUOT) * DVSR mov ecx,eax ; save the result in ecx mov eax,esi ; set up low word of quotient mul dword ptr LOWORD(DVSR) ; LOWORD(QUOT) * DVSR add edx,ecx ; EDX:EAX = QUOT * DVSR jmp short L2 ; complete remainder calculation ; ; Here we do it the hard way. Remember, eax contains DVSRHI ; L1: mov ecx,eax ; ecx:ebx <- divisor mov ebx,LOWORD(DVSR) mov edx,HIWORD(DVND) ; edx:eax <- dividend mov eax,LOWORD(DVND) L3: shr ecx,1 ; shift divisor right one bit; hi bit <- 0 rcr ebx,1 shr edx,1 ; shift dividend right one bit; hi bit <- 0 rcr eax,1 or ecx,ecx jnz short L3 ; loop until divisor < 4194304K div ebx ; now divide, ignore remainder mov esi,eax ; save quotient ; ; We may be off by one, so to check, we will multiply the quotient ; by the divisor and check the result against the orignal dividend ; Note that we must also check for overflow, which can occur if the ; dividend is close to 2**64 and the quotient is off by 1. ; mul dword ptr HIWORD(DVSR) ; QUOT * HIWORD(DVSR) mov ecx,eax mov eax,LOWORD(DVSR) mul esi ; QUOT * LOWORD(DVSR) add edx,ecx ; EDX:EAX = QUOT * DVSR jc short L4 ; carry means Quotient is off by 1 ; ; do long compare here between original dividend and the result of the ; multiply in edx:eax. If original is larger or equal, we are ok, otherwise ; subtract one (1) from the quotient. ; cmp edx,HIWORD(DVND) ; compare hi words of result and original ja short L4 ; if result > original, do subtract jb short L5 ; if result < original, we are ok cmp eax,LOWORD(DVND) ; hi words are equal, compare lo words jbe short L5 ; if less or equal we are ok, else subtract L4: dec esi ; subtract 1 from quotient sub eax,LOWORD(DVSR) ; subtract divisor from result sbb edx,HIWORD(DVSR) L5: xor ebx,ebx ; ebx:esi <- quotient L2: ; ; Calculate remainder by subtracting the result from the original dividend. ; Since the result is already in a register, we will do the subtract in the ; opposite direction and negate the result. ; sub eax,LOWORD(DVND) ; subtract dividend from result sbb edx,HIWORD(DVND) neg edx ; otherwise, negate the result neg eax sbb edx,0 ; ; Now we need to get the quotient into edx:eax and the remainder into ebx:ecx. ; mov ecx,edx mov edx,ebx mov ebx,ecx mov ecx,eax mov eax,esi ; ; Just the cleanup left to do. edx:eax contains the quotient. ; Restore the saved registers and return. ; pop esi ret 16 __aulldvrm ENDP end
extern long_mode_start global start global special_pd_table section .text bits 32 start: mov esp, stack_top push dword 0 push ebx call check_multiboot call check_cpuid call check_long_mode call set_up_page_tables call enable_paging lgdt [gdt64.pointer] jmp gdt64.code:long_mode_start mov al, "3" jmp error error: mov dword [0xb8000], 0x4f524f45 mov dword [0xb8004], 0x4f3a4f52 mov dword [0xb8008], 0x4f204f20 mov byte [0xb800a], al .loop: hlt jmp .loop check_multiboot: cmp eax, 0x36d76289 jne .no_multiboot ret .no_multiboot: mov al, "0" jmp error check_cpuid: pushfd pop eax ; Save EAX to ECX mov ecx, eax ; Flip the ID bit xor eax, 1 << 21 push eax popfd ; Copy FLAGS back to EAX (with the flipped bit if CPUID is supported) pushfd pop eax ; Restore FLAGS from the old version stored in ECX (i.e. flipping the ID bit ; back if it was ever flipped). push ecx popfd xor eax, ecx jz .no_cpuid ret .no_cpuid: mov al, "1" jmp error check_long_mode: mov eax, 0x80000000 cpuid cmp eax, 0x80000001 jb .no_long_mode mov eax, 0x80000001 cpuid test edx, 1 << 29 jz .no_long_mode ret .no_long_mode: mov al, "2" jmp error set_up_page_tables: mov eax, pdp0_table or eax, 3 mov [pml4_table], eax mov eax, pdp511_table or eax, 3 mov [pml4_table + (511*8)], eax mov dword [pdp0_table], 0x83 mov dword [pdp0_table+8], 0x40000083 mov dword [pdp0_table+16], 0x80000083 mov dword [pdp0_table+24], 0xC0000083 ; special page table mov eax, special_pd_table or eax, 3 mov [pdp511_table + (510*8)], eax ret ; mov eax, pdp_table ; or eax, 0b11 ; mov [pml4_table], eax ; ; mov eax, pd_table ; or eax, 0b11 ; mov [pdp_table], eax ; ; mov ecx, 0 ; .map_pd_table: ; mov eax, 0x20000 ; ; eax *= ecx ; mul ecx ; or eax, 0x83 ; mov [pd_table + ecx * 8], eax ; ; inc ecx ; cmp ecx, 512 ; jne .map_pd_table ; ; ret enable_paging: ; load P4 to cr3 register (cpu uses this to access the P4 table) mov eax, pml4_table mov cr3, eax ; enable PAE-flag in cr4 (Physical Address Extension) mov eax, cr4 or eax, 1 << 5 mov cr4, eax ; set the long mode bit in the EFER MSR (model specific register) mov ecx, 0xC0000080 rdmsr or eax, 1 << 8 wrmsr ; enable paging in the cr0 register mov eax, cr0 or eax, 1 << 31 mov cr0, eax ret section .bss align 4096 pml4_table: ; Page-Map Level-4 Table resb 4096 pdp0_table: ; Page-Directory Pointer Table resb 4096 pdp511_table: ; Page-Directory Pointer Table resb 4096 special_pd_table: ; Page-Directory Table resb 4096 stack_bottom: resb 4*4096 stack_top: section .rodata gdt64: dq 0 .code equ $ - gdt64 dq (1<<43) | (1<<44) | (1<<47) | (1<<53) ; code segment .pointer: dw $ - gdt64 - 1 dq gdt64
; copy list of pointers include win1_mac_oli section utility xdef ut_cpylst ;+++ ; copy list of pointers ; ; Entry Exit ; a0 from list preserved ; a1 to list preserved ;--- ut_cpylst subr a0/a1 lp move.l (a0)+,(a1)+ bne.s lp subend end
; A079273: Octo numbers (a polygonal sequence): a(n) = 5*n^2 - 6*n + 2 = (n-1)^2 + (2*n-1)^2. ; 1,10,29,58,97,146,205,274,353,442,541,650,769,898,1037,1186,1345,1514,1693,1882,2081,2290,2509,2738,2977,3226,3485,3754,4033,4322,4621,4930,5249,5578,5917,6266,6625,6994,7373,7762,8161,8570,8989,9418,9857,10306,10765,11234,11713,12202,12701,13210,13729,14258,14797,15346,15905,16474,17053,17642,18241,18850,19469,20098,20737,21386,22045,22714,23393,24082,24781,25490,26209,26938,27677,28426,29185,29954,30733,31522,32321,33130,33949,34778,35617,36466,37325,38194,39073,39962,40861,41770,42689,43618 mov $1,5 mul $1,$0 add $1,4 mul $1,$0 add $1,1 mov $0,$1
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 004D2C move.l D0, (A4)+ 004D2E dbra D1, $4d1e 010332 move.b #$32, ($4ea,A5) [base+4E8] 010338 clr.b ($4eb,A5) [base+4EA] 0103B2 tst.b ($4ea,A5) 0103B6 beq $103c0 [base+4EA] 0103BA subq.b #1, ($4ea,A5) 0103BE rts [base+4EA] 0103F2 move.b #$32, ($4ea,A5) [base+4E9] 0103F8 rts [base+4EA] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
db 0 ; 293 DEX NO db 64, 51, 23, 28, 51, 23 ; hp atk def spd sat sdf db NORMAL, NORMAL ; type db 190 ; catch rate db 68 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/hoenn/whismur/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_SLOW ; growth rate dn EGG_MONSTER, EGG_GROUND ; egg groups ; tm/hm learnset tmhm ; end
; Input: ; x0: [bp + 12] -> [bp + rect_x0] ; y0: [bp + 10] -> [bp + rect_y0] ; w: [bp + 8] -> [bp + rect_w] ; h: [bp + 6] -> [bp + rect_h] ; px: [bp + 4] -> [bp + px_set] %assign rect_x0 12 %assign rect_y0 10 %assign rect_w 8 %assign rect_h 6 %assign px_set 4 %assign rect_row_end 2 %assign rect_col_end 4 %include "graphics_rectangle_test_dimensions.asm" %include "graphics_rectangle_test_boundaries.asm" Graphics_Rectangle_Algorithm: push bp mov bp, sp sub sp, 4 push cx push dx push si ;____________________ ; Setup call Graphics_Rectangle_Test_Dimensions mov si, word [bp + rect_x0] ; Column end add si, word [bp + rect_w] mov [bp - rect_row_end], si mov si, word [bp + rect_y0] ; Row end add si, word [bp + rect_h] mov [bp - rect_col_end], si call Graphics_Rectangle_Test_Boundaries mov cx, word [bp + rect_x0] ; Column start mov dx, word [bp + rect_y0] ; Row start mov ax, word [bp + px_set] ; AH: 0Ch, AL: colour jmp Draw_Rectangle_Inner ; Skip the first inc. Draw_Rectangle_Repeat: inc cx Draw_Rectangle_Inner: int 10h cmp cx, word [bp - rect_row_end]; if (x != w) continue; jne Draw_Rectangle_Repeat mov cx, [bp + rect_x0] ; Get back to the start of the line. inc dx cmp dx, word [bp - rect_col_end]; if (y = h) break; jle Draw_Rectangle_Inner pop si pop dx pop cx leave ret 10
; ; Copyright (C) 2021 by Intel Corporation ; ; Permission to use, copy, modify, and/or distribute this software for any ; purpose with or without fee is hereby granted. ; ; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH ; REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY ; AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, ; INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ; LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR ; OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR ; PERFORMANCE OF THIS SOFTWARE. ; ; .globl rsqrtps_newt_sse ; void rsqrtps_newt_sse(float *in, float *out, size_t len) ; On entry: ; rcx = in ; rdx = out ; r8 = len .data ALIGN 16 minus_half REAL4 -0.5, -0.5, -0.5, -0.5 three REAL4 3.0, 3.0, 3.0, 3.0 .code rsqrtps_newt_sse PROC public push rbx mov rax, rcx mov rbx, rdx mov rcx, r8 shl rcx, 2 ; rcx is size of inputs in bytes xor r8, r8 movups xmm3, xmmword ptr three movups xmm4, xmmword ptr minus_half loop1: movups xmm5, [rax+r8] rsqrtps xmm0, xmm5 movaps xmm2, xmm0 mulps xmm0, xmm0 mulps xmm0, xmm5 subps xmm0, xmm3 mulps xmm0, xmm2 mulps xmm0, xmm4 movups [rbx+r8], xmm0 add r8, 16 cmp r8, rcx jl loop1 pop rbx ret rsqrtps_newt_sse ENDP end
// Copyright 2016 Jonathan Buchanan. // This file is part of Sunglasses, which is licensed under the MIT License. // See LICENSE.md for details. #include <sunglasses/Extern/Resource.h> namespace sunglasses { Resource::~Resource() { } } // namespace
;; ==++== ;; ;; Copyright (c) Microsoft Corporation. All rights reserved. ;; ;; ==--== #include "kxarm.h" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; STUBS & DATA SECTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; THUNK_CODESIZE equ 0x10 ;; 4-byte mov, 2-byte add, 4-byte str, 4-byte ldr, 2-byte branch THUNK_DATASIZE equ 0x08 ;; 2 dwords THUNK_POOL_NUM_THUNKS_PER_PAGE equ 0xFA ;; 250 thunks per page PAGE_SIZE equ 0x1000 ;; 4K POINTER_SIZE equ 0x04 MACRO NAMED_READONLY_DATA_SECTION $name, $areaAlias AREA $areaAlias,DATA,READONLY RO$name % 4 MEND MACRO NAMED_READWRITE_DATA_SECTION $name, $areaAlias AREA $areaAlias,DATA RW$name % 4 MEND MACRO LOAD_DATA_ADDRESS $groupIndex, $index ;; set r12 to begining of data page : r12 <- pc - (THUNK_CODESIZE * current thunk's index - sizeof(mov+add instructions)) + PAGE_SIZE ;; fix offset of the data : r12 <- r12 + (THUNK_DATASIZE * current thunk's index) mov.w r12, PAGE_SIZE + ($groupIndex * THUNK_DATASIZE * 10 + THUNK_DATASIZE * $index) - (8 + $groupIndex * THUNK_CODESIZE * 10 + THUNK_CODESIZE * $index) add.n r12, r12, pc MEND MACRO JUMP_TO_COMMON $groupIndex, $index ;; start : r12 points to the current thunks first data cell in the data page ;; put r12 into the red zone : r12 isn't changed ;; set r12 to begining of data page : r12 <- r12 - (THUNK_DATASIZE * current thunk's index) ;; fix offset to point to last DWROD in page : r12 <- r11 + PAGE_SIZE - POINTER_SIZE ;; jump to the location pointed at by the last dword in the data page str.w r12, [sp, #-4] ldr.w r12, [r12, #(PAGE_SIZE - POINTER_SIZE - ($groupIndex * THUNK_DATASIZE * 10 + THUNK_DATASIZE * $index))] bx.n r12 MEND MACRO TenThunks $groupIndex ;; Each thunk will load the address of its corresponding data (from the page that immediately follows) ;; and call a common stub. The address of the common stub is setup by the caller (last dword ;; in the thunks data section) depending on the 'kind' of thunks needed (interop, fat function pointers, etc...) ;; Each data block used by a thunk consists of two dword values: ;; - Context: some value given to the thunk as context (passed in eax). Example for fat-fptrs: context = generic dictionary ;; - Target : target code that the thunk eventually jumps to. LOAD_DATA_ADDRESS $groupIndex,0 JUMP_TO_COMMON $groupIndex,0 LOAD_DATA_ADDRESS $groupIndex,1 JUMP_TO_COMMON $groupIndex,1 LOAD_DATA_ADDRESS $groupIndex,2 JUMP_TO_COMMON $groupIndex,2 LOAD_DATA_ADDRESS $groupIndex,3 JUMP_TO_COMMON $groupIndex,3 LOAD_DATA_ADDRESS $groupIndex,4 JUMP_TO_COMMON $groupIndex,4 LOAD_DATA_ADDRESS $groupIndex,5 JUMP_TO_COMMON $groupIndex,5 LOAD_DATA_ADDRESS $groupIndex,6 JUMP_TO_COMMON $groupIndex,6 LOAD_DATA_ADDRESS $groupIndex,7 JUMP_TO_COMMON $groupIndex,7 LOAD_DATA_ADDRESS $groupIndex,8 JUMP_TO_COMMON $groupIndex,8 LOAD_DATA_ADDRESS $groupIndex,9 JUMP_TO_COMMON $groupIndex,9 MEND MACRO THUNKS_PAGE_BLOCK TenThunks 0 TenThunks 1 TenThunks 2 TenThunks 3 TenThunks 4 TenThunks 5 TenThunks 6 TenThunks 7 TenThunks 8 TenThunks 9 TenThunks 10 TenThunks 11 TenThunks 12 TenThunks 13 TenThunks 14 TenThunks 15 TenThunks 16 TenThunks 17 TenThunks 18 TenThunks 19 TenThunks 20 TenThunks 21 TenThunks 22 TenThunks 23 TenThunks 24 MEND ;; ;; The first thunks section should be 64K aligned because it can get ;; mapped multiple times in memory, and mapping works on allocation ;; granularity boundaries (we don't want to map more than what we need) ;; ;; The easiest way to do so is by having the thunks section at the ;; first 64K aligned virtual address in the binary. We provide a section ;; layout file to the linker to tell it how to layout the thunks sections ;; that we care about. (ndp\rh\src\runtime\DLLs\app\mrt100_app_sectionlayout.txt) ;; ;; The PE spec says images cannot have gaps between sections (other ;; than what is required by the section alignment value in the header), ;; therefore we need a couple of padding data sections (otherwise the ;; OS will not load the image). ;; NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment0, "|.pad0|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment1, "|.pad1|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment2, "|.pad2|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment3, "|.pad3|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment4, "|.pad4|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment5, "|.pad5|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment6, "|.pad6|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment7, "|.pad7|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment8, "|.pad8|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment9, "|.pad9|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment10, "|.pad10|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment11, "|.pad11|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment12, "|.pad12|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment13, "|.pad13|" NAMED_READONLY_DATA_SECTION PaddingFor64KAlignment14, "|.pad14|" ;; ;; Thunk Stubs ;; NOTE: Keep number of blocks in sync with macro/constant named 'NUM_THUNK_BLOCKS' in: ;; - ndp\FxCore\src\System.Private.CoreLib\System\Runtime\InteropServices\ThunkPool.cs ;; - ndp\rh\src\tools\rhbind\zapimage.h ;; LEAF_ENTRY ThunkPool, "|.tks0|" THUNKS_PAGE_BLOCK LEAF_END ThunkPool NAMED_READWRITE_DATA_SECTION ThunkData0, "|.tkd0|" LEAF_ENTRY ThunkPool1, "|.tks1|" THUNKS_PAGE_BLOCK LEAF_END ThunkPool1 NAMED_READWRITE_DATA_SECTION ThunkData1, "|.tkd1|" LEAF_ENTRY ThunkPool2, "|.tks2|" THUNKS_PAGE_BLOCK LEAF_END ThunkPool2 NAMED_READWRITE_DATA_SECTION ThunkData2, "|.tkd2|" LEAF_ENTRY ThunkPool3, "|.tks3|" THUNKS_PAGE_BLOCK LEAF_END ThunkPool3 NAMED_READWRITE_DATA_SECTION ThunkData3, "|.tkd3|" LEAF_ENTRY ThunkPool4, "|.tks4|" THUNKS_PAGE_BLOCK LEAF_END ThunkPool4 NAMED_READWRITE_DATA_SECTION ThunkData4, "|.tkd4|" LEAF_ENTRY ThunkPool5, "|.tks5|" THUNKS_PAGE_BLOCK LEAF_END ThunkPool5 NAMED_READWRITE_DATA_SECTION ThunkData5, "|.tkd5|" LEAF_ENTRY ThunkPool6, "|.tks6|" THUNKS_PAGE_BLOCK LEAF_END ThunkPool6 NAMED_READWRITE_DATA_SECTION ThunkData6, "|.tkd6|" LEAF_ENTRY ThunkPool7, "|.tks7|" THUNKS_PAGE_BLOCK LEAF_END ThunkPool7 NAMED_READWRITE_DATA_SECTION ThunkData7, "|.tkd7|" ;; ;; IntPtr RhpGetThunksBase() ;; LEAF_ENTRY RhpGetThunksBase ;; Return the address of the first thunk pool to the caller (this is really the base address) ldr r0, =ThunkPool sub r0, r0, #1 bx lr LEAF_END RhpGetThunksBase ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; General Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; int RhpGetNumThunksPerBlock() ;; LEAF_ENTRY RhpGetNumThunksPerBlock mov r0, THUNK_POOL_NUM_THUNKS_PER_PAGE bx lr LEAF_END RhpGetNumThunksPerBlock ;; ;; int RhpGetThunkSize() ;; LEAF_ENTRY RhpGetThunkSize mov r0, THUNK_CODESIZE bx lr LEAF_END RhpGetThunkSize ;; ;; int RhpGetNumThunkBlocksPerMapping() ;; LEAF_ENTRY RhpGetNumThunkBlocksPerMapping mov r0, 8 bx lr LEAF_END RhpGetNumThunkBlocksPerMapping ;; ;; IntPtr RhpGetNextThunkStubsBlockAddress(IntPtr currentThunkStubsBlockAddress) ;; LEAF_ENTRY RhpGetNextThunkStubsBlockAddress add r0, PAGE_SIZE * 2 bx lr LEAF_END RhpGetNextThunkStubsBlockAddress ;; ;; IntPtr RhpGetThunkDataBlockAddress(IntPtr thunkStubAddress) ;; LEAF_ENTRY RhpGetThunkDataBlockAddress mov r12, PAGE_SIZE - 1 bic r0, r0, r12 add r0, PAGE_SIZE bx lr LEAF_END RhpGetThunkDataBlockAddress ;; ;; IntPtr RhpGetThunkStubsBlockAddress(IntPtr thunkDataAddress) ;; LEAF_ENTRY RhpGetThunkStubsBlockAddress mov r12, PAGE_SIZE - 1 bic r0, r0, r12 sub r0, PAGE_SIZE bx lr LEAF_END RhpGetThunkStubsBlockAddress END
GLOBAL _syscaller section .text _syscaller: int 80h ret
.constant_pool .const 0 string [start] .const 1 string [constructor] .const 2 string [antes da chamada a x] .const 3 int [1] .const 4 string [io.writeln] .const 5 string [x] .const 6 string [depois da chamada a x] .const 7 string [no metodo x] .end .entity start .valid_context_when (always) .method constructor ldconst 2 --> [antes da chamada a x] ldconst 3 --> [1] lcall 4 --> [io.writeln] ldself mcall 5 --> [x] ldconst 6 --> [depois da chamada a x] ldconst 3 --> [1] lcall 4 --> [io.writeln] exit .end .method x ldconst 7 --> [no metodo x] ldconst 3 --> [1] lcall 4 --> [io.writeln] ret .end .end
; A168398: a(n) = 4 + 8*floor((n-1)/2). ; 4,4,12,12,20,20,28,28,36,36,44,44,52,52,60,60,68,68,76,76,84,84,92,92,100,100,108,108,116,116,124,124,132,132,140,140,148,148,156,156,164,164,172,172,180,180,188,188,196,196,204,204,212,212,220,220,228,228,236,236,244,244,252,252,260,260,268,268,276,276,284,284,292,292,300,300,308,308,316,316,324,324,332,332,340,340,348,348,356,356,364,364,372,372,380,380,388,388,396,396,404,404,412,412,420,420,428,428,436,436,444,444,452,452,460,460,468,468,476,476,484,484,492,492,500,500,508,508,516,516,524,524,532,532,540,540,548,548,556,556,564,564,572,572,580,580,588,588,596,596,604,604,612,612,620,620,628,628,636,636,644,644,652,652,660,660,668,668,676,676,684,684,692,692,700,700,708,708,716,716,724,724,732,732,740,740,748,748,756,756,764,764,772,772,780,780,788,788,796,796,804,804,812,812,820,820,828,828,836,836,844,844,852,852,860,860,868,868,876,876,884,884,892,892,900,900,908,908,916,916,924,924,932,932,940,940,948,948,956,956,964,964,972,972,980,980,988,988,996,996 mov $1,$0 div $1,2 mul $1,8 add $1,4
/// RawFile // @module lrf /* RawFile.cpp * * Copyright (C) 2016 Thermo Fisher Scientific * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. */ #include "RawFile.h" #include "comutil.h" namespace RawFile { static const struct luaL_Reg luaRawFile_l[] = { { "New", newRawFile }, { "GetRawFileMetaTable", getMetaTable }, { NULL, NULL } }; extern "C" THERMO int luaopen_LuaRawFile_core(lua_State* L) { Register(L); luaL_newlib(L, luaRawFile_l); lua_pushstring(L, Version); lua_setfield(L, -2, "Version"); return 1; } int __index(lua_State* L) { const char* key = luaL_checkstring(L, 2); // Get the metatable for this userdata lua_getmetatable(L, 1); // Attempt to get the field lua_getfield(L, -1, key); if (!lua_isnil(L, -1)) return 1; // Get the user value stored with this userdata lua_getuservalue(L, 1); if (lua_isnil(L, -1)) return 0; // Attempt to get the field lua_getfield(L, -1, key); if (!lua_isnil(L, -1)) return 1; return 0; } bool is_number(const std::string& s) { std::string::const_iterator it = s.begin(); while (it != s.end() && std::isdigit(*it) || *it == '.' ) ++it; return !s.empty() && it == s.end(); } static int ListToTable(lua_State* L, VARIANT* items, int size) { lua_createtable(L, size, 0); BSTR* pItems = NULL; SAFEARRAY FAR* itemsSA = items->parray; SafeArrayAccessData(itemsSA, (void**)(&pItems)); for (int i = 0; i < size; i++) { CStringA value = (CStringA)pItems[i]; std::string sValue((LPCTSTR)value); lua_pushstring(L, sValue.c_str()); lua_rawseti(L, -2, i + 1); } SafeArrayUnaccessData(itemsSA); SafeArrayDestroy(itemsSA); return 1; } static int MapToStack(lua_State* L, VARIANT* labels, VARIANT* values, int size) { lua_createtable(L, 0, size); BSTR* pLabels = NULL; BSTR* pValues = NULL; SAFEARRAY FAR* labelSA = labels->parray; SafeArrayAccessData(labelSA, (void**)(&pLabels)); SAFEARRAY FAR* valueSA = values->parray; SafeArrayAccessData(valueSA, (void**)(&pValues)); for (int i = 0; i < size; i++) { lua_pushstring(L, (CStringA)pLabels[i]); CStringA value = (CStringA)pValues[i]; std::string sValue((LPCTSTR)value); if (is_number(sValue)) { lua_pushnumber(L, std::stod(sValue)); } else { lua_pushstring(L, sValue.c_str()); } lua_settable(L, 3); } SafeArrayUnaccessData(labelSA); SafeArrayDestroy(labelSA); SafeArrayUnaccessData(valueSA); SafeArrayDestroy(valueSA); return 1; } static void VariantToStack(lua_State* L, VARIANT* value) { switch (value->vt) { case VT_BSTR: lua_pushstring(L, _bstr_t(value->bstrVal)); break; case VT_R4: lua_pushnumber(L, value->fltVal); break; case VT_R8: lua_pushnumber(L, value->dblVal); break; case VT_I4: lua_pushnumber(L, value->lVal); break; case VT_I2: lua_pushnumber(L, value->iVal); break; case VT_BOOL: lua_pushboolean(L, value->boolVal); break; case VT_UI1: lua_pushnumber(L, value->bVal); break; case VT_ERROR: lua_pushnumber(L, value->scode); case VT_EMPTY: case VT_NULL: lua_pushnil(L); break; default: luaL_error(L, "Unhandled VT type %d, tell Derek to support this. He'll know what to do :)", value->vt); break; } VariantClear(value); } /*** Create a new instance of the rawfile @function New @string filePath The path to the rawfile @treturn rawFile The Lua wrapped access to the rawfile */ int newRawFile(lua_State* L) { const char* filePath = luaL_checkstring(L, -1); // Create the user data, just the size of a pointer to the struct RawFile **rawFile = reinterpret_cast<RawFile**>(lua_newuserdata(L, sizeof(RawFile*))); // Allocate the actual memory *rawFile = new RawFile(filePath); // Get the initialization error if present int result = (*rawFile)->init; if (result != 0) { luaL_error(L, "Error creating rawfile instance from COM: %d", result); } // Set the metatable for the userdata (on top of the stack) to the rawfile metatable luaL_getmetatable(L, RawFileType); lua_setmetatable(L, -2); lua_newtable(L); lua_pushstring(L, (*rawFile)->FileName); lua_setfield(L, -2, "FilePath"); lua_setuservalue(L, -2); // return the userdata return 1; } /// a // @type rawFile int openRawFile(lua_State* L) { RawFile *rawFile = checkRawFile(L); HRESULT hr = rawFile->comRawFile->Open(rawFile->FileName); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } hr = rawFile->comRawFile->SetCurrentController(0, 1); // MS device, 1st device rawFile->IsOpen = true; // Handle read once properties long firstScanNumber = 0; long lastScanNumber = 0; rawFile->comRawFile->GetFirstSpectrumNumber(&firstScanNumber); rawFile->comRawFile->GetLastSpectrumNumber(&lastScanNumber); // Get the user value for this userdata lua_getuservalue(L, 1); // Push fields lua_pushnumber(L, firstScanNumber); lua_setfield(L, -2, "FirstSpectrumNumber"); lua_pushnumber(L, lastScanNumber); lua_setfield(L, -2, "LastSpectrumNumber"); lua_pushboolean(L, rawFile->IsOpen); lua_setfield(L, -2, "IsOpen"); lua_pushboolean(L, true); return 1; } int closeRawFile(lua_State* L) { RawFile *rawFile = checkRawFile(L); rawFile->comRawFile->Close(); rawFile->IsOpen = false; // Clear the user value table with a new one lua_newtable(L); lua_pushboolean(L, rawFile->IsOpen); lua_setfield(L, -2, "IsOpen"); lua_setuservalue(L, 1); return 0; } int rawFileToString(lua_State* L) { RawFile *rawFile = checkRawFile(L); lua_pushfstring(L, "RawFile: %s", rawFile->FileName); return 1; } int tuneData(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2) - 1; if (lua_gettop(L) == 3) { const char* key = luaL_checkstring(L, -1); VARIANT varValue; VariantInit(&varValue); HRESULT hr = rawFile->comRawFile->GetTuneDataValue(spectrumNumber, _bstr_t(key), &varValue); if (FAILED(hr)) { return luaL_error(L, "Couldn't access key"); } VariantToStack(L, &varValue); VariantClear(&varValue); return 1; } VARIANT labels; VARIANT values; VariantInit(&labels); VariantInit(&values); long size = 0; rawFile->comRawFile->GetTuneData(spectrumNumber, &labels, &values, &size); MapToStack(L, &labels, &values, size); return 1; } int scanTrailer(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); if (lua_gettop(L) == 3) { const char* key = luaL_checkstring(L, 3); VARIANT varValue; VariantInit(&varValue); HRESULT hr = rawFile->comRawFile->GetTrailerExtraValueForScanNum(spectrumNumber, _bstr_t(key), &varValue); if (FAILED(hr)) { return luaL_error(L, "Couldn't access key"); } VariantToStack(L, &varValue); VariantClear(&varValue); return 1; } VARIANT labels; VARIANT values; VariantInit(&labels); VariantInit(&values); long size = 0; rawFile->comRawFile->GetTrailerExtraForScanNum(spectrumNumber, &labels, &values, &size); MapToStack(L, &labels, &values, size); return 1; } int statusLog(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); if (lua_gettop(L) == 3) { const char* key = luaL_checkstring(L, 3); VARIANT varValue; VariantInit(&varValue); double dRt = 0; HRESULT hr = rawFile->comRawFile->GetStatusLogValueForScanNum(spectrumNumber, _bstr_t(key), &dRt, &varValue); if (FAILED(hr)) { return luaL_error(L, "Couldn't access key"); } VariantToStack(L, &varValue); VariantClear(&varValue); return 1; } VARIANT labels; VARIANT values; VariantInit(&labels); VariantInit(&values); long size = 0; double rt = 0; rawFile->comRawFile->GetStatusLogForScanNum(spectrumNumber, &rt, &labels, &values, &size); MapToStack(L, &labels, &values, size); return 1; } int scanFilter(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); BSTR filter = NULL; rawFile->comRawFile->GetFilterForScanNum(spectrumNumber, &filter); lua_pushstring(L, _bstr_t(filter)); SysFreeString(filter); return 1; } int scanHeader(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); long nPackets = 0; double dStartTime = 0; double dLowMass = 0; double dHighMass = 0; double dTic = 0; double dBPMass = 0; double dBPIntensity = 0; long nChannels = 0; long nUniformTime = 0; double dFrequency = 0; rawFile->comRawFile->GetScanHeaderInfoForScanNum(spectrumNumber, &nPackets, &dStartTime, &dLowMass, &dHighMass, &dTic, &dBPMass, &dBPIntensity, &nChannels, &nUniformTime, &dFrequency); lua_createtable(L, 0, 10); luaD_setNumber(L, nPackets, "NumPackets"); luaD_setNumber(L, dStartTime, "StartTime"); luaD_setNumber(L, dLowMass, "LowMass"); luaD_setNumber(L, dHighMass, "HighMass"); luaD_setNumber(L, dTic, "TIC"); luaD_setNumber(L, dBPMass, "BasePeakMass"); luaD_setNumber(L, dBPIntensity, "BasePeakIntensity"); luaD_setNumber(L, nChannels, "NumChannels"); luaD_setNumber(L, nUniformTime, "UniformTime"); luaD_setNumber(L, dFrequency, "Frequency"); return 1; } int getNumInstMethods(lua_State* L) { RawFile *rawFile = checkRawFile(L); try { long number(0); HRESULT hr = rawFile->comRawFile->GetNumInstMethods(&number); if (SUCCEEDED(hr)) { lua_pushnumber(L, number); return 1; } } catch (...) {} lua_pushnil(L); return 1; } int getInstrumentMethod(lua_State* L) { RawFile *rawFile = checkRawFile(L); try { int index = (int)luaL_checkinteger(L, -1) - 1; BSTR str = NULL; HRESULT hr = rawFile->comRawFile->GetInstMethod(index, &str); if (SUCCEEDED(hr) && str != NULL) { CStringA returnString = CStringA(str); SysFreeString(str); lua_pushstring(L, returnString); return 1; } } catch (...) {} lua_pushnil(L); return 1; } int getInstrumentMethodNames(lua_State* L) { RawFile *rawFile = checkRawFile(L); try { long number(0); VARIANT names; VariantInit(&names); HRESULT hr = rawFile->comRawFile->GetInstMethodNames(&number, &names); if (SUCCEEDED(hr)) { ListToTable(L, &names, number); VariantClear(&names); lua_pushnumber(L, number); return 2; } VariantClear(&names); } catch (...) {} lua_pushnil(L); return 1; } int getIsolationWidthForScanNum(lua_State* L) { RawFile *rawFile = checkRawFile(L); long sn = (long)luaL_checkinteger(L, 2); long msOrder = 2; if (lua_gettop(L) == 3) { msOrder = (long)luaL_checkinteger(L, 3); } double width = 0; rawFile->comRawFile->GetIsolationWidthForScanNum(sn, msOrder, &width); lua_pushnumber(L, width); lua_pushinteger(L, msOrder); return 2; } int getRetentionTime(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); double dRT = 0; rawFile->comRawFile->RTFromScanNum(spectrumNumber, &dRT); lua_pushnumber(L, dRT); return 1; } int getScanNumberFromRT(lua_State* L) { RawFile *rawFile = checkRawFile(L); double dRT = luaL_checknumber(L, 2); long spectrumNumber; rawFile->comRawFile->ScanNumFromRT(dRT, &spectrumNumber); rawFile->comRawFile->RTFromScanNum(spectrumNumber, &dRT); lua_pushinteger(L, spectrumNumber); lua_pushnumber(L, dRT); return 2; } int getMSNOrder(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); long msnOrder = -1; rawFile->comRawFile->GetMSOrderForScanNum(spectrumNumber, &msnOrder); lua_pushinteger(L, msnOrder); return 1; } int hasCentroidData(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); long centroid = 0; rawFile->comRawFile->IsCentroidScanForScanNum(spectrumNumber, &centroid); lua_pushboolean(L, centroid); return 1; } int getChroData(lua_State* L) { RawFile *rawFile = checkRawFile(L); if (!lua_istable(L, 2)) { luaL_argerror(L, -2, "Expecting Table of parameters for Chro Data"); return 0; } lua_getfield(L, -1, "Type"); long chroType = (long)lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "StartTime"); double startTime = 0; if (lua_isnumber(L, -1)) startTime = lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "EndTime"); double endTime = 0; if (lua_isnumber(L, -1)) endTime = lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "Delay"); double delay = 0; if (lua_isnumber(L, -1)) delay = lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "Operator"); long chroOperator = 0; if (lua_isnumber(L, -1)) chroOperator = (long)lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "Type2"); long chroType2 = 0; if (lua_isnumber(L, -1)) chroType2 = (long)lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "Filter"); _bstr_t filter = ""; if (lua_isstring(L, -1)) filter = lua_tostring(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "MassRange1"); _bstr_t massRange1 = ""; if (lua_isstring(L, -1)) massRange1 = lua_tostring(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "MassRange2"); _bstr_t massRange2 = ""; if (lua_isstring(L, -1)) massRange2 = lua_tostring(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "SmoothingType"); long smoothingType = 0; if (lua_isnumber(L, -1)) smoothingType = (long)lua_tonumber(L, -1); lua_pop(L, 1); lua_getfield(L, -1, "SmoothingValue"); long smoothingValue = 3; if (lua_isnumber(L, -1)) smoothingValue = (long)lua_tonumber(L, -1); lua_pop(L, 1); long size = 0; VARIANT chroData; VARIANT flags; VariantInit(&chroData); VariantInit(&flags); HRESULT hr = rawFile->comRawFile->GetChroData(chroType, chroOperator, chroType2, filter, massRange1, massRange2, delay, &startTime, &endTime, smoothingType, smoothingValue, &chroData, &flags, &size); lua_createtable(L, size, 2); luaD_setNumber(L, startTime, "StartTime"); luaD_setNumber(L, endTime, "EndTime"); ChroPeak* pValues = NULL; SAFEARRAY FAR* valueSA = chroData.parray; SafeArrayAccessData(valueSA, (void**)(&pValues)); for (int i = 0; i < size; i++) { lua_createtable(L, 0, 2); luaD_setNumber(L, pValues[i].dTime, "Time"); luaD_setNumber(L, pValues[i].dIntensity, "Intensity"); lua_rawseti(L, -2, i + 1); } SafeArrayUnaccessData(valueSA); SafeArrayDestroy(valueSA); return 1; } int getSpectrumData(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); double fm = 0; double lm = 1000000000; if (lua_gettop(L) > 2) { luaL_checktype(L, 3, LUA_TTABLE); lua_getfield(L, 3, "fm"); if (lua_isnumber(L, -1)) { fm = lua_tonumber(L, -1); } lua_getfield(L, 3, "lm"); if (lua_isnumber(L, -1)) { lm = lua_tonumber(L, -1); } lua_pop(L, 2); } VARIANT massList; VariantInit(&massList); VARIANT peakFlags; VariantInit(&peakFlags); long size; double centroidPeakWidth = 0; rawFile->comRawFile->GetMassListFromScanNum(&spectrumNumber, (LPCTSTR)NULL, 0, 0, 0, 0, &centroidPeakWidth, &massList, &peakFlags, &size); SAFEARRAY FAR* psa = massList.parray; DataPeak* pDataPeaks = NULL; SafeArrayAccessData(psa, (void**)(&pDataPeaks)); lua_createtable(L, size, 0); int c = 1; for (int i = 0; i < size; i++) { double mass = pDataPeaks[i].Mass; if (mass < fm || mass > lm) continue; lua_createtable(L, 0, 2); luaD_setNumber(L, mass, "Mass"); luaD_setNumber(L, pDataPeaks[i].Intensity, "Intensity"); lua_rawseti(L, -2, c++); } SafeArrayUnaccessData(psa); SafeArrayDestroy(psa); VariantClear(&peakFlags); return 1; } int getLabelData(lua_State* L) { RawFile *rawFile = checkRawFile(L); long spectrumNumber = (long)luaL_checkinteger(L, 2); double fm = 0; double lm = 1000000000; if (lua_gettop(L) > 2) { luaL_checktype(L, 3, LUA_TTABLE); lua_getfield(L, 3, "fm"); if (lua_isnumber(L, -1)) { fm = lua_tonumber(L, -1); } lua_getfield(L, 3, "lm"); if (lua_isnumber(L, -1)) { lm = lua_tonumber(L, -1); } lua_pop(L, 2); } VARIANT labels; VARIANT flags; VariantInit(&labels); VariantInit(&flags); rawFile->comRawFile->GetLabelData(&labels, &flags, &spectrumNumber); LabelData* pValues = NULL; SAFEARRAY FAR* valueSA = labels.parray; SafeArrayAccessData(valueSA, (void**)(&pValues)); LabelFlags* pFlags = NULL; SAFEARRAY FAR* flagsSA = flags.parray; SafeArrayAccessData(flagsSA, (void**)(&pFlags)); int size = labels.parray->rgsabound[0].cElements; lua_createtable(L, size, 0); int c = 1; for (int i = 0; i < size; i++) { double mass = pValues[i].Mass; if (mass < fm || mass > lm) continue; lua_createtable(L, 0, 6); luaD_setNumber(L, mass, "Mass"); luaD_setNumber(L, pValues[i].Intensity, "Intensity"); luaD_setNumber(L, pValues[i].Baseline, "Baseline"); luaD_setNumber(L, pValues[i].Noise, "Noise"); luaD_setNumber(L, pValues[i].Resolution, "Resolution"); luaD_setNumber(L, pValues[i].Charge, "Charge"); if (pFlags[i].Exception) { lua_pushboolean(L, true); lua_setfield(L, -2, "Exception"); } if (pFlags[i].Fragmented) { lua_pushboolean(L, true); lua_setfield(L, -2, "Fragmented"); } if (pFlags[i].Merged) { lua_pushboolean(L, true); lua_setfield(L, -2, "Merged"); } if (pFlags[i].Modified) { lua_pushboolean(L, true); lua_setfield(L, -2, "Modified"); } if (pFlags[i].Saturated) { lua_pushboolean(L, true); lua_setfield(L, -2, "Saturated"); } lua_rawseti(L, -2, c++); } SafeArrayUnaccessData(valueSA); SafeArrayDestroy(valueSA); SafeArrayUnaccessData(flagsSA); SafeArrayDestroy(flagsSA); return 1; } /*** Get the precursor mass of a given MSn stage in a spectrum @function GetPrecursorMass @int sn The spectrum number @int[opt=2] msn The precursor MSn stage @treturn float The precursor mass at the given stage */ int getPrecursorMass(lua_State* L) { RawFile *rawFile = checkRawFile(L); long sn = (long)luaL_checkinteger(L, 2); long msOrder = 2; if (lua_gettop(L) == 3) { msOrder = (long)luaL_checkinteger(L, 3); } double mass = 0; int charge = 0; rawFile->comRawFile->GetPrecursorMassForScanNum(sn, msOrder, &mass); lua_pushnumber(L, mass); lua_pushinteger(L, msOrder); return 2; } int getInAcquisition(lua_State* L) { RawFile *rawFile = checkRawFile(L); long inAcq = 0; rawFile->comRawFile->InAcquisition(&inAcq); lua_pushboolean(L, inAcq); return 1; } int getSegmentsForScanNumber(lua_State* L) { RawFile *rawFile = checkRawFile(L); long sn = (long)luaL_checkinteger(L, 2); long segs = 0; long events = 0; rawFile->comRawFile->GetSegmentAndEventForScanNum(sn, &segs, &events); lua_pushinteger(L, segs); lua_pushinteger(L, events); return 2; } int getLowMass(lua_State* L) { RawFile *rawFile = checkRawFile(L); double lowMass(0); HRESULT hr = rawFile->comRawFile->GetLowMass(&lowMass); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushnumber(L, lowMass); return 1; } int getHighMass(lua_State* L) { RawFile *rawFile = checkRawFile(L); double highMass(0); HRESULT hr = rawFile->comRawFile->GetHighMass(&highMass); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushnumber(L, highMass); return 1; } int getInstName(lua_State* L) { RawFile *rawFile = checkRawFile(L); BSTR name = NULL; // the assignment to null is needed for some odd reason HRESULT hr = rawFile->comRawFile->GetInstName(&name); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushstring(L, _bstr_t(name)); return 1; } int getSWVersion(lua_State* L) { RawFile *rawFile = checkRawFile(L); BSTR version = NULL; // the assignment to null is needed for some odd reason HRESULT hr = rawFile->comRawFile->GetInstSoftwareVersion(&version); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushstring(L, _bstr_t(version)); return 1; } int getSerialNumber(lua_State* L) { RawFile *rawFile = checkRawFile(L); BSTR serialNumber = NULL; HRESULT hr = rawFile->comRawFile->GetInstSerialNumber(&serialNumber); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushstring(L, _bstr_t(serialNumber)); return 1; } int getHWVersion(lua_State* L) { RawFile *rawFile = checkRawFile(L); BSTR version = NULL; HRESULT hr = rawFile->comRawFile->GetInstHardwareVersion(&version); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushstring(L, _bstr_t(version)); return 1; } int getInstModel(lua_State* L) { RawFile *rawFile = checkRawFile(L); BSTR model = NULL; HRESULT hr = rawFile->comRawFile->GetInstModel(&model); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushstring(L, _bstr_t(model)); return 1; } int getErrorLogCount(lua_State* L) { RawFile *rawFile = checkRawFile(L); long count(0); HRESULT hr = rawFile->comRawFile->GetNumErrorLog(&count); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushinteger(L, count); return 1; } int getErrorLogItem(lua_State* L) { RawFile *rawFile = checkRawFile(L); long id = (long)luaL_checkinteger(L, 2); BSTR message = NULL; // the assignment to null is needed for some odd reason double rt(0); HRESULT hr = rawFile->comRawFile->GetErrorLogItem(id, &rt, &message); if (FAILED(hr)) { lua_pushboolean(L, false); return 1; } lua_pushstring(L, _bstr_t(message)); lua_pushnumber(L, rt); return 2; } int releaseRawfile(lua_State* L) { RawFile *rawFile = checkRawFile(L); delete rawFile; return 0; } int Register(lua_State* L) { luaL_newmetatable(L, RawFileType); lua_pushvalue(L, -1); lua_setfield(L, -2, "__index"); luaL_setfuncs(L, thermo_rawfile_m, 0); return 1; } }
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/iam/model/GetRoleResult.h> #include <aws/core/utils/xml/XmlSerializer.h> #include <aws/core/AmazonWebServiceResult.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/logging/LogMacros.h> #include <utility> using namespace Aws::IAM::Model; using namespace Aws::Utils::Xml; using namespace Aws::Utils::Logging; using namespace Aws::Utils; using namespace Aws; GetRoleResult::GetRoleResult() { } GetRoleResult::GetRoleResult(const Aws::AmazonWebServiceResult<XmlDocument>& result) { *this = result; } GetRoleResult& GetRoleResult::operator =(const Aws::AmazonWebServiceResult<XmlDocument>& result) { const XmlDocument& xmlDocument = result.GetPayload(); XmlNode rootNode = xmlDocument.GetRootElement(); XmlNode resultNode = rootNode; if (!rootNode.IsNull() && (rootNode.GetName() != "GetRoleResult")) { resultNode = rootNode.FirstChild("GetRoleResult"); } if(!resultNode.IsNull()) { XmlNode roleNode = resultNode.FirstChild("Role"); if(!roleNode.IsNull()) { m_role = roleNode; } } if (!rootNode.IsNull()) { XmlNode responseMetadataNode = rootNode.FirstChild("ResponseMetadata"); m_responseMetadata = responseMetadataNode; AWS_LOGSTREAM_DEBUG("Aws::IAM::Model::GetRoleResult", "x-amzn-request-id: " << m_responseMetadata.GetRequestId() ); } return *this; }
_MeetLaprasGuyText:: text "Oh! Hi! You're" line "not a ROCKET! You" cont "came to save us?" cont "Why, thank you!" para "I want you to" line "have this #MON" cont "for saving us." prompt _HeresYourLaprasText:: text "It's LAPRAS. It's" line "very intelligent." para "We kept it in our" line "lab, but it will" cont "be much better" cont "off with you!" para "I think you will" line "be a good trainer" cont "for LAPRAS!" para "It's a good" line "swimmer. It'll" cont "give you a lift!" done _LaprasGuyText:: text "TEAM ROCKET's" line "BOSS went to the" cont "boardroom! Is our" cont "PRESIDENT OK?" done _LaprasGuySavedText:: text "Saved at last!" line "Thank you!" done _SilphCo7Text_51e00:: text "TEAM ROCKET was" line "after the MASTER" cont "BALL which will" cont "catch any #MON!" done _CanceledMasterBallText:: text "We canceled the" line "MASTER BALL" cont "project because" cont "of TEAM ROCKET." done _SilphCo7Text_51e23:: text "It would be bad" line "if TEAM ROCKET" cont "took over SILPH" cont "or our #MON!" done _SilphCo7Text_51e28:: text "Wow! You chased" line "off TEAM ROCKET" cont "all by yourself?" done _SilphCo7Text_51e46:: text "You! It's really" line "dangerous here!" cont "You came to save" cont "me? You can't!" done _SilphCo7Text_51e4b:: text "Safe at last!" line "Oh thank you!" done _SilphCo7BattleText1:: text "Oh ho! I smell a" line "little rat!" done _SilphCo7EndBattleText1:: text "Lights" line "out!" prompt _SilphCo7AfterBattleText1:: text "You won't find my" line "BOSS by just" cont "scurrying around!" done _SilphCo7BattleText2:: text "Heheh!" para "You mistook me for" line "a SILPH worker?" done _SilphCo7EndBattleText2:: text "I'm" line "done!" prompt _SilphCo7AfterBattleText2:: text "Despite your age," line "you are a skilled" cont "trainer!" done _SilphCo7BattleText3:: text "I am one of the 4" line "ROCKET BROTHERS!" done _SilphCo7EndBattleText3:: text "Aack!" line "Brothers, I lost!" prompt _SilphCo7AfterBattleText3:: text "Doesn't matter." line "My brothers will" cont "repay the favor!" done _SilphCo7BattleText4:: text "A child intruder?" line "That must be you!" done _SilphCo7EndBattleText4:: text "Fine!" line "I lost!" prompt _SilphCo7AfterBattleText4:: text "Go on home" line "before my BOSS" cont "gets ticked off!" done _SilphCo7Text_51ebe:: text "<RIVAL>: What" line "kept you <PLAYER>?" done _SilphCo7Text_51ec3:: text "<RIVAL>: Hahaha!" line "I thought you'd" cont "turn up if I" cont "waited here!" para "I guess TEAM" line "ROCKET slowed you" cont "down! Not that I" cont "care!" para "I saw you in" line "SAFFRON, so I" cont "decided to see if" cont "you got better!" done _SilphCo7Text_51ec8:: text "Oh ho!" line "So, you are ready" cont "for BOSS ROCKET!" prompt _SilphCo7Text_51ecd:: text "<RIVAL>: How can" line "I put this?" para "You're not good" line "enough to play" cont "with us big boys!" prompt _SilphCo7Text_51ed2:: text "Well, <PLAYER>!" para "I'm moving on up" line "and ahead!" para "By checking my" line "#DEX, I'm" cont "starting to see" cont "what's strong and" cont "how they evolve!" para "I'm going to the" line "#MON LEAGUE" cont "to boot out the" cont "ELITE FOUR!" para "I'll become the" line "world's most" cont "powerful trainer!" para "<PLAYER>, well" line "good luck to you!" cont "Don't sweat it!" cont "Smell ya!" done
org 100h ; add your code here MOV AX, 0300H MOV DS, AX MOV CX, 4A3CH MOV [3126H], CX MOV DX, 10H MUL DX ADD AX, 3126H ret
mov si, 7c00h mov ah, 0eh loop: lodsb int 10h cmp al, 0 jne loop
#include "Platform.inc" #include "ResetFlags.inc" #include "TestDoubles.inc" radix decimal extern resetFlags ResetFlagsStubs code global stubIsLastResetDueToBrownOutToReturnTrue global stubIsLastResetDueToBrownOutToReturnFalse stubIsLastResetDueToBrownOutToReturnTrue: banksel resetFlags bsf resetFlags, RESET_FLAG_BROWNOUT return stubIsLastResetDueToBrownOutToReturnFalse: banksel resetFlags bcf resetFlags, RESET_FLAG_BROWNOUT return end
; A250768: Number of (n+1) X (7+1) 0..1 arrays with nondecreasing x(i,j)-x(i,j-1) in the i direction and nondecreasing absolute value of x(i,j)-x(i-1,j) in the j direction. ; 519,798,1158,1680,2526,4020,6810,12192,22758,43692,85362,168504,334590,666564,1330314,2657616,5312022,10620636,21237666,42471528,84939054,169873908,339743418,679482240,1358959686,2717914380,5435823570,10871641752,21743277918,43486550052,86973094122,173946182064,347892357750,695784708924,1391569411074,2783138815176,5566277623182,11132555238996,22265110470426,44530220933088,89060441858214,178120883708268,356241767408178,712483534807800,1424967069606846,2849934139204740,5699868278400330 mov $1,4 mov $2,$0 mov $3,8 lpb $0,1 sub $0,1 mul $3,2 add $3,1 lpe add $3,2 sub $3,$1 mov $1,$3 add $1,$3 mul $1,4 sub $3,3 add $1,$3 sub $1,4 lpb $2,1 add $1,198 sub $2,1 lpe add $1,472
// Copyright (c) 2011-2017 The Cryptonote developers // Copyright (c) 2017-2018 The Circle Foundation & invert Devs // Copyright (c) 2018-2019 invert Network & invert Devs // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "IntegerOverflow.h" using namespace CryptoNote; namespace { void split_miner_tx_outs(Transaction& miner_tx, uint64_t amount_1) { uint64_t total_amount = get_outs_money_amount(miner_tx); uint64_t amount_2 = total_amount - amount_1; TransactionOutputTarget target = miner_tx.outputs[0].target; miner_tx.outputs.clear(); TransactionOutput out1; out1.amount = amount_1; out1.target = target; miner_tx.outputs.push_back(out1); TransactionOutput out2; out2.amount = amount_2; out2.target = target; miner_tx.outputs.push_back(out2); } void append_TransactionSourceEntry(std::vector<CryptoNote::TransactionSourceEntry>& sources, const Transaction& tx, size_t out_idx) { CryptoNote::TransactionSourceEntry se; se.amount = tx.outputs[out_idx].amount; se.outputs.push_back(std::make_pair(0, boost::get<CryptoNote::KeyOutput>(tx.outputs[out_idx].target).key)); se.realOutput = 0; se.realTransactionPublicKey = getTransactionPublicKeyFromExtra(tx.extra); se.realOutputIndexInTransaction = out_idx; sources.push_back(se); } } //====================================================================================================================== gen_uint_overflow_base::gen_uint_overflow_base() : m_last_valid_block_event_idx(static_cast<size_t>(-1)) { REGISTER_CALLBACK_METHOD(gen_uint_overflow_1, mark_last_valid_block); } bool gen_uint_overflow_base::check_tx_verification_context(const CryptoNote::tx_verification_context& tvc, bool tx_added, size_t event_idx, const CryptoNote::Transaction& /*tx*/) { return m_last_valid_block_event_idx < event_idx ? !tx_added && tvc.m_verification_failed : tx_added && !tvc.m_verification_failed; } bool gen_uint_overflow_base::check_block_verification_context(const CryptoNote::block_verification_context& bvc, size_t event_idx, const CryptoNote::Block& /*block*/) { return m_last_valid_block_event_idx < event_idx ? bvc.m_verification_failed | bvc.m_marked_as_orphaned : !bvc.m_verification_failed; } bool gen_uint_overflow_base::mark_last_valid_block(CryptoNote::core& c, size_t ev_index, const std::vector<test_event_entry>& events) { m_last_valid_block_event_idx = ev_index - 1; return true; } //====================================================================================================================== bool gen_uint_overflow_1::generate(std::vector<test_event_entry>& events) const { uint64_t ts_start = 1338224400; GENERATE_ACCOUNT(miner_account); MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start); DO_CALLBACK(events, "mark_last_valid_block"); MAKE_ACCOUNT(events, bob_account); MAKE_ACCOUNT(events, alice_account); // Problem 1. Miner tx output overflow MAKE_MINER_TX_MANUALLY(miner_tx_0, blk_0); split_miner_tx_outs(miner_tx_0, std::numeric_limits<uint64_t>::max()); Block blk_1; if (!generator.constructBlockManually(blk_1, blk_0, miner_account, test_generator::bf_miner_tx, 0, 0, 0, Crypto::Hash(), 0, miner_tx_0)) return false; events.push_back(blk_1); // Problem 1. Miner tx outputs overflow MAKE_MINER_TX_MANUALLY(miner_tx_1, blk_1); split_miner_tx_outs(miner_tx_1, std::numeric_limits<uint64_t>::max()); Block blk_2; if (!generator.constructBlockManually(blk_2, blk_1, miner_account, test_generator::bf_miner_tx, 0, 0, 0, Crypto::Hash(), 0, miner_tx_1)) return false; events.push_back(blk_2); REWIND_BLOCKS(events, blk_2r, blk_2, miner_account); MAKE_TX_LIST_START(events, txs_0, miner_account, bob_account, std::numeric_limits<uint64_t>::max(), blk_2); MAKE_TX_LIST(events, txs_0, miner_account, bob_account, std::numeric_limits<uint64_t>::max(), blk_2); MAKE_NEXT_BLOCK_TX_LIST(events, blk_3, blk_2r, miner_account, txs_0); REWIND_BLOCKS(events, blk_3r, blk_3, miner_account); // Problem 2. total_fee overflow, block_reward overflow std::list<CryptoNote::Transaction> txs_1; // Create txs with huge fee txs_1.push_back(construct_tx_with_fee(m_logger, events, blk_3, bob_account, alice_account, MK_COINS(1), std::numeric_limits<uint64_t>::max() - MK_COINS(1))); txs_1.push_back(construct_tx_with_fee(m_logger, events, blk_3, bob_account, alice_account, MK_COINS(1), std::numeric_limits<uint64_t>::max() - MK_COINS(1))); MAKE_NEXT_BLOCK_TX_LIST(events, blk_4, blk_3r, miner_account, txs_1); return true; } //====================================================================================================================== bool gen_uint_overflow_2::generate(std::vector<test_event_entry>& events) const { uint64_t ts_start = 1338224400; GENERATE_ACCOUNT(miner_account); MAKE_GENESIS_BLOCK(events, blk_0, miner_account, ts_start); MAKE_ACCOUNT(events, bob_account); MAKE_ACCOUNT(events, alice_account); REWIND_BLOCKS(events, blk_0r, blk_0, miner_account); DO_CALLBACK(events, "mark_last_valid_block"); // Problem 1. Regular tx outputs overflow std::vector<CryptoNote::TransactionSourceEntry> sources; for (size_t i = 0; i < blk_0.baseTransaction.outputs.size(); ++i) { if (m_currency.minimumFee() < blk_0.baseTransaction.outputs[i].amount) { append_TransactionSourceEntry(sources, blk_0.baseTransaction, i); break; } } if (sources.empty()) { return false; } std::vector<CryptoNote::TransactionDestinationEntry> destinations; const AccountPublicAddress& bob_addr = bob_account.getAccountKeys().address; destinations.push_back(TransactionDestinationEntry(std::numeric_limits<uint64_t>::max(), bob_addr)); destinations.push_back(TransactionDestinationEntry(std::numeric_limits<uint64_t>::max() - 1, bob_addr)); // sources.front().amount = destinations[0].amount + destinations[2].amount + destinations[3].amount + m_currency.minimumFee() destinations.push_back(TransactionDestinationEntry(sources.front().amount - std::numeric_limits<uint64_t>::max() - std::numeric_limits<uint64_t>::max() + 1 - m_currency.minimumFee(), bob_addr)); CryptoNote::Transaction tx_1; Crypto::SecretKey txSK; if (!constructTransaction(miner_account.getAccountKeys(), sources, destinations, std::vector<uint8_t>(), tx_1, 0, m_logger, txSK)) return false; events.push_back(tx_1); MAKE_NEXT_BLOCK_TX1(events, blk_1, blk_0r, miner_account, tx_1); REWIND_BLOCKS(events, blk_1r, blk_1, miner_account); // Problem 2. Regular tx inputs overflow sources.clear(); for (size_t i = 0; i < tx_1.outputs.size(); ++i) { auto& tx_1_out = tx_1.outputs[i]; if (tx_1_out.amount < std::numeric_limits<uint64_t>::max() - 1) continue; append_TransactionSourceEntry(sources, tx_1, i); } destinations.clear(); CryptoNote::TransactionDestinationEntry de; de.addr = alice_account.getAccountKeys().address; de.amount = std::numeric_limits<uint64_t>::max() - m_currency.minimumFee(); destinations.push_back(de); destinations.push_back(de); CryptoNote::Transaction tx_2; Crypto::SecretKey txSK2; if (!constructTransaction(bob_account.getAccountKeys(), sources, destinations, std::vector<uint8_t>(), tx_2, 0, m_logger, txSK2)) return false; events.push_back(tx_2); MAKE_NEXT_BLOCK_TX1(events, blk_2, blk_1r, miner_account, tx_2); return true; }
include w2.inc include noxport.inc include consts.inc include structs.inc createSeg disptbl_PCODE,disptbln,byte,public,CODE ; DEBUGGING DECLARATIONS ifdef DEBUG midDisptbln equ 25 ; module ID, for native asserts NatPause equ 1 endif ifdef NatPause PAUSE MACRO int 3 ENDM else PAUSE MACRO ENDM endif ; EXTERNAL FUNCTIONS externFP <FSetRgchDiff> ifdef DEBUG externFP <AssertProcForNative> endif sBegin data ; ; /* E X T E R N A L S */ ; externW vfti ; extern struct FTI vfti; sEnd data ; CODE SEGMENT _disptbln sBegin disptbln assumes cs,disptbln assumes ds,dgroup assumes ss,dgroup ;------------------------------------------------------------------------- ; WidthHeightFromBrc(brc, grpf) ;------------------------------------------------------------------------- ;HANDNATIVE C_WidthHeightFromBrc(brc, grpf) ;struct BRC brc; ;int grpf; ;{ ; int dzp, dz = 0, dxp; ; int fFrameLines, fWidth, fLine; ; %%Function:WidthHeightFromBrc %%Owner:tomsax PUBLIC N_WidthHeightFromBrc N_WidthHeightFromBrc: mov bx,sp mov cx,[bx+4] errnz <cbBrcMin - 2> mov dx,[bx+6] ;We now have brc in dx, grpf in cx ; fFrameLines = grpf & 1; ; fWidth = grpf & 2; ; fLine = grpf & 4; maskFFrameLinesLocal equ 1 maskFWidthLocal equ 2 maskFLineLocal equ 4 ; dzp = fWidth ? dxpBorderFti : dypBorderFti; ;#define dypBorderFti vfti.dypBorder ;#define dxpBorderFti vfti.dxpBorder mov ax,[vfti.dxpBorderFti] test cl,maskFWidthLocal jne WHFB01 mov ax,[vfti.dypBorderFti] WHFB01: ; if ((int) brc == brcNone && fFrameLines) ; return dzp; mov bx,ax errnz <brcNone - 0> or dx,dx jne WHFB02 test cl,maskFFrameLinesLocal jne WHFB10 WHFB02: ; if ((int) brc == brcNone || (int) brc == brcNil) ; return 0; xor ax,ax errnz <brcNil - (-1)> inc dx je WHFB10 errnz <brcNone - 0> dec dx je WHFB10 ; /* All the more difficult cases */ ; if (!fLine) ; /* brc.dxpSpace is in points - Hungarian name is wrong */ ; dz = NMultDiv(brc.dxpSpace, ; fWidth ? vfti.dxpInch : vfti.dypInch, ; cptInch); test cl,maskFLineLocal jne WHFB07 push bx ;save dzp push dx ;save brc mov ax,[vfti.dxpInchFti] test cl,maskFWidthLocal jne WHFB04 mov ax,[vfti.dypInchFti] WHFB04: errnz <(dxpSpaceBrc) - 1> errnz <maskDxpSpaceBrc - 03Eh> mov dl,dh and dx,maskDxpSpaceBrc shr dx,1 imul dx add ax,cptInch SHR 1 adc dx,0 ifdef DEBUG ;Assert the following idiv will not overflow with a call ;so as not to mess up short jumps. call WHFB11 endif ;DEBUG mov bx,cptInch idiv bx pop dx ;restore brc pop bx ;restore dzp WHFB07: ; if (brc.fShadow) ; dz += fWidth ? dxShadow : dyShadow; ;#define dxShadow dxpBorderFti ;#define dyShadow dypBorderFti ;PAUSE errnz <(fShadowBrc) - 1> test dh,maskFShadowBrc je WHFB08 add ax,bx WHFB08: ; switch(brc.brcBase) ; { ; case brcSingle: ; return dz + dzp; ; case brcTwoSingle: ; return dz + 3 * dzp; ; case brcThick: ; return dz + 2 * dzp; ; } ; Assert(fFalse); ; return 0; errnz <maskBrcBaseBrc - 001FFh> and dh,maskBrcBaseBrc SHR 8 add ax,bx cmp dx,brcSingle je WHFB09 add ax,bx cmp dx,brcThick je WHFB09 add ax,bx cmp dx,brcTwoSingle je WHFB09 ifdef DEBUG ;Assert (fFalse) with a call so as not to mess up short jumps. call WHFB14 endif ;DEBUG xor ax,ax jmp short WHFB10 WHFB09: ; return dz; WHFB10: ;} db 0CAh, 004h, 000h ;far ret, pop 4 bytes ifdef DEBUG WHFB11: push ax push bx push cx push dx or dx,dx jns WHFB12 neg dx WHFB12: cmp dx,cptInch SHR 1 jb WHFB13 mov ax,midDisptbln mov bx,1001 cCall AssertProcForNative,<ax,bx> WHFB13: pop dx pop cx pop bx pop ax ret endif ;DEBUG ifdef DEBUG WHFB14: push ax push bx push cx push dx mov ax,midDisptbln mov bx,1002 cCall AssertProcForNative,<ax,bx> pop dx pop cx pop bx pop ax ret endif ;DEBUG sEnd disptbln end
# ========================================================================= # # NAME: # DATE: May 28, 2001 # ASSIGNMENT: Homework #2, CSC-201-01 # OBJECTIVE: Read an integer from the keyboard and quadruple the number. # Then subtract the quadrupled number by the input number. Then # apply an if/then statement. If the number is equal to 10, # multiply by 3 and subtract by 50. If the number is less than # 10, multiply by 2 and print "That's all folks". Otherwise, # multiply by 4 and subtract by 6. The number should be shown # each time a mathematical operation has been applied, except # for the if/then statements. The final result must be shown. # # ========================================================================= .data .align 2 prompt1: .asciiz " Enter a number: " prompt2: .asciiz " Input doubled: " prompt3: .asciiz " Doubled result: " prompt4: .asciiz "Subtracted result: " prompt5: .asciiz "That's all folks\n" prompt6: .asciiz "The output is " newline: .asciiz "\n" .text .align 2 main: # ========================================================================= # # $t0 - input number # $t1 - input number * 2 # $t2 - input number * 4 # $t3 - input number * 4 - input number # # ========================================================================= # ::::: OP :::: ARGUMENTS ::::::::::::: COMMENTS :::::::::::::::::::::::::: # ========================================================================= la $a0, prompt1 li $v0, 4 syscall # print "Enter a number: " li $v0, 5 syscall # read number from keyboard move $t0, $v0 # save orginal number # ========================================================================= add $t1, $t0, $t0 # double = input + input la $a0, prompt2 li $v0, 4 syscall # print " Input doubled: " move $a0, $t1 li $v0, 1 syscall # print doubled number la $a0, newline li $v0, 4 syscall # print new line # ========================================================================= add $t2, $t1, $t1 # quadruple = double + double la $a0, prompt3 li $v0, 4 syscall # print "Doubled result: " move $a0, $t2 li $v0, 1 syscall # print doubled number la $a0, newline li $v0, 4 syscall # print new line # ========================================================================= sub $t3, $t2, $t0 # answer = quadruple - input la $a0, prompt4 li $v0, 4 syscall # print "Subtracted result: " move $a0, $t3 li $v0, 1 syscall # print doubled number la $a0, newline li $v0, 4 syscall # print new line # ========================================================================= # # $t0 - input number # $t1 - result # # ========================================================================= beq $t0, 10, equal10 # if input = 10, goto equal10 j equal10_end equal10: add $t1, $t0, $t0 # answer = input + input add $t1, $t1, $t0 # answer = answer + input sub $t1, $t1, 50 # answer = answer - 50 equal10_end: # ========================================================================= blt $t0, 10, less10 # if input < 10, goto less10 j less10_end less10: add $t1, $t0, $t0 # answer = input + input la $a0, prompt5 li $v0, 4 syscall # print "That's all folks" less10_end: # ========================================================================= bgt $t0, 10, big10 # if input > 10, goto big10 j big10_end big10: add $t1, $t0, $t0 # answer = input + input add $t1, $t1, $t0 # answer = answer + input add $t1, $t1, $t0 # answer = answer + input sub $t1, $t1, 6 # answer = answer - 6 big10_end: # ========================================================================= la $a0, prompt6 li $v0, 4 syscall # print "The output is " move $a0, $t1 li $v0, 1 syscall # print final answer la $a0, newline li $v0, 4 syscall # print new line # ========================================================================= li $v0, 10 syscall # exit program # ========================================================================= # :::::::::::::::::::::::::::: END OF PROGRAM! :::::::::::::::::::::::::::: # =========================================================================
;------------------------------------------------------------------------------- ; rfs_fileops.nasm - basic file operations. ;------------------------------------------------------------------------------- module tm.pathman.rfs_fileops %include "errors.ah" %include "pool.ah" %include "time.ah" %include "tm/inode.ah" %include "tm/rfs.ah" %include "rm/stat.ah" publicproc RFS_InitOCBpool externproc PoolInit, PoolAllocChunk, PoolChunkNumber, PoolChunkAddr externproc RFS_SearchForFileName externproc RFS_InsertFileName, RFS_DeleteFileName externproc RFS_AllocBlock, RFS_DeallocBlock library $libc importproc _ClockTime section .bss ?MaxOCBs RESD 1 ?OCBpool RESB tMasterPool_size section .text ; RFS_InitOCBpool - initialize OCB pool. ; Input: EAX=maximum number of OCBs. ; Output: CF=0 - OK; ; CF=1 - error, AX=error code. proc RFS_InitOCBpool mov [?MaxOCBs],eax xor ecx,ecx mov ebx,?OCBpool mov cl,tRFSOCB_size call PoolInit ret endp ;--------------------------------------------------------------- ; RFS_CreateFile - create a file. ; Input: ESI=pointer to name. ; Output: CF=0 - OK, EAX=file descriptor; ; CF=1 - error, AX=error code. proc RFS_CreateFile locauto timestamp, Qword_size locauto dirent, tDirEntry_size ; Name buffer prologue mpush ebx,ecx,edx,esi,edi mov ecx,RFS_FILENAMELEN ; Move name to stack lea edi,[%$dirent] ; call MoveNameToStack ; XXX ; jc near .Error lea esi,[%$dirent] call RFS_SearchForFileName ; See if name exists jnc near .ExistingFile ; Yes, go truncate it cmp ax,ENOENT ; Else see if not found jne near .Error ; No, service other errors call RFS_AllocBlock ; Else allocate the file block jc near .Error mov ebx,eax mBseek mov edi,esi ; Blank it to zeros xor eax,eax mov ecx,RFS_BLOCKSIZE/4 rep stosd push esi ; Move the name to it lea edi,[esi+tFileNode.Name] lea esi,[%$dirent] push esi mov ecx,RFS_FILENAMELEN / 4 rep movsd pop esi ; Save file node mov [esi+tDirEntry.Entry],ebx ; in directory entry mov byte [esi+tDirEntry.Flags],0 mov dword [esi+tDirEntry.More],0 xchg esi,[esp] mov word [esi+tFileNode.Sig],RFS_FNSignature lea eax,[%$timestamp] Ccall _ClockTime, CLOCK_REALTIME, 0, eax mov eax,[%$timestamp] mov [esi+tFileNode.IAttr+tInodeAttr.LWtime],eax mov eax,[%$timestamp+4] mov [esi+tFileNode.IAttr+tInodeAttr.LWtime+4],eax call RFS_InsertFileName ; Go insert the file name jc .Exit .OpenFile: lea esi,[%$dirent] ; Open the file call RFS_OpenFile jmp .Exit .ExistingFile: lea esi,[%$dirent] ; Existing file, open it call RFS_OpenFile mov ebx,eax ; Save filedes jc .Exit push eax call RFS_TruncateFile ; Truncate it pop ebx jnc .OK push ebx push eax call RFS_CloseFile pop ebx ; Doing a swap with pops pop eax jmp .Error .OK: mov eax,ebx jmp .Exit .Error: stc .Exit: mpop edi,esi,edx,ecx,ebx epilogue ret endp ;--------------------------------------------------------------- ; RFS_OpenFile - open a file. ; Input: ESI=pointer to name. ; Output: CF=0 - OK, EAX=file descriptor; ; CF=1 - error, AX=error code. proc RFS_OpenFile locauto dirent, tDirEntry_size ; Name buffer prologue mpush ebx,ecx,edx,esi,edi mov ecx,RFS_FILENAMELEN lea edi,[%$dirent] ; Get name to stack ; call MoveNameToStack ; XXX ; jc .Error call RFS_GetOCB ; Find a free OCB jc .Error lea esi,[%$dirent] ; Search for file push edi call RFS_SearchForFileName pop edi jc .Error mov ebx,eax mBseek ; Seek to a file block mov eax,[esi+tFileNode.Len] ; Get length to OCB mov [edi+tRFSOCB.Bytes],eax and dword [edi+tRFSOCB.Bytes],RFS_BLOCKSIZE-1 shr eax,RFS_BLOCKSHIFT mov [edi+tRFSOCB.Pages],eax mov [edi+tRFSOCB.FSaddr],edx ; FS address to OCB mov [edi+tRFSOCB.Page],ebx ; File page to OCB xor eax,eax mov [edi+tRFSOCB.PosBytes],eax ; Position = start of file mov [edi+tRFSOCB.PosPages],eax mov [edi+tRFSOCB.CurrPage],eax ; Current page not loaded mov esi,edi ; Calculate filedes call PoolChunkNumber jc .Exit .Exit: mpop edi,esi,edx,ecx,ebx epilogue ret .Error: mov dword [edi+tRFSOCB.Page],0 jmp .Exit endp ;--------------------------------------------------------------- ; RFS_CloseFile - close a file. ; Input: EBX=file descriptor. ; Output: CF=0 - OK; ; CF=1 - error, AX=error code. proc RFS_CloseFile mpush ebx,edx,esi,edi call RFS_CalcOCB ; Calculate OCB address jc .Exit mov ebx,[edi+tRFSOCB.Page] ; Seek at file page mov edx,[edi+tRFSOCB.FSaddr] mBseek mov eax,[edi+tRFSOCB.Bytes] ; Update file length mov ebx,[edi+tRFSOCB.Pages] shl ebx,RFS_BLOCKSHIFT add eax,ebx mov [esi+tFileNode.Len],eax mov dword [edi+tRFSOCB.Page],0 ; Release OCB .Exit: mpop edi,esi,edx,ebx ret endp ;--------------------------------------------------------------- ; RFS_Delete - delete a file. ; Input: ESI=pointer to file name. ; Output: CF=0 - OK, EAX=0; ; CF=1 - error, AX=error code. proc RFS_DeleteFile locauto dirent, tDirEntry_size ; Name buffer prologue mpush ebx,ecx,edx,esi,edi mov ecx,RFS_FILENAMELEN ; Move name to stack lea edi,[%$dirent] ; call MoveNameToStack ; XXX ; jc .Exit lea esi,[%$dirent] ; Search for name call RFS_SearchForFileName jc .Exit mov ebx,eax ; Truncate the file call DoTruncate jc .Exit mov eax,ebx ; Deallocate file page call RFS_DeallocBlock jc .Exit pushimm 0 ; Delete the name lea edi,[%$dirent] ; from the directory push edi call RFS_DeleteFileName jc .Exit xor eax,eax .Exit: mpop edi,esi,edx,ecx,ebx epilogue ret .Error: stc jmp .Exit endp ;--------------------------------------------------------------- ; RFS_TruncateFile - truncate a file. ; Input: EBX=file descriptor. ; Output: CF=0 - OK, EAX=0; ; CF=1 - error, AX=error code. proc RFS_TruncateFile mpush ebx,ecx,edx,esi,edi call RFS_CalcOCB ; Get OCB jc .Exit mov edx,[edi+tRFSOCB.FSaddr] mov ebx,[edi+tRFSOCB.Page] ; Truncate call DoTruncate jc .Exit xor eax,eax mov [edi+tRFSOCB.Pages],eax ; Reset position mov [edi+tRFSOCB.PosPages],eax ; and length mov [edi+tRFSOCB.Bytes],eax mov [edi+tRFSOCB.PosBytes],eax .Exit: mpop edi,esi,edx,ecx,ebx ret endp ;--------------------------------------------------------------- ; RFS_RenameFile - rename a file. ; Input: ESI=old name, ; EDI=new name. ; Output: CF=0 - OK, EAX=0; ; CF=1 - error, AX=error code. proc RFS_RenameFile locauto newdirent, tDirEntry_size ; New name locauto olddirent, tDirEntry_size ; Old name prologue mpush ebx,ecx,edx,esi,edi mov ecx,RFS_FILENAMELEN ; Move names to stack push edi lea edi,[%$olddirent] ; call MoveNameToStack pop edi ; jc .Error mov esi,edi lea edi,[%$newdirent] ; call CFS_MoveNameToStack ; jc .Error xor eax,eax mov [%$newdirent+tDirEntry.Flags],al ; Set params mov [%$newdirent+tDirEntry.More],eax ; of new entry lea esi,[%$olddirent] ; Get old entry file page call RFS_SearchForFileName jc .Exit mov [%$newdirent+tDirEntry.Entry],eax ; Save in new entry lea edi,[%$newdirent] ; Insert new file name push edi call RFS_InsertFileName jc .Exit pushimm 0 ; Delete old file name lea edi,[%$olddirent] push edi call RFS_DeleteFileName jc .Exit mov ebx,[%$newdirent+tDirEntry.Entry] ; Get the file page mBseek lea edi,[esi+tFileNode.Name] ; Change the name lea esi,[%$newdirent] ; in the file page mov ecx,RFS_FILENAMELEN/4 rep movsd .Exit: mpop edi,esi,edx,ecx,ebx epilogue ret endp ;--------------------------------------------------------------- ; RFS_ReadLong - read large number of bytes. ; Input: EBX=file descriptor, ; ECX=number of bytes to read, ; ESI=address of buffer to read. ; Output: CF=0 - OK, ECX=number of read bytes; ; CF=1 - error, AX=error code. proc RFS_ReadLong locals bytes prologue mpush ebx,edx,esi,edi mov dword [%$bytes],0 ; Bytes read = 0 .Loop: cmp ecx,RFS_BLOCKSIZE ; Just one block? jc .Last ; Yes, go do it push ecx ; Save count and position push esi mov ecx,RFS_BLOCKSIZE ; Read in a block push edx call ReadShort pop edx jc .Exit add [%$bytes],ecx ; Update read count pop esi ; Update position add esi,ecx cmp ecx,RFS_BLOCKSIZE ; See if full read pop ecx jnz .OK ; Get out if not sub ecx,RFS_BLOCKSIZE ; Decrement amount left jmp .Loop ; Loop again .Last: call ReadShort ; Read last block. Block routine ; Checks for 0 bytes jc .Exit ; Error, exit add [%$bytes],ecx ; Add number of bytes read to rv .OK: clc .Exit: mov ecx,[%$bytes] mpop edi,esi,edx,ebx epilogue ret endp ;--------------------------------------------------------------- ; RFS_WriteLong - write large number of bytes. ; Input: EBX=file descriptor, ; ECX=number of bytes, ; ESI=address of buffer to write. ; Output: CF=0 - OK, ECX=number of bytes written; ; CF=1 - error, AX=error code. proc RFS_WriteLong locals bytes prologue mpush ebx,edx,esi,edi mov dword [%$bytes],0 ; Bytes written = 0 .Loop: cmp ecx,RFS_BLOCKSIZE ; Just one block? jc .Last ; Yeah, go do it push ecx ; Save count and position push esi mov ecx,RFS_BLOCKSIZE ; Write in a block call WriteShort jc .Exit ; Exit if error add [%$bytes],ecx ; Else update write count pop esi ; Update position add esi,ecx pop ecx ; Decrement amount left sub ecx,RFS_BLOCKSIZE jmp .Loop ; Loop again .Last: call WriteShort ; Write last block. Block routine ; Checks for 0 bytes jc .Exit ; Error, get out add [%$bytes],ecx ; Add number of bytes Written to rv clc .Exit: mov ecx,[%$bytes] mpop edi,esi,edx,ebx epilogue ret endp ;--------------------------------------------------------------- ; RFS_SetFilePos - set file position. ; Input: EBX=file descriptor, ; ECX=offset, ; DL=origin (0=begin, 1=current position, 2=end). ; Output: CF=0 - OK, EAX=new position; ; CF=1 - error, AX=error code. proc RFS_SetFilePos push ecx call RFS_CalcOCB ; Calculate OCB jc .Exit or dl,dl jz .FromBegin dec dl jnz .FromEnd mov eax,[edi+tRFSOCB.PosPages] ; Get org position shl eax,RFS_BLOCKSHIFT or eax,[edi+tRFSOCB.PosBytes] add ecx,eax jmp .FromBegin .FromEnd: mov eax,[edi+tRFSOCB.Pages] ; Get org position shl eax,RFS_BLOCKSHIFT or eax,[edi+tRFSOCB.Bytes] add ecx,eax .FromBegin: mov eax,[edi+tRFSOCB.Pages] ; Get org position shl eax,RFS_BLOCKSHIFT or eax,[edi+tRFSOCB.Bytes] cmp ecx,eax jb .DoLoad mov ecx,eax .DoLoad: mov [edi+tRFSOCB.PosBytes],ecx ; Set new position and dword [edi+tRFSOCB.PosBytes],RFS_BLOCKSIZE-1 shr ecx,RFS_BLOCKSHIFT mov [edi+tRFSOCB.PosPages],ecx mov dword [edi+tRFSOCB.CurrPage],0 mov eax,ecx clc .Exit: pop ecx ret endp ;--------------------------------------------------------------- ; RFS_GetFilePos - get file position. ; Input: EBX=file descriptor. ; Output: CF=0 - OK, ECX=file position; ; CF=1 - error, AX=error code. proc RFS_GetFilePos call RFS_CalcOCB ; Get OCB address jc .Exit mov ecx,[edi+tRFSOCB.PosPages] ; Load position shl ecx,RFS_BLOCKSHIFT or ecx,[edi+tRFSOCB.PosBytes] clc .Exit: ret endp ;--------------------------------------------------------------- ; RFS_GoEOF - Go to end of file. ; Input: EBX=file descriptor. ; Output: CF=0 - OK; ; CF=1 - error, AX=error code. proc RFS_GoEOF call RFS_CalcOCB ; Calculate OCB jc .Exit mov eax,[edi+tRFSOCB.Page] ; Position to end mov [edi+tRFSOCB.PosPages],eax mov eax,[edi+tRFSOCB.Bytes] mov [edi+tRFSOCB.PosBytes],eax .Exit: ret endp ;--------------------------------------------------------------- ; RFS_SetFileAttr - set file attributes. ; Input: ; Output: proc RFS_SetFileAttr ret endp ;--------------------------------------------------------------- ; RFS_GetFileAttr - set file attributes. ; Input: ; Output: proc RFS_GetFileAttr ret endp ;--------------------------------------------------------------- ; --- Implementation routines --- ; Get an OCB. ; Input: none. ; Output: CF=0 - OK, EDI=OCB address; ; CF=1 - error, AX=error code. proc RFS_GetOCB push ebx mov ebx,?OCBpool call PoolAllocChunk jc .Exit mov edi,esi .Exit: pop ebx ret endp ;--------------------------------------------------------------- ; RFS_CalcOCB - calculate OCB address from file descriptor. ; Input: EBX=file descriptor. ; Output: CF=0 - OK, EDI=OCB address; ; CF=1 - error, AX=error code. proc RFS_CalcOCB mpush ebx,esi mov eax,ebx mov ebx,?OCBpool call PoolChunkAddr jc .Exit mov edi,esi .Exit: mpop esi,ebx ret endp ;--------------------------------------------------------------- ; RFS_CalcBlock - calculate block to read or write at. ; Input: EDI=OCB address. ; Output: CF=0 - OK, ESI=block address; ; CF=1 - error, AX=error code. proc RFS_CalcBlock mov ebx,[edi+tRFSOCB.Page] ; Read file page mov edx,[edi+tRFSOCB.FSaddr] mBseek mov eax,[edi+tRFSOCB.PosPages] ; See if within direct entries cmp eax,RFS_FNDirectEntries jc .Single ; Yes - get block directly sub eax,RFS_FNDirectEntries ; Else offset to first indir entry push eax shr eax,RFS_BLOCKSHIFT-2 ; Divide by Entries per page mov ebx,[esi+eax*4+tFileNode.Doubles] ; Find indir page mBseek pop eax and eax,RFS_BLOCKSIZE/4-1 ; Mod is entry this page mov ebx,[esi+eax*4] ; Target is indicated page jmp .ReadTarget .Single: mov ebx,[esi+eax*4+tFileNode.Singles] ; Read from direct entry table .ReadTarget: mov [edi+tRFSOCB.CurrPage],ebx ; Save as current page mBseek clc .Exit: ret endp ;--------------------------------------------------------------- ; Truncate a file. ; Input: EDX=file system address,linkpoint number, ; EBX=file page starting block number. ; Output: CF=0 - OK; ; CF=1 - error, AX=error code. proc DoTruncate push ecx mBseek mov dword [esi+tFileNode.Len],0 ; Mark len 0 mov ecx,RFS_FNDirectEntries-1 ; Number of direct entries to run through .Singles: mov eax,[esi+4*ecx+tFileNode.Singles] ; Current entry or eax,eax ; Zero entry is unallocated jz .SNoDeall mov dword [esi+4*ecx+tFileNode.Singles],0 ; Else mark unallocated call RFS_DeallocBlock ; Deallocate jc .Exit .SNoDeall: dec ecx ; Next entry jns .Singles mov ecx,RFS_FNIndirEntries-1 ; Number of indirect entries to run through .Doubles: mpush ebx,ecx ; Save file page mov ebx,[esi+4*ecx+tFileNode.Doubles] ; Get a double or ebx,ebx ; If none allocated - jz .NoDoubleDeall ; don't deallocate mov dword [esi+4*ecx+tFileNode.Doubles],0 ; Get entry mBseek mov eax,ebx ; Deallocate the block itself call RFS_DeallocBlock jc .Exit mov ecx,RFS_BLOCKSIZE/4 ; Number of items in a block .DoubleDeall: mov eax,[esi+4*ecx] ; Get one or eax,eax jz .TNoDeall ; Don't deallocate if not allocated mov dword [esi+4*ecx],0 ; Else mark deallocated call RFS_DeallocBlock ; And deallocate it jc .Exit .TNoDeall: dec ecx ; Next item this block jns .DoubleDeall .NoDoubleDeall: mpop ecx,ebx ; Back to file page mBseek dec ecx ; Next indirect buffer jns .Doubles clc jmp .Exit .Exit: push ecx ret endp ;--------------------------------------------------------------- ; RFS_CalcPosLen - calculate position to read or write at, ; and length to read or write. ; Input: EDI=pointer to OCB. ; Output: CF=0 - OK: ; ESI=position (address), ; ECX=length; ; CF=1 - error, AX=error code. proc RFS_CalcPosLen mpush ebx,edi mov ebx,[edi+tRFSOCB.CurrPage] ; Page number cached? or ebx,ebx jz .ReadPage ; No - go calculate mov edx,[edi+tRFSOCB.FSaddr] ; Else read cached page mBseek jmp .GotPage .ReadPage: call RFS_CalcBlock ; Calculate page jc .Exit .GotPage: add esi,[edi+tRFSOCB.PosBytes] ; Calculate amount left mov eax,RFS_BLOCKSIZE sub eax,[edi+tRFSOCB.PosBytes] cmp eax,ecx ; Greater than request? jc .RestOfBuf mov eax,ecx ; Yes, use request .RestOfBuf: add [edi+tRFSOCB.PosBytes],eax ; Update position cmp dword [edi+tRFSOCB.PosBytes],RFS_BLOCKSIZE ; See if at end jc .NotNew mov dword [edi+tRFSOCB.CurrPage],0 ; No cached page sub dword [edi+tRFSOCB.PosBytes],RFS_BLOCKSIZE ; Update position inc dword [edi+tRFSOCB.PosPages] ; to next block .NotNew: clc .Exit: mpop edi,ebx ret endp ;--------------------------------------------------------------- ; Read from file <=RFS_BLOCKSIZE bytes. ; Input: EBX=file descriptor, ; ECX=number of bytes to read, ; ESI=address of buffer where to read. ; Output: CF=0 - OK; ; CF=1 - error, AX=error code. proc ReadShort cmp ecx,RFS_BLOCKSIZE ; Exit if request too big ja .Error1 or ecx,ecx jz .Done2 call RFS_CalcOCB ; Calculate OCB jc .Error push ebx mov ebx,[edi+tRFSOCB.PosPages] ; Calculate amount left shl ebx,RFS_BLOCKSHIFT or ebx,[edi+tRFSOCB.PosBytes] mov eax,[edi+tRFSOCB.Pages] shl eax,RFS_BLOCKSHIFT or eax,[edi+tRFSOCB.Bytes] sub eax,ebx pop ebx cmp eax,ecx ; See if enough jnc .SizeOK ; to satisfy request mov ecx,eax ; No, lower request .SizeOK: or ecx,ecx ; See if any to get jz .EOF ; EOF if none mov ebx,esi push ecx ; Push total length call RFS_CalcPosLen ; Get position jc .Error2 mpush ecx,edi ; Move to user buffer mov ecx,eax mov edi,ebx rep movsb mpop edi,ecx sub ecx,eax ; Subtract length moved jz .Done ; Quit if done call RFS_CalcPosLen ; Get position to read from jc .Error2 mov edi,ebx ; Move to user buffer mov ecx,eax rep movsb .Done: pop ecx ; Restore length of request .Done2: clc ret .Error2: pop ecx jmp .Error .Error1: mov ax,EINVAL .Error: stc ret .EOF: xor ecx,ecx ; EOF returns a zero count ret endp ;--------------------------------------------------------------- ; Write to file <=RFS_BLOCKSIZE bytes. ; Input: EBX=file descriptor, ; ECX=number of bytes to read. ; Output: CF=0 - OK; ; CF=1 - error, AX=error code. proc WriteShort locals len, ueof ; Extending EOF if true prologue mpush ebx,edx cmp ecx,RFS_BLOCKSIZE ; Get out if too big request ja near .Err1 mov dword [%$ueof],0 ; Assume not extending EOF mov [%$len],ecx or ecx,ecx ; Quit if no request jz near .Done call RFS_CalcOCB ; Calculate OCB jc near .Exit mov edx,[edi+tRFSOCB.FSaddr] mov eax,[edi+tRFSOCB.Pages] ; See if extending shl eax,RFS_BLOCKSHIFT add eax,[edi+tRFSOCB.Bytes] mov ebx,[edi+tRFSOCB.PosPages] shl ebx,RFS_BLOCKSHIFT add ebx,[edi+tRFSOCB.PosBytes] add ebx,ecx cmp eax,ebx jnc .ToMiddle ; No, write to middle inc byte [%$ueof] ; Else extending EOF push dword [edi+tRFSOCB.PosPages] ; Save position push dword [edi+tRFSOCB.PosBytes] mov eax,[edi+tRFSOCB.PosBytes] add [edi+tRFSOCB.PosBytes],ecx ; Find last page or eax,eax jz .Alloc cmp dword [edi+tRFSOCB.PosBytes],RFS_BLOCKSIZE cmc jae .NoAlloc inc dword [edi+tRFSOCB.PosPages] .Alloc: call RFS_ExtendFile ; Allocate the page .NoAlloc: pop dword [edi+tRFSOCB.PosBytes] ; Restore position pop dword [edi+tRFSOCB.PosPages] jc .Exit .ToMiddle: mov ebx,esi call RFS_CalcPosLen ; Get position to write to jc .Exit mpush ecx,esi,edi ; Move data from user buffer mov edi,esi mov esi,ebx mov ecx,eax rep movsb mpop edi,esi,ecx sub ecx,eax ; Subtract amount moved jz .Done ; Get out if done call RFS_CalcPosLen ; Get position to write to jc .Exit mpush esi,edi mov ecx,eax ; Write data from user buffer mov edi,esi mov esi,ebx rep movsb mpop edi,esi .Done: mov ecx,[%$len] ; Get length moved test byte [%$ueof],-1 ; See if changing EOF jz .OK ; No, exit mov ebx,[edi+tRFSOCB.Page] ; Read file page mBseek mov eax,[edi+tRFSOCB.PosPages] ; Get final position mov [edi+tRFSOCB.Pages],eax ; Update OCB len mov ebx,eax shl ebx,RFS_BLOCKSHIFT mov eax,[edi+tRFSOCB.PosBytes] mov [edi+tRFSOCB.Bytes],eax or ebx,eax mov [esi+tFileNode.Len],ebx ; Update file page len .OK: clc .Exit: mpop edx,ebx epilogue ret .Err1: mov ax,EINVAL stc jmp .Exit endp ;--------------------------------------------------------------- ; RFS_ExtendFile - extend a file by one page. ; Input: EDI=address of OCB. ; Output: CF=0 - OK; ; CF=1 - error, AX=error code. proc RFS_ExtendFile locals ieofs prologue mpush ebx,ecx,esi mov ebx,[edi+tRFSOCB.Page] ; Read file page mov edx,[edi+tRFSOCB.FSaddr] mBseek mov eax,[edi+tRFSOCB.PosPages] ; Get position to allocate at cmp eax,RFS_FNDirectEntries ; See if in direct entries jc .Single sub eax,RFS_FNDirectEntries ; No, offset to first indir entry mov [%$ieofs],eax shr eax,RFS_BLOCKSHIFT-2 lea ebx,[esi+eax*4+tFileNode.Doubles] ; Point at relevant indir entry test dword [ebx],-1 ; See if allocated jnz .NoAlloc ; Yes, don't allocate call RFS_AllocBlock ; No, allocate jc .Exit mov [ebx],eax ; Save allocated mov ebx,eax ; Get allocated page mpush ecx,edi mov edi,esi ; Zero it out xor eax,eax mov ecx,RFS_BLOCKSIZE/4 rep stosd mpop edi,ecx jmp .NoAlloc2 .NoAlloc: mov ebx,[ebx] ; Get previously allocated indir block .NoAlloc2: mBseek ; Seek at it mov eax,[%$ieofs] and eax,RFS_BLOCKSIZE/4-1 ; Find the entry in it lea ebx,[esi+eax*4] ; Point to it jmp .ReadTarget .Single: lea ebx,[esi+eax*4+tFileNode.Singles] ; Point to singles entry .ReadTarget: mov eax,[ebx] ; Get it or eax,eax ; Already allocated? jnz .OK ; Yes - get out call RFS_AllocBlock ; Otherwise allocate mov [ebx],eax ; Save allocated block .OK: clc .Exit: mpop esi,ecx,ebx epilogue ret endp ;---------------------------------------------------------------
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/android/compositor/layer/content_layer.h" #include "base/lazy_instance.h" #include "cc/base/filter_operations.h" #include "cc/layers/layer.h" #include "cc/layers/layer_collections.h" #include "cc/layers/surface_layer.h" #include "chrome/browser/android/compositor/layer/thumbnail_layer.h" #include "chrome/browser/android/compositor/tab_content_manager.h" #include "content/public/browser/android/compositor.h" #include "ui/gfx/geometry/size.h" namespace android { // static scoped_refptr<ContentLayer> ContentLayer::Create( TabContentManager* tab_content_manager) { return make_scoped_refptr(new ContentLayer(tab_content_manager)); } static void SetOpacityOnLeaf(scoped_refptr<cc::Layer> layer, float alpha) { const cc::LayerList& children = layer->children(); if (children.size() > 0) { layer->SetOpacity(1.0f); for (uint i = 0; i < children.size(); ++i) SetOpacityOnLeaf(children[i], alpha); } else { layer->SetOpacity(alpha); } } static cc::Layer* GetDrawsContentLeaf(scoped_refptr<cc::Layer> layer) { if (!layer.get()) return nullptr; // If the subtree is hidden, then any layers in this tree will not be drawn. if (layer->hide_layer_and_subtree()) return nullptr; if (layer->opacity() == 0.0f) return nullptr; if (layer->DrawsContent()) return layer.get(); const cc::LayerList& children = layer->children(); for (unsigned i = 0; i < children.size(); i++) { cc::Layer* leaf = GetDrawsContentLeaf(children[i]); if (leaf) return leaf; } return nullptr; } void ContentLayer::SetProperties(int id, bool can_use_live_layer, float static_to_view_blend, bool should_override_content_alpha, float content_alpha_override, float saturation, bool should_clip, const gfx::Rect& clip) { scoped_refptr<cc::Layer> live_layer = tab_content_manager_->GetLiveLayer(id); if (live_layer) live_layer->SetHideLayerAndSubtree(!can_use_live_layer); bool live_layer_draws = GetDrawsContentLeaf(live_layer); scoped_refptr<ThumbnailLayer> static_layer = tab_content_manager_->GetOrCreateStaticLayer(id, !live_layer_draws); float content_opacity = should_override_content_alpha ? content_alpha_override : 1.0f; float static_opacity = should_override_content_alpha ? content_alpha_override : 1.0f; if (live_layer_draws) static_opacity = static_to_view_blend; const cc::LayerList& layer_children = layer_->children(); for (unsigned i = 0; i < layer_children.size(); i++) layer_children[i]->RemoveFromParent(); if (live_layer.get()) { live_layer->SetMasksToBounds(should_clip); live_layer->SetBounds(clip.size()); SetOpacityOnLeaf(live_layer, content_opacity); layer_->AddChild(live_layer); } if (static_layer.get()) { static_layer->layer()->SetIsDrawable(true); if (should_clip) static_layer->Clip(clip); else static_layer->ClearClip(); SetOpacityOnLeaf(static_layer->layer(), static_opacity); cc::FilterOperations static_filter_operations; if (saturation < 1.0f) { static_filter_operations.Append( cc::FilterOperation::CreateSaturateFilter(saturation)); } static_layer->layer()->SetFilters(static_filter_operations); layer_->AddChild(static_layer->layer()); } } gfx::Size ContentLayer::ComputeSize(int id) const { gfx::Size size; scoped_refptr<cc::Layer> live_layer = tab_content_manager_->GetLiveLayer(id); cc::SurfaceLayer* surface_layer = static_cast<cc::SurfaceLayer*>(GetDrawsContentLeaf(live_layer)); if (surface_layer) size.SetToMax(surface_layer->primary_surface_info().size_in_pixels()); scoped_refptr<ThumbnailLayer> static_layer = tab_content_manager_->GetStaticLayer(id); if (static_layer.get() && GetDrawsContentLeaf(static_layer->layer())) size.SetToMax(static_layer->layer()->bounds()); return size; } scoped_refptr<cc::Layer> ContentLayer::layer() { return layer_; } ContentLayer::ContentLayer(TabContentManager* tab_content_manager) : layer_(cc::Layer::Create()), tab_content_manager_(tab_content_manager) {} ContentLayer::~ContentLayer() { } } // namespace android
#pragma once #include <Engine/Scene/ItemEntry.hpp> #include <Engine/Scene/System.hpp> namespace Ra { namespace Engine { namespace Scene { /** * The SkeletonBasedAnimationSystem manages both SkeletonComponents and SkinningComponents. * It is also responsible for transmitting calls to/from animation-related processes. */ class RA_ENGINE_API SkeletonBasedAnimationSystem : public System { public: /// Create a new animation system SkeletonBasedAnimationSystem(); SkeletonBasedAnimationSystem( const SkeletonBasedAnimationSystem& ) = delete; SkeletonBasedAnimationSystem& operator=( const SkeletonBasedAnimationSystem& ) = delete; /// \name System Interface /// \{ /// Creates a task for each AnimationComponent to update skeleton display. void generateTasks( Core::TaskQueue* taskQueue, const FrameInfo& frameInfo ) override; /// Loads Skeletons and Animations from a file data into the givn Entity. void handleAssetLoading( Entity* entity, const Core::Asset::FileData* fileData ) override; /// \} /// \name Skeleton display /// \{ /// Sets bone display xray mode to \p on for all AnimationComponents. void setXray( bool on ); /// Returns true if bone display xray mode on, false otherwise. bool isXrayOn(); /// Toggles skeleton display for all AnimationComponents. void toggleSkeleton( const bool status ); /// \} /// Enforce Skeleton update at the next frame. inline void enforceUpdate() { m_time = -1; } private: /// True if we want to show xray-bones. bool m_xrayOn {false}; /// The current animation time. Scalar m_time {0_ra}; }; } // namespace Scene } // namespace Engine } // namespace Ra
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r14 push %r8 push %rbp push %rcx push %rdi push %rsi lea addresses_WT_ht+0x1be9c, %r12 nop nop nop nop nop inc %rbp mov (%r12), %r8 nop dec %r11 lea addresses_WT_ht+0x2c7c, %rsi lea addresses_D_ht+0x198bc, %rdi clflush (%rsi) clflush (%rdi) nop xor %r14, %r14 mov $109, %rcx rep movsl add %rdi, %rdi lea addresses_normal_ht+0xbcbc, %rsi lea addresses_WC_ht+0x13400, %rdi nop dec %rbp mov $108, %rcx rep movsq nop nop nop nop nop and %r14, %r14 lea addresses_D_ht+0x19134, %rsi lea addresses_normal_ht+0x99c1, %rdi nop nop nop nop sub %rbp, %rbp mov $49, %rcx rep movsq nop nop nop nop nop xor $45129, %r11 lea addresses_UC_ht+0x19cbc, %rsi nop nop nop nop inc %rdi movups (%rsi), %xmm4 vpextrq $1, %xmm4, %r12 nop nop nop nop nop dec %rdi lea addresses_D_ht+0x1c79c, %r8 clflush (%r8) add %r12, %r12 movups (%r8), %xmm0 vpextrq $0, %xmm0, %rbp add %r14, %r14 lea addresses_WT_ht+0x178bc, %rsi xor $31209, %r14 mov (%rsi), %edi and %rcx, %rcx pop %rsi pop %rdi pop %rcx pop %rbp pop %r8 pop %r14 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r13 push %r15 push %r9 push %rbp push %rcx push %rdi push %rsi // Store lea addresses_UC+0x18d5c, %r15 nop nop nop nop xor %rdi, %rdi movb $0x51, (%r15) nop xor %rdi, %rdi // Store lea addresses_WC+0x19c3c, %rcx nop nop nop xor %r9, %r9 mov $0x5152535455565758, %r15 movq %r15, %xmm6 vmovups %ymm6, (%rcx) nop and $38171, %rcx // REPMOV lea addresses_A+0xdabc, %rsi lea addresses_RW+0x1225c, %rdi nop nop and %r13, %r13 mov $21, %rcx rep movsw nop nop nop xor $18265, %rsi // Faulty Load lea addresses_D+0x1c8bc, %r11 nop nop nop nop cmp $50638, %rsi vmovups (%r11), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %rbp lea oracles, %rsi and $0xff, %rbp shlq $12, %rbp mov (%rsi,%rbp,1), %rbp pop %rsi pop %rdi pop %rcx pop %rbp pop %r9 pop %r15 pop %r13 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'} {'dst': {'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 4, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 6, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'} {'src': {'congruent': 9, 'same': False, 'type': 'addresses_A'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_RW'}, 'OP': 'REPM'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_D'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 5, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_WT_ht'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'src': {'congruent': 9, 'same': True, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM'} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 4, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'36': 9165} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
/* The smooth Class Library * Copyright (C) 1998-2019 Robert Kausch <robert.kausch@gmx.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of "The Artistic License, Version 2.0". * * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include <smooth/gui/widgets/basic/multiedit.h> #include <smooth/gui/widgets/special/cursor.h> #include <smooth/gui/widgets/basic/scrollbar.h> #include <smooth/gui/widgets/layer.h> #include <smooth/misc/binary.h> #include <smooth/misc/math.h> #include <smooth/graphics/surface.h> #include <smooth/gui/window/window.h> const S::Short S::GUI::MultiEdit::classID = S::Object::RequestClassID(); S::GUI::MultiEdit::MultiEdit(const Point &iPos, const Size &iSize, Int maxSize) : Widget(iPos, iSize) { type = classID; scrollbar = NIL; scrollbarPos = 0; font.SetColor(Setup::ClientTextColor); if (GetWidth() == 0) SetWidth(80); if (GetHeight() == 0) SetHeight(19); cursor = new Cursor(Point(3, Math::Ceil(Float(19 - font.GetUnscaledTextSizeY()) / 2) - 2), GetSize() - Size(6, Math::Ceil(Float(19 - font.GetUnscaledTextSizeY()) / 2) - 1)); cursor->onScroll.Connect(&MultiEdit::OnCursorScroll, this); cursor->SetMaxSize(maxSize); cursor->SetBackgroundColor(Setup::ClientColor); cursor->SetFlags(CF_MULTILINE); cursor->SetFont(font); cursor->onInput.Connect(&onInput); Add(cursor); onInput.SetParentObject(this); onChangeSize.Connect(&MultiEdit::OnChangeSize, this); onLoseFocus.Connect(&cursor->onLoseFocus); } S::GUI::MultiEdit::MultiEdit(const String &iText, const Point &iPos, const Size &iSize, Int maxSize) : Widget(iPos, iSize) { type = classID; scrollbar = NIL; scrollbarPos = 0; font.SetColor(Setup::ClientTextColor); if (GetWidth() == 0) SetWidth(80); if (GetHeight() == 0) SetHeight(19); cursor = new Cursor(Point(3, Math::Ceil(Float(19 - font.GetUnscaledTextSizeY()) / 2) - 2), GetSize() - Size(6, Math::Ceil(Float(19 - font.GetUnscaledTextSizeY()) / 2) - 1)); cursor->onScroll.Connect(&MultiEdit::OnCursorScroll, this); cursor->SetMaxSize(maxSize); cursor->SetBackgroundColor(Setup::ClientColor); cursor->SetFlags(CF_MULTILINE); cursor->SetFont(font); cursor->SetText(iText); cursor->onInput.Connect(&onInput); Add(cursor); onInput.SetParentObject(this); onChangeSize.Connect(&MultiEdit::OnChangeSize, this); onLoseFocus.Connect(&cursor->onLoseFocus); } S::GUI::MultiEdit::~MultiEdit() { DeleteObject(cursor); if (scrollbar != NIL) DeleteObject(scrollbar); } S::Int S::GUI::MultiEdit::Paint(Int message) { if (!IsRegistered()) return Error(); if (!IsVisible()) return Success(); switch (message) { case SP_PAINT: { Surface *surface = GetDrawSurface(); Rect frame = Rect(GetRealPosition(), GetRealSize()); Color backgroundColor = IsActive() ? Setup::ClientColor : Setup::BackgroundColor; surface->StartPaint(GetVisibleArea()); cursor->SetBackgroundColor(backgroundColor); surface->Box(frame, backgroundColor, Rect::Filled); surface->Frame(frame, FRAME_DOWN); Widget::Paint(message); surface->EndPaint(); return Success(); } } return Widget::Paint(message); } S::Int S::GUI::MultiEdit::GetNOfLines() { Int lines = 1; Int length = text.Length(); for (Int i = 0; i < length; i++) { if (text[i] == '\n') lines++; } return lines; } S::Int S::GUI::MultiEdit::GetNOfInvisibleLines() { static Int lineSize = font.GetUnscaledTextSizeY() + 1; return 1 + GetNOfLines() - Math::Floor((GetHeight() - 6) / lineSize); } S::Int S::GUI::MultiEdit::SetText(const String &newText) { scrollbarPos = 0; cursor->SetVisibleDirect(False); cursor->SetText(newText); cursor->SetVisibleDirect(True); if (IsVisible()) Paint(SP_PAINT); return Success(); } S::Void S::GUI::MultiEdit::OnScroll() { cursor->Scroll(scrollbarPos); } S::Void S::GUI::MultiEdit::OnCursorScroll(Int scrollPos, Int maxScrollPos) { if (maxScrollPos == 0 && scrollbar != NIL) { DeleteObject(scrollbar); scrollbar = NIL; cursor->SetWidth(cursor->GetWidth() + 17); Paint(SP_PAINT); } else if (scrollbar == NIL) { cursor->SetWidth(cursor->GetWidth() - 17); scrollbar = new Scrollbar(Point(18, 1), Size(0, GetHeight() - 2), OR_VERT, &scrollbarPos, 0, maxScrollPos); scrollbar->onValueChange.Connect(&MultiEdit::OnScroll, this); scrollbar->SetOrientation(OR_UPPERRIGHT); scrollbar->SetAlwaysActive(True); Add(scrollbar); Paint(SP_PAINT); } else { scrollbar->SetRange(0, maxScrollPos); scrollbar->SetValue(scrollPos); } } S::Void S::GUI::MultiEdit::OnChangeSize(const Size &nSize) { if (scrollbar != NIL) scrollbar->SetHeight(nSize.cy - 2); cursor->SetSize(nSize - Size(6 + (scrollbar != NIL ? 17 : 0), Math::Ceil(Float(19 - font.GetUnscaledTextSizeY()) / 2) - 1)); }
include common.inc ; ; Extern functions. ; EXTRN AvmRdtscEmulationTrap0D:PROC EXTRN AvmpRdtscEmulationTrap0DOriginalHandler:QWORD ; ; ; ------------------------------------------------------------------- ; ; CODE SECTION ; ; ------------------------------------------------------------------- ; ; ; .CODE AvmpRdtscEmulationTrap0D PROC PUBLIC TRAP_ENTRY ; ; Call our new trap function. ; mov rcx, rsp ; set first parameter sub rsp, 32 ; shadow space call AvmRdtscEmulationTrap0D add rsp, 32 ; shadow space ; ; If our trap did not handle the fault, ; pass it to the original trap handler. ; cmp rax, 0 jz OldHandler ; ; Fault has been handled, ; return from the interrupt handler. ; TRAP_END add rsp, 8 iretq OldHandler: TRAP_END jmp qword ptr [AvmpRdtscEmulationTrap0DOriginalHandler] AvmpRdtscEmulationTrap0D ENDP END
db 0 ; species ID placeholder db 90, 100, 90, 90, 125, 85 ; hp atk def spd sat sdf db FIRE, FLYING ; type db 3 ; catch rate db 217 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_UNKNOWN ; gender ratio db 100 ; unknown 1 db 80 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/moltres/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_SLOW ; growth rate dn EGG_NONE, EGG_NONE ; egg groups ; tm/hm learnset tmhm CURSE, ROAR, TOXIC, ROCK_SMASH, SUNNY_DAY, SNORE, HYPER_BEAM, PROTECT, RAIN_DANCE, RETURN, FEATHERDANCE, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SANDSTORM, FIRE_BLAST, SWIFT, PURSUIT, REST, STEEL_WING, FLY, FLAMETHROWER ; end
#ifndef BOOST_MPL_IF_HPP_INCLUDED #define BOOST_MPL_IF_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2000-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/mpl for documentation. // $Id$ // $Date$ // $Revision$ #include <boost/mpl/aux_/value_wknd.hpp> #include <boost/mpl/aux_/static_cast.hpp> #include <boost/mpl/aux_/na_spec.hpp> #include <boost/mpl/aux_/lambda_support.hpp> #include <boost/mpl/aux_/config/integral.hpp> #include <boost/mpl/aux_/config/ctps.hpp> #include <boost/mpl/aux_/config/workaround.hpp> namespace geofeatures_boost {} namespace boost = geofeatures_boost; namespace geofeatures_boost { namespace mpl { #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template< bool C , typename T1 , typename T2 > struct if_c { typedef T1 type; }; template< typename T1 , typename T2 > struct if_c<false,T1,T2> { typedef T2 type; }; // agurt, 05/sep/04: nondescriptive parameter names for the sake of DigitalMars // (and possibly MWCW < 8.0); see http://article.gmane.org/gmane.comp.lib.boost.devel/108959 template< typename BOOST_MPL_AUX_NA_PARAM(T1) , typename BOOST_MPL_AUX_NA_PARAM(T2) , typename BOOST_MPL_AUX_NA_PARAM(T3) > struct if_ { private: // agurt, 02/jan/03: two-step 'type' definition for the sake of aCC typedef if_c< #if defined(BOOST_MPL_CFG_BCC_INTEGRAL_CONSTANTS) BOOST_MPL_AUX_VALUE_WKND(T1)::value #else BOOST_MPL_AUX_STATIC_CAST(bool, BOOST_MPL_AUX_VALUE_WKND(T1)::value) #endif , T2 , T3 > almost_type_; public: typedef typename almost_type_::type type; BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(T1,T2,T3)) }; #else // no partial class template specialization namespace aux { template< bool C > struct if_impl { template< typename T1, typename T2 > struct result_ { typedef T1 type; }; }; template<> struct if_impl<false> { template< typename T1, typename T2 > struct result_ { typedef T2 type; }; }; } // namespace aux template< bool C_ , typename T1 , typename T2 > struct if_c { typedef typename aux::if_impl< C_ > ::template result_<T1,T2>::type type; }; // (almost) copy & paste in order to save one more // recursively nested template instantiation to user template< typename BOOST_MPL_AUX_NA_PARAM(C_) , typename BOOST_MPL_AUX_NA_PARAM(T1) , typename BOOST_MPL_AUX_NA_PARAM(T2) > struct if_ { enum { msvc_wknd_ = BOOST_MPL_AUX_MSVC_VALUE_WKND(C_)::value }; typedef typename aux::if_impl< BOOST_MPL_AUX_STATIC_CAST(bool, msvc_wknd_) > ::template result_<T1,T2>::type type; BOOST_MPL_AUX_LAMBDA_SUPPORT(3,if_,(C_,T1,T2)) }; #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION BOOST_MPL_AUX_NA_SPEC(3, if_) }} #endif // BOOST_MPL_IF_HPP_INCLUDED
/* //@HEADER // ************************************************************************ // // KokkosKernels 0.9: Linear Algebra and Graph Kernels // Copyright 2017 Sandia Corporation // // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, // the U.S. Government retains certain rights in this software. // // 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 Corporation nor the names of the // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "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 SANDIA CORPORATION OR THE // 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. // // Questions? Contact Siva Rajamanickam (srajama@sandia.gov) // // ************************************************************************ //@HEADER */ #define KOKKOSKERNELS_IMPL_COMPILE_LIBRARY true #include "KokkosKernels_config.h" #if defined (KOKKOSKERNELS_INST_DOUBLE) \ && defined (KOKKOSKERNELS_INST_LAYOUTRIGHT) \ && defined (KOKKOSKERNELS_INST_EXECSPACE_OPENMP) \ && defined (KOKKOSKERNELS_INST_MEMSPACE_HBWSPACE) #include "KokkosBlas1_nrm2w_spec.hpp" namespace KokkosBlas { namespace Impl { KOKKOSBLAS1_NRM2W_MV_ETI_SPEC_INST(double, Kokkos::LayoutRight, Kokkos::OpenMP, Kokkos::Experimental::HBWSpace) } // Impl } // KokkosBlas #endif
#include "Mcu.inc" #include "FarCalls.inc" #include "Door.inc" #include "TestFixture.inc" #include "../PollAfterDoorMock.inc" radix decimal PollChainTest code global testArrange testArrange: fcall initialisePollAfterDoorMock fcall initialiseDoor testAct: fcall pollDoor testAssert: banksel calledPollAfterDoor .assert "calledPollAfterDoor != 0, 'Next poll in chain was not called.'" return end
; Echo program that waits for user to enter a character and than echoing it. ; NASM assembly for Mac OS X x64. section .data msg_enter: db "Please, enter a char: " .len: equ $ - msg_enter msg_entered: db "You have entered: " .len: equ $ - msg_entered section .bss char: resb 1 ; reserve one byte for one char section .text global _main _main: ; show message mov rax, 0x2000004 ; put the write-system-call-code into register rax mov rdi, 1 ; tell kernel to use stdout mov rsi, msg_enter ; rsi is where the kernel expects to find the address of the message mov rdx, msg_enter.len ; and rdx is where the kernel expects to find the length of the message syscall ; read char mov rax, 0x2000003 ; put the read-system-call-code into register rax mov rdi, 0 ; tell kernel to use stdin mov rsi, char ; address of storage, declared in section .bss mov rdx, 2 ; get 2 bytes from the kernel's buffer (one for the carriage return) syscall ; show message mov rax, 0x2000004 ; put the write-system-call-code into register rax mov rdi, 1 ; tell kernel to use stdout mov rsi, msg_entered ; rsi is where the kernel expects to find the address of the message mov rdx, msg_entered.len ; and rdx is where the kernel expects to find the length of the message syscall ; show char mov rax, 0x2000004 ; put the write-system-call-code into register rax mov rdi, 1 ; tell kernel to use stdout mov rsi, char ; address of storage of char mov rdx, 2 ; the second byte is to apply the carriage return expected in the string syscall ; exit system call mov rax, 0x2000001 ; exit system call xor rdi, rdi ; equivalent to "mov rdi, 0", however xor is preferred pattern on modern ; CPUs syscall
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r15 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_UC_ht+0x2a73, %rsi lea addresses_D_ht+0x1b073, %rdi clflush (%rdi) nop nop nop nop nop sub %rbp, %rbp mov $55, %rcx rep movsq nop nop nop nop and %r12, %r12 lea addresses_A_ht+0x118a, %r15 nop nop add %rax, %rax movb $0x61, (%r15) nop nop nop nop nop and $62909, %r12 lea addresses_WC_ht+0x15673, %r12 nop nop and %rbp, %rbp mov (%r12), %rcx nop nop nop nop sub %r15, %r15 lea addresses_normal_ht+0xd747, %rcx nop add $37928, %rsi movl $0x61626364, (%rcx) nop nop nop nop and %rcx, %rcx lea addresses_A_ht+0x1dd73, %rsi nop add %rbp, %rbp mov $0x6162636465666768, %rdi movq %rdi, %xmm6 movups %xmm6, (%rsi) nop nop nop nop and %rdi, %rdi lea addresses_WC_ht+0x5a73, %rsi lea addresses_WC_ht+0x19803, %rdi add %rax, %rax mov $78, %rcx rep movsl nop nop nop nop xor $25303, %rax lea addresses_normal_ht+0x15473, %rax nop xor $23884, %rcx mov (%rax), %di cmp %rsi, %rsi pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r15 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r15 push %rax push %rcx push %rsi // Faulty Load lea addresses_US+0x7c73, %rax xor $55477, %r11 vmovups (%rax), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $1, %xmm1, %rcx lea oracles, %r15 and $0xff, %rcx shlq $12, %rcx mov (%r15,%rcx,1), %rcx pop %rsi pop %rcx pop %rax pop %r15 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_US', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_US', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': True, 'type': 'addresses_UC_ht', 'congruent': 6}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 8}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': True, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': True, 'AVXalign': False, 'congruent': 1}} {'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 9}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 4}} {'OP': 'LOAD', 'src': {'size': 2, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'00': 21466, '48': 363} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A027472: Third convolution of the powers of 3 (A000244). ; 1,9,54,270,1215,5103,20412,78732,295245,1082565,3897234,13817466,48361131,167403915,573956280,1951451352,6586148313,22082967873,73609892910,244074908070 mov $1,$0 mov $2,$0 add $2,2 mov $0,$2 bin $0,$1 mov $3,3 pow $3,$1 mul $0,$3 mov $1,$0
; A047493: Numbers that are congruent to {1, 4, 5, 7} mod 8. ; 1,4,5,7,9,12,13,15,17,20,21,23,25,28,29,31,33,36,37,39,41,44,45,47,49,52,53,55,57,60,61,63,65,68,69,71,73,76,77,79,81,84,85,87,89,92,93,95,97,100,101,103,105,108,109,111,113,116,117,119,121,124 mov $1,$0 mul $0,6 add $1,14 mod $1,4 add $0,$1 div $0,3 add $0,1
; A246730: Decimal expansion of r_9, the 9th smallest radius < 1 for which a compact packing of the plane exists, with disks of radius 1 and r_9. ; Submitted by Jon Maiga ; 6,3,7,5,5,5,9,7,7,2,3,1,9,4,5,7,9,3,4,9,1,3,1,7,1,6,7,7,3,9,9,0,9,5,9,6,7,3,7,5,7,0,8,4,2,4,5,7,4,0,1,8,7,4,0,6,7,0,8,5,4,5,6,5,6,7,3,3,1,8,1,1,5,9,9,4,0,6,8,7,3,7,5,7,5,0,4,1,7,1,6,6,0,0,7,3,3,3,7,7 add $0,1 mov $1,1 mov $3,$0 mul $3,4 lpb $3 add $6,$2 add $1,$6 add $1,$2 add $2,$1 mul $1,2 sub $3,1 add $5,$2 mul $6,-1 add $6,$5 lpe mov $4,10 pow $4,$0 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
UnknownText_0x1b5270: text "Hello, this is" line "@" text_ram wStringBuffer3 text " speaking…" para "Hi, <PLAY_G>!" line "Good morning!" done UnknownText_0x1b52a5: text "Hello, this is" line "@" text_ram wStringBuffer3 text " speaking…" para "Hi, <PLAY_G>!" done UnknownText_0x1b52cc: text "Hello, this is" line "@" text_ram wStringBuffer3 text " speaking…" para "Hi, <PLAY_G>!" line "Good evening!" done UnknownText_0x1b5301: text "<PLAY_G>, good" line "morning!" para "It's me, @" text_ram wStringBuffer3 text "." line "How are you doing?" done UnknownText_0x1b5335: text "Hi, <PLAY_G>!" para "It's me, @" text_ram wStringBuffer3 text "." line "How are you doing?" done UnknownText_0x1b535f: text "<PLAY_G>, good" line "evening!" para "It's me, @" text_ram wStringBuffer3 text "." line "How are you doing?" done UnknownText_0x1b5393: text "How are your" line "#MON doing?" para "My @" text_ram wStringBuffer4 text "'s" line "doing as great as" cont "ever." para "Let's keep at it" line "and become #MON" cont "CHAMPS!" done
; A330095: Beatty sequence for 3^(x-1), where 1/2^x + 1/3^(x-1) = 1. ; 1,3,4,6,7,9,11,12,14,15,17,19,20,22,23,25,27,28,30,31,33,35,36,38,39,41,43,44,46,47,49,51,52,54,55,57,58,60,62,63,65,66,68,70,71,73,74,76,78,79,81,82,84,86,87,89,90,92,94,95,97,98,100,102,103 mov $4,$0 add $4,1 mov $8,$0 lpb $4 mov $0,$8 sub $4,1 sub $0,$4 mov $2,$0 mov $10,2 lpb $10 mov $0,$2 sub $10,1 add $0,$10 mul $0,2 cmp $3,$9 add $3,8 mov $5,19 mul $5,$0 div $5,8 div $5,$3 mov $6,$10 lpb $6 sub $6,1 mov $7,$5 lpe lpe lpb $2 mov $2,0 sub $7,$5 lpe mov $5,$7 add $5,1 add $1,$5 lpe mov $0,$1
IDEAL ASSUME CS:MYGROUP, DS:MYGROUP, ES:MYGROUP, SS:MYGROUP SEGMENT SEG1 PUBLIC sword: DW 0DEADh DW 0FACEh JMP sword JMP near CS:100h ENDS GROUP MYGROUP SEG1 END
.macosx_version_min 10, 12 .section __TEXT,__text,regular,pure_instructions .align 4, 0x90 .globl _main _main: pushq %rbp movq %rsp, %rbp pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbx subq $760, %rsp movq %rsi, %r14 movl %edi, %r15d movq (%r14), %rax movq %rax, _progname(%rip) testq %rax, %rax je L0000002E L00000029: cmpb $0, (%rax) jne L0000003C L0000002E: leaq LC00000CF2(%rip), %rax movq %rax, _progname(%rip) L0000003C: leaq -784(%rbp), %rdi xorl %eax, %eax call _jpeg_std_error L0000004A: movq %rax, -616(%rbp) leaq -616(%rbp), %rbx movl $62, %esi movl $576, %edx xorl %eax, %eax movq %rbx, %rdi call _jpeg_CreateCompress L0000006C: leaq _cdjpeg_message_table(%rip), %rax movq %rax, -632(%rbp) movl $1000, -624(%rbp) movl $1043, -620(%rbp) movl $2, -556(%rbp) xorl %eax, %eax movq %rbx, %rdi call _jpeg_set_defaults L000000A2: xorl %ecx, %ecx movq %rbx, %rdi movl %r15d, %esi movq %r14, %rdx call _parse_switches L000000B2: leal -1(%r15), %ecx cmpl %ecx, %eax jl L0000034F L000000BE: cmpl %r15d, %eax jge L000000F5 L000000C3: movslq %eax, %rbx movq (%r14,%rbx,8), %rdi leaq LC00000D11(%rip), %rsi call _fopen L000000D6: movq %rax, %r13 testq %r13, %r13 jne L000000FF L000000DE: movq ___stderrp@GOTPCREL(%rip), %rax movq (%rax), %rdi movq _progname(%rip), %rdx movq (%r14,%rbx,8), %rcx jmp L00000137 L000000F5: xorl %eax, %eax call _read_stdin L000000FC: movq %rax, %r13 L000000FF: movq _outfilename(%rip), %rdi testq %rdi, %rdi je L0000014F L0000010B: leaq LC00000D27(%rip), %rsi call _fopen L00000117: movq %rax, %r12 testq %r12, %r12 jne L00000159 L0000011F: movq ___stderrp@GOTPCREL(%rip), %rax movq (%rax), %rdi movq _progname(%rip), %rdx movq _outfilename(%rip), %rcx L00000137: leaq LC00000D14(%rip), %rsi xorl %eax, %eax call _fprintf L00000145: movl $1, %edi call _exit L0000014F: xorl %eax, %eax call _write_stdout L00000156: movq %rax, %r12 L00000159: movzbl _is_targa(%rip), %eax cmpl $1, %eax jne L0000016E L00000165: movq %r12, -792(%rbp) jmp L000001CE L0000016E: movq %r13, %rdi call _getc L00000176: movl %eax, %ebx cmpl $-1, %ebx jne L00000196 L0000017D: movq -616(%rbp), %rcx movl $42, 40(%rcx) leaq -616(%rbp), %rdi xorl %eax, %eax call *(%rcx) L00000196: movl %ebx, %edi movq %r13, %rsi call _ungetc L000001A0: cmpl $-1, %eax jne L000001BE L000001A5: movq -616(%rbp), %rcx movl $1040, 40(%rcx) leaq -616(%rbp), %rdi xorl %eax, %eax call *(%rcx) L000001BE: cmpl $70, %ebx jg L000001E4 L000001C3: movq %r12, -792(%rbp) testl %ebx, %ebx jne L00000206 L000001CE: movq %r14, %r12 leaq -616(%rbp), %rdi xorl %eax, %eax call _jinit_read_targa L000001DF: movq %rax, %rbx jmp L00000254 L000001E4: movq %r12, -792(%rbp) movq %r14, %r12 cmpl $71, %ebx jne L00000221 L000001F3: leaq -616(%rbp), %rdi xorl %eax, %eax call _jinit_read_gif L00000201: movq %rax, %rbx jmp L00000254 L00000206: movq %r14, %r12 cmpl $66, %ebx jne L00000239 L0000020E: leaq -616(%rbp), %rdi xorl %eax, %eax call _jinit_read_bmp L0000021C: movq %rax, %rbx jmp L00000254 L00000221: cmpl $80, %ebx jne L00000239 L00000226: leaq -616(%rbp), %rdi xorl %eax, %eax call _jinit_read_ppm L00000234: movq %rax, %rbx jmp L00000254 L00000239: movq -616(%rbp), %rcx movl $1041, 40(%rcx) xorl %ebx, %ebx leaq -616(%rbp), %rdi xorl %eax, %eax call *(%rcx) L00000254: movq %r13, 24(%rbx) leaq -616(%rbp), %r14 xorl %eax, %eax movq %r14, %rdi movq %rbx, %rsi call *(%rbx) L00000269: xorl %eax, %eax movq %r14, %rdi call _jpeg_default_colorspace L00000273: movl $1, %ecx movq %r14, %rdi movl %r15d, %esi movq %r12, %rdx call _parse_switches L00000286: xorl %eax, %eax movq %r14, %rdi movq -792(%rbp), %r15 movq %r15, %rsi call _jpeg_stdio_dest L0000029A: movl $1, %esi xorl %eax, %eax movq %r14, %rdi call _jpeg_start_compress L000002A9: movl -256(%rbp), %eax cmpl -564(%rbp), %eax jae L000002EB L000002B7: leaq -616(%rbp), %r14 .align 4, 0x90 L000002C0: xorl %eax, %eax movq %r14, %rdi movq %rbx, %rsi call *8(%rbx) L000002CB: movl %eax, %ecx movq 32(%rbx), %rsi xorl %eax, %eax movq %r14, %rdi movl %ecx, %edx call _jpeg_write_scanlines L000002DD: movl -256(%rbp), %eax cmpl -564(%rbp), %eax jb L000002C0 L000002EB: leaq -616(%rbp), %r14 xorl %eax, %eax movq %r14, %rdi movq %rbx, %rsi call *16(%rbx) L000002FD: xorl %eax, %eax movq %r14, %rdi call _jpeg_finish_compress L00000307: xorl %eax, %eax movq %r14, %rdi call _jpeg_destroy_compress L00000311: movq ___stdinp@GOTPCREL(%rip), %rax cmpq (%rax), %r13 je L00000325 L0000031D: movq %r13, %rdi call _fclose L00000325: movq ___stdoutp@GOTPCREL(%rip), %rax cmpq (%rax), %r15 je L00000339 L00000331: movq %r15, %rdi call _fclose L00000339: movl $2, %edi cmpq $0, -656(%rbp) jne L0000034A L00000348: xorl %edi, %edi L0000034A: call _exit L0000034F: movq ___stderrp@GOTPCREL(%rip), %rax movq (%rax), %rdi movq _progname(%rip), %rdx leaq LC00000CF8(%rip), %rsi xorl %eax, %eax call _fprintf L0000036E: call _usage L00000373: .align 4, 0x90 # ---------------------- _parse_switches: pushq %rbp movq %rsp, %rbp pushq %r15 pushq %r14 pushq %r13 pushq %r12 pushq %rbx subq $104, %rsp movl %ecx, -100(%rbp) movq %rdx, %r13 movl %esi, %r12d movq %rdi, %r14 movl $75, -44(%rbp) movb $0, _is_targa(%rip) movq $0, _outfilename(%rip) movq (%r14), %rax movl $0, 124(%rax) cmpl $2, %r12d jl L00000978 L000003CA: movl $1, %ebx movl $100, -140(%rbp) xorl %eax, %eax movq %rax, -96(%rbp) xorl %eax, %eax movq %rax, -136(%rbp) xorl %eax, %eax movq %rax, -120(%rbp) xorl %eax, %eax movq %rax, -128(%rbp) xorl %eax, %eax movq %rax, -112(%rbp) xorl %eax, %eax movq %rax, -88(%rbp) jmp L00000900 L00000405: movl $2, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001297(%rip), %rsi call _keymatch L0000041B: testl %eax, %eax je L0000045D L0000041F: incl %ebx cmpl %r12d, %ebx jge L00000A8A L0000042A: movslq %ebx, %r15 movq (%r13,%r15,8), %rdi movl $1, %edx xorl %eax, %eax leaq LC0000129B(%rip), %rsi call _keymatch L00000445: testl %eax, %eax je L000004D7 L0000044D: movl $0, 324(%r14) jmp L0000096F L0000045D: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC000012AA(%rip), %rsi call _keymatch L00000473: testl %eax, %eax jne L00000495 L00000477: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC000012B0(%rip), %rsi call _keymatch L0000048D: testl %eax, %eax je L00000533 L00000495: movb _parse_switches.printed_version(%rip), %al testb %al, %al jne L000004CC L0000049F: movq ___stderrp@GOTPCREL(%rip), %rax movq (%rax), %rdi xorl %eax, %eax leaq LC000012B8(%rip), %rsi leaq LC000012E7(%rip), %rdx leaq LC000012F7(%rip), %rcx call _fprintf L000004C5: movb $1, _parse_switches.printed_version(%rip) L000004CC: movq (%r14), %rax incl 124(%rax) jmp L0000096F L000004D7: movq (%r13,%r15,8), %rdi movl $2, %edx xorl %eax, %eax leaq LC0000129F(%rip), %rsi call _keymatch L000004EF: testl %eax, %eax je L00000503 L000004F3: movl $1, 324(%r14) jmp L0000096F L00000503: movq (%r13,%r15,8), %rdi movl $2, %edx xorl %eax, %eax leaq LC000012A4(%rip), %rsi call _keymatch L0000051B: testl %eax, %eax je L00000A8F L00000523: movl $2, 324(%r14) jmp L0000096F L00000533: movl $2, %edx xorl %eax, %eax movq %r15, %rdi leaq LC0000131A(%rip), %rsi call _keymatch L00000549: testl %eax, %eax jne L00000567 L0000054D: movl $2, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001324(%rip), %rsi call _keymatch L00000563: testl %eax, %eax je L0000057B L00000567: movl $1, %esi xorl %eax, %eax movq %r14, %rdi call _jpeg_set_colorspace L00000576: jmp L0000096F L0000057B: movl $3, %edx xorl %eax, %eax movq %r15, %rdi leaq LC0000132E(%rip), %rsi call _keymatch L00000591: testl %eax, %eax je L000005E5 L00000595: movb $120, -57(%rbp) incl %ebx cmpl %r12d, %ebx jge L00000A8A L000005A4: movslq %ebx, %rax movq (%r13,%rax,8), %rdi xorl %eax, %eax leaq LC00001338(%rip), %rsi leaq -56(%rbp), %rdx leaq -57(%rbp), %rcx call _sscanf L000005C2: testl %eax, %eax jle L00000A8A L000005CA: movb -57(%rbp), %al orb $32, %al movzbl %al, %eax cmpl $109, %eax jne L00000629 L000005D7: imulq $1000, -56(%rbp), %rax movq %rax, -56(%rbp) jmp L0000062D L000005E5: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC0000133E(%rip), %rsi call _keymatch L000005FB: testl %eax, %eax jne L00000619 L000005FF: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001347(%rip), %rsi call _keymatch L00000615: testl %eax, %eax je L00000641 L00000619: movl $1, 312(%r14) jmp L0000096F L00000629: movq -56(%rbp), %rax L0000062D: imulq $1000, %rax, %rax movq 8(%r14), %rcx movq %rax, 88(%rcx) jmp L0000096F L00000641: movl $4, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001350(%rip), %rsi call _keymatch L00000657: testl %eax, %eax je L0000067A L0000065B: incl %ebx cmpl %r12d, %ebx jge L00000A8A L00000666: movslq %ebx, %rax movq (%r13,%rax,8), %rax movq %rax, _outfilename(%rip) jmp L0000096F L0000067A: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001358(%rip), %rsi call _keymatch L00000690: testl %eax, %eax je L000006A2 L00000694: movl $1, %eax movq %rax, -112(%rbp) jmp L0000096F L000006A2: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001364(%rip), %rsi call _keymatch L000006B8: testl %eax, %eax je L000006FF L000006BC: incl %ebx cmpl %r12d, %ebx jge L00000A8A L000006C7: movslq %ebx, %rax movq (%r13,%rax,8), %rdi xorl %eax, %eax leaq LC0000136C(%rip), %rsi leaq -44(%rbp), %rdx call _sscanf L000006E1: cmpl $1, %eax jne L00000A8A L000006EA: movl -44(%rbp), %edi xorl %eax, %eax call _jpeg_quality_scaling L000006F4: movl %eax, -140(%rbp) jmp L0000096F L000006FF: movl $2, %edx xorl %eax, %eax movq %r15, %rdi leaq LC0000136F(%rip), %rsi call _keymatch L00000715: testl %eax, %eax je L00000735 L00000719: incl %ebx cmpl %r12d, %ebx jge L00000A8A L00000724: movslq %ebx, %rax movq (%r13,%rax,8), %rax movq %rax, -120(%rbp) jmp L0000096F L00000735: movl $2, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001376(%rip), %rsi call _keymatch L0000074B: testl %eax, %eax je L0000076B L0000074F: incl %ebx cmpl %r12d, %ebx jge L00000A8A L0000075A: movslq %ebx, %rax movq (%r13,%rax,8), %rax movq %rax, -128(%rbp) jmp L0000096F L0000076B: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC0000137E(%rip), %rsi call _keymatch L00000781: testl %eax, %eax je L000007EF L00000785: movb $120, -73(%rbp) incl %ebx cmpl %r12d, %ebx jge L00000A8A L00000794: movslq %ebx, %rax movq (%r13,%rax,8), %rdi xorl %eax, %eax leaq LC00001338(%rip), %rsi leaq -72(%rbp), %rdx leaq -73(%rbp), %rcx call _sscanf L000007B2: testl %eax, %eax jle L00000A8A L000007BA: movq -72(%rbp), %rax cmpq $65536, %rax jae L00000A8A L000007CA: movb -73(%rbp), %cl orb $32, %cl movzbl %cl, %ecx cmpl $98, %ecx jne L00000828 L000007D8: movl %eax, 328(%r14) movl $0, 332(%r14) jmp L0000096F L000007EF: movl $2, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001386(%rip), %rsi call _keymatch L00000805: testl %eax, %eax je L00000834 L00000809: incl %ebx cmpl %r12d, %ebx jge L00000A8A L00000814: movslq %ebx, %rax movq (%r13,%rax,8), %rax movq %rax, -136(%rbp) jmp L0000096F L00000828: movl %eax, 332(%r14) jmp L0000096F L00000834: movl $2, %edx xorl %eax, %eax movq %r15, %rdi leaq LC0000138D(%rip), %rsi call _keymatch L0000084A: testl %eax, %eax je L0000086A L0000084E: incl %ebx cmpl %r12d, %ebx jge L00000A8A L00000859: movslq %ebx, %rax movq (%r13,%rax,8), %rax movq %rax, -96(%rbp) jmp L0000096F L0000086A: movl $2, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001393(%rip), %rsi call _keymatch L00000880: testl %eax, %eax je L000008CA L00000884: incl %ebx cmpl %r12d, %ebx jge L00000A8A L0000088F: movslq %ebx, %rax movq (%r13,%rax,8), %rdi xorl %eax, %eax leaq LC0000136C(%rip), %rsi leaq -80(%rbp), %rdx call _sscanf L000008A9: cmpl $1, %eax jne L00000A8A L000008B2: movl -80(%rbp), %eax cmpl $101, %eax jae L00000A8A L000008BE: movl %eax, 320(%r14) jmp L0000096F L000008CA: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC0000139A(%rip), %rsi call _keymatch L000008E0: testl %eax, %eax je L00000A94 L000008E8: movb $1, _is_targa(%rip) jmp L0000096F L000008F1: .align 4, 0x90 L00000900: movslq %ebx, %rax movq (%r13,%rax,8), %r15 movzbl (%r15), %eax cmpl $45, %eax jne L00000960 L00000911: incq %r15 movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC00001257(%rip), %rsi call _keymatch L0000092A: testl %eax, %eax jne L00000A61 L00000932: movl $1, %edx xorl %eax, %eax movq %r15, %rdi leaq LC0000128E(%rip), %rsi call _keymatch L00000948: testl %eax, %eax je L00000405 L00000950: movl $1, %eax movq %rax, -88(%rbp) jmp L0000096F L0000095B: .align 4, 0x90 L00000960: testl %ebx, %ebx jg L000009AE L00000964: movq $0, _outfilename(%rip) L0000096F: incl %ebx cmpl %r12d, %ebx jl L00000900 L00000976: jmp L000009AE L00000978: xorl %eax, %eax movq %rax, -96(%rbp) movl $1, %ebx movl $100, -140(%rbp) xorl %eax, %eax movq %rax, -136(%rbp) xorl %eax, %eax movq %rax, -120(%rbp) xorl %eax, %eax movq %rax, -128(%rbp) xorl %eax, %eax movq %rax, -112(%rbp) xorl %eax, %eax movq %rax, -88(%rbp) L000009AE: cmpl $0, -100(%rbp) movq -96(%rbp), %r15 je L00000A50 L000009BC: movl -44(%rbp), %esi xorl %eax, %eax movq %r14, %rdi movq -88(%rbp), %r12 movl %r12d, %edx call _jpeg_set_quality L000009D0: movq -128(%rbp), %rsi testq %rsi, %rsi je L000009F4 L000009D9: xorl %eax, %eax movq %r14, %rdi movl -140(%rbp), %edx movl %r12d, %ecx call _read_quant_tables L000009EC: testl %eax, %eax je L00000A8A L000009F4: movq -120(%rbp), %rsi testq %rsi, %rsi movq -136(%rbp), %r12 je L00000A12 L00000A04: xorl %eax, %eax movq %r14, %rdi call _set_quant_slots L00000A0E: testl %eax, %eax je L00000A8A L00000A12: testq %r12, %r12 je L00000A28 L00000A17: xorl %eax, %eax movq %r14, %rdi movq %r12, %rsi call _set_sample_factors L00000A24: testl %eax, %eax je L00000A8A L00000A28: movq -112(%rbp), %rax testl %eax, %eax je L00000A3A L00000A30: xorl %eax, %eax movq %r14, %rdi call _jpeg_simple_progression L00000A3A: testq %r15, %r15 je L00000A50 L00000A3F: xorl %eax, %eax movq %r14, %rdi movq %r15, %rsi call _read_scan_script L00000A4C: testl %eax, %eax je L00000A8A L00000A50: movl %ebx, %eax addq $104, %rsp popq %rbx popq %r12 popq %r13 popq %r14 popq %r15 popq %rbp ret L00000A61: movq ___stderrp@GOTPCREL(%rip), %rax movq (%rax), %rdi movq _progname(%rip), %rdx leaq LC00001262(%rip), %rsi xorl %eax, %eax call _fprintf L00000A80: movl $1, %edi call _exit L00000A8A: call _usage L00000A8F: call _usage L00000A94: call _usage L00000A99: .align 4, 0x90 # ---------------------- _usage: pushq %rbp movq %rsp, %rbp pushq %r14 pushq %rbx movq ___stderrp@GOTPCREL(%rip), %rbx movq (%rbx), %rdi movq _progname(%rip), %rdx leaq LC000013A0(%rip), %rsi xorl %eax, %eax call _fprintf L00000AC6: movq (%rbx), %rcx leaq LC000013B6(%rip), %rdi movl $12, %esi movl $1, %edx call _fwrite L00000ADF: movq (%rbx), %rcx leaq LC000013C3(%rip), %rdi movl $37, %esi movl $1, %edx call _fwrite L00000AF8: movq (%rbx), %rcx leaq LC000013E9(%rip), %rdi movl $68, %esi movl $1, %edx call _fwrite L00000B11: movq (%rbx), %rcx leaq LC0000142E(%rip), %rdi movl $45, %esi movl $1, %edx call _fwrite L00000B2A: movq (%rbx), %rcx leaq LC0000145C(%rip), %rdi movl $77, %esi movl $1, %edx call _fwrite L00000B43: movq (%rbx), %rcx leaq LC000014AA(%rip), %rdi movl $46, %esi movl $1, %edx call _fwrite L00000B5C: movq (%rbx), %rcx leaq LC000014D9(%rip), %rdi movl $65, %esi movl $1, %edx call _fwrite L00000B75: movq (%rbx), %rcx leaq LC0000151B(%rip), %rdi movl $29, %esi movl $1, %edx call _fwrite L00000B8E: movq (%rbx), %rdi leaq LC00001539(%rip), %rsi leaq LC00001564(%rip), %rdx xorl %eax, %eax call _fprintf L00000BA6: movq (%rbx), %rdi leaq LC0000156F(%rip), %rsi leaq LC000015A8(%rip), %r14 xorl %eax, %eax movq %r14, %rdx call _fprintf L00000BC1: movq (%rbx), %rdi leaq LC000015A9(%rip), %rsi xorl %eax, %eax movq %r14, %rdx call _fprintf L00000BD5: movq (%rbx), %rcx leaq LC000015DB(%rip), %rdi movl $67, %esi movl $1, %edx call _fwrite L00000BEE: movq (%rbx), %rcx leaq LC0000161F(%rip), %rdi movl $62, %esi movl $1, %edx call _fwrite L00000C07: movq (%rbx), %rcx leaq LC0000165E(%rip), %rdi movl $51, %esi movl $1, %edx call _fwrite L00000C20: movq (%rbx), %rcx leaq LC00001692(%rip), %rdi movl $46, %esi movl $1, %edx call _fwrite L00000C39: movq (%rbx), %rcx leaq LC000016C1(%rip), %rdi movl $43, %esi movl $1, %edx call _fwrite L00000C52: movq (%rbx), %rcx leaq LC000016ED(%rip), %rdi movl $22, %esi movl $1, %edx call _fwrite L00000C6B: movq (%rbx), %rcx leaq LC00001704(%rip), %rdi movl $52, %esi movl $1, %edx call _fwrite L00000C84: movq (%rbx), %rcx leaq LC00001739(%rip), %rdi movl $55, %esi movl $1, %edx call _fwrite L00000C9D: movq (%rbx), %rcx leaq LC00001771(%rip), %rdi movl $55, %esi movl $1, %edx call _fwrite L00000CB6: movq (%rbx), %rcx leaq LC000017A9(%rip), %rdi movl $52, %esi movl $1, %edx call _fwrite L00000CCF: movq (%rbx), %rcx leaq LC000017DE(%rip), %rdi movl $56, %esi movl $1, %edx call _fwrite L00000CE8: movl $1, %edi call _exit # ---------------------- .section __TEXT,__cstring,cstring_literals LC00000CF2: .string "cjpeg" LC00000CF8: .string "%s: only one input file\n" LC00000D11: .string "rb" LC00000D14: .string "%s: can't open %s\n" LC00000D27: .string "wb" LC00000D2A: .string "Unsupported BMP colormap format" LC00000D4A: .string "Only 8- and 24-bit BMP files are supported" LC00000D75: .string "Invalid BMP file: bad header length" LC00000D99: .string "Invalid BMP file: biPlanes not equal to 1" LC00000DC3: .string "BMP output must be grayscale or RGB" LC00000DE7: .string "Sorry, compressed BMPs not yet supported" LC00000E10: .string "Not a BMP file - does not start with BM" LC00000E38: .string "%ux%u 24-bit BMP image" LC00000E4F: .string "%ux%u 8-bit colormapped BMP image" LC00000E71: .string "%ux%u 24-bit OS2 BMP image" LC00000E8C: .string "%ux%u 8-bit colormapped OS2 BMP image" LC00000EB2: .string "GIF output got confused" LC00000ECA: .string "Bogus GIF codesize %d" LC00000EE0: .string "GIF output must be grayscale or RGB" LC00000F04: .string "Too few images in GIF file" LC00000F1F: .string "Not a GIF file" LC00000F2E: .string "%ux%ux%d GIF image" LC00000F41: .string "Warning: unexpected GIF version number '%c%c%c'" LC00000F71: .string "Ignoring GIF extension block of type 0x%02x" LC00000F9D: .string "Caution: nonsquare pixels in input" LC00000FC0: .string "Corrupt data in GIF file" LC00000FD9: .string "Bogus char 0x%02x in GIF file, ignoring" LC00001001: .string "Premature end of GIF image" LC0000101C: .string "Ran out of GIF bits" LC00001030: .string "PPM output must be grayscale or RGB" LC00001054: .string "Nonnumeric data in PPM file" LC00001070: .string "Not a PPM/PGM file" LC00001083: .string "%ux%u PGM image" LC00001093: .string "%ux%u text PGM image" LC000010A8: .string "%ux%u PPM image" LC000010B8: .string "%ux%u text PPM image" LC000010CD: .string "Unsupported Targa colormap format" LC000010EF: .string "Invalid or unsupported Targa file" LC00001111: .string "Targa output must be grayscale or RGB" LC00001137: .string "%ux%u RGB Targa image" LC0000114D: .string "%ux%u grayscale Targa image" LC00001169: .string "%ux%u colormapped Targa image" LC00001187: .string "Color map file is invalid or of unsupported format" LC000011BA: .string "Output file format cannot handle %d colormap entries" LC000011EF: .string "ungetc failed" LC000011FD: .string "Unrecognized input file format --- perhaps you need -targa" LC00001238: .string "Unsupported output file format" LC00001257: .string "arithmetic" LC00001262: .string "%s: sorry, arithmetic coding not supported\n" LC0000128E: .string "baseline" LC00001297: .string "dct" LC0000129B: .string "int" LC0000129F: .string "fast" LC000012A4: .string "float" LC000012AA: .string "debug" LC000012B0: .string "verbose" LC000012B8: .string "Independent JPEG Group's CJPEG, version %s\n%s\n" LC000012E7: .string "6b 27-Mar-1998" LC000012F7: .string "Copyright (C) 1998, Thomas G. Lane" LC0000131A: .string "grayscale" LC00001324: .string "greyscale" LC0000132E: .string "maxmemory" LC00001338: .string "%ld%c" LC0000133E: .string "optimize" LC00001347: .string "optimise" LC00001350: .string "outfile" LC00001358: .string "progressive" LC00001364: .string "quality" LC0000136C: .string "%d" LC0000136F: .string "qslots" LC00001376: .string "qtables" LC0000137E: .string "restart" LC00001386: .string "sample" LC0000138D: .string "scans" LC00001393: .string "smooth" LC0000139A: .string "targa" LC000013A0: .string "usage: %s [switches] " LC000013B6: .string "[inputfile]\n" LC000013C3: .string "Switches (names may be abbreviated):\n" LC000013E9: .string " -quality N Compression quality (0..100; 5-95 is useful range)\n" LC0000142E: .string " -grayscale Create monochrome JPEG file\n" LC0000145C: .string " -optimize Optimize Huffman table (smaller file, but slow compression)\n" LC000014AA: .string " -progressive Create progressive JPEG file\n" LC000014D9: .string " -targa Input file is Targa format (usually not needed)\n" LC0000151B: .string "Switches for advanced users:\n" LC00001539: .string " -dct int Use integer DCT method%s\n" LC00001564: .string " (default)" LC0000156F: .string " -dct fast Use fast integer DCT (less accurate)%s\n" LC000015A8: .byte 0 LC000015A9: .string " -dct float Use floating-point DCT method%s\n" LC000015DB: .string " -restart N Set restart interval in rows, or in blocks with B\n" LC0000161F: .string " -smooth N Smooth dithered input (N=1..100 is strength)\n" LC0000165E: .string " -maxmemory N Maximum memory to use (in kbytes)\n" LC00001692: .string " -outfile name Specify name for output file\n" LC000016C1: .string " -verbose or -debug Emit debug output\n" LC000016ED: .string "Switches for wizards:\n" LC00001704: .string " -baseline Force baseline quantization tables\n" LC00001739: .string " -qtables file Use quantization tables given in file\n" LC00001771: .string " -qslots N[,...] Set component quantization tables\n" LC000017A9: .string " -sample HxV[,...] Set component sampling factors\n" LC000017DE: .string " -scans file Create multi-scan JPEG per script file\n" # ---------------------- .section __DATA,__const,regular _cdjpeg_message_table: .zero 8 .quad LC00000D2A .quad LC00000D4A .quad LC00000D75 .quad LC00000D99 .quad LC00000DC3 .quad LC00000DE7 .quad LC00000E10 .quad LC00000E38 .quad LC00000E4F .quad LC00000E71 .quad LC00000E8C .quad LC00000EB2 .quad LC00000ECA .quad LC00000EE0 .quad LC00000F04 .quad LC00000F1F .quad LC00000F2E .quad LC00000F41 .quad LC00000F71 .quad LC00000F9D .quad LC00000FC0 .quad LC00000FD9 .quad LC00001001 .quad LC0000101C .quad LC00001030 .quad LC00001054 .quad LC00001070 .quad LC00001083 .quad LC00001093 .quad LC000010A8 .quad LC000010B8 .quad LC000010CD .quad LC000010EF .quad LC00001111 .quad LC00001137 .quad LC0000114D .quad LC00001169 .quad LC00001187 .quad LC000011BA .quad LC000011EF .quad LC000011FD .quad LC00001238 .zero 8 # ---------------------- .zerofill __DATA,__bss,_progname,8,3 # ---------------------- .zerofill __DATA,__bss,_outfilename,8,3 # ---------------------- .zerofill __DATA,__bss,_is_targa,1,0 # ---------------------- .zerofill __DATA,__bss,_parse_switches.printed_version,1,0 # ---------------------- .subsections_via_symbols
/*============================================================================= Copyright (c) 2001-2003 Daniel Nuffer Copyright (c) 2001-2007 Hartmut Kaiser Revised 2007, Copyright (c) Tobias Schwinger http://spirit.sourceforge.net/ 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_SPIRIT_TREE_COMMON_HPP #define BOOST_SPIRIT_TREE_COMMON_HPP #if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) #include <vector> #else #include <list> #endif #if defined(BOOST_SPIRIT_USE_BOOST_ALLOCATOR_FOR_TREES) #include <boost/pool/pool_alloc.hpp> #endif #include <algorithm> #include <boost/ref.hpp> #include <boost/call_traits.hpp> #include <boost/spirit/home/classic/namespace.hpp> #include <boost/spirit/home/classic/core.hpp> #include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) #include <iostream> #include <boost/spirit/home/classic/debug/debug_node.hpp> #endif #include <boost/spirit/home/classic/tree/common_fwd.hpp> namespace boost { namespace spirit { BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN template <typename T> void swap(tree_node<T>& a, tree_node<T>& b); template <typename T, typename V> void swap(node_iter_data<T, V>& a, node_iter_data<T, V>& b); namespace impl { template <typename T> inline void cp_swap(T& t1, T& t2); } template <typename T> struct tree_node { typedef T parse_node_t; #if !defined(BOOST_SPIRIT_USE_BOOST_ALLOCATOR_FOR_TREES) typedef std::allocator<tree_node<T> > allocator_type; #elif !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) typedef boost::pool_allocator<tree_node<T> > allocator_type; #else typedef boost::fast_pool_allocator<tree_node<T> > allocator_type; #endif #if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) typedef std::vector<tree_node<T>, allocator_type> children_t; #else typedef std::list<tree_node<T>, allocator_type> children_t; #endif // BOOST_SPIRIT_USE_LIST_FOR_TREES typedef typename children_t::iterator tree_iterator; typedef typename children_t::const_iterator const_tree_iterator; T value; children_t children; tree_node() : value() , children() {} explicit tree_node(T const& v) : value(v) , children() {} tree_node(T const& v, children_t const& c) : value(v) , children(c) {} void swap(tree_node<T>& x) { impl::cp_swap(value, x.value); impl::cp_swap(children, x.children); } // Intel V5.0.1 has a problem without this explicit operator= tree_node &operator= (tree_node const &rhs) { tree_node(rhs).swap(*this); return *this; } }; #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) template <typename T> inline std::ostream& operator<<(std::ostream& o, tree_node<T> const& n) { static int depth = 0; o << "\n"; for (int i = 0; i <= depth; ++i) { o << "\t"; } o << "(depth = " << depth++ << " value = " << n.value; int c = 0; for (typename tree_node<T>::children_t::const_iterator it = n.children.begin(); it != n.children.end(); ++it) { o << " children[" << c++ << "] = " << *it; } o << ")"; --depth; return o; } #endif ////////////////////////////////// template <typename IteratorT, typename ValueT> struct node_iter_data { typedef IteratorT iterator_t; typedef IteratorT /*const*/ const_iterator_t; node_iter_data() : first(), last(), is_root_(false), parser_id_(), value_() {} node_iter_data(IteratorT const& _first, IteratorT const& _last) : first(_first), last(_last), is_root_(false), parser_id_(), value_() {} void swap(node_iter_data& x) { impl::cp_swap(first, x.first); impl::cp_swap(last, x.last); impl::cp_swap(parser_id_, x.parser_id_); impl::cp_swap(is_root_, x.is_root_); impl::cp_swap(value_, x.value_); } IteratorT begin() { return first; } IteratorT const& begin() const { return first; } IteratorT end() { return last; } IteratorT const& end() const { return last; } bool is_root() const { return is_root_; } void is_root(bool b) { is_root_ = b; } parser_id id() const { return parser_id_; } void id(parser_id r) { parser_id_ = r; } ValueT const& value() const { return value_; } void value(ValueT const& v) { value_ = v; } private: IteratorT first, last; bool is_root_; parser_id parser_id_; ValueT value_; public: }; #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) // value is default nil_t, so provide an operator<< for nil_t inline std::ostream& operator<<(std::ostream& o, nil_t const&) { return o; } template <typename IteratorT, typename ValueT> inline std::ostream& operator<<(std::ostream& o, node_iter_data<IteratorT, ValueT> const& n) { o << "(id = " << n.id() << " text = \""; typedef typename node_iter_data<IteratorT, ValueT>::const_iterator_t iterator_t; for (iterator_t it = n.begin(); it != n.end(); ++it) impl::token_printer(o, *it); o << "\" is_root = " << n.is_root() << /*" value = " << n.value() << */")"; return o; } #endif ////////////////////////////////// template <typename IteratorT = char const*, typename ValueT = nil_t> struct node_val_data { typedef typename boost::detail::iterator_traits<IteratorT>::value_type value_type; #if !defined(BOOST_SPIRIT_USE_BOOST_ALLOCATOR_FOR_TREES) typedef std::allocator<value_type> allocator_type; #elif !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) typedef boost::pool_allocator<value_type> allocator_type; #else typedef boost::fast_pool_allocator<value_type> allocator_type; #endif #if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) typedef std::vector<value_type, allocator_type> container_t; #else typedef std::list<value_type, allocator_type> container_t; #endif typedef typename container_t::iterator iterator_t; typedef typename container_t::const_iterator const_iterator_t; node_val_data() : text(), is_root_(false), parser_id_(), value_() {} #if defined(BOOST_NO_TEMPLATED_ITERATOR_CONSTRUCTORS) node_val_data(IteratorT const& _first, IteratorT const& _last) : text(), is_root_(false), parser_id_(), value_() { std::copy(_first, _last, std::inserter(text, text.end())); } // This constructor is for building text out of iterators template <typename IteratorT2> node_val_data(IteratorT2 const& _first, IteratorT2 const& _last) : text(), is_root_(false), parser_id_(), value_() { std::copy(_first, _last, std::inserter(text, text.end())); } #else node_val_data(IteratorT const& _first, IteratorT const& _last) : text(_first, _last), is_root_(false), parser_id_(), value_() {} // This constructor is for building text out of iterators template <typename IteratorT2> node_val_data(IteratorT2 const& _first, IteratorT2 const& _last) : text(_first, _last), is_root_(false), parser_id_(), value_() {} #endif void swap(node_val_data& x) { impl::cp_swap(text, x.text); impl::cp_swap(is_root_, x.is_root_); impl::cp_swap(parser_id_, x.parser_id_); impl::cp_swap(value_, x.value_); } typename container_t::iterator begin() { return text.begin(); } typename container_t::const_iterator begin() const { return text.begin(); } typename container_t::iterator end() { return text.end(); } typename container_t::const_iterator end() const { return text.end(); } bool is_root() const { return is_root_; } void is_root(bool b) { is_root_ = b; } parser_id id() const { return parser_id_; } void id(parser_id r) { parser_id_ = r; } ValueT const& value() const { return value_; } void value(ValueT const& v) { value_ = v; } private: container_t text; bool is_root_; parser_id parser_id_; ValueT value_; }; #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) template <typename IteratorT, typename ValueT> inline std::ostream& operator<<(std::ostream& o, node_val_data<IteratorT, ValueT> const& n) { o << "(id = " << n.id() << " text = \""; typedef typename node_val_data<IteratorT, ValueT>::const_iterator_t iterator_t; for (iterator_t it = n.begin(); it != n.end(); ++it) impl::token_printer(o, *it); o << "\" is_root = " << n.is_root() << " value = " << n.value() << ")"; return o; } #endif template <typename T> inline void swap(tree_node<T>& a, tree_node<T>& b) { a.swap(b); } template <typename T, typename V> inline void swap(node_iter_data<T, V>& a, node_iter_data<T, V>& b) { a.swap(b); } ////////////////////////////////// template <typename ValueT> class node_iter_data_factory { public: // This inner class is so that node_iter_data_factory can simulate // a template template parameter template <typename IteratorT> class factory { public: typedef IteratorT iterator_t; typedef node_iter_data<iterator_t, ValueT> node_t; static node_t create_node(iterator_t const& first, iterator_t const& last, bool /*is_leaf_node*/) { return node_t(first, last); } static node_t empty_node() { return node_t(); } // precondition: ContainerT contains a tree_node<node_t>. And all // iterators in the container point to the same sequence. template <typename ContainerT> static node_t group_nodes(ContainerT const& nodes) { return node_t(nodes.begin()->value.begin(), nodes.back().value.end()); } }; }; ////////////////////////////////// template <typename ValueT> class node_val_data_factory { public: // This inner class is so that node_val_data_factory can simulate // a template template parameter template <typename IteratorT> class factory { public: typedef IteratorT iterator_t; typedef node_val_data<iterator_t, ValueT> node_t; static node_t create_node(iterator_t const& first, iterator_t const& last, bool is_leaf_node) { if (is_leaf_node) return node_t(first, last); else return node_t(); } static node_t empty_node() { return node_t(); } template <typename ContainerT> static node_t group_nodes(ContainerT const& nodes) { typename node_t::container_t c; typename ContainerT::const_iterator i_end = nodes.end(); // copy all the nodes text into a new one for (typename ContainerT::const_iterator i = nodes.begin(); i != i_end; ++i) { // See docs: reduced_node_d cannot be used with a // rule inside the []. assert(i->children.size() == 0); c.insert(c.end(), i->value.begin(), i->value.end()); } return node_t(c.begin(), c.end()); } }; }; ////////////////////////////////// template <typename ValueT> class node_all_val_data_factory { public: // This inner class is so that node_all_val_data_factory can simulate // a template template parameter template <typename IteratorT> class factory { public: typedef IteratorT iterator_t; typedef node_val_data<iterator_t, ValueT> node_t; static node_t create_node(iterator_t const& first, iterator_t const& last, bool /*is_leaf_node*/) { return node_t(first, last); } static node_t empty_node() { return node_t(); } template <typename ContainerT> static node_t group_nodes(ContainerT const& nodes) { typename node_t::container_t c; typename ContainerT::const_iterator i_end = nodes.end(); // copy all the nodes text into a new one for (typename ContainerT::const_iterator i = nodes.begin(); i != i_end; ++i) { assert(i->children.size() == 0); c.insert(c.end(), i->value.begin(), i->value.end()); } return node_t(c.begin(), c.end()); } }; }; namespace impl { /////////////////////////////////////////////////////////////////////////// // can't call unqualified swap from within classname::swap // as Koenig lookup rules will find only the classname::swap // member function not the global declaration, so use cp_swap // as a forwarding function (JM): #if __GNUC__ == 2 using ::std::swap; #endif template <typename T> inline void cp_swap(T& t1, T& t2) { using std::swap; using BOOST_SPIRIT_CLASSIC_NS::swap; using boost::swap; swap(t1, t2); } } ////////////////////////////////// template <typename IteratorT, typename NodeFactoryT, typename T> class tree_match : public match<T> { public: typedef typename NodeFactoryT::template factory<IteratorT> node_factory_t; typedef typename node_factory_t::node_t parse_node_t; typedef tree_node<parse_node_t> node_t; typedef typename node_t::children_t container_t; typedef typename container_t::iterator tree_iterator; typedef typename container_t::const_iterator const_tree_iterator; typedef T attr_t; typedef typename boost::call_traits<T>::param_type param_type; typedef typename boost::call_traits<T>::reference reference; typedef typename boost::call_traits<T>::const_reference const_reference; tree_match() : match<T>(), trees() {} explicit tree_match(std::size_t length_) : match<T>(length_), trees() {} tree_match(std::size_t length_, parse_node_t const& n) : match<T>(length_), trees() { trees.push_back(node_t(n)); } tree_match(std::size_t length_, param_type val, parse_node_t const& n) : match<T>(length_, val), trees() { #if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) trees.reserve(10); // this is more or less an arbitrary number... #endif trees.push_back(node_t(n)); } // attention, these constructors will change the second parameter! tree_match(std::size_t length_, container_t& c) : match<T>(length_), trees() { impl::cp_swap(trees, c); } tree_match(std::size_t length_, param_type val, container_t& c) : match<T>(length_, val), trees() { impl::cp_swap(trees, c); } template <typename T2> tree_match(match<T2> const& other) : match<T>(other), trees() {} template <typename T2, typename T3, typename T4> tree_match(tree_match<T2, T3, T4> const& other) : match<T>(other), trees() { impl::cp_swap(trees, other.trees); } template <typename T2> tree_match& operator=(match<T2> const& other) { match<T>::operator=(other); return *this; } template <typename T2, typename T3, typename T4> tree_match& operator=(tree_match<T2, T3, T4> const& other) { match<T>::operator=(other); impl::cp_swap(trees, other.trees); return *this; } tree_match(tree_match const& x) : match<T>(x), trees() { // use auto_ptr like ownership for the trees data member impl::cp_swap(trees, x.trees); } tree_match& operator=(tree_match const& x) { tree_match tmp(x); this->swap(tmp); return *this; } void swap(tree_match& x) { match<T>::swap(x); impl::cp_swap(trees, x.trees); } mutable container_t trees; }; #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) template <typename IteratorT, typename NodeFactoryT, typename T> inline std::ostream& operator<<(std::ostream& o, tree_match<IteratorT, NodeFactoryT, T> const& m) { typedef typename tree_match<IteratorT, NodeFactoryT, T>::container_t::iterator iterator; o << "(length = " << (int)m.length(); int c = 0; for (iterator i = m.trees.begin(); i != m.trees.end(); ++i) { o << " trees[" << c++ << "] = " << *i; } o << "\n)"; return o; } #endif ////////////////////////////////// struct tree_policy { template <typename FunctorT, typename MatchT> static void apply_op_to_match(FunctorT const& /*op*/, MatchT& /*m*/) {} template <typename MatchT, typename Iterator1T, typename Iterator2T> static void group_match(MatchT& /*m*/, parser_id const& /*id*/, Iterator1T const& /*first*/, Iterator2T const& /*last*/) {} template <typename MatchT> static void concat(MatchT& /*a*/, MatchT const& /*b*/) {} }; ////////////////////////////////// template < typename MatchPolicyT, typename IteratorT, typename NodeFactoryT, typename TreePolicyT, typename T > struct common_tree_match_policy : public match_policy { common_tree_match_policy() { } template <typename PolicyT> common_tree_match_policy(PolicyT const & policies) : match_policy((match_policy const &)policies) { } template <typename U> struct result { typedef tree_match<IteratorT, NodeFactoryT, U> type; }; typedef tree_match<IteratorT, NodeFactoryT, T> match_t; typedef IteratorT iterator_t; typedef TreePolicyT tree_policy_t; typedef NodeFactoryT factory_t; static const match_t no_match() { return match_t(); } static const match_t empty_match() { return match_t(0, tree_policy_t::empty_node()); } template <typename AttrT, typename Iterator1T, typename Iterator2T> static tree_match<IteratorT, NodeFactoryT, AttrT> create_match( std::size_t length, AttrT const& val, Iterator1T const& first, Iterator2T const& last) { #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) BOOST_SPIRIT_DEBUG_OUT << "\n>>> create_node(begin) <<<\n" "creating node text: \""; for (Iterator1T it = first; it != last; ++it) impl::token_printer(BOOST_SPIRIT_DEBUG_OUT, *it); BOOST_SPIRIT_DEBUG_OUT << "\"\n"; BOOST_SPIRIT_DEBUG_OUT << ">>> create_node(end) <<<\n\n"; #endif return tree_match<IteratorT, NodeFactoryT, AttrT>(length, val, tree_policy_t::create_node(length, first, last, true)); } template <typename Match1T, typename Match2T> static void concat_match(Match1T& a, Match2T const& b) { #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) BOOST_SPIRIT_DEBUG_OUT << "\n>>> concat_match(begin) <<<\n"; BOOST_SPIRIT_DEBUG_OUT << "tree a:\n" << a << "\n"; BOOST_SPIRIT_DEBUG_OUT << "tree b:\n" << b << "\n"; BOOST_SPIRIT_DEBUG_OUT << ">>> concat_match(end) <<<\n\n"; #endif BOOST_SPIRIT_ASSERT(a && b); if (a.length() == 0) { a = b; return; } else if (b.length() == 0 #ifdef BOOST_SPIRIT_NO_TREE_NODE_COLLAPSING && !b.trees.begin()->value.id().to_long() #endif ) { return; } a.concat(b); tree_policy_t::concat(a, b); } template <typename MatchT, typename IteratorT2> void group_match( MatchT& m, parser_id const& id, IteratorT2 const& first, IteratorT2 const& last) const { if (!m) return; #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_TREES) BOOST_SPIRIT_DEBUG_OUT << "\n>>> group_match(begin) <<<\n" "new node(" << id << ") \""; for (IteratorT2 it = first; it != last; ++it) impl::token_printer(BOOST_SPIRIT_DEBUG_OUT, *it); BOOST_SPIRIT_DEBUG_OUT << "\"\n"; BOOST_SPIRIT_DEBUG_OUT << "new child tree (before grouping):\n" << m << "\n"; tree_policy_t::group_match(m, id, first, last); BOOST_SPIRIT_DEBUG_OUT << "new child tree (after grouping):\n" << m << "\n"; BOOST_SPIRIT_DEBUG_OUT << ">>> group_match(end) <<<\n\n"; #else tree_policy_t::group_match(m, id, first, last); #endif } }; ////////////////////////////////// template <typename MatchPolicyT, typename NodeFactoryT> struct common_tree_tree_policy { typedef typename MatchPolicyT::iterator_t iterator_t; typedef typename MatchPolicyT::match_t match_t; typedef typename NodeFactoryT::template factory<iterator_t> factory_t; typedef typename factory_t::node_t node_t; template <typename Iterator1T, typename Iterator2T> static node_t create_node(std::size_t /*length*/, Iterator1T const& first, Iterator2T const& last, bool leaf_node) { return factory_t::create_node(first, last, leaf_node); } static node_t empty_node() { return factory_t::empty_node(); } template <typename FunctorT> static void apply_op_to_match(FunctorT const& op, match_t& m) { op(m); } }; ////////////////////////////////// // directives to modify how the parse tree is generated struct no_tree_gen_node_parser_gen; template <typename T> struct no_tree_gen_node_parser : public unary<T, parser<no_tree_gen_node_parser<T> > > { typedef no_tree_gen_node_parser<T> self_t; typedef no_tree_gen_node_parser_gen parser_generator_t; typedef unary_parser_category parser_category_t; no_tree_gen_node_parser(T const& a) : unary<T, parser<no_tree_gen_node_parser<T> > >(a) {} template <typename ScannerT> typename parser_result<self_t, ScannerT>::type parse(ScannerT const& scanner) const { typedef typename ScannerT::iteration_policy_t iteration_policy_t; typedef match_policy match_policy_t; typedef typename ScannerT::action_policy_t action_policy_t; typedef scanner_policies< iteration_policy_t, match_policy_t, action_policy_t > policies_t; return this->subject().parse(scanner.change_policies(policies_t(scanner))); } }; struct no_tree_gen_node_parser_gen { template <typename T> struct result { typedef no_tree_gen_node_parser<T> type; }; template <typename T> static no_tree_gen_node_parser<T> generate(parser<T> const& s) { return no_tree_gen_node_parser<T>(s.derived()); } template <typename T> no_tree_gen_node_parser<T> operator[](parser<T> const& s) const { return no_tree_gen_node_parser<T>(s.derived()); } }; const no_tree_gen_node_parser_gen no_node_d = no_tree_gen_node_parser_gen(); ////////////////////////////////// struct leaf_node_parser_gen; template<typename T> struct leaf_node_parser : public unary<T, parser<leaf_node_parser<T> > > { typedef leaf_node_parser<T> self_t; typedef leaf_node_parser_gen parser_generator_t; typedef unary_parser_category parser_category_t; leaf_node_parser(T const& a) : unary<T, parser<leaf_node_parser<T> > >(a) {} template <typename ScannerT> typename parser_result<self_t, ScannerT>::type parse(ScannerT const& scanner) const { typedef scanner_policies< typename ScannerT::iteration_policy_t, match_policy, typename ScannerT::action_policy_t > policies_t; typedef typename ScannerT::iterator_t iterator_t; typedef typename parser_result<self_t, ScannerT>::type result_t; typedef typename result_t::node_factory_t factory_t; iterator_t from = scanner.first; result_t hit = impl::contiguous_parser_parse<result_t>(this->subject(), scanner.change_policies(policies_t(scanner,match_policy(),scanner)), scanner); if (hit) return result_t(hit.length(), factory_t::create_node(from, scanner.first, true)); else return result_t(hit.length()); } }; struct leaf_node_parser_gen { template <typename T> struct result { typedef leaf_node_parser<T> type; }; template <typename T> static leaf_node_parser<T> generate(parser<T> const& s) { return leaf_node_parser<T>(s.derived()); } template <typename T> leaf_node_parser<T> operator[](parser<T> const& s) const { return leaf_node_parser<T>(s.derived()); } }; const leaf_node_parser_gen leaf_node_d = leaf_node_parser_gen(); const leaf_node_parser_gen token_node_d = leaf_node_parser_gen(); ////////////////////////////////// namespace impl { template <typename MatchPolicyT> struct tree_policy_selector { typedef tree_policy type; }; } // namespace impl ////////////////////////////////// template <typename NodeParserT> struct node_parser_gen; template <typename T, typename NodeParserT> struct node_parser : public unary<T, parser<node_parser<T, NodeParserT> > > { typedef node_parser<T, NodeParserT> self_t; typedef node_parser_gen<NodeParserT> parser_generator_t; typedef unary_parser_category parser_category_t; node_parser(T const& a) : unary<T, parser<node_parser<T, NodeParserT> > >(a) {} template <typename ScannerT> struct result { typedef typename parser_result<T, ScannerT>::type type; }; template <typename ScannerT> typename parser_result<self_t, ScannerT>::type parse(ScannerT const& scanner) const { typename parser_result<self_t, ScannerT>::type hit = this->subject().parse(scanner); if (hit) { impl::tree_policy_selector<typename ScannerT::match_policy_t>::type::apply_op_to_match(NodeParserT(), hit); } return hit; } }; template <typename NodeParserT> struct node_parser_gen { template <typename T> struct result { typedef node_parser<T, NodeParserT> type; }; template <typename T> static node_parser<T, NodeParserT> generate(parser<T> const& s) { return node_parser<T, NodeParserT>(s.derived()); } template <typename T> node_parser<T, NodeParserT> operator[](parser<T> const& s) const { return node_parser<T, NodeParserT>(s.derived()); } }; ////////////////////////////////// struct reduced_node_op { template <typename MatchT> void operator()(MatchT& m) const { if (m.trees.size() == 1) { m.trees.begin()->children.clear(); } else if (m.trees.size() > 1) { typedef typename MatchT::node_factory_t node_factory_t; m = MatchT(m.length(), node_factory_t::group_nodes(m.trees)); } } }; const node_parser_gen<reduced_node_op> reduced_node_d = node_parser_gen<reduced_node_op>(); struct discard_node_op { template <typename MatchT> void operator()(MatchT& m) const { m.trees.clear(); } }; const node_parser_gen<discard_node_op> discard_node_d = node_parser_gen<discard_node_op>(); struct infix_node_op { template <typename MatchT> void operator()(MatchT& m) const { typedef typename MatchT::container_t container_t; typedef typename MatchT::container_t::iterator iter_t; typedef typename MatchT::container_t::value_type value_t; using std::swap; using boost::swap; using BOOST_SPIRIT_CLASSIC_NS::swap; // copying the tree nodes is expensive, since it may copy a whole // tree. swapping them is cheap, so swap the nodes we want into // a new container of children. container_t new_children; std::size_t length = 0; std::size_t tree_size = m.trees.size(); // the infix_node_d[] make no sense for nodes with no subnodes BOOST_SPIRIT_ASSERT(tree_size >= 1); bool keep = true; #if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) new_children.reserve((tree_size+1)/2); #endif iter_t i_end = m.trees.end(); for (iter_t i = m.trees.begin(); i != i_end; ++i) { if (keep) { // adjust the length length += std::distance((*i).value.begin(), (*i).value.end()); // move the child node new_children.push_back(value_t()); swap(new_children.back(), *i); keep = false; } else { // ignore this child node keep = true; } } m = MatchT(length, new_children); } }; const node_parser_gen<infix_node_op> infix_node_d = node_parser_gen<infix_node_op>(); struct discard_first_node_op { template <typename MatchT> void operator()(MatchT& m) const { typedef typename MatchT::container_t container_t; typedef typename MatchT::container_t::iterator iter_t; typedef typename MatchT::container_t::value_type value_t; using std::swap; using boost::swap; using BOOST_SPIRIT_CLASSIC_NS::swap; // copying the tree nodes is expensive, since it may copy a whole // tree. swapping them is cheap, so swap the nodes we want into // a new container of children, instead of saying // m.trees.erase(m.trees.begin()) because, on a container_t that will // cause all the nodes afterwards to be copied into the previous // position. container_t new_children; std::size_t length = 0; std::size_t tree_size = m.trees.size(); // the discard_first_node_d[] make no sense for nodes with no subnodes BOOST_SPIRIT_ASSERT(tree_size >= 1); if (tree_size > 1) { #if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) new_children.reserve(tree_size - 1); #endif iter_t i = m.trees.begin(), i_end = m.trees.end(); for (++i; i != i_end; ++i) { // adjust the length length += std::distance((*i).value.begin(), (*i).value.end()); // move the child node new_children.push_back(value_t()); swap(new_children.back(), *i); } } else { // if there was a tree and now there isn't any, insert an empty node iter_t i = m.trees.begin(); // This isn't entirely correct, since the empty node will reference // the end of the discarded node, but I currently don't see any way to // get at the begin of the node following this subnode. // This should be safe anyway because the it shouldn't get dereferenced // under any circumstances. typedef typename value_t::parse_node_t::iterator_t iterator_type; iterator_type it = (*i).value.end(); new_children.push_back( value_t(typename value_t::parse_node_t(it, it))); } m = MatchT(length, new_children); } }; const node_parser_gen<discard_first_node_op> discard_first_node_d = node_parser_gen<discard_first_node_op>(); struct discard_last_node_op { template <typename MatchT> void operator()(MatchT& m) const { typedef typename MatchT::container_t container_t; typedef typename MatchT::container_t::iterator iter_t; typedef typename MatchT::container_t::value_type value_t; using std::swap; using boost::swap; using BOOST_SPIRIT_CLASSIC_NS::swap; // copying the tree nodes is expensive, since it may copy a whole // tree. swapping them is cheap, so swap the nodes we want into // a new container of children, instead of saying // m.trees.erase(m.trees.begin()) because, on a container_t that will // cause all the nodes afterwards to be copied into the previous // position. container_t new_children; std::size_t length = 0; std::size_t tree_size = m.trees.size(); // the discard_last_node_d[] make no sense for nodes with no subnodes BOOST_SPIRIT_ASSERT(tree_size >= 1); if (tree_size > 1) { m.trees.pop_back(); #if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) new_children.reserve(tree_size - 1); #endif iter_t i_end = m.trees.end(); for (iter_t i = m.trees.begin(); i != i_end; ++i) { // adjust the length length += std::distance((*i).value.begin(), (*i).value.end()); // move the child node new_children.push_back(value_t()); swap(new_children.back(), *i); } } else { // if there was a tree and now there isn't any, insert an empty node iter_t i = m.trees.begin(); typedef typename value_t::parse_node_t::iterator_t iterator_type; iterator_type it = (*i).value.begin(); new_children.push_back( value_t(typename value_t::parse_node_t(it, it))); } m = MatchT(length, new_children); } }; const node_parser_gen<discard_last_node_op> discard_last_node_d = node_parser_gen<discard_last_node_op>(); struct inner_node_op { template <typename MatchT> void operator()(MatchT& m) const { typedef typename MatchT::container_t container_t; typedef typename MatchT::container_t::iterator iter_t; typedef typename MatchT::container_t::value_type value_t; using std::swap; using boost::swap; using BOOST_SPIRIT_CLASSIC_NS::swap; // copying the tree nodes is expensive, since it may copy a whole // tree. swapping them is cheap, so swap the nodes we want into // a new container of children, instead of saying // m.trees.erase(m.trees.begin()) because, on a container_t that will // cause all the nodes afterwards to be copied into the previous // position. container_t new_children; std::size_t length = 0; std::size_t tree_size = m.trees.size(); // the inner_node_d[] make no sense for nodes with less then 2 subnodes BOOST_SPIRIT_ASSERT(tree_size >= 2); if (tree_size > 2) { m.trees.pop_back(); // erase the last element #if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES) new_children.reserve(tree_size - 1); #endif iter_t i = m.trees.begin(); // skip over the first element iter_t i_end = m.trees.end(); for (++i; i != i_end; ++i) { // adjust the length length += std::distance((*i).value.begin(), (*i).value.end()); // move the child node new_children.push_back(value_t()); swap(new_children.back(), *i); } } else { // if there was a tree and now there isn't any, insert an empty node iter_t i = m.trees.begin(); // skip over the first element typedef typename value_t::parse_node_t::iterator_t iterator_type; iterator_type it = (*++i).value.begin(); new_children.push_back( value_t(typename value_t::parse_node_t(it, it))); } m = MatchT(length, new_children); } }; const node_parser_gen<inner_node_op> inner_node_d = node_parser_gen<inner_node_op>(); ////////////////////////////////// // action_directive_parser and action_directive_parser_gen // are meant to be used as a template to create directives that // generate action classes. For example access_match and // access_node. The ActionParserT template parameter must be // a class that has an innter class called action that is templated // on the parser type and the action type. template <typename ActionParserT> struct action_directive_parser_gen; template <typename T, typename ActionParserT> struct action_directive_parser : public unary<T, parser<action_directive_parser<T, ActionParserT> > > { typedef action_directive_parser<T, ActionParserT> self_t; typedef action_directive_parser_gen<ActionParserT> parser_generator_t; typedef unary_parser_category parser_category_t; action_directive_parser(T const& a) : unary<T, parser<action_directive_parser<T, ActionParserT> > >(a) {} template <typename ScannerT> struct result { typedef typename parser_result<T, ScannerT>::type type; }; template <typename ScannerT> typename parser_result<self_t, ScannerT>::type parse(ScannerT const& scanner) const { return this->subject().parse(scanner); } template <typename ActionT> typename ActionParserT::template action<action_directive_parser<T, ActionParserT>, ActionT> operator[](ActionT const& actor) const { typedef typename ActionParserT::template action<action_directive_parser, ActionT> action_t; return action_t(*this, actor); } }; ////////////////////////////////// template <typename ActionParserT> struct action_directive_parser_gen { template <typename T> struct result { typedef action_directive_parser<T, ActionParserT> type; }; template <typename T> static action_directive_parser<T, ActionParserT> generate(parser<T> const& s) { return action_directive_parser<T, ActionParserT>(s.derived()); } template <typename T> action_directive_parser<T, ActionParserT> operator[](parser<T> const& s) const { return action_directive_parser<T, ActionParserT>(s.derived()); } }; ////////////////////////////////// // Calls the attached action passing it the match from the parser // and the first and last iterators. // The inner template class is used to simulate template-template parameters // (declared in common_fwd.hpp). template <typename ParserT, typename ActionT> struct access_match_action::action : public unary<ParserT, parser<access_match_action::action<ParserT, ActionT> > > { typedef action_parser_category parser_category; typedef action<ParserT, ActionT> self_t; template <typename ScannerT> struct result { typedef typename parser_result<ParserT, ScannerT>::type type; }; action( ParserT const& subject, ActionT const& actor_); template <typename ScannerT> typename parser_result<self_t, ScannerT>::type parse(ScannerT const& scanner) const; ActionT const &predicate() const; private: ActionT actor; }; ////////////////////////////////// template <typename ParserT, typename ActionT> access_match_action::action<ParserT, ActionT>::action( ParserT const& subject, ActionT const& actor_) : unary<ParserT, parser<access_match_action::action<ParserT, ActionT> > >(subject) , actor(actor_) {} ////////////////////////////////// template <typename ParserT, typename ActionT> template <typename ScannerT> typename parser_result<access_match_action::action<ParserT, ActionT>, ScannerT>::type access_match_action::action<ParserT, ActionT>:: parse(ScannerT const& scan) const { typedef typename ScannerT::iterator_t iterator_t; typedef typename parser_result<self_t, ScannerT>::type result_t; if (!scan.at_end()) { iterator_t save = scan.first; result_t hit = this->subject().parse(scan); actor(hit, save, scan.first); return hit; } return scan.no_match(); } ////////////////////////////////// template <typename ParserT, typename ActionT> ActionT const &access_match_action::action<ParserT, ActionT>::predicate() const { return actor; } ////////////////////////////////// const action_directive_parser_gen<access_match_action> access_match_d = action_directive_parser_gen<access_match_action>(); ////////////////////////////////// // Calls the attached action passing it the node from the parser // and the first and last iterators // The inner template class is used to simulate template-template parameters // (declared in common_fwd.hpp). template <typename ParserT, typename ActionT> struct access_node_action::action : public unary<ParserT, parser<access_node_action::action<ParserT, ActionT> > > { typedef action_parser_category parser_category; typedef action<ParserT, ActionT> self_t; template <typename ScannerT> struct result { typedef typename parser_result<ParserT, ScannerT>::type type; }; action( ParserT const& subject, ActionT const& actor_); template <typename ScannerT> typename parser_result<self_t, ScannerT>::type parse(ScannerT const& scanner) const; ActionT const &predicate() const; private: ActionT actor; }; ////////////////////////////////// template <typename ParserT, typename ActionT> access_node_action::action<ParserT, ActionT>::action( ParserT const& subject, ActionT const& actor_) : unary<ParserT, parser<access_node_action::action<ParserT, ActionT> > >(subject) , actor(actor_) {} ////////////////////////////////// template <typename ParserT, typename ActionT> template <typename ScannerT> typename parser_result<access_node_action::action<ParserT, ActionT>, ScannerT>::type access_node_action::action<ParserT, ActionT>:: parse(ScannerT const& scan) const { typedef typename ScannerT::iterator_t iterator_t; typedef typename parser_result<self_t, ScannerT>::type result_t; if (!scan.at_end()) { iterator_t save = scan.first; result_t hit = this->subject().parse(scan); if (hit && hit.trees.size() > 0) actor(*hit.trees.begin(), save, scan.first); return hit; } return scan.no_match(); } ////////////////////////////////// template <typename ParserT, typename ActionT> ActionT const &access_node_action::action<ParserT, ActionT>::predicate() const { return actor; } ////////////////////////////////// const action_directive_parser_gen<access_node_action> access_node_d = action_directive_parser_gen<access_node_action>(); ////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // // tree_parse_info // // Results returned by the tree parse functions: // // stop: points to the final parse position (i.e parsing // processed the input up to this point). // // match: true if parsing is successful. This may be full: // the parser consumed all the input, or partial: // the parser consumed only a portion of the input. // // full: true when we have a full match (i.e the parser // consumed all the input. // // length: The number of characters consumed by the parser. // This is valid only if we have a successful match // (either partial or full). A negative value means // that the match is unsucessful. // // trees: Contains the root node(s) of the tree. // /////////////////////////////////////////////////////////////////////////////// template < typename IteratorT, typename NodeFactoryT, typename T > struct tree_parse_info { IteratorT stop; bool match; bool full; std::size_t length; typename tree_match<IteratorT, NodeFactoryT, T>::container_t trees; tree_parse_info() : stop() , match(false) , full(false) , length(0) , trees() {} template <typename IteratorT2> tree_parse_info(tree_parse_info<IteratorT2> const& pi) : stop(pi.stop) , match(pi.match) , full(pi.full) , length(pi.length) , trees() { using std::swap; using boost::swap; using BOOST_SPIRIT_CLASSIC_NS::swap; // use auto_ptr like ownership for the trees data member swap(trees, pi.trees); } tree_parse_info( IteratorT stop_, bool match_, bool full_, std::size_t length_, typename tree_match<IteratorT, NodeFactoryT, T>::container_t trees_) : stop(stop_) , match(match_) , full(full_) , length(length_) , trees() { using std::swap; using boost::swap; using BOOST_SPIRIT_CLASSIC_NS::swap; // use auto_ptr like ownership for the trees data member swap(trees, trees_); } }; BOOST_SPIRIT_CLASSIC_NAMESPACE_END }} // namespace BOOST_SPIRIT_CLASSIC_NS #endif
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %rax push %rbp push %rcx push %rdi push %rsi lea addresses_UC_ht+0x7bd, %r10 nop add %rbp, %rbp mov $0x6162636465666768, %rax movq %rax, (%r10) nop xor %r11, %r11 lea addresses_UC_ht+0xd7bd, %r12 nop dec %r10 movl $0x61626364, (%r12) nop nop cmp $53175, %rcx lea addresses_A_ht+0xe9bd, %r12 nop nop and $8868, %rax mov (%r12), %r11d nop nop nop nop sub $4314, %rcx lea addresses_UC_ht+0x5bbd, %rsi lea addresses_WT_ht+0x1cfbd, %rdi nop nop nop nop cmp %r11, %r11 mov $69, %rcx rep movsw nop nop nop nop dec %r11 lea addresses_UC_ht+0xe341, %rbp nop nop nop inc %r10 movb (%rbp), %r12b nop nop nop nop nop add %rax, %rax pop %rsi pop %rdi pop %rcx pop %rbp pop %rax pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r13 push %r9 push %rax push %rcx // Store lea addresses_A+0x1f75d, %r10 nop nop cmp $56233, %rax mov $0x5152535455565758, %r13 movq %r13, %xmm3 movaps %xmm3, (%r10) nop nop cmp $47425, %r9 // Store lea addresses_D+0xa9bd, %rcx nop nop nop add $14137, %r12 movw $0x5152, (%rcx) nop nop nop nop add %r12, %r12 // Faulty Load lea addresses_US+0xfbd, %rax nop nop nop nop sub $48745, %rcx vmovups (%rax), %ymm7 vextracti128 $0, %ymm7, %xmm7 vpextrq $1, %xmm7, %r10 lea oracles, %r13 and $0xff, %r10 shlq $12, %r10 mov (%r13,%r10,1), %r10 pop %rcx pop %rax pop %r9 pop %r13 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 16, 'AVXalign': True, 'NT': True, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D', 'size': 2, 'AVXalign': False, 'NT': True, 'congruent': 9, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 8, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'00': 3212} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
format PE GUI 4.0 stack 0x1000 entry start ..ShowSkipped equ ON ..ShowSizes equ ON include '%finc%\win32\win32a.inc' include '%finc%\libs\msgutils.inc' include 'source\giflib.inc' section '.code' code readable executable uglobal hInstance dd 0 ; Instance handle for common use. endg include '%finc%\libs\msgutils.asm' include 'MainWindow.asm' include 'source\giflib.asm' start: ; Main init sequence invoke GetModuleHandle,0 mov [hInstance],eax ; Startup windows creation call InitMainWindow ; Create main window. include '%finc%\libs\MainLoop.asm' ;***************************************************************** ; Main static data section. ; Actually this is the only data section in the program. ;***************************************************************** section '.data' data readable writeable IncludeAllGlobals section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL', \ gdi32,'gdi32.dll', \ comctl32,'comctl32.dll',\ comdlg32,'comdlg32.dll',\ shell32, 'shell32.dll', \ ole32, 'ole32.dll' include '%finc%\win32\apia\kernel32.inc' include '%finc%\win32\apia\user32.inc' include '%finc%\win32\apia\gdi32.inc' include '%finc%\win32\apia\ComCtl32.inc' include '%finc%\win32\apia\ComDlg32.inc' include '%finc%\win32\apia\Shell32.inc' include '%finc%\win32\apia\ole32.inc' section '.rsrc' resource from 'GifTest.res' data readable
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "components/gcm_driver/gcm_driver.h" #include <algorithm> #include "base/bind.h" #include "base/logging.h" #include "components/gcm_driver/gcm_app_handler.h" namespace gcm { GCMDriver::GCMDriver() : weak_ptr_factory_(this) { } GCMDriver::~GCMDriver() { } void GCMDriver::Register(const std::string& app_id, const std::vector<std::string>& sender_ids, const RegisterCallback& callback) { DCHECK(!app_id.empty()); DCHECK(!sender_ids.empty()); DCHECK(!callback.is_null()); GCMClient::Result result = EnsureStarted(GCMClient::IMMEDIATE_START); if (result != GCMClient::SUCCESS) { callback.Run(std::string(), result); return; } // If previous register operation is still in progress, bail out. if (register_callbacks_.find(app_id) != register_callbacks_.end()) { callback.Run(std::string(), GCMClient::ASYNC_OPERATION_PENDING); return; } // Normalize the sender IDs by making them sorted. std::vector<std::string> normalized_sender_ids = sender_ids; std::sort(normalized_sender_ids.begin(), normalized_sender_ids.end()); register_callbacks_[app_id] = callback; // If previous unregister operation is still in progress, wait until it // finishes. We don't want to throw ASYNC_OPERATION_PENDING when the user // uninstalls an app (ungistering) and then reinstalls the app again // (registering). std::map<std::string, UnregisterCallback>::iterator unregister_iter = unregister_callbacks_.find(app_id); if (unregister_iter != unregister_callbacks_.end()) { // Replace the original unregister callback with an intermediate callback // that will invoke the original unregister callback and trigger the pending // registration after the unregistration finishes. // Note that some parameters to RegisterAfterUnregister are specified here // when the callback is created (base::Bind supports the partial binding // of parameters). unregister_iter->second = base::Bind( &GCMDriver::RegisterAfterUnregister, weak_ptr_factory_.GetWeakPtr(), app_id, normalized_sender_ids, unregister_iter->second); return; } RegisterImpl(app_id, normalized_sender_ids); } void GCMDriver::Unregister(const std::string& app_id, const UnregisterCallback& callback) { UnregisterInternal(app_id, nullptr /* sender_id */, callback); } void GCMDriver::UnregisterWithSenderId( const std::string& app_id, const std::string& sender_id, const UnregisterCallback& callback) { DCHECK(!sender_id.empty()); UnregisterInternal(app_id, &sender_id, callback); } void GCMDriver::UnregisterInternal(const std::string& app_id, const std::string* sender_id, const UnregisterCallback& callback) { DCHECK(!app_id.empty()); DCHECK(!callback.is_null()); GCMClient::Result result = EnsureStarted(GCMClient::IMMEDIATE_START); if (result != GCMClient::SUCCESS) { callback.Run(result); return; } // If previous un/register operation is still in progress, bail out. if (register_callbacks_.find(app_id) != register_callbacks_.end() || unregister_callbacks_.find(app_id) != unregister_callbacks_.end()) { callback.Run(GCMClient::ASYNC_OPERATION_PENDING); return; } unregister_callbacks_[app_id] = callback; if (sender_id) UnregisterWithSenderIdImpl(app_id, *sender_id); else UnregisterImpl(app_id); } void GCMDriver::Send(const std::string& app_id, const std::string& receiver_id, const GCMClient::OutgoingMessage& message, const SendCallback& callback) { DCHECK(!app_id.empty()); DCHECK(!receiver_id.empty()); DCHECK(!callback.is_null()); GCMClient::Result result = EnsureStarted(GCMClient::IMMEDIATE_START); if (result != GCMClient::SUCCESS) { callback.Run(std::string(), result); return; } // If the message with send ID is still in progress, bail out. std::pair<std::string, std::string> key(app_id, message.id); if (send_callbacks_.find(key) != send_callbacks_.end()) { callback.Run(message.id, GCMClient::INVALID_PARAMETER); return; } send_callbacks_[key] = callback; SendImpl(app_id, receiver_id, message); } void GCMDriver::UnregisterWithSenderIdImpl(const std::string& app_id, const std::string& sender_id) { NOTREACHED(); } void GCMDriver::RegisterFinished(const std::string& app_id, const std::string& registration_id, GCMClient::Result result) { std::map<std::string, RegisterCallback>::iterator callback_iter = register_callbacks_.find(app_id); if (callback_iter == register_callbacks_.end()) { // The callback could have been removed when the app is uninstalled. return; } RegisterCallback callback = callback_iter->second; register_callbacks_.erase(callback_iter); callback.Run(registration_id, result); } void GCMDriver::UnregisterFinished(const std::string& app_id, GCMClient::Result result) { std::map<std::string, UnregisterCallback>::iterator callback_iter = unregister_callbacks_.find(app_id); if (callback_iter == unregister_callbacks_.end()) return; UnregisterCallback callback = callback_iter->second; unregister_callbacks_.erase(callback_iter); callback.Run(result); } void GCMDriver::SendFinished(const std::string& app_id, const std::string& message_id, GCMClient::Result result) { std::map<std::pair<std::string, std::string>, SendCallback>::iterator callback_iter = send_callbacks_.find( std::pair<std::string, std::string>(app_id, message_id)); if (callback_iter == send_callbacks_.end()) { // The callback could have been removed when the app is uninstalled. return; } SendCallback callback = callback_iter->second; send_callbacks_.erase(callback_iter); callback.Run(message_id, result); } void GCMDriver::Shutdown() { for (GCMAppHandlerMap::const_iterator iter = app_handlers_.begin(); iter != app_handlers_.end(); ++iter) { DVLOG(1) << "Calling ShutdownHandler for: " << iter->first; iter->second->ShutdownHandler(); } app_handlers_.clear(); } void GCMDriver::AddAppHandler(const std::string& app_id, GCMAppHandler* handler) { DCHECK(!app_id.empty()); DCHECK(handler); DCHECK_EQ(app_handlers_.count(app_id), 0u); app_handlers_[app_id] = handler; DVLOG(1) << "App handler added for: " << app_id; } void GCMDriver::RemoveAppHandler(const std::string& app_id) { DCHECK(!app_id.empty()); app_handlers_.erase(app_id); DVLOG(1) << "App handler removed for: " << app_id; } GCMAppHandler* GCMDriver::GetAppHandler(const std::string& app_id) { // Look for exact match. GCMAppHandlerMap::const_iterator iter = app_handlers_.find(app_id); if (iter != app_handlers_.end()) return iter->second; // Ask the handlers whether they know how to handle it. for (iter = app_handlers_.begin(); iter != app_handlers_.end(); ++iter) { if (iter->second->CanHandle(app_id)) return iter->second; } return &default_app_handler_; } bool GCMDriver::HasRegisterCallback(const std::string& app_id) { return register_callbacks_.find(app_id) != register_callbacks_.end(); } void GCMDriver::ClearCallbacks() { register_callbacks_.clear(); unregister_callbacks_.clear(); send_callbacks_.clear(); } void GCMDriver::RegisterAfterUnregister( const std::string& app_id, const std::vector<std::string>& normalized_sender_ids, const UnregisterCallback& unregister_callback, GCMClient::Result result) { // Invoke the original unregister callback. unregister_callback.Run(result); // Trigger the pending registration. DCHECK(register_callbacks_.find(app_id) != register_callbacks_.end()); RegisterImpl(app_id, normalized_sender_ids); } } // namespace gcm
; A213544: Sum of numerators of Farey Sequence of order n. ; 1,2,5,9,19,25,46,62,89,109,164,188,266,308,368,432,568,622,793,873,999,1109,1362,1458,1708,1864,2107,2275,2681,2801,3266,3522,3852,4124,4544,4760,5426,5768,6236,6556,7376,7628,8531,8971,9511,10017,11098,11482,12511,13011,13827,14451,15829,16315,17415,18087,19113,19925,21636,22116,23946,24876,26010,27034,28594,29254,31465,32553,34071,34911,37396,38260,40888,42220,43720,45088,47398,48334,51415,52695,54882,56522,59925,60933,63653,65459,67895,69655,73571,74651,77927,79951,82741,84903,88323,89859 lpb $0 mov $2,$0 sub $0,1 seq $2,2618 ; a(n) = n*phi(n). add $1,$2 lpe div $1,2 add $1,1 mov $0,$1
;/*! ; @file ; ; @brief BvsSetCurType DOS wrapper ; ; (c) osFree Project 2008-2022, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ; * 0 NO_ERROR ; * 355 ERROR_VIO_MODE ; * 356 ERROR_VIO_WIDTH ; * 421 ERROR_VIO_INVALID_PARMS ; * 436 ERROR_VIO_INVALID_HANDLE ; * 465 ERROR_VIO_DETACHED ; ; @todo add params checks ; ;*/ .8086 ; Helpers INCLUDE helpers.inc INCLUDE bios.inc INCL_SUB EQU 1 INCLUDE bseerr.inc INCLUDE bsesub.inc _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 @BVSPROLOG BVSSETCURTYPE VIOHANDLE DW ? ;VIDEO HANDLE CURINFO DD ? ; @BVSSTART BVSSETCURTYPE EXTERN VIOCHECKHANDLE: PROC MOV BX,[DS:BP].ARGS.VIOHANDLE ; GET HANDLE CALL VIOCHECKHANDLE JNZ EXIT LDS SI,[DS:BP].ARGS.CURINFO MOV AX,[DS:SI].VIOCURSORINFO.VIOCI_YSTART AND AL,01FH MOV CH,AL MOV AX,[DS:SI].VIOCURSORINFO.VIOCI_CEND AND AL,01FH @SetCurSz CH, AL XOR AX,AX EXIT: @BVSEPILOG BVSSETCURTYPE _TEXT ENDS END
############################################################################### # Copyright 2019 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 5, 0x90 .globl _e9_Touch_SubsDword_8uT _e9_Touch_SubsDword_8uT: movslq %edx, %r8 xor %rcx, %rcx .Ltouch_tblgas_1: mov (%rsi,%rcx), %rax add $(64), %rcx cmp %r8, %rcx jl .Ltouch_tblgas_1 mov %rdi, %rax and $(255), %rax movzbq (%rsi,%rax), %rax shr $(8), %rdi mov %rdi, %r9 and $(255), %r9 movzbq (%r9,%rsi), %r9 shl $(8), %r9 shr $(8), %rdi mov %rdi, %rcx and $(255), %rcx movzbq (%rsi,%rcx), %rcx shl $(16), %rcx shr $(8), %rdi mov %rdi, %rdx and $(255), %rdx movzbq (%rsi,%rdx), %rdx shl $(24), %rdx or %r9, %rax or %rcx, %rax or %rdx, %rax vzeroupper ret
; A275367: Number of odd divisors of n^2. ; 1,1,3,1,3,3,3,1,5,3,3,3,3,3,9,1,3,5,3,3,9,3,3,3,5,3,7,3,3,9,3,1,9,3,9,5,3,3,9,3,3,9,3,3,15,3,3,3,5,5,9,3,3,7,9,3,9,3,3,9,3,3,15,1,9,9,3,3,9,9,3,5,3,3,15,3,9,9,3,3,9,3,3,9,9,3,9,3,3,15,9,3,9,3,9,3,3,5,15,5,3,9,3,3,27,3,3,7,3,9,9,3,3,9,9,3,15,3,9,9,5,3,9,3,7,15,3,1,9,9,3,9,9,3,21,3,3,9,3,9,9,3,9,5,9,3,15,3,3,15,3,3,15,9,9,9,3,3,9,3,9,9,3,3,27,3,3,9,5,9,15,3,3,9,15,3,9,3,3,15,3,9,9,3,9,9,9,3,21,9,3,3,3,3,27,5,3,15,3,5,9,3,9,9,9,3,15,3,9,27,3,3,9,3,9,7,9,3,9,9,9,9,3,3,25,3,3,9,3,9,27,3,3,15,9,3,9,9,3,9,3,5,11,3,15,9,9,3,9,7 add $0,1 pow $0,2 sub $0,1 cal $0,1227 ; Number of odd divisors of n. mov $1,$0
SFX_Denied_3_Ch1: duty 3 unknownsfx0x10 90 unknownsfx0x20 4, 240, 0, 5 unknownsfx0x10 8 unknownsfx0x20 4, 0, 0, 0 unknownsfx0x20 15, 240, 0, 5 unknownsfx0x20 1, 0, 0, 0 endchannel SFX_Denied_3_Ch2: duty 3 unknownsfx0x20 4, 240, 1, 4 unknownsfx0x20 4, 0, 0, 0 unknownsfx0x20 15, 240, 1, 4 unknownsfx0x20 1, 0, 0, 0 endchannel
; A081347: First column in maze arrangement of natural numbers. ; 1,2,3,12,13,30,31,56,57,90,91,132,133,182,183,240,241,306,307,380,381,462,463,552,553,650,651,756,757,870,871,992,993,1122,1123,1260,1261,1406,1407,1560,1561,1722,1723,1892,1893,2070,2071,2256,2257,2450,2451,2652,2653,2862,2863,3080,3081,3306,3307,3540,3541,3782,3783,4032,4033,4290,4291,4556,4557,4830,4831,5112,5113,5402,5403,5700,5701,6006,6007,6320,6321,6642,6643,6972,6973,7310,7311,7656,7657,8010,8011,8372,8373,8742,8743,9120,9121,9506,9507,9900 mov $2,$0 sub $0,1 div $0,2 mul $0,2 add $0,1 pow $0,2 add $0,$2
// Copyright 2015 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "testing/js_embedder_test.h" JSEmbedderTest::JSEmbedderTest() : m_pArrayBufferAllocator(new FXJS_ArrayBufferAllocator) { v8::Isolate::CreateParams params; params.array_buffer_allocator = m_pArrayBufferAllocator.get(); m_pIsolate = v8::Isolate::New(params); } JSEmbedderTest::~JSEmbedderTest() { m_pIsolate->Dispose(); } void JSEmbedderTest::SetUp() { EmbedderTest::SetExternalIsolate(m_pIsolate); EmbedderTest::SetUp(); v8::Isolate::Scope isolate_scope(m_pIsolate); #ifdef PDF_ENABLE_XFA v8::Locker locker(m_pIsolate); #endif // PDF_ENABLE_XFA v8::HandleScope handle_scope(m_pIsolate); FXJS_PerIsolateData::SetUp(m_pIsolate); FXJS_InitializeRuntime(m_pIsolate, nullptr, &m_pPersistentContext, &m_StaticObjects); } void JSEmbedderTest::TearDown() { FXJS_ReleaseRuntime(m_pIsolate, &m_pPersistentContext, &m_StaticObjects); m_pPersistentContext.Reset(); FXJS_Release(); EmbedderTest::TearDown(); } v8::Isolate* JSEmbedderTest::isolate() { return m_pIsolate; } v8::Local<v8::Context> JSEmbedderTest::GetV8Context() { return m_pPersistentContext.Get(m_pIsolate); }
;***************************************************************************** ;* x86-optimized functions for blend filter ;* ;* Copyright (C) 2015 Paul B Mahol ;* ;* 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 ps_255: times 4 dd 255.0 pw_1: times 8 dw 1 pw_128: times 8 dw 128 pw_255: times 8 dw 255 pb_127: times 16 db 127 pb_128: times 16 db 128 pb_255: times 16 db 255 SECTION .text %macro BLEND_INIT 2 %if ARCH_X86_64 cglobal blend_%1, 6, 9, %2, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, end, x mov widthd, dword widthm %else cglobal blend_%1, 5, 7, %2, top, top_linesize, bottom, bottom_linesize, dst, end, x %define dst_linesizeq r5mp %define widthq r6mp %endif mov endd, dword r7m add topq, widthq add bottomq, widthq add dstq, widthq neg widthq %endmacro %macro BLEND_END 0 add topq, top_linesizeq add bottomq, bottom_linesizeq add dstq, dst_linesizeq sub endd, 1 jg .nextrow REP_RET %endmacro %macro BLEND_SIMPLE 2 BLEND_INIT %1, 2 .nextrow: mov xq, widthq .loop: movu m0, [topq + xq] movu m1, [bottomq + xq] p%2 m0, m1 mova [dstq + xq], m0 add xq, mmsize jl .loop BLEND_END %endmacro INIT_XMM sse2 BLEND_SIMPLE xor, xor BLEND_SIMPLE or, or BLEND_SIMPLE and, and BLEND_SIMPLE addition, addusb BLEND_SIMPLE subtract, subusb BLEND_SIMPLE darken, minub BLEND_SIMPLE lighten, maxub BLEND_INIT difference128, 4 pxor m2, m2 mova m3, [pw_128] .nextrow: mov xq, widthq .loop: movh m0, [topq + xq] movh m1, [bottomq + xq] punpcklbw m0, m2 punpcklbw m1, m2 paddw m0, m3 psubw m0, m1 packuswb m0, m0 movh [dstq + xq], m0 add xq, mmsize / 2 jl .loop BLEND_END %macro MULTIPLY 3 ; a, b, pw_1 pmullw %1, %2 ; xxxxxxxx a * b paddw %1, %3 mova %2, %1 psrlw %2, 8 paddw %1, %2 psrlw %1, 8 ; 00xx00xx a * b / 255 %endmacro %macro SCREEN 4 ; a, b, pw_1, pw_255 pxor %1, %4 ; 00xx00xx 255 - a pxor %2, %4 MULTIPLY %1, %2, %3 pxor %1, %4 ; 00xx00xx 255 - x / 255 %endmacro BLEND_INIT multiply, 4 pxor m2, m2 mova m3, [pw_1] .nextrow: mov xq, widthq .loop: ; word ; |--| movh m0, [topq + xq] ; 0000xxxx movh m1, [bottomq + xq] punpcklbw m0, m2 ; 00xx00xx punpcklbw m1, m2 MULTIPLY m0, m1, m3 packuswb m0, m0 ; 0000xxxx movh [dstq + xq], m0 add xq, mmsize / 2 jl .loop BLEND_END BLEND_INIT screen, 5 pxor m2, m2 mova m3, [pw_1] mova m4, [pw_255] .nextrow: mov xq, widthq .loop: movh m0, [topq + xq] ; 0000xxxx movh m1, [bottomq + xq] punpcklbw m0, m2 ; 00xx00xx punpcklbw m1, m2 SCREEN m0, m1, m3, m4 packuswb m0, m0 ; 0000xxxx movh [dstq + xq], m0 add xq, mmsize / 2 jl .loop BLEND_END BLEND_INIT average, 3 pxor m2, m2 .nextrow: mov xq, widthq .loop: movh m0, [topq + xq] movh m1, [bottomq + xq] punpcklbw m0, m2 punpcklbw m1, m2 paddw m0, m1 psrlw m0, 1 packuswb m0, m0 movh [dstq + xq], m0 add xq, mmsize / 2 jl .loop BLEND_END BLEND_INIT addition128, 4 pxor m2, m2 mova m3, [pw_128] .nextrow: mov xq, widthq .loop: movh m0, [topq + xq] movh m1, [bottomq + xq] punpcklbw m0, m2 punpcklbw m1, m2 paddw m0, m1 psubw m0, m3 packuswb m0, m0 movh [dstq + xq], m0 add xq, mmsize / 2 jl .loop BLEND_END BLEND_INIT hardmix, 5 mova m2, [pb_255] mova m3, [pb_128] mova m4, [pb_127] .nextrow: mov xq, widthq .loop: movu m0, [topq + xq] movu m1, [bottomq + xq] pxor m1, m4 pxor m0, m3 pcmpgtb m1, m0 pxor m1, m2 mova [dstq + xq], m1 add xq, mmsize jl .loop BLEND_END BLEND_INIT divide, 4 pxor m2, m2 mova m3, [ps_255] .nextrow: mov xq, widthq .loop: movd m0, [topq + xq] ; 000000xx movd m1, [bottomq + xq] punpcklbw m0, m2 ; 00000x0x punpcklbw m1, m2 punpcklwd m0, m2 ; 000x000x punpcklwd m1, m2 cvtdq2ps m0, m0 cvtdq2ps m1, m1 divps m0, m1 ; a / b mulps m0, m3 ; a / b * 255 minps m0, m3 cvttps2dq m0, m0 packssdw m0, m0 ; 00000x0x packuswb m0, m0 ; 000000xx movd [dstq + xq], m0 add xq, mmsize / 4 jl .loop BLEND_END BLEND_INIT phoenix, 4 mova m3, [pb_255] .nextrow: mov xq, widthq .loop: movu m0, [topq + xq] movu m1, [bottomq + xq] mova m2, m0 pminub m0, m1 pmaxub m1, m2 mova m2, m3 psubusb m2, m1 paddusb m2, m0 mova [dstq + xq], m2 add xq, mmsize jl .loop BLEND_END %macro BLEND_ABS 0 BLEND_INIT difference, 3 pxor m2, m2 .nextrow: mov xq, widthq .loop: movh m0, [topq + xq] movh m1, [bottomq + xq] punpcklbw m0, m2 punpcklbw m1, m2 psubw m0, m1 ABS1 m0, m1 packuswb m0, m0 movh [dstq + xq], m0 add xq, mmsize / 2 jl .loop BLEND_END BLEND_INIT negation, 5 pxor m2, m2 mova m4, [pw_255] .nextrow: mov xq, widthq .loop: movh m0, [topq + xq] movh m1, [bottomq + xq] punpcklbw m0, m2 punpcklbw m1, m2 mova m3, m4 psubw m3, m0 psubw m3, m1 ABS1 m3, m1 mova m0, m4 psubw m0, m3 packuswb m0, m0 movh [dstq + xq], m0 add xq, mmsize / 2 jl .loop BLEND_END %endmacro INIT_XMM sse2 BLEND_ABS INIT_XMM ssse3 BLEND_ABS
********************************************************************************* * DynoSprite - graphics-text.asm * Copyright (c) 2013, Richard Goedeken * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * 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. ********************************************************************************* *********************************************************** * Gfx_DrawTextLine: * * - IN: A=Y coordinate in rows (0-199) * B=X coordinate in bytes (pixel pairs, 0-159) * X=pointer to NULL-terminated string * U=color (4 bits) * - OUT: N/A * - Trashed: A,B,X,Y,U *********************************************************** * Gfx_DrawTextLine_Back pshs x jsr Gfx_GetPixelAddress_Back * start by getting starting memory location bra MapScreenWindow@ Gfx_DrawTextLine pshs x jsr Gfx_GetPixelAddress_Front * start by getting starting memory location MapScreenWindow@ tfr a,b incb std $FFA3 * map screen buffer to $6000-$9FFF leay $6000,y * Y now points to starting destination byte tfr u,d * color is in 4 low bits of B stb ColorMaskVal@+3 lslb lslb lslb lslb stb ColorMaskVal@+5 orb ColorMaskVal@+3 stb ColorMaskVal@+7 LetterLoop@ puls u ldb ,u+ * get next character bne > * if non-0 character, continue forward rts * otherwise we're done * * Locals ColorMaskVal@ fcb $ff,$00,$f0,$00,$0f,$00,$00,$00 RowCounter@ rmb 1 * ! pshs u subb #$20 * first printable character map is 32 ldx #Gfx_FontData ldu #ColorMaskVal@ lda #13 mul ADD_D_TO_X * X is pointer to 8x13 bitmap for current character lda #13 sta RowCounter@ RowLoop@ lda ,x anda #$c0 beq SkipByte0@ * skip this byte lsla rola rola rola ldb ,y andb a,u inca orb a,u stb ,y SkipByte0@ lda ,x anda #$30 beq SkipByte1@ * skip this byte lsra lsra lsra ldb 1,y andb a,u inca orb a,u stb 1,y SkipByte1@ lda ,x anda #$0c beq SkipByte2@ * skip this byte lsra ldb 2,y andb a,u inca orb a,u stb 2,y SkipByte2@ lda ,x anda #$03 beq SkipByte3@ * skip this byte lsla ldb 3,y andb a,u inca orb a,u ! stb 3,y SkipByte3@ leax 1,x * advance bitmap pointer to next row leay 256,y * advance destination pixel pointer to next line dec RowCounter@ bne RowLoop@ leay -3324,y * move pixel pointer up 13 rows and right 8 pixels (4 bytes) bra LetterLoop@ * do next character in line * font data were generated with: hexdump -e '" fcb " 16/1 "$%02X," "\n"' ~/Desktop/pgcfont.bin > ../font.asm Gfx_FontData fcb $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 fcb $00,$00,$18,$3C,$3C,$3C,$18,$18,$00,$18,$18,$00,$00 fcb $00,$66,$66,$66,$24,$00,$00,$00,$00,$00,$00,$00,$00 fcb $00,$00,$6C,$6C,$FE,$6C,$6C,$6C,$FE,$6C,$6C,$00,$00 fcb $18,$18,$7C,$C6,$C2,$C0,$7C,$06,$86,$C6,$7C,$18,$18 fcb $00,$00,$00,$00,$C2,$C6,$0C,$18,$30,$66,$C6,$00,$00 fcb $00,$00,$38,$6C,$6C,$38,$76,$DC,$CC,$CC,$76,$00,$00 fcb $00,$30,$30,$30,$60,$00,$00,$00,$00,$00,$00,$00,$00 fcb $00,$00,$0C,$18,$30,$30,$30,$30,$30,$18,$0C,$00,$00 fcb $00,$00,$30,$18,$0C,$0C,$0C,$0C,$0C,$18,$30,$00,$00 fcb $00,$00,$00,$00,$66,$3C,$FF,$3C,$66,$00,$00,$00,$00 fcb $00,$00,$00,$00,$18,$18,$7E,$18,$18,$00,$00,$00,$00 fcb $00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$18,$30,$00 fcb $00,$00,$00,$00,$00,$00,$FE,$00,$00,$00,$00,$00,$00 fcb $00,$00,$00,$00,$00,$00,$00,$00,$00,$18,$18,$00,$00 fcb $00,$00,$02,$06,$0C,$18,$30,$60,$C0,$80,$00,$00,$00 fcb $00,$00,$7C,$C6,$CE,$DE,$F6,$E6,$C6,$C6,$7C,$00,$00 fcb $00,$00,$18,$38,$78,$18,$18,$18,$18,$18,$7E,$00,$00 fcb $00,$00,$7C,$C6,$06,$0C,$18,$30,$60,$C6,$FE,$00,$00 fcb $00,$00,$7C,$C6,$06,$06,$3C,$06,$06,$C6,$7C,$00,$00 fcb $00,$00,$0C,$1C,$3C,$6C,$CC,$FE,$0C,$0C,$1E,$00,$00 fcb $00,$00,$FE,$C0,$C0,$C0,$FC,$06,$06,$C6,$7C,$00,$00 fcb $00,$00,$38,$60,$C0,$C0,$FC,$C6,$C6,$C6,$7C,$00,$00 fcb $00,$00,$FE,$C6,$06,$0C,$18,$30,$30,$30,$30,$00,$00 fcb $00,$00,$7C,$C6,$C6,$C6,$7C,$C6,$C6,$C6,$7C,$00,$00 fcb $00,$00,$7C,$C6,$C6,$C6,$7E,$06,$06,$0C,$78,$00,$00 fcb $00,$00,$00,$18,$18,$00,$00,$00,$18,$18,$00,$00,$00 fcb $00,$00,$00,$18,$18,$00,$00,$00,$18,$18,$30,$00,$00 fcb $00,$00,$06,$0C,$18,$30,$60,$30,$18,$0C,$06,$00,$00 fcb $00,$00,$00,$00,$00,$7E,$00,$00,$7E,$00,$00,$00,$00 fcb $00,$00,$60,$30,$18,$0C,$06,$0C,$18,$30,$60,$00,$00 fcb $00,$00,$7C,$C6,$C6,$0C,$18,$18,$00,$18,$18,$00,$00 fcb $00,$00,$7C,$C6,$C6,$DE,$DE,$DE,$DC,$C0,$7C,$00,$00 fcb $00,$00,$10,$38,$6C,$C6,$C6,$FE,$C6,$C6,$C6,$00,$00 fcb $00,$00,$FC,$66,$66,$66,$7C,$66,$66,$66,$FC,$00,$00 fcb $00,$00,$3C,$66,$C2,$C0,$C0,$C0,$C2,$66,$3C,$00,$00 fcb $00,$00,$F8,$6C,$66,$66,$66,$66,$66,$6C,$F8,$00,$00 fcb $00,$00,$FE,$66,$62,$68,$78,$68,$62,$66,$FE,$00,$00 fcb $00,$00,$FE,$66,$62,$68,$78,$68,$60,$60,$F0,$00,$00 fcb $00,$00,$3C,$66,$C2,$C0,$C0,$DE,$C6,$66,$3A,$00,$00 fcb $00,$00,$C6,$C6,$C6,$C6,$FE,$C6,$C6,$C6,$C6,$00,$00 fcb $00,$00,$3C,$18,$18,$18,$18,$18,$18,$18,$3C,$00,$00 fcb $00,$00,$1E,$0C,$0C,$0C,$0C,$0C,$CC,$CC,$78,$00,$00 fcb $00,$00,$E6,$66,$6C,$6C,$78,$6C,$6C,$66,$E6,$00,$00 fcb $00,$00,$F0,$60,$60,$60,$60,$60,$62,$66,$FE,$00,$00 fcb $00,$00,$C6,$EE,$FE,$FE,$D6,$C6,$C6,$C6,$C6,$00,$00 fcb $00,$00,$C6,$E6,$F6,$FE,$DE,$CE,$C6,$C6,$C6,$00,$00 fcb $00,$00,$38,$6C,$C6,$C6,$C6,$C6,$C6,$6C,$38,$00,$00 fcb $00,$00,$FC,$66,$66,$66,$7C,$60,$60,$60,$F0,$00,$00 fcb $00,$00,$7C,$C6,$C6,$C6,$C6,$D6,$DE,$7C,$0C,$0E,$00 fcb $00,$00,$FC,$66,$66,$66,$7C,$6C,$66,$66,$E6,$00,$00 fcb $00,$00,$7C,$C6,$C6,$60,$38,$0C,$C6,$C6,$7C,$00,$00 fcb $00,$00,$7E,$7E,$5A,$18,$18,$18,$18,$18,$3C,$00,$00 fcb $00,$00,$C6,$C6,$C6,$C6,$C6,$C6,$C6,$C6,$7C,$00,$00 fcb $00,$00,$C6,$C6,$C6,$C6,$C6,$C6,$6C,$38,$10,$00,$00 fcb $00,$00,$C6,$C6,$C6,$C6,$D6,$D6,$FE,$7C,$6C,$00,$00 fcb $00,$00,$C6,$C6,$6C,$38,$38,$38,$6C,$C6,$C6,$00,$00 fcb $00,$00,$66,$66,$66,$66,$3C,$18,$18,$18,$3C,$00,$00 fcb $00,$00,$FE,$C6,$8C,$18,$30,$60,$C2,$C6,$FE,$00,$00 fcb $00,$00,$3C,$30,$30,$30,$30,$30,$30,$30,$3C,$00,$00 fcb $00,$00,$80,$C0,$E0,$70,$38,$1C,$0E,$06,$02,$00,$00 fcb $00,$00,$3C,$0C,$0C,$0C,$0C,$0C,$0C,$0C,$3C,$00,$00 fcb $10,$38,$6C,$C6,$00,$00,$00,$00,$00,$00,$00,$00,$00 fcb $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$FF fcb $30,$30,$18,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 fcb $00,$00,$00,$00,$00,$78,$0C,$7C,$CC,$CC,$76,$00,$00 fcb $00,$00,$E0,$60,$60,$78,$6C,$66,$66,$66,$7C,$00,$00 fcb $00,$00,$00,$00,$00,$7C,$C6,$C0,$C0,$C6,$7C,$00,$00 fcb $00,$00,$1C,$0C,$0C,$3C,$6C,$CC,$CC,$CC,$76,$00,$00 fcb $00,$00,$00,$00,$00,$7C,$C6,$FE,$C0,$C6,$7C,$00,$00 fcb $00,$00,$38,$6C,$64,$60,$F0,$60,$60,$60,$F0,$00,$00 fcb $00,$00,$00,$00,$00,$76,$CC,$CC,$CC,$7C,$0C,$CC,$78 fcb $00,$00,$E0,$60,$60,$6C,$76,$66,$66,$66,$E6,$00,$00 fcb $00,$00,$18,$18,$00,$38,$18,$18,$18,$18,$3C,$00,$00 fcb $00,$00,$06,$06,$00,$0E,$06,$06,$06,$06,$66,$66,$3C fcb $00,$00,$E0,$60,$60,$66,$6C,$78,$6C,$66,$E6,$00,$00 fcb $00,$00,$38,$18,$18,$18,$18,$18,$18,$18,$3C,$00,$00 fcb $00,$00,$00,$00,$00,$EC,$FE,$D6,$D6,$D6,$C6,$00,$00 fcb $00,$00,$00,$00,$00,$DC,$66,$66,$66,$66,$66,$00,$00 fcb $00,$00,$00,$00,$00,$7C,$C6,$C6,$C6,$C6,$7C,$00,$00 fcb $00,$00,$00,$00,$00,$DC,$66,$66,$66,$7C,$60,$60,$F0 fcb $00,$00,$00,$00,$00,$76,$CC,$CC,$CC,$7C,$0C,$0C,$1E fcb $00,$00,$00,$00,$00,$DC,$76,$66,$60,$60,$F0,$00,$00 fcb $00,$00,$00,$00,$00,$7C,$C6,$70,$1C,$C6,$7C,$00,$00 fcb $00,$00,$10,$30,$30,$FC,$30,$30,$30,$36,$1C,$00,$00 fcb $00,$00,$00,$00,$00,$CC,$CC,$CC,$CC,$CC,$76,$00,$00 fcb $00,$00,$00,$00,$00,$66,$66,$66,$66,$3C,$18,$00,$00 fcb $00,$00,$00,$00,$00,$C6,$C6,$D6,$D6,$FE,$6C,$00,$00 fcb $00,$00,$00,$00,$00,$C6,$6C,$38,$38,$6C,$C6,$00,$00 fcb $00,$00,$00,$00,$00,$C6,$C6,$C6,$C6,$7E,$06,$0C,$F8 fcb $00,$00,$00,$00,$00,$FE,$CC,$18,$30,$66,$FE,$00,$00 fcb $00,$00,$0E,$18,$18,$18,$70,$18,$18,$18,$0E,$00,$00 fcb $00,$00,$18,$18,$18,$18,$00,$18,$18,$18,$18,$00,$00 fcb $00,$00,$70,$18,$18,$18,$0E,$18,$18,$18,$70,$00,$00 fcb $00,$00,$76,$DC,$00,$00,$00,$00,$00,$00,$00,$00,$00 fcb $00,$00,$00,$00,$10,$38,$6C,$C6,$C6,$FE,$00,$00,$00
; =============================================================== ; Feb 2014 ; =============================================================== ; ; int wv_priority_queue_shrink_to_fit(wv_priority_queue_t *q) ; ; Release any excess memory allocated for the queue. ; ; After calling, priority_queue.capacity == priority_queue.size ; ; =============================================================== SECTION code_clib SECTION code_adt_wv_priority_queue PUBLIC asm_wv_priority_queue_shrink_to_fit EXTERN asm_bv_priority_queue_shrink_to_fit defc asm_wv_priority_queue_shrink_to_fit = asm_bv_priority_queue_shrink_to_fit ; enter : hl = priority_queue * ; ; exit : success ; ; hl = -1 ; carry reset ; ; fail on realloc not getting lock ; ; hl = 0 ; carry set ; ; uses : af, bc, de, hl
<% import collections import pwnlib.abi import pwnlib.constants import pwnlib.shellcraft import six %> <%docstring>sched_setparam(pid, param) -> str Invokes the syscall sched_setparam. See 'man 2 sched_setparam' for more information. Arguments: pid(pid_t): pid param(sched_param*): param Returns: int </%docstring> <%page args="pid=0, param=0"/> <% abi = pwnlib.abi.ABI.syscall() stack = abi.stack regs = abi.register_arguments[1:] allregs = pwnlib.shellcraft.registers.current() can_pushstr = [] can_pushstr_array = [] argument_names = ['pid', 'param'] argument_values = [pid, param] # Load all of the arguments into their destination registers / stack slots. register_arguments = dict() stack_arguments = collections.OrderedDict() string_arguments = dict() dict_arguments = dict() array_arguments = dict() syscall_repr = [] for name, arg in zip(argument_names, argument_values): if arg is not None: syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False))) # If the argument itself (input) is a register... if arg in allregs: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[index] = arg # The argument is not a register. It is a string value, and we # are expecting a string value elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)): if isinstance(arg, six.text_type): arg = arg.encode('utf-8') string_arguments[name] = arg # The argument is not a register. It is a dictionary, and we are # expecting K:V paris. elif name in can_pushstr_array and isinstance(arg, dict): array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()] # The arguent is not a register. It is a list, and we are expecting # a list of arguments. elif name in can_pushstr_array and isinstance(arg, (list, tuple)): array_arguments[name] = arg # The argument is not a register, string, dict, or list. # It could be a constant string ('O_RDONLY') for an integer argument, # an actual integer value, or a constant. else: index = argument_names.index(name) if index < len(regs): target = regs[index] register_arguments[target] = arg elif arg is not None: stack_arguments[target] = arg # Some syscalls have different names on various architectures. # Determine which syscall number to use for the current architecture. for syscall in ['SYS_sched_setparam']: if hasattr(pwnlib.constants, syscall): break else: raise Exception("Could not locate any syscalls: %r" % syscalls) %> /* sched_setparam(${', '.join(syscall_repr)}) */ %for name, arg in string_arguments.items(): ${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))} ${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)} %endfor %for name, arg in array_arguments.items(): ${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)} %endfor %for name, arg in stack_arguments.items(): ${pwnlib.shellcraft.push(arg)} %endfor ${pwnlib.shellcraft.setregs(register_arguments)} ${pwnlib.shellcraft.syscall(syscall)}
.file "Program2.c" .text .balign 2 .global main .type main, @function main: ; start of function ; framesize_regs: 0 ; framesize_locals: 0 ; framesize_outgoing: 0 ; framesize: 0 ; elim ap -> fp 2 ; elim fp -> sp 0 ; saved regs:(none) ; start of prologue ; end of prologue MOV.W #23168, &WDTCTL MOV.B #-9, &P1DIR MOV.B #73, &P1OUT MOV.B #8, &P1REN MOV.B #8, &P1IE ; 22 "Program2.c" 1 bis.w #248, SR ; 0 "" 2 ; start of epilogue .refsym __crt0_call_exit RET .size main, .-main .balign 2 .global PORT1_ISR .section __interrupt_vector_3,"ax",@progbits .word PORT1_ISR .text .type PORT1_ISR, @function PORT1_ISR: ; start of function ; attributes: interrupt ; framesize_regs: 0 ; framesize_locals: 0 ; framesize_outgoing: 0 ; framesize: 0 ; elim ap -> fp 2 ; elim fp -> sp 0 ; saved regs:(none) ; start of prologue ; end of prologue XOR.B #65, &P1OUT BIC.B #8, &P1IFG ; start of epilogue RETI .size PORT1_ISR, .-PORT1_ISR .ident "GCC: (Mitto Systems Limited - msp430-gcc 8.3.0.16) 8.3.0"
#include <cstdio> #include <Kernels/Time.h> #include <Kernels/Local.h> #include <Kernels/Neighbor.h> #include <Kernels/DynamicRupture.h> #include <Kernels/Plasticity.h> int main() { /// ADER-DG Flops long long nonZeroFlops = 0, hardwareFlops = 0; long long avgNeighborNonZeroFlops = 0, avgNeighborHardwareFlops = 0; long long minNeighborNonZeroFlops = std::numeric_limits<long long>::max(), minNeighborHardwareFlops = std::numeric_limits<long long>::max(); long long maxNeighborNonZeroFlops = 0, maxNeighborHardwareFlops = 0; unsigned kernelNonZeroFlops, kernelHardwareFlops; long long kernelDRNonZeroFlops, kernelDRHardwareFlops; seissol::kernels::Time timeKernel; seissol::kernels::Local localKernel; seissol::kernels::Neighbor neighborKernel; FaceType faceTypes[] = {FaceType::regular, FaceType::regular, FaceType::regular, FaceType::regular}; timeKernel.flopsAder( kernelNonZeroFlops, kernelHardwareFlops ); nonZeroFlops += kernelNonZeroFlops; hardwareFlops += kernelHardwareFlops; localKernel.flopsIntegral(faceTypes, kernelNonZeroFlops, kernelHardwareFlops); nonZeroFlops += kernelNonZeroFlops; hardwareFlops += kernelHardwareFlops; int faceRelations[4][2]; CellDRMapping dummyDRMapping[4]; unsigned numConfs = 12*12*12*12; for (unsigned conf = 0; conf < 12*12*12*12; ++conf) { unsigned m = 1; for (int side = 0; side < 4; ++side) { unsigned confSide = (conf % (12*m)) / m; faceRelations[side][0] = confSide % 4; faceRelations[side][1] = confSide / 4; m *= 12; } neighborKernel.flopsNeighborsIntegral( faceTypes, faceRelations, dummyDRMapping, kernelNonZeroFlops, kernelHardwareFlops, kernelDRNonZeroFlops, kernelDRHardwareFlops ); minNeighborNonZeroFlops = std::min(minNeighborNonZeroFlops, static_cast<long long>(kernelNonZeroFlops)); maxNeighborNonZeroFlops = std::max(maxNeighborNonZeroFlops, static_cast<long long>(kernelNonZeroFlops)); minNeighborHardwareFlops = std::min(minNeighborHardwareFlops, static_cast<long long>(kernelHardwareFlops)); maxNeighborHardwareFlops = std::max(maxNeighborHardwareFlops, static_cast<long long>(kernelHardwareFlops)); avgNeighborNonZeroFlops += kernelNonZeroFlops; avgNeighborHardwareFlops += kernelHardwareFlops; } double avgNonZeroFlops = nonZeroFlops + avgNeighborNonZeroFlops / static_cast<double>(numConfs); double avgHardwareFlops = hardwareFlops + avgNeighborHardwareFlops / static_cast<double>(numConfs); printf("Element non-zero flops (average): %.1lf\n", avgNonZeroFlops); printf("Element hardware flops (average): %.1lf\n", avgHardwareFlops); printf("Element non-zero flops (min): %lld\n", nonZeroFlops + minNeighborNonZeroFlops); printf("Element hardware flops (min): %lld\n", hardwareFlops + minNeighborHardwareFlops); printf("Element non-zero flops (max): %lld\n", nonZeroFlops + maxNeighborNonZeroFlops); printf("Element hardware flops (max): %lld\n", hardwareFlops + maxNeighborHardwareFlops); printf("Max non-zero deviation from average: %.2lf %\n", 100.0 * std::max((nonZeroFlops + maxNeighborNonZeroFlops) / avgNonZeroFlops - 1.0, 1.0 - (nonZeroFlops + minNeighborNonZeroFlops) / avgNonZeroFlops)); printf("Max hardware deviation from average: %.2lf %\n", 100.0 * std::max((hardwareFlops + maxNeighborHardwareFlops) / avgHardwareFlops - 1.0, 1.0 - (hardwareFlops + minNeighborHardwareFlops) / avgHardwareFlops)); /// Dynamic rupture flops long long drNonZeroFlops = 0, drHardwareFlops = 0; long long neighborDRNonZeroFlops = 0, neighborDRHardwareFlops = 0; seissol::kernels::DynamicRupture dynRupKernel; FaceType faceTypesDR[] = {FaceType::dynamicRupture, FaceType::dynamicRupture, FaceType::dynamicRupture, FaceType::dynamicRupture}; CellDRMapping drMapping[4]; for (int neighborSide = 0; neighborSide < 4; ++neighborSide) { for (int sideOrientation = 0; sideOrientation < 3; ++sideOrientation) { for (int side = 0; side < 4; ++side) { DRFaceInformation faceInfo; faceInfo.plusSide = side; faceInfo.minusSide = neighborSide; faceInfo.faceRelation = sideOrientation; dynRupKernel.flopsGodunovState(faceInfo, kernelDRNonZeroFlops, kernelDRHardwareFlops); drNonZeroFlops += kernelDRNonZeroFlops; drHardwareFlops += kernelDRHardwareFlops; } } } for (int neighborSide = 0; neighborSide < 4; ++neighborSide) { for (int faceRelation = 0; faceRelation < 4; ++faceRelation) { for (int face = 0; face < 4; ++face) { drMapping[face].side = neighborSide; drMapping[face].faceRelation = faceRelation; } neighborKernel.flopsNeighborsIntegral( faceTypesDR, faceRelations, drMapping, kernelNonZeroFlops, kernelHardwareFlops, kernelDRNonZeroFlops, kernelDRHardwareFlops ); neighborDRNonZeroFlops += kernelDRNonZeroFlops; neighborDRHardwareFlops += kernelDRHardwareFlops; } } printf("Dynamic rupture face non-zero flops (average, w/o friction law): %.1lf\n", drNonZeroFlops / 48.0 + neighborDRNonZeroFlops / 16.0 / 4.0); printf("Dynamic rupture face hardware flops (average, w/o friction law): %.1lf\n", drHardwareFlops / 48.0 + neighborDRHardwareFlops / 16.0 / 4.0); /// Plasticity flops long long PlNonZeroFlopsCheck = 0, PlHardwareFlopsCheck = 0; long long PlNonZeroFlopsYield = 0, PlHardwareFlopsYield = 0; long long kernelNonZeroFlopsCheck, kernelHardwareFlopsCheck; long long kernelNonZeroFlopsYield, kernelHardwareFlopsYield; seissol::kernels::Plasticity::flopsPlasticity(kernelNonZeroFlopsCheck, kernelHardwareFlopsCheck, kernelNonZeroFlopsYield, kernelHardwareFlopsYield); PlNonZeroFlopsCheck += kernelNonZeroFlopsCheck; PlHardwareFlopsCheck += kernelHardwareFlopsCheck; PlNonZeroFlopsYield += kernelNonZeroFlopsYield; PlHardwareFlopsYield += kernelHardwareFlopsYield; printf("Plasticity non-zero min flops : %lld\n", PlNonZeroFlopsCheck ); printf("Plasticity hardware min flops : %lld\n", PlHardwareFlopsCheck ); printf("Plasticity non-zero max flops : %lld\n", PlNonZeroFlopsCheck + PlNonZeroFlopsYield ); printf("Plasticity hardware max flops : %lld\n", PlHardwareFlopsCheck+ PlHardwareFlopsYield ); printf("Plasticity non-zero min vs elastic average: %.2lf %\n", 100.0 * PlNonZeroFlopsCheck / avgNonZeroFlops); printf("Plasticity hardware min vs elastic average: %.2lf %\n", 100.0 * PlHardwareFlopsCheck / avgHardwareFlops); printf("Plasticity non-zero max vs elastic average: %.2lf %\n", 100.0 * (PlNonZeroFlopsCheck + PlNonZeroFlopsYield) / avgNonZeroFlops); printf("Plasticity hardware max vs elastic average: %.2lf %\n", 100.0 * (PlHardwareFlopsCheck + PlHardwareFlopsYield) / avgHardwareFlops); return 0; }
section .text global _start _start: mov ax, 8h and ax, 1 jz evnn mov eax, 4 mov ebx, 1 mov ecx, odd_msg mov edx, len2 int 0x80 jmp outprog evnn: mov ah, 09h mov eax, 4 mov ebx, 1 mov ecx, even_msg mov edx, len1 int 0x80 outprog: mov eax, 1 int 0x80 section .data even_msg db 'bilangan genap' len1 equ $ - even_msg odd_msg db 'bilangan ganjil' len2 equ $ - odd_msg
DPLC_61ABE: dc.w word_61AD6-DPLC_61ABE dc.w word_61ADA-DPLC_61ABE dc.w word_61ADE-DPLC_61ABE dc.w word_61AE2-DPLC_61ABE dc.w word_61AE6-DPLC_61ABE dc.w word_61AEA-DPLC_61ABE dc.w word_61AF0-DPLC_61ABE dc.w word_61AFA-DPLC_61ABE dc.w word_61B04-DPLC_61ABE dc.w word_61B0E-DPLC_61ABE dc.w word_61B18-DPLC_61ABE dc.w word_61B1E-DPLC_61ABE word_61AD6: dc.w 0 dc.w 3 word_61ADA: dc.w 0 dc.w $43 word_61ADE: dc.w 0 dc.w $88 word_61AE2: dc.w 0 dc.w $118 word_61AE6: dc.w 0 dc.w $1AF word_61AEA: dc.w 1 dc.w $2AF dc.w $3A3 word_61AF0: dc.w 3 dc.w $3E5 dc.w $445 dc.w $4A5 dc.w $505 word_61AFA: dc.w 3 dc.w $562 dc.w $59F dc.w $693 dc.w $6D2 word_61B04: dc.w 3 dc.w $70F dc.w $80F dc.w $90F dc.w $A0F word_61B0E: dc.w 3 dc.w $B0F dc.w $C0B dc.w $CCF dc.w $DCB word_61B18: dc.w 1 dc.w $E8B dc.w $F4B word_61B1E: dc.w 3 dc.w $100F dc.w $110B dc.w $11CF dc.w $12CB
/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "frameworks/bridge/declarative_frontend/jsview/js_text.h" #include <map> #include <sstream> #include <string> #include "base/geometry/dimension.h" #include "base/log/ace_trace.h" namespace OHOS::Ace::Framework { const std::map<int, TextOverflow> textOverflowEnumMapping = { { 0, TextOverflow::CLIP }, { 1, TextOverflow::ELLIPSIS }, { 2, TextOverflow::NONE }, }; const std::map<int, TextAlign> textAlignEnumMapping = { { 0, TextAlign::LEFT }, { 1, TextAlign::RIGHT }, { 2, TextAlign::CENTER }, { 3, TextAlign::JUSTIFY }, { 4, TextAlign::START }, { 5, TextAlign::END }, }; const std::map<int, FontStyle> fontStyleEnumMapping = { { 0, FontStyle::NORMAL }, { 1, FontStyle::ITALIC }, }; JSText::JSText(const std::string& text) { textComponent_ = AceType::MakeRefPtr<OHOS::Ace::TextComponent>(text); } RefPtr<OHOS::Ace::Component> JSText::CreateSpecializedComponent() { LOGD("Create component: Text"); return textComponent_; } std::vector<RefPtr<OHOS::Ace::SingleChild>> JSText::CreateInteractableComponents() { return JSInteractableView::CreateComponents(); } #ifdef USE_QUICKJS_ENGINE void JSText::MarkGC(JSRuntime* rt, JS_MarkFunc* markFunc) { LOGD("JSText => MarkGC: Mark value for GC start"); JSInteractableView::MarkGC(rt, markFunc); LOGD("JSText => MarkGC: Mark value for GC end"); } void JSText::ReleaseRT(JSRuntime* rt) { LOGD("JSText => release start"); JSInteractableView::ReleaseRT(rt); LOGD("JSText => release text: %s", textComponent_->GetData().c_str()); LOGD("JSText => release end"); } #endif void JSText::SetFontSize(const std::string& value) { Dimension dimension = TextAttr2Dimension(value, true); if (GreatNotEqual(dimension.Value(), 0.0)) { auto textStyle = GetTextStyle(); textStyle.SetFontSize(dimension); SetTextStyle(std::move(textStyle)); } else { LOGE("value %s is not positive", value.c_str()); } } void JSText::SetFontWeight(const std::string& value) { auto textStyle = GetTextStyle(); textStyle.SetFontWeight(ConvertStrToFontWeight(value)); SetTextStyle(std::move(textStyle)); } void JSText::SetTextColor(const std::string& value) { auto textStyle = GetTextStyle(); textStyle.SetTextColor(Color::FromString(value)); SetTextStyle(std::move(textStyle)); } void JSText::SetTextOverflow(int value) { auto iter = textOverflowEnumMapping.find(value); if (iter != textOverflowEnumMapping.end()) { auto textStyle = GetTextStyle(); textStyle.SetTextOverflow(iter->second); SetTextStyle(std::move(textStyle)); } else { LOGE("Text: textOverflow(%d) illegal value", value); } } void JSText::SetMaxLines(int value) { if (value > 0) { auto textStyle = GetTextStyle(); textStyle.SetMaxLines(value); SetTextStyle(std::move(textStyle)); } else { LOGE("Text: maxLines(%d) expected positive number", value); } } void JSText::SetFontStyle(int value) { auto iter = fontStyleEnumMapping.find(value); if (iter != fontStyleEnumMapping.end()) { auto textStyle = GetTextStyle(); textStyle.SetFontStyle(FontStyle(value)); SetTextStyle(std::move(textStyle)); } else { LOGE("Text fontStyle(%d) illega value", value); } } void JSText::SetTextAlign(int value) { auto iter = textAlignEnumMapping.find(value); if (iter != textAlignEnumMapping.end()) { auto textStyle = GetTextStyle(); textStyle.SetTextAlign(iter->second); SetTextStyle(std::move(textStyle)); } else { LOGE("Text: TextAlign(%d) expected positive number", value); } } void JSText::SetLineHeight(const std::string& value) { Dimension dimension = TextAttr2Dimension(value, true); if (GreatNotEqual(dimension.Value(), 0.0)) { auto textStyle = GetTextStyle(); textStyle.SetLineHeight(dimension); SetTextStyle(std::move(textStyle)); } else { LOGE("value %s is not positive", value.c_str()); } } void JSText::SetFontFamily(const std::string& fontFamiliy) { std::vector<std::string> fontFamilies = ParseFontFamilies(fontFamiliy); auto textStyle = GetTextStyle(); textStyle.SetFontFamilies(fontFamilies); SetTextStyle(std::move(textStyle)); } void JSText::SetMinFontSize(const std::string& value) { Dimension dimension = TextAttr2Dimension(value, true); if (GreatNotEqual(dimension.Value(), 0.0)) { auto textStyle = GetTextStyle(); textStyle.SetAdaptMinFontSize(dimension); SetTextStyle(std::move(textStyle)); } else { LOGE("value %s is not positive", value.c_str()); } } void JSText::SetMaxFontSize(const std::string& value) { Dimension dimension = TextAttr2Dimension(value, true); if (GreatNotEqual(dimension.Value(), 0.0)) { auto textStyle = GetTextStyle(); textStyle.SetAdaptMaxFontSize(dimension); SetTextStyle(std::move(textStyle)); } else { LOGE("value %s is not positive", value.c_str()); } } std::vector<std::string> JSText::ParseFontFamilies(const std::string& value) const { std::vector<std::string> fontFamilies; std::stringstream stream(value); std::string fontFamily; while (getline(stream, fontFamily, ',')) { fontFamilies.push_back(fontFamily); } return fontFamilies; } Dimension JSText::TextAttr2Dimension(const std::string& value, bool usefp) { errno = 0; char* pEnd = nullptr; double result = std::strtod(value.c_str(), &pEnd); if (pEnd == value.c_str() || errno == ERANGE) { return Dimension(0.0, DimensionUnit::PX); } else { if ((pEnd) && (std::strcmp(pEnd, "%") == 0)) { // Parse percent, transfer from [0, 100] to [0`, 1] return Dimension(result / 100.0, DimensionUnit::PERCENT); } else if ((pEnd) && (std::strcmp(pEnd, "px") == 0)) { return Dimension(result, DimensionUnit::PX); } else if ((pEnd) && (std::strcmp(pEnd, "vp") == 0)) { return Dimension(result, DimensionUnit::VP); } else if ((pEnd) && (std::strcmp(pEnd, "fp") == 0)) { return Dimension(result, DimensionUnit::FP); } return Dimension(result, usefp ? DimensionUnit::FP : DimensionUnit::PX); } } #ifdef USE_QUICKJS_ENGINE void JSText::QjsDestructor(JSRuntime* rt, JSText* view) { LOGD("JSText(QjsDestructor) start"); if (!view) return; view->ReleaseRT(rt); delete view; LOGD("JSText(QjsDestructor) end"); } void JSText::QjsGcMark(JSRuntime* rt, JSValueConst val, JS_MarkFunc* markFunc) { LOGD("JSText(QjsGcMark) start"); JSText* view = Unwrap<JSText>(val); if (!view) return; view->MarkGC(rt, markFunc); LOGD("JSText(QjsGcMark) end"); } #endif void JSText::JSBind(BindingTarget globalObj) { JSClass<JSText>::Declare("Text"); JSClass<JSText>::Inherit<JSViewAbstract>(); MethodOptions opt = MethodOptions::RETURN_SELF; JSClass<JSText>::Method("color", &JSText::SetTextColor, opt); JSClass<JSText>::Method("fontSize", &JSText::SetFontSize, opt); JSClass<JSText>::Method("fontWeight", &JSText::SetFontWeight, opt); JSClass<JSText>::Method("maxLines", &JSText::SetMaxLines, opt); JSClass<JSText>::Method("textOverflow", &JSText::SetTextOverflow, opt); JSClass<JSText>::Method("fontStyle", &JSText::SetFontStyle, opt); JSClass<JSText>::Method("textAlign", &JSText::SetTextAlign, opt); JSClass<JSText>::Method("lineHeight", &JSText::SetLineHeight, opt); JSClass<JSText>::Method("fontFamily", &JSText::SetFontFamily, opt); JSClass<JSText>::Method("minFontSize", &JSText::SetMinFontSize, opt); JSClass<JSText>::Method("maxFontSize", &JSText::SetMaxFontSize, opt); JSClass<JSText>::CustomMethod("onTouch", &JSInteractableView::JsOnTouch); JSClass<JSText>::CustomMethod("onClick", &JSInteractableView::JsOnClick); JSClass<JSText>::Bind<std::string>(globalObj); } TextStyle JSText::GetTextStyle() const { return textComponent_->GetTextStyle(); } void JSText::SetTextStyle(TextStyle style) { textComponent_->SetTextStyle(std::move(style)); } } // namespace OHOS::Ace::Framework
; A240707: Sum of the middle parts in the partitions of 4n-1 into 3 parts. ; 1,8,31,80,159,282,459,690,993,1378,1841,2404,3077,3852,4755,5796,6963,8286,9775,11414,13237,15254,17445,19848,22473,25296,28359,31672,35207,39010,43091,47418,52041,56970,62169,67692,73549,79700,86203,93068,100251 mov $2,$0 add $2,1 mov $4,$0 lpb $2 mov $0,$4 sub $2,1 sub $0,$2 mov $5,$0 add $5,1 mov $6,0 mov $10,$0 lpb $5 mov $0,$10 sub $5,1 sub $0,$5 mov $11,$0 mov $13,2 lpb $13 mov $0,$11 mov $7,0 sub $13,1 add $0,$13 sub $0,1 mul $0,2 add $7,$0 mov $0,3 mov $3,2 add $7,2 mov $9,$7 sub $7,2 add $3,$7 mul $3,4 mul $9,$7 div $7,3 mov $8,1 add $8,$7 add $7,1 lpb $0 add $0,$9 sub $3,$7 add $3,$0 mov $0,0 pow $8,2 add $8,$3 mov $3,$8 lpe mov $14,$13 lpb $14 mov $12,$3 sub $14,1 lpe lpe lpb $11 mov $11,0 sub $12,$3 lpe mov $3,$12 sub $3,10 add $6,$3 lpe add $1,$6 lpe mov $0,$1
; A201837: G.f.: real part of 1/(1 - i*x - i*x^2) where i=sqrt(-1). ; Submitted by Jon Maiga ; 1,0,-1,-2,0,4,5,-2,-13,-12,12,40,25,-52,-117,-38,196,324,-3,-678,-841,360,2200,2000,-2079,-6760,-4121,8918,19720,6084,-33435,-54442,1547,115228,140772,-63880,-372775,-332892,359763,1142322,678796,-1528956,-3323203,-970958,5702319,9146320,-437200,-19580000,-23557759,11308080,63154959,55387438,-62213360,-193005436,-111716475,262044718,559940707,154393668,-972313668,-1536319800,103585625,3326553468,3941367643,-1997404918,-10698060204,-9211883836,10751502397,32605409162,18370325479,-44896530120 mov $2,1 lpb $0 sub $0,1 sub $3,$4 mov $5,$4 mov $4,$2 mov $2,$3 add $2,$1 mov $1,$3 mul $5,-1 mov $3,$5 lpe mov $0,$2
; A170294: Number of reduced words of length n in Coxeter group on 45 generators S_i with relations (S_i)^2 = (S_i S_j)^41 = I. ; 1,45,1980,87120,3833280,168664320,7421230080,326534123520,14367501434880,632170063134720,27815482777927680,1223881242228817920,53850774658067988480,2369434084954991493120,104255099738019625697280 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,44 lpe mov $0,$2 div $0,44
; mov ah, 0x0e ; tty mode ; ; mov al, 'X' ; jmp print ; endprint: ; ; print: ; int 0x10 ; jmp endprint print: pusha ; keep this in mind: ; while (string[i] != 0) { print string[i]; i++ } ; the comparison for string end (null byte) start: mov al, [bx] ; 'bx' is the base address for the string cmp al, 0 je done mov ah, 0x0e int 0x10 ; 'al' already contains the char add bx, 1 jmp start done: popa ret print_nl: pusha mov ah, 0x0e mov al, 0x0a ; newline char int 0x10 ; a control character or mechanism used to reset a device's position ; to the beginning of a line of text. mov al, 0x0d ; carriage return int 0x10 popa ret
; --------------------------------------------------------------------------- ; Animation script - Newtron enemy ; --------------------------------------------------------------------------- dc.w byte_DF24-Ani_obj42 dc.w byte_DF28-Ani_obj42 dc.w byte_DF30-Ani_obj42 dc.w byte_DF34-Ani_obj42 dc.w byte_DF38-Ani_obj42 byte_DF24: dc.b $F, $A, $FF, 0 byte_DF28: dc.b $13, 0, 1, 3, 4, 5, $FE, 1 byte_DF30: dc.b 2, 6, 7, $FF byte_DF34: dc.b 2, 8, 9, $FF byte_DF38: dc.b $13, 0, 1, 1, 2, 1, 1, 0, $FC, 0 even
#include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define pf push_front #define pp push #define et empty #define mp make_pair #define For(i,a,b) for (int i=a;i<=b;i++) #define Fod(i,b,a) for (int i=b;i>=a;i--) #define Forl(i,a,b) for (ll i=a;i<=b;i++) #define Fodl(i,b,a) for (ll i=b;i>=a;i--) typedef int64_t ll; typedef uint64_t ull; #define prno cout<<"NO\n" #define pryes cout<<"YES\n" #define pryon pryes; else prno; #define brln cout << "\n"; #define el "\n" #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define prarr(a,n) For(i,1,n)cout<<a[i]<<" "; brln; #define bitcount(n) __builtin_popcountll(n) #define INFILE(name) freopen(name, "r", stdin) #define OUFILE(name) freopen(name, "w", stdout) #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); const int inf = 1e6+5; int n,st[inf*4],stp[inf*4]; ll a[inf]; ull res; void compresss(ll a[],int n){ ll b[inf]; For(i,1,n) b[i]=a[i]; sort(b,b+n); For(i,1,n) a[i]=upper_bound(b,b+n,a[i])-b; } int update(int st[],int n,int l,int r,int ind,int state){ if(l>r) return 0; if(ind<l||ind>r) return st[n]; if(l==r && l==ind) return st[n]+=state; return st[n] = update(st,n*2,l,(l+r)/2,ind,state) + update(st,n*2+1,(l+r)/2+1,r,ind,state); } ll query(int st[],int n,int l,int r,int ql,int qr){ if(l>r) return 0; if(l>=ql && r<=qr) return st[n]; if(l>qr||r<ql) return 0; return query(st,n*2,l,(l+r)/2,ql,qr) + query(st,n*2+1,(l+r)/2+1,r,ql,qr); } int main(){ fast; // INFILE("in.txt"); // OUFILE("out.txt"); cin>>n; For(i,1,n) cin>>a[i]; compresss(a,n); For(i,2,n) update(stp,1,1,n,a[i],1); For(i,2,n-1){ update(stp,1,1,n,a[i],-1); update(st,1,1,n,a[i-1],1); res+=query(st,1,1,n,a[i]+1,n)*query(stp,1,1,n,1,a[i]-1); } cout<<res; }
; A131534: Period 3: repeat [1, 2, 1]. ; 1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1,1,2,1 mod $0,3 mov $1,2 bin $1,$0
#include <stdio.h> #include <Windows.h> #include "stdafx.h" // DLL Function #define DEF_KERNEL ("kernel32.dll") #define DEF_FUNC ("WriteFile") // original function syntax typedef BOOL(WINAPI *tWriteFile) ( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped ); // save original function tWriteFile savedFunc; // fake function BOOL WINAPI NewWriteFile( HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped ) { MessageBoxA(NULL, "Hi, I'm fake function", "Success", MB_OK); // change content char s[] = "you have been hacked!"; nNumberOfBytesToWrite = strlen(s) + 1; PBYTE llpBuffer = (PBYTE)malloc(nNumberOfBytesToWrite); for (int i = 0; i < nNumberOfBytesToWrite-1; i++) { llpBuffer[i] = s[i]; } llpBuffer[nNumberOfBytesToWrite - 1] = '\0'; // call origin function return ((tWriteFile)savedFunc)(hFile, llpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped); } // IAT hook DWORD WINAPI tryHook() { HMODULE hMod = GetModuleHandle(NULL); PIMAGE_DOS_HEADER pDos = (PIMAGE_DOS_HEADER)hMod; PIMAGE_NT_HEADERS64 pNt = (PIMAGE_NT_HEADERS64)((ULONGLONG)hMod + (pDos->e_lfanew)); PIMAGE_OPTIONAL_HEADER64 pOptional = &(pNt->OptionalHeader); PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)((ULONGLONG)hMod + (pOptional->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress)); DWORD dwOldProtect; PIMAGE_THUNK_DATA pThunk, rThunk; // find dll while (pImportDesc) { if (_stricmp(DEF_KERNEL, (PCHAR)(pImportDesc->Name + (ULONGLONG)hMod)) == 0) break; pImportDesc++; } MessageBoxA(NULL, (PCHAR)(pImportDesc->Name + (ULONGLONG)hMod), "Success", MB_OK); // find function pThunk = (PIMAGE_THUNK_DATA)(pImportDesc->FirstThunk + (ULONGLONG)hMod); rThunk = (PIMAGE_THUNK_DATA)(pImportDesc->OriginalFirstThunk + (UCHAR*)hMod); IMAGE_IMPORT_BY_NAME* pImportByName; while (pThunk->u1.Function) { pImportByName = (IMAGE_IMPORT_BY_NAME*)((char*)hMod + rThunk->u1.AddressOfData); if (_stricmp(pImportByName->Name, DEF_FUNC) == 0) { MessageBoxA(NULL, pImportByName->Name, "Success", MB_OK); // save original function savedFunc = (tWriteFile)pThunk->u1.Function; // change the protection VirtualProtect((LPVOID)&(pThunk->u1.Function), sizeof(LPVOID), PAGE_EXECUTE_READWRITE, &dwOldProtect); // point to fake function PROC* tmp = (PROC*)&(pThunk->u1.Function); *tmp = (PROC)&NewWriteFile; // restore the protection VirtualProtect((LPVOID)&(pThunk->u1.Function), sizeof(LPVOID), dwOldProtect, &dwOldProtect); MessageBoxA(NULL, "VirtualProtect", "Success", MB_OK); return TRUE; } pThunk++; rThunk++; } MessageBoxA(NULL, "VirtualProtect", "Failed", MB_OK); return FALSE; } BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: MessageBoxA(NULL, "ATTACH", "Success", MB_OK); tryHook(); break; case DLL_PROCESS_DETACH: MessageBoxA(NULL, "DETACH", "Success", MB_OK); break; } return TRUE; }
#include <stdio.h> // - Just for some ASCII messages #include <string.h> #include <math.h> #include <iostream> #include <fstream> #include "visuals.h" // Header file for our OpenGL functions #include <stdlib.h> #include <time.h> #include "GL/glut.h" // - An interface and windows management library model md; #define MAX_STARS 2000 #define MAX 100 static float tx = 0.0; static float ty = 0.0; static float tz = 0.0; static float planet_rotate = 0.0; static float rotx[2]; static bool animate = true; static bool up = true; static double sun_radius = 5; double stars_positions[MAX_STARS][3]; void DrawAxes() { glColor3f(0.6, 0.6, 0.6); glBegin(GL_LINES); glVertex2f(0.0, 0.0); glVertex2f(100.0, 0.0); glVertex2f(0.0, 0.0); glVertex2f(0.0, 100.0); glEnd(); } void DisplayStars() {//create the stars for (int i = 0; i < MAX_STARS; i++) { glPushMatrix(); glTranslatef(stars_positions[i][0], stars_positions[i][1], stars_positions[i][2]); //move them to the ramdom x,y,z position of array glColor3f(1.0, 1.0, 1.0);// Set drawing colour white glutSolidSphere(0.05, 30, 24); glPopMatrix(); } } using namespace std; void Render() { //CLEARS FRAME BUFFER ie COLOR BUFFER& DEPTH BUFFER (1.0) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clean up the colour of the window glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0, 0, -20); glTranslatef(tx, 0.0, 0.0); //rotate the camera from keyboard interrupt glTranslatef(0.0, ty, 0.0); glTranslatef(0, 0, -20); DrawAxes(); glClear(GL_COLOR_BUFFER_BIT); DisplayStars();//create stars glPushMatrix(); glTranslatef(0, 0, -15); glRotatef(rotx[0], 0, 1, 0); glTranslatef(0, 0, 9); glColor3f(0.1, 0.1, 0.8); // Set drawing colour displayPlanet(md, 0, 0, 0,0.004); //create earth glRotatef(rotx[1], 1, 0, 0); //so the moon rotates around earth glTranslatef(-1, -1, -17); glTranslatef(0, -1, 20); glColor3f(1, 1, 1); // Set drawing colour displayPlanet(md, 0, 0, 0, 0.001); //create moon glPopMatrix(); DisplaySun();//create sun glutSwapBuffers(); // All drawing commands applied to the // hidden buffer, so now, bring forward // the hidden buffer and hide the visible one } //----------------------------------------------------------- void Resize(int w, int h) { // define the visible area of the window ( in pixels ) if (h==0) h=1; glViewport(0,0,w,h); // Setup viewing volume glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, (float)w/(float)h, 1.0, 500.0); } void Idle() { if(animate){ //if there's not an I/O interrupt //modify the halo around the sun if ( (sun_radius < 5.9) && up){ sun_radius += 0.03; } else if( (sun_radius > 5 ) && !up ){ sun_radius -= 0.03; }else if (sun_radius >= 5.9 && up){ up = false; sun_radius -= 0.03; } else if (sun_radius <= 5 && !up) { up = true; sun_radius += 0.03; } planet_rotate += 4.0; //speed of planet's rotation rotx[0] += 1.2;//increase the speed of planets (for earth it's 1.2) rotx[1] += 1.2 + 9.0; } glutPostRedisplay(); } void Keyboard(unsigned char key,int xx,int xy) { switch (key) { case 'q': exit(0); break; case 'a': tx += 0.5f; break; case 'd': tx -= 0.5f; break; case 'w': ty -= 0.5f; break; case 's': ty += 0.5f; break; default: break; } glutPostRedisplay(); } void Mouse(int button,int state,int x,int y) { if(state == GLUT_DOWN && button == GLUT_LEFT_BUTTON) { animate = !animate; glutPostRedisplay(); } } void Setup() { rotx[0] = 0.0; //initialize the value of rotation of earth rotx[1] = 0.0; //initialize the value of rotation of moon srand(time(NULL)); for (int i = 0; i < MAX_STARS; i++) { stars_positions[i][0] = (rand() % 200) - MAX; //generate random number x from -100 to 100 stars_positions[i][1] = (rand() % 200) - MAX; //generate random number y from -100 to 100 stars_positions[i][2] = (rand() % 200) - MAX; //generate random number z from -100 to 100 } ReadFile(&md); glShadeModel(GL_FLAT); // polygon rendering mode glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_NORMALIZE); //Parameter handling glShadeModel (GL_SMOOTH); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glClearDepth(1); // polygon rendering mode glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); //set up transparency glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //Set up light source GLfloat light_position[] = { 0.0, 0.0, 15.0, 0.0 }; glLightfv( GL_LIGHT0, GL_POSITION, light_position); GLfloat ambientLight[] = { 0.3, 0.3, 0.3, 1.0 }; GLfloat diffuseLight[] = { 0.8, 0.8, 0.8, 1.0 }; GLfloat specularLight[] = { 1.0, 1.0, 1.0, 1.0 }; glLightfv( GL_LIGHT0, GL_AMBIENT, ambientLight ); glLightfv( GL_LIGHT0, GL_DIFFUSE, diffuseLight ); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glFrontFace(GL_CW); } void DisplaySun() { glPushMatrix(); glTranslatef(0, 0, -15); glColor3f(1.0, 1.0, 0.0); // Sun glutSolidSphere(5, 200, 20); double opacity = (5.9 - sun_radius) / 0.9 + 0.15; glColor4f(1, 0.90, 0.0, opacity); // Radiation glutSolidSphere(sun_radius, 200, 20); glPopMatrix(); } void ReadFile(model *md) { FILE * file = fopen("planet.obj", "r"); if (file == NULL) { printf("Error opening file\n"); return; } while (1) { char lineHeader[1024]; // read the first word of the line int res = fscanf(file, "%s", lineHeader); if (res == EOF) break; if (strcmp(lineHeader, "v") == 0) { point vertex; fscanf(file, "%f %f %f\n", &vertex.x, &vertex.y, &vertex.z); md->obj_points.push_back(vertex); } else if (strcmp(lineHeader, "vn") == 0) { point normal; fscanf(file, "%f %f %f\n", &normal.x, &normal.y, &normal.z); md->normals.push_back(normal); } else if (strcmp(lineHeader, "f") == 0) { face vertexIndex, normalIndex; int matches = fscanf(file, "%d//%d %d//%d %d//%d\n", &vertexIndex.vtx[0], &normalIndex.vtx[0], &vertexIndex.vtx[1], &normalIndex.vtx[1], &vertexIndex.vtx[2], &normalIndex.vtx[2]); if (matches != 6) { return; } md->vertexIndices.push_back(vertexIndex); md->normalIndices.push_back(normalIndex); } } fclose(file); } void displayPlanet(model md, double x, double y, double z, float size){ glPushMatrix(); glTranslatef(x,y,z); glScalef(size, size, size); glRotatef(planet_rotate, 1, 0, 0); //planet's rotation glBegin(GL_TRIANGLES); for (int i = 0; i < md.vertexIndices.size(); i++) { glVertex3f(md.obj_points[md.vertexIndices[i].vtx[0]-1].x,md.obj_points[md.vertexIndices[i].vtx[0]-1].y,md.obj_points[md.vertexIndices[i].vtx[0]-1].z); glVertex3f(md.obj_points[md.vertexIndices[i].vtx[1]-1].x,md.obj_points[md.vertexIndices[i].vtx[1]-1].y,md.obj_points[md.vertexIndices[i].vtx[1]-1].z); glVertex3f(md.obj_points[md.vertexIndices[i].vtx[2]-1].x,md.obj_points[md.vertexIndices[i].vtx[2]-1].y,md.obj_points[md.vertexIndices[i].vtx[2]-1].z); glNormal3f(md.obj_points[md.normalIndices[i].vtx[0]-1].x,md.obj_points[md.normalIndices[i].vtx[0]-1].y,md.obj_points[md.normalIndices[i].vtx[0]-1].z); glNormal3f(md.obj_points[md.normalIndices[i].vtx[1]-1].x,md.obj_points[md.normalIndices[i].vtx[1]-1].y,md.obj_points[md.normalIndices[i].vtx[1]-1].z); glNormal3f(md.obj_points[md.normalIndices[i].vtx[2]-1].x,md.obj_points[md.normalIndices[i].vtx[2]-1].y,md.obj_points[md.normalIndices[i].vtx[2]-1].z); } glEnd(); glPopMatrix(); }
; A314894: Coordination sequence Gal.6.194.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; 1,5,9,14,19,24,28,33,38,43,47,52,57,61,66,71,76,80,85,90,95,99,104,109,113,118,123,128,132,137,142,147,151,156,161,165,170,175,180,184,189,194,199,203,208,213,217,222,227,232 mov $2,$0 add $2,$0 add $2,6 mov $3,$2 mov $4,$0 add $0,$2 sub $3,6 lpb $0 sub $0,1 trn $0,10 mov $1,7 add $3,3 trn $3,4 lpe add $1,$3 add $1,3 lpb $4 add $1,3 sub $4,1 lpe sub $1,9 mov $0,$1
// Rockman X3 Practice ROM hack // by Myria // arch snes.cpu // LoROM org macro - see bass's snes-cpu.asm "seek" macro macro reorg n org ((({n}) & 0x7f0000) >> 1) | (({n}) & 0x7fff) base {n} endmacro // Warn if the current address is greater than the specified value. macro warnpc n {#}: if {#} > {n} warning "warnpc assertion failure" endif endmacro // Allows saving the current location and seeking somewhere else. define savepc push origin, base define loadpc pull base, origin // Warn if the expression is false. macro static_assert n if ({n}) == 0 warning "static assertion failure" endif endmacro // Copy the original ROM to initialize the address space. {reorg $008000} incbin "RockmanX3-original.smc" // Version tags eval version_major 0 eval version_minor 8 eval version_revision 2 // Constants eval stage_intro 0 eval stage_doppler1 9 eval stage_doppler2 10 eval stage_doppler3 11 eval stage_doppler4 12 eval game_config_size $1B eval soundnum_cant_escape $5A eval magic_sram_tag_lo $3358 // Combined, these say "X3PR" eval magic_sram_tag_hi $5250 eval magic_config_tag_lo $3358 // Combined, these say "X3C1" eval magic_config_tag_hi $3147 // RAM addresses eval title_screen_option $7E003C eval controller_1_current $7E00A8 eval controller_1_previous $7E00AA eval controller_1_new $7E00AC eval controller_2_current $7E00AE eval controller_2_previous $7E00B0 eval controller_2_new $7E00B2 eval screen_control_shadow $7E00B4 eval nmi_control_shadow $7E00C3 eval hdma_control_shadow $7E00C4 eval rng_value $7E09D6 eval controller_1_disable $7E1F63 eval event_flags $7E1FB2 eval state_vars $7E1FA0 eval state_level_already_loaded $7E1FB6 //x3fixme eval current_level $7E1F7A //x3fixme eval life_count $7E1F80 //x3fixme eval midpoint_flag $7E1F81 //x3fixme eval weapon_power $7E1F85 //x3fixme eval intro_completed $7E1F9B eval config_selected_option $7EFF80 eval config_data $7EFFC0 eval config_shot $7EFFC0 eval config_jump $7EFFC1 eval config_dash $7EFFC2 eval config_select_l $7EFFC3 eval config_select_r $7EFFC4 eval config_menu $7EFFC5 eval config_bgm $7EFFC8 // unused in X2 and X3, but might as well reuse these eval config_se $7EFFC9 // unused in X2 and X3, but might as well reuse these eval config_sound $7EFFCA eval spc_state_shadow $7EFFFE // Temporary storage for load process. Overlaps game use. eval load_temporary_rng $7F0000 // ROM addresses //x3fixme eval rom_play_music $80878B eval rom_play_sound $01802B //x3fixme eval rom_rtl_instruction $808798 // last instruction of rom_play_sound //x3fixme eval rom_rts_instruction $8087D0 // last instruction of some part of rom_play_music //x3fixme eval rom_nmi_after_pushes $808173 eval rom_nmi_after_controller $088621 eval ram_nmi_after_controller $7E2621 // RAM copy of rom_nmi_after_controller //x3fixme eval rom_config_loop $80EAAA //x3fixme eval rom_config_button $80EB55 //x3fixme eval rom_config_stereo $80EBE8 //x3fixme eval rom_config_bgm $80EC30 //x3fixme eval rom_config_se $80EC74 //x3fixme eval rom_config_exit $80ECC0 eval rom_default_config $06E0E4 eval rom_level_table $069C04 // SRAM addresses for saved states eval sram_start $700000 eval sram_previous_command $700200 eval sram_wram_7E0000 $710000 eval sram_wram_7E8000 $720000 eval sram_wram_7F0000 $730000 eval sram_wram_7F8000 $740000 eval sram_vram_0000 $750000 eval sram_vram_8000 $760000 eval sram_cgram $772000 eval sram_oam $772200 eval sram_dma_bank $770000 eval sram_validity $774000 eval sram_saved_sp $774004 eval sram_saved_dp $774006 // SRAM addresses for general config. These are at lower addresses to support // emulators and cartridges that don't support 256 KB of SRAM. eval sram_config_valid $700100 eval sram_config_game $700104 // Main game config. game_config_size bytes. eval sram_config_extra {sram_config_game} + {game_config_size} eval sram_config_category {sram_config_extra} + 0 eval sram_config_route {sram_config_extra} + 1 eval sram_config_midpointsoff {sram_config_extra} + 2 eval sram_config_keeprng {sram_config_extra} + 3 eval sram_config_musicoff {sram_config_extra} + 4 eval sram_config_godmode {sram_config_extra} + 5 eval sram_config_extra_size 6 // adjust this as more are added eval sram_banks $08 // Constants for categories and routing. eval category_anyp 0 eval num_categories 1 eval route_anyp_default 0 eval num_routes_anyp 1 // State table index offsets for special data. eval state_entry_size 64 eval index_offset_vile_flag (10 * 2) + 0 // Header edits {savepc} // Change SRAM size to 256 KB {reorg $00FFD8} db $08 {loadpc} // Init hook {savepc} {reorg $00800E} jml init_hook {loadpc} // Start of primary data bank (2B8000-2BE1FF) {reorg $2B8000} // Gameplay hacks. incsrc "gameplay.asm" // Stage select hacks. incsrc "stageselect.asm" // Config code. incsrc "config.asm" // Saved state code. incsrc "savedstates.asm" // The state table for each level is in statetable.asm. incsrc "statetable.asm" // End of primary data bank (2B8000-2BE1FF) {warnpc $2BE200}
; A073423: Sums of two powers of zero: triangle read by rows: T(m,n) = 0^n + 0^m, n = 0,1,2,3 ..., m = 0,1,2,3, ... n ; 2,1,0,1,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1 lpb $0,1 mov $2,$0 add $3,1 sub $0,$3 trn $0,1 lpe mov $1,2 trn $1,$2
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r14 push %rax push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0xe63d, %r14 nop nop nop nop cmp %rax, %rax movw $0x6162, (%r14) nop dec %r13 lea addresses_normal_ht+0x18835, %rsi nop sub $13601, %r10 vmovups (%rsi), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %r13 nop cmp $34495, %rax lea addresses_A_ht+0x1cb5d, %r10 nop nop nop nop dec %rcx mov (%r10), %r14 nop nop nop nop nop cmp $17915, %r13 lea addresses_normal_ht+0x1675d, %r13 nop nop nop cmp $22530, %rcx mov (%r13), %rax nop nop xor $7103, %rsi lea addresses_UC_ht+0x1435d, %rsi nop nop nop nop sub $27569, %r10 movups (%rsi), %xmm5 vpextrq $0, %xmm5, %r13 nop nop nop nop add %rdx, %rdx lea addresses_normal_ht+0x1afd, %r13 nop inc %r10 vmovups (%r13), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $0, %xmm7, %r14 nop nop nop nop and %r13, %r13 lea addresses_WC_ht+0x17edd, %rax cmp %r13, %r13 mov $0x6162636465666768, %r14 movq %r14, %xmm6 movups %xmm6, (%rax) nop nop cmp $32112, %r10 lea addresses_D_ht+0x17b5d, %r14 xor $3057, %rdx mov $0x6162636465666768, %rax movq %rax, %xmm7 vmovups %ymm7, (%r14) dec %r13 lea addresses_WC_ht+0x1c75d, %rax clflush (%rax) nop nop add %r10, %r10 movb $0x61, (%rax) nop nop nop nop cmp %r10, %r10 lea addresses_WC_ht+0x120dd, %rax nop nop cmp %r10, %r10 vmovups (%rax), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $1, %xmm0, %rdx nop nop nop xor $57792, %r13 lea addresses_normal_ht+0x85d, %rax nop add %rdx, %rdx movups (%rax), %xmm5 vpextrq $0, %xmm5, %r13 add $50622, %r10 lea addresses_normal_ht+0x668d, %rsi lea addresses_normal_ht+0xc21d, %rdi nop nop nop nop nop xor %rax, %rax mov $119, %rcx rep movsq nop nop nop add %r14, %r14 pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r14 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r9 push %rax push %rdx // Faulty Load lea addresses_PSE+0x1775d, %r11 nop nop xor %rax, %rax movups (%r11), %xmm7 vpextrq $1, %xmm7, %r9 lea oracles, %rax and $0xff, %r9 shlq $12, %r9 mov (%rax,%r9,1), %r9 pop %rdx pop %rax pop %r9 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_PSE', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 2}} {'src': {'NT': False, 'same': False, 'congruent': 1, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 11, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 8, 'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 5, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 16}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 10, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 1}} {'src': {'NT': False, 'same': False, 'congruent': 6, 'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'src': {'NT': False, 'same': False, 'congruent': 7, 'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 16}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 4, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 6, 'type': 'addresses_normal_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 */
%ifdef CONFIG { "RegData": { "XMM0": ["0x428b029f42a63326", "0x0000000000000000"], "XMM1": ["0x4150f0e342241b6c", "0x0000000000000000"], "XMM2": ["0x41aff21340ab4706", "0x0000000000000000"], "XMM3": ["0x40aa5bea411ac802", "0x0000000000000000"], "XMM4": ["0x428500c641e83ad2", "0x0000000000000000"], "XMM5": ["0x42b6ba02419a760c", "0x0000000000000000"], "XMM6": ["0x424bd89b4221cdae", "0x0000000000000000"], "XMM7": ["0x41bfce514202945e", "0x0000000000000000"], "XMM8": ["0x41c1cdc342b5494c", "0x0000000000000000"], "XMM9": ["0x42b66f2e42c5e0f9", "0x0000000000000000"], "XMM10": ["0x42c6f7d842b59a55", "0x0000000000000000"], "XMM11": ["0x4294cbf84281f1e5", "0x0000000000000000"], "XMM12": ["0x41cad360420ce913", "0x0000000000000000"], "XMM13": ["0x42b4662d40bbf141", "0x0000000000000000"], "XMM14": ["0x42501e3a42042015", "0x0000000000000000"], "XMM15": ["0x4122ce1242698acb", "0x0000000000000000"] } } %endif lea rdx, [rel .data] movapd xmm0, [rdx + 16 * 0] movapd xmm1, [rdx + 16 * 1] movapd xmm2, [rdx + 16 * 2] movapd xmm3, [rdx + 16 * 3] movapd xmm4, [rdx + 16 * 4] movapd xmm5, [rdx + 16 * 5] movapd xmm6, [rdx + 16 * 6] movapd xmm7, [rdx + 16 * 7] movapd xmm8, [rdx + 16 * 8] movapd xmm9, [rdx + 16 * 9] movapd xmm10, [rdx + 16 * 10] movapd xmm11, [rdx + 16 * 11] movapd xmm12, [rdx + 16 * 12] movapd xmm13, [rdx + 16 * 13] movapd xmm14, [rdx + 16 * 14] movapd xmm15, [rdx + 16 * 15] cvtpd2ps xmm0, [rdx + 16 * 0] cvtpd2ps xmm1, [rdx + 16 * 1] cvtpd2ps xmm2, [rdx + 16 * 2] cvtpd2ps xmm3, [rdx + 16 * 3] cvtpd2ps xmm4, [rdx + 16 * 4] cvtpd2ps xmm5, [rdx + 16 * 5] cvtpd2ps xmm6, [rdx + 16 * 6] cvtpd2ps xmm7, [rdx + 16 * 7] cvtpd2ps xmm8, [rdx + 16 * 8] cvtpd2ps xmm9, [rdx + 16 * 9] cvtpd2ps xmm10, [rdx + 16 * 10] cvtpd2ps xmm11, [rdx + 16 * 11] cvtpd2ps xmm12, [rdx + 16 * 12] cvtpd2ps xmm13, [rdx + 16 * 13] cvtpd2ps xmm14, [rdx + 16 * 14] cvtpd2ps xmm15, [rdx + 16 * 15] hlt align 16 ; 512bytes of random data .data: dq 83.0999,69.50512,41.02678,13.05881,5.35242,21.9932,9.67383,5.32372,29.02872,66.50151,19.30764,91.3633,40.45086,50.96153,32.64489,23.97574,90.64316,24.22547,98.9394,91.21715,90.80143,99.48407,64.97245,74.39838,35.22761,25.35321,5.8732,90.19956,33.03133,52.02952,58.38554,10.17531,47.84703,84.04831,90.02965,65.81329,96.27991,6.64479,25.58971,95.00694,88.1929,37.16964,49.52602,10.27223,77.70605,20.21439,9.8056,41.29389,15.4071,57.54286,9.61117,55.54302,52.90745,4.88086,72.52882,3.0201,56.55091,71.22749,61.84736,88.74295,47.72641,24.17404,33.70564,96.71303
/* * Copyright (c) 2011-2012,2015,2017 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall * not be construed as granting a license to any other intellectual * property including but not limited to intellectual property relating * to a hardware implementation of the functionality of the software * licensed hereunder. You may use the software subject to the license * terms below provided that you ensure that this notice is replicated * unmodified and in its entirety in all distributions of the software, * modified or unmodified, in source code or in binary form. * * Copyright (c) 2002-2005 The Regents of The University of Michigan * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer; * redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution; * neither the name of the copyright holders nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Authors: Ron Dreslinski * Andreas Hansson * William Wang */ #ifndef __MEM_GEM5_PROTOCOL_FUNCTIONAL_HH__ #define __MEM_GEM5_PROTOCOL_FUNCTIONAL_HH__ #include "mem/packet.hh" class FunctionalResponseProtocol; class FunctionalRequestProtocol { friend class FunctionalResponseProtocol; protected: /** * Send a functional request packet, where the data is instantly * updated everywhere in the memory system, without affecting the * current state of any block or moving the block. * * @param pkt Packet to send. */ void send(FunctionalResponseProtocol *peer, PacketPtr pkt) const; /** * Receive a functional snoop request packet from the peer. */ virtual void recvFunctionalSnoop(PacketPtr pkt) = 0; }; class FunctionalResponseProtocol { friend class FunctionalRequestProtocol; protected: /** * Send a functional snoop request packet, where the data is * instantly updated everywhere in the memory system, without * affecting the current state of any block or moving the block. * * @param pkt Snoop packet to send. */ void sendSnoop(FunctionalRequestProtocol *peer, PacketPtr pkt) const; /** * Receive a functional request packet from the peer. */ virtual void recvFunctional(PacketPtr pkt) = 0; }; #endif //__MEM_GEM5_PROTOCOL_FUNCTIONAL_HH__
; A182321: Number of iterations of A025581(n) required to reach 0. ; 0,1,2,1,3,2,1,2,3,2,1,4,2,3,2,1,3,4,2,3,2,1,2,3,4,2,3,2,1,3,2,3,4,2,3,2,1,4,3,2,3,4,2,3,2,1,3,4,3,2,3,4,2,3,2,1,2,3,4,3,2,3,4,2,3,2,1,5,2,3,4,3,2,3,4,2,3,2,1,3,5,2,3,4,3,2,3,4,2,3,2,1,4,3,5,2,3,4,3,2,3,4,2,3,2,1,3,4,3,5,2,3,4,3,2,3,4,2,3,2,1,2,3,4,3,5,2,3,4,3,2,3,4,2,3,2,1,4,2,3,4,3,5,2,3,4,3,2,3,4,2,3,2,1,5,4,2,3,4,3,5,2,3,4,3,2,3,4,2,3,2,1,3,5,4,2,3,4,3,5,2,3,4,3,2,3,4,2,3,2,1,4,3,5,4,2,3,4,3,5,2,3,4,3,2,3,4,2,3,2,1,3,4,3,5,4,2,3,4,3,5,2,3,4,3,2,3,4,2,3,2,1,2,3,4,3,5,4,2,3,4,3,5,2,3,4,3,2,3,4 lpb $0 sub $0,1 add $1,1 cal $0,25669 ; Exponent of 7 (value of i) in n-th number of form 7^i*8^j. lpe
; A289161: Number of 3-cycles in the n X n black bishop graph. ; 0,0,2,6,24,50,114,196,352,540,850,1210,1752,2366,3234,4200,5504,6936,8802,10830,13400,16170,19602,23276,27744,32500,38194,44226,51352,58870,67650,76880,87552,98736,111554,124950,140184,156066,174002,192660,213600,235340,259602,284746,312664,341550,373474,406456,442752,480200,521250,563550,609752,657306,709074,762300,820064,879396,943602,1009490,1080600,1153510,1232002,1312416,1398784,1487200,1581954,1678886,1782552,1888530,2001650,2117220,2240352,2366076,2499794,2636250,2781144,2928926,3085602 pow $0,2 mov $1,$0 mod $1,2 sub $2,$0 div $2,2 add $1,$2 mul $1,$0 sub $0,$1 div $0,12 mul $0,2
; A250659: Number of (5+1) X (n+1) 0..1 arrays with nondecreasing x(i,j)-x(i,j-1) in the i direction and nondecreasing min(x(i,j),x(i-1,j)) in the j direction. ; 159,286,445,636,859,1114,1401,1720,2071,2454,2869,3316,3795,4306,4849,5424,6031,6670,7341,8044,8779,9546,10345,11176,12039,12934,13861,14820,15811,16834,17889,18976,20095,21246,22429,23644,24891,26170,27481,28824,30199,31606,33045,34516,36019,37554,39121,40720,42351,44014,45709,47436,49195,50986,52809,54664,56551,58470,60421,62404,64419,66466,68545,70656,72799,74974,77181,79420,81691,83994,86329,88696,91095,93526,95989,98484,101011,103570,106161,108784,111439,114126,116845,119596,122379,125194 mul $0,2 add $0,7 mul $0,8 bin $0,2 add $0,20 div $0,8 sub $0,36
; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license and patent ; grant that can be found in the LICENSE file in the root of the source ; tree. All contributing project authors may be found in the AUTHORS ; file in the root of the source tree. ; EXPORT |vp8_dc_only_idct_add_neon| ARM REQUIRE8 PRESERVE8 AREA ||.text||, CODE, READONLY, ALIGN=2 ;void vp8_dc_only_idct_add_neon(short input_dc, unsigned char *pred_ptr, ; unsigned char *dst_ptr, int pitch, int stride) ; r0 input_dc ; r1 pred_ptr ; r2 dst_ptr ; r3 pitch ; sp stride |vp8_dc_only_idct_add_neon| PROC add r0, r0, #4 asr r0, r0, #3 ldr r12, [sp] vdup.16 q0, r0 vld1.32 {d2[0]}, [r1], r3 vld1.32 {d2[1]}, [r1], r3 vld1.32 {d4[0]}, [r1], r3 vld1.32 {d4[1]}, [r1] vaddw.u8 q1, q0, d2 vaddw.u8 q2, q0, d4 vqmovun.s16 d2, q1 vqmovun.s16 d4, q2 vst1.32 {d2[0]}, [r2], r12 vst1.32 {d2[1]}, [r2], r12 vst1.32 {d4[0]}, [r2], r12 vst1.32 {d4[1]}, [r2] bx lr ENDP END
; A253433: Number of (n+1) X (6+1) 0..1 arrays with every 2 X 2 subblock diagonal minus antidiagonal sum nondecreasing horizontally, vertically and ne-to-sw antidiagonally. ; 325,318,336,372,444,588,876,1452,2604,4908,9516,18732,37164,74028,147756,295212,590124,1179948,2359596,4718892,9437484,18874668,37749036,75497772,150995244,301990188,603980076,1207959852,2415919404,4831838508,9663676716,19327353132,38654705964,77309411628,154618822956,309237645612,618475290924,1236950581548,2473901162796,4947802325292,9895604650284,19791209300268,39582418600236,79164837200172,158329674400044,316659348799788,633318697599276,1266637395198252,2533274790396204,5066549580792108,10133099161583916,20266198323167532,40532396646334764,81064793292669228,162129586585338156,324259173170676012,648518346341351724,1297036692682703148,2594073385365405996,5188146770730811692,10376293541461623084,20752587082923245868,41505174165846491436,83010348331692982572,166020696663385964844,332041393326771929388,664082786653543858476,1328165573307087716652,2656331146614175433004,5312662293228350865708,10625324586456701731116,21250649172913403461932,42501298345826806923564,85002596691653613846828,170005193383307227693356,340010386766614455386412,680020773533228910772524,1360041547066457821544748,2720083094132915643089196,5440166188265831286178092,10880332376531662572355884,21760664753063325144711468,43521329506126650289422636,87042659012253300578844972,174085318024506601157689644,348170636049013202315378988,696341272098026404630757676,1392682544196052809261515052,2785365088392105618523029804,5570730176784211237046059308,11141460353568422474092118316,22282920707136844948184236332,44565841414273689896368472364,89131682828547379792736944428,178263365657094759585473888556,356526731314189519170947776812,713053462628379038341895553324,1426106925256758076683791106348,2852213850513516153367582212396,5704427701027032306735164424492 seq $0,253434 ; Number of (n+1) X (7+1) 0..1 arrays with every 2 X 2 subblock diagonal minus antidiagonal sum nondecreasing horizontally, vertically and ne-to-sw antidiagonally. sub $0,288
/** @file ***************************************************************************** Implementation of functions for generating randomness. See rng.hpp . ***************************************************************************** * @author This file is part of libff, developed by SCIPR Lab * and contributors (see AUTHORS). * @copyright MIT license (see LICENSE file) *****************************************************************************/ #ifndef RNG_TCC_ #define RNG_TCC_ #include <gmp.h> #include <libff/algebra/fields/bigint.hpp> #include <libff/common/rng.hpp> #include <libff/common/utils.hpp> #include <openssl/sha.h> namespace libff { template<typename FieldT> FieldT SHA512_rng(const uint64_t idx) { // current Python code cannot handle larger // values, so testing here for some assumptions. assert(GMP_NUMB_BITS == 64); assert(is_little_endian()); assert(FieldT::size_in_bits() <= SHA512_DIGEST_LENGTH * 8); bigint<FieldT::num_limbs> rval; uint64_t iter = 0; do { mp_limb_t hash [((SHA512_DIGEST_LENGTH * 8) + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS]; SHA512_CTX sha512; SHA512_Init(&sha512); SHA512_Update(&sha512, &idx, sizeof(idx)); SHA512_Update(&sha512, &iter, sizeof(iter)); SHA512_Final((unsigned char *)hash, &sha512); for (mp_size_t i = 0; i < FieldT::num_limbs; ++i) { rval.data[i] = hash[i]; } /* clear all bits higher than MSB of modulus */ size_t bitno = GMP_NUMB_BITS * FieldT::num_limbs - 1; /* mod is non-zero so the loop will always terminate */ while (FieldT::mod.test_bit(bitno) == false) { const std::size_t part = bitno / GMP_NUMB_BITS; const std::size_t bit = bitno - (GMP_NUMB_BITS * part); rval.data[part] &= ~(1ul << bit); bitno--; } ++iter; } /* if r.data is still >= modulus -- repeat (rejection sampling) */ while (mpn_cmp(rval.data, FieldT::mod.data, FieldT::num_limbs) >= 0); return FieldT(rval); } } // namespace libff #endif // RNG_TCC_
; A165447: T(n,k) = n^4 - 2*k^2*n^2 + k^4 = A120070(n, k)^2. ; Submitted by Christian Krause ; 9,64,25,225,144,49,576,441,256,81,1225,1024,729,400,121,2304,2025,1600,1089,576,169,3969,3600,3025,2304,1521,784,225,6400,5929,5184,4225,3136,2025,1024,289,9801,9216,8281,7056,5625,4096,2601,1296,361,14400,13689,12544,11025,9216,7225,5184,3249,1600,441,20449,19600,18225,16384,14161,11664,9025,6400,3969,1936,529,28224,27225,25600,23409,20736,17689,14400,11025,7744,4761,2304,625,38025,36864,34969,32400,29241,25600,21609,17424,13225,9216,5625,2704,729,50176,48841,46656,43681,40000,35721,30976 seq $0,120070 ; Triangle of numbers used to compute the frequencies of the spectral lines of the hydrogen atom. pow $0,2
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .section .note.GNU-stack,"",%progbits .text .p2align 4, 0x90 .globl EncryptECB_RIJ128pipe_AES_NI .type EncryptECB_RIJ128pipe_AES_NI, @function EncryptECB_RIJ128pipe_AES_NI: movslq %r8d, %r8 sub $(64), %r8 jl .Lshort_inputgas_1 .p2align 4, 0x90 .Lblks_loopgas_1: movdqa (%rcx), %xmm4 mov %rcx, %r9 movdqu (%rdi), %xmm0 movdqu (16)(%rdi), %xmm1 movdqu (32)(%rdi), %xmm2 movdqu (48)(%rdi), %xmm3 add $(64), %rdi pxor %xmm4, %xmm0 pxor %xmm4, %xmm1 pxor %xmm4, %xmm2 pxor %xmm4, %xmm3 movdqa (16)(%r9), %xmm4 add $(16), %r9 mov %rdx, %r10 sub $(1), %r10 .p2align 4, 0x90 .Lcipher_loopgas_1: aesenc %xmm4, %xmm0 aesenc %xmm4, %xmm1 aesenc %xmm4, %xmm2 aesenc %xmm4, %xmm3 movdqa (16)(%r9), %xmm4 add $(16), %r9 dec %r10 jnz .Lcipher_loopgas_1 aesenclast %xmm4, %xmm0 movdqu %xmm0, (%rsi) aesenclast %xmm4, %xmm1 movdqu %xmm1, (16)(%rsi) aesenclast %xmm4, %xmm2 movdqu %xmm2, (32)(%rsi) aesenclast %xmm4, %xmm3 movdqu %xmm3, (48)(%rsi) add $(64), %rsi sub $(64), %r8 jge .Lblks_loopgas_1 .Lshort_inputgas_1: add $(64), %r8 jz .Lquitgas_1 lea (,%rdx,4), %rax lea (-144)(%rcx,%rax,4), %r9 .p2align 4, 0x90 .Lsingle_blk_loopgas_1: movdqu (%rdi), %xmm0 add $(16), %rdi pxor (%rcx), %xmm0 cmp $(12), %rdx jl .Lkey_128_sgas_1 jz .Lkey_192_sgas_1 .Lkey_256_sgas_1: aesenc (-64)(%r9), %xmm0 aesenc (-48)(%r9), %xmm0 .Lkey_192_sgas_1: aesenc (-32)(%r9), %xmm0 aesenc (-16)(%r9), %xmm0 .Lkey_128_sgas_1: aesenc (%r9), %xmm0 aesenc (16)(%r9), %xmm0 aesenc (32)(%r9), %xmm0 aesenc (48)(%r9), %xmm0 aesenc (64)(%r9), %xmm0 aesenc (80)(%r9), %xmm0 aesenc (96)(%r9), %xmm0 aesenc (112)(%r9), %xmm0 aesenc (128)(%r9), %xmm0 aesenclast (144)(%r9), %xmm0 movdqu %xmm0, (%rsi) add $(16), %rsi sub $(16), %r8 jnz .Lsingle_blk_loopgas_1 .Lquitgas_1: pxor %xmm4, %xmm4 ret .Lfe1: .size EncryptECB_RIJ128pipe_AES_NI, .Lfe1-(EncryptECB_RIJ128pipe_AES_NI)