text
stringlengths
1
1.05M
// Copyright (c) 2009-2012 The Bitcoin developers // Copyright (c) 2015-2018 The PIVX developers // Copyright (c) 2019 The GHRCoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "activemasternode.h" #include "db.h" #include "init.h" #include "main.h" #include "masternode-budget.h" #include "masternode-payments.h" #include "masternodeconfig.h" #include "masternodeman.h" #include "rpc/server.h" #include "utilmoneystr.h" #include <univalue.h> #include <boost/tokenizer.hpp> #include <fstream> UniValue getpoolinfo(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( "getpoolinfo\n" "\nReturns anonymous pool-related information\n" "\nResult:\n" "{\n" " \"current\": \"addr\", (string) GHRCoin address of current masternode\n" " \"state\": xxxx, (string) unknown\n" " \"entries\": xxxx, (numeric) Number of entries\n" " \"accepted\": xxxx, (numeric) Number of entries accepted\n" "}\n" "\nExamples:\n" + HelpExampleCli("getpoolinfo", "") + HelpExampleRpc("getpoolinfo", "")); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("current_masternode", mnodeman.GetCurrentMasterNode()->addr.ToString())); obj.push_back(Pair("state", obfuScationPool.GetState())); obj.push_back(Pair("entries", obfuScationPool.GetEntriesCount())); obj.push_back(Pair("entries_accepted", obfuScationPool.GetCountEntriesAccepted())); return obj; } // This command is retained for backwards compatibility, but is depreciated. // Future removal of this command is planned to keep things clean. UniValue masternode(const UniValue& params, bool fHelp) { string strCommand; if (params.size() >= 1) strCommand = params[0].get_str(); if (fHelp || (strCommand != "start" && strCommand != "start-alias" && strCommand != "start-many" && strCommand != "start-all" && strCommand != "start-missing" && strCommand != "start-disabled" && strCommand != "list" && strCommand != "list-conf" && strCommand != "count" && strCommand != "enforce" && strCommand != "debug" && strCommand != "current" && strCommand != "winners" && strCommand != "genkey" && strCommand != "connect" && strCommand != "outputs" && strCommand != "status" && strCommand != "calcscore")) throw runtime_error( "masternode \"command\"...\n" "\nSet of commands to execute masternode related actions\n" "This command is depreciated, please see individual command documentation for future reference\n\n" "\nArguments:\n" "1. \"command\" (string or set of strings, required) The command to execute\n" "\nAvailable commands:\n" " count - Print count information of all known masternodes\n" " current - Print info on current masternode winner\n" " debug - Print masternode status\n" " genkey - Generate new masternodeprivkey\n" " outputs - Print masternode compatible outputs\n" " start - Start masternode configured in ghrcoin.conf\n" " start-alias - Start single masternode by assigned alias configured in masternode.conf\n" " start-<mode> - Start masternodes configured in masternode.conf (<mode>: 'all', 'missing', 'disabled')\n" " status - Print masternode status information\n" " list - Print list of all known masternodes (see masternodelist for more info)\n" " list-conf - Print masternode.conf in JSON format\n" " winners - Print list of masternode winners\n"); if (strCommand == "list") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return listmasternodes(newParams, fHelp); } if (strCommand == "connect") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return masternodeconnect(newParams, fHelp); } if (strCommand == "count") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return getmasternodecount(newParams, fHelp); } if (strCommand == "current") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return masternodecurrent(newParams, fHelp); } if (strCommand == "debug") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return masternodedebug(newParams, fHelp); } if (strCommand == "start" || strCommand == "start-alias" || strCommand == "start-many" || strCommand == "start-all" || strCommand == "start-missing" || strCommand == "start-disabled") { return startmasternode(params, fHelp); } if (strCommand == "genkey") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return createmasternodekey(newParams, fHelp); } if (strCommand == "list-conf") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return listmasternodeconf(newParams, fHelp); } if (strCommand == "outputs") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return getmasternodeoutputs(newParams, fHelp); } if (strCommand == "status") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return getmasternodestatus(newParams, fHelp); } if (strCommand == "winners") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return getmasternodewinners(newParams, fHelp); } if (strCommand == "calcscore") { UniValue newParams(UniValue::VARR); // forward params but skip command for (unsigned int i = 1; i < params.size(); i++) { newParams.push_back(params[i]); } return getmasternodescores(newParams, fHelp); } return NullUniValue; } UniValue listmasternodes(const UniValue& params, bool fHelp) { std::string strFilter = ""; if (params.size() == 1) strFilter = params[0].get_str(); if (fHelp || (params.size() > 1)) throw runtime_error( "listmasternodes ( \"filter\" )\n" "\nGet a ranked list of masternodes\n" "\nArguments:\n" "1. \"filter\" (string, optional) Filter search text. Partial match by txhash, status, or addr.\n" "\nResult:\n" "[\n" " {\n" " \"rank\": n, (numeric) Masternode Rank (or 0 if not enabled)\n" " \"txhash\": \"hash\", (string) Collateral transaction hash\n" " \"outidx\": n, (numeric) Collateral transaction output index\n" " \"status\": s, (string) Status (ENABLED/EXPIRED/REMOVE/etc)\n" " \"addr\": \"addr\", (string) Masternode GHRCoin address\n" " \"version\": v, (numeric) Masternode protocol version\n" " \"lastseen\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) of the last seen\n" " \"activetime\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) masternode has been active\n" " \"lastpaid\": ttt, (numeric) The time in seconds since epoch (Jan 1 1970 GMT) masternode was last paid\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("listmasternodes", "") + HelpExampleRpc("listmasternodes", "")); UniValue ret(UniValue::VARR); int nHeight; { LOCK(cs_main); CBlockIndex* pindex = chainActive.Tip(); if(!pindex) return 0; nHeight = pindex->nHeight; } std::vector<pair<int, CMasternode> > vMasternodeRanks = mnodeman.GetMasternodeRanks(nHeight); BOOST_FOREACH (PAIRTYPE(int, CMasternode) & s, vMasternodeRanks) { UniValue obj(UniValue::VOBJ); std::string strVin = s.second.vin.prevout.ToStringShort(); std::string strTxHash = s.second.vin.prevout.hash.ToString(); uint32_t oIdx = s.second.vin.prevout.n; CMasternode* mn = mnodeman.Find(s.second.vin); if (mn != NULL) { if (strFilter != "" && strTxHash.find(strFilter) == string::npos && mn->Status().find(strFilter) == string::npos && CBitcoinAddress(mn->pubKeyCollateralAddress.GetID()).ToString().find(strFilter) == string::npos) continue; std::string strStatus = mn->Status(); std::string strHost; int port; SplitHostPort(mn->addr.ToString(), port, strHost); CNetAddr node = CNetAddr(strHost, false); std::string strNetwork = GetNetworkName(node.GetNetwork()); obj.push_back(Pair("rank", (strStatus == "ENABLED" ? s.first : 0))); obj.push_back(Pair("network", strNetwork)); obj.push_back(Pair("txhash", strTxHash)); obj.push_back(Pair("outidx", (uint64_t)oIdx)); obj.push_back(Pair("status", strStatus)); obj.push_back(Pair("ip", mn->addr.ToStringIP())); obj.push_back(Pair("addr", CBitcoinAddress(mn->pubKeyCollateralAddress.GetID()).ToString())); obj.push_back(Pair("version", mn->protocolVersion)); obj.push_back(Pair("lastseen", (int64_t)mn->lastPing.sigTime)); obj.push_back(Pair("activetime", (int64_t)(mn->lastPing.sigTime - mn->sigTime))); obj.push_back(Pair("lastpaid", (int64_t)mn->GetLastPaid())); ret.push_back(obj); } } return ret; } UniValue masternodeconnect(const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 1)) throw runtime_error( "masternodeconnect \"address\"\n" "\nAttempts to connect to specified masternode address\n" "\nArguments:\n" "1. \"address\" (string, required) IP or net address to connect to\n" "\nExamples:\n" + HelpExampleCli("masternodeconnect", "\"192.168.0.6:23121\"") + HelpExampleRpc("masternodeconnect", "\"192.168.0.6:23121\"")); std::string strAddress = params[0].get_str(); CService addr = CService(strAddress); CNode* pnode = ConnectNode((CAddress)addr, NULL, false); if (pnode) { pnode->Release(); return NullUniValue; } else { throw runtime_error("error connecting\n"); } } UniValue getmasternodecount (const UniValue& params, bool fHelp) { if (fHelp || (params.size() > 0)) throw runtime_error( "getmasternodecount\n" "\nGet masternode count values\n" "\nResult:\n" "{\n" " \"total\": n, (numeric) Total masternodes\n" " \"stable\": n, (numeric) Stable count\n" " \"obfcompat\": n, (numeric) Obfuscation Compatible\n" " \"enabled\": n, (numeric) Enabled masternodes\n" " \"inqueue\": n (numeric) Masternodes in queue\n" "}\n" "\nExamples:\n" + HelpExampleCli("getmasternodecount", "") + HelpExampleRpc("getmasternodecount", "")); UniValue obj(UniValue::VOBJ); int nCount = 0; int ipv4 = 0, ipv6 = 0, onion = 0; if (chainActive.Tip()) mnodeman.GetNextMasternodeInQueueForPayment(chainActive.Tip()->nHeight, true, nCount); mnodeman.CountNetworks(ActiveProtocol(), ipv4, ipv6, onion); obj.push_back(Pair("total", mnodeman.size())); obj.push_back(Pair("stable", mnodeman.stable_size())); obj.push_back(Pair("obfcompat", mnodeman.CountEnabled(ActiveProtocol()))); obj.push_back(Pair("enabled", mnodeman.CountEnabled())); obj.push_back(Pair("inqueue", nCount)); obj.push_back(Pair("ipv4", ipv4)); obj.push_back(Pair("ipv6", ipv6)); obj.push_back(Pair("onion", onion)); return obj; } UniValue masternodecurrent (const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 0)) throw runtime_error( "masternodecurrent\n" "\nGet current masternode winner\n" "\nResult:\n" "{\n" " \"protocol\": xxxx, (numeric) Protocol version\n" " \"txhash\": \"xxxx\", (string) Collateral transaction hash\n" " \"pubkey\": \"xxxx\", (string) MN Public key\n" " \"lastseen\": xxx, (numeric) Time since epoch of last seen\n" " \"activeseconds\": xxx, (numeric) Seconds MN has been active\n" "}\n" "\nExamples:\n" + HelpExampleCli("masternodecurrent", "") + HelpExampleRpc("masternodecurrent", "")); CMasternode* winner = mnodeman.GetCurrentMasterNode(1); if (winner) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("protocol", (int64_t)winner->protocolVersion)); obj.push_back(Pair("txhash", winner->vin.prevout.hash.ToString())); obj.push_back(Pair("pubkey", CBitcoinAddress(winner->pubKeyCollateralAddress.GetID()).ToString())); obj.push_back(Pair("lastseen", (winner->lastPing == CMasternodePing()) ? winner->sigTime : (int64_t)winner->lastPing.sigTime)); obj.push_back(Pair("activeseconds", (winner->lastPing == CMasternodePing()) ? 0 : (int64_t)(winner->lastPing.sigTime - winner->sigTime))); return obj; } throw runtime_error("unknown"); } UniValue masternodedebug (const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 0)) throw runtime_error( "masternodedebug\n" "\nPrint masternode status\n" "\nResult:\n" "\"status\" (string) Masternode status message\n" "\nExamples:\n" + HelpExampleCli("masternodedebug", "") + HelpExampleRpc("masternodedebug", "")); if (activeMasternode.status != ACTIVE_MASTERNODE_INITIAL || !masternodeSync.IsSynced()) return activeMasternode.GetStatus(); CTxIn vin = CTxIn(); CPubKey pubkey; CKey key; if (!activeMasternode.GetMasterNodeVin(vin, pubkey, key)) throw runtime_error("Missing masternode input, please look at the documentation for instructions on masternode creation\n"); else return activeMasternode.GetStatus(); } UniValue startmasternode (const UniValue& params, bool fHelp) { std::string strCommand; if (params.size() >= 1) { strCommand = params[0].get_str(); // Backwards compatibility with legacy 'masternode' super-command forwarder if (strCommand == "start") strCommand = "local"; if (strCommand == "start-alias") strCommand = "alias"; if (strCommand == "start-all") strCommand = "all"; if (strCommand == "start-many") strCommand = "many"; if (strCommand == "start-missing") strCommand = "missing"; if (strCommand == "start-disabled") strCommand = "disabled"; } if (fHelp || params.size() < 2 || params.size() > 3 || (params.size() == 2 && (strCommand != "local" && strCommand != "all" && strCommand != "many" && strCommand != "missing" && strCommand != "disabled")) || (params.size() == 3 && strCommand != "alias")) throw runtime_error( "startmasternode \"local|all|many|missing|disabled|alias\" lockwallet ( \"alias\" )\n" "\nAttempts to start one or more masternode(s)\n" "\nArguments:\n" "1. set (string, required) Specify which set of masternode(s) to start.\n" "2. lockwallet (boolean, required) Lock wallet after completion.\n" "3. alias (string) Masternode alias. Required if using 'alias' as the set.\n" "\nResult: (for 'local' set):\n" "\"status\" (string) Masternode status message\n" "\nResult: (for other sets):\n" "{\n" " \"overall\": \"xxxx\", (string) Overall status message\n" " \"detail\": [\n" " {\n" " \"node\": \"xxxx\", (string) Node name or alias\n" " \"result\": \"xxxx\", (string) 'success' or 'failed'\n" " \"error\": \"xxxx\" (string) Error message, if failed\n" " }\n" " ,...\n" " ]\n" "}\n" "\nExamples:\n" + HelpExampleCli("startmasternode", "\"alias\" \"0\" \"my_mn\"") + HelpExampleRpc("startmasternode", "\"alias\" \"0\" \"my_mn\"")); bool fLock = (params[1].get_str() == "true" ? true : false); EnsureWalletIsUnlocked(); if (strCommand == "local") { if (!fMasterNode) throw runtime_error("you must set masternode=1 in the configuration\n"); if (activeMasternode.status != ACTIVE_MASTERNODE_STARTED) { activeMasternode.status = ACTIVE_MASTERNODE_INITIAL; // TODO: consider better way activeMasternode.ManageStatus(); if (fLock) pwalletMain->Lock(); } return activeMasternode.GetStatus(); } if (strCommand == "all" || strCommand == "many" || strCommand == "missing" || strCommand == "disabled") { if ((strCommand == "missing" || strCommand == "disabled") && (masternodeSync.RequestedMasternodeAssets <= MASTERNODE_SYNC_LIST || masternodeSync.RequestedMasternodeAssets == MASTERNODE_SYNC_FAILED)) { throw runtime_error("You can't use this command until masternode list is synced\n"); } std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries; mnEntries = masternodeConfig.getEntries(); int successful = 0; int failed = 0; UniValue resultsObj(UniValue::VARR); BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { std::string errorMessage; int nIndex; if(!mne.castOutputIndex(nIndex)) continue; CTxIn vin = CTxIn(uint256(mne.getTxHash()), uint32_t(nIndex)); CMasternode* pmn = mnodeman.Find(vin); CMasternodeBroadcast mnb; if (pmn != NULL) { if (strCommand == "missing") continue; if (strCommand == "disabled" && pmn->IsEnabled()) continue; } bool result = activeMasternode.CreateBroadcast(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage, mnb); UniValue statusObj(UniValue::VOBJ); statusObj.push_back(Pair("alias", mne.getAlias())); statusObj.push_back(Pair("result", result ? "success" : "failed")); if (result) { successful++; statusObj.push_back(Pair("error", "")); } else { failed++; statusObj.push_back(Pair("error", errorMessage)); } resultsObj.push_back(statusObj); } if (fLock) pwalletMain->Lock(); UniValue returnObj(UniValue::VOBJ); returnObj.push_back(Pair("overall", strprintf("Successfully started %d masternodes, failed to start %d, total %d", successful, failed, successful + failed))); returnObj.push_back(Pair("detail", resultsObj)); return returnObj; } if (strCommand == "alias") { std::string alias = params[2].get_str(); bool found = false; int successful = 0; int failed = 0; UniValue resultsObj(UniValue::VARR); UniValue statusObj(UniValue::VOBJ); statusObj.push_back(Pair("alias", alias)); BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { if (mne.getAlias() == alias) { found = true; std::string errorMessage; CMasternodeBroadcast mnb; bool result = activeMasternode.CreateBroadcast(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage, mnb); statusObj.push_back(Pair("result", result ? "successful" : "failed")); if (result) { successful++; mnodeman.UpdateMasternodeList(mnb); mnb.Relay(); } else { failed++; statusObj.push_back(Pair("errorMessage", errorMessage)); } break; } } if (!found) { failed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("error", "could not find alias in config. Verify with list-conf.")); } resultsObj.push_back(statusObj); if (fLock) pwalletMain->Lock(); UniValue returnObj(UniValue::VOBJ); returnObj.push_back(Pair("overall", strprintf("Successfully started %d masternodes, failed to start %d, total %d", successful, failed, successful + failed))); returnObj.push_back(Pair("detail", resultsObj)); return returnObj; } return NullUniValue; } UniValue createmasternodekey (const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 0)) throw runtime_error( "createmasternodekey\n" "\nCreate a new masternode private key\n" "\nResult:\n" "\"key\" (string) Masternode private key\n" "\nExamples:\n" + HelpExampleCli("createmasternodekey", "") + HelpExampleRpc("createmasternodekey", "")); CKey secret; secret.MakeNewKey(false); return CBitcoinSecret(secret).ToString(); } UniValue getmasternodeoutputs (const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 0)) throw runtime_error( "getmasternodeoutputs\n" "\nPrint all masternode transaction outputs\n" "\nResult:\n" "[\n" " {\n" " \"txhash\": \"xxxx\", (string) output transaction hash\n" " \"outputidx\": n (numeric) output index number\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("getmasternodeoutputs", "") + HelpExampleRpc("getmasternodeoutputs", "")); // Find possible candidates vector<COutput> possibleCoins = activeMasternode.SelectCoinsMasternode(); UniValue ret(UniValue::VARR); BOOST_FOREACH (COutput& out, possibleCoins) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txhash", out.tx->GetHash().ToString())); obj.push_back(Pair("outputidx", out.i)); ret.push_back(obj); } return ret; } UniValue listmasternodeconf (const UniValue& params, bool fHelp) { std::string strFilter = ""; if (params.size() == 1) strFilter = params[0].get_str(); if (fHelp || (params.size() > 1)) throw runtime_error( "listmasternodeconf ( \"filter\" )\n" "\nPrint masternode.conf in JSON format\n" "\nArguments:\n" "1. \"filter\" (string, optional) Filter search text. Partial match on alias, address, txHash, or status.\n" "\nResult:\n" "[\n" " {\n" " \"alias\": \"xxxx\", (string) masternode alias\n" " \"address\": \"xxxx\", (string) masternode IP address\n" " \"privateKey\": \"xxxx\", (string) masternode private key\n" " \"txHash\": \"xxxx\", (string) transaction hash\n" " \"outputIndex\": n, (numeric) transaction output index\n" " \"status\": \"xxxx\" (string) masternode status\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("listmasternodeconf", "") + HelpExampleRpc("listmasternodeconf", "")); std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries; mnEntries = masternodeConfig.getEntries(); UniValue ret(UniValue::VARR); BOOST_FOREACH (CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { int nIndex; if(!mne.castOutputIndex(nIndex)) continue; CTxIn vin = CTxIn(uint256(mne.getTxHash()), uint32_t(nIndex)); CMasternode* pmn = mnodeman.Find(vin); std::string strStatus = pmn ? pmn->Status() : "MISSING"; if (strFilter != "" && mne.getAlias().find(strFilter) == string::npos && mne.getIp().find(strFilter) == string::npos && mne.getTxHash().find(strFilter) == string::npos && strStatus.find(strFilter) == string::npos) continue; UniValue mnObj(UniValue::VOBJ); mnObj.push_back(Pair("alias", mne.getAlias())); mnObj.push_back(Pair("address", mne.getIp())); mnObj.push_back(Pair("privateKey", mne.getPrivKey())); mnObj.push_back(Pair("txHash", mne.getTxHash())); mnObj.push_back(Pair("outputIndex", mne.getOutputIndex())); mnObj.push_back(Pair("status", strStatus)); ret.push_back(mnObj); } return ret; } UniValue getmasternodestatus (const UniValue& params, bool fHelp) { if (fHelp || (params.size() != 0)) throw runtime_error( "getmasternodestatus\n" "\nPrint masternode status\n" "\nResult:\n" "{\n" " \"txhash\": \"xxxx\", (string) Collateral transaction hash\n" " \"outputidx\": n, (numeric) Collateral transaction output index number\n" " \"netaddr\": \"xxxx\", (string) Masternode network address\n" " \"addr\": \"xxxx\", (string) GHRCoin address for masternode payments\n" " \"status\": \"xxxx\", (string) Masternode status\n" " \"message\": \"xxxx\" (string) Masternode status message\n" "}\n" "\nExamples:\n" + HelpExampleCli("getmasternodestatus", "") + HelpExampleRpc("getmasternodestatus", "")); if (!fMasterNode) throw runtime_error("This is not a masternode"); CMasternode* pmn = mnodeman.Find(activeMasternode.vin); if (pmn) { UniValue mnObj(UniValue::VOBJ); mnObj.push_back(Pair("txhash", activeMasternode.vin.prevout.hash.ToString())); mnObj.push_back(Pair("outputidx", (uint64_t)activeMasternode.vin.prevout.n)); mnObj.push_back(Pair("netaddr", activeMasternode.service.ToString())); mnObj.push_back(Pair("addr", CBitcoinAddress(pmn->pubKeyCollateralAddress.GetID()).ToString())); mnObj.push_back(Pair("status", activeMasternode.status)); mnObj.push_back(Pair("message", activeMasternode.GetStatus())); return mnObj; } throw runtime_error("Masternode not found in the list of available masternodes. Current status: " + activeMasternode.GetStatus()); } UniValue getmasternodewinners (const UniValue& params, bool fHelp) { if (fHelp || params.size() > 3) throw runtime_error( "getmasternodewinners ( blocks \"filter\" )\n" "\nPrint the masternode winners for the last n blocks\n" "\nArguments:\n" "1. blocks (numeric, optional) Number of previous blocks to show (default: 10)\n" "2. filter (string, optional) Search filter matching MN address\n" "\nResult (single winner):\n" "[\n" " {\n" " \"nHeight\": n, (numeric) block height\n" " \"winner\": {\n" " \"address\": \"xxxx\", (string) GHRCoin MN Address\n" " \"nVotes\": n, (numeric) Number of votes for winner\n" " }\n" " }\n" " ,...\n" "]\n" "\nResult (multiple winners):\n" "[\n" " {\n" " \"nHeight\": n, (numeric) block height\n" " \"winner\": [\n" " {\n" " \"address\": \"xxxx\", (string) GHRCoin MN Address\n" " \"nVotes\": n, (numeric) Number of votes for winner\n" " }\n" " ,...\n" " ]\n" " }\n" " ,...\n" "]\n" "\nExamples:\n" + HelpExampleCli("getmasternodewinners", "") + HelpExampleRpc("getmasternodewinners", "")); int nHeight; { LOCK(cs_main); CBlockIndex* pindex = chainActive.Tip(); if(!pindex) return 0; nHeight = pindex->nHeight; } int nLast = 10; std::string strFilter = ""; if (params.size() >= 1) nLast = atoi(params[0].get_str()); if (params.size() == 2) strFilter = params[1].get_str(); UniValue ret(UniValue::VARR); for (int i = nHeight - nLast; i < nHeight + 20; i++) { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("nHeight", i)); std::string strPayment = GetRequiredPaymentsString(i); if (strFilter != "" && strPayment.find(strFilter) == std::string::npos) continue; if (strPayment.find(',') != std::string::npos) { UniValue winner(UniValue::VARR); boost::char_separator<char> sep(","); boost::tokenizer< boost::char_separator<char> > tokens(strPayment, sep); BOOST_FOREACH (const string& t, tokens) { UniValue addr(UniValue::VOBJ); std::size_t pos = t.find(":"); std::string strAddress = t.substr(0,pos); uint64_t nVotes = atoi(t.substr(pos+1)); addr.push_back(Pair("address", strAddress)); addr.push_back(Pair("nVotes", nVotes)); winner.push_back(addr); } obj.push_back(Pair("winner", winner)); } else if (strPayment.find("Unknown") == std::string::npos) { UniValue winner(UniValue::VOBJ); std::size_t pos = strPayment.find(":"); std::string strAddress = strPayment.substr(0,pos); uint64_t nVotes = atoi(strPayment.substr(pos+1)); winner.push_back(Pair("address", strAddress)); winner.push_back(Pair("nVotes", nVotes)); obj.push_back(Pair("winner", winner)); } else { UniValue winner(UniValue::VOBJ); winner.push_back(Pair("address", strPayment)); winner.push_back(Pair("nVotes", 0)); obj.push_back(Pair("winner", winner)); } ret.push_back(obj); } return ret; } UniValue getmasternodescores (const UniValue& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getmasternodescores ( blocks )\n" "\nPrint list of winning masternode by score\n" "\nArguments:\n" "1. blocks (numeric, optional) Show the last n blocks (default 10)\n" "\nResult:\n" "{\n" " xxxx: \"xxxx\" (numeric : string) Block height : Masternode hash\n" " ,...\n" "}\n" "\nExamples:\n" + HelpExampleCli("getmasternodescores", "") + HelpExampleRpc("getmasternodescores", "")); int nLast = 10; if (params.size() == 1) { try { nLast = std::stoi(params[0].get_str()); } catch (const boost::bad_lexical_cast &) { throw runtime_error("Exception on param 2"); } } UniValue obj(UniValue::VOBJ); std::vector<CMasternode> vMasternodes = mnodeman.GetFullMasternodeVector(); for (int nHeight = chainActive.Tip()->nHeight - nLast; nHeight < chainActive.Tip()->nHeight + 20; nHeight++) { uint256 nHigh = 0; CMasternode* pBestMasternode = NULL; BOOST_FOREACH (CMasternode& mn, vMasternodes) { uint256 n = mn.CalculateScore(1, nHeight - 100); if (n > nHigh) { nHigh = n; pBestMasternode = &mn; } } if (pBestMasternode) obj.push_back(Pair(strprintf("%d", nHeight), pBestMasternode->vin.prevout.hash.ToString().c_str())); } return obj; } bool DecodeHexMnb(CMasternodeBroadcast& mnb, std::string strHexMnb) { if (!IsHex(strHexMnb)) return false; vector<unsigned char> mnbData(ParseHex(strHexMnb)); CDataStream ssData(mnbData, SER_NETWORK, PROTOCOL_VERSION); try { ssData >> mnb; } catch (const std::exception&) { return false; } return true; } UniValue createmasternodebroadcast(const UniValue& params, bool fHelp) { string strCommand; if (params.size() >= 1) strCommand = params[0].get_str(); if (fHelp || (strCommand != "alias" && strCommand != "all") || (strCommand == "alias" && params.size() < 2)) throw runtime_error( "createmasternodebroadcast \"command\" ( \"alias\")\n" "\nCreates a masternode broadcast message for one or all masternodes configured in masternode.conf\n" + HelpRequiringPassphrase() + "\n" "\nArguments:\n" "1. \"command\" (string, required) \"alias\" for single masternode, \"all\" for all masternodes\n" "2. \"alias\" (string, required if command is \"alias\") Alias of the masternode\n" "\nResult (all):\n" "{\n" " \"overall\": \"xxx\", (string) Overall status message indicating number of successes.\n" " \"detail\": [ (array) JSON array of broadcast objects.\n" " {\n" " \"alias\": \"xxx\", (string) Alias of the masternode.\n" " \"success\": true|false, (boolean) Success status.\n" " \"hex\": \"xxx\" (string, if success=true) Hex encoded broadcast message.\n" " \"error_message\": \"xxx\" (string, if success=false) Error message, if any.\n" " }\n" " ,...\n" " ]\n" "}\n" "\nResult (alias):\n" "{\n" " \"alias\": \"xxx\", (string) Alias of the masternode.\n" " \"success\": true|false, (boolean) Success status.\n" " \"hex\": \"xxx\" (string, if success=true) Hex encoded broadcast message.\n" " \"error_message\": \"xxx\" (string, if success=false) Error message, if any.\n" "}\n" "\nExamples:\n" + HelpExampleCli("createmasternodebroadcast", "alias mymn1") + HelpExampleRpc("createmasternodebroadcast", "alias mymn1")); EnsureWalletIsUnlocked(); if (strCommand == "alias") { // wait for reindex and/or import to finish if (fImporting || fReindex) throw JSONRPCError(RPC_INTERNAL_ERROR, "Wait for reindex and/or import to finish"); std::string alias = params[1].get_str(); bool found = false; UniValue statusObj(UniValue::VOBJ); statusObj.push_back(Pair("alias", alias)); BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { if(mne.getAlias() == alias) { found = true; std::string errorMessage; CMasternodeBroadcast mnb; bool success = activeMasternode.CreateBroadcast(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage, mnb, true); statusObj.push_back(Pair("success", success)); if(success) { CDataStream ssMnb(SER_NETWORK, PROTOCOL_VERSION); ssMnb << mnb; statusObj.push_back(Pair("hex", HexStr(ssMnb.begin(), ssMnb.end()))); } else { statusObj.push_back(Pair("error_message", errorMessage)); } break; } } if(!found) { statusObj.push_back(Pair("success", false)); statusObj.push_back(Pair("error_message", "Could not find alias in config. Verify with list-conf.")); } return statusObj; } if (strCommand == "all") { // wait for reindex and/or import to finish if (fImporting || fReindex) throw JSONRPCError(RPC_INTERNAL_ERROR, "Wait for reindex and/or import to finish"); std::vector<CMasternodeConfig::CMasternodeEntry> mnEntries; mnEntries = masternodeConfig.getEntries(); int successful = 0; int failed = 0; UniValue resultsObj(UniValue::VARR); BOOST_FOREACH(CMasternodeConfig::CMasternodeEntry mne, masternodeConfig.getEntries()) { std::string errorMessage; CTxIn vin = CTxIn(uint256S(mne.getTxHash()), uint32_t(atoi(mne.getOutputIndex().c_str()))); CMasternodeBroadcast mnb; bool success = activeMasternode.CreateBroadcast(mne.getIp(), mne.getPrivKey(), mne.getTxHash(), mne.getOutputIndex(), errorMessage, mnb, true); UniValue statusObj(UniValue::VOBJ); statusObj.push_back(Pair("alias", mne.getAlias())); statusObj.push_back(Pair("success", success)); if(success) { successful++; CDataStream ssMnb(SER_NETWORK, PROTOCOL_VERSION); ssMnb << mnb; statusObj.push_back(Pair("hex", HexStr(ssMnb.begin(), ssMnb.end()))); } else { failed++; statusObj.push_back(Pair("error_message", errorMessage)); } resultsObj.push_back(statusObj); } UniValue returnObj(UniValue::VOBJ); returnObj.push_back(Pair("overall", strprintf("Successfully created broadcast messages for %d masternodes, failed to create %d, total %d", successful, failed, successful + failed))); returnObj.push_back(Pair("detail", resultsObj)); return returnObj; } return NullUniValue; } UniValue decodemasternodebroadcast(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "decodemasternodebroadcast \"hexstring\"\n" "\nCommand to decode masternode broadcast messages\n" "\nArgument:\n" "1. \"hexstring\" (string) The hex encoded masternode broadcast message\n" "\nResult:\n" "{\n" " \"vin\": \"xxxx\" (string) The unspent output which is holding the masternode collateral\n" " \"addr\": \"xxxx\" (string) IP address of the masternode\n" " \"pubkeycollateral\": \"xxxx\" (string) Collateral address's public key\n" " \"pubkeymasternode\": \"xxxx\" (string) Masternode's public key\n" " \"vchsig\": \"xxxx\" (string) Base64-encoded signature of this message (verifiable via pubkeycollateral)\n" " \"sigtime\": \"nnn\" (numeric) Signature timestamp\n" " \"protocolversion\": \"nnn\" (numeric) Masternode's protocol version\n" " \"nlastdsq\": \"nnn\" (numeric) The last time the masternode sent a DSQ message (for mixing) (DEPRECATED)\n" " \"lastping\" : { (object) JSON object with information about the masternode's last ping\n" " \"vin\": \"xxxx\" (string) The unspent output of the masternode which is signing the message\n" " \"blockhash\": \"xxxx\" (string) Current chaintip blockhash minus 12\n" " \"sigtime\": \"nnn\" (numeric) Signature time for this ping\n" " \"vchsig\": \"xxxx\" (string) Base64-encoded signature of this ping (verifiable via pubkeymasternode)\n" "}\n" "\nExamples:\n" + HelpExampleCli("decodemasternodebroadcast", "hexstring") + HelpExampleRpc("decodemasternodebroadcast", "hexstring")); CMasternodeBroadcast mnb; if (!DecodeHexMnb(mnb, params[0].get_str())) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Masternode broadcast message decode failed"); if(!mnb.VerifySignature()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Masternode broadcast signature verification failed"); UniValue resultObj(UniValue::VOBJ); resultObj.push_back(Pair("vin", mnb.vin.prevout.ToString())); resultObj.push_back(Pair("addr", mnb.addr.ToString())); resultObj.push_back(Pair("pubkeycollateral", CBitcoinAddress(mnb.pubKeyCollateralAddress.GetID()).ToString())); resultObj.push_back(Pair("pubkeymasternode", CBitcoinAddress(mnb.pubKeyMasternode.GetID()).ToString())); resultObj.push_back(Pair("vchsig", EncodeBase64(&mnb.sig[0], mnb.sig.size()))); resultObj.push_back(Pair("sigtime", mnb.sigTime)); resultObj.push_back(Pair("protocolversion", mnb.protocolVersion)); resultObj.push_back(Pair("nlastdsq", mnb.nLastDsq)); UniValue lastPingObj(UniValue::VOBJ); lastPingObj.push_back(Pair("vin", mnb.lastPing.vin.prevout.ToString())); lastPingObj.push_back(Pair("blockhash", mnb.lastPing.blockHash.ToString())); lastPingObj.push_back(Pair("sigtime", mnb.lastPing.sigTime)); lastPingObj.push_back(Pair("vchsig", EncodeBase64(&mnb.lastPing.vchSig[0], mnb.lastPing.vchSig.size()))); resultObj.push_back(Pair("lastping", lastPingObj)); return resultObj; } UniValue relaymasternodebroadcast(const UniValue& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "relaymasternodebroadcast \"hexstring\"\n" "\nCommand to relay masternode broadcast messages\n" "\nArguments:\n" "1. \"hexstring\" (string) The hex encoded masternode broadcast message\n" "\nExamples:\n" + HelpExampleCli("relaymasternodebroadcast", "hexstring") + HelpExampleRpc("relaymasternodebroadcast", "hexstring")); CMasternodeBroadcast mnb; if (!DecodeHexMnb(mnb, params[0].get_str())) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Masternode broadcast message decode failed"); if(!mnb.VerifySignature()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Masternode broadcast signature verification failed"); mnodeman.UpdateMasternodeList(mnb); mnb.Relay(); return strprintf("Masternode broadcast sent (service %s, vin %s)", mnb.addr.ToString(), mnb.vin.ToString()); }
; A018240: Number of rational knots (or two-bridge knots) with n crossings (up to mirroring). ; 1,1,2,3,7,12,24,45,91,176,352,693,1387,2752,5504,10965,21931,43776,87552,174933,349867,699392,1398784,2796885,5593771,11186176,22372352,44741973,89483947,178962432,357924864,715838805,1431677611,2863333376,5726666752,11453289813,22906579627,45813071872,91626143744,183252112725,366504225451,733008101376,1466016202752,2932031706453,5864063412907,11728125427712,23456250855424,46912498914645,93824997829291,187649990066176,375299980132352,750599949079893,1501199898159787,3002399773949952,6004799547899904 cal $0,56309 ; Number of reversible strings with n beads using exactly two different colors. mov $1,$0 div $1,3 add $1,1
; ; Memotech MTX stdio ; ; getkey() Wait for keypress ; ; Stefano Bodrato - Aug. 2010 ; ; ; $Id: fgetc_cons.asm,v 1.2 2015/01/19 01:33:20 pauloscustodio Exp $ ; PUBLIC fgetc_cons .fgetc_cons call $79 jr z,fgetc_cons ld h,0 ld l,a ret
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r15 push %r9 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WT_ht+0x14115, %rdx nop nop nop xor %r10, %r10 movb $0x61, (%rdx) xor $25081, %rbx lea addresses_WT_ht+0x2bef, %r12 nop nop nop nop cmp $24409, %rbx movb (%r12), %r9b nop nop nop nop xor %r10, %r10 lea addresses_normal_ht+0x19fef, %r15 clflush (%r15) nop nop nop nop and $30145, %r12 mov (%r15), %edx nop nop nop nop xor $47763, %r10 lea addresses_normal_ht+0x95ef, %rsi lea addresses_D_ht+0x1493f, %rdi nop nop nop nop dec %r9 mov $116, %rcx rep movsb nop nop nop nop cmp $18425, %r12 lea addresses_UC_ht+0xc2ef, %rcx nop add %rsi, %rsi mov $0x6162636465666768, %r10 movq %r10, (%rcx) nop nop nop add $64149, %rdx lea addresses_A_ht+0x24ff, %rsi lea addresses_A_ht+0x1a7ef, %rdi clflush (%rsi) nop nop nop and $4009, %r15 mov $3, %rcx rep movsq nop nop nop nop sub %rsi, %rsi lea addresses_WC_ht+0x6262, %r12 nop and %rsi, %rsi movl $0x61626364, (%r12) add $4496, %rbx lea addresses_A_ht+0x7fef, %rsi lea addresses_D_ht+0x1321f, %rdi nop nop and %r15, %r15 mov $42, %rcx rep movsb nop nop cmp $11445, %r10 lea addresses_WT_ht+0x8bf, %rsi lea addresses_A_ht+0x1890f, %rdi clflush (%rdi) nop nop nop and %r9, %r9 mov $89, %rcx rep movsl nop nop nop nop xor $44380, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r9 pop %r15 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r8 push %r9 push %rbx push %rdi // Store lea addresses_normal+0xcd49, %rdi dec %r14 movl $0x51525354, (%rdi) dec %r12 // Faulty Load lea addresses_D+0x197ef, %r8 nop cmp %rbx, %rbx mov (%r8), %r14 lea oracles, %rdi and $0xff, %r14 shlq $12, %r14 mov (%rdi,%r14,1), %r14 pop %rdi pop %rbx pop %r9 pop %r8 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 4, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_D', 'same': True, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WT_ht', 'same': False, 'size': 1, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 4, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM'} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; A242127: Primes modulo 29. ; 2,3,5,7,11,13,17,19,23,0,2,8,12,14,18,24,1,3,9,13,15,21,25,2,10,14,16,20,22,26,11,15,21,23,4,6,12,18,22,28,5,7,17,19,23,25,8,20,24,26,1,7,9,19,25,2,8,10,16,20,22,3,17,21,23,27,12,18,28,1,5,11,19,25,2,6,12,20,24,3,13,15,25,27,4,8,14,22,26,28,3,15,23,27,6,10,16,28,1,19 seq $0,40 ; The prime numbers. mod $0,29
; A111113: a(2^m) = 1, a(2^m+1) = -1 (m>0), otherwise a(n) = 0. ; 0,0,1,-1,1,-1,0,0,1,-1,0,0,0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 lpb $0 sub $0,1 sub $2,$3 add $3,1 bin $2,$3 mod $2,2 lpe mov $0,$2
; A051411: a(n+1) = a(n) + sum of digits of a(n)^3. ; Submitted by Jamie Morken(s2) ; 7,17,34,53,88,116,151,179,214,242,277,305,340,359,403,440,466,503,538,575,610,638,682,719,772,818,853,890,925,962,1006,1034,1060,1079,1114,1160,1195,1250,1276,1322,1357,1412,1456,1502,1546,1592,1645,1673,1717 mov $1,5 mov $3,$0 add $3,1 lpb $3 mov $0,$1 add $0,2 seq $0,4164 ; Sum of digits of n^3. mov $2,$1 add $1,$0 mul $2,124 sub $3,1 lpe mov $0,$2 div $0,124 add $0,2
; A141996: Primes congruent to 20 mod 29. ; 107,223,281,397,571,919,977,1093,1151,1499,1789,1847,2137,2311,2543,2659,2833,3181,3413,3529,3761,3877,4051,4283,4457,5153,5443,5501,5791,5849,6197,6661,6719,7589,7879,7937,8053,8111,8807,8923,9619,9677,9851,9967,10141,10663,10837,11069,11243,11939,12113,12577,12809,12983,13099,13331,13679,14143,14549,14723,14897,15013,15187,15361,15767,16057,16231,16811,16927,17159,17333,17449,17623,17681,17971,18493,18899,19073,19421,20117,20233,20407,20639,20929,21277,21683,21799,22031,22147,22669,22727,22901,23017,23539,23887,24061,24989,25163,25453,25801 mov $2,$0 add $2,2 pow $2,2 lpb $2 add $1,19 sub $2,1 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,10 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 lpe div $1,2 sub $1,22 mul $1,2 add $1,35 mov $0,$1
/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. **/ #ifndef QUICKSTEP_TYPES_OPERATIONS_COMPARISONS_COMPARISON_ID_HPP_ #define QUICKSTEP_TYPES_OPERATIONS_COMPARISONS_COMPARISON_ID_HPP_ #include <type_traits> #include "glog/logging.h" namespace quickstep { /** \addtogroup Types * @{ */ /** * @brief Concrete Comparisons. **/ enum class ComparisonID { kEqual = 0, kNotEqual, kLess, kLessOrEqual, kGreater, kGreaterOrEqual, kLike, kNotLike, kRegexMatch, kNotRegexMatch, kNumComparisonIDs // Not a real ComparisonID, exists for counting purposes. }; /** * @brief Names of comparisons in the same order as BinaryOperationID. **/ extern const char *kComparisonNames[ static_cast<typename std::underlying_type<ComparisonID>::type>( ComparisonID::kNumComparisonIDs)]; /** * @brief Short names (i.e. mathematical symbols) of comparisons in the same * order as BinaryOperationID. **/ extern const char *kComparisonShortNames[ static_cast<typename std::underlying_type<ComparisonID>::type>( ComparisonID::kNumComparisonIDs)]; /** * @brief Flips a comparison. * * As in greater than flips to less than, less than flips to greater than, and * similarly for greater/less than or equals. Notice that flipping equals * results in equals, same for not equals. * * @param comparison The Id of a comparison to flip. * @return The flipped comparison id. */ inline ComparisonID flipComparisonID(const ComparisonID comparison) { switch (comparison) { case ComparisonID::kLess: return ComparisonID::kGreater; case ComparisonID::kLessOrEqual: return ComparisonID::kGreaterOrEqual; case ComparisonID::kGreater: return ComparisonID::kLess; case ComparisonID::kGreaterOrEqual: return ComparisonID::kLessOrEqual; case ComparisonID::kLike: case ComparisonID::kNotLike: case ComparisonID::kRegexMatch: case ComparisonID::kNotRegexMatch: LOG(FATAL) << "Cannot flip pattern matching comparison."; default: return comparison; } } /** @} */ } // namespace quickstep #endif // QUICKSTEP_TYPES_OPERATIONS_COMPARISONS_COMPARISON_ID_HPP_
; A044682: Numbers n such that string 5,5 occurs in the base 9 representation of n but not of n+1. ; 50,131,212,293,374,458,536,617,698,779,860,941,1022,1103,1187,1265,1346,1427,1508,1589,1670,1751,1832,1916,1994,2075,2156,2237,2318,2399,2480,2561,2645,2723,2804,2885,2966,3047,3128 mov $4,$0 mul $0,8 add $0,5 mov $7,8 lpb $0 trn $0,$7 mov $3,$0 sub $0,1 lpe add $5,9 sub $5,$3 div $7,10 pow $6,$7 mul $6,$5 gcd $6,4 mov $1,$6 add $1,49 mov $2,$4 mul $2,81 add $1,$2
; A099816: Bisection of A000796 (decimal expansion of Pi). ; 3,4,5,2,5,5,9,9,2,8,6,6,3,8,2,9,0,8,4,9,1,9,9,3,5,0,8,0,7,9,4,9,3,7,1,4,6,8,2,8,9,6,8,3,8,5,4,1,7,6,9,2,4,0,6,1,2,2,0,6,7,9,8,4,0,5,0,8,2,1,2,3,9,0,1,8,8,1,7,5,2,4,0,7,1,3,5,1,0,5,9,4,6,2,4,9,4,3,3,1 mul $0,2 seq $0,796 ; Decimal expansion of Pi (or digits of Pi).
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r15 push %r8 push %rcx push %rdi push %rdx push %rsi // REPMOV lea addresses_UC+0x4748, %rsi lea addresses_D+0x15948, %rdi nop sub $5372, %rdx mov $109, %rcx rep movsb and $51554, %r8 // Store mov $0x320, %rsi nop nop nop sub $9797, %r10 mov $0x5152535455565758, %rdi movq %rdi, (%rsi) nop xor %rdi, %rdi // Store lea addresses_PSE+0x1fdc8, %rdi nop nop nop nop nop add $34338, %r15 movw $0x5152, (%rdi) nop nop nop nop add %rdx, %rdx // Faulty Load lea addresses_PSE+0x5048, %r8 nop nop nop and %rdx, %rdx mov (%r8), %di lea oracles, %rsi and $0xff, %rdi shlq $12, %rdi mov (%rsi,%rdi,1), %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r15 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': True, 'type': 'addresses_PSE', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_P', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_PSE', 'size': 2, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_PSE', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'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 */
; $Id: bit_synth_mwr.asm,v 1.2 2015/01/19 01:32:44 pauloscustodio Exp $ ; ; void bit_synth(int duration, int frequency1, int frequency2, int frequency3, int frequency4); ; ; 1 bit sound library - version for "memory write" I/O architectures ; ; synthetizer - this is a sort of "quad sound" routine. ; It is based on 4 separate counters and a delay. ; Depending on the parameters being passed it is able to play ; on two audible voices, to generate sound effects and to play ; with a single voice having odd waveforms. ; ; The parameters are passed with a self modifying code trick :o( ; This routine shouldn't stay in contended memory locations !! ; PUBLIC bit_synth INCLUDE "games/games.inc" EXTERN bit_open_di EXTERN bit_close_ei .bit_synth ld ix,2 add ix,sp ld a,(ix+8) ld (LEN+1),a ld a,(ix+6) and a jr z,FR1_blank ld (FR_1+1),a ld a,sndbit_mask .FR1_blank ld (FR1_tick+1),a ld a,(ix+4) and a jr z,FR2_blank ld (FR_2+1),a ld a,sndbit_mask .FR2_blank ld (FR2_tick+1),a ld a,(ix+2) and a jr z,FR3_blank ld (FR_3+1),a ld a,sndbit_mask .FR3_blank ld (FR1_tick+1),a ld a,(ix+0) and a jr z,FR4_blank ld (FR_4+1),a ld a,sndbit_mask .FR4_blank ld (FR1_tick+1),a call bit_open_di ld h,1 ld l,h ld d,h ld e,h .LEN ld b,50 .loop ld c,4 .loop2 dec h jr nz,jump .FR1_tick xor sndbit_mask ld (sndbit_port),a .FR_1 ld h,80 .jump dec l jr nz,jump2 .FR2_tick xor sndbit_mask ld (sndbit_port),a .FR_2 ld l,81 .jump2 dec d jr nz,jump3 .FR3_tick xor sndbit_mask ld (sndbit_port),a .FR_3 ld d,162 .jump3 dec e jr nz,loop2 .FR4_tick xor sndbit_mask ld (sndbit_port),a .FR_4 ld e,163 dec c jr nz,loop2 djnz loop call bit_close_ei ret
; A332476: The number of unitary divisors of n in Gaussian integers. ; Submitted by Christian Krause ; 1,2,2,2,4,4,2,2,2,8,2,4,4,4,8,2,4,4,2,8,4,4,2,4,4,8,2,4,4,16,2,2,4,8,8,4,4,4,8,8,4,8,2,4,8,4,2,4,2,8,8,8,4,4,8,4,4,8,2,16,4,4,4,2,16,8,2,8,4,16,2,4,4,8,8,4,4,16,2,8,2,8,2,8,16,4,8,4,4,16,8,4,4,4,8,4,4,4,4,8 add $0,1 mov $1,1 lpb $0 mov $3,$0 lpb $3 mov $4,$0 mov $6,$2 cmp $6,0 add $2,$6 mod $4,$2 cmp $4,0 cmp $4,0 mov $5,$2 add $2,1 cmp $5,1 max $4,$5 sub $3,$4 lpe lpb $0 dif $0,$2 lpe bin $2,2 gcd $2,2 gcd $5,$2 mul $1,$5 div $2,$5 add $2,1 mul $1,$2 lpe mov $0,$1
frame 1, 10 frame 2, 10 frame 3, 25 frame 2, 10 endanim
#include "Model.h" #include"include_globals.h" #include "light.h" extern const unsigned int WIDTH; extern const unsigned int HEIGHT; extern float ZNEAR,ZFAR,XLEFT,XRIGHT,YUP,YDOWN; extern Light* LLight; extern Camera* camera; #define VERT_INDICES_MODE false void Model::draw() { //drawWireframe_model(ftriangles); draw_model(ftriangles, Shade); } //void Model::oldLoad(std::string filename) //{ // std::ifstream file; // file.open(filename); // if (file.fail()) // { // std::cout << "File cannot be opened \n"; // exit(-1); // } // // Local cache of verts // std::vector<vect4> verts; // // while (!file.eof()) // { // char line[128]; // file.getline(line, 128); // // std::stringstream s; // s << line; // // char junk; // // if (line[0] == 'v') // { // vect4 v; // s >> junk >> v.x >> v.y >> v.z; // verts.push_back(v); // } // // if (line[0] == 'f') // { // int f[3]; // s >> junk >> f[0] >> f[1] >> f[2]; // triangles.push_back(Triangle{ verts[f[0] - 1], verts[f[1] - 1], verts[f[2] - 1] }); // } // } // ftriangles = triangles; //} void Model::Load(std::string filename) { std::ifstream in; in.open(filename, std::ifstream::in); if (in.fail()) { std::cout << "Cannot Read" << std::endl; exit(-1); } std::string line; std::vector<vect4> verts; std::vector<vect4> normals; std::vector<vec2i> textures; float minX, maxX, minY, maxY, minZ, maxZ; minX = maxX = minY = maxY = minZ = maxZ = 0; int count = 1; int n_iter = 0; while (!in.eof()) { //if (count > 10000) break; n_iter++; //get one line at a time std::getline(in, line); //string object std::istringstream iss(line.c_str()); char trash; if (!line.compare(0, 2, "v ")) //starts with v<space> { // std::cout << count; iss >> trash; // first character is v vect4 v; // followed by xyz co-ords iss >> v.x; v.x += 3; if (v.x < minX)minX = v.x; if (v.x > maxX)maxX = v.x; iss >> v.y; v.y -= 8; if (v.y < minY)minY = v.y; if (v.y > maxY)maxY = v.y; iss >> v.z; v.z -= 3; if (v.z < minZ)minZ = v.z; if (v.z > maxZ)maxZ = v.z; v.w = 1; // maths::printvec(v); verts.push_back(v); vertices_list.push_back(v); vert_norm_indices.push_back(7);//dummy pushed count++; } //else if (!line.compare(0, 3, "vt ")) //starts with vt<space> //{ // iss >> trash >> trash; //Ignore vt // vec2i uv; // iss >> uv.x; // iss >> uv.y; // textures.push_back(uv); //} else if (!line.compare(0, 3, "vn ")) //starts with vn<space> { iss >> trash >> trash; vect4 n; iss >> n.x; iss >> n.y; iss >> n.z; n.w = 0; normals.push_back(n); normals_list.push_back(n); } else if (!line.compare(0, 2, "f ")) //starts with f<space> { std::vector<vect4> f; vect4 temp; iss >> trash; //first charecter is f while (iss >> temp.x >> trash >> temp.y >> trash >> temp.z) // in the form vert/vertTex/norm (vert is read, the rest are treated as trash) { //in wavefront obj all indices start at 1, not zero temp.x--; //vert temp.y--; //texture temp.z--; // normal f.push_back(temp); } Triangle tri; tri.setVertex(verts[f[0].x], verts[f[1].x], verts[f[2].x]); tri.setVertIndices(f[0].x, f[1].x, f[2].x); // std::cout << f[0][0] <<'\n'; //tri.setTexCoords(textures[f[0].y], textures[f[1].y], textures[f[2].y]); tri.setNormals(normals_list[f[0].z], normals_list[f[1].z], normals_list[f[2].z]); for (int i = 0; i < 3; i++) vert_norm_indices[f[i].x] = f[i].z; triangles.push_back(tri); } } for (size_t i = 0; i < triangles.size() - 1; i++) { triangles[i].zbuffer = (triangles[i].vertices[0].z + triangles[i].vertices[1].z + triangles[i].vertices[2].z); } ftriangles = triangles; std::cout << "\n" << minX << " --> " << maxX; std::cout << "\n" << minY << " --> " << maxY; std::cout << "\n" << minZ << " --> " << maxZ; } //void Model::modelToScreen() //{ // for (int i = 0; i < triangles.size(); i++) // { // for (int j = 0; j < 3; j++) // { // triangles[i].vertices[j] = triangles[i].vertices[j].Convert_to_Screen(); // } // } //} void Model::translate_model(vect4 pt) { if (VERT_INDICES_MODE) for (auto& vert : vertices_list) { transate_polygon(vert, pt); } else for (int i = 0; i < triangles.size(); i++) { for (int j = 0; j < 3; j++) { transate_polygon(triangles[i].vertices[j], pt); } } } void Model::scale_model(float pt, char dim ) { if (dim == 'X') { if(VERT_INDICES_MODE) for (auto& vert : vertices_list) { scale_polygon(vert, pt, 'X'); } else for (int i = 0; i < triangles.size(); i++) for (int j = 0; j < 3; j++) scale_polygon(triangles[i].vertices[j], pt, 'X'); } if (dim == 'Y') { if(VERT_INDICES_MODE) for (auto& vert : vertices_list) { scale_polygon(vert, pt, 'Y'); } else for (int i = 0; i < triangles.size(); i++) for (int j = 0; j < 3; j++) scale_polygon(triangles[i].vertices[j], pt, 'Y'); } if (dim == 'Z') { if(VERT_INDICES_MODE) for (auto& vert : vertices_list) { scale_polygon(vert, pt, 'Z'); } else for (int i = 0; i < triangles.size(); i++) for (int j = 0; j < 3; j++) scale_polygon(triangles[i].vertices[j], pt, 'Z'); } else { if(VERT_INDICES_MODE) for (auto& vert : vertices_list) { scale_polygon(vert, pt); } else for (int i = 0; i < triangles.size(); i++) for (int j = 0; j < 3; j++) scale_polygon(triangles[i].vertices[j], pt); } } void Model::rotate_model(char XYZ, float angle) { if (XYZ == 'X') { if (VERT_INDICES_MODE) { for (auto& vert : vertices_list) { rotateX(vert, angle); } for (auto& norm : normals_list) { rotateX(norm, angle); } } else for (int i = 0; i < triangles.size(); i++) for (int j = 0; j < 3; j++) { rotateX(triangles[i].vertices[j], angle); rotateX(triangles[i].normals[j], angle); } } else if (XYZ == 'Y') { if (VERT_INDICES_MODE) { for (auto& vert : vertices_list) { rotateY(vert, angle); } for (auto& norm : normals_list) { rotateY(norm, angle); } } else for (int i = 0; i < triangles.size(); i++) for (int j = 0; j < 3; j++) { rotateY(triangles[i].vertices[j], angle); rotateY(triangles[i].normals[j], angle); } } else if (XYZ == 'Z') { if (VERT_INDICES_MODE) { for (auto& vert : vertices_list) { rotateZ(vert, angle); } for (auto& norm : normals_list) { rotateZ(norm, angle); } } else for (int i = 0; i < triangles.size(); i++) for (int j = 0; j < 3; j++) { rotateZ(triangles[i].vertices[j], angle); rotateZ(triangles[i].normals[j], angle); } } } //void Model::rotate_modelY2(float angle, float yref) //{ // //deprecated but not updated because probably not in use // for (int i = 0; i < triangles.size(); i++) // for (int j = 0; j < 3; j++) // rotateY2(triangles[i].vertices[j], angle, yref); //} bool Model::is_in_depthBox(vect4 vertices[3]) { bool flag1, flag2, flag3; flag1 = flag2 = flag3 = false; if (vertices[0].z < ZNEAR && vertices[0].z > ZFAR) flag1= true; if (vertices[1].z < ZNEAR && vertices[1].z > ZFAR) flag2 = true; if (vertices[2].z < ZNEAR && vertices[2].z > ZFAR) flag3 = true; if ( flag1&&flag2&&flag3//flag1 && flag2 || flag2 && flag3 || flag1 && flag3 ) return true; return false; } bool Model::is_in_depthBox(int vertices[3]) { if (fvertices_list[vertices[0]].z < ZNEAR && fvertices_list[vertices[0]].z > ZFAR) if (fvertices_list[vertices[1]].z < ZNEAR && fvertices_list[vertices[1]].z > ZFAR) if (fvertices_list[vertices[2]].z < ZNEAR && fvertices_list[vertices[2]].z > ZFAR) return true; return false; } bool Model::is_in_viewPlane(vect4 vertices[3]) { bool flag = false; //bool flag2 = true; for(int i=0;i<3;i++) if (vertices[i].x > XLEFT && vertices[i].x < XRIGHT) { flag = true; } if (!flag) return false; flag = false; for (int i = 0; i < 3; i++) if (vertices[i].y > YDOWN && vertices[i].y < YUP) { flag = true; } if (!flag) return false; return true; } bool Model::is_in_viewPlane(int vertices[3]) { bool flag = false; //bool flag2 = true; for (int i = 0; i < 3; i++) if (fvertices_list[vertices[i]].x > XLEFT && fvertices_list[vertices[i]].x < XRIGHT) { flag = true; } if (!flag) return false; flag = false; for (int i = 0; i < 3; i++) if (fvertices_list[vertices[i]].y > YDOWN && fvertices_list[vertices[i]].y < YUP) { flag = true; } if (!flag) return false; return true; } void Model::transformModel(mat4f& viewMat, mat4f& projection) { ftriangles.clear(); fvertices_list.clear(); int cullCount = 0; int clipped = 0; int faceCount = 0; int vec_index_count = 0; if(VERT_INDICES_MODE) for (auto& vert : vertices_list) { vect4 tmp_vert = mul(viewMat, vert); tmp_vert = mulProj(projection, tmp_vert);// mulProj doesnt change z coord fvertices_list.push_back(tmp_vert); intensities_list.push_back( calcIntensity(Ka, Kdm, Ksm, nsm,vert, LLight->getPosition(), view, normals_list[vert_norm_indices[vec_index_count++]], Ia, LLight->getIntensities() ) ); } for (auto& tri : triangles) { Triangle temptri = tri; // view transformation if (!VERT_INDICES_MODE) { temptri.vertices[0] = mul(viewMat, temptri.vertices[0]); temptri.vertices[1] = mul(viewMat, temptri.vertices[1]); temptri.vertices[2] = mul(viewMat, temptri.vertices[2]); } //std::cout<< temptri.vertices[0] <<std::endl; //std::cout << temptri.vertices[1] << std::endl; //std::cout << temptri.vertices[2] << std::endl; //Projection Transformation bool depth_check_flag; if (VERT_INDICES_MODE) { depth_check_flag = is_in_depthBox(temptri.vert_indices); } else { depth_check_flag = is_in_depthBox(temptri.vertices); } if (depth_check_flag) { if (!VERT_INDICES_MODE) { temptri.vertices[0] = mulProj(projection, temptri.vertices[0]); temptri.vertices[1] = mulProj(projection, temptri.vertices[1]); temptri.vertices[2] = mulProj(projection, temptri.vertices[2]); } //backface culling should be used at projected coords... bool culled = backFaceDetection(temptri); //bool culled = Culling(temptri); if (culled) { cullCount++; //continue; } if (VERT_INDICES_MODE) { depth_check_flag = is_in_viewPlane(temptri.vert_indices); } else { depth_check_flag = is_in_viewPlane(temptri.vertices); } if (depth_check_flag) { if(VERT_INDICES_MODE) temptri.setVertex( fvertices_list[temptri.vert_indices[0]], fvertices_list[temptri.vert_indices[1]], fvertices_list[temptri.vert_indices[2]] ); temptri.color = colorm;// vec3{ 200, 205, 200 }.normalize(); if (Shade) { //using world coordinates to calculate lighting if (VERT_INDICES_MODE) { temptri.setIntensity(0, intensities_list[temptri.vert_indices[0]]); temptri.setIntensity(1, intensities_list[temptri.vert_indices[1]]); temptri.setIntensity(2, intensities_list[temptri.vert_indices[2]]); } else { vect4 Iplus; if (ambient) { Iplus = Ia + Iam; } else Iplus = Ia; temptri.setIntensity(0, calcIntensity(Ka, Kdm, Ksm, nsm, tri.vertices[0], LLight->getPosition(), view, tri.normals[0], Iplus, LLight->getIntensities())); temptri.setIntensity(1, calcIntensity(Ka, Kdm, Ksm, nsm, tri.vertices[1], LLight->getPosition(), view, tri.normals[1], Iplus, LLight->getIntensities())); temptri.setIntensity(2, calcIntensity(Ka, Kdm, Ksm, nsm, tri.vertices[2], LLight->getPosition(), view, tri.normals[2], Iplus, LLight->getIntensities())); } } else { flatShading(temptri); } /*std::cout << "£" << temptri.vertices[0] << std::endl; std::cout << temptri.vertices[1] << std::endl; std::cout << temptri.vertices[2] << std::endl;*/ for (int i = 0; i < 3; i++) transate_polygon(temptri.vertices[i], { 800 / 2,800 / 2,0,0 }); ftriangles.push_back(temptri); faceCount++; } else { clipped++; //std::cout << "\nclipped!"; } } else { clipped++; //std::cout << "\n not in view box... " << temptri.vertices[0] << temptri.vertices[1] << temptri.vertices[2]; } } //std::cout << "\n" << clipped << " Clipped , " << cullCount << "Culled\n"<<faceCount<<" ( "<< 100*faceCount/float(clipped+cullCount+faceCount)<<"% ) faces"; /*sort(ftriangles.begin(), ftriangles.end(), [](Triangle& t1, Triangle& t2) { float z1 = (t1.vertices[0].z + t1.vertices[1].z + t1.vertices[2].z) / 3.0f; float z2 = (t2.vertices[0].z + t2.vertices[1].z + t2.vertices[2].z) / 3.0f; return z1 > z2; });*/ //for (auto& tri : ftriangles) //{ // tri.color = vec3{ 0, 255, 200 }.normalize(); // if (Shade) // ;// Shading(tri); // else // flatShading(tri); //} } bool Model::backFaceDetection(Triangle& tri) { vect4 v1 = tri.vertices[0]; vect4 v2 = tri.vertices[1]; vect4 v3 = tri.vertices[2]; vect4 n1 = tri.normals[0]; vect4 n2 = tri.normals[1]; vect4 n3 = tri.normals[2]; vect4 view1 = (camera->Position - v1).normalize(); vect4 view2 = (camera->Position - v2).normalize(); vect4 view3 = (camera->Position - v3).normalize(); //std::cout<< view1.x <<std::endl; //std::cout << view1.y << std::endl; //std::cout << view1.z << std::endl; //std::cout << view2.x << std::endl; //std::cout << view2.y << std::endl; //std::cout << view2.z << std::endl; //std::cout << view3.x << std::endl; //std::cout << view3.y << std::endl; //std::cout << view3.z << std::endl; float dotProduct1 = dotProduct(n1, view1); float dotProduct2 = dotProduct(n2, view2); float dotProduct3 = dotProduct(n3, view3); /*if (dotProduct1 < 0 || dotProduct2 < 0 || dotProduct3 < 0) { return false; } return true;*/ if (n1.z < 0 || n2.z < 0 || n3.z < 0) { return false; } return true; } bool Model::Culling(Triangle& tri) { vect4 line1 = tri.vertices[1] - tri.vertices[0]; vect4 line2 = tri.vertices[2] - tri.vertices[0]; vect4 normal = line1.crossProduct(line2); normal = normal.normalize(); float val = dotProduct(normal, (tri.vertices[0] - camera->Position)); if (val < 0) return true; return false; } //bool Model::backfaceDetectionNormalize(Triangle& tri) //{ // vect4 v1 = tri.vertices[0], v2 = tri.vertices[1], v3 = tri.vertices[2]; // vect4 centroid; // centroid.x = (v1.x + v2.x + v3.x) / 3; // centroid.y = (v1.y + v2.y + v3.y) / 3; // centroid.z = (v1.z + v2.z + v3.z) / 3; // // vect4 V = (camera->Position - centroid).normalize(); // // vect4 V = (vect4{0,0,100} - centroid).normalize(); // // v2 = v2 - v1; // v3 = v3 - v1; // // vect4 normal = v2.crossProduct(v3); // normal = normal.normalize(); // // std::cout<<normal; // // float value = dotProduct(normal, V); // // if (value < 0) // { // ftriangles.push_back(tri); // return false; // } // // return true; //} float Model::calIntensity(vect4 point, vect4 Normal, vect4 View) { float i = 0.0; vect4 position = { 500, 600, -200 }; vect4 Ldir = (light - point).normalize();// (position - point).normalize(); // std::cout << point.x << "\t" << point.y << "\t" << point.z << "\n"; float ambientInt = 0.3; float pointInt = 0.5; float ambientConstant = 0.7; float diffuseConstant = 0.7; float specularConstant = 0.8; float ambientLight = ambientConstant * ambientInt; float diffuseLight = std::max(0.0f, diffuseConstant * pointInt * dotProduct(Normal, Ldir)); // Point R = maths::sub(maths::mul(Normal, (2 * maths::dot(Normal, Ldir))), Ldir); vect4 R = ((Normal * (2 * dotProduct(Normal, Ldir))) - Ldir).normalize(); float specularExp = 32; float specularLight = specularConstant * pointInt * pow(dotProduct(R, View), specularExp); float tmp = ambientLight + specularLight + diffuseLight; tmp = tmp > 1 ? 1 : tmp; return tmp; } void Model::flatShading(Triangle& tri) { vect4 v1 = tri.vertices[0]; vect4 v2 = tri.vertices[1]; vect4 v3 = tri.vertices[2]; vect4 centroid; centroid.x = (v1.x + v2.x + v3.x) / 3; centroid.y = (v1.y + v2.y + v3.y) / 3; centroid.z = (v1.z + v2.z + v3.z) / 3; // std::cout << centroid[0] <<"\t"; vect4 view = (camera->Position - centroid).normalize(); // Point view = (Point{0,0,1000} - centroid).normalize(); // generating the normal vector of a triangle vect4 ver1 = centroid - v2; vect4 ver2 = centroid - v3; vect4 normal = (ver1.crossProduct(ver2)).normalize(); float intensity = calIntensity(centroid, normal, view); // std::cout << "The intensity: " << intensity << "\n"; vec3 newColor = tri.color * intensity; tri.color = newColor; } //void Model::Shading(Triangle& tri) //{ // std::vector<float>intensity(3); // int count = 0; // for (auto& vertex : tri.vertices) // { // vect4 view = (vect4{ 0, 0, 10 } - vertex).normalize(); // intensity[count] = calIntensity(vertex, tri.normals[count], view); // count++; // } // tri.setIntensity(intensity); //} //void Model::updateTransform(mat4f& view, mat4f& projection) //{ // mat4f rotation = mul(Matrix_MakeRotationX(camera->thetaX), mul(Matrix_MakeRotationY(camera->thetaY), Matrix_MakeRotationZ(camera->thetaZ))); // mat4f translate = Translation(0.0f, 0.0f, 5.0f); // mat4f matWorld = mul(translate, rotation); // // // ftriangles.clear(); // // ftriangles = triangles; // int cullCount = 0; // // for (auto& tri : triangles) // { // // Triangle temptri = tri; // // Triangle triProjected, triTransformed, triViewed; // // // World Matrix Transform // triTransformed.vertices[0] = mul(matWorld, tri.vertices[0]); // triTransformed.vertices[1] = mul(matWorld, tri.vertices[1]); // triTransformed.vertices[2] = mul(matWorld, tri.vertices[2]); // triTransformed.normals[0] = mul(rotation, tri.normals[0]); // triTransformed.normals[1] = mul(rotation, tri.normals[1]); // triTransformed.normals[2] = mul(rotation, tri.normals[2]); // // //Convert World Space --> View Space // triViewed.vertices[0] = mul(view, triTransformed.vertices[0]); // triViewed.vertices[1] = mul(view, triTransformed.vertices[1]); // triViewed.vertices[2] = mul(view, triTransformed.vertices[2]); // // triProjected.vertices[0] = mul(projection, triViewed.vertices[0]); // triProjected.vertices[1] = mul(projection, triViewed.vertices[1]); // triProjected.vertices[2] = mul(projection, triViewed.vertices[2]); // // // bool culled = backfaceDetectionNormalize(tri); // // bool culled = backFaceCulling(temptri); // // if(!culled) // // continue; // // // // view transformation // // temptri.vertices[0] = mul(view, temptri.vertices[0]); // // temptri.vertices[1] = mul(view, temptri.vertices[1]); // // temptri.vertices[2] = mul(view, temptri.vertices[2]); // // // //Projection Transformation // // temptri.vertices[0] = mul(projection, temptri.vertices[0]); // // temptri.vertices[1] = mul(projection, temptri.vertices[1]); // // temptri.vertices[2] = mul(projection, temptri.vertices[2]); // // ftriangles.push_back(triProjected); // } // // //------------------- painters algorithm --------------------------- // // painterSort(ftriangles, 0, ftriangles.size()); // // sort(ftriangles.begin(), ftriangles.end(), [](Triangle& t1, Triangle& t2) // { // float z1 = (t1.vertices[0].z + t1.vertices[1].z + t1.vertices[2].z) / 3.0f; // float z2 = (t2.vertices[0].z + t2.vertices[1].z + t2.vertices[2].z) / 3.0f; // return z1 > z2; // }); // // for (auto& tri : ftriangles) // { // // Point color = Point{220, 220, 220}.normalize(); // // tri.color = vec3{ 179, 60, 0 }.normalize(); // if (Shade) // Shading(tri); // else // phongIlluminationModel(tri); // } //}
// Copyright 2005, Google Inc. // 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 Google Inc. 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. // // This file implements death tests. #include "gtest/gtest-death-test.h" #include <utility> #include "gtest/internal/gtest-port.h" #include "gtest/internal/custom/gtest.h" #if GTEST_HAS_DEATH_TEST # if GTEST_OS_MAC # include <crt_externs.h> # endif // GTEST_OS_MAC # include <errno.h> # include <fcntl.h> # include <limits.h> # if GTEST_OS_LINUX # include <signal.h> # endif // GTEST_OS_LINUX # include <stdarg.h> # if GTEST_OS_WINDOWS # include <windows.h> # else # include <sys/mman.h> # include <sys/wait.h> # endif // GTEST_OS_WINDOWS # if GTEST_OS_QNX # include <spawn.h> # endif // GTEST_OS_QNX # if GTEST_OS_FUCHSIA # include <lib/fdio/fd.h> # include <lib/fdio/io.h> # include <lib/fdio/spawn.h> # include <lib/zx/port.h> # include <lib/zx/process.h> # include <lib/zx/socket.h> # include <zircon/processargs.h> # include <zircon/syscalls.h> # include <zircon/syscalls/policy.h> # include <zircon/syscalls/port.h> # endif // GTEST_OS_FUCHSIA #endif // GTEST_HAS_DEATH_TEST #include "gtest/gtest-message.h" #include "gtest/internal/gtest-string.h" #include "src/gtest-internal-inl.h" namespace testing { // Constants. // The default death test style. // // This is defined in internal/gtest-port.h as "fast", but can be overridden by // a definition in internal/custom/gtest-port.h. The recommended value, which is // used internally at Google, is "threadsafe". static const char kDefaultDeathTestStyle[] = GTEST_DEFAULT_DEATH_TEST_STYLE; GTEST_DEFINE_string_( death_test_style, internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle), "Indicates how to run a death test in a forked child process: " "\"threadsafe\" (child process re-executes the test binary " "from the beginning, running only the specific death test) or " "\"fast\" (child process runs the death test immediately " "after forking)."); GTEST_DEFINE_bool_( death_test_use_fork, internal::BoolFromGTestEnv("death_test_use_fork", false), "Instructs to use fork()/_exit() instead of clone() in death tests. " "Ignored and always uses fork() on POSIX systems where clone() is not " "implemented. Useful when running under valgrind or similar tools if " "those do not support clone(). Valgrind 3.3.1 will just fail if " "it sees an unsupported combination of clone() flags. " "It is not recommended to use this flag w/o valgrind though it will " "work in 99% of the cases. Once valgrind is fixed, this flag will " "most likely be removed."); namespace internal { GTEST_DEFINE_string_( internal_run_death_test, "", "Indicates the file, line number, temporal index of " "the single death test to run, and a file descriptor to " "which a success code may be sent, all separated by " "the '|' characters. This flag is specified if and only if the current " "process is a sub-process launched for running a thread-safe " "death test. FOR INTERNAL USE ONLY."); } // namespace internal #if GTEST_HAS_DEATH_TEST namespace internal { // Valid only for fast death tests. Indicates the code is running in the // child process of a fast style death test. # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA static bool g_in_fast_death_test_child = false; # endif // Returns a Boolean value indicating whether the caller is currently // executing in the context of the death test child process. Tools such as // Valgrind heap checkers may need this to modify their behavior in death // tests. IMPORTANT: This is an internal utility. Using it may break the // implementation of death tests. User code MUST NOT use it. bool InDeathTestChild() { # if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA // On Windows and Fuchsia, death tests are thread-safe regardless of the value // of the death_test_style flag. return !GTEST_FLAG(internal_run_death_test).empty(); # else if (GTEST_FLAG(death_test_style) == "threadsafe") return !GTEST_FLAG(internal_run_death_test).empty(); else return g_in_fast_death_test_child; #endif } } // namespace internal // ExitedWithCode constructor. ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) { } // ExitedWithCode function-call operator. bool ExitedWithCode::operator()(int exit_status) const { # if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA return exit_status == exit_code_; # else return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_; # endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA } # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // KilledBySignal constructor. KilledBySignal::KilledBySignal(int signum) : signum_(signum) { } // KilledBySignal function-call operator. bool KilledBySignal::operator()(int exit_status) const { # if defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_) { bool result; if (GTEST_KILLED_BY_SIGNAL_OVERRIDE_(signum_, exit_status, &result)) { return result; } } # endif // defined(GTEST_KILLED_BY_SIGNAL_OVERRIDE_) return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_; } # endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA namespace internal { // Utilities needed for death tests. // Generates a textual description of a given exit code, in the format // specified by wait(2). static std::string ExitSummary(int exit_code) { Message m; # if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA m << "Exited with exit status " << exit_code; # else if (WIFEXITED(exit_code)) { m << "Exited with exit status " << WEXITSTATUS(exit_code); } else if (WIFSIGNALED(exit_code)) { m << "Terminated by signal " << WTERMSIG(exit_code); } # ifdef WCOREDUMP if (WCOREDUMP(exit_code)) { m << " (core dumped)"; } # endif # endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA return m.GetString(); } // Returns true if exit_status describes a process that was terminated // by a signal, or exited normally with a nonzero exit code. bool ExitedUnsuccessfully(int exit_status) { return !ExitedWithCode(0)(exit_status); } # if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // Generates a textual failure message when a death test finds more than // one thread running, or cannot determine the number of threads, prior // to executing the given statement. It is the responsibility of the // caller not to pass a thread_count of 1. static std::string DeathTestThreadWarning(size_t thread_count) { Message msg; msg << "Death tests use fork(), which is unsafe particularly" << " in a threaded context. For this test, " << GTEST_NAME_ << " "; if (thread_count == 0) { msg << "couldn't detect the number of threads."; } else { msg << "detected " << thread_count << " threads."; } msg << " See " "https://github.com/google/googletest/blob/master/googletest/docs/" "advanced.md#death-tests-and-threads" << " for more explanation and suggested solutions, especially if" << " this is the last message you see before your test times out."; return msg.GetString(); } # endif // !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA // Flag characters for reporting a death test that did not die. static const char kDeathTestLived = 'L'; static const char kDeathTestReturned = 'R'; static const char kDeathTestThrew = 'T'; static const char kDeathTestInternalError = 'I'; #if GTEST_OS_FUCHSIA // File descriptor used for the pipe in the child process. static const int kFuchsiaReadPipeFd = 3; #endif // An enumeration describing all of the possible ways that a death test can // conclude. DIED means that the process died while executing the test // code; LIVED means that process lived beyond the end of the test code; // RETURNED means that the test statement attempted to execute a return // statement, which is not allowed; THREW means that the test statement // returned control by throwing an exception. IN_PROGRESS means the test // has not yet concluded. enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; // Routine for aborting the program which is safe to call from an // exec-style death test child process, in which case the error // message is propagated back to the parent process. Otherwise, the // message is simply printed to stderr. In either case, the program // then exits with status 1. static void DeathTestAbort(const std::string& message) { // On a POSIX system, this function may be called from a threadsafe-style // death test child process, which operates on a very small stack. Use // the heap for any additional non-minuscule memory requirements. const InternalRunDeathTestFlag* const flag = GetUnitTestImpl()->internal_run_death_test_flag(); if (flag != nullptr) { FILE* parent = posix::FDOpen(flag->write_fd(), "w"); fputc(kDeathTestInternalError, parent); fprintf(parent, "%s", message.c_str()); fflush(parent); _exit(1); } else { fprintf(stderr, "%s", message.c_str()); fflush(stderr); posix::Abort(); } } // A replacement for CHECK that calls DeathTestAbort if the assertion // fails. # define GTEST_DEATH_TEST_CHECK_(expression) \ do { \ if (!::testing::internal::IsTrue(expression)) { \ DeathTestAbort( \ ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ + ::testing::internal::StreamableToString(__LINE__) + ": " \ + #expression); \ } \ } while (::testing::internal::AlwaysFalse()) // This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for // evaluating any system call that fulfills two conditions: it must return // -1 on failure, and set errno to EINTR when it is interrupted and // should be tried again. The macro expands to a loop that repeatedly // evaluates the expression as long as it evaluates to -1 and sets // errno to EINTR. If the expression evaluates to -1 but errno is // something other than EINTR, DeathTestAbort is called. # define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \ do { \ int gtest_retval; \ do { \ gtest_retval = (expression); \ } while (gtest_retval == -1 && errno == EINTR); \ if (gtest_retval == -1) { \ DeathTestAbort( \ ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ + ::testing::internal::StreamableToString(__LINE__) + ": " \ + #expression + " != -1"); \ } \ } while (::testing::internal::AlwaysFalse()) // Returns the message describing the last system error in errno. std::string GetLastErrnoDescription() { return errno == 0 ? "" : posix::StrError(errno); } // This is called from a death test parent process to read a failure // message from the death test child process and log it with the FATAL // severity. On Windows, the message is read from a pipe handle. On other // platforms, it is read from a file descriptor. static void FailFromInternalError(int fd) { Message error; char buffer[256]; int num_read; do { while ((num_read = posix::Read(fd, buffer, 255)) > 0) { buffer[num_read] = '\0'; error << buffer; } } while (num_read == -1 && errno == EINTR); if (num_read == 0) { GTEST_LOG_(FATAL) << error.GetString(); } else { const int last_error = errno; GTEST_LOG_(FATAL) << "Error while reading death test internal: " << GetLastErrnoDescription() << " [" << last_error << "]"; } } // Death test constructor. Increments the running death test count // for the current test. DeathTest::DeathTest() { TestInfo* const info = GetUnitTestImpl()->current_test_info(); if (info == nullptr) { DeathTestAbort("Cannot run a death test outside of a TEST or " "TEST_F construct"); } } // Creates and returns a death test by dispatching to the current // death test factory. bool DeathTest::Create(const char* statement, Matcher<const std::string&> matcher, const char* file, int line, DeathTest** test) { return GetUnitTestImpl()->death_test_factory()->Create( statement, std::move(matcher), file, line, test); } const char* DeathTest::LastMessage() { return last_death_test_message_.c_str(); } void DeathTest::set_last_death_test_message(const std::string& message) { last_death_test_message_ = message; } std::string DeathTest::last_death_test_message_; // Provides cross platform implementation for some death functionality. class DeathTestImpl : public DeathTest { protected: DeathTestImpl(const char* a_statement, Matcher<const std::string&> matcher) : statement_(a_statement), matcher_(std::move(matcher)), spawned_(false), status_(-1), outcome_(IN_PROGRESS), read_fd_(-1), write_fd_(-1) {} // read_fd_ is expected to be closed and cleared by a derived class. ~DeathTestImpl() override { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); } void Abort(AbortReason reason) override; bool Passed(bool status_ok) override; const char* statement() const { return statement_; } bool spawned() const { return spawned_; } void set_spawned(bool is_spawned) { spawned_ = is_spawned; } int status() const { return status_; } void set_status(int a_status) { status_ = a_status; } DeathTestOutcome outcome() const { return outcome_; } void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; } int read_fd() const { return read_fd_; } void set_read_fd(int fd) { read_fd_ = fd; } int write_fd() const { return write_fd_; } void set_write_fd(int fd) { write_fd_ = fd; } // Called in the parent process only. Reads the result code of the death // test child process via a pipe, interprets it to set the outcome_ // member, and closes read_fd_. Outputs diagnostics and terminates in // case of unexpected codes. void ReadAndInterpretStatusByte(); // Returns stderr output from the child process. virtual std::string GetErrorLogs(); private: // The textual content of the code this object is testing. This class // doesn't own this string and should not attempt to delete it. const char* const statement_; // A matcher that's expected to match the stderr output by the child process. Matcher<const std::string&> matcher_; // True if the death test child process has been successfully spawned. bool spawned_; // The exit status of the child process. int status_; // How the death test concluded. DeathTestOutcome outcome_; // Descriptor to the read end of the pipe to the child process. It is // always -1 in the child process. The child keeps its write end of the // pipe in write_fd_. int read_fd_; // Descriptor to the child's write end of the pipe to the parent process. // It is always -1 in the parent process. The parent keeps its end of the // pipe in read_fd_. int write_fd_; }; // Called in the parent process only. Reads the result code of the death // test child process via a pipe, interprets it to set the outcome_ // member, and closes read_fd_. Outputs diagnostics and terminates in // case of unexpected codes. void DeathTestImpl::ReadAndInterpretStatusByte() { char flag; int bytes_read; // The read() here blocks until data is available (signifying the // failure of the death test) or until the pipe is closed (signifying // its success), so it's okay to call this in the parent before // the child process has exited. do { bytes_read = posix::Read(read_fd(), &flag, 1); } while (bytes_read == -1 && errno == EINTR); if (bytes_read == 0) { set_outcome(DIED); } else if (bytes_read == 1) { switch (flag) { case kDeathTestReturned: set_outcome(RETURNED); break; case kDeathTestThrew: set_outcome(THREW); break; case kDeathTestLived: set_outcome(LIVED); break; case kDeathTestInternalError: FailFromInternalError(read_fd()); // Does not return. break; default: GTEST_LOG_(FATAL) << "Death test child process reported " << "unexpected status byte (" << static_cast<unsigned int>(flag) << ")"; } } else { GTEST_LOG_(FATAL) << "Read from death test child process failed: " << GetLastErrnoDescription(); } GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd())); set_read_fd(-1); } std::string DeathTestImpl::GetErrorLogs() { return GetCapturedStderr(); } // Signals that the death test code which should have exited, didn't. // Should be called only in a death test child process. // Writes a status byte to the child's status file descriptor, then // calls _exit(1). void DeathTestImpl::Abort(AbortReason reason) { // The parent process considers the death test to be a failure if // it finds any data in our pipe. So, here we write a single flag byte // to the pipe, then exit. const char status_ch = reason == TEST_DID_NOT_DIE ? kDeathTestLived : reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned; GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1)); // We are leaking the descriptor here because on some platforms (i.e., // when built as Windows DLL), destructors of global objects will still // run after calling _exit(). On such systems, write_fd_ will be // indirectly closed from the destructor of UnitTestImpl, causing double // close if it is also closed here. On debug configurations, double close // may assert. As there are no in-process buffers to flush here, we are // relying on the OS to close the descriptor after the process terminates // when the destructors are not run. _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash) } // Returns an indented copy of stderr output for a death test. // This makes distinguishing death test output lines from regular log lines // much easier. static ::std::string FormatDeathTestOutput(const ::std::string& output) { ::std::string ret; for (size_t at = 0; ; ) { const size_t line_end = output.find('\n', at); ret += "[ DEATH ] "; if (line_end == ::std::string::npos) { ret += output.substr(at); break; } ret += output.substr(at, line_end + 1 - at); at = line_end + 1; } return ret; } // Assesses the success or failure of a death test, using both private // members which have previously been set, and one argument: // // Private data members: // outcome: An enumeration describing how the death test // concluded: DIED, LIVED, THREW, or RETURNED. The death test // fails in the latter three cases. // status: The exit status of the child process. On *nix, it is in the // in the format specified by wait(2). On Windows, this is the // value supplied to the ExitProcess() API or a numeric code // of the exception that terminated the program. // matcher_: A matcher that's expected to match the stderr output by the child // process. // // Argument: // status_ok: true if exit_status is acceptable in the context of // this particular death test, which fails if it is false // // Returns true iff all of the above conditions are met. Otherwise, the // first failing condition, in the order given above, is the one that is // reported. Also sets the last death test message string. bool DeathTestImpl::Passed(bool status_ok) { if (!spawned()) return false; const std::string error_message = GetErrorLogs(); bool success = false; Message buffer; buffer << "Death test: " << statement() << "\n"; switch (outcome()) { case LIVED: buffer << " Result: failed to die.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case THREW: buffer << " Result: threw an exception.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case RETURNED: buffer << " Result: illegal return in test statement.\n" << " Error msg:\n" << FormatDeathTestOutput(error_message); break; case DIED: if (status_ok) { if (matcher_.Matches(error_message)) { success = true; } else { std::ostringstream stream; matcher_.DescribeTo(&stream); buffer << " Result: died but not with expected error.\n" << " Expected: " << stream.str() << "\n" << "Actual msg:\n" << FormatDeathTestOutput(error_message); } } else { buffer << " Result: died but not with expected exit code:\n" << " " << ExitSummary(status()) << "\n" << "Actual msg:\n" << FormatDeathTestOutput(error_message); } break; case IN_PROGRESS: default: GTEST_LOG_(FATAL) << "DeathTest::Passed somehow called before conclusion of test"; } DeathTest::set_last_death_test_message(buffer.GetString()); return success; } # if GTEST_OS_WINDOWS // WindowsDeathTest implements death tests on Windows. Due to the // specifics of starting new processes on Windows, death tests there are // always threadsafe, and Google Test considers the // --gtest_death_test_style=fast setting to be equivalent to // --gtest_death_test_style=threadsafe there. // // A few implementation notes: Like the Linux version, the Windows // implementation uses pipes for child-to-parent communication. But due to // the specifics of pipes on Windows, some extra steps are required: // // 1. The parent creates a communication pipe and stores handles to both // ends of it. // 2. The parent starts the child and provides it with the information // necessary to acquire the handle to the write end of the pipe. // 3. The child acquires the write end of the pipe and signals the parent // using a Windows event. // 4. Now the parent can release the write end of the pipe on its side. If // this is done before step 3, the object's reference count goes down to // 0 and it is destroyed, preventing the child from acquiring it. The // parent now has to release it, or read operations on the read end of // the pipe will not return when the child terminates. // 5. The parent reads child's output through the pipe (outcome code and // any possible error messages) from the pipe, and its stderr and then // determines whether to fail the test. // // Note: to distinguish Win32 API calls from the local method and function // calls, the former are explicitly resolved in the global namespace. // class WindowsDeathTest : public DeathTestImpl { public: WindowsDeathTest(const char* a_statement, Matcher<const std::string&> matcher, const char* file, int line) : DeathTestImpl(a_statement, std::move(matcher)), file_(file), line_(line) {} // All of these virtual functions are inherited from DeathTest. virtual int Wait(); virtual TestRole AssumeRole(); private: // The name of the file in which the death test is located. const char* const file_; // The line number on which the death test is located. const int line_; // Handle to the write end of the pipe to the child process. AutoHandle write_handle_; // Child process handle. AutoHandle child_handle_; // Event the child process uses to signal the parent that it has // acquired the handle to the write end of the pipe. After seeing this // event the parent can release its own handles to make sure its // ReadFile() calls return when the child terminates. AutoHandle event_handle_; }; // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. int WindowsDeathTest::Wait() { if (!spawned()) return 0; // Wait until the child either signals that it has acquired the write end // of the pipe or it dies. const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() }; switch (::WaitForMultipleObjects(2, wait_handles, FALSE, // Waits for any of the handles. INFINITE)) { case WAIT_OBJECT_0: case WAIT_OBJECT_0 + 1: break; default: GTEST_DEATH_TEST_CHECK_(false); // Should not get here. } // The child has acquired the write end of the pipe or exited. // We release the handle on our side and continue. write_handle_.Reset(); event_handle_.Reset(); ReadAndInterpretStatusByte(); // Waits for the child process to exit if it haven't already. This // returns immediately if the child has already exited, regardless of // whether previous calls to WaitForMultipleObjects synchronized on this // handle or not. GTEST_DEATH_TEST_CHECK_( WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(), INFINITE)); DWORD status_code; GTEST_DEATH_TEST_CHECK_( ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE); child_handle_.Reset(); set_status(static_cast<int>(status_code)); return status(); } // The AssumeRole process for a Windows death test. It creates a child // process with the same executable as the current process to run the // death test. The child process is given the --gtest_filter and // --gtest_internal_run_death_test flags such that it knows to run the // current death test only. DeathTest::TestRole WindowsDeathTest::AssumeRole() { const UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const TestInfo* const info = impl->current_test_info(); const int death_test_index = info->result()->death_test_count(); if (flag != nullptr) { // ParseInternalRunDeathTestFlag() has performed all the necessary // processing. set_write_fd(flag->write_fd()); return EXECUTE_TEST; } // WindowsDeathTest uses an anonymous pipe to communicate results of // a death test. SECURITY_ATTRIBUTES handles_are_inheritable = {sizeof(SECURITY_ATTRIBUTES), nullptr, TRUE}; HANDLE read_handle, write_handle; GTEST_DEATH_TEST_CHECK_( ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable, 0) // Default buffer size. != FALSE); set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle), O_RDONLY)); write_handle_.Reset(write_handle); event_handle_.Reset(::CreateEvent( &handles_are_inheritable, TRUE, // The event will automatically reset to non-signaled state. FALSE, // The initial state is non-signalled. nullptr)); // The even is unnamed. GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != nullptr); const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + info->test_suite_name() + "." + info->name(); const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index) + "|" + StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) + // size_t has the same width as pointers on both 32-bit and 64-bit // Windows platforms. // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx. "|" + StreamableToString(reinterpret_cast<size_t>(write_handle)) + "|" + StreamableToString(reinterpret_cast<size_t>(event_handle_.Get())); char executable_path[_MAX_PATH + 1]; // NOLINT GTEST_DEATH_TEST_CHECK_(_MAX_PATH + 1 != ::GetModuleFileNameA(nullptr, executable_path, _MAX_PATH)); std::string command_line = std::string(::GetCommandLineA()) + " " + filter_flag + " \"" + internal_flag + "\""; DeathTest::set_last_death_test_message(""); CaptureStderr(); // Flush the log buffers since the log streams are shared with the child. FlushInfoLog(); // The child process will share the standard handles with the parent. STARTUPINFOA startup_info; memset(&startup_info, 0, sizeof(STARTUPINFO)); startup_info.dwFlags = STARTF_USESTDHANDLES; startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE); startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE); startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE); PROCESS_INFORMATION process_info; GTEST_DEATH_TEST_CHECK_( ::CreateProcessA( executable_path, const_cast<char*>(command_line.c_str()), nullptr, // Retuned process handle is not inheritable. nullptr, // Retuned thread handle is not inheritable. TRUE, // Child inherits all inheritable handles (for write_handle_). 0x0, // Default creation flags. nullptr, // Inherit the parent's environment. UnitTest::GetInstance()->original_working_dir(), &startup_info, &process_info) != FALSE); child_handle_.Reset(process_info.hProcess); ::CloseHandle(process_info.hThread); set_spawned(true); return OVERSEE_TEST; } # elif GTEST_OS_FUCHSIA class FuchsiaDeathTest : public DeathTestImpl { public: FuchsiaDeathTest(const char* a_statement, Matcher<const std::string&> matcher, const char* file, int line) : DeathTestImpl(a_statement, std::move(matcher)), file_(file), line_(line) {} // All of these virtual functions are inherited from DeathTest. int Wait() override; TestRole AssumeRole() override; std::string GetErrorLogs() override; private: // The name of the file in which the death test is located. const char* const file_; // The line number on which the death test is located. const int line_; // The stderr data captured by the child process. std::string captured_stderr_; zx::process child_process_; zx::port port_; zx::socket stderr_socket_; }; // Utility class for accumulating command-line arguments. class Arguments { public: Arguments() { args_.push_back(nullptr); } ~Arguments() { for (std::vector<char*>::iterator i = args_.begin(); i != args_.end(); ++i) { free(*i); } } void AddArgument(const char* argument) { args_.insert(args_.end() - 1, posix::StrDup(argument)); } template <typename Str> void AddArguments(const ::std::vector<Str>& arguments) { for (typename ::std::vector<Str>::const_iterator i = arguments.begin(); i != arguments.end(); ++i) { args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); } } char* const* Argv() { return &args_[0]; } int size() { return args_.size() - 1; } private: std::vector<char*> args_; }; // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. int FuchsiaDeathTest::Wait() { const int kProcessKey = 0; const int kSocketKey = 1; if (!spawned()) return 0; // Register to wait for the child process to terminate. zx_status_t status_zx; status_zx = child_process_.wait_async( port_, kProcessKey, ZX_PROCESS_TERMINATED, ZX_WAIT_ASYNC_ONCE); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); // Register to wait for the socket to be readable or closed. status_zx = stderr_socket_.wait_async( port_, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED, ZX_WAIT_ASYNC_ONCE); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); bool process_terminated = false; bool socket_closed = false; do { zx_port_packet_t packet = {}; status_zx = port_.wait(zx::time::infinite(), &packet); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); if (packet.key == kProcessKey) { if (ZX_PKT_IS_EXCEPTION(packet.type)) { // Process encountered an exception. Kill it directly rather than // letting other handlers process the event. We will get a second // kProcessKey event when the process actually terminates. status_zx = child_process_.kill(); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); } else { // Process terminated. GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type)); GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_PROCESS_TERMINATED); process_terminated = true; } } else if (packet.key == kSocketKey) { GTEST_DEATH_TEST_CHECK_(ZX_PKT_IS_SIGNAL_ONE(packet.type)); if (packet.signal.observed & ZX_SOCKET_READABLE) { // Read data from the socket. constexpr size_t kBufferSize = 1024; do { size_t old_length = captured_stderr_.length(); size_t bytes_read = 0; captured_stderr_.resize(old_length + kBufferSize); status_zx = stderr_socket_.read( 0, &captured_stderr_.front() + old_length, kBufferSize, &bytes_read); captured_stderr_.resize(old_length + bytes_read); } while (status_zx == ZX_OK); if (status_zx == ZX_ERR_PEER_CLOSED) { socket_closed = true; } else { GTEST_DEATH_TEST_CHECK_(status_zx == ZX_ERR_SHOULD_WAIT); status_zx = stderr_socket_.wait_async( port_, kSocketKey, ZX_SOCKET_READABLE | ZX_SOCKET_PEER_CLOSED, ZX_WAIT_ASYNC_ONCE); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); } } else { GTEST_DEATH_TEST_CHECK_(packet.signal.observed & ZX_SOCKET_PEER_CLOSED); socket_closed = true; } } } while (!process_terminated && !socket_closed); ReadAndInterpretStatusByte(); zx_info_process_t buffer; status_zx = child_process_.get_info( ZX_INFO_PROCESS, &buffer, sizeof(buffer), nullptr, nullptr); GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK); GTEST_DEATH_TEST_CHECK_(buffer.exited); set_status(buffer.return_code); return status(); } // The AssumeRole process for a Fuchsia death test. It creates a child // process with the same executable as the current process to run the // death test. The child process is given the --gtest_filter and // --gtest_internal_run_death_test flags such that it knows to run the // current death test only. DeathTest::TestRole FuchsiaDeathTest::AssumeRole() { const UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const TestInfo* const info = impl->current_test_info(); const int death_test_index = info->result()->death_test_count(); if (flag != nullptr) { // ParseInternalRunDeathTestFlag() has performed all the necessary // processing. set_write_fd(kFuchsiaReadPipeFd); return EXECUTE_TEST; } // Flush the log buffers since the log streams are shared with the child. FlushInfoLog(); // Build the child process command line. const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + info->test_suite_name() + "." + info->name(); const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index); Arguments args; args.AddArguments(GetInjectableArgvs()); args.AddArgument(filter_flag.c_str()); args.AddArgument(internal_flag.c_str()); // Build the pipe for communication with the child. zx_status_t status; zx_handle_t child_pipe_handle; int child_pipe_fd; status = fdio_pipe_half2(&child_pipe_fd, &child_pipe_handle); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); set_read_fd(child_pipe_fd); // Set the pipe handle for the child. fdio_spawn_action_t spawn_actions[2] = {}; fdio_spawn_action_t* add_handle_action = &spawn_actions[0]; add_handle_action->action = FDIO_SPAWN_ACTION_ADD_HANDLE; add_handle_action->h.id = PA_HND(PA_FD, kFuchsiaReadPipeFd); add_handle_action->h.handle = child_pipe_handle; // Create a socket pair will be used to receive the child process' stderr. zx::socket stderr_producer_socket; status = zx::socket::create(0, &stderr_producer_socket, &stderr_socket_); GTEST_DEATH_TEST_CHECK_(status >= 0); int stderr_producer_fd = -1; status = fdio_fd_create(stderr_producer_socket.release(), &stderr_producer_fd); GTEST_DEATH_TEST_CHECK_(status >= 0); // Make the stderr socket nonblocking. GTEST_DEATH_TEST_CHECK_(fcntl(stderr_producer_fd, F_SETFL, 0) == 0); fdio_spawn_action_t* add_stderr_action = &spawn_actions[1]; add_stderr_action->action = FDIO_SPAWN_ACTION_CLONE_FD; add_stderr_action->fd.local_fd = stderr_producer_fd; add_stderr_action->fd.target_fd = STDERR_FILENO; // Create a child job. zx_handle_t child_job = ZX_HANDLE_INVALID; status = zx_job_create(zx_job_default(), 0, & child_job); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); zx_policy_basic_t policy; policy.condition = ZX_POL_NEW_ANY; policy.policy = ZX_POL_ACTION_ALLOW; status = zx_job_set_policy( child_job, ZX_JOB_POL_RELATIVE, ZX_JOB_POL_BASIC, &policy, 1); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); // Create an exception port and attach it to the |child_job|, to allow // us to suppress the system default exception handler from firing. status = zx::port::create(0, &port_); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); status = zx_task_bind_exception_port( child_job, port_.get(), 0 /* key */, 0 /*options */); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); // Spawn the child process. status = fdio_spawn_etc( child_job, FDIO_SPAWN_CLONE_ALL, args.Argv()[0], args.Argv(), nullptr, 2, spawn_actions, child_process_.reset_and_get_address(), nullptr); GTEST_DEATH_TEST_CHECK_(status == ZX_OK); set_spawned(true); return OVERSEE_TEST; } std::string FuchsiaDeathTest::GetErrorLogs() { return captured_stderr_; } #else // We are neither on Windows, nor on Fuchsia. // ForkingDeathTest provides implementations for most of the abstract // methods of the DeathTest interface. Only the AssumeRole method is // left undefined. class ForkingDeathTest : public DeathTestImpl { public: ForkingDeathTest(const char* statement, Matcher<const std::string&> matcher); // All of these virtual functions are inherited from DeathTest. int Wait() override; protected: void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; } private: // PID of child process during death test; 0 in the child process itself. pid_t child_pid_; }; // Constructs a ForkingDeathTest. ForkingDeathTest::ForkingDeathTest(const char* a_statement, Matcher<const std::string&> matcher) : DeathTestImpl(a_statement, std::move(matcher)), child_pid_(-1) {} // Waits for the child in a death test to exit, returning its exit // status, or 0 if no child process exists. As a side effect, sets the // outcome data member. int ForkingDeathTest::Wait() { if (!spawned()) return 0; ReadAndInterpretStatusByte(); int status_value; GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0)); set_status(status_value); return status_value; } // A concrete death test class that forks, then immediately runs the test // in the child process. class NoExecDeathTest : public ForkingDeathTest { public: NoExecDeathTest(const char* a_statement, Matcher<const std::string&> matcher) : ForkingDeathTest(a_statement, std::move(matcher)) {} TestRole AssumeRole() override; }; // The AssumeRole process for a fork-and-run death test. It implements a // straightforward fork, with a simple pipe to transmit the status byte. DeathTest::TestRole NoExecDeathTest::AssumeRole() { const size_t thread_count = GetThreadCount(); if (thread_count != 1) { GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count); } int pipe_fd[2]; GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); DeathTest::set_last_death_test_message(""); CaptureStderr(); // When we fork the process below, the log file buffers are copied, but the // file descriptors are shared. We flush all log files here so that closing // the file descriptors in the child process doesn't throw off the // synchronization between descriptors and buffers in the parent process. // This is as close to the fork as possible to avoid a race condition in case // there are multiple threads running before the death test, and another // thread writes to the log file. FlushInfoLog(); const pid_t child_pid = fork(); GTEST_DEATH_TEST_CHECK_(child_pid != -1); set_child_pid(child_pid); if (child_pid == 0) { GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0])); set_write_fd(pipe_fd[1]); // Redirects all logging to stderr in the child process to prevent // concurrent writes to the log files. We capture stderr in the parent // process and append the child process' output to a log. LogToStderr(); // Event forwarding to the listeners of event listener API mush be shut // down in death test subprocesses. GetUnitTestImpl()->listeners()->SuppressEventForwarding(); g_in_fast_death_test_child = true; return EXECUTE_TEST; } else { GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); set_read_fd(pipe_fd[0]); set_spawned(true); return OVERSEE_TEST; } } // A concrete death test class that forks and re-executes the main // program from the beginning, with command-line flags set that cause // only this specific death test to be run. class ExecDeathTest : public ForkingDeathTest { public: ExecDeathTest(const char* a_statement, Matcher<const std::string&> matcher, const char* file, int line) : ForkingDeathTest(a_statement, std::move(matcher)), file_(file), line_(line) {} TestRole AssumeRole() override; private: static ::std::vector<std::string> GetArgvsForDeathTestChildProcess() { ::std::vector<std::string> args = GetInjectableArgvs(); # if defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) ::std::vector<std::string> extra_args = GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_(); args.insert(args.end(), extra_args.begin(), extra_args.end()); # endif // defined(GTEST_EXTRA_DEATH_TEST_COMMAND_LINE_ARGS_) return args; } // The name of the file in which the death test is located. const char* const file_; // The line number on which the death test is located. const int line_; }; // Utility class for accumulating command-line arguments. class Arguments { public: Arguments() { args_.push_back(nullptr); } ~Arguments() { for (std::vector<char*>::iterator i = args_.begin(); i != args_.end(); ++i) { free(*i); } } void AddArgument(const char* argument) { args_.insert(args_.end() - 1, posix::StrDup(argument)); } template <typename Str> void AddArguments(const ::std::vector<Str>& arguments) { for (typename ::std::vector<Str>::const_iterator i = arguments.begin(); i != arguments.end(); ++i) { args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); } } char* const* Argv() { return &args_[0]; } private: std::vector<char*> args_; }; // A struct that encompasses the arguments to the child process of a // threadsafe-style death test process. struct ExecDeathTestArgs { char* const* argv; // Command-line arguments for the child's call to exec int close_fd; // File descriptor to close; the read end of a pipe }; # if GTEST_OS_MAC inline char** GetEnviron() { // When Google Test is built as a framework on MacOS X, the environ variable // is unavailable. Apple's documentation (man environ) recommends using // _NSGetEnviron() instead. return *_NSGetEnviron(); } # else // Some POSIX platforms expect you to declare environ. extern "C" makes // it reside in the global namespace. extern "C" char** environ; inline char** GetEnviron() { return environ; } # endif // GTEST_OS_MAC # if !GTEST_OS_QNX // The main function for a threadsafe-style death test child process. // This function is called in a clone()-ed process and thus must avoid // any potentially unsafe operations like malloc or libc functions. static int ExecDeathTestChildMain(void* child_arg) { ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd)); // We need to execute the test program in the same environment where // it was originally invoked. Therefore we change to the original // working directory first. const char* const original_dir = UnitTest::GetInstance()->original_working_dir(); // We can safely call chdir() as it's a direct system call. if (chdir(original_dir) != 0) { DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } // We can safely call execve() as it's a direct system call. We // cannot use execvp() as it's a libc function and thus potentially // unsafe. Since execve() doesn't search the PATH, the user must // invoke the test program via a valid path that contains at least // one path separator. execve(args->argv[0], args->argv, GetEnviron()); DeathTestAbort(std::string("execve(") + args->argv[0] + ", ...) in " + original_dir + " failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } # endif // !GTEST_OS_QNX # if GTEST_HAS_CLONE // Two utility routines that together determine the direction the stack // grows. // This could be accomplished more elegantly by a single recursive // function, but we want to guard against the unlikely possibility of // a smart compiler optimizing the recursion away. // // GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining // StackLowerThanAddress into StackGrowsDown, which then doesn't give // correct answer. static void StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_; // HWAddressSanitizer add a random tag to the MSB of the local variable address, // making comparison result unpredictable. GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ static void StackLowerThanAddress(const void* ptr, bool* result) { int dummy; *result = (&dummy < ptr); } // Make sure AddressSanitizer does not tamper with the stack here. GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ static bool StackGrowsDown() { int dummy; bool result; StackLowerThanAddress(&dummy, &result); return result; } # endif // GTEST_HAS_CLONE // Spawns a child process with the same executable as the current process in // a thread-safe manner and instructs it to run the death test. The // implementation uses fork(2) + exec. On systems where clone(2) is // available, it is used instead, being slightly more thread-safe. On QNX, // fork supports only single-threaded environments, so this function uses // spawn(2) there instead. The function dies with an error message if // anything goes wrong. static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { ExecDeathTestArgs args = { argv, close_fd }; pid_t child_pid = -1; # if GTEST_OS_QNX // Obtains the current directory and sets it to be closed in the child // process. const int cwd_fd = open(".", O_RDONLY); GTEST_DEATH_TEST_CHECK_(cwd_fd != -1); GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC)); // We need to execute the test program in the same environment where // it was originally invoked. Therefore we change to the original // working directory first. const char* const original_dir = UnitTest::GetInstance()->original_working_dir(); // We can safely call chdir() as it's a direct system call. if (chdir(original_dir) != 0) { DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + GetLastErrnoDescription()); return EXIT_FAILURE; } int fd_flags; // Set close_fd to be closed after spawn. GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD)); GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD, fd_flags | FD_CLOEXEC)); struct inheritance inherit = {0}; // spawn is a system call. child_pid = spawn(args.argv[0], 0, nullptr, &inherit, args.argv, GetEnviron()); // Restores the current working directory. GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd)); # else // GTEST_OS_QNX # if GTEST_OS_LINUX // When a SIGPROF signal is received while fork() or clone() are executing, // the process may hang. To avoid this, we ignore SIGPROF here and re-enable // it after the call to fork()/clone() is complete. struct sigaction saved_sigprof_action; struct sigaction ignore_sigprof_action; memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action)); sigemptyset(&ignore_sigprof_action.sa_mask); ignore_sigprof_action.sa_handler = SIG_IGN; GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction( SIGPROF, &ignore_sigprof_action, &saved_sigprof_action)); # endif // GTEST_OS_LINUX # if GTEST_HAS_CLONE const bool use_fork = GTEST_FLAG(death_test_use_fork); if (!use_fork) { static const bool stack_grows_down = StackGrowsDown(); const size_t stack_size = getpagesize(); // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead. void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED); // Maximum stack alignment in bytes: For a downward-growing stack, this // amount is subtracted from size of the stack space to get an address // that is within the stack space and is aligned on all systems we care // about. As far as I know there is no ABI with stack alignment greater // than 64. We assume stack and stack_size already have alignment of // kMaxStackAlignment. const size_t kMaxStackAlignment = 64; void* const stack_top = static_cast<char*>(stack) + (stack_grows_down ? stack_size - kMaxStackAlignment : 0); GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment && reinterpret_cast<intptr_t>(stack_top) % kMaxStackAlignment == 0); child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args); GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1); } # else const bool use_fork = true; # endif // GTEST_HAS_CLONE if (use_fork && (child_pid = fork()) == 0) { ExecDeathTestChildMain(&args); _exit(0); } # endif // GTEST_OS_QNX # if GTEST_OS_LINUX GTEST_DEATH_TEST_CHECK_SYSCALL_( sigaction(SIGPROF, &saved_sigprof_action, nullptr)); # endif // GTEST_OS_LINUX GTEST_DEATH_TEST_CHECK_(child_pid != -1); return child_pid; } // The AssumeRole process for a fork-and-exec death test. It re-executes the // main program from the beginning, setting the --gtest_filter // and --gtest_internal_run_death_test flags to cause only the current // death test to be re-run. DeathTest::TestRole ExecDeathTest::AssumeRole() { const UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const TestInfo* const info = impl->current_test_info(); const int death_test_index = info->result()->death_test_count(); if (flag != nullptr) { set_write_fd(flag->write_fd()); return EXECUTE_TEST; } int pipe_fd[2]; GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); // Clear the close-on-exec flag on the write end of the pipe, lest // it be closed when the child process does an exec: GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1); const std::string filter_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + info->test_suite_name() + "." + info->name(); const std::string internal_flag = std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + file_ + "|" + StreamableToString(line_) + "|" + StreamableToString(death_test_index) + "|" + StreamableToString(pipe_fd[1]); Arguments args; args.AddArguments(GetArgvsForDeathTestChildProcess()); args.AddArgument(filter_flag.c_str()); args.AddArgument(internal_flag.c_str()); DeathTest::set_last_death_test_message(""); CaptureStderr(); // See the comment in NoExecDeathTest::AssumeRole for why the next line // is necessary. FlushInfoLog(); const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]); GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); set_child_pid(child_pid); set_read_fd(pipe_fd[0]); set_spawned(true); return OVERSEE_TEST; } # endif // !GTEST_OS_WINDOWS // Creates a concrete DeathTest-derived class that depends on the // --gtest_death_test_style flag, and sets the pointer pointed to // by the "test" argument to its address. If the test should be // skipped, sets that pointer to NULL. Returns true, unless the // flag is set to an invalid value. bool DefaultDeathTestFactory::Create(const char* statement, Matcher<const std::string&> matcher, const char* file, int line, DeathTest** test) { UnitTestImpl* const impl = GetUnitTestImpl(); const InternalRunDeathTestFlag* const flag = impl->internal_run_death_test_flag(); const int death_test_index = impl->current_test_info() ->increment_death_test_count(); if (flag != nullptr) { if (death_test_index > flag->index()) { DeathTest::set_last_death_test_message( "Death test count (" + StreamableToString(death_test_index) + ") somehow exceeded expected maximum (" + StreamableToString(flag->index()) + ")"); return false; } if (!(flag->file() == file && flag->line() == line && flag->index() == death_test_index)) { *test = nullptr; return true; } } # if GTEST_OS_WINDOWS if (GTEST_FLAG(death_test_style) == "threadsafe" || GTEST_FLAG(death_test_style) == "fast") { *test = new WindowsDeathTest(statement, std::move(matcher), file, line); } # elif GTEST_OS_FUCHSIA if (GTEST_FLAG(death_test_style) == "threadsafe" || GTEST_FLAG(death_test_style) == "fast") { *test = new FuchsiaDeathTest(statement, std::move(matcher), file, line); } # else if (GTEST_FLAG(death_test_style) == "threadsafe") { *test = new ExecDeathTest(statement, std::move(matcher), file, line); } else if (GTEST_FLAG(death_test_style) == "fast") { *test = new NoExecDeathTest(statement, std::move(matcher)); } # endif // GTEST_OS_WINDOWS else { // NOLINT - this is more readable than unbalanced brackets inside #if. DeathTest::set_last_death_test_message( "Unknown death test style \"" + GTEST_FLAG(death_test_style) + "\" encountered"); return false; } return true; } # if GTEST_OS_WINDOWS // Recreates the pipe and event handles from the provided parameters, // signals the event, and returns a file descriptor wrapped around the pipe // handle. This function is called in the child process only. static int GetStatusFileDescriptor(unsigned int parent_process_id, size_t write_handle_as_size_t, size_t event_handle_as_size_t) { AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE, FALSE, // Non-inheritable. parent_process_id)); if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) { DeathTestAbort("Unable to open parent process " + StreamableToString(parent_process_id)); } GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t)); const HANDLE write_handle = reinterpret_cast<HANDLE>(write_handle_as_size_t); HANDLE dup_write_handle; // The newly initialized handle is accessible only in the parent // process. To obtain one accessible within the child, we need to use // DuplicateHandle. if (!::DuplicateHandle(parent_process_handle.Get(), write_handle, ::GetCurrentProcess(), &dup_write_handle, 0x0, // Requested privileges ignored since // DUPLICATE_SAME_ACCESS is used. FALSE, // Request non-inheritable handler. DUPLICATE_SAME_ACCESS)) { DeathTestAbort("Unable to duplicate the pipe handle " + StreamableToString(write_handle_as_size_t) + " from the parent process " + StreamableToString(parent_process_id)); } const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t); HANDLE dup_event_handle; if (!::DuplicateHandle(parent_process_handle.Get(), event_handle, ::GetCurrentProcess(), &dup_event_handle, 0x0, FALSE, DUPLICATE_SAME_ACCESS)) { DeathTestAbort("Unable to duplicate the event handle " + StreamableToString(event_handle_as_size_t) + " from the parent process " + StreamableToString(parent_process_id)); } const int write_fd = ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND); if (write_fd == -1) { DeathTestAbort("Unable to convert pipe handle " + StreamableToString(write_handle_as_size_t) + " to a file descriptor"); } // Signals the parent that the write end of the pipe has been acquired // so the parent can release its own write end. ::SetEvent(dup_event_handle); return write_fd; } # endif // GTEST_OS_WINDOWS // Returns a newly created InternalRunDeathTestFlag object with fields // initialized from the GTEST_FLAG(internal_run_death_test) flag if // the flag is specified; otherwise returns NULL. InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { if (GTEST_FLAG(internal_run_death_test) == "") return nullptr; // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we // can use it here. int line = -1; int index = -1; ::std::vector< ::std::string> fields; SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields); int write_fd = -1; # if GTEST_OS_WINDOWS unsigned int parent_process_id = 0; size_t write_handle_as_size_t = 0; size_t event_handle_as_size_t = 0; if (fields.size() != 6 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index) || !ParseNaturalNumber(fields[3], &parent_process_id) || !ParseNaturalNumber(fields[4], &write_handle_as_size_t) || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) { DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + GTEST_FLAG(internal_run_death_test)); } write_fd = GetStatusFileDescriptor(parent_process_id, write_handle_as_size_t, event_handle_as_size_t); # elif GTEST_OS_FUCHSIA if (fields.size() != 3 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index)) { DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + GTEST_FLAG(internal_run_death_test)); } # else if (fields.size() != 4 || !ParseNaturalNumber(fields[1], &line) || !ParseNaturalNumber(fields[2], &index) || !ParseNaturalNumber(fields[3], &write_fd)) { DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + GTEST_FLAG(internal_run_death_test)); } # endif // GTEST_OS_WINDOWS return new InternalRunDeathTestFlag(fields[0], line, index, write_fd); } } // namespace internal #endif // GTEST_HAS_DEATH_TEST } // namespace testing
/** * Copyright (C) 2014 MongoDB Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects for * all of the code used other than as permitted herein. If you modify file(s) * with this exception, you may extend this exception to your version of the * file(s), but you are not obligated to do so. If you do not wish to do so, * delete this exception statement from your version. If you delete this * exception statement from all source files in the program, then also delete * it in the license file. */ #include "mongo/db/index/external_key_generator.h" #include "mongo/db/fts/fts_index_format.h" #include "mongo/db/index/s2_common.h" #include "mongo/db/index_names.h" #include "mongo/db/index/2d_common.h" #include "mongo/db/index/btree_key_generator.h" #include "mongo/db/index/expression_keys_private.h" #include "mongo/db/index/expression_params.h" #include "mongo/db/jsobj.h" namespace mongo { namespace { void getKeysForUpgradeChecking(const BSONObj& infoObj, const BSONObj& doc, BSONObjSet* keys) { BSONObj keyPattern = infoObj.getObjectField("key"); string type = IndexNames::findPluginName(keyPattern); if (IndexNames::GEO_2D == type) { TwoDIndexingParams params; ExpressionParams::parseTwoDParams(infoObj, &params); ExpressionKeysPrivate::get2DKeys(doc, params, keys, NULL); } else if (IndexNames::GEO_HAYSTACK == type) { string geoField; vector<string> otherFields; double bucketSize; ExpressionParams::parseHaystackParams(infoObj, &geoField, &otherFields, &bucketSize); ExpressionKeysPrivate::getHaystackKeys(doc, geoField, otherFields, bucketSize, keys); } else if (IndexNames::GEO_2DSPHERE == type) { S2IndexingParams params; ExpressionParams::parse2dsphereParams(infoObj, &params); ExpressionKeysPrivate::getS2Keys(doc, keyPattern, params, keys); } else if (IndexNames::TEXT == type) { fts::FTSSpec spec(infoObj); ExpressionKeysPrivate::getFTSKeys(doc, spec, keys); } else if (IndexNames::HASHED == type) { HashSeed seed; int version; string field; ExpressionParams::parseHashParams(infoObj, &seed, &version, &field); ExpressionKeysPrivate::getHashKeys(doc, field, seed, version, infoObj["sparse"].trueValue(), keys); } else { invariant(IndexNames::BTREE == type); std::vector<const char *> fieldNames; std::vector<BSONElement> fixed; BSONObjIterator keyIt(keyPattern); while (keyIt.more()) { BSONElement patternElt = keyIt.next(); fieldNames.push_back(patternElt.fieldName()); fixed.push_back(BSONElement()); } // XXX: do we care about version BtreeKeyGeneratorV1 keyGen(fieldNames, fixed, infoObj["sparse"].trueValue()); keyGen.getKeys(doc, keys); } } // cloned from key.cpp to build the below set const int binDataCodeLengths[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 32}; const std::set<int> acceptableBinDataLengths( binDataCodeLengths, binDataCodeLengths + (sizeof(binDataCodeLengths) / sizeof(int))); // modified version of the KeyV1Owned constructor that returns the would-be-key's datasize() int keyV1Size(const BSONObj& obj) { BSONObj::iterator i(obj); int size = 0; const int traditionalSize = obj.objsize() + 1; while (i.more()) { BSONElement e = i.next(); switch (e.type()) { case MinKey: case jstNULL: case MaxKey: case Bool: size += 1; break; case jstOID: size += 1; size += sizeof(OID); break; case BinData: { int t = e.binDataType(); // 0-7 and 0x80 to 0x87 are supported by Key if( (t & 0x78) == 0 && t != ByteArrayDeprecated ) { int len; e.binData(len); if (acceptableBinDataLengths.count(len)) { size += 1; size += 1; size += len; break; } } return traditionalSize; } case Date: size += 1; size += sizeof(Date_t); break; case String: { size += 1; // note we do not store the terminating null, to save space. unsigned x = (unsigned) e.valuestrsize() - 1; if (x > 255) { return traditionalSize; } size += 1; size += x; break; } case NumberInt: size += 1; size += sizeof(double); break; case NumberLong: { long long n = e._numberLong(); long long m = 2LL << 52; if( n >= m || n <= -m ) { // can't represent exactly as a double return traditionalSize; } size += 1; size += sizeof(double); break; } case NumberDouble: { double d = e._numberDouble(); if (isNaN(d)) { return traditionalSize; } size += 1; size += sizeof(double); break; } default: // if other types involved, store as traditional BSON return traditionalSize; } } return size; } } // namespace bool isAnyIndexKeyTooLarge(const BSONObj& index, const BSONObj& doc) { BSONObjSet keys; getKeysForUpgradeChecking(index, doc, &keys); int largestKeySize = 0; for (BSONObjSet::const_iterator it = keys.begin(); it != keys.end(); ++it) { largestKeySize = std::max(largestKeySize, keyV1Size(*it)); } // BtreeData_V1::KeyMax is 1024 return largestKeySize > 1024; } } // namespace mongo
_cat: file format elf32-i386 Disassembly of section .text: 00000000 <cat>: char buf[512]; void cat(int fd) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 28 sub $0x28,%esp int n; while((n = read(fd, buf, sizeof(buf))) > 0) 6: eb 1b jmp 23 <cat+0x23> write(1, buf, n); 8: 8b 45 f4 mov -0xc(%ebp),%eax b: 89 44 24 08 mov %eax,0x8(%esp) f: c7 44 24 04 c0 0b 00 movl $0xbc0,0x4(%esp) 16: 00 17: c7 04 24 01 00 00 00 movl $0x1,(%esp) 1e: e8 82 03 00 00 call 3a5 <write> void cat(int fd) { int n; while((n = read(fd, buf, sizeof(buf))) > 0) 23: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 2a: 00 2b: c7 44 24 04 c0 0b 00 movl $0xbc0,0x4(%esp) 32: 00 33: 8b 45 08 mov 0x8(%ebp),%eax 36: 89 04 24 mov %eax,(%esp) 39: e8 5f 03 00 00 call 39d <read> 3e: 89 45 f4 mov %eax,-0xc(%ebp) 41: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 45: 7f c1 jg 8 <cat+0x8> write(1, buf, n); if(n < 0){ 47: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 4b: 79 19 jns 66 <cat+0x66> printf(1, "cat: read error\n"); 4d: c7 44 24 04 f1 08 00 movl $0x8f1,0x4(%esp) 54: 00 55: c7 04 24 01 00 00 00 movl $0x1,(%esp) 5c: e8 c4 04 00 00 call 525 <printf> exit(); 61: e8 1f 03 00 00 call 385 <exit> } } 66: c9 leave 67: c3 ret 00000068 <main>: int main(int argc, char *argv[]) { 68: 55 push %ebp 69: 89 e5 mov %esp,%ebp 6b: 83 e4 f0 and $0xfffffff0,%esp 6e: 83 ec 20 sub $0x20,%esp int fd, i; if(argc <= 1){ 71: 83 7d 08 01 cmpl $0x1,0x8(%ebp) 75: 7f 11 jg 88 <main+0x20> cat(0); 77: c7 04 24 00 00 00 00 movl $0x0,(%esp) 7e: e8 7d ff ff ff call 0 <cat> exit(); 83: e8 fd 02 00 00 call 385 <exit> } for(i = 1; i < argc; i++){ 88: c7 44 24 1c 01 00 00 movl $0x1,0x1c(%esp) 8f: 00 90: eb 79 jmp 10b <main+0xa3> if((fd = open(argv[i], 0)) < 0){ 92: 8b 44 24 1c mov 0x1c(%esp),%eax 96: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx 9d: 8b 45 0c mov 0xc(%ebp),%eax a0: 01 d0 add %edx,%eax a2: 8b 00 mov (%eax),%eax a4: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) ab: 00 ac: 89 04 24 mov %eax,(%esp) af: e8 11 03 00 00 call 3c5 <open> b4: 89 44 24 18 mov %eax,0x18(%esp) b8: 83 7c 24 18 00 cmpl $0x0,0x18(%esp) bd: 79 2f jns ee <main+0x86> printf(1, "cat: cannot open %s\n", argv[i]); bf: 8b 44 24 1c mov 0x1c(%esp),%eax c3: 8d 14 85 00 00 00 00 lea 0x0(,%eax,4),%edx ca: 8b 45 0c mov 0xc(%ebp),%eax cd: 01 d0 add %edx,%eax cf: 8b 00 mov (%eax),%eax d1: 89 44 24 08 mov %eax,0x8(%esp) d5: c7 44 24 04 02 09 00 movl $0x902,0x4(%esp) dc: 00 dd: c7 04 24 01 00 00 00 movl $0x1,(%esp) e4: e8 3c 04 00 00 call 525 <printf> exit(); e9: e8 97 02 00 00 call 385 <exit> } cat(fd); ee: 8b 44 24 18 mov 0x18(%esp),%eax f2: 89 04 24 mov %eax,(%esp) f5: e8 06 ff ff ff call 0 <cat> close(fd); fa: 8b 44 24 18 mov 0x18(%esp),%eax fe: 89 04 24 mov %eax,(%esp) 101: e8 a7 02 00 00 call 3ad <close> if(argc <= 1){ cat(0); exit(); } for(i = 1; i < argc; i++){ 106: 83 44 24 1c 01 addl $0x1,0x1c(%esp) 10b: 8b 44 24 1c mov 0x1c(%esp),%eax 10f: 3b 45 08 cmp 0x8(%ebp),%eax 112: 0f 8c 7a ff ff ff jl 92 <main+0x2a> exit(); } cat(fd); close(fd); } exit(); 118: e8 68 02 00 00 call 385 <exit> 0000011d <stosb>: "cc"); } static inline void stosb(void *addr, int data, int cnt) { 11d: 55 push %ebp 11e: 89 e5 mov %esp,%ebp 120: 57 push %edi 121: 53 push %ebx asm volatile("cld; rep stosb" : 122: 8b 4d 08 mov 0x8(%ebp),%ecx 125: 8b 55 10 mov 0x10(%ebp),%edx 128: 8b 45 0c mov 0xc(%ebp),%eax 12b: 89 cb mov %ecx,%ebx 12d: 89 df mov %ebx,%edi 12f: 89 d1 mov %edx,%ecx 131: fc cld 132: f3 aa rep stos %al,%es:(%edi) 134: 89 ca mov %ecx,%edx 136: 89 fb mov %edi,%ebx 138: 89 5d 08 mov %ebx,0x8(%ebp) 13b: 89 55 10 mov %edx,0x10(%ebp) "=D" (addr), "=c" (cnt) : "0" (addr), "1" (cnt), "a" (data) : "memory", "cc"); } 13e: 5b pop %ebx 13f: 5f pop %edi 140: 5d pop %ebp 141: c3 ret 00000142 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 142: 55 push %ebp 143: 89 e5 mov %esp,%ebp 145: 83 ec 10 sub $0x10,%esp char *os; os = s; 148: 8b 45 08 mov 0x8(%ebp),%eax 14b: 89 45 fc mov %eax,-0x4(%ebp) while((*s++ = *t++) != 0) 14e: 90 nop 14f: 8b 45 08 mov 0x8(%ebp),%eax 152: 8d 50 01 lea 0x1(%eax),%edx 155: 89 55 08 mov %edx,0x8(%ebp) 158: 8b 55 0c mov 0xc(%ebp),%edx 15b: 8d 4a 01 lea 0x1(%edx),%ecx 15e: 89 4d 0c mov %ecx,0xc(%ebp) 161: 0f b6 12 movzbl (%edx),%edx 164: 88 10 mov %dl,(%eax) 166: 0f b6 00 movzbl (%eax),%eax 169: 84 c0 test %al,%al 16b: 75 e2 jne 14f <strcpy+0xd> ; return os; 16d: 8b 45 fc mov -0x4(%ebp),%eax } 170: c9 leave 171: c3 ret 00000172 <strcmp>: int strcmp(const char *p, const char *q) { 172: 55 push %ebp 173: 89 e5 mov %esp,%ebp while(*p && *p == *q) 175: eb 08 jmp 17f <strcmp+0xd> p++, q++; 177: 83 45 08 01 addl $0x1,0x8(%ebp) 17b: 83 45 0c 01 addl $0x1,0xc(%ebp) } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 17f: 8b 45 08 mov 0x8(%ebp),%eax 182: 0f b6 00 movzbl (%eax),%eax 185: 84 c0 test %al,%al 187: 74 10 je 199 <strcmp+0x27> 189: 8b 45 08 mov 0x8(%ebp),%eax 18c: 0f b6 10 movzbl (%eax),%edx 18f: 8b 45 0c mov 0xc(%ebp),%eax 192: 0f b6 00 movzbl (%eax),%eax 195: 38 c2 cmp %al,%dl 197: 74 de je 177 <strcmp+0x5> p++, q++; return (uchar)*p - (uchar)*q; 199: 8b 45 08 mov 0x8(%ebp),%eax 19c: 0f b6 00 movzbl (%eax),%eax 19f: 0f b6 d0 movzbl %al,%edx 1a2: 8b 45 0c mov 0xc(%ebp),%eax 1a5: 0f b6 00 movzbl (%eax),%eax 1a8: 0f b6 c0 movzbl %al,%eax 1ab: 29 c2 sub %eax,%edx 1ad: 89 d0 mov %edx,%eax } 1af: 5d pop %ebp 1b0: c3 ret 000001b1 <strlen>: uint strlen(char *s) { 1b1: 55 push %ebp 1b2: 89 e5 mov %esp,%ebp 1b4: 83 ec 10 sub $0x10,%esp int n; for(n = 0; s[n]; n++) 1b7: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) 1be: eb 04 jmp 1c4 <strlen+0x13> 1c0: 83 45 fc 01 addl $0x1,-0x4(%ebp) 1c4: 8b 55 fc mov -0x4(%ebp),%edx 1c7: 8b 45 08 mov 0x8(%ebp),%eax 1ca: 01 d0 add %edx,%eax 1cc: 0f b6 00 movzbl (%eax),%eax 1cf: 84 c0 test %al,%al 1d1: 75 ed jne 1c0 <strlen+0xf> ; return n; 1d3: 8b 45 fc mov -0x4(%ebp),%eax } 1d6: c9 leave 1d7: c3 ret 000001d8 <memset>: void* memset(void *dst, int c, uint n) { 1d8: 55 push %ebp 1d9: 89 e5 mov %esp,%ebp 1db: 83 ec 0c sub $0xc,%esp stosb(dst, c, n); 1de: 8b 45 10 mov 0x10(%ebp),%eax 1e1: 89 44 24 08 mov %eax,0x8(%esp) 1e5: 8b 45 0c mov 0xc(%ebp),%eax 1e8: 89 44 24 04 mov %eax,0x4(%esp) 1ec: 8b 45 08 mov 0x8(%ebp),%eax 1ef: 89 04 24 mov %eax,(%esp) 1f2: e8 26 ff ff ff call 11d <stosb> return dst; 1f7: 8b 45 08 mov 0x8(%ebp),%eax } 1fa: c9 leave 1fb: c3 ret 000001fc <strchr>: char* strchr(const char *s, char c) { 1fc: 55 push %ebp 1fd: 89 e5 mov %esp,%ebp 1ff: 83 ec 04 sub $0x4,%esp 202: 8b 45 0c mov 0xc(%ebp),%eax 205: 88 45 fc mov %al,-0x4(%ebp) for(; *s; s++) 208: eb 14 jmp 21e <strchr+0x22> if(*s == c) 20a: 8b 45 08 mov 0x8(%ebp),%eax 20d: 0f b6 00 movzbl (%eax),%eax 210: 3a 45 fc cmp -0x4(%ebp),%al 213: 75 05 jne 21a <strchr+0x1e> return (char*)s; 215: 8b 45 08 mov 0x8(%ebp),%eax 218: eb 13 jmp 22d <strchr+0x31> } char* strchr(const char *s, char c) { for(; *s; s++) 21a: 83 45 08 01 addl $0x1,0x8(%ebp) 21e: 8b 45 08 mov 0x8(%ebp),%eax 221: 0f b6 00 movzbl (%eax),%eax 224: 84 c0 test %al,%al 226: 75 e2 jne 20a <strchr+0xe> if(*s == c) return (char*)s; return 0; 228: b8 00 00 00 00 mov $0x0,%eax } 22d: c9 leave 22e: c3 ret 0000022f <gets>: char* gets(char *buf, int max) { 22f: 55 push %ebp 230: 89 e5 mov %esp,%ebp 232: 83 ec 28 sub $0x28,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 235: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) 23c: eb 4c jmp 28a <gets+0x5b> cc = read(0, &c, 1); 23e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 245: 00 246: 8d 45 ef lea -0x11(%ebp),%eax 249: 89 44 24 04 mov %eax,0x4(%esp) 24d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 254: e8 44 01 00 00 call 39d <read> 259: 89 45 f0 mov %eax,-0x10(%ebp) if(cc < 1) 25c: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 260: 7f 02 jg 264 <gets+0x35> break; 262: eb 31 jmp 295 <gets+0x66> buf[i++] = c; 264: 8b 45 f4 mov -0xc(%ebp),%eax 267: 8d 50 01 lea 0x1(%eax),%edx 26a: 89 55 f4 mov %edx,-0xc(%ebp) 26d: 89 c2 mov %eax,%edx 26f: 8b 45 08 mov 0x8(%ebp),%eax 272: 01 c2 add %eax,%edx 274: 0f b6 45 ef movzbl -0x11(%ebp),%eax 278: 88 02 mov %al,(%edx) if(c == '\n' || c == '\r') 27a: 0f b6 45 ef movzbl -0x11(%ebp),%eax 27e: 3c 0a cmp $0xa,%al 280: 74 13 je 295 <gets+0x66> 282: 0f b6 45 ef movzbl -0x11(%ebp),%eax 286: 3c 0d cmp $0xd,%al 288: 74 0b je 295 <gets+0x66> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 28a: 8b 45 f4 mov -0xc(%ebp),%eax 28d: 83 c0 01 add $0x1,%eax 290: 3b 45 0c cmp 0xc(%ebp),%eax 293: 7c a9 jl 23e <gets+0xf> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 295: 8b 55 f4 mov -0xc(%ebp),%edx 298: 8b 45 08 mov 0x8(%ebp),%eax 29b: 01 d0 add %edx,%eax 29d: c6 00 00 movb $0x0,(%eax) return buf; 2a0: 8b 45 08 mov 0x8(%ebp),%eax } 2a3: c9 leave 2a4: c3 ret 000002a5 <stat>: int stat(char *n, struct stat *st) { 2a5: 55 push %ebp 2a6: 89 e5 mov %esp,%ebp 2a8: 83 ec 28 sub $0x28,%esp int fd; int r; fd = open(n, O_RDONLY); 2ab: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 2b2: 00 2b3: 8b 45 08 mov 0x8(%ebp),%eax 2b6: 89 04 24 mov %eax,(%esp) 2b9: e8 07 01 00 00 call 3c5 <open> 2be: 89 45 f4 mov %eax,-0xc(%ebp) if(fd < 0) 2c1: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 2c5: 79 07 jns 2ce <stat+0x29> return -1; 2c7: b8 ff ff ff ff mov $0xffffffff,%eax 2cc: eb 23 jmp 2f1 <stat+0x4c> r = fstat(fd, st); 2ce: 8b 45 0c mov 0xc(%ebp),%eax 2d1: 89 44 24 04 mov %eax,0x4(%esp) 2d5: 8b 45 f4 mov -0xc(%ebp),%eax 2d8: 89 04 24 mov %eax,(%esp) 2db: e8 fd 00 00 00 call 3dd <fstat> 2e0: 89 45 f0 mov %eax,-0x10(%ebp) close(fd); 2e3: 8b 45 f4 mov -0xc(%ebp),%eax 2e6: 89 04 24 mov %eax,(%esp) 2e9: e8 bf 00 00 00 call 3ad <close> return r; 2ee: 8b 45 f0 mov -0x10(%ebp),%eax } 2f1: c9 leave 2f2: c3 ret 000002f3 <atoi>: int atoi(const char *s) { 2f3: 55 push %ebp 2f4: 89 e5 mov %esp,%ebp 2f6: 83 ec 10 sub $0x10,%esp int n; n = 0; 2f9: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%ebp) while('0' <= *s && *s <= '9') 300: eb 25 jmp 327 <atoi+0x34> n = n*10 + *s++ - '0'; 302: 8b 55 fc mov -0x4(%ebp),%edx 305: 89 d0 mov %edx,%eax 307: c1 e0 02 shl $0x2,%eax 30a: 01 d0 add %edx,%eax 30c: 01 c0 add %eax,%eax 30e: 89 c1 mov %eax,%ecx 310: 8b 45 08 mov 0x8(%ebp),%eax 313: 8d 50 01 lea 0x1(%eax),%edx 316: 89 55 08 mov %edx,0x8(%ebp) 319: 0f b6 00 movzbl (%eax),%eax 31c: 0f be c0 movsbl %al,%eax 31f: 01 c8 add %ecx,%eax 321: 83 e8 30 sub $0x30,%eax 324: 89 45 fc mov %eax,-0x4(%ebp) atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 327: 8b 45 08 mov 0x8(%ebp),%eax 32a: 0f b6 00 movzbl (%eax),%eax 32d: 3c 2f cmp $0x2f,%al 32f: 7e 0a jle 33b <atoi+0x48> 331: 8b 45 08 mov 0x8(%ebp),%eax 334: 0f b6 00 movzbl (%eax),%eax 337: 3c 39 cmp $0x39,%al 339: 7e c7 jle 302 <atoi+0xf> n = n*10 + *s++ - '0'; return n; 33b: 8b 45 fc mov -0x4(%ebp),%eax } 33e: c9 leave 33f: c3 ret 00000340 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 340: 55 push %ebp 341: 89 e5 mov %esp,%ebp 343: 83 ec 10 sub $0x10,%esp char *dst, *src; dst = vdst; 346: 8b 45 08 mov 0x8(%ebp),%eax 349: 89 45 fc mov %eax,-0x4(%ebp) src = vsrc; 34c: 8b 45 0c mov 0xc(%ebp),%eax 34f: 89 45 f8 mov %eax,-0x8(%ebp) while(n-- > 0) 352: eb 17 jmp 36b <memmove+0x2b> *dst++ = *src++; 354: 8b 45 fc mov -0x4(%ebp),%eax 357: 8d 50 01 lea 0x1(%eax),%edx 35a: 89 55 fc mov %edx,-0x4(%ebp) 35d: 8b 55 f8 mov -0x8(%ebp),%edx 360: 8d 4a 01 lea 0x1(%edx),%ecx 363: 89 4d f8 mov %ecx,-0x8(%ebp) 366: 0f b6 12 movzbl (%edx),%edx 369: 88 10 mov %dl,(%eax) { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 36b: 8b 45 10 mov 0x10(%ebp),%eax 36e: 8d 50 ff lea -0x1(%eax),%edx 371: 89 55 10 mov %edx,0x10(%ebp) 374: 85 c0 test %eax,%eax 376: 7f dc jg 354 <memmove+0x14> *dst++ = *src++; return vdst; 378: 8b 45 08 mov 0x8(%ebp),%eax } 37b: c9 leave 37c: c3 ret 0000037d <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 37d: b8 01 00 00 00 mov $0x1,%eax 382: cd 40 int $0x40 384: c3 ret 00000385 <exit>: SYSCALL(exit) 385: b8 02 00 00 00 mov $0x2,%eax 38a: cd 40 int $0x40 38c: c3 ret 0000038d <wait>: SYSCALL(wait) 38d: b8 03 00 00 00 mov $0x3,%eax 392: cd 40 int $0x40 394: c3 ret 00000395 <pipe>: SYSCALL(pipe) 395: b8 04 00 00 00 mov $0x4,%eax 39a: cd 40 int $0x40 39c: c3 ret 0000039d <read>: SYSCALL(read) 39d: b8 05 00 00 00 mov $0x5,%eax 3a2: cd 40 int $0x40 3a4: c3 ret 000003a5 <write>: SYSCALL(write) 3a5: b8 10 00 00 00 mov $0x10,%eax 3aa: cd 40 int $0x40 3ac: c3 ret 000003ad <close>: SYSCALL(close) 3ad: b8 15 00 00 00 mov $0x15,%eax 3b2: cd 40 int $0x40 3b4: c3 ret 000003b5 <kill>: SYSCALL(kill) 3b5: b8 06 00 00 00 mov $0x6,%eax 3ba: cd 40 int $0x40 3bc: c3 ret 000003bd <exec>: SYSCALL(exec) 3bd: b8 07 00 00 00 mov $0x7,%eax 3c2: cd 40 int $0x40 3c4: c3 ret 000003c5 <open>: SYSCALL(open) 3c5: b8 0f 00 00 00 mov $0xf,%eax 3ca: cd 40 int $0x40 3cc: c3 ret 000003cd <mknod>: SYSCALL(mknod) 3cd: b8 11 00 00 00 mov $0x11,%eax 3d2: cd 40 int $0x40 3d4: c3 ret 000003d5 <unlink>: SYSCALL(unlink) 3d5: b8 12 00 00 00 mov $0x12,%eax 3da: cd 40 int $0x40 3dc: c3 ret 000003dd <fstat>: SYSCALL(fstat) 3dd: b8 08 00 00 00 mov $0x8,%eax 3e2: cd 40 int $0x40 3e4: c3 ret 000003e5 <link>: SYSCALL(link) 3e5: b8 13 00 00 00 mov $0x13,%eax 3ea: cd 40 int $0x40 3ec: c3 ret 000003ed <mkdir>: SYSCALL(mkdir) 3ed: b8 14 00 00 00 mov $0x14,%eax 3f2: cd 40 int $0x40 3f4: c3 ret 000003f5 <chdir>: SYSCALL(chdir) 3f5: b8 09 00 00 00 mov $0x9,%eax 3fa: cd 40 int $0x40 3fc: c3 ret 000003fd <dup>: SYSCALL(dup) 3fd: b8 0a 00 00 00 mov $0xa,%eax 402: cd 40 int $0x40 404: c3 ret 00000405 <getpid>: SYSCALL(getpid) 405: b8 0b 00 00 00 mov $0xb,%eax 40a: cd 40 int $0x40 40c: c3 ret 0000040d <sbrk>: SYSCALL(sbrk) 40d: b8 0c 00 00 00 mov $0xc,%eax 412: cd 40 int $0x40 414: c3 ret 00000415 <sleep>: SYSCALL(sleep) 415: b8 0d 00 00 00 mov $0xd,%eax 41a: cd 40 int $0x40 41c: c3 ret 0000041d <uptime>: SYSCALL(uptime) 41d: b8 0e 00 00 00 mov $0xe,%eax 422: cd 40 int $0x40 424: c3 ret 00000425 <changepriority>: SYSCALL(changepriority) 425: b8 16 00 00 00 mov $0x16,%eax 42a: cd 40 int $0x40 42c: c3 ret 0000042d <processstatus>: SYSCALL(processstatus) 42d: b8 17 00 00 00 mov $0x17,%eax 432: cd 40 int $0x40 434: c3 ret 00000435 <randomgen>: SYSCALL(randomgen) 435: b8 18 00 00 00 mov $0x18,%eax 43a: cd 40 int $0x40 43c: c3 ret 0000043d <randomgenrange>: SYSCALL(randomgenrange) 43d: b8 19 00 00 00 mov $0x19,%eax 442: cd 40 int $0x40 444: c3 ret 00000445 <putc>: #include "stat.h" #include "user.h" static void putc(int fd, char c) { 445: 55 push %ebp 446: 89 e5 mov %esp,%ebp 448: 83 ec 18 sub $0x18,%esp 44b: 8b 45 0c mov 0xc(%ebp),%eax 44e: 88 45 f4 mov %al,-0xc(%ebp) write(fd, &c, 1); 451: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 458: 00 459: 8d 45 f4 lea -0xc(%ebp),%eax 45c: 89 44 24 04 mov %eax,0x4(%esp) 460: 8b 45 08 mov 0x8(%ebp),%eax 463: 89 04 24 mov %eax,(%esp) 466: e8 3a ff ff ff call 3a5 <write> } 46b: c9 leave 46c: c3 ret 0000046d <printint>: static void printint(int fd, int xx, int base, int sgn) { 46d: 55 push %ebp 46e: 89 e5 mov %esp,%ebp 470: 56 push %esi 471: 53 push %ebx 472: 83 ec 30 sub $0x30,%esp static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 475: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) if(sgn && xx < 0){ 47c: 83 7d 14 00 cmpl $0x0,0x14(%ebp) 480: 74 17 je 499 <printint+0x2c> 482: 83 7d 0c 00 cmpl $0x0,0xc(%ebp) 486: 79 11 jns 499 <printint+0x2c> neg = 1; 488: c7 45 f0 01 00 00 00 movl $0x1,-0x10(%ebp) x = -xx; 48f: 8b 45 0c mov 0xc(%ebp),%eax 492: f7 d8 neg %eax 494: 89 45 ec mov %eax,-0x14(%ebp) 497: eb 06 jmp 49f <printint+0x32> } else { x = xx; 499: 8b 45 0c mov 0xc(%ebp),%eax 49c: 89 45 ec mov %eax,-0x14(%ebp) } i = 0; 49f: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%ebp) do{ buf[i++] = digits[x % base]; 4a6: 8b 4d f4 mov -0xc(%ebp),%ecx 4a9: 8d 41 01 lea 0x1(%ecx),%eax 4ac: 89 45 f4 mov %eax,-0xc(%ebp) 4af: 8b 5d 10 mov 0x10(%ebp),%ebx 4b2: 8b 45 ec mov -0x14(%ebp),%eax 4b5: ba 00 00 00 00 mov $0x0,%edx 4ba: f7 f3 div %ebx 4bc: 89 d0 mov %edx,%eax 4be: 0f b6 80 84 0b 00 00 movzbl 0xb84(%eax),%eax 4c5: 88 44 0d dc mov %al,-0x24(%ebp,%ecx,1) }while((x /= base) != 0); 4c9: 8b 75 10 mov 0x10(%ebp),%esi 4cc: 8b 45 ec mov -0x14(%ebp),%eax 4cf: ba 00 00 00 00 mov $0x0,%edx 4d4: f7 f6 div %esi 4d6: 89 45 ec mov %eax,-0x14(%ebp) 4d9: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 4dd: 75 c7 jne 4a6 <printint+0x39> if(neg) 4df: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 4e3: 74 10 je 4f5 <printint+0x88> buf[i++] = '-'; 4e5: 8b 45 f4 mov -0xc(%ebp),%eax 4e8: 8d 50 01 lea 0x1(%eax),%edx 4eb: 89 55 f4 mov %edx,-0xc(%ebp) 4ee: c6 44 05 dc 2d movb $0x2d,-0x24(%ebp,%eax,1) while(--i >= 0) 4f3: eb 1f jmp 514 <printint+0xa7> 4f5: eb 1d jmp 514 <printint+0xa7> putc(fd, buf[i]); 4f7: 8d 55 dc lea -0x24(%ebp),%edx 4fa: 8b 45 f4 mov -0xc(%ebp),%eax 4fd: 01 d0 add %edx,%eax 4ff: 0f b6 00 movzbl (%eax),%eax 502: 0f be c0 movsbl %al,%eax 505: 89 44 24 04 mov %eax,0x4(%esp) 509: 8b 45 08 mov 0x8(%ebp),%eax 50c: 89 04 24 mov %eax,(%esp) 50f: e8 31 ff ff ff call 445 <putc> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 514: 83 6d f4 01 subl $0x1,-0xc(%ebp) 518: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 51c: 79 d9 jns 4f7 <printint+0x8a> putc(fd, buf[i]); } 51e: 83 c4 30 add $0x30,%esp 521: 5b pop %ebx 522: 5e pop %esi 523: 5d pop %ebp 524: c3 ret 00000525 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 525: 55 push %ebp 526: 89 e5 mov %esp,%ebp 528: 83 ec 38 sub $0x38,%esp char *s; int c, i, state; uint *ap; state = 0; 52b: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) ap = (uint*)(void*)&fmt + 1; 532: 8d 45 0c lea 0xc(%ebp),%eax 535: 83 c0 04 add $0x4,%eax 538: 89 45 e8 mov %eax,-0x18(%ebp) for(i = 0; fmt[i]; i++){ 53b: c7 45 f0 00 00 00 00 movl $0x0,-0x10(%ebp) 542: e9 7c 01 00 00 jmp 6c3 <printf+0x19e> c = fmt[i] & 0xff; 547: 8b 55 0c mov 0xc(%ebp),%edx 54a: 8b 45 f0 mov -0x10(%ebp),%eax 54d: 01 d0 add %edx,%eax 54f: 0f b6 00 movzbl (%eax),%eax 552: 0f be c0 movsbl %al,%eax 555: 25 ff 00 00 00 and $0xff,%eax 55a: 89 45 e4 mov %eax,-0x1c(%ebp) if(state == 0){ 55d: 83 7d ec 00 cmpl $0x0,-0x14(%ebp) 561: 75 2c jne 58f <printf+0x6a> if(c == '%'){ 563: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 567: 75 0c jne 575 <printf+0x50> state = '%'; 569: c7 45 ec 25 00 00 00 movl $0x25,-0x14(%ebp) 570: e9 4a 01 00 00 jmp 6bf <printf+0x19a> } else { putc(fd, c); 575: 8b 45 e4 mov -0x1c(%ebp),%eax 578: 0f be c0 movsbl %al,%eax 57b: 89 44 24 04 mov %eax,0x4(%esp) 57f: 8b 45 08 mov 0x8(%ebp),%eax 582: 89 04 24 mov %eax,(%esp) 585: e8 bb fe ff ff call 445 <putc> 58a: e9 30 01 00 00 jmp 6bf <printf+0x19a> } } else if(state == '%'){ 58f: 83 7d ec 25 cmpl $0x25,-0x14(%ebp) 593: 0f 85 26 01 00 00 jne 6bf <printf+0x19a> if(c == 'd'){ 599: 83 7d e4 64 cmpl $0x64,-0x1c(%ebp) 59d: 75 2d jne 5cc <printf+0xa7> printint(fd, *ap, 10, 1); 59f: 8b 45 e8 mov -0x18(%ebp),%eax 5a2: 8b 00 mov (%eax),%eax 5a4: c7 44 24 0c 01 00 00 movl $0x1,0xc(%esp) 5ab: 00 5ac: c7 44 24 08 0a 00 00 movl $0xa,0x8(%esp) 5b3: 00 5b4: 89 44 24 04 mov %eax,0x4(%esp) 5b8: 8b 45 08 mov 0x8(%ebp),%eax 5bb: 89 04 24 mov %eax,(%esp) 5be: e8 aa fe ff ff call 46d <printint> ap++; 5c3: 83 45 e8 04 addl $0x4,-0x18(%ebp) 5c7: e9 ec 00 00 00 jmp 6b8 <printf+0x193> } else if(c == 'x' || c == 'p'){ 5cc: 83 7d e4 78 cmpl $0x78,-0x1c(%ebp) 5d0: 74 06 je 5d8 <printf+0xb3> 5d2: 83 7d e4 70 cmpl $0x70,-0x1c(%ebp) 5d6: 75 2d jne 605 <printf+0xe0> printint(fd, *ap, 16, 0); 5d8: 8b 45 e8 mov -0x18(%ebp),%eax 5db: 8b 00 mov (%eax),%eax 5dd: c7 44 24 0c 00 00 00 movl $0x0,0xc(%esp) 5e4: 00 5e5: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 5ec: 00 5ed: 89 44 24 04 mov %eax,0x4(%esp) 5f1: 8b 45 08 mov 0x8(%ebp),%eax 5f4: 89 04 24 mov %eax,(%esp) 5f7: e8 71 fe ff ff call 46d <printint> ap++; 5fc: 83 45 e8 04 addl $0x4,-0x18(%ebp) 600: e9 b3 00 00 00 jmp 6b8 <printf+0x193> } else if(c == 's'){ 605: 83 7d e4 73 cmpl $0x73,-0x1c(%ebp) 609: 75 45 jne 650 <printf+0x12b> s = (char*)*ap; 60b: 8b 45 e8 mov -0x18(%ebp),%eax 60e: 8b 00 mov (%eax),%eax 610: 89 45 f4 mov %eax,-0xc(%ebp) ap++; 613: 83 45 e8 04 addl $0x4,-0x18(%ebp) if(s == 0) 617: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 61b: 75 09 jne 626 <printf+0x101> s = "(null)"; 61d: c7 45 f4 17 09 00 00 movl $0x917,-0xc(%ebp) while(*s != 0){ 624: eb 1e jmp 644 <printf+0x11f> 626: eb 1c jmp 644 <printf+0x11f> putc(fd, *s); 628: 8b 45 f4 mov -0xc(%ebp),%eax 62b: 0f b6 00 movzbl (%eax),%eax 62e: 0f be c0 movsbl %al,%eax 631: 89 44 24 04 mov %eax,0x4(%esp) 635: 8b 45 08 mov 0x8(%ebp),%eax 638: 89 04 24 mov %eax,(%esp) 63b: e8 05 fe ff ff call 445 <putc> s++; 640: 83 45 f4 01 addl $0x1,-0xc(%ebp) } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 644: 8b 45 f4 mov -0xc(%ebp),%eax 647: 0f b6 00 movzbl (%eax),%eax 64a: 84 c0 test %al,%al 64c: 75 da jne 628 <printf+0x103> 64e: eb 68 jmp 6b8 <printf+0x193> putc(fd, *s); s++; } } else if(c == 'c'){ 650: 83 7d e4 63 cmpl $0x63,-0x1c(%ebp) 654: 75 1d jne 673 <printf+0x14e> putc(fd, *ap); 656: 8b 45 e8 mov -0x18(%ebp),%eax 659: 8b 00 mov (%eax),%eax 65b: 0f be c0 movsbl %al,%eax 65e: 89 44 24 04 mov %eax,0x4(%esp) 662: 8b 45 08 mov 0x8(%ebp),%eax 665: 89 04 24 mov %eax,(%esp) 668: e8 d8 fd ff ff call 445 <putc> ap++; 66d: 83 45 e8 04 addl $0x4,-0x18(%ebp) 671: eb 45 jmp 6b8 <printf+0x193> } else if(c == '%'){ 673: 83 7d e4 25 cmpl $0x25,-0x1c(%ebp) 677: 75 17 jne 690 <printf+0x16b> putc(fd, c); 679: 8b 45 e4 mov -0x1c(%ebp),%eax 67c: 0f be c0 movsbl %al,%eax 67f: 89 44 24 04 mov %eax,0x4(%esp) 683: 8b 45 08 mov 0x8(%ebp),%eax 686: 89 04 24 mov %eax,(%esp) 689: e8 b7 fd ff ff call 445 <putc> 68e: eb 28 jmp 6b8 <printf+0x193> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); 690: c7 44 24 04 25 00 00 movl $0x25,0x4(%esp) 697: 00 698: 8b 45 08 mov 0x8(%ebp),%eax 69b: 89 04 24 mov %eax,(%esp) 69e: e8 a2 fd ff ff call 445 <putc> putc(fd, c); 6a3: 8b 45 e4 mov -0x1c(%ebp),%eax 6a6: 0f be c0 movsbl %al,%eax 6a9: 89 44 24 04 mov %eax,0x4(%esp) 6ad: 8b 45 08 mov 0x8(%ebp),%eax 6b0: 89 04 24 mov %eax,(%esp) 6b3: e8 8d fd ff ff call 445 <putc> } state = 0; 6b8: c7 45 ec 00 00 00 00 movl $0x0,-0x14(%ebp) int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6bf: 83 45 f0 01 addl $0x1,-0x10(%ebp) 6c3: 8b 55 0c mov 0xc(%ebp),%edx 6c6: 8b 45 f0 mov -0x10(%ebp),%eax 6c9: 01 d0 add %edx,%eax 6cb: 0f b6 00 movzbl (%eax),%eax 6ce: 84 c0 test %al,%al 6d0: 0f 85 71 fe ff ff jne 547 <printf+0x22> putc(fd, c); } state = 0; } } } 6d6: c9 leave 6d7: c3 ret 000006d8 <free>: static Header base; static Header *freep; void free(void *ap) { 6d8: 55 push %ebp 6d9: 89 e5 mov %esp,%ebp 6db: 83 ec 10 sub $0x10,%esp Header *bp, *p; bp = (Header*)ap - 1; 6de: 8b 45 08 mov 0x8(%ebp),%eax 6e1: 83 e8 08 sub $0x8,%eax 6e4: 89 45 f8 mov %eax,-0x8(%ebp) for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6e7: a1 a8 0b 00 00 mov 0xba8,%eax 6ec: 89 45 fc mov %eax,-0x4(%ebp) 6ef: eb 24 jmp 715 <free+0x3d> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6f1: 8b 45 fc mov -0x4(%ebp),%eax 6f4: 8b 00 mov (%eax),%eax 6f6: 3b 45 fc cmp -0x4(%ebp),%eax 6f9: 77 12 ja 70d <free+0x35> 6fb: 8b 45 f8 mov -0x8(%ebp),%eax 6fe: 3b 45 fc cmp -0x4(%ebp),%eax 701: 77 24 ja 727 <free+0x4f> 703: 8b 45 fc mov -0x4(%ebp),%eax 706: 8b 00 mov (%eax),%eax 708: 3b 45 f8 cmp -0x8(%ebp),%eax 70b: 77 1a ja 727 <free+0x4f> free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 70d: 8b 45 fc mov -0x4(%ebp),%eax 710: 8b 00 mov (%eax),%eax 712: 89 45 fc mov %eax,-0x4(%ebp) 715: 8b 45 f8 mov -0x8(%ebp),%eax 718: 3b 45 fc cmp -0x4(%ebp),%eax 71b: 76 d4 jbe 6f1 <free+0x19> 71d: 8b 45 fc mov -0x4(%ebp),%eax 720: 8b 00 mov (%eax),%eax 722: 3b 45 f8 cmp -0x8(%ebp),%eax 725: 76 ca jbe 6f1 <free+0x19> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 727: 8b 45 f8 mov -0x8(%ebp),%eax 72a: 8b 40 04 mov 0x4(%eax),%eax 72d: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 734: 8b 45 f8 mov -0x8(%ebp),%eax 737: 01 c2 add %eax,%edx 739: 8b 45 fc mov -0x4(%ebp),%eax 73c: 8b 00 mov (%eax),%eax 73e: 39 c2 cmp %eax,%edx 740: 75 24 jne 766 <free+0x8e> bp->s.size += p->s.ptr->s.size; 742: 8b 45 f8 mov -0x8(%ebp),%eax 745: 8b 50 04 mov 0x4(%eax),%edx 748: 8b 45 fc mov -0x4(%ebp),%eax 74b: 8b 00 mov (%eax),%eax 74d: 8b 40 04 mov 0x4(%eax),%eax 750: 01 c2 add %eax,%edx 752: 8b 45 f8 mov -0x8(%ebp),%eax 755: 89 50 04 mov %edx,0x4(%eax) bp->s.ptr = p->s.ptr->s.ptr; 758: 8b 45 fc mov -0x4(%ebp),%eax 75b: 8b 00 mov (%eax),%eax 75d: 8b 10 mov (%eax),%edx 75f: 8b 45 f8 mov -0x8(%ebp),%eax 762: 89 10 mov %edx,(%eax) 764: eb 0a jmp 770 <free+0x98> } else bp->s.ptr = p->s.ptr; 766: 8b 45 fc mov -0x4(%ebp),%eax 769: 8b 10 mov (%eax),%edx 76b: 8b 45 f8 mov -0x8(%ebp),%eax 76e: 89 10 mov %edx,(%eax) if(p + p->s.size == bp){ 770: 8b 45 fc mov -0x4(%ebp),%eax 773: 8b 40 04 mov 0x4(%eax),%eax 776: 8d 14 c5 00 00 00 00 lea 0x0(,%eax,8),%edx 77d: 8b 45 fc mov -0x4(%ebp),%eax 780: 01 d0 add %edx,%eax 782: 3b 45 f8 cmp -0x8(%ebp),%eax 785: 75 20 jne 7a7 <free+0xcf> p->s.size += bp->s.size; 787: 8b 45 fc mov -0x4(%ebp),%eax 78a: 8b 50 04 mov 0x4(%eax),%edx 78d: 8b 45 f8 mov -0x8(%ebp),%eax 790: 8b 40 04 mov 0x4(%eax),%eax 793: 01 c2 add %eax,%edx 795: 8b 45 fc mov -0x4(%ebp),%eax 798: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 79b: 8b 45 f8 mov -0x8(%ebp),%eax 79e: 8b 10 mov (%eax),%edx 7a0: 8b 45 fc mov -0x4(%ebp),%eax 7a3: 89 10 mov %edx,(%eax) 7a5: eb 08 jmp 7af <free+0xd7> } else p->s.ptr = bp; 7a7: 8b 45 fc mov -0x4(%ebp),%eax 7aa: 8b 55 f8 mov -0x8(%ebp),%edx 7ad: 89 10 mov %edx,(%eax) freep = p; 7af: 8b 45 fc mov -0x4(%ebp),%eax 7b2: a3 a8 0b 00 00 mov %eax,0xba8 } 7b7: c9 leave 7b8: c3 ret 000007b9 <morecore>: static Header* morecore(uint nu) { 7b9: 55 push %ebp 7ba: 89 e5 mov %esp,%ebp 7bc: 83 ec 28 sub $0x28,%esp char *p; Header *hp; if(nu < 4096) 7bf: 81 7d 08 ff 0f 00 00 cmpl $0xfff,0x8(%ebp) 7c6: 77 07 ja 7cf <morecore+0x16> nu = 4096; 7c8: c7 45 08 00 10 00 00 movl $0x1000,0x8(%ebp) p = sbrk(nu * sizeof(Header)); 7cf: 8b 45 08 mov 0x8(%ebp),%eax 7d2: c1 e0 03 shl $0x3,%eax 7d5: 89 04 24 mov %eax,(%esp) 7d8: e8 30 fc ff ff call 40d <sbrk> 7dd: 89 45 f4 mov %eax,-0xc(%ebp) if(p == (char*)-1) 7e0: 83 7d f4 ff cmpl $0xffffffff,-0xc(%ebp) 7e4: 75 07 jne 7ed <morecore+0x34> return 0; 7e6: b8 00 00 00 00 mov $0x0,%eax 7eb: eb 22 jmp 80f <morecore+0x56> hp = (Header*)p; 7ed: 8b 45 f4 mov -0xc(%ebp),%eax 7f0: 89 45 f0 mov %eax,-0x10(%ebp) hp->s.size = nu; 7f3: 8b 45 f0 mov -0x10(%ebp),%eax 7f6: 8b 55 08 mov 0x8(%ebp),%edx 7f9: 89 50 04 mov %edx,0x4(%eax) free((void*)(hp + 1)); 7fc: 8b 45 f0 mov -0x10(%ebp),%eax 7ff: 83 c0 08 add $0x8,%eax 802: 89 04 24 mov %eax,(%esp) 805: e8 ce fe ff ff call 6d8 <free> return freep; 80a: a1 a8 0b 00 00 mov 0xba8,%eax } 80f: c9 leave 810: c3 ret 00000811 <malloc>: void* malloc(uint nbytes) { 811: 55 push %ebp 812: 89 e5 mov %esp,%ebp 814: 83 ec 28 sub $0x28,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 817: 8b 45 08 mov 0x8(%ebp),%eax 81a: 83 c0 07 add $0x7,%eax 81d: c1 e8 03 shr $0x3,%eax 820: 83 c0 01 add $0x1,%eax 823: 89 45 ec mov %eax,-0x14(%ebp) if((prevp = freep) == 0){ 826: a1 a8 0b 00 00 mov 0xba8,%eax 82b: 89 45 f0 mov %eax,-0x10(%ebp) 82e: 83 7d f0 00 cmpl $0x0,-0x10(%ebp) 832: 75 23 jne 857 <malloc+0x46> base.s.ptr = freep = prevp = &base; 834: c7 45 f0 a0 0b 00 00 movl $0xba0,-0x10(%ebp) 83b: 8b 45 f0 mov -0x10(%ebp),%eax 83e: a3 a8 0b 00 00 mov %eax,0xba8 843: a1 a8 0b 00 00 mov 0xba8,%eax 848: a3 a0 0b 00 00 mov %eax,0xba0 base.s.size = 0; 84d: c7 05 a4 0b 00 00 00 movl $0x0,0xba4 854: 00 00 00 } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 857: 8b 45 f0 mov -0x10(%ebp),%eax 85a: 8b 00 mov (%eax),%eax 85c: 89 45 f4 mov %eax,-0xc(%ebp) if(p->s.size >= nunits){ 85f: 8b 45 f4 mov -0xc(%ebp),%eax 862: 8b 40 04 mov 0x4(%eax),%eax 865: 3b 45 ec cmp -0x14(%ebp),%eax 868: 72 4d jb 8b7 <malloc+0xa6> if(p->s.size == nunits) 86a: 8b 45 f4 mov -0xc(%ebp),%eax 86d: 8b 40 04 mov 0x4(%eax),%eax 870: 3b 45 ec cmp -0x14(%ebp),%eax 873: 75 0c jne 881 <malloc+0x70> prevp->s.ptr = p->s.ptr; 875: 8b 45 f4 mov -0xc(%ebp),%eax 878: 8b 10 mov (%eax),%edx 87a: 8b 45 f0 mov -0x10(%ebp),%eax 87d: 89 10 mov %edx,(%eax) 87f: eb 26 jmp 8a7 <malloc+0x96> else { p->s.size -= nunits; 881: 8b 45 f4 mov -0xc(%ebp),%eax 884: 8b 40 04 mov 0x4(%eax),%eax 887: 2b 45 ec sub -0x14(%ebp),%eax 88a: 89 c2 mov %eax,%edx 88c: 8b 45 f4 mov -0xc(%ebp),%eax 88f: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 892: 8b 45 f4 mov -0xc(%ebp),%eax 895: 8b 40 04 mov 0x4(%eax),%eax 898: c1 e0 03 shl $0x3,%eax 89b: 01 45 f4 add %eax,-0xc(%ebp) p->s.size = nunits; 89e: 8b 45 f4 mov -0xc(%ebp),%eax 8a1: 8b 55 ec mov -0x14(%ebp),%edx 8a4: 89 50 04 mov %edx,0x4(%eax) } freep = prevp; 8a7: 8b 45 f0 mov -0x10(%ebp),%eax 8aa: a3 a8 0b 00 00 mov %eax,0xba8 return (void*)(p + 1); 8af: 8b 45 f4 mov -0xc(%ebp),%eax 8b2: 83 c0 08 add $0x8,%eax 8b5: eb 38 jmp 8ef <malloc+0xde> } if(p == freep) 8b7: a1 a8 0b 00 00 mov 0xba8,%eax 8bc: 39 45 f4 cmp %eax,-0xc(%ebp) 8bf: 75 1b jne 8dc <malloc+0xcb> if((p = morecore(nunits)) == 0) 8c1: 8b 45 ec mov -0x14(%ebp),%eax 8c4: 89 04 24 mov %eax,(%esp) 8c7: e8 ed fe ff ff call 7b9 <morecore> 8cc: 89 45 f4 mov %eax,-0xc(%ebp) 8cf: 83 7d f4 00 cmpl $0x0,-0xc(%ebp) 8d3: 75 07 jne 8dc <malloc+0xcb> return 0; 8d5: b8 00 00 00 00 mov $0x0,%eax 8da: eb 13 jmp 8ef <malloc+0xde> nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 8dc: 8b 45 f4 mov -0xc(%ebp),%eax 8df: 89 45 f0 mov %eax,-0x10(%ebp) 8e2: 8b 45 f4 mov -0xc(%ebp),%eax 8e5: 8b 00 mov (%eax),%eax 8e7: 89 45 f4 mov %eax,-0xc(%ebp) return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } 8ea: e9 70 ff ff ff jmp 85f <malloc+0x4e> } 8ef: c9 leave 8f0: c3 ret
// redbox, 2021 #include "InstancedPluginEditorCommands.h" #define LOCTEXT_NAMESPACE "FInstancedPluginEditorModule" void FInstancedPluginEditorCommands::RegisterCommands() { UI_COMMAND(PluginCommand0, "Convert static meshes to instances", "Replace selected StaticMeshActors or actors containing StaticMeshComponents with instances", EUserInterfaceActionType::Button, FInputChord()); UI_COMMAND(PluginCommand1, "Convert instances to static meshes", "Replace selected instances with static meshes", EUserInterfaceActionType::Button, FInputChord()); UI_COMMAND(PluginCommand2, "Check negative scale", "Check selected actors and instances for containing negative scale values", EUserInterfaceActionType::Button, FInputChord()); } #undef LOCTEXT_NAMESPACE
InternalClockTradeAnim: ; Do the trading animation with the player's gameboy on the left. ; In-game trades and internally clocked link cable trades use this. ld a, [wTradedPlayerMonSpecies] ld [wLeftGBMonSpecies], a ld a, [wTradedEnemyMonSpecies] ld [wRightGBMonSpecies], a ld de, InternalClockTradeFuncSequence jr TradeAnimCommon ExternalClockTradeAnim: ; Do the trading animation with the player's gameboy on the right. ; Externally clocked link cable trades use this. ld a, [wTradedEnemyMonSpecies] ld [wLeftGBMonSpecies], a ld a, [wTradedPlayerMonSpecies] ld [wRightGBMonSpecies], a ld de, ExternalClockTradeFuncSequence TradeAnimCommon: ld a, [wOptions] push af ldh a, [hSCY] push af ldh a, [hSCX] push af xor a ld [wOptions], a ldh [hSCY], a ldh [hSCX], a push de .loop pop de ld a, [de] cp $ff jr z, .done inc de push de ld hl, TradeFuncPointerTable add a ld c, a ld b, $0 add hl, bc ld a, [hli] ld h, [hl] ld l, a ld de, .loop push de jp hl ; call trade func, which will return to the top of the loop .done pop af ldh [hSCX], a pop af ldh [hSCY], a pop af ld [wOptions], a ret addtradefunc: MACRO \1TradeFunc:: dw \1 ENDM tradefunc: MACRO db (\1TradeFunc - TradeFuncPointerTable) / 2 ENDM ; The functions in the sequences below are executed in order by TradeFuncCommon. ; They are from opposite perspectives. The external clock one makes use of ; Trade_SwapNames to swap the player and enemy names for some functions. InternalClockTradeFuncSequence: tradefunc LoadTradingGFXAndMonNames tradefunc Trade_ShowPlayerMon tradefunc Trade_DrawOpenEndOfLinkCable tradefunc Trade_AnimateBallEnteringLinkCable tradefunc Trade_AnimLeftToRight tradefunc Trade_Delay100 tradefunc Trade_ShowClearedWindow tradefunc PrintTradeWentToText tradefunc PrintTradeForSendsText tradefunc PrintTradeFarewellText tradefunc Trade_AnimRightToLeft tradefunc Trade_ShowClearedWindow tradefunc Trade_DrawOpenEndOfLinkCable tradefunc Trade_ShowEnemyMon tradefunc Trade_Delay100 tradefunc Trade_Cleanup db -1 ; end ExternalClockTradeFuncSequence: tradefunc LoadTradingGFXAndMonNames tradefunc Trade_ShowClearedWindow tradefunc PrintTradeWillTradeText tradefunc PrintTradeFarewellText tradefunc Trade_SwapNames tradefunc Trade_AnimLeftToRight tradefunc Trade_SwapNames tradefunc Trade_ShowClearedWindow tradefunc Trade_DrawOpenEndOfLinkCable tradefunc Trade_ShowEnemyMon tradefunc Trade_SlideTextBoxOffScreen tradefunc Trade_ShowPlayerMon tradefunc Trade_DrawOpenEndOfLinkCable tradefunc Trade_AnimateBallEnteringLinkCable tradefunc Trade_SwapNames tradefunc Trade_AnimRightToLeft tradefunc Trade_SwapNames tradefunc Trade_Delay100 tradefunc Trade_ShowClearedWindow tradefunc PrintTradeWentToText tradefunc Trade_Cleanup db -1 ; end TradeFuncPointerTable: addtradefunc LoadTradingGFXAndMonNames addtradefunc Trade_ShowPlayerMon addtradefunc Trade_DrawOpenEndOfLinkCable addtradefunc Trade_AnimateBallEnteringLinkCable addtradefunc Trade_ShowEnemyMon addtradefunc Trade_AnimLeftToRight addtradefunc Trade_AnimRightToLeft addtradefunc Trade_Delay100 addtradefunc Trade_ShowClearedWindow addtradefunc PrintTradeWentToText addtradefunc PrintTradeForSendsText addtradefunc PrintTradeFarewellText addtradefunc PrintTradeTakeCareText addtradefunc PrintTradeWillTradeText addtradefunc Trade_Cleanup addtradefunc Trade_SlideTextBoxOffScreen addtradefunc Trade_SwapNames Trade_Delay100: ld c, 100 jp DelayFrames Trade_CopyTileMapToVRAM: ld a, $1 ldh [hAutoBGTransferEnabled], a call Delay3 xor a ldh [hAutoBGTransferEnabled], a ret Trade_Delay80: ld c, 80 jp DelayFrames Trade_ClearTileMap: hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld a, " " jp FillMemory LoadTradingGFXAndMonNames: call Trade_ClearTileMap call DisableLCD ld hl, TradingAnimationGraphics ld de, vChars2 tile $31 ld bc, TradingAnimationGraphicsEnd - TradingAnimationGraphics ld a, BANK(TradingAnimationGraphics) call FarCopyData2 ld hl, TradingAnimationGraphics2 ld de, vSprites tile $7c ld bc, TradingAnimationGraphics2End - TradingAnimationGraphics2 ld a, BANK(TradingAnimationGraphics2) call FarCopyData2 ld hl, vBGMap0 ld bc, $800 ld a, " " call FillMemory call ClearSprites ld a, $ff ld [wUpdateSpritesEnabled], a ld hl, wd730 set 6, [hl] ; turn on instant text printing ld a, [wOnSGB] and a ld a, $e4 ; non-SGB OBP0 jr z, .next ld a, $f0 ; SGB OBP0 .next ldh [rOBP0], a call EnableLCD xor a ldh [hAutoBGTransferEnabled], a ld a, [wTradedPlayerMonSpecies] ld [wd11e], a call GetMonName ld hl, wcd6d ld de, wcf4b ld bc, NAME_LENGTH call CopyData ld a, [wTradedEnemyMonSpecies] ld [wd11e], a jp GetMonName Trade_LoadMonPartySpriteGfx: ld a, %11010000 ldh [rOBP1], a farjp LoadMonPartySpriteGfx Trade_SwapNames: ld hl, wPlayerName ld de, wBuffer ld bc, NAME_LENGTH call CopyData ld hl, wLinkEnemyTrainerName ld de, wPlayerName ld bc, NAME_LENGTH call CopyData ld hl, wBuffer ld de, wLinkEnemyTrainerName ld bc, NAME_LENGTH jp CopyData Trade_Cleanup: xor a call LoadGBPal ld hl, wd730 res 6, [hl] ; turn off instant text printing ret Trade_ShowPlayerMon: ld a, %10101011 ldh [rLCDC], a ld a, $50 ldh [hWY], a ld a, $86 ldh [rWX], a ldh [hSCX], a xor a ldh [hAutoBGTransferEnabled], a hlcoord 4, 0 ld b, 6 ld c, 10 call TextBoxBorder call Trade_PrintPlayerMonInfoText ld b, HIGH(vBGMap0) call CopyScreenTileBufferToVRAM call ClearScreen ld a, [wTradedPlayerMonSpecies] call Trade_LoadMonSprite ld a, $7e .slideScreenLoop push af call DelayFrame pop af ldh [rWX], a ldh [hSCX], a dec a dec a and a jr nz, .slideScreenLoop call Trade_Delay80 ld a, TRADE_BALL_POOF_ANIM call Trade_ShowAnimation ld a, TRADE_BALL_DROP_ANIM call Trade_ShowAnimation ; clears mon pic ld a, [wTradedPlayerMonSpecies] call PlayCry xor a ldh [hAutoBGTransferEnabled], a ret Trade_DrawOpenEndOfLinkCable: call Trade_ClearTileMap ld b, HIGH(vBGMap0) call CopyScreenTileBufferToVRAM ld b, SET_PAL_GENERIC call RunPaletteCommand ; This function call is pointless. It just copies blank tiles to VRAM that was ; already filled with blank tiles. ld hl, vBGMap1 + $8c call Trade_CopyCableTilesOffScreen ld a, $a0 ldh [hSCX], a call DelayFrame ld a, %10001011 ldh [rLCDC], a hlcoord 6, 2 ld b, TILEMAP_LINK_CABLE call CopyTileIDsFromList_ZeroBaseTileID call Trade_CopyTileMapToVRAM ld a, SFX_HEAL_HP call PlaySound ld c, 20 .loop ldh a, [hSCX] add 4 ldh [hSCX], a dec c jr nz, .loop ret Trade_AnimateBallEnteringLinkCable: ld a, TRADE_BALL_SHAKE_ANIM call Trade_ShowAnimation ld c, 10 call DelayFrames ld a, %11100100 ldh [rOBP0], a xor a ld [wLinkCableAnimBulgeToggle], a lb bc, $20, $60 .moveBallInsideLinkCableLoop push bc xor a ld de, Trade_BallInsideLinkCableOAM call WriteOAMBlock ld a, [wLinkCableAnimBulgeToggle] xor $1 ld [wLinkCableAnimBulgeToggle], a add $7e ld hl, wOAMBuffer + $02 ld de, 4 ld c, e .cycleLinkCableBulgeTile ld [hl], a add hl, de dec c jr nz, .cycleLinkCableBulgeTile call Delay3 pop bc ld a, c add $4 ld c, a cp $a0 jr nc, .ballSpriteReachedEdgeOfScreen ld a, SFX_TINK call PlaySound jr .moveBallInsideLinkCableLoop .ballSpriteReachedEdgeOfScreen call ClearSprites ld a, $1 ldh [hAutoBGTransferEnabled], a call ClearScreen ld b, $98 call CopyScreenTileBufferToVRAM call Delay3 xor a ldh [hAutoBGTransferEnabled], a ret Trade_BallInsideLinkCableOAM: dbsprite 0, 15, 0, 6, $7e, OAM_HFLIP dbsprite 8, 15, 0, 6, $7e, OAM_HFLIP | OAM_VFLIP Trade_ShowEnemyMon: ld a, TRADE_BALL_TILT_ANIM call Trade_ShowAnimation call Trade_ShowClearedWindow hlcoord 4, 10 ld b, 6 ld c, 10 call TextBoxBorder call Trade_PrintEnemyMonInfoText call Trade_CopyTileMapToVRAM ld a, $1 ldh [hAutoBGTransferEnabled], a ld a, [wTradedEnemyMonSpecies] call Trade_LoadMonSprite ld a, TRADE_BALL_POOF_ANIM call Trade_ShowAnimation ld a, $1 ldh [hAutoBGTransferEnabled], a ld a, [wTradedEnemyMonSpecies] call PlayCry call Trade_Delay100 hlcoord 4, 10 lb bc, 8, 12 call ClearScreenArea jp PrintTradeTakeCareText Trade_AnimLeftToRight: ; Animates the mon moving from the left GB to the right one. call Trade_InitGameboyTransferGfx ld a, $1 ld [wTradedMonMovingRight], a ld a, %11100100 ldh [rOBP0], a ld a, $54 ld [wBaseCoordX], a ld a, $1c ld [wBaseCoordY], a ld a, [wLeftGBMonSpecies] ld [wMonPartySpriteSpecies], a call Trade_WriteCircledMonOAM call Trade_DrawLeftGameboy call Trade_CopyTileMapToVRAM call Trade_DrawCableAcrossScreen ld hl, vBGMap1 + $8c call Trade_CopyCableTilesOffScreen ld b, $6 call Trade_AnimMonMoveHorizontal ld a, $1 ldh [hAutoBGTransferEnabled], a call Trade_DrawCableAcrossScreen ld b, $4 call Trade_AnimMonMoveHorizontal call Trade_DrawRightGameboy ld b, $6 call Trade_AnimMonMoveHorizontal xor a ldh [hAutoBGTransferEnabled], a call Trade_AnimMonMoveVertical jp ClearSprites Trade_AnimRightToLeft: ; Animates the mon moving from the right GB to the left one. call Trade_InitGameboyTransferGfx xor a ld [wTradedMonMovingRight], a ld a, $64 ld [wBaseCoordX], a ld a, $44 ld [wBaseCoordY], a ld a, [wRightGBMonSpecies] ld [wMonPartySpriteSpecies], a call Trade_WriteCircledMonOAM call Trade_DrawRightGameboy call Trade_CopyTileMapToVRAM call Trade_DrawCableAcrossScreen ld hl, vBGMap1 + $94 call Trade_CopyCableTilesOffScreen call Trade_AnimMonMoveVertical ld b, $6 call Trade_AnimMonMoveHorizontal ld a, $1 ldh [hAutoBGTransferEnabled], a call Trade_DrawCableAcrossScreen ld b, $4 call Trade_AnimMonMoveHorizontal call Trade_DrawLeftGameboy ld b, $6 call Trade_AnimMonMoveHorizontal xor a ldh [hAutoBGTransferEnabled], a jp ClearSprites Trade_InitGameboyTransferGfx: ; Initialises the graphics for showing a mon moving between gameboys. ld a, $1 ldh [hAutoBGTransferEnabled], a call ClearScreen xor a ldh [hAutoBGTransferEnabled], a call Trade_LoadMonPartySpriteGfx call DelayFrame ld a, %10101011 ldh [rLCDC], a xor a ldh [hSCX], a ld a, $90 ldh [hWY], a ret Trade_DrawLeftGameboy: call Trade_ClearTileMap ; draw link cable hlcoord 11, 4 ld a, $5d ld [hli], a ld a, $5e ld c, 8 .loop ld [hli], a dec c jr nz, .loop ; draw gameboy pic hlcoord 5, 3 ld b, TILEMAP_GAME_BOY call CopyTileIDsFromList_ZeroBaseTileID ; draw text box with player name below gameboy pic hlcoord 4, 12 ld b, 2 ld c, 7 call TextBoxBorder hlcoord 5, 14 ld de, wPlayerName call PlaceString jp DelayFrame Trade_DrawRightGameboy: call Trade_ClearTileMap ; draw horizontal segment of link cable hlcoord 0, 4 ld a, $5e ld c, $e .loop ld [hli], a dec c jr nz, .loop ; draw vertical segment of link cable ld a, $5f ld [hl], a ld de, SCREEN_WIDTH add hl, de ld a, $61 ld [hl], a add hl, de ld [hl], a add hl, de ld [hl], a add hl, de ld [hl], a add hl, de ld a, $60 ld [hld], a ld a, $5d ld [hl], a ; draw gameboy pic hlcoord 7, 8 ld b, TILEMAP_GAME_BOY call CopyTileIDsFromList_ZeroBaseTileID ; draw text box with enemy name above link cable hlcoord 6, 0 ld b, 2 ld c, 7 call TextBoxBorder hlcoord 7, 2 ld de, wLinkEnemyTrainerName call PlaceString jp DelayFrame Trade_DrawCableAcrossScreen: ; Draws the link cable across the screen. call Trade_ClearTileMap hlcoord 0, 4 ld a, $5e ld c, SCREEN_WIDTH .loop ld [hli], a dec c jr nz, .loop ret Trade_CopyCableTilesOffScreen: ; This is used to copy the link cable tiles off screen so that the cable ; continues when the screen is scrolled. push hl hlcoord 0, 4 call CopyToRedrawRowOrColumnSrcTiles pop hl ld a, h ldh [hRedrawRowOrColumnDest + 1], a ld a, l ldh [hRedrawRowOrColumnDest], a ld a, REDRAW_ROW ldh [hRedrawRowOrColumnMode], a ld c, 10 jp DelayFrames Trade_AnimMonMoveHorizontal: ; Animates the mon going through the link cable horizontally over a distance of ; b 16-pixel units. ld a, [wTradedMonMovingRight] ld e, a ld d, $8 .scrollLoop ld a, e dec a jr z, .movingRight ; moving left ldh a, [hSCX] sub $2 jr .next .movingRight ldh a, [hSCX] add $2 .next ldh [hSCX], a call DelayFrame dec d jr nz, .scrollLoop call Trade_AnimCircledMon dec b jr nz, Trade_AnimMonMoveHorizontal ret Trade_AnimCircledMon: ; Cycles between the two animation frames of the mon party sprite, cycles ; between a circle and an oval around the mon sprite, and makes the cable flash. push de push bc push hl ldh a, [rBGP] xor $3c ; make link cable flash ldh [rBGP], a ld hl, wOAMBuffer + $02 ld de, $4 ld c, $14 .loop ld a, [hl] xor ICONOFFSET ld [hl], a add hl, de dec c jr nz, .loop pop hl pop bc pop de ret Trade_WriteCircledMonOAM: farcall WriteMonPartySpriteOAMBySpecies call Trade_WriteCircleOAM Trade_AddOffsetsToOAMCoords: ld hl, wOAMBuffer ld c, $14 .loop ld a, [wBaseCoordY] add [hl] ld [hli], a ld a, [wBaseCoordX] add [hl] ld [hli], a inc hl inc hl dec c jr nz, .loop ret Trade_AnimMonMoveVertical: ; Animates the mon going through the link cable vertically as well as ; horizontally for a bit. The last bit of horizontal movement (when moving ; right) or the first bit of horizontal movement (when moving left) are done ; here instead of Trade_AnimMonMoveHorizontal because this function moves the ; sprite itself rather than scrolling the screen around the sprite. Moving the ; sprite itself is necessary because the vertical segment of the link cable is ; to the right of the screen position that the mon sprite has when ; Trade_AnimMonMoveHorizontal is executing. ld a, [wTradedMonMovingRight] and a jr z, .movingLeft ; moving right lb bc, 4, 0 ; move right call .doAnim lb bc, 0, 10 ; move down jr .doAnim .movingLeft lb bc, 0, -10 ; move up call .doAnim lb bc, -4, 0 ; move left .doAnim ld a, b ld [wBaseCoordX], a ld a, c ld [wBaseCoordY], a ld d, $4 .loop call Trade_AddOffsetsToOAMCoords call Trade_AnimCircledMon ld c, 8 call DelayFrames dec d jr nz, .loop ret Trade_WriteCircleOAM: ; Writes the OAM blocks for the circle around the traded mon as it passes ; the link cable. ld hl, Trade_CircleOAMPointers ld c, $4 xor a .loop push bc ld e, [hl] inc hl ld d, [hl] inc hl ld c, [hl] inc hl ld b, [hl] inc hl push hl inc a push af call WriteOAMBlock pop af pop hl pop bc dec c jr nz, .loop ret trade_circle_oam: MACRO dw \1 db \2, \3 ENDM Trade_CircleOAMPointers: ; oam pointer, upper-left x coord, upper-left y coord trade_circle_oam Trade_CircleOAM0, $08, $08 trade_circle_oam Trade_CircleOAM1, $18, $08 trade_circle_oam Trade_CircleOAM2, $08, $18 trade_circle_oam Trade_CircleOAM3, $18, $18 Trade_CircleOAM0: dbsprite 2, 7, 0, 0, ICON_TRADEBUBBLE << 2 + 1, OAM_OBP1 dbsprite 2, 7, 0, 2, ICON_TRADEBUBBLE << 2 + 3, OAM_OBP1 Trade_CircleOAM1: dbsprite 6, 7, 0, 1, ICON_TRADEBUBBLE << 2 + 0, OAM_OBP1 | OAM_HFLIP dbsprite 6, 7, 0, 3, ICON_TRADEBUBBLE << 2 + 2, OAM_OBP1 | OAM_HFLIP Trade_CircleOAM2: dbsprite 10, 7, 0, 2, ICON_TRADEBUBBLE << 2 + 3, OAM_OBP1 | OAM_VFLIP dbsprite 10, 7, 0, 0, ICON_TRADEBUBBLE << 2 + 1, OAM_OBP1 | OAM_VFLIP Trade_CircleOAM3: dbsprite 14, 7, 0, 3, ICON_TRADEBUBBLE << 2 + 2, OAM_OBP1 | OAM_HFLIP | OAM_VFLIP dbsprite 14, 7, 0, 1, ICON_TRADEBUBBLE << 2 + 0, OAM_OBP1 | OAM_HFLIP | OAM_VFLIP ; a = species Trade_LoadMonSprite: ld [wcf91], a ld [wd0b5], a ld [wWholeScreenPaletteMonSpecies], a ld b, SET_PAL_POKEMON_WHOLE_SCREEN ld c, 0 call RunPaletteCommand ldh a, [hAutoBGTransferEnabled] xor $1 ldh [hAutoBGTransferEnabled], a call GetMonHeader hlcoord 7, 2 call LoadFlippedFrontSpriteByMonIndex ld c, 10 jp DelayFrames Trade_ShowClearedWindow: ; clears the window and covers the BG entirely with the window ld a, $1 ldh [hAutoBGTransferEnabled], a call ClearScreen ld a, %11100011 ldh [rLCDC], a ld a, $7 ldh [rWX], a xor a ldh [hWY], a ld a, $90 ldh [hSCX], a ret Trade_SlideTextBoxOffScreen: ; Slides the window right until it's off screen. The window usually just has ; a text box at the bottom when this is called. However, when this is called ; after Trade_ShowEnemyMon in the external clock sequence, there is a mon pic ; above the text box and it is also scrolled off the screen. ld c, 50 call DelayFrames .loop call DelayFrame ldh a, [rWX] inc a inc a ldh [rWX], a cp $a1 jr nz, .loop call Trade_ClearTileMap ld c, 10 call DelayFrames ld a, $7 ldh [rWX], a ret PrintTradeWentToText: ld hl, TradeWentToText call PrintText ld c, 200 call DelayFrames jp Trade_SlideTextBoxOffScreen TradeWentToText: text_far _TradeWentToText text_end PrintTradeForSendsText: ld hl, TradeForText call PrintText call Trade_Delay80 ld hl, TradeSendsText call PrintText jp Trade_Delay80 TradeForText: text_far _TradeForText text_end TradeSendsText: text_far _TradeSendsText text_end PrintTradeFarewellText: ld hl, TradeWavesFarewellText call PrintText call Trade_Delay80 ld hl, TradeTransferredText call PrintText call Trade_Delay80 jp Trade_SlideTextBoxOffScreen TradeWavesFarewellText: text_far _TradeWavesFarewellText text_end TradeTransferredText: text_far _TradeTransferredText text_end PrintTradeTakeCareText: ld hl, TradeTakeCareText call PrintText jp Trade_Delay80 TradeTakeCareText: text_far _TradeTakeCareText text_end PrintTradeWillTradeText: ld hl, TradeWillTradeText call PrintText call Trade_Delay80 ld hl, TradeforText call PrintText jp Trade_Delay80 TradeWillTradeText: text_far _TradeWillTradeText text_end TradeforText: text_far _TradeforText text_end Trade_ShowAnimation: ld [wAnimationID], a xor a ld [wAnimationType], a predef_jump MoveAnimation
processor 6502 ORG $2000 + 8000 include "player_const.asm" include "soundfxinterface.asm" include "soundfxinstruments.asm"
; ; z88dk library: Generic VDP support code ; ; int msx_vram(); ; ; Detects the VRAM size (in KB) ; ; $Id: gen_vram.asm,v 1.1 2010/06/30 13:21:38 stefano Exp $ ; XLIB msx_vram INCLUDE "msx/vdp.inc" msx_vram: ld hl,VRAM_SIZE ret
<<<<<<< HEAD ;/* ; * FreeRTOS Kernel <DEVELOPMENT BRANCH> ; * Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * SPDX-License-Identifier: MIT ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in ; * the Software without restriction, including without limitation the rights to ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of ; * the Software, and to permit persons to whom the Software is furnished to do so, ; * subject to the following conditions: ; * ; * The above copyright notice and this permission notice shall be included in all ; * copies or substantial portions of the Software. ; * ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ; * ; * https://www.FreeRTOS.org ; * https://github.com/FreeRTOS ; * ; */ ; * The definition of the "register test" tasks, as described at the top of ; * main.c .include data_model.h .global xTaskIncrementTick .global vTaskSwitchContext .global vPortSetupTimerInterrupt .global pxCurrentTCB .global usCriticalNesting .def vPortPreemptiveTickISR .def vPortCooperativeTickISR .def vPortYield .def xPortStartScheduler ;----------------------------------------------------------- portSAVE_CONTEXT .macro ;Save the remaining registers. pushm_x #12, r15 mov.w &usCriticalNesting, r14 push_x r14 mov_x &pxCurrentTCB, r12 mov_x sp, 0( r12 ) .endm ;----------------------------------------------------------- portRESTORE_CONTEXT .macro mov_x &pxCurrentTCB, r12 mov_x @r12, sp pop_x r15 mov.w r15, &usCriticalNesting popm_x #12, r15 nop pop.w sr nop ret_x .endm ;----------------------------------------------------------- ;* ;* The RTOS tick ISR. ;* ;* If the cooperative scheduler is in use this simply increments the tick ;* count. ;* ;* If the preemptive scheduler is in use a context switch can also occur. ;*/ .text .align 2 vPortPreemptiveTickISR: .asmfunc ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs ;to save it manually before it gets modified (interrupts get disabled). push.w sr portSAVE_CONTEXT call_x #xTaskIncrementTick call_x #vTaskSwitchContext portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- .align 2 vPortCooperativeTickISR: .asmfunc ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs ;to save it manually before it gets modified (interrupts get disabled). push.w sr portSAVE_CONTEXT call_x #xTaskIncrementTick portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- ; ; Manual context switch called by the portYIELD() macro. ; .align 2 vPortYield: .asmfunc ; The sr needs saving before it is modified. push.w sr ; Now the SR is stacked we can disable interrupts. dint nop ; Save the context of the current task. portSAVE_CONTEXT ; Select the next task to run. call_x #vTaskSwitchContext ; Restore the context of the new task. portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- ; ; Start off the scheduler by initialising the RTOS tick timer, then restoring ; the context of the first task. ; .align 2 xPortStartScheduler: .asmfunc ; Setup the hardware to generate the tick. Interrupts are disabled ; when this function is called. call_x #vPortSetupTimerInterrupt ; Restore the context of the first task that is going to run. portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- .end ======= ;/* ; * FreeRTOS SMP Kernel V202110.00 ; * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. ; * ; * Permission is hereby granted, free of charge, to any person obtaining a copy of ; * this software and associated documentation files (the "Software"), to deal in ; * the Software without restriction, including without limitation the rights to ; * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of ; * the Software, and to permit persons to whom the Software is furnished to do so, ; * subject to the following conditions: ; * ; * The above copyright notice and this permission notice shall be included in all ; * copies or substantial portions of the Software. ; * ; * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS ; * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR ; * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER ; * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN ; * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ; * ; * https://www.FreeRTOS.org ; * https://github.com/FreeRTOS ; * ; * 1 tab == 4 spaces! ; */ ; * The definition of the "register test" tasks, as described at the top of ; * main.c .include data_model.h .global xTaskIncrementTick .global vTaskSwitchContext .global vPortSetupTimerInterrupt .global pxCurrentTCB .global usCriticalNesting .def vPortPreemptiveTickISR .def vPortCooperativeTickISR .def vPortYield .def xPortStartScheduler ;----------------------------------------------------------- portSAVE_CONTEXT .macro ;Save the remaining registers. pushm_x #12, r15 mov.w &usCriticalNesting, r14 push_x r14 mov_x &pxCurrentTCB, r12 mov_x sp, 0( r12 ) .endm ;----------------------------------------------------------- portRESTORE_CONTEXT .macro mov_x &pxCurrentTCB, r12 mov_x @r12, sp pop_x r15 mov.w r15, &usCriticalNesting popm_x #12, r15 nop pop.w sr nop ret_x .endm ;----------------------------------------------------------- ;* ;* The RTOS tick ISR. ;* ;* If the cooperative scheduler is in use this simply increments the tick ;* count. ;* ;* If the preemptive scheduler is in use a context switch can also occur. ;*/ .text .align 2 vPortPreemptiveTickISR: .asmfunc ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs ;to save it manually before it gets modified (interrupts get disabled). push.w sr portSAVE_CONTEXT call_x #xTaskIncrementTick call_x #vTaskSwitchContext portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- .align 2 vPortCooperativeTickISR: .asmfunc ; The sr is not saved in portSAVE_CONTEXT() because vPortYield() needs ;to save it manually before it gets modified (interrupts get disabled). push.w sr portSAVE_CONTEXT call_x #xTaskIncrementTick portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- ; ; Manual context switch called by the portYIELD() macro. ; .align 2 vPortYield: .asmfunc ; The sr needs saving before it is modified. push.w sr ; Now the SR is stacked we can disable interrupts. dint nop ; Save the context of the current task. portSAVE_CONTEXT ; Select the next task to run. call_x #vTaskSwitchContext ; Restore the context of the new task. portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- ; ; Start off the scheduler by initialising the RTOS tick timer, then restoring ; the context of the first task. ; .align 2 xPortStartScheduler: .asmfunc ; Setup the hardware to generate the tick. Interrupts are disabled ; when this function is called. call_x #vPortSetupTimerInterrupt ; Restore the context of the first task that is going to run. portRESTORE_CONTEXT .endasmfunc ;----------------------------------------------------------- .end >>>>>>> origin/smp
.data inp: .asciiz "Enter some capital alphabet: " out: .asciiz "\nThe lower alphabet is: " .text .globl main .ent main main: # print input message li $v0, 4 la $a0, inp syscall # get character input li $v0, 12 syscall move $t0, $v0 #calculations addi $s0, $t0, 32 # print output li $v0, 4 la $a0, out syscall li $v0, 11 move $a0, $s0 syscall jr $ra .end main
; A339051: Even bisection of the infinite Fibonacci word A096270. ; 0,0,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,1,0 mul $0,2 add $0,1 seq $0,189661 ; Fixed point of the morphism 0->010, 1->10 starting with 0. cmp $0,0
ORG 0H; LJMP MAIN; MAIN: MOV TMOD, #01H; MOV P1, #0FFH; START: MOV A, #20H; LOWER BYTE CPL A; ADD A, #1D; MOV R0, A; MOV A, #4EH; UPPER BYTE ACALL CHECK_CARRY; MOV R2, #200D; CPL P1.4; CPL P1.5; CPL P1.6; CPL P1.7; ACALL DELAY; CPL P1.4; CPL P1.5; CPL P1.6; CPL P1.7; MOV R2, #200D; ACALL DELAY; LJMP START; DELAY: AGAIN: MOV TL0, R0; MOV TH0, R1; SETB TR0; HERE: JNB TF0, HERE; CLR TR0; CLR TF0; DJNZ R2, AGAIN; RET; CHECK_CARRY: CPL A; JNC GO; ADD A, #1D; GO: MOV R1, A; RET; END;
// -------------------------------------------------------------------------- // OpenMS -- Open-Source Mass Spectrometry // -------------------------------------------------------------------------- // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen, // ETH Zurich, and Freie Universitaet Berlin 2002-2016. // // This software is released under a three-clause BSD license: // * 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 any author or any participating institution // may be used to endorse or promote products derived from this software // without specific prior written permission. // For a full list of authors, refer to the file AUTHORS. // -------------------------------------------------------------------------- // 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 ANY OF THE AUTHORS OR THE CONTRIBUTING // INSTITUTIONS 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. // // -------------------------------------------------------------------------- // $Maintainer: Mathias Walzer $ // $Authors: $ // -------------------------------------------------------------------------- // #include <OpenMS/COMPARISON/CLUSTERING/AverageLinkage.h> #include <OpenMS/DATASTRUCTURES/String.h> namespace OpenMS { /// creates a new instance of a AverageLinkage object ClusterFunctor * AverageLinkage::create() { return new AverageLinkage(); } /// get the identifier for this object const String AverageLinkage::getProductName() { return "AverageLinkage"; } AverageLinkage::AverageLinkage() : ClusterFunctor(), ProgressLogger() { } AverageLinkage::AverageLinkage(const AverageLinkage & source) : ClusterFunctor(source), ProgressLogger(source) { } AverageLinkage::~AverageLinkage() { } AverageLinkage & AverageLinkage::operator=(const AverageLinkage & source) { if (this != &source) { ClusterFunctor::operator=(source); ProgressLogger::operator=(source); } return *this; } void AverageLinkage::operator()(DistanceMatrix<float> & original_distance, std::vector<BinaryTreeNode> & cluster_tree, const float threshold /*=1*/) const { // input MUST have >= 2 elements! if (original_distance.dimensionsize() < 2) { throw ClusterFunctor::InsufficientInput(__FILE__, __LINE__, __PRETTY_FUNCTION__, "Distance matrix to start from only contains one element"); } std::vector<std::set<Size> > clusters(original_distance.dimensionsize()); for (Size i = 0; i < original_distance.dimensionsize(); ++i) { clusters[i].insert(i); } cluster_tree.clear(); cluster_tree.reserve(original_distance.dimensionsize() - 1); // Initial minimum-distance pair original_distance.updateMinElement(); std::pair<Size, Size> min = original_distance.getMinElementCoordinates(); Size overall_cluster_steps(original_distance.dimensionsize()); startProgress(0, original_distance.dimensionsize(), "clustering data"); while (original_distance(min.second, min.first) < threshold) { //grow the tree cluster_tree.push_back(BinaryTreeNode(*(clusters[min.second].begin()), *(clusters[min.first].begin()), original_distance(min.first, min.second))); if (cluster_tree.back().left_child > cluster_tree.back().right_child) { std::swap(cluster_tree.back().left_child, cluster_tree.back().right_child); } if (original_distance.dimensionsize() > 2) { //pick minimum-distance pair i,j and merge them //calculate parameter for lance-williams formula float alpha_i = (float)(clusters[min.first].size() / (float)(clusters[min.first].size() + clusters[min.second].size())); float alpha_j = (float)(clusters[min.second].size() / (float)(clusters[min.first].size() + clusters[min.second].size())); //~ std::cout << alpha_i << '\t' << alpha_j << std::endl; //pushback elements of second to first (and then erase second) clusters[min.second].insert(clusters[min.first].begin(), clusters[min.first].end()); // erase first one clusters.erase(clusters.begin() + min.first); //update original_distance matrix //average linkage: new distance between clusters is the minimum distance between elements of each cluster //lance-williams update for d((i,j),k): (m_i/m_i+m_j)* d(i,k) + (m_j/m_i+m_j)* d(j,k) ; m_x is the number of elements in cluster x for (Size k = 0; k < min.second; ++k) { float dik = original_distance.getValue(min.first, k); float djk = original_distance.getValue(min.second, k); original_distance.setValueQuick(min.second, k, (alpha_i * dik + alpha_j * djk)); } for (Size k = min.second + 1; k < original_distance.dimensionsize(); ++k) { float dik = original_distance.getValue(min.first, k); float djk = original_distance.getValue(min.second, k); original_distance.setValueQuick(k, min.second, (alpha_i * dik + alpha_j * djk)); } //reduce original_distance.reduce(min.first); //update minimum-distance pair original_distance.updateMinElement(); //get min-pair from triangular matrix min = original_distance.getMinElementCoordinates(); } else { break; } setProgress(overall_cluster_steps - original_distance.dimensionsize()); //repeat until only two cluster remains, last step skips matrix operations } //fill tree with dummy nodes Size sad(*clusters.front().begin()); for (Size i = 1; (i < clusters.size()) && (cluster_tree.size() < cluster_tree.capacity()); ++i) { cluster_tree.push_back(BinaryTreeNode(sad, *clusters[i].begin(), -1.0)); } endProgress(); } }
; A285684: Characteristic sequence of the Beatty sequence, A022838, of sqrt(3). ; 0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,1 mov $4,2 mov $5,$0 lpb $4,1 mov $0,$5 sub $4,1 add $0,$4 add $0,1 mov $3,$0 cal $3,195129 ; a(n) = 2*n - floor(n*sqrt(1/3)). mov $2,$4 mov $6,$3 sub $6,2 lpb $2,1 mov $1,$6 sub $2,1 lpe lpe lpb $5,1 sub $1,$6 mov $5,0 lpe sub $1,1
softwares/hello/output/hello.merl: file format elf32-littleriscv Disassembly of section .init: 20000000 <_start>: 20000000: 00000297 auipc t0,0x0 20000004: 02828293 addi t0,t0,40 # 20000028 <_stext> 20000008: 30529073 csrw mtvec,t0 2000000c: f0000197 auipc gp,0xf0000 20000010: ff418193 addi gp,gp,-12 # 10000000 <mcause_trap_table> 20000014: f0001117 auipc sp,0xf0001 20000018: fec10113 addi sp,sp,-20 # 10001000 <__stack_top> 2000001c: 00010433 add s0,sp,zero 20000020: 35c0006f j 2000037c <main> Disassembly of section .text: 20000028 <_stext>: 20000028: f8010113 addi sp,sp,-128 2000002c: 00000013 nop 20000030: 00112223 sw ra,4(sp) 20000034: 00212423 sw sp,8(sp) 20000038: 00312623 sw gp,12(sp) 2000003c: 00412823 sw tp,16(sp) 20000040: 00512a23 sw t0,20(sp) 20000044: 00612c23 sw t1,24(sp) 20000048: 00712e23 sw t2,28(sp) 2000004c: 02812023 sw s0,32(sp) 20000050: 02912223 sw s1,36(sp) 20000054: 02a12423 sw a0,40(sp) 20000058: 02b12623 sw a1,44(sp) 2000005c: 02c12823 sw a2,48(sp) 20000060: 02d12a23 sw a3,52(sp) 20000064: 02e12c23 sw a4,56(sp) 20000068: 02f12e23 sw a5,60(sp) 2000006c: 05012023 sw a6,64(sp) 20000070: 05112223 sw a7,68(sp) 20000074: 05212423 sw s2,72(sp) 20000078: 05312623 sw s3,76(sp) 2000007c: 05412823 sw s4,80(sp) 20000080: 05512a23 sw s5,84(sp) 20000084: 05612c23 sw s6,88(sp) 20000088: 05712e23 sw s7,92(sp) 2000008c: 07812023 sw s8,96(sp) 20000090: 07912223 sw s9,100(sp) 20000094: 07a12423 sw s10,104(sp) 20000098: 07b12623 sw s11,108(sp) 2000009c: 07c12823 sw t3,112(sp) 200000a0: 07d12a23 sw t4,116(sp) 200000a4: 07e12c23 sw t5,120(sp) 200000a8: 07f12e23 sw t6,124(sp) 200000ac: 34202573 csrr a0,mcause 200000b0: 341025f3 csrr a1,mepc 200000b4: 00010613 mv a2,sp 200000b8: 218000ef jal ra,200002d0 <handle_trap> 200000bc: 34151073 csrw mepc,a0 200000c0: 00412083 lw ra,4(sp) 200000c4: 00812103 lw sp,8(sp) 200000c8: 00c12183 lw gp,12(sp) 200000cc: 01012203 lw tp,16(sp) 200000d0: 01412283 lw t0,20(sp) 200000d4: 01812303 lw t1,24(sp) 200000d8: 01c12383 lw t2,28(sp) 200000dc: 02012403 lw s0,32(sp) 200000e0: 02412483 lw s1,36(sp) 200000e4: 02812503 lw a0,40(sp) 200000e8: 02c12583 lw a1,44(sp) 200000ec: 03012603 lw a2,48(sp) 200000f0: 03412683 lw a3,52(sp) 200000f4: 03812703 lw a4,56(sp) 200000f8: 03c12783 lw a5,60(sp) 200000fc: 04012803 lw a6,64(sp) 20000100: 04412883 lw a7,68(sp) 20000104: 04812903 lw s2,72(sp) 20000108: 04c12983 lw s3,76(sp) 2000010c: 05012a03 lw s4,80(sp) 20000110: 05412a83 lw s5,84(sp) 20000114: 05812b03 lw s6,88(sp) 20000118: 05c12b83 lw s7,92(sp) 2000011c: 06012c03 lw s8,96(sp) 20000120: 06412c83 lw s9,100(sp) 20000124: 06812d03 lw s10,104(sp) 20000128: 06c12d83 lw s11,108(sp) 2000012c: 07012e03 lw t3,112(sp) 20000130: 07412e83 lw t4,116(sp) 20000134: 07812f03 lw t5,120(sp) 20000138: 07c12f83 lw t6,124(sp) 2000013c: 08010113 addi sp,sp,128 20000140: 30200073 mret 20000144: 0000 unimp 20000146: 0000 unimp 20000148 <__timer_handler>: 20000148: 40000437 lui s0,0x40000 2000014c: 00000293 li t0,0 20000150: 10042823 sw zero,272(s0) # 40000110 <_etext+0x1ffffd64> 20000154: 10b42023 sw a1,256(s0) 20000158: 10542a23 sw t0,276(s0) 2000015c: 00542023 sw t0,0(s0) 20000160: 30029073 csrw mstatus,t0 20000164: 30429073 csrw mie,t0 20000168: 30200073 mret 2000016c <delay>: 2000016c: fd010113 addi sp,sp,-48 20000170: 02812623 sw s0,44(sp) 20000174: 03010413 addi s0,sp,48 20000178: fca42e23 sw a0,-36(s0) 2000017c: 400007b7 lui a5,0x40000 20000180: 10c78793 addi a5,a5,268 # 4000010c <_etext+0x1ffffd60> 20000184: fef42623 sw a5,-20(s0) 20000188: fec42783 lw a5,-20(s0) 2000018c: fdc42703 lw a4,-36(s0) 20000190: 00e7a023 sw a4,0(a5) 20000194: 40000437 lui s0,0x40000 20000198: 10042823 sw zero,272(s0) # 40000110 <_etext+0x1ffffd64> 2000019c: 08000293 li t0,128 200001a0: 00800313 li t1,8 200001a4: 30031073 csrw mstatus,t1 200001a8: 30429073 csrw mie,t0 200001ac: 000205b7 lui a1,0x20 200001b0: 00258593 addi a1,a1,2 # 20002 <mcause_trap_table-0xffdfffe> 200001b4: 10b42023 sw a1,256(s0) 200001b8: 00100293 li t0,1 200001bc: 10542a23 sw t0,276(s0) 200001c0: 00542023 sw t0,0(s0) 200001c4: 200002b7 lui t0,0x20000 200001c8: 50028293 addi t0,t0,1280 # 20000500 <_etext+0x154> 200001cc: 30529073 csrw mtvec,t0 200001d0: 10500073 wfi 200001d4: 00000013 nop 200001d8: 02c12403 lw s0,44(sp) 200001dc: 03010113 addi sp,sp,48 200001e0: 00008067 ret 200001e4 <PWM_DUTYCYCLE>: 200001e4: fd010113 addi sp,sp,-48 200001e8: 02812623 sw s0,44(sp) 200001ec: 03010413 addi s0,sp,48 200001f0: fca42e23 sw a0,-36(s0) 200001f4: fcb42c23 sw a1,-40(s0) 200001f8: fdc42703 lw a4,-36(s0) 200001fc: 00100793 li a5,1 20000200: 02f71e63 bne a4,a5,2000023c <PWM_DUTYCYCLE+0x58> 20000204: 400b07b7 lui a5,0x400b0 20000208: 00c78793 addi a5,a5,12 # 400b000c <_etext+0x200afc60> 2000020c: fef42423 sw a5,-24(s0) 20000210: fe842783 lw a5,-24(s0) 20000214: fd842703 lw a4,-40(s0) 20000218: 00e7a023 sw a4,0(a5) 2000021c: 400b0437 lui s0,0x400b0 20000220: 01400313 li t1,20 20000224: 00642023 sw t1,0(s0) # 400b0000 <_etext+0x200afc54> 20000228: 00200313 li t1,2 2000022c: 00642223 sw t1,4(s0) 20000230: 00300313 li t1,3 20000234: 00642423 sw t1,8(s0) 20000238: 0380006f j 20000270 <PWM_DUTYCYCLE+0x8c> 2000023c: 400b07b7 lui a5,0x400b0 20000240: 01c78793 addi a5,a5,28 # 400b001c <_etext+0x200afc70> 20000244: fef42623 sw a5,-20(s0) 20000248: fec42783 lw a5,-20(s0) 2000024c: fd842703 lw a4,-40(s0) 20000250: 00e7a023 sw a4,0(a5) 20000254: 400b0437 lui s0,0x400b0 20000258: 01400313 li t1,20 2000025c: 00642823 sw t1,16(s0) # 400b0010 <_etext+0x200afc64> 20000260: 00200313 li t1,2 20000264: 00642a23 sw t1,20(s0) 20000268: 00300313 li t1,3 2000026c: 00642c23 sw t1,24(s0) 20000270: 00000013 nop 20000274: 02c12403 lw s0,44(sp) 20000278: 03010113 addi sp,sp,48 2000027c: 00008067 ret 20000280 <extract_ie_code>: 20000280: fd010113 addi sp,sp,-48 20000284: 02812623 sw s0,44(sp) 20000288: 03010413 addi s0,sp,48 2000028c: fca42e23 sw a0,-36(s0) 20000290: fdc42703 lw a4,-36(s0) 20000294: 800007b7 lui a5,0x80000 20000298: fff7c793 not a5,a5 2000029c: 00f777b3 and a5,a4,a5 200002a0: fef42623 sw a5,-20(s0) 200002a4: fec42783 lw a5,-20(s0) 200002a8: 00078513 mv a0,a5 200002ac: 02c12403 lw s0,44(sp) 200002b0: 03010113 addi sp,sp,48 200002b4: 00008067 ret 200002b8 <default_handler>: 200002b8: fe010113 addi sp,sp,-32 200002bc: 00812e23 sw s0,28(sp) 200002c0: 02010413 addi s0,sp,32 200002c4: fea42623 sw a0,-20(s0) 200002c8: feb42423 sw a1,-24(s0) 200002cc: 0000006f j 200002cc <default_handler+0x14> 200002d0 <handle_trap>: 200002d0: fd010113 addi sp,sp,-48 200002d4: 02112623 sw ra,44(sp) 200002d8: 02812423 sw s0,40(sp) 200002dc: 03010413 addi s0,sp,48 200002e0: fca42e23 sw a0,-36(s0) 200002e4: fcb42c23 sw a1,-40(s0) 200002e8: fe042623 sw zero,-20(s0) 200002ec: fe042423 sw zero,-24(s0) 200002f0: 01f00793 li a5,31 200002f4: fef42423 sw a5,-24(s0) 200002f8: fe842783 lw a5,-24(s0) 200002fc: 00100713 li a4,1 20000300: 00f717b3 sll a5,a4,a5 20000304: 00078713 mv a4,a5 20000308: fdc42783 lw a5,-36(s0) 2000030c: 00f777b3 and a5,a4,a5 20000310: 02078a63 beqz a5,20000344 <handle_trap+0x74> 20000314: fdc42503 lw a0,-36(s0) 20000318: f69ff0ef jal ra,20000280 <extract_ie_code> 2000031c: fea42623 sw a0,-20(s0) 20000320: 00818713 addi a4,gp,8 # 10000008 <mcause_interrupt_table> 20000324: fec42783 lw a5,-20(s0) 20000328: 00279793 slli a5,a5,0x2 2000032c: 00f707b3 add a5,a4,a5 20000330: 0007a783 lw a5,0(a5) # 80000000 <_etext+0x5ffffc54> 20000334: fd842583 lw a1,-40(s0) 20000338: fdc42503 lw a0,-36(s0) 2000033c: 000780e7 jalr a5 20000340: 0240006f j 20000364 <handle_trap+0x94> 20000344: 00018713 mv a4,gp 20000348: fdc42783 lw a5,-36(s0) 2000034c: 00279793 slli a5,a5,0x2 20000350: 00f707b3 add a5,a4,a5 20000354: 0007a783 lw a5,0(a5) 20000358: fd842583 lw a1,-40(s0) 2000035c: fdc42503 lw a0,-36(s0) 20000360: 000780e7 jalr a5 20000364: fd842783 lw a5,-40(s0) 20000368: 00078513 mv a0,a5 2000036c: 02c12083 lw ra,44(sp) 20000370: 02812403 lw s0,40(sp) 20000374: 03010113 addi sp,sp,48 20000378: 00008067 ret 2000037c <main>: 2000037c: ff010113 addi sp,sp,-16 20000380: 00112623 sw ra,12(sp) 20000384: 00812423 sw s0,8(sp) 20000388: 01010413 addi s0,sp,16 2000038c: 00500513 li a0,5 20000390: dddff0ef jal ra,2000016c <delay> 20000394: 00000793 li a5,0 20000398: 00078513 mv a0,a5 2000039c: 00c12083 lw ra,12(sp) 200003a0: 00812403 lw s0,8(sp) 200003a4: 01010113 addi sp,sp,16 200003a8: 00008067 ret Disassembly of section .eh_frame: 200003ac <__global_pointer$+0x100003ac>: 200003ac: 0014 0x14 200003ae: 0000 unimp 200003b0: 0000 unimp 200003b2: 0000 unimp 200003b4: 00527a03 0x527a03 200003b8: 7c01 lui s8,0xfffe0 200003ba: 0101 addi sp,sp,0 200003bc: 07020d1b 0x7020d1b 200003c0: 0001 nop 200003c2: 0000 unimp 200003c4: 0010 0x10 200003c6: 0000 unimp 200003c8: 001c 0x1c 200003ca: 0000 unimp 200003cc: fc40 fsw fs0,60(s0) 200003ce: ffff 0xffff 200003d0: 0018 0x18 200003d2: 0000 unimp 200003d4: 0000 unimp 200003d6: 0000 unimp Disassembly of section .sbss: 10000000 <mcause_trap_table>: 10000000: 0000 unimp 10000002: 0000 unimp 10000004: 0000 unimp 10000006: 0000 unimp 10000008 <mcause_interrupt_table>: 10000008: 0000 unimp 1000000a: 0000 unimp 1000000c: 0000 unimp 1000000e: 0000 unimp Disassembly of section .riscv.attributes: 00000000 <.riscv.attributes>: 0: 1f41 addi t5,t5,-16 2: 0000 unimp 4: 7200 flw fs0,32(a2) 6: 7369 lui t1,0xffffa 8: 01007663 bgeu zero,a6,14 <mcause_trap_table-0xfffffec> c: 0015 c.nop 5 e: 0000 unimp 10: 1004 addi s1,sp,32 12: 7205 lui tp,0xfffe1 14: 3376 fld ft6,376(sp) 16: 6932 flw fs2,12(sp) 18: 7032 flw ft0,44(sp) 1a: 0030 addi a2,sp,8 1c: 0108 addi a0,sp,128 1e: 0b0a slli s6,s6,0x2 Disassembly of section .comment: 00000000 <.comment>: 0: 3a434347 fmsub.d ft6,ft6,ft4,ft7,rmm 4: 2820 fld fs0,80(s0) 6: 29554e47 fmsub.s ft8,fa0,fs5,ft5,rmm a: 3120 fld fs0,96(a0) c: 2e30 fld fa2,88(a2) e: 2e32 fld ft8,264(sp) 10: 0030 addi a2,sp,8
#define PJ_LIB__ #include <errno.h> #include <math.h> #include "proj.h" #include "proj_internal.h" PROJ_HEAD(col_urban, "Colombia Urban") "\n\tMisc\n\th_0="; // Notations and formulas taken from IOGP Publication 373-7-2 - // Geomatics Guidance Note number 7, part 2 - March 2020 namespace { // anonymous namespace struct pj_opaque { double h0; // height of projection origin, divided by semi-major axis (a) double rho0; // adimensional value, contrary to Guidance note 7.2 double A; double B; // adimensional value, contrary to Guidance note 7.2 double C; double D; // adimensional value, contrary to Guidance note 7.2 }; } // anonymous namespace static PJ_XY col_urban_forward (PJ_LP lp, PJ *P) { PJ_XY xy; struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); const double cosphi = cos(lp.phi); const double sinphi = sin(lp.phi); const double nu = 1. / sqrt(1 - P->es * sinphi * sinphi); const double lam_nu_cosphi = lp.lam * nu * cosphi; xy.x = Q->A * lam_nu_cosphi; const double sinphi_m = sin(0.5 * (lp.phi + P->phi0)); const double rho_m = (1 - P->es) / pow(1 - P->es * sinphi_m * sinphi_m, 1.5); const double G = 1 + Q->h0 / rho_m; xy.y = G * Q->rho0 * ((lp.phi - P->phi0) + Q->B * lam_nu_cosphi * lam_nu_cosphi); return xy; } static PJ_LP col_urban_inverse (PJ_XY xy, PJ *P) { PJ_LP lp; struct pj_opaque *Q = static_cast<struct pj_opaque*>(P->opaque); lp.phi = P->phi0 + xy.y / Q->D - Q->B * (xy.x / Q->C) * (xy.x / Q->C); const double sinphi = sin(lp.phi); const double nu = 1. / sqrt(1 - P->es * sinphi * sinphi); lp.lam = xy.x / (Q->C * nu * cos(lp.phi)); return lp; } PJ *PROJECTION(col_urban) { struct pj_opaque *Q = static_cast<struct pj_opaque*>(calloc (1, sizeof (struct pj_opaque))); if (nullptr==Q) return pj_default_destructor (P, PROJ_ERR_OTHER /*ENOMEM*/); P->opaque = Q; const double h0_unscaled = pj_param(P->ctx, P->params, "dh_0").f; Q->h0 = h0_unscaled / P->a; const double sinphi0 = sin(P->phi0); const double nu0 = 1. / sqrt(1 - P->es * sinphi0 * sinphi0); Q->A = 1 + Q->h0 / nu0; Q->rho0 = (1 - P->es) / pow(1 - P->es * sinphi0 * sinphi0, 1.5); Q->B = tan(P->phi0) / (2 * Q->rho0 * nu0); Q->C = 1 + Q->h0; Q->D = Q->rho0 * (1 + Q->h0 / (1 - P->es)); P->fwd = col_urban_forward; P->inv = col_urban_inverse; return P; }
%define ICW_1 0x11 ; 00010001 binary. Enables initialization mode and we are sending ICW 4 %define PIC_1_CTRL 0x20 ; Primary PIC control register %define PIC_2_CTRL 0xA0 ; Secondary PIC control register %define PIC_1_DATA 0x21 ; Primary PIC data register %define PIC_2_DATA 0xA1 ; Secondary PIC data register %define IRQ_0 0x20 ; IRQs 0-7 mapped to use interrupts 0x20-0x27 %define IRQ_8 0x28 ; IRQs 8-15 mapped to use interrupts 0x28-0x36 ;=====; ; PIC ; ;=====; pic_remap: push eax ; Send ICW 1 - Begin initialization ------------------------- ; Setup to initialize the primary PIC. Send ICW 1 mov al, ICW_1 out PIC_1_CTRL, al ; Send ICW 2 - Map IRQ base interrupt numbers --------------- ; Remember that we have 2 PICs. Because we are cascading with this second PIC, send ICW 1 to second PIC command register out PIC_2_CTRL, al ; send ICW 2 to primary PIC mov al, IRQ_0 out PIC_1_DATA, al ; send ICW 2 to secondary controller mov al, IRQ_8 out PIC_2_DATA, al ; Send ICW 3 - Set the IR line to connect both PICs --------- ; Send ICW 3 to primary PIC mov al, 0x4 ; 0x04 => 0100, second bit (IR line 2) out PIC_1_DATA, al ; write to data register of primary PIC ; Send ICW 3 to secondary PIC mov al, 0x2 ; 010=> IR line 2 out PIC_2_DATA, al ; write to data register of secondary PIC ; Send ICW 4 - Set x86 mode -------------------------------- mov al, 1 ; bit 0 enables 80x86 mode ; send ICW 4 to both primary and secondary PICs out PIC_1_DATA, al out PIC_2_DATA, al ; All done. Null out the data registers mov al, 0 out PIC_1_DATA, al out PIC_2_DATA, al pop eax ret
// Signum.asm // Computes: if R0 > 0: // R1 = 1 // else: // R1=0 @R0 D=M @POSITIVE D;JGT @R1 M=0 @END 0;JMP (POSITIVE) @R1 M=1 (END) @END 0;JMP
;------------------------------------------------------------------------------ ; Z88DK Z80 Macro Assembler ; ; DAA emulation for Rabbit - based on the Fuse implementation ; ; Copyright (C) Paulo Custodio, 2011-2017 ; License: The Artistic License 2.0, http://www.perlfoundation.org/artistic_license_2_0 ; Repository: https://github.com/z88dk/z88dk ;------------------------------------------------------------------------------ IF __CPU_RABBIT__ SECTION code_crt0_sccz80 PUBLIC __z80asm__daa __z80asm__daa: push bc push af ex (sp), hl ; H is A, L is F ; libspectrum_byte add = 0, carry = ( F & FLAG_C ); ld bc, 0 ; B = add rl c ; C = 1 if carry, 0 otherwise ; if( ( F & FLAG_H ) || ( ( A & 0x0f ) > 9 ) ) add = 6; bit 4, l ; check H jr nz, t1_true ld a, h and $0F cp 9+1 ; A >= 10 -> no carry jr c, t1_cont t1_true: ld b, 6 ; add = 6 t1_cont: ; if( carry || ( A > 0x99 ) ) add |= 0x60; bit 0, c ; check carry jr nz, t2_true ld a, h cp 0x99+1 jr c, t2_cont t2_true: ld a, 0x60 or b ld b, a t2_cont: ; if( A > 0x99 ) carry = FLAG_C; ld a, h cp 0x99+1 jr c, t3_cont t3_true: set 0, c ; store carry=1 in C t3_cont: ; if( F & FLAG_N ) { SUB(add); } else { ADD(add); } bit 1, l ; check N ld a, h ; prepare to add/subtract jr z, t4_zero t4_one: sub b jr t4_cont t4_zero: add a, b t4_cont: ld h, a ; F = ( F & ~( FLAG_C | FLAG_P ) ) | carry | parity_table[A]; ld a, l and ~$01 ; clear C or $04 ; set P/V (even = 1, odd = 0) or c ; | carry ld l, a ld b, $80 parity_loop: ld a, h and b ; check each bit jr z, bit0 ld a, l xor $04 ; invert parity bit ld l, a bit0: rr b jr nc, parity_loop ; set zero flag ld a, h and a jr nz, not_z set 6, l ; set Z flag not_z: ; set sign flag bit 7, h jr z, positive set 7, l ; set S flag positive: ; return ex (sp), hl pop af pop bc ret ENDIF
BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after this bootloader add ax, 288 ; (4096 + 512) / 16 bytes per paragraph mov ss, ax mov sp, 4096 mov ax, 07C0h ; Set data segment to where we're loaded mov ds, ax mov si, text_string ; Put string position into SI call print_string ; Call our string-printing routine jmp $ ; Jump here - infinite loop! text_string db 'This is my cool new OS!', 0 print_string: ; Routine: output string in SI to screen mov ah, 0Eh ; int 10h 'print char' function .repeat: lodsb ; Get character from string cmp al, 0 je .done ; If char is zero, end of string int 10h ; Otherwise, print it jmp .repeat .done: ret times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s dw 0xAA55 ; The standard PC boot signature
// ----------------------------------------------------------------------------------------------------- // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file * \author Hannes Hauswedell <hannes.hauswedell AT fu-berlin.de> * \brief Provides seqan3::views::type_reduce. */ #pragma once #include <string_view> #include <seqan3/core/type_traits/template_inspection.hpp> #include <seqan3/range/concept.hpp> #include <seqan3/range/views/detail.hpp> #include <seqan3/std/concepts> #include <seqan3/std/ranges> #include <seqan3/std/span> namespace seqan3::detail { // ============================================================================ // type_reduce_fn (adaptor definition) // ============================================================================ /*!\brief View adaptor definition for views::type_reduce. */ class type_reduce_fn : public adaptor_base<type_reduce_fn> { private: //!\brief Type of the CRTP-base. using base_t = adaptor_base<type_reduce_fn>; public: //!\brief Inherit the base class's Constructors. using base_t::base_t; private: //!\brief Befriend the base class so it can call impl(). friend base_t; /*!\brief Type erase if possible and delegate to std::views::all otherwise. * \returns An instance of std::span, std::basic_string_view, std::ranges::subrange or std::views::all's return type. */ template <std::ranges::range urng_t> static constexpr auto impl(urng_t && urange) { static_assert(std::ranges::viewable_range<urng_t>, "The views::type_reduce adaptor can only be passed viewable_ranges, i.e. Views or &-to-non-View."); // views are always passed as-is if constexpr (std::ranges::view<remove_cvref_t<urng_t>>) { return std::views::all(std::forward<urng_t>(urange)); } // string const & else if constexpr (is_type_specialisation_of_v<remove_cvref_t<urng_t>, std::basic_string> && std::is_const_v<std::remove_reference_t<urng_t>>) { return std::basic_string_view{std::ranges::data(urange), std::ranges::size(urange)}; } // contiguous else if constexpr (forwarding_range<urng_t> && std::ranges::contiguous_range<urng_t> && std::ranges::sized_range<urng_t>) { return std::span{std::ranges::data(urange), std::ranges::size(urange)}; } // random_access else if constexpr (forwarding_range<urng_t> && std::ranges::random_access_range<urng_t> && std::ranges::sized_range<urng_t>) { return std::ranges::subrange<std::ranges::iterator_t<urng_t>, std::ranges::iterator_t<urng_t>> { std::ranges::begin(urange), std::ranges::begin(urange) + std::ranges::size(urange), std::ranges::size(urange) }; } // pass to std::views::all (will return ref-view) else { return std::views::all(std::forward<urng_t>(urange)); } } }; } // namespace seqan3::detail // ============================================================================ // views::type_reduce (adaptor instance definition) // ============================================================================ namespace seqan3::views { /*!\name General purpose views * \{ */ /*!\brief A view adaptor that behaves like std::views::all, but type erases certain ranges. * \tparam urng_t The type of the range being processed. See below for requirements. [template parameter is * omitted in pipe notation] * \param[in] urange The range being processed. [parameter is omitted in pipe notation] * \returns The range turned into a view. * \ingroup views * * \details * * \header_file{seqan3/range/views/view_type_reduce.hpp} * * ### View properties * * | Concepts and traits | `urng_t` (underlying range type) | `rrng_t` (returned range type) | * |----------------------------------|:---------------------------------:|:--------------------------------------:| * | std::ranges::input_range | *required* | *preserved* | * | std::ranges::forward_range | | *preserved* | * | std::ranges::bidirectional_range | | *preserved* | * | std::ranges::random_access_range | | *preserved* | * | std::ranges::contiguous_range | | *preserved* | * | | | | * | std::ranges::viewable_range | *required* | *guaranteed* | * | std::ranges::view | | *guaranteed* | * | std::ranges::sized_range | | *preserved* | * | std::ranges::common_range | | *preserved* | * | std::ranges::output_range | | *preserved* | * | seqan3::const_iterable_range | | *preserved* | * | | | | * | std::ranges::range_reference_t | | std::ranges::range_reference_t<urng_t> | * * See the \link views views submodule documentation \endlink for detailed descriptions of the view properties. * * ### Return type * * | `urng_t` (underlying range type) | `rrng_t` (returned range type) | * |:----------------------------------------------------------------------------------------------:|:-------------------------------:| * | `std::ranges::view` | `urng_t` | * | `std::basic_string const &` *or* `std::basic_string_view` | `std::basic_string_view` | * | `seqan3::forwarding_range && std::ranges::sized_range && std::ranges::contiguous_range` | `std::span` | * | `seqan3::forwarding_range && std::ranges::sized_range && std::ranges::random_access_range` | `std::ranges::subrange` | * | *else* | `std::ranges::ref_view<urng_t>` | * * This adaptor is different from std::views::all in that it performs type erasure for some underlying ranges; * std::views::all always returns `std::ranges::ref_view<urng_t>` or the type itself if it already is a view. * * ### Example * * \include test/snippet/range/views/type_reduce.cpp * * \hideinitializer */ inline constexpr auto type_reduce = detail::type_reduce_fn{}; //!\} } // namespace seqan3::views namespace seqan3 { //!\brief Deduces the return value of seqan3::views::type_reduce. template <typename t> using type_reduce_view = decltype(views::type_reduce(std::declval<t>())); }
; struct sp1_update *sp1_GetUpdateStruct(uchar row, uchar col) SECTION code_clib SECTION code_temp_sp1 PUBLIC sp1_GetUpdateStruct EXTERN asm_sp1_GetUpdateStruct sp1_GetUpdateStruct: ld hl,2 add hl,sp ld e,(hl) inc hl inc hl ld d,(hl) jp asm_sp1_GetUpdateStruct
; A121633: Sum of the bottom levels of the last column over all deco polyominoes of height n. A deco polyomino is a directed column-convex polyomino in which the height, measured along the diagonal, is attained only in the last column. ; Submitted by Jon Maiga ; 0,0,1,9,68,527,4408,40303,403046,4393339,51955528,663383135,9102982354,133668773755,2092209897524,34783032728383,612234346270510,11375905660965179,222544581264066400,4572536725690159999,98456173247669999978,2217126753620449439515,52117916061047944788844,1276682002204035651572255,32537498456834130728666374,861486169921018384929325723,23663418048994102028675794520,673464574822253208963690246559,19835361014457056920448521150210,603902592427451409567999250506299,18986233225063184755244285245695268 add $0,1 mov $1,1 lpb $0 sub $0,1 add $2,1 mul $3,$2 add $3,$1 mul $1,$2 sub $3,1 lpe mov $0,$3
ld hl,end End ; mixed case = label (not directive) .end ALIGN ; .END should not work at first column, not even with --dirbol enabled end DUP 2 ; END should not work at first column, not even with --dirbol enabled nop ; but other directive on the same line (ALIGN, DUP above) must work! EDUP .2 ld b,1 ; China number one! .2 ld c,-1 ; Taiwan number dash one! END : no start address provided, and this text should be NOT parsed either Some random text, which is not supposed to be assembled.
ifdef Vasm macro ScreenStartDrawing endm macro ScreenStopDrawing endm else endif ifdef BuildMSX read "..\srcMSX\V1_VdpMemory_Header.asm" endif ifdef BuildCPC ifdef V9K read "..\srcMSX\V1_VdpMemory_Header.asm" endif endif
; A122088: Add 10, subtract 5, add 10, subtract 5, ad infinitum. ; 1,11,6,16,11,21,16,26,21,31,26,36,31,41,36,46,41,51,46,56,51,61,56,66,61,71,66,76,71,81,76,86,81,91,86,96,91,101,96,106,101,111,106,116,111,121,116,126,121,131,126,136,131,141,136,146,141,151,146,156,151,161,156,166,161,171 mov $1,10 mul $1,$0 div $0,2 mul $0,15 add $1,1 sub $1,$0 mov $0,$1
//INITIAL VALUES // BAR @24397 D=A @0 //Bar address M=D @3 D=A @1 //Row drawing M=D @6 D=A @2 //Column Drawing M=D // BALL @24175 //Ball initial position D=A @7 M=D @32767 //Number for drawing D=A @8 M=D @24577 //32767 + 24577 = 57344 D=A @8 M=M+D @7 //Number for drawing D=A @9 M=D @6 D=A @10 M=D //BAR PROCESS (BAR) //32 (12) @0 //Bar address A=M M=-1 @0 //Bar address M=M+1 @2 //Column Drawing M=M-1 D=M @NEXT D;JEQ @BAR 0;JMP (NEXT)//44 (21) // Value resetting for next bar row. @26 // 32-6 D=A @0 //Bar address M=M+D @6 D=A @2 //Column Drawing M=D @1 //Row drawing M=M-1 D=M @BAR D;JGT // Loop ending @96 // 32 + 32 + 32 D=A @0 //Bar address M=M-D // Value resetting for next bar drawing. @3 D=A @1 //Row drawing M=D (LOOP)//65 (6) //TIMER @10 D=A @6 M=D @BALL 0;JMP (PRESSED) //71 (24) //130 left //132 right @KBD //55 D=M @3 M=D @0 D=M @4 M=D @130 D=A @3 M=M-D D=M @LEFT D;JEQ @2 //Column Drawing D=A @3 M=M-D D=M @RIGHT D;JEQ @LOOP 0;JMP (LEFT) //95 (18) //Erase 3 columns to the right and add 3 to the left. Check row limits. @24384 D=A @0 D=D-M @LOOP D;JEQ // Erasing position @5 D=A @4 M=M+D // Moving position to the left @0 M=M-1 // Values for erasing @3 D=A @5 M=D @BARERASE 0;JMP (RIGHT) //113 (14) //Erase 3 columns to the left and add 3 to the right. Check row limits. @24410 D=A @0 D=D-M @LOOP D;JEQ // Moving position to the right @0 M=M+1 // Values for erasing @3 D=A @5 M=D @BARERASE 0;JMP (BARERASE) //127 (3) @4 //Bar address A=M M=0 (NEXTERASE) //130 (15) @32 D=A @4 //Bar address M=M+D @5 // Row for erasing M=M-1 D=M @BARERASE D;JGT // Loop ending // Resetting values for next bar erase. @3 D=A @5 // Row for erasing M=D @BAR 0;JMP //BALL PROCESS (BALL) //145 (30) @8 //Left drawing value D=M @7 //Ball position A=M M=D @9 //Right drawing value D=M @7 //Moving position to the right M=M+1 A=M M=D @31 //32-1 Next ball row position D=A @7 M=M+D @10 //Ball rows quantity M=M-1 D=M @BALL D;JGT @192 // 32 * 6 Resetting ball position D=A @7 M=M-D @6 D=A @10 M=D @TIMER 0;JMP (TIMER) //175 (7) @6 M=M-1 D=M @CHECKIFPRESSED D;JEQ @TIMER 0;JMP (CHECKIFPRESSED) //182 (6) @KBD D=M @PRESSED D;JGT @LOOP 0;JMP
; A020772: Decimal expansion of 1/sqrt(15). ; Submitted by Jon Maiga ; 2,5,8,1,9,8,8,8,9,7,4,7,1,6,1,1,2,5,6,7,8,6,1,7,6,9,3,3,1,8,8,2,6,6,4,0,7,2,2,1,9,4,7,8,0,3,5,2,7,7,2,7,2,1,7,7,2,5,0,4,9,1,7,7,4,0,8,9,8,8,7,2,7,9,5,7,9,8,6,0,2,2,3,4,6,1,9,1,5,8,4,5,7,2,4,4,9,0,1,1 mov $3,$0 add $3,1 mul $3,3 lpb $3 add $6,$2 add $1,$6 add $2,$1 add $1,$2 add $2,$1 mov $5,$1 mul $1,2 add $1,$5 sub $3,1 add $5,$2 mov $6,2 add $6,$5 lpe mul $2,3 mov $4,10 pow $4,$0 mul $4,4 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
SECTION .text GLOBAL test test: shrx rax, rax, rax shrx rax, rax, rbx shrx rax, rax, rcx shrx rax, rax, rdx shrx rax, rax, rdi shrx rax, rax, r8 shrx rax, rax, r9 shrx rax, rax, r10 shrx rax, rax, r11 shrx rax, rax, r12 shrx rax, rax, r13 shrx rax, rax, r14 shrx rax, rax, r15 shrx rax, rax, rsp shrx rax, rax, rsi shrx rax, rax, rbp shrx rax, rbx, rax shrx rax, rbx, rbx shrx rax, rbx, rcx shrx rax, rbx, rdx shrx rax, rbx, rdi shrx rax, rbx, r8 shrx rax, rbx, r9 shrx rax, rbx, r10 shrx rax, rbx, r11 shrx rax, rbx, r12 shrx rax, rbx, r13 shrx rax, rbx, r14 shrx rax, rbx, r15 shrx rax, rbx, rsp shrx rax, rbx, rsi shrx rax, rbx, rbp shrx rax, rcx, rax shrx rax, rcx, rbx shrx rax, rcx, rcx shrx rax, rcx, rdx shrx rax, rcx, rdi shrx rax, rcx, r8 shrx rax, rcx, r9 shrx rax, rcx, r10 shrx rax, rcx, r11 shrx rax, rcx, r12 shrx rax, rcx, r13 shrx rax, rcx, r14 shrx rax, rcx, r15 shrx rax, rcx, rsp shrx rax, rcx, rsi shrx rax, rcx, rbp shrx rax, rdx, rax shrx rax, rdx, rbx shrx rax, rdx, rcx shrx rax, rdx, rdx shrx rax, rdx, rdi shrx rax, rdx, r8 shrx rax, rdx, r9 shrx rax, rdx, r10 shrx rax, rdx, r11 shrx rax, rdx, r12 shrx rax, rdx, r13 shrx rax, rdx, r14 shrx rax, rdx, r15 shrx rax, rdx, rsp shrx rax, rdx, rsi shrx rax, rdx, rbp shrx rax, rdi, rax shrx rax, rdi, rbx shrx rax, rdi, rcx shrx rax, rdi, rdx shrx rax, rdi, rdi shrx rax, rdi, r8 shrx rax, rdi, r9 shrx rax, rdi, r10 shrx rax, rdi, r11 shrx rax, rdi, r12 shrx rax, rdi, r13 shrx rax, rdi, r14 shrx rax, rdi, r15 shrx rax, rdi, rsp shrx rax, rdi, rsi shrx rax, rdi, rbp shrx rax, r8, rax shrx rax, r8, rbx shrx rax, r8, rcx shrx rax, r8, rdx shrx rax, r8, rdi shrx rax, r8, r8 shrx rax, r8, r9 shrx rax, r8, r10 shrx rax, r8, r11 shrx rax, r8, r12 shrx rax, r8, r13 shrx rax, r8, r14 shrx rax, r8, r15 shrx rax, r8, rsp shrx rax, r8, rsi shrx rax, r8, rbp shrx rax, r9, rax shrx rax, r9, rbx shrx rax, r9, rcx shrx rax, r9, rdx shrx rax, r9, rdi shrx rax, r9, r8 shrx rax, r9, r9 shrx rax, r9, r10 shrx rax, r9, r11 shrx rax, r9, r12 shrx rax, r9, r13 shrx rax, r9, r14 shrx rax, r9, r15 shrx rax, r9, rsp shrx rax, r9, rsi shrx rax, r9, rbp shrx rax, r10, rax shrx rax, r10, rbx shrx rax, r10, rcx shrx rax, r10, rdx shrx rax, r10, rdi shrx rax, r10, r8 shrx rax, r10, r9 shrx rax, r10, r10 shrx rax, r10, r11 shrx rax, r10, r12 shrx rax, r10, r13 shrx rax, r10, r14 shrx rax, r10, r15 shrx rax, r10, rsp shrx rax, r10, rsi shrx rax, r10, rbp shrx rax, r11, rax shrx rax, r11, rbx shrx rax, r11, rcx shrx rax, r11, rdx shrx rax, r11, rdi shrx rax, r11, r8 shrx rax, r11, r9 shrx rax, r11, r10 shrx rax, r11, r11 shrx rax, r11, r12 shrx rax, r11, r13 shrx rax, r11, r14 shrx rax, r11, r15 shrx rax, r11, rsp shrx rax, r11, rsi shrx rax, r11, rbp shrx rax, r12, rax shrx rax, r12, rbx shrx rax, r12, rcx shrx rax, r12, rdx shrx rax, r12, rdi shrx rax, r12, r8 shrx rax, r12, r9 shrx rax, r12, r10 shrx rax, r12, r11 shrx rax, r12, r12 shrx rax, r12, r13 shrx rax, r12, r14 shrx rax, r12, r15 shrx rax, r12, rsp shrx rax, r12, rsi shrx rax, r12, rbp shrx rax, r13, rax shrx rax, r13, rbx shrx rax, r13, rcx shrx rax, r13, rdx shrx rax, r13, rdi shrx rax, r13, r8 shrx rax, r13, r9 shrx rax, r13, r10 shrx rax, r13, r11 shrx rax, r13, r12 shrx rax, r13, r13 shrx rax, r13, r14 shrx rax, r13, r15 shrx rax, r13, rsp shrx rax, r13, rsi shrx rax, r13, rbp shrx rax, r14, rax shrx rax, r14, rbx shrx rax, r14, rcx shrx rax, r14, rdx shrx rax, r14, rdi shrx rax, r14, r8 shrx rax, r14, r9 shrx rax, r14, r10 shrx rax, r14, r11 shrx rax, r14, r12 shrx rax, r14, r13 shrx rax, r14, r14 shrx rax, r14, r15 shrx rax, r14, rsp shrx rax, r14, rsi shrx rax, r14, rbp shrx rax, r15, rax shrx rax, r15, rbx shrx rax, r15, rcx shrx rax, r15, rdx shrx rax, r15, rdi shrx rax, r15, r8 shrx rax, r15, r9 shrx rax, r15, r10 shrx rax, r15, r11 shrx rax, r15, r12 shrx rax, r15, r13 shrx rax, r15, r14 shrx rax, r15, r15 shrx rax, r15, rsp shrx rax, r15, rsi shrx rax, r15, rbp shrx rax, rsp, rax shrx rax, rsp, rbx shrx rax, rsp, rcx shrx rax, rsp, rdx shrx rax, rsp, rdi shrx rax, rsp, r8 shrx rax, rsp, r9 shrx rax, rsp, r10 shrx rax, rsp, r11 shrx rax, rsp, r12 shrx rax, rsp, r13 shrx rax, rsp, r14 shrx rax, rsp, r15 shrx rax, rsp, rsp shrx rax, rsp, rsi shrx rax, rsp, rbp shrx rax, rsi, rax shrx rax, rsi, rbx shrx rax, rsi, rcx shrx rax, rsi, rdx shrx rax, rsi, rdi shrx rax, rsi, r8 shrx rax, rsi, r9 shrx rax, rsi, r10 shrx rax, rsi, r11 shrx rax, rsi, r12 shrx rax, rsi, r13 shrx rax, rsi, r14 shrx rax, rsi, r15 shrx rax, rsi, rsp shrx rax, rsi, rsi shrx rax, rsi, rbp shrx rax, rbp, rax shrx rax, rbp, rbx shrx rax, rbp, rcx shrx rax, rbp, rdx shrx rax, rbp, rdi shrx rax, rbp, r8 shrx rax, rbp, r9 shrx rax, rbp, r10 shrx rax, rbp, r11 shrx rax, rbp, r12 shrx rax, rbp, r13 shrx rax, rbp, r14 shrx rax, rbp, r15 shrx rax, rbp, rsp shrx rax, rbp, rsi shrx rax, rbp, rbp shrx rbx, rax, rax shrx rbx, rax, rbx shrx rbx, rax, rcx shrx rbx, rax, rdx shrx rbx, rax, rdi shrx rbx, rax, r8 shrx rbx, rax, r9 shrx rbx, rax, r10 shrx rbx, rax, r11 shrx rbx, rax, r12 shrx rbx, rax, r13 shrx rbx, rax, r14 shrx rbx, rax, r15 shrx rbx, rax, rsp shrx rbx, rax, rsi shrx rbx, rax, rbp shrx rbx, rbx, rax shrx rbx, rbx, rbx shrx rbx, rbx, rcx shrx rbx, rbx, rdx shrx rbx, rbx, rdi shrx rbx, rbx, r8 shrx rbx, rbx, r9 shrx rbx, rbx, r10 shrx rbx, rbx, r11 shrx rbx, rbx, r12 shrx rbx, rbx, r13 shrx rbx, rbx, r14 shrx rbx, rbx, r15 shrx rbx, rbx, rsp shrx rbx, rbx, rsi shrx rbx, rbx, rbp shrx rbx, rcx, rax shrx rbx, rcx, rbx shrx rbx, rcx, rcx shrx rbx, rcx, rdx shrx rbx, rcx, rdi shrx rbx, rcx, r8 shrx rbx, rcx, r9 shrx rbx, rcx, r10 shrx rbx, rcx, r11 shrx rbx, rcx, r12 shrx rbx, rcx, r13 shrx rbx, rcx, r14 shrx rbx, rcx, r15 shrx rbx, rcx, rsp shrx rbx, rcx, rsi shrx rbx, rcx, rbp shrx rbx, rdx, rax shrx rbx, rdx, rbx shrx rbx, rdx, rcx shrx rbx, rdx, rdx shrx rbx, rdx, rdi shrx rbx, rdx, r8 shrx rbx, rdx, r9 shrx rbx, rdx, r10 shrx rbx, rdx, r11 shrx rbx, rdx, r12 shrx rbx, rdx, r13 shrx rbx, rdx, r14 shrx rbx, rdx, r15 shrx rbx, rdx, rsp shrx rbx, rdx, rsi shrx rbx, rdx, rbp shrx rbx, rdi, rax shrx rbx, rdi, rbx shrx rbx, rdi, rcx shrx rbx, rdi, rdx shrx rbx, rdi, rdi shrx rbx, rdi, r8 shrx rbx, rdi, r9 shrx rbx, rdi, r10 shrx rbx, rdi, r11 shrx rbx, rdi, r12 shrx rbx, rdi, r13 shrx rbx, rdi, r14 shrx rbx, rdi, r15 shrx rbx, rdi, rsp shrx rbx, rdi, rsi shrx rbx, rdi, rbp shrx rbx, r8, rax shrx rbx, r8, rbx shrx rbx, r8, rcx shrx rbx, r8, rdx shrx rbx, r8, rdi shrx rbx, r8, r8 shrx rbx, r8, r9 shrx rbx, r8, r10 shrx rbx, r8, r11 shrx rbx, r8, r12 shrx rbx, r8, r13 shrx rbx, r8, r14 shrx rbx, r8, r15 shrx rbx, r8, rsp shrx rbx, r8, rsi shrx rbx, r8, rbp shrx rbx, r9, rax shrx rbx, r9, rbx shrx rbx, r9, rcx shrx rbx, r9, rdx shrx rbx, r9, rdi shrx rbx, r9, r8 shrx rbx, r9, r9 shrx rbx, r9, r10 shrx rbx, r9, r11 shrx rbx, r9, r12 shrx rbx, r9, r13 shrx rbx, r9, r14 shrx rbx, r9, r15 shrx rbx, r9, rsp shrx rbx, r9, rsi shrx rbx, r9, rbp shrx rbx, r10, rax shrx rbx, r10, rbx shrx rbx, r10, rcx shrx rbx, r10, rdx shrx rbx, r10, rdi shrx rbx, r10, r8 shrx rbx, r10, r9 shrx rbx, r10, r10 shrx rbx, r10, r11 shrx rbx, r10, r12 shrx rbx, r10, r13 shrx rbx, r10, r14 shrx rbx, r10, r15 shrx rbx, r10, rsp shrx rbx, r10, rsi shrx rbx, r10, rbp shrx rbx, r11, rax shrx rbx, r11, rbx shrx rbx, r11, rcx shrx rbx, r11, rdx shrx rbx, r11, rdi shrx rbx, r11, r8 shrx rbx, r11, r9 shrx rbx, r11, r10 shrx rbx, r11, r11 shrx rbx, r11, r12 shrx rbx, r11, r13 shrx rbx, r11, r14 shrx rbx, r11, r15 shrx rbx, r11, rsp shrx rbx, r11, rsi shrx rbx, r11, rbp shrx rbx, r12, rax shrx rbx, r12, rbx shrx rbx, r12, rcx shrx rbx, r12, rdx shrx rbx, r12, rdi shrx rbx, r12, r8 shrx rbx, r12, r9 shrx rbx, r12, r10 shrx rbx, r12, r11 shrx rbx, r12, r12 shrx rbx, r12, r13 shrx rbx, r12, r14 shrx rbx, r12, r15 shrx rbx, r12, rsp shrx rbx, r12, rsi shrx rbx, r12, rbp shrx rbx, r13, rax shrx rbx, r13, rbx shrx rbx, r13, rcx shrx rbx, r13, rdx shrx rbx, r13, rdi shrx rbx, r13, r8 shrx rbx, r13, r9 shrx rbx, r13, r10 shrx rbx, r13, r11 shrx rbx, r13, r12 shrx rbx, r13, r13 shrx rbx, r13, r14 shrx rbx, r13, r15 shrx rbx, r13, rsp shrx rbx, r13, rsi shrx rbx, r13, rbp shrx rbx, r14, rax shrx rbx, r14, rbx shrx rbx, r14, rcx shrx rbx, r14, rdx shrx rbx, r14, rdi shrx rbx, r14, r8 shrx rbx, r14, r9 shrx rbx, r14, r10 shrx rbx, r14, r11 shrx rbx, r14, r12 shrx rbx, r14, r13 shrx rbx, r14, r14 shrx rbx, r14, r15 shrx rbx, r14, rsp shrx rbx, r14, rsi shrx rbx, r14, rbp shrx rbx, r15, rax shrx rbx, r15, rbx shrx rbx, r15, rcx shrx rbx, r15, rdx shrx rbx, r15, rdi shrx rbx, r15, r8 shrx rbx, r15, r9 shrx rbx, r15, r10 shrx rbx, r15, r11 shrx rbx, r15, r12 shrx rbx, r15, r13 shrx rbx, r15, r14 shrx rbx, r15, r15 shrx rbx, r15, rsp shrx rbx, r15, rsi shrx rbx, r15, rbp shrx rbx, rsp, rax shrx rbx, rsp, rbx shrx rbx, rsp, rcx shrx rbx, rsp, rdx shrx rbx, rsp, rdi shrx rbx, rsp, r8 shrx rbx, rsp, r9 shrx rbx, rsp, r10 shrx rbx, rsp, r11 shrx rbx, rsp, r12 shrx rbx, rsp, r13 shrx rbx, rsp, r14 shrx rbx, rsp, r15 shrx rbx, rsp, rsp shrx rbx, rsp, rsi shrx rbx, rsp, rbp shrx rbx, rsi, rax shrx rbx, rsi, rbx shrx rbx, rsi, rcx shrx rbx, rsi, rdx shrx rbx, rsi, rdi shrx rbx, rsi, r8 shrx rbx, rsi, r9 shrx rbx, rsi, r10 shrx rbx, rsi, r11 shrx rbx, rsi, r12 shrx rbx, rsi, r13 shrx rbx, rsi, r14 shrx rbx, rsi, r15 shrx rbx, rsi, rsp shrx rbx, rsi, rsi shrx rbx, rsi, rbp shrx rbx, rbp, rax shrx rbx, rbp, rbx shrx rbx, rbp, rcx shrx rbx, rbp, rdx shrx rbx, rbp, rdi shrx rbx, rbp, r8 shrx rbx, rbp, r9 shrx rbx, rbp, r10 shrx rbx, rbp, r11 shrx rbx, rbp, r12 shrx rbx, rbp, r13 shrx rbx, rbp, r14 shrx rbx, rbp, r15 shrx rbx, rbp, rsp shrx rbx, rbp, rsi shrx rbx, rbp, rbp shrx rcx, rax, rax shrx rcx, rax, rbx shrx rcx, rax, rcx shrx rcx, rax, rdx shrx rcx, rax, rdi shrx rcx, rax, r8 shrx rcx, rax, r9 shrx rcx, rax, r10 shrx rcx, rax, r11 shrx rcx, rax, r12 shrx rcx, rax, r13 shrx rcx, rax, r14 shrx rcx, rax, r15 shrx rcx, rax, rsp shrx rcx, rax, rsi shrx rcx, rax, rbp shrx rcx, rbx, rax shrx rcx, rbx, rbx shrx rcx, rbx, rcx shrx rcx, rbx, rdx shrx rcx, rbx, rdi shrx rcx, rbx, r8 shrx rcx, rbx, r9 shrx rcx, rbx, r10 shrx rcx, rbx, r11 shrx rcx, rbx, r12 shrx rcx, rbx, r13 shrx rcx, rbx, r14 shrx rcx, rbx, r15 shrx rcx, rbx, rsp shrx rcx, rbx, rsi shrx rcx, rbx, rbp shrx rcx, rcx, rax shrx rcx, rcx, rbx shrx rcx, rcx, rcx shrx rcx, rcx, rdx shrx rcx, rcx, rdi shrx rcx, rcx, r8 shrx rcx, rcx, r9 shrx rcx, rcx, r10 shrx rcx, rcx, r11 shrx rcx, rcx, r12 shrx rcx, rcx, r13 shrx rcx, rcx, r14 shrx rcx, rcx, r15 shrx rcx, rcx, rsp shrx rcx, rcx, rsi shrx rcx, rcx, rbp shrx rcx, rdx, rax shrx rcx, rdx, rbx shrx rcx, rdx, rcx shrx rcx, rdx, rdx shrx rcx, rdx, rdi shrx rcx, rdx, r8 shrx rcx, rdx, r9 shrx rcx, rdx, r10 shrx rcx, rdx, r11 shrx rcx, rdx, r12 shrx rcx, rdx, r13 shrx rcx, rdx, r14 shrx rcx, rdx, r15 shrx rcx, rdx, rsp shrx rcx, rdx, rsi shrx rcx, rdx, rbp shrx rcx, rdi, rax shrx rcx, rdi, rbx shrx rcx, rdi, rcx shrx rcx, rdi, rdx shrx rcx, rdi, rdi shrx rcx, rdi, r8 shrx rcx, rdi, r9 shrx rcx, rdi, r10 shrx rcx, rdi, r11 shrx rcx, rdi, r12 shrx rcx, rdi, r13 shrx rcx, rdi, r14 shrx rcx, rdi, r15 shrx rcx, rdi, rsp shrx rcx, rdi, rsi shrx rcx, rdi, rbp shrx rcx, r8, rax shrx rcx, r8, rbx shrx rcx, r8, rcx shrx rcx, r8, rdx shrx rcx, r8, rdi shrx rcx, r8, r8 shrx rcx, r8, r9 shrx rcx, r8, r10 shrx rcx, r8, r11 shrx rcx, r8, r12 shrx rcx, r8, r13 shrx rcx, r8, r14 shrx rcx, r8, r15 shrx rcx, r8, rsp shrx rcx, r8, rsi shrx rcx, r8, rbp shrx rcx, r9, rax shrx rcx, r9, rbx shrx rcx, r9, rcx shrx rcx, r9, rdx shrx rcx, r9, rdi shrx rcx, r9, r8 shrx rcx, r9, r9 shrx rcx, r9, r10 shrx rcx, r9, r11 shrx rcx, r9, r12 shrx rcx, r9, r13 shrx rcx, r9, r14 shrx rcx, r9, r15 shrx rcx, r9, rsp shrx rcx, r9, rsi shrx rcx, r9, rbp shrx rcx, r10, rax shrx rcx, r10, rbx shrx rcx, r10, rcx shrx rcx, r10, rdx shrx rcx, r10, rdi shrx rcx, r10, r8 shrx rcx, r10, r9 shrx rcx, r10, r10 shrx rcx, r10, r11 shrx rcx, r10, r12 shrx rcx, r10, r13 shrx rcx, r10, r14 shrx rcx, r10, r15 shrx rcx, r10, rsp shrx rcx, r10, rsi shrx rcx, r10, rbp shrx rcx, r11, rax shrx rcx, r11, rbx shrx rcx, r11, rcx shrx rcx, r11, rdx shrx rcx, r11, rdi shrx rcx, r11, r8 shrx rcx, r11, r9 shrx rcx, r11, r10 shrx rcx, r11, r11 shrx rcx, r11, r12 shrx rcx, r11, r13 shrx rcx, r11, r14 shrx rcx, r11, r15 shrx rcx, r11, rsp shrx rcx, r11, rsi shrx rcx, r11, rbp shrx rcx, r12, rax shrx rcx, r12, rbx shrx rcx, r12, rcx shrx rcx, r12, rdx shrx rcx, r12, rdi shrx rcx, r12, r8 shrx rcx, r12, r9 shrx rcx, r12, r10 shrx rcx, r12, r11 shrx rcx, r12, r12 shrx rcx, r12, r13 shrx rcx, r12, r14 shrx rcx, r12, r15 shrx rcx, r12, rsp shrx rcx, r12, rsi shrx rcx, r12, rbp shrx rcx, r13, rax shrx rcx, r13, rbx shrx rcx, r13, rcx shrx rcx, r13, rdx shrx rcx, r13, rdi shrx rcx, r13, r8 shrx rcx, r13, r9 shrx rcx, r13, r10 shrx rcx, r13, r11 shrx rcx, r13, r12 shrx rcx, r13, r13 shrx rcx, r13, r14 shrx rcx, r13, r15 shrx rcx, r13, rsp shrx rcx, r13, rsi shrx rcx, r13, rbp shrx rcx, r14, rax shrx rcx, r14, rbx shrx rcx, r14, rcx shrx rcx, r14, rdx shrx rcx, r14, rdi shrx rcx, r14, r8 shrx rcx, r14, r9 shrx rcx, r14, r10 shrx rcx, r14, r11 shrx rcx, r14, r12 shrx rcx, r14, r13 shrx rcx, r14, r14 shrx rcx, r14, r15 shrx rcx, r14, rsp shrx rcx, r14, rsi shrx rcx, r14, rbp shrx rcx, r15, rax shrx rcx, r15, rbx shrx rcx, r15, rcx shrx rcx, r15, rdx shrx rcx, r15, rdi shrx rcx, r15, r8 shrx rcx, r15, r9 shrx rcx, r15, r10 shrx rcx, r15, r11 shrx rcx, r15, r12 shrx rcx, r15, r13 shrx rcx, r15, r14 shrx rcx, r15, r15 shrx rcx, r15, rsp shrx rcx, r15, rsi shrx rcx, r15, rbp shrx rcx, rsp, rax shrx rcx, rsp, rbx shrx rcx, rsp, rcx shrx rcx, rsp, rdx shrx rcx, rsp, rdi shrx rcx, rsp, r8 shrx rcx, rsp, r9 shrx rcx, rsp, r10 shrx rcx, rsp, r11 shrx rcx, rsp, r12 shrx rcx, rsp, r13 shrx rcx, rsp, r14 shrx rcx, rsp, r15 shrx rcx, rsp, rsp shrx rcx, rsp, rsi shrx rcx, rsp, rbp shrx rcx, rsi, rax shrx rcx, rsi, rbx shrx rcx, rsi, rcx shrx rcx, rsi, rdx shrx rcx, rsi, rdi shrx rcx, rsi, r8 shrx rcx, rsi, r9 shrx rcx, rsi, r10 shrx rcx, rsi, r11 shrx rcx, rsi, r12 shrx rcx, rsi, r13 shrx rcx, rsi, r14 shrx rcx, rsi, r15 shrx rcx, rsi, rsp shrx rcx, rsi, rsi shrx rcx, rsi, rbp shrx rcx, rbp, rax shrx rcx, rbp, rbx shrx rcx, rbp, rcx shrx rcx, rbp, rdx shrx rcx, rbp, rdi shrx rcx, rbp, r8 shrx rcx, rbp, r9 shrx rcx, rbp, r10 shrx rcx, rbp, r11 shrx rcx, rbp, r12 shrx rcx, rbp, r13 shrx rcx, rbp, r14 shrx rcx, rbp, r15 shrx rcx, rbp, rsp shrx rcx, rbp, rsi shrx rcx, rbp, rbp shrx rdx, rax, rax shrx rdx, rax, rbx shrx rdx, rax, rcx shrx rdx, rax, rdx shrx rdx, rax, rdi shrx rdx, rax, r8 shrx rdx, rax, r9 shrx rdx, rax, r10 shrx rdx, rax, r11 shrx rdx, rax, r12 shrx rdx, rax, r13 shrx rdx, rax, r14 shrx rdx, rax, r15 shrx rdx, rax, rsp shrx rdx, rax, rsi shrx rdx, rax, rbp shrx rdx, rbx, rax shrx rdx, rbx, rbx shrx rdx, rbx, rcx shrx rdx, rbx, rdx shrx rdx, rbx, rdi shrx rdx, rbx, r8 shrx rdx, rbx, r9 shrx rdx, rbx, r10 shrx rdx, rbx, r11 shrx rdx, rbx, r12 shrx rdx, rbx, r13 shrx rdx, rbx, r14 shrx rdx, rbx, r15 shrx rdx, rbx, rsp shrx rdx, rbx, rsi shrx rdx, rbx, rbp shrx rdx, rcx, rax shrx rdx, rcx, rbx shrx rdx, rcx, rcx shrx rdx, rcx, rdx shrx rdx, rcx, rdi shrx rdx, rcx, r8 shrx rdx, rcx, r9 shrx rdx, rcx, r10 shrx rdx, rcx, r11 shrx rdx, rcx, r12 shrx rdx, rcx, r13 shrx rdx, rcx, r14 shrx rdx, rcx, r15 shrx rdx, rcx, rsp shrx rdx, rcx, rsi shrx rdx, rcx, rbp shrx rdx, rdx, rax shrx rdx, rdx, rbx shrx rdx, rdx, rcx shrx rdx, rdx, rdx shrx rdx, rdx, rdi shrx rdx, rdx, r8 shrx rdx, rdx, r9 shrx rdx, rdx, r10 shrx rdx, rdx, r11 shrx rdx, rdx, r12 shrx rdx, rdx, r13 shrx rdx, rdx, r14 shrx rdx, rdx, r15 shrx rdx, rdx, rsp shrx rdx, rdx, rsi shrx rdx, rdx, rbp shrx rdx, rdi, rax shrx rdx, rdi, rbx shrx rdx, rdi, rcx shrx rdx, rdi, rdx shrx rdx, rdi, rdi shrx rdx, rdi, r8 shrx rdx, rdi, r9 shrx rdx, rdi, r10 shrx rdx, rdi, r11 shrx rdx, rdi, r12 shrx rdx, rdi, r13 shrx rdx, rdi, r14 shrx rdx, rdi, r15 shrx rdx, rdi, rsp shrx rdx, rdi, rsi shrx rdx, rdi, rbp shrx rdx, r8, rax shrx rdx, r8, rbx shrx rdx, r8, rcx shrx rdx, r8, rdx shrx rdx, r8, rdi shrx rdx, r8, r8 shrx rdx, r8, r9 shrx rdx, r8, r10 shrx rdx, r8, r11 shrx rdx, r8, r12 shrx rdx, r8, r13 shrx rdx, r8, r14 shrx rdx, r8, r15 shrx rdx, r8, rsp shrx rdx, r8, rsi shrx rdx, r8, rbp shrx rdx, r9, rax shrx rdx, r9, rbx shrx rdx, r9, rcx shrx rdx, r9, rdx shrx rdx, r9, rdi shrx rdx, r9, r8 shrx rdx, r9, r9 shrx rdx, r9, r10 shrx rdx, r9, r11 shrx rdx, r9, r12 shrx rdx, r9, r13 shrx rdx, r9, r14 shrx rdx, r9, r15 shrx rdx, r9, rsp shrx rdx, r9, rsi shrx rdx, r9, rbp shrx rdx, r10, rax shrx rdx, r10, rbx shrx rdx, r10, rcx shrx rdx, r10, rdx shrx rdx, r10, rdi shrx rdx, r10, r8 shrx rdx, r10, r9 shrx rdx, r10, r10 shrx rdx, r10, r11 shrx rdx, r10, r12 shrx rdx, r10, r13 shrx rdx, r10, r14 shrx rdx, r10, r15 shrx rdx, r10, rsp shrx rdx, r10, rsi shrx rdx, r10, rbp shrx rdx, r11, rax shrx rdx, r11, rbx shrx rdx, r11, rcx shrx rdx, r11, rdx shrx rdx, r11, rdi shrx rdx, r11, r8 shrx rdx, r11, r9 shrx rdx, r11, r10 shrx rdx, r11, r11 shrx rdx, r11, r12 shrx rdx, r11, r13 shrx rdx, r11, r14 shrx rdx, r11, r15 shrx rdx, r11, rsp shrx rdx, r11, rsi shrx rdx, r11, rbp shrx rdx, r12, rax shrx rdx, r12, rbx shrx rdx, r12, rcx shrx rdx, r12, rdx shrx rdx, r12, rdi shrx rdx, r12, r8 shrx rdx, r12, r9 shrx rdx, r12, r10 shrx rdx, r12, r11 shrx rdx, r12, r12 shrx rdx, r12, r13 shrx rdx, r12, r14 shrx rdx, r12, r15 shrx rdx, r12, rsp shrx rdx, r12, rsi shrx rdx, r12, rbp shrx rdx, r13, rax shrx rdx, r13, rbx shrx rdx, r13, rcx shrx rdx, r13, rdx shrx rdx, r13, rdi shrx rdx, r13, r8 shrx rdx, r13, r9 shrx rdx, r13, r10 shrx rdx, r13, r11 shrx rdx, r13, r12 shrx rdx, r13, r13 shrx rdx, r13, r14 shrx rdx, r13, r15 shrx rdx, r13, rsp shrx rdx, r13, rsi shrx rdx, r13, rbp shrx rdx, r14, rax shrx rdx, r14, rbx shrx rdx, r14, rcx shrx rdx, r14, rdx shrx rdx, r14, rdi shrx rdx, r14, r8 shrx rdx, r14, r9 shrx rdx, r14, r10 shrx rdx, r14, r11 shrx rdx, r14, r12 shrx rdx, r14, r13 shrx rdx, r14, r14 shrx rdx, r14, r15 shrx rdx, r14, rsp shrx rdx, r14, rsi shrx rdx, r14, rbp shrx rdx, r15, rax shrx rdx, r15, rbx shrx rdx, r15, rcx shrx rdx, r15, rdx shrx rdx, r15, rdi shrx rdx, r15, r8 shrx rdx, r15, r9 shrx rdx, r15, r10 shrx rdx, r15, r11 shrx rdx, r15, r12 shrx rdx, r15, r13 shrx rdx, r15, r14 shrx rdx, r15, r15 shrx rdx, r15, rsp shrx rdx, r15, rsi shrx rdx, r15, rbp shrx rdx, rsp, rax shrx rdx, rsp, rbx shrx rdx, rsp, rcx shrx rdx, rsp, rdx shrx rdx, rsp, rdi shrx rdx, rsp, r8 shrx rdx, rsp, r9 shrx rdx, rsp, r10 shrx rdx, rsp, r11 shrx rdx, rsp, r12 shrx rdx, rsp, r13 shrx rdx, rsp, r14 shrx rdx, rsp, r15 shrx rdx, rsp, rsp shrx rdx, rsp, rsi shrx rdx, rsp, rbp shrx rdx, rsi, rax shrx rdx, rsi, rbx shrx rdx, rsi, rcx shrx rdx, rsi, rdx shrx rdx, rsi, rdi shrx rdx, rsi, r8 shrx rdx, rsi, r9 shrx rdx, rsi, r10 shrx rdx, rsi, r11 shrx rdx, rsi, r12 shrx rdx, rsi, r13 shrx rdx, rsi, r14 shrx rdx, rsi, r15 shrx rdx, rsi, rsp shrx rdx, rsi, rsi shrx rdx, rsi, rbp shrx rdx, rbp, rax shrx rdx, rbp, rbx shrx rdx, rbp, rcx shrx rdx, rbp, rdx shrx rdx, rbp, rdi shrx rdx, rbp, r8 shrx rdx, rbp, r9 shrx rdx, rbp, r10 shrx rdx, rbp, r11 shrx rdx, rbp, r12 shrx rdx, rbp, r13 shrx rdx, rbp, r14 shrx rdx, rbp, r15 shrx rdx, rbp, rsp shrx rdx, rbp, rsi shrx rdx, rbp, rbp shrx rdi, rax, rax shrx rdi, rax, rbx shrx rdi, rax, rcx shrx rdi, rax, rdx shrx rdi, rax, rdi shrx rdi, rax, r8 shrx rdi, rax, r9 shrx rdi, rax, r10 shrx rdi, rax, r11 shrx rdi, rax, r12 shrx rdi, rax, r13 shrx rdi, rax, r14 shrx rdi, rax, r15 shrx rdi, rax, rsp shrx rdi, rax, rsi shrx rdi, rax, rbp shrx rdi, rbx, rax shrx rdi, rbx, rbx shrx rdi, rbx, rcx shrx rdi, rbx, rdx shrx rdi, rbx, rdi shrx rdi, rbx, r8 shrx rdi, rbx, r9 shrx rdi, rbx, r10 shrx rdi, rbx, r11 shrx rdi, rbx, r12 shrx rdi, rbx, r13 shrx rdi, rbx, r14 shrx rdi, rbx, r15 shrx rdi, rbx, rsp shrx rdi, rbx, rsi shrx rdi, rbx, rbp shrx rdi, rcx, rax shrx rdi, rcx, rbx shrx rdi, rcx, rcx shrx rdi, rcx, rdx shrx rdi, rcx, rdi shrx rdi, rcx, r8 shrx rdi, rcx, r9 shrx rdi, rcx, r10 shrx rdi, rcx, r11 shrx rdi, rcx, r12 shrx rdi, rcx, r13 shrx rdi, rcx, r14 shrx rdi, rcx, r15 shrx rdi, rcx, rsp shrx rdi, rcx, rsi shrx rdi, rcx, rbp shrx rdi, rdx, rax shrx rdi, rdx, rbx shrx rdi, rdx, rcx shrx rdi, rdx, rdx shrx rdi, rdx, rdi shrx rdi, rdx, r8 shrx rdi, rdx, r9 shrx rdi, rdx, r10 shrx rdi, rdx, r11 shrx rdi, rdx, r12 shrx rdi, rdx, r13 shrx rdi, rdx, r14 shrx rdi, rdx, r15 shrx rdi, rdx, rsp shrx rdi, rdx, rsi shrx rdi, rdx, rbp shrx rdi, rdi, rax shrx rdi, rdi, rbx shrx rdi, rdi, rcx shrx rdi, rdi, rdx shrx rdi, rdi, rdi shrx rdi, rdi, r8 shrx rdi, rdi, r9 shrx rdi, rdi, r10 shrx rdi, rdi, r11 shrx rdi, rdi, r12 shrx rdi, rdi, r13 shrx rdi, rdi, r14 shrx rdi, rdi, r15 shrx rdi, rdi, rsp shrx rdi, rdi, rsi shrx rdi, rdi, rbp shrx rdi, r8, rax shrx rdi, r8, rbx shrx rdi, r8, rcx shrx rdi, r8, rdx shrx rdi, r8, rdi shrx rdi, r8, r8 shrx rdi, r8, r9 shrx rdi, r8, r10 shrx rdi, r8, r11 shrx rdi, r8, r12 shrx rdi, r8, r13 shrx rdi, r8, r14 shrx rdi, r8, r15 shrx rdi, r8, rsp shrx rdi, r8, rsi shrx rdi, r8, rbp shrx rdi, r9, rax shrx rdi, r9, rbx shrx rdi, r9, rcx shrx rdi, r9, rdx shrx rdi, r9, rdi shrx rdi, r9, r8 shrx rdi, r9, r9 shrx rdi, r9, r10 shrx rdi, r9, r11 shrx rdi, r9, r12 shrx rdi, r9, r13 shrx rdi, r9, r14 shrx rdi, r9, r15 shrx rdi, r9, rsp shrx rdi, r9, rsi shrx rdi, r9, rbp shrx rdi, r10, rax shrx rdi, r10, rbx shrx rdi, r10, rcx shrx rdi, r10, rdx shrx rdi, r10, rdi shrx rdi, r10, r8 shrx rdi, r10, r9 shrx rdi, r10, r10 shrx rdi, r10, r11 shrx rdi, r10, r12 shrx rdi, r10, r13 shrx rdi, r10, r14 shrx rdi, r10, r15 shrx rdi, r10, rsp shrx rdi, r10, rsi shrx rdi, r10, rbp shrx rdi, r11, rax shrx rdi, r11, rbx shrx rdi, r11, rcx shrx rdi, r11, rdx shrx rdi, r11, rdi shrx rdi, r11, r8 shrx rdi, r11, r9 shrx rdi, r11, r10 shrx rdi, r11, r11 shrx rdi, r11, r12 shrx rdi, r11, r13 shrx rdi, r11, r14 shrx rdi, r11, r15 shrx rdi, r11, rsp shrx rdi, r11, rsi shrx rdi, r11, rbp shrx rdi, r12, rax shrx rdi, r12, rbx shrx rdi, r12, rcx shrx rdi, r12, rdx shrx rdi, r12, rdi shrx rdi, r12, r8 shrx rdi, r12, r9 shrx rdi, r12, r10 shrx rdi, r12, r11 shrx rdi, r12, r12 shrx rdi, r12, r13 shrx rdi, r12, r14 shrx rdi, r12, r15 shrx rdi, r12, rsp shrx rdi, r12, rsi shrx rdi, r12, rbp shrx rdi, r13, rax shrx rdi, r13, rbx shrx rdi, r13, rcx shrx rdi, r13, rdx shrx rdi, r13, rdi shrx rdi, r13, r8 shrx rdi, r13, r9 shrx rdi, r13, r10 shrx rdi, r13, r11 shrx rdi, r13, r12 shrx rdi, r13, r13 shrx rdi, r13, r14 shrx rdi, r13, r15 shrx rdi, r13, rsp shrx rdi, r13, rsi shrx rdi, r13, rbp shrx rdi, r14, rax shrx rdi, r14, rbx shrx rdi, r14, rcx shrx rdi, r14, rdx shrx rdi, r14, rdi shrx rdi, r14, r8 shrx rdi, r14, r9 shrx rdi, r14, r10 shrx rdi, r14, r11 shrx rdi, r14, r12 shrx rdi, r14, r13 shrx rdi, r14, r14 shrx rdi, r14, r15 shrx rdi, r14, rsp shrx rdi, r14, rsi shrx rdi, r14, rbp shrx rdi, r15, rax shrx rdi, r15, rbx shrx rdi, r15, rcx shrx rdi, r15, rdx shrx rdi, r15, rdi shrx rdi, r15, r8 shrx rdi, r15, r9 shrx rdi, r15, r10 shrx rdi, r15, r11 shrx rdi, r15, r12 shrx rdi, r15, r13 shrx rdi, r15, r14 shrx rdi, r15, r15 shrx rdi, r15, rsp shrx rdi, r15, rsi shrx rdi, r15, rbp shrx rdi, rsp, rax shrx rdi, rsp, rbx shrx rdi, rsp, rcx shrx rdi, rsp, rdx shrx rdi, rsp, rdi shrx rdi, rsp, r8 shrx rdi, rsp, r9 shrx rdi, rsp, r10 shrx rdi, rsp, r11 shrx rdi, rsp, r12 shrx rdi, rsp, r13 shrx rdi, rsp, r14 shrx rdi, rsp, r15 shrx rdi, rsp, rsp shrx rdi, rsp, rsi shrx rdi, rsp, rbp shrx rdi, rsi, rax shrx rdi, rsi, rbx shrx rdi, rsi, rcx shrx rdi, rsi, rdx shrx rdi, rsi, rdi shrx rdi, rsi, r8 shrx rdi, rsi, r9 shrx rdi, rsi, r10 shrx rdi, rsi, r11 shrx rdi, rsi, r12 shrx rdi, rsi, r13 shrx rdi, rsi, r14 shrx rdi, rsi, r15 shrx rdi, rsi, rsp shrx rdi, rsi, rsi shrx rdi, rsi, rbp shrx rdi, rbp, rax shrx rdi, rbp, rbx shrx rdi, rbp, rcx shrx rdi, rbp, rdx shrx rdi, rbp, rdi shrx rdi, rbp, r8 shrx rdi, rbp, r9 shrx rdi, rbp, r10 shrx rdi, rbp, r11 shrx rdi, rbp, r12 shrx rdi, rbp, r13 shrx rdi, rbp, r14 shrx rdi, rbp, r15 shrx rdi, rbp, rsp shrx rdi, rbp, rsi shrx rdi, rbp, rbp shrx r8, rax, rax shrx r8, rax, rbx shrx r8, rax, rcx shrx r8, rax, rdx shrx r8, rax, rdi shrx r8, rax, r8 shrx r8, rax, r9 shrx r8, rax, r10 shrx r8, rax, r11 shrx r8, rax, r12 shrx r8, rax, r13 shrx r8, rax, r14 shrx r8, rax, r15 shrx r8, rax, rsp shrx r8, rax, rsi shrx r8, rax, rbp shrx r8, rbx, rax shrx r8, rbx, rbx shrx r8, rbx, rcx shrx r8, rbx, rdx shrx r8, rbx, rdi shrx r8, rbx, r8 shrx r8, rbx, r9 shrx r8, rbx, r10 shrx r8, rbx, r11 shrx r8, rbx, r12 shrx r8, rbx, r13 shrx r8, rbx, r14 shrx r8, rbx, r15 shrx r8, rbx, rsp shrx r8, rbx, rsi shrx r8, rbx, rbp shrx r8, rcx, rax shrx r8, rcx, rbx shrx r8, rcx, rcx shrx r8, rcx, rdx shrx r8, rcx, rdi shrx r8, rcx, r8 shrx r8, rcx, r9 shrx r8, rcx, r10 shrx r8, rcx, r11 shrx r8, rcx, r12 shrx r8, rcx, r13 shrx r8, rcx, r14 shrx r8, rcx, r15 shrx r8, rcx, rsp shrx r8, rcx, rsi shrx r8, rcx, rbp shrx r8, rdx, rax shrx r8, rdx, rbx shrx r8, rdx, rcx shrx r8, rdx, rdx shrx r8, rdx, rdi shrx r8, rdx, r8 shrx r8, rdx, r9 shrx r8, rdx, r10 shrx r8, rdx, r11 shrx r8, rdx, r12 shrx r8, rdx, r13 shrx r8, rdx, r14 shrx r8, rdx, r15 shrx r8, rdx, rsp shrx r8, rdx, rsi shrx r8, rdx, rbp shrx r8, rdi, rax shrx r8, rdi, rbx shrx r8, rdi, rcx shrx r8, rdi, rdx shrx r8, rdi, rdi shrx r8, rdi, r8 shrx r8, rdi, r9 shrx r8, rdi, r10 shrx r8, rdi, r11 shrx r8, rdi, r12 shrx r8, rdi, r13 shrx r8, rdi, r14 shrx r8, rdi, r15 shrx r8, rdi, rsp shrx r8, rdi, rsi shrx r8, rdi, rbp shrx r8, r8, rax shrx r8, r8, rbx shrx r8, r8, rcx shrx r8, r8, rdx shrx r8, r8, rdi shrx r8, r8, r8 shrx r8, r8, r9 shrx r8, r8, r10 shrx r8, r8, r11 shrx r8, r8, r12 shrx r8, r8, r13 shrx r8, r8, r14 shrx r8, r8, r15 shrx r8, r8, rsp shrx r8, r8, rsi shrx r8, r8, rbp shrx r8, r9, rax shrx r8, r9, rbx shrx r8, r9, rcx shrx r8, r9, rdx shrx r8, r9, rdi shrx r8, r9, r8 shrx r8, r9, r9 shrx r8, r9, r10 shrx r8, r9, r11 shrx r8, r9, r12 shrx r8, r9, r13 shrx r8, r9, r14 shrx r8, r9, r15 shrx r8, r9, rsp shrx r8, r9, rsi shrx r8, r9, rbp shrx r8, r10, rax shrx r8, r10, rbx shrx r8, r10, rcx shrx r8, r10, rdx shrx r8, r10, rdi shrx r8, r10, r8 shrx r8, r10, r9 shrx r8, r10, r10 shrx r8, r10, r11 shrx r8, r10, r12 shrx r8, r10, r13 shrx r8, r10, r14 shrx r8, r10, r15 shrx r8, r10, rsp shrx r8, r10, rsi shrx r8, r10, rbp shrx r8, r11, rax shrx r8, r11, rbx shrx r8, r11, rcx shrx r8, r11, rdx shrx r8, r11, rdi shrx r8, r11, r8 shrx r8, r11, r9 shrx r8, r11, r10 shrx r8, r11, r11 shrx r8, r11, r12 shrx r8, r11, r13 shrx r8, r11, r14 shrx r8, r11, r15 shrx r8, r11, rsp shrx r8, r11, rsi shrx r8, r11, rbp shrx r8, r12, rax shrx r8, r12, rbx shrx r8, r12, rcx shrx r8, r12, rdx shrx r8, r12, rdi shrx r8, r12, r8 shrx r8, r12, r9 shrx r8, r12, r10 shrx r8, r12, r11 shrx r8, r12, r12 shrx r8, r12, r13 shrx r8, r12, r14 shrx r8, r12, r15 shrx r8, r12, rsp shrx r8, r12, rsi shrx r8, r12, rbp shrx r8, r13, rax shrx r8, r13, rbx shrx r8, r13, rcx shrx r8, r13, rdx shrx r8, r13, rdi shrx r8, r13, r8 shrx r8, r13, r9 shrx r8, r13, r10 shrx r8, r13, r11 shrx r8, r13, r12 shrx r8, r13, r13 shrx r8, r13, r14 shrx r8, r13, r15 shrx r8, r13, rsp shrx r8, r13, rsi shrx r8, r13, rbp shrx r8, r14, rax shrx r8, r14, rbx shrx r8, r14, rcx shrx r8, r14, rdx shrx r8, r14, rdi shrx r8, r14, r8 shrx r8, r14, r9 shrx r8, r14, r10 shrx r8, r14, r11 shrx r8, r14, r12 shrx r8, r14, r13 shrx r8, r14, r14 shrx r8, r14, r15 shrx r8, r14, rsp shrx r8, r14, rsi shrx r8, r14, rbp shrx r8, r15, rax shrx r8, r15, rbx shrx r8, r15, rcx shrx r8, r15, rdx shrx r8, r15, rdi shrx r8, r15, r8 shrx r8, r15, r9 shrx r8, r15, r10 shrx r8, r15, r11 shrx r8, r15, r12 shrx r8, r15, r13 shrx r8, r15, r14 shrx r8, r15, r15 shrx r8, r15, rsp shrx r8, r15, rsi shrx r8, r15, rbp shrx r8, rsp, rax shrx r8, rsp, rbx shrx r8, rsp, rcx shrx r8, rsp, rdx shrx r8, rsp, rdi shrx r8, rsp, r8 shrx r8, rsp, r9 shrx r8, rsp, r10 shrx r8, rsp, r11 shrx r8, rsp, r12 shrx r8, rsp, r13 shrx r8, rsp, r14 shrx r8, rsp, r15 shrx r8, rsp, rsp shrx r8, rsp, rsi shrx r8, rsp, rbp shrx r8, rsi, rax shrx r8, rsi, rbx shrx r8, rsi, rcx shrx r8, rsi, rdx shrx r8, rsi, rdi shrx r8, rsi, r8 shrx r8, rsi, r9 shrx r8, rsi, r10 shrx r8, rsi, r11 shrx r8, rsi, r12 shrx r8, rsi, r13 shrx r8, rsi, r14 shrx r8, rsi, r15 shrx r8, rsi, rsp shrx r8, rsi, rsi shrx r8, rsi, rbp shrx r8, rbp, rax shrx r8, rbp, rbx shrx r8, rbp, rcx shrx r8, rbp, rdx shrx r8, rbp, rdi shrx r8, rbp, r8 shrx r8, rbp, r9 shrx r8, rbp, r10 shrx r8, rbp, r11 shrx r8, rbp, r12 shrx r8, rbp, r13 shrx r8, rbp, r14 shrx r8, rbp, r15 shrx r8, rbp, rsp shrx r8, rbp, rsi shrx r8, rbp, rbp shrx r9, rax, rax shrx r9, rax, rbx shrx r9, rax, rcx shrx r9, rax, rdx shrx r9, rax, rdi shrx r9, rax, r8 shrx r9, rax, r9 shrx r9, rax, r10 shrx r9, rax, r11 shrx r9, rax, r12 shrx r9, rax, r13 shrx r9, rax, r14 shrx r9, rax, r15 shrx r9, rax, rsp shrx r9, rax, rsi shrx r9, rax, rbp shrx r9, rbx, rax shrx r9, rbx, rbx shrx r9, rbx, rcx shrx r9, rbx, rdx shrx r9, rbx, rdi shrx r9, rbx, r8 shrx r9, rbx, r9 shrx r9, rbx, r10 shrx r9, rbx, r11 shrx r9, rbx, r12 shrx r9, rbx, r13 shrx r9, rbx, r14 shrx r9, rbx, r15 shrx r9, rbx, rsp shrx r9, rbx, rsi shrx r9, rbx, rbp shrx r9, rcx, rax shrx r9, rcx, rbx shrx r9, rcx, rcx shrx r9, rcx, rdx shrx r9, rcx, rdi shrx r9, rcx, r8 shrx r9, rcx, r9 shrx r9, rcx, r10 shrx r9, rcx, r11 shrx r9, rcx, r12 shrx r9, rcx, r13 shrx r9, rcx, r14 shrx r9, rcx, r15 shrx r9, rcx, rsp shrx r9, rcx, rsi shrx r9, rcx, rbp shrx r9, rdx, rax shrx r9, rdx, rbx shrx r9, rdx, rcx shrx r9, rdx, rdx shrx r9, rdx, rdi shrx r9, rdx, r8 shrx r9, rdx, r9 shrx r9, rdx, r10 shrx r9, rdx, r11 shrx r9, rdx, r12 shrx r9, rdx, r13 shrx r9, rdx, r14 shrx r9, rdx, r15 shrx r9, rdx, rsp shrx r9, rdx, rsi shrx r9, rdx, rbp shrx r9, rdi, rax shrx r9, rdi, rbx shrx r9, rdi, rcx shrx r9, rdi, rdx shrx r9, rdi, rdi shrx r9, rdi, r8 shrx r9, rdi, r9 shrx r9, rdi, r10 shrx r9, rdi, r11 shrx r9, rdi, r12 shrx r9, rdi, r13 shrx r9, rdi, r14 shrx r9, rdi, r15 shrx r9, rdi, rsp shrx r9, rdi, rsi shrx r9, rdi, rbp shrx r9, r8, rax shrx r9, r8, rbx shrx r9, r8, rcx shrx r9, r8, rdx shrx r9, r8, rdi shrx r9, r8, r8 shrx r9, r8, r9 shrx r9, r8, r10 shrx r9, r8, r11 shrx r9, r8, r12 shrx r9, r8, r13 shrx r9, r8, r14 shrx r9, r8, r15 shrx r9, r8, rsp shrx r9, r8, rsi shrx r9, r8, rbp shrx r9, r9, rax shrx r9, r9, rbx shrx r9, r9, rcx shrx r9, r9, rdx shrx r9, r9, rdi shrx r9, r9, r8 shrx r9, r9, r9 shrx r9, r9, r10 shrx r9, r9, r11 shrx r9, r9, r12 shrx r9, r9, r13 shrx r9, r9, r14 shrx r9, r9, r15 shrx r9, r9, rsp shrx r9, r9, rsi shrx r9, r9, rbp shrx r9, r10, rax shrx r9, r10, rbx shrx r9, r10, rcx shrx r9, r10, rdx shrx r9, r10, rdi shrx r9, r10, r8 shrx r9, r10, r9 shrx r9, r10, r10 shrx r9, r10, r11 shrx r9, r10, r12 shrx r9, r10, r13 shrx r9, r10, r14 shrx r9, r10, r15 shrx r9, r10, rsp shrx r9, r10, rsi shrx r9, r10, rbp shrx r9, r11, rax shrx r9, r11, rbx shrx r9, r11, rcx shrx r9, r11, rdx shrx r9, r11, rdi shrx r9, r11, r8 shrx r9, r11, r9 shrx r9, r11, r10 shrx r9, r11, r11 shrx r9, r11, r12 shrx r9, r11, r13 shrx r9, r11, r14 shrx r9, r11, r15 shrx r9, r11, rsp shrx r9, r11, rsi shrx r9, r11, rbp shrx r9, r12, rax shrx r9, r12, rbx shrx r9, r12, rcx shrx r9, r12, rdx shrx r9, r12, rdi shrx r9, r12, r8 shrx r9, r12, r9 shrx r9, r12, r10 shrx r9, r12, r11 shrx r9, r12, r12 shrx r9, r12, r13 shrx r9, r12, r14 shrx r9, r12, r15 shrx r9, r12, rsp shrx r9, r12, rsi shrx r9, r12, rbp shrx r9, r13, rax shrx r9, r13, rbx shrx r9, r13, rcx shrx r9, r13, rdx shrx r9, r13, rdi shrx r9, r13, r8 shrx r9, r13, r9 shrx r9, r13, r10 shrx r9, r13, r11 shrx r9, r13, r12 shrx r9, r13, r13 shrx r9, r13, r14 shrx r9, r13, r15 shrx r9, r13, rsp shrx r9, r13, rsi shrx r9, r13, rbp shrx r9, r14, rax shrx r9, r14, rbx shrx r9, r14, rcx shrx r9, r14, rdx shrx r9, r14, rdi shrx r9, r14, r8 shrx r9, r14, r9 shrx r9, r14, r10 shrx r9, r14, r11 shrx r9, r14, r12 shrx r9, r14, r13 shrx r9, r14, r14 shrx r9, r14, r15 shrx r9, r14, rsp shrx r9, r14, rsi shrx r9, r14, rbp shrx r9, r15, rax shrx r9, r15, rbx shrx r9, r15, rcx shrx r9, r15, rdx shrx r9, r15, rdi shrx r9, r15, r8 shrx r9, r15, r9 shrx r9, r15, r10 shrx r9, r15, r11 shrx r9, r15, r12 shrx r9, r15, r13 shrx r9, r15, r14 shrx r9, r15, r15 shrx r9, r15, rsp shrx r9, r15, rsi shrx r9, r15, rbp shrx r9, rsp, rax shrx r9, rsp, rbx shrx r9, rsp, rcx shrx r9, rsp, rdx shrx r9, rsp, rdi shrx r9, rsp, r8 shrx r9, rsp, r9 shrx r9, rsp, r10 shrx r9, rsp, r11 shrx r9, rsp, r12 shrx r9, rsp, r13 shrx r9, rsp, r14 shrx r9, rsp, r15 shrx r9, rsp, rsp shrx r9, rsp, rsi shrx r9, rsp, rbp shrx r9, rsi, rax shrx r9, rsi, rbx shrx r9, rsi, rcx shrx r9, rsi, rdx shrx r9, rsi, rdi shrx r9, rsi, r8 shrx r9, rsi, r9 shrx r9, rsi, r10 shrx r9, rsi, r11 shrx r9, rsi, r12 shrx r9, rsi, r13 shrx r9, rsi, r14 shrx r9, rsi, r15 shrx r9, rsi, rsp shrx r9, rsi, rsi shrx r9, rsi, rbp shrx r9, rbp, rax shrx r9, rbp, rbx shrx r9, rbp, rcx shrx r9, rbp, rdx shrx r9, rbp, rdi shrx r9, rbp, r8 shrx r9, rbp, r9 shrx r9, rbp, r10 shrx r9, rbp, r11 shrx r9, rbp, r12 shrx r9, rbp, r13 shrx r9, rbp, r14 shrx r9, rbp, r15 shrx r9, rbp, rsp shrx r9, rbp, rsi shrx r9, rbp, rbp shrx r10, rax, rax shrx r10, rax, rbx shrx r10, rax, rcx shrx r10, rax, rdx shrx r10, rax, rdi shrx r10, rax, r8 shrx r10, rax, r9 shrx r10, rax, r10 shrx r10, rax, r11 shrx r10, rax, r12 shrx r10, rax, r13 shrx r10, rax, r14 shrx r10, rax, r15 shrx r10, rax, rsp shrx r10, rax, rsi shrx r10, rax, rbp shrx r10, rbx, rax shrx r10, rbx, rbx shrx r10, rbx, rcx shrx r10, rbx, rdx shrx r10, rbx, rdi shrx r10, rbx, r8 shrx r10, rbx, r9 shrx r10, rbx, r10 shrx r10, rbx, r11 shrx r10, rbx, r12 shrx r10, rbx, r13 shrx r10, rbx, r14 shrx r10, rbx, r15 shrx r10, rbx, rsp shrx r10, rbx, rsi shrx r10, rbx, rbp shrx r10, rcx, rax shrx r10, rcx, rbx shrx r10, rcx, rcx shrx r10, rcx, rdx shrx r10, rcx, rdi shrx r10, rcx, r8 shrx r10, rcx, r9 shrx r10, rcx, r10 shrx r10, rcx, r11 shrx r10, rcx, r12 shrx r10, rcx, r13 shrx r10, rcx, r14 shrx r10, rcx, r15 shrx r10, rcx, rsp shrx r10, rcx, rsi shrx r10, rcx, rbp shrx r10, rdx, rax shrx r10, rdx, rbx shrx r10, rdx, rcx shrx r10, rdx, rdx shrx r10, rdx, rdi shrx r10, rdx, r8 shrx r10, rdx, r9 shrx r10, rdx, r10 shrx r10, rdx, r11 shrx r10, rdx, r12 shrx r10, rdx, r13 shrx r10, rdx, r14 shrx r10, rdx, r15 shrx r10, rdx, rsp shrx r10, rdx, rsi shrx r10, rdx, rbp shrx r10, rdi, rax shrx r10, rdi, rbx shrx r10, rdi, rcx shrx r10, rdi, rdx shrx r10, rdi, rdi shrx r10, rdi, r8 shrx r10, rdi, r9 shrx r10, rdi, r10 shrx r10, rdi, r11 shrx r10, rdi, r12 shrx r10, rdi, r13 shrx r10, rdi, r14 shrx r10, rdi, r15 shrx r10, rdi, rsp shrx r10, rdi, rsi shrx r10, rdi, rbp shrx r10, r8, rax shrx r10, r8, rbx shrx r10, r8, rcx shrx r10, r8, rdx shrx r10, r8, rdi shrx r10, r8, r8 shrx r10, r8, r9 shrx r10, r8, r10 shrx r10, r8, r11 shrx r10, r8, r12 shrx r10, r8, r13 shrx r10, r8, r14 shrx r10, r8, r15 shrx r10, r8, rsp shrx r10, r8, rsi shrx r10, r8, rbp shrx r10, r9, rax shrx r10, r9, rbx shrx r10, r9, rcx shrx r10, r9, rdx shrx r10, r9, rdi shrx r10, r9, r8 shrx r10, r9, r9 shrx r10, r9, r10 shrx r10, r9, r11 shrx r10, r9, r12 shrx r10, r9, r13 shrx r10, r9, r14 shrx r10, r9, r15 shrx r10, r9, rsp shrx r10, r9, rsi shrx r10, r9, rbp shrx r10, r10, rax shrx r10, r10, rbx shrx r10, r10, rcx shrx r10, r10, rdx shrx r10, r10, rdi shrx r10, r10, r8 shrx r10, r10, r9 shrx r10, r10, r10 shrx r10, r10, r11 shrx r10, r10, r12 shrx r10, r10, r13 shrx r10, r10, r14 shrx r10, r10, r15 shrx r10, r10, rsp shrx r10, r10, rsi shrx r10, r10, rbp shrx r10, r11, rax shrx r10, r11, rbx shrx r10, r11, rcx shrx r10, r11, rdx shrx r10, r11, rdi shrx r10, r11, r8 shrx r10, r11, r9 shrx r10, r11, r10 shrx r10, r11, r11 shrx r10, r11, r12 shrx r10, r11, r13 shrx r10, r11, r14 shrx r10, r11, r15 shrx r10, r11, rsp shrx r10, r11, rsi shrx r10, r11, rbp shrx r10, r12, rax shrx r10, r12, rbx shrx r10, r12, rcx shrx r10, r12, rdx shrx r10, r12, rdi shrx r10, r12, r8 shrx r10, r12, r9 shrx r10, r12, r10 shrx r10, r12, r11 shrx r10, r12, r12 shrx r10, r12, r13 shrx r10, r12, r14 shrx r10, r12, r15 shrx r10, r12, rsp shrx r10, r12, rsi shrx r10, r12, rbp shrx r10, r13, rax shrx r10, r13, rbx shrx r10, r13, rcx shrx r10, r13, rdx shrx r10, r13, rdi shrx r10, r13, r8 shrx r10, r13, r9 shrx r10, r13, r10 shrx r10, r13, r11 shrx r10, r13, r12 shrx r10, r13, r13 shrx r10, r13, r14 shrx r10, r13, r15 shrx r10, r13, rsp shrx r10, r13, rsi shrx r10, r13, rbp shrx r10, r14, rax shrx r10, r14, rbx shrx r10, r14, rcx shrx r10, r14, rdx shrx r10, r14, rdi shrx r10, r14, r8 shrx r10, r14, r9 shrx r10, r14, r10 shrx r10, r14, r11 shrx r10, r14, r12 shrx r10, r14, r13 shrx r10, r14, r14 shrx r10, r14, r15 shrx r10, r14, rsp shrx r10, r14, rsi shrx r10, r14, rbp shrx r10, r15, rax shrx r10, r15, rbx shrx r10, r15, rcx shrx r10, r15, rdx shrx r10, r15, rdi shrx r10, r15, r8 shrx r10, r15, r9 shrx r10, r15, r10 shrx r10, r15, r11 shrx r10, r15, r12 shrx r10, r15, r13 shrx r10, r15, r14 shrx r10, r15, r15 shrx r10, r15, rsp shrx r10, r15, rsi shrx r10, r15, rbp shrx r10, rsp, rax shrx r10, rsp, rbx shrx r10, rsp, rcx shrx r10, rsp, rdx shrx r10, rsp, rdi shrx r10, rsp, r8 shrx r10, rsp, r9 shrx r10, rsp, r10 shrx r10, rsp, r11 shrx r10, rsp, r12 shrx r10, rsp, r13 shrx r10, rsp, r14 shrx r10, rsp, r15 shrx r10, rsp, rsp shrx r10, rsp, rsi shrx r10, rsp, rbp shrx r10, rsi, rax shrx r10, rsi, rbx shrx r10, rsi, rcx shrx r10, rsi, rdx shrx r10, rsi, rdi shrx r10, rsi, r8 shrx r10, rsi, r9 shrx r10, rsi, r10 shrx r10, rsi, r11 shrx r10, rsi, r12 shrx r10, rsi, r13 shrx r10, rsi, r14 shrx r10, rsi, r15 shrx r10, rsi, rsp shrx r10, rsi, rsi shrx r10, rsi, rbp shrx r10, rbp, rax shrx r10, rbp, rbx shrx r10, rbp, rcx shrx r10, rbp, rdx shrx r10, rbp, rdi shrx r10, rbp, r8 shrx r10, rbp, r9 shrx r10, rbp, r10 shrx r10, rbp, r11 shrx r10, rbp, r12 shrx r10, rbp, r13 shrx r10, rbp, r14 shrx r10, rbp, r15 shrx r10, rbp, rsp shrx r10, rbp, rsi shrx r10, rbp, rbp shrx r11, rax, rax shrx r11, rax, rbx shrx r11, rax, rcx shrx r11, rax, rdx shrx r11, rax, rdi shrx r11, rax, r8 shrx r11, rax, r9 shrx r11, rax, r10 shrx r11, rax, r11 shrx r11, rax, r12 shrx r11, rax, r13 shrx r11, rax, r14 shrx r11, rax, r15 shrx r11, rax, rsp shrx r11, rax, rsi shrx r11, rax, rbp shrx r11, rbx, rax shrx r11, rbx, rbx shrx r11, rbx, rcx shrx r11, rbx, rdx shrx r11, rbx, rdi shrx r11, rbx, r8 shrx r11, rbx, r9 shrx r11, rbx, r10 shrx r11, rbx, r11 shrx r11, rbx, r12 shrx r11, rbx, r13 shrx r11, rbx, r14 shrx r11, rbx, r15 shrx r11, rbx, rsp shrx r11, rbx, rsi shrx r11, rbx, rbp shrx r11, rcx, rax shrx r11, rcx, rbx shrx r11, rcx, rcx shrx r11, rcx, rdx shrx r11, rcx, rdi shrx r11, rcx, r8 shrx r11, rcx, r9 shrx r11, rcx, r10 shrx r11, rcx, r11 shrx r11, rcx, r12 shrx r11, rcx, r13 shrx r11, rcx, r14 shrx r11, rcx, r15 shrx r11, rcx, rsp shrx r11, rcx, rsi shrx r11, rcx, rbp shrx r11, rdx, rax shrx r11, rdx, rbx shrx r11, rdx, rcx shrx r11, rdx, rdx shrx r11, rdx, rdi shrx r11, rdx, r8 shrx r11, rdx, r9 shrx r11, rdx, r10 shrx r11, rdx, r11 shrx r11, rdx, r12 shrx r11, rdx, r13 shrx r11, rdx, r14 shrx r11, rdx, r15 shrx r11, rdx, rsp shrx r11, rdx, rsi shrx r11, rdx, rbp shrx r11, rdi, rax shrx r11, rdi, rbx shrx r11, rdi, rcx shrx r11, rdi, rdx shrx r11, rdi, rdi shrx r11, rdi, r8 shrx r11, rdi, r9 shrx r11, rdi, r10 shrx r11, rdi, r11 shrx r11, rdi, r12 shrx r11, rdi, r13 shrx r11, rdi, r14 shrx r11, rdi, r15 shrx r11, rdi, rsp shrx r11, rdi, rsi shrx r11, rdi, rbp shrx r11, r8, rax shrx r11, r8, rbx shrx r11, r8, rcx shrx r11, r8, rdx shrx r11, r8, rdi shrx r11, r8, r8 shrx r11, r8, r9 shrx r11, r8, r10 shrx r11, r8, r11 shrx r11, r8, r12 shrx r11, r8, r13 shrx r11, r8, r14 shrx r11, r8, r15 shrx r11, r8, rsp shrx r11, r8, rsi shrx r11, r8, rbp shrx r11, r9, rax shrx r11, r9, rbx shrx r11, r9, rcx shrx r11, r9, rdx shrx r11, r9, rdi shrx r11, r9, r8 shrx r11, r9, r9 shrx r11, r9, r10 shrx r11, r9, r11 shrx r11, r9, r12 shrx r11, r9, r13 shrx r11, r9, r14 shrx r11, r9, r15 shrx r11, r9, rsp shrx r11, r9, rsi shrx r11, r9, rbp shrx r11, r10, rax shrx r11, r10, rbx shrx r11, r10, rcx shrx r11, r10, rdx shrx r11, r10, rdi shrx r11, r10, r8 shrx r11, r10, r9 shrx r11, r10, r10 shrx r11, r10, r11 shrx r11, r10, r12 shrx r11, r10, r13 shrx r11, r10, r14 shrx r11, r10, r15 shrx r11, r10, rsp shrx r11, r10, rsi shrx r11, r10, rbp shrx r11, r11, rax shrx r11, r11, rbx shrx r11, r11, rcx shrx r11, r11, rdx shrx r11, r11, rdi shrx r11, r11, r8 shrx r11, r11, r9 shrx r11, r11, r10 shrx r11, r11, r11 shrx r11, r11, r12 shrx r11, r11, r13 shrx r11, r11, r14 shrx r11, r11, r15 shrx r11, r11, rsp shrx r11, r11, rsi shrx r11, r11, rbp shrx r11, r12, rax shrx r11, r12, rbx shrx r11, r12, rcx shrx r11, r12, rdx shrx r11, r12, rdi shrx r11, r12, r8 shrx r11, r12, r9 shrx r11, r12, r10 shrx r11, r12, r11 shrx r11, r12, r12 shrx r11, r12, r13 shrx r11, r12, r14 shrx r11, r12, r15 shrx r11, r12, rsp shrx r11, r12, rsi shrx r11, r12, rbp shrx r11, r13, rax shrx r11, r13, rbx shrx r11, r13, rcx shrx r11, r13, rdx shrx r11, r13, rdi shrx r11, r13, r8 shrx r11, r13, r9 shrx r11, r13, r10 shrx r11, r13, r11 shrx r11, r13, r12 shrx r11, r13, r13 shrx r11, r13, r14 shrx r11, r13, r15 shrx r11, r13, rsp shrx r11, r13, rsi shrx r11, r13, rbp shrx r11, r14, rax shrx r11, r14, rbx shrx r11, r14, rcx shrx r11, r14, rdx shrx r11, r14, rdi shrx r11, r14, r8 shrx r11, r14, r9 shrx r11, r14, r10 shrx r11, r14, r11 shrx r11, r14, r12 shrx r11, r14, r13 shrx r11, r14, r14 shrx r11, r14, r15 shrx r11, r14, rsp shrx r11, r14, rsi shrx r11, r14, rbp shrx r11, r15, rax shrx r11, r15, rbx shrx r11, r15, rcx shrx r11, r15, rdx shrx r11, r15, rdi shrx r11, r15, r8 shrx r11, r15, r9 shrx r11, r15, r10 shrx r11, r15, r11 shrx r11, r15, r12 shrx r11, r15, r13 shrx r11, r15, r14 shrx r11, r15, r15 shrx r11, r15, rsp shrx r11, r15, rsi shrx r11, r15, rbp shrx r11, rsp, rax shrx r11, rsp, rbx shrx r11, rsp, rcx shrx r11, rsp, rdx shrx r11, rsp, rdi shrx r11, rsp, r8 shrx r11, rsp, r9 shrx r11, rsp, r10 shrx r11, rsp, r11 shrx r11, rsp, r12 shrx r11, rsp, r13 shrx r11, rsp, r14 shrx r11, rsp, r15 shrx r11, rsp, rsp shrx r11, rsp, rsi shrx r11, rsp, rbp shrx r11, rsi, rax shrx r11, rsi, rbx shrx r11, rsi, rcx shrx r11, rsi, rdx shrx r11, rsi, rdi shrx r11, rsi, r8 shrx r11, rsi, r9 shrx r11, rsi, r10 shrx r11, rsi, r11 shrx r11, rsi, r12 shrx r11, rsi, r13 shrx r11, rsi, r14 shrx r11, rsi, r15 shrx r11, rsi, rsp shrx r11, rsi, rsi shrx r11, rsi, rbp shrx r11, rbp, rax shrx r11, rbp, rbx shrx r11, rbp, rcx shrx r11, rbp, rdx shrx r11, rbp, rdi shrx r11, rbp, r8 shrx r11, rbp, r9 shrx r11, rbp, r10 shrx r11, rbp, r11 shrx r11, rbp, r12 shrx r11, rbp, r13 shrx r11, rbp, r14 shrx r11, rbp, r15 shrx r11, rbp, rsp shrx r11, rbp, rsi shrx r11, rbp, rbp shrx r12, rax, rax shrx r12, rax, rbx shrx r12, rax, rcx shrx r12, rax, rdx shrx r12, rax, rdi shrx r12, rax, r8 shrx r12, rax, r9 shrx r12, rax, r10 shrx r12, rax, r11 shrx r12, rax, r12 shrx r12, rax, r13 shrx r12, rax, r14 shrx r12, rax, r15 shrx r12, rax, rsp shrx r12, rax, rsi shrx r12, rax, rbp shrx r12, rbx, rax shrx r12, rbx, rbx shrx r12, rbx, rcx shrx r12, rbx, rdx shrx r12, rbx, rdi shrx r12, rbx, r8 shrx r12, rbx, r9 shrx r12, rbx, r10 shrx r12, rbx, r11 shrx r12, rbx, r12 shrx r12, rbx, r13 shrx r12, rbx, r14 shrx r12, rbx, r15 shrx r12, rbx, rsp shrx r12, rbx, rsi shrx r12, rbx, rbp shrx r12, rcx, rax shrx r12, rcx, rbx shrx r12, rcx, rcx shrx r12, rcx, rdx shrx r12, rcx, rdi shrx r12, rcx, r8 shrx r12, rcx, r9 shrx r12, rcx, r10 shrx r12, rcx, r11 shrx r12, rcx, r12 shrx r12, rcx, r13 shrx r12, rcx, r14 shrx r12, rcx, r15 shrx r12, rcx, rsp shrx r12, rcx, rsi shrx r12, rcx, rbp shrx r12, rdx, rax shrx r12, rdx, rbx shrx r12, rdx, rcx shrx r12, rdx, rdx shrx r12, rdx, rdi shrx r12, rdx, r8 shrx r12, rdx, r9 shrx r12, rdx, r10 shrx r12, rdx, r11 shrx r12, rdx, r12 shrx r12, rdx, r13 shrx r12, rdx, r14 shrx r12, rdx, r15 shrx r12, rdx, rsp shrx r12, rdx, rsi shrx r12, rdx, rbp shrx r12, rdi, rax shrx r12, rdi, rbx shrx r12, rdi, rcx shrx r12, rdi, rdx shrx r12, rdi, rdi shrx r12, rdi, r8 shrx r12, rdi, r9 shrx r12, rdi, r10 shrx r12, rdi, r11 shrx r12, rdi, r12 shrx r12, rdi, r13 shrx r12, rdi, r14 shrx r12, rdi, r15 shrx r12, rdi, rsp shrx r12, rdi, rsi shrx r12, rdi, rbp shrx r12, r8, rax shrx r12, r8, rbx shrx r12, r8, rcx shrx r12, r8, rdx shrx r12, r8, rdi shrx r12, r8, r8 shrx r12, r8, r9 shrx r12, r8, r10 shrx r12, r8, r11 shrx r12, r8, r12 shrx r12, r8, r13 shrx r12, r8, r14 shrx r12, r8, r15 shrx r12, r8, rsp shrx r12, r8, rsi shrx r12, r8, rbp shrx r12, r9, rax shrx r12, r9, rbx shrx r12, r9, rcx shrx r12, r9, rdx shrx r12, r9, rdi shrx r12, r9, r8 shrx r12, r9, r9 shrx r12, r9, r10 shrx r12, r9, r11 shrx r12, r9, r12 shrx r12, r9, r13 shrx r12, r9, r14 shrx r12, r9, r15 shrx r12, r9, rsp shrx r12, r9, rsi shrx r12, r9, rbp shrx r12, r10, rax shrx r12, r10, rbx shrx r12, r10, rcx shrx r12, r10, rdx shrx r12, r10, rdi shrx r12, r10, r8 shrx r12, r10, r9 shrx r12, r10, r10 shrx r12, r10, r11 shrx r12, r10, r12 shrx r12, r10, r13 shrx r12, r10, r14 shrx r12, r10, r15 shrx r12, r10, rsp shrx r12, r10, rsi shrx r12, r10, rbp shrx r12, r11, rax shrx r12, r11, rbx shrx r12, r11, rcx shrx r12, r11, rdx shrx r12, r11, rdi shrx r12, r11, r8 shrx r12, r11, r9 shrx r12, r11, r10 shrx r12, r11, r11 shrx r12, r11, r12 shrx r12, r11, r13 shrx r12, r11, r14 shrx r12, r11, r15 shrx r12, r11, rsp shrx r12, r11, rsi shrx r12, r11, rbp shrx r12, r12, rax shrx r12, r12, rbx shrx r12, r12, rcx shrx r12, r12, rdx shrx r12, r12, rdi shrx r12, r12, r8 shrx r12, r12, r9 shrx r12, r12, r10 shrx r12, r12, r11 shrx r12, r12, r12 shrx r12, r12, r13 shrx r12, r12, r14 shrx r12, r12, r15 shrx r12, r12, rsp shrx r12, r12, rsi shrx r12, r12, rbp shrx r12, r13, rax shrx r12, r13, rbx shrx r12, r13, rcx shrx r12, r13, rdx shrx r12, r13, rdi shrx r12, r13, r8 shrx r12, r13, r9 shrx r12, r13, r10 shrx r12, r13, r11 shrx r12, r13, r12 shrx r12, r13, r13 shrx r12, r13, r14 shrx r12, r13, r15 shrx r12, r13, rsp shrx r12, r13, rsi shrx r12, r13, rbp shrx r12, r14, rax shrx r12, r14, rbx shrx r12, r14, rcx shrx r12, r14, rdx shrx r12, r14, rdi shrx r12, r14, r8 shrx r12, r14, r9 shrx r12, r14, r10 shrx r12, r14, r11 shrx r12, r14, r12 shrx r12, r14, r13 shrx r12, r14, r14 shrx r12, r14, r15 shrx r12, r14, rsp shrx r12, r14, rsi shrx r12, r14, rbp shrx r12, r15, rax shrx r12, r15, rbx shrx r12, r15, rcx shrx r12, r15, rdx shrx r12, r15, rdi shrx r12, r15, r8 shrx r12, r15, r9 shrx r12, r15, r10 shrx r12, r15, r11 shrx r12, r15, r12 shrx r12, r15, r13 shrx r12, r15, r14 shrx r12, r15, r15 shrx r12, r15, rsp shrx r12, r15, rsi shrx r12, r15, rbp shrx r12, rsp, rax shrx r12, rsp, rbx shrx r12, rsp, rcx shrx r12, rsp, rdx shrx r12, rsp, rdi shrx r12, rsp, r8 shrx r12, rsp, r9 shrx r12, rsp, r10 shrx r12, rsp, r11 shrx r12, rsp, r12 shrx r12, rsp, r13 shrx r12, rsp, r14 shrx r12, rsp, r15 shrx r12, rsp, rsp shrx r12, rsp, rsi shrx r12, rsp, rbp shrx r12, rsi, rax shrx r12, rsi, rbx shrx r12, rsi, rcx shrx r12, rsi, rdx shrx r12, rsi, rdi shrx r12, rsi, r8 shrx r12, rsi, r9 shrx r12, rsi, r10 shrx r12, rsi, r11 shrx r12, rsi, r12 shrx r12, rsi, r13 shrx r12, rsi, r14 shrx r12, rsi, r15 shrx r12, rsi, rsp shrx r12, rsi, rsi shrx r12, rsi, rbp shrx r12, rbp, rax shrx r12, rbp, rbx shrx r12, rbp, rcx shrx r12, rbp, rdx shrx r12, rbp, rdi shrx r12, rbp, r8 shrx r12, rbp, r9 shrx r12, rbp, r10 shrx r12, rbp, r11 shrx r12, rbp, r12 shrx r12, rbp, r13 shrx r12, rbp, r14 shrx r12, rbp, r15 shrx r12, rbp, rsp shrx r12, rbp, rsi shrx r12, rbp, rbp shrx r13, rax, rax shrx r13, rax, rbx shrx r13, rax, rcx shrx r13, rax, rdx shrx r13, rax, rdi shrx r13, rax, r8 shrx r13, rax, r9 shrx r13, rax, r10 shrx r13, rax, r11 shrx r13, rax, r12 shrx r13, rax, r13 shrx r13, rax, r14 shrx r13, rax, r15 shrx r13, rax, rsp shrx r13, rax, rsi shrx r13, rax, rbp shrx r13, rbx, rax shrx r13, rbx, rbx shrx r13, rbx, rcx shrx r13, rbx, rdx shrx r13, rbx, rdi shrx r13, rbx, r8 shrx r13, rbx, r9 shrx r13, rbx, r10 shrx r13, rbx, r11 shrx r13, rbx, r12 shrx r13, rbx, r13 shrx r13, rbx, r14 shrx r13, rbx, r15 shrx r13, rbx, rsp shrx r13, rbx, rsi shrx r13, rbx, rbp shrx r13, rcx, rax shrx r13, rcx, rbx shrx r13, rcx, rcx shrx r13, rcx, rdx shrx r13, rcx, rdi shrx r13, rcx, r8 shrx r13, rcx, r9 shrx r13, rcx, r10 shrx r13, rcx, r11 shrx r13, rcx, r12 shrx r13, rcx, r13 shrx r13, rcx, r14 shrx r13, rcx, r15 shrx r13, rcx, rsp shrx r13, rcx, rsi shrx r13, rcx, rbp shrx r13, rdx, rax shrx r13, rdx, rbx shrx r13, rdx, rcx shrx r13, rdx, rdx shrx r13, rdx, rdi shrx r13, rdx, r8 shrx r13, rdx, r9 shrx r13, rdx, r10 shrx r13, rdx, r11 shrx r13, rdx, r12 shrx r13, rdx, r13 shrx r13, rdx, r14 shrx r13, rdx, r15 shrx r13, rdx, rsp shrx r13, rdx, rsi shrx r13, rdx, rbp shrx r13, rdi, rax shrx r13, rdi, rbx shrx r13, rdi, rcx shrx r13, rdi, rdx shrx r13, rdi, rdi shrx r13, rdi, r8 shrx r13, rdi, r9 shrx r13, rdi, r10 shrx r13, rdi, r11 shrx r13, rdi, r12 shrx r13, rdi, r13 shrx r13, rdi, r14 shrx r13, rdi, r15 shrx r13, rdi, rsp shrx r13, rdi, rsi shrx r13, rdi, rbp shrx r13, r8, rax shrx r13, r8, rbx shrx r13, r8, rcx shrx r13, r8, rdx shrx r13, r8, rdi shrx r13, r8, r8 shrx r13, r8, r9 shrx r13, r8, r10 shrx r13, r8, r11 shrx r13, r8, r12 shrx r13, r8, r13 shrx r13, r8, r14 shrx r13, r8, r15 shrx r13, r8, rsp shrx r13, r8, rsi shrx r13, r8, rbp shrx r13, r9, rax shrx r13, r9, rbx shrx r13, r9, rcx shrx r13, r9, rdx shrx r13, r9, rdi shrx r13, r9, r8 shrx r13, r9, r9 shrx r13, r9, r10 shrx r13, r9, r11 shrx r13, r9, r12 shrx r13, r9, r13 shrx r13, r9, r14 shrx r13, r9, r15 shrx r13, r9, rsp shrx r13, r9, rsi shrx r13, r9, rbp shrx r13, r10, rax shrx r13, r10, rbx shrx r13, r10, rcx shrx r13, r10, rdx shrx r13, r10, rdi shrx r13, r10, r8 shrx r13, r10, r9 shrx r13, r10, r10 shrx r13, r10, r11 shrx r13, r10, r12 shrx r13, r10, r13 shrx r13, r10, r14 shrx r13, r10, r15 shrx r13, r10, rsp shrx r13, r10, rsi shrx r13, r10, rbp shrx r13, r11, rax shrx r13, r11, rbx shrx r13, r11, rcx shrx r13, r11, rdx shrx r13, r11, rdi shrx r13, r11, r8 shrx r13, r11, r9 shrx r13, r11, r10 shrx r13, r11, r11 shrx r13, r11, r12 shrx r13, r11, r13 shrx r13, r11, r14 shrx r13, r11, r15 shrx r13, r11, rsp shrx r13, r11, rsi shrx r13, r11, rbp shrx r13, r12, rax shrx r13, r12, rbx shrx r13, r12, rcx shrx r13, r12, rdx shrx r13, r12, rdi shrx r13, r12, r8 shrx r13, r12, r9 shrx r13, r12, r10 shrx r13, r12, r11 shrx r13, r12, r12 shrx r13, r12, r13 shrx r13, r12, r14 shrx r13, r12, r15 shrx r13, r12, rsp shrx r13, r12, rsi shrx r13, r12, rbp shrx r13, r13, rax shrx r13, r13, rbx shrx r13, r13, rcx shrx r13, r13, rdx shrx r13, r13, rdi shrx r13, r13, r8 shrx r13, r13, r9 shrx r13, r13, r10 shrx r13, r13, r11 shrx r13, r13, r12 shrx r13, r13, r13 shrx r13, r13, r14 shrx r13, r13, r15 shrx r13, r13, rsp shrx r13, r13, rsi shrx r13, r13, rbp shrx r13, r14, rax shrx r13, r14, rbx shrx r13, r14, rcx shrx r13, r14, rdx shrx r13, r14, rdi shrx r13, r14, r8 shrx r13, r14, r9 shrx r13, r14, r10 shrx r13, r14, r11 shrx r13, r14, r12 shrx r13, r14, r13 shrx r13, r14, r14 shrx r13, r14, r15 shrx r13, r14, rsp shrx r13, r14, rsi shrx r13, r14, rbp shrx r13, r15, rax shrx r13, r15, rbx shrx r13, r15, rcx shrx r13, r15, rdx shrx r13, r15, rdi shrx r13, r15, r8 shrx r13, r15, r9 shrx r13, r15, r10 shrx r13, r15, r11 shrx r13, r15, r12 shrx r13, r15, r13 shrx r13, r15, r14 shrx r13, r15, r15 shrx r13, r15, rsp shrx r13, r15, rsi shrx r13, r15, rbp shrx r13, rsp, rax shrx r13, rsp, rbx shrx r13, rsp, rcx shrx r13, rsp, rdx shrx r13, rsp, rdi shrx r13, rsp, r8 shrx r13, rsp, r9 shrx r13, rsp, r10 shrx r13, rsp, r11 shrx r13, rsp, r12 shrx r13, rsp, r13 shrx r13, rsp, r14 shrx r13, rsp, r15 shrx r13, rsp, rsp shrx r13, rsp, rsi shrx r13, rsp, rbp shrx r13, rsi, rax shrx r13, rsi, rbx shrx r13, rsi, rcx shrx r13, rsi, rdx shrx r13, rsi, rdi shrx r13, rsi, r8 shrx r13, rsi, r9 shrx r13, rsi, r10 shrx r13, rsi, r11 shrx r13, rsi, r12 shrx r13, rsi, r13 shrx r13, rsi, r14 shrx r13, rsi, r15 shrx r13, rsi, rsp shrx r13, rsi, rsi shrx r13, rsi, rbp shrx r13, rbp, rax shrx r13, rbp, rbx shrx r13, rbp, rcx shrx r13, rbp, rdx shrx r13, rbp, rdi shrx r13, rbp, r8 shrx r13, rbp, r9 shrx r13, rbp, r10 shrx r13, rbp, r11 shrx r13, rbp, r12 shrx r13, rbp, r13 shrx r13, rbp, r14 shrx r13, rbp, r15 shrx r13, rbp, rsp shrx r13, rbp, rsi shrx r13, rbp, rbp shrx r14, rax, rax shrx r14, rax, rbx shrx r14, rax, rcx shrx r14, rax, rdx shrx r14, rax, rdi shrx r14, rax, r8 shrx r14, rax, r9 shrx r14, rax, r10 shrx r14, rax, r11 shrx r14, rax, r12 shrx r14, rax, r13 shrx r14, rax, r14 shrx r14, rax, r15 shrx r14, rax, rsp shrx r14, rax, rsi shrx r14, rax, rbp shrx r14, rbx, rax shrx r14, rbx, rbx shrx r14, rbx, rcx shrx r14, rbx, rdx shrx r14, rbx, rdi shrx r14, rbx, r8 shrx r14, rbx, r9 shrx r14, rbx, r10 shrx r14, rbx, r11 shrx r14, rbx, r12 shrx r14, rbx, r13 shrx r14, rbx, r14 shrx r14, rbx, r15 shrx r14, rbx, rsp shrx r14, rbx, rsi shrx r14, rbx, rbp shrx r14, rcx, rax shrx r14, rcx, rbx shrx r14, rcx, rcx shrx r14, rcx, rdx shrx r14, rcx, rdi shrx r14, rcx, r8 shrx r14, rcx, r9 shrx r14, rcx, r10 shrx r14, rcx, r11 shrx r14, rcx, r12 shrx r14, rcx, r13 shrx r14, rcx, r14 shrx r14, rcx, r15 shrx r14, rcx, rsp shrx r14, rcx, rsi shrx r14, rcx, rbp shrx r14, rdx, rax shrx r14, rdx, rbx shrx r14, rdx, rcx shrx r14, rdx, rdx shrx r14, rdx, rdi shrx r14, rdx, r8 shrx r14, rdx, r9 shrx r14, rdx, r10 shrx r14, rdx, r11 shrx r14, rdx, r12 shrx r14, rdx, r13 shrx r14, rdx, r14 shrx r14, rdx, r15 shrx r14, rdx, rsp shrx r14, rdx, rsi shrx r14, rdx, rbp shrx r14, rdi, rax shrx r14, rdi, rbx shrx r14, rdi, rcx shrx r14, rdi, rdx shrx r14, rdi, rdi shrx r14, rdi, r8 shrx r14, rdi, r9 shrx r14, rdi, r10 shrx r14, rdi, r11 shrx r14, rdi, r12 shrx r14, rdi, r13 shrx r14, rdi, r14 shrx r14, rdi, r15 shrx r14, rdi, rsp shrx r14, rdi, rsi shrx r14, rdi, rbp shrx r14, r8, rax shrx r14, r8, rbx shrx r14, r8, rcx shrx r14, r8, rdx shrx r14, r8, rdi shrx r14, r8, r8 shrx r14, r8, r9 shrx r14, r8, r10 shrx r14, r8, r11 shrx r14, r8, r12 shrx r14, r8, r13 shrx r14, r8, r14 shrx r14, r8, r15 shrx r14, r8, rsp shrx r14, r8, rsi shrx r14, r8, rbp shrx r14, r9, rax shrx r14, r9, rbx shrx r14, r9, rcx shrx r14, r9, rdx shrx r14, r9, rdi shrx r14, r9, r8 shrx r14, r9, r9 shrx r14, r9, r10 shrx r14, r9, r11 shrx r14, r9, r12 shrx r14, r9, r13 shrx r14, r9, r14 shrx r14, r9, r15 shrx r14, r9, rsp shrx r14, r9, rsi shrx r14, r9, rbp shrx r14, r10, rax shrx r14, r10, rbx shrx r14, r10, rcx shrx r14, r10, rdx shrx r14, r10, rdi shrx r14, r10, r8 shrx r14, r10, r9 shrx r14, r10, r10 shrx r14, r10, r11 shrx r14, r10, r12 shrx r14, r10, r13 shrx r14, r10, r14 shrx r14, r10, r15 shrx r14, r10, rsp shrx r14, r10, rsi shrx r14, r10, rbp shrx r14, r11, rax shrx r14, r11, rbx shrx r14, r11, rcx shrx r14, r11, rdx shrx r14, r11, rdi shrx r14, r11, r8 shrx r14, r11, r9 shrx r14, r11, r10 shrx r14, r11, r11 shrx r14, r11, r12 shrx r14, r11, r13 shrx r14, r11, r14 shrx r14, r11, r15 shrx r14, r11, rsp shrx r14, r11, rsi shrx r14, r11, rbp shrx r14, r12, rax shrx r14, r12, rbx shrx r14, r12, rcx shrx r14, r12, rdx shrx r14, r12, rdi shrx r14, r12, r8 shrx r14, r12, r9 shrx r14, r12, r10 shrx r14, r12, r11 shrx r14, r12, r12 shrx r14, r12, r13 shrx r14, r12, r14 shrx r14, r12, r15 shrx r14, r12, rsp shrx r14, r12, rsi shrx r14, r12, rbp shrx r14, r13, rax shrx r14, r13, rbx shrx r14, r13, rcx shrx r14, r13, rdx shrx r14, r13, rdi shrx r14, r13, r8 shrx r14, r13, r9 shrx r14, r13, r10 shrx r14, r13, r11 shrx r14, r13, r12 shrx r14, r13, r13 shrx r14, r13, r14 shrx r14, r13, r15 shrx r14, r13, rsp shrx r14, r13, rsi shrx r14, r13, rbp shrx r14, r14, rax shrx r14, r14, rbx shrx r14, r14, rcx shrx r14, r14, rdx shrx r14, r14, rdi shrx r14, r14, r8 shrx r14, r14, r9 shrx r14, r14, r10 shrx r14, r14, r11 shrx r14, r14, r12 shrx r14, r14, r13 shrx r14, r14, r14 shrx r14, r14, r15 shrx r14, r14, rsp shrx r14, r14, rsi shrx r14, r14, rbp shrx r14, r15, rax shrx r14, r15, rbx shrx r14, r15, rcx shrx r14, r15, rdx shrx r14, r15, rdi shrx r14, r15, r8 shrx r14, r15, r9 shrx r14, r15, r10 shrx r14, r15, r11 shrx r14, r15, r12 shrx r14, r15, r13 shrx r14, r15, r14 shrx r14, r15, r15 shrx r14, r15, rsp shrx r14, r15, rsi shrx r14, r15, rbp shrx r14, rsp, rax shrx r14, rsp, rbx shrx r14, rsp, rcx shrx r14, rsp, rdx shrx r14, rsp, rdi shrx r14, rsp, r8 shrx r14, rsp, r9 shrx r14, rsp, r10 shrx r14, rsp, r11 shrx r14, rsp, r12 shrx r14, rsp, r13 shrx r14, rsp, r14 shrx r14, rsp, r15 shrx r14, rsp, rsp shrx r14, rsp, rsi shrx r14, rsp, rbp shrx r14, rsi, rax shrx r14, rsi, rbx shrx r14, rsi, rcx shrx r14, rsi, rdx shrx r14, rsi, rdi shrx r14, rsi, r8 shrx r14, rsi, r9 shrx r14, rsi, r10 shrx r14, rsi, r11 shrx r14, rsi, r12 shrx r14, rsi, r13 shrx r14, rsi, r14 shrx r14, rsi, r15 shrx r14, rsi, rsp shrx r14, rsi, rsi shrx r14, rsi, rbp shrx r14, rbp, rax shrx r14, rbp, rbx shrx r14, rbp, rcx shrx r14, rbp, rdx shrx r14, rbp, rdi shrx r14, rbp, r8 shrx r14, rbp, r9 shrx r14, rbp, r10 shrx r14, rbp, r11 shrx r14, rbp, r12 shrx r14, rbp, r13 shrx r14, rbp, r14 shrx r14, rbp, r15 shrx r14, rbp, rsp shrx r14, rbp, rsi shrx r14, rbp, rbp shrx r15, rax, rax shrx r15, rax, rbx shrx r15, rax, rcx shrx r15, rax, rdx shrx r15, rax, rdi shrx r15, rax, r8 shrx r15, rax, r9 shrx r15, rax, r10 shrx r15, rax, r11 shrx r15, rax, r12 shrx r15, rax, r13 shrx r15, rax, r14 shrx r15, rax, r15 shrx r15, rax, rsp shrx r15, rax, rsi shrx r15, rax, rbp shrx r15, rbx, rax shrx r15, rbx, rbx shrx r15, rbx, rcx shrx r15, rbx, rdx shrx r15, rbx, rdi shrx r15, rbx, r8 shrx r15, rbx, r9 shrx r15, rbx, r10 shrx r15, rbx, r11 shrx r15, rbx, r12 shrx r15, rbx, r13 shrx r15, rbx, r14 shrx r15, rbx, r15 shrx r15, rbx, rsp shrx r15, rbx, rsi shrx r15, rbx, rbp shrx r15, rcx, rax shrx r15, rcx, rbx shrx r15, rcx, rcx shrx r15, rcx, rdx shrx r15, rcx, rdi shrx r15, rcx, r8 shrx r15, rcx, r9 shrx r15, rcx, r10 shrx r15, rcx, r11 shrx r15, rcx, r12 shrx r15, rcx, r13 shrx r15, rcx, r14 shrx r15, rcx, r15 shrx r15, rcx, rsp shrx r15, rcx, rsi shrx r15, rcx, rbp shrx r15, rdx, rax shrx r15, rdx, rbx shrx r15, rdx, rcx shrx r15, rdx, rdx shrx r15, rdx, rdi shrx r15, rdx, r8 shrx r15, rdx, r9 shrx r15, rdx, r10 shrx r15, rdx, r11 shrx r15, rdx, r12 shrx r15, rdx, r13 shrx r15, rdx, r14 shrx r15, rdx, r15 shrx r15, rdx, rsp shrx r15, rdx, rsi shrx r15, rdx, rbp shrx r15, rdi, rax shrx r15, rdi, rbx shrx r15, rdi, rcx shrx r15, rdi, rdx shrx r15, rdi, rdi shrx r15, rdi, r8 shrx r15, rdi, r9 shrx r15, rdi, r10 shrx r15, rdi, r11 shrx r15, rdi, r12 shrx r15, rdi, r13 shrx r15, rdi, r14 shrx r15, rdi, r15 shrx r15, rdi, rsp shrx r15, rdi, rsi shrx r15, rdi, rbp shrx r15, r8, rax shrx r15, r8, rbx shrx r15, r8, rcx shrx r15, r8, rdx shrx r15, r8, rdi shrx r15, r8, r8 shrx r15, r8, r9 shrx r15, r8, r10 shrx r15, r8, r11 shrx r15, r8, r12 shrx r15, r8, r13 shrx r15, r8, r14 shrx r15, r8, r15 shrx r15, r8, rsp shrx r15, r8, rsi shrx r15, r8, rbp shrx r15, r9, rax shrx r15, r9, rbx shrx r15, r9, rcx shrx r15, r9, rdx shrx r15, r9, rdi shrx r15, r9, r8 shrx r15, r9, r9 shrx r15, r9, r10 shrx r15, r9, r11 shrx r15, r9, r12 shrx r15, r9, r13 shrx r15, r9, r14 shrx r15, r9, r15 shrx r15, r9, rsp shrx r15, r9, rsi shrx r15, r9, rbp shrx r15, r10, rax shrx r15, r10, rbx shrx r15, r10, rcx shrx r15, r10, rdx shrx r15, r10, rdi shrx r15, r10, r8 shrx r15, r10, r9 shrx r15, r10, r10 shrx r15, r10, r11 shrx r15, r10, r12 shrx r15, r10, r13 shrx r15, r10, r14 shrx r15, r10, r15 shrx r15, r10, rsp shrx r15, r10, rsi shrx r15, r10, rbp shrx r15, r11, rax shrx r15, r11, rbx shrx r15, r11, rcx shrx r15, r11, rdx shrx r15, r11, rdi shrx r15, r11, r8 shrx r15, r11, r9 shrx r15, r11, r10 shrx r15, r11, r11 shrx r15, r11, r12 shrx r15, r11, r13 shrx r15, r11, r14 shrx r15, r11, r15 shrx r15, r11, rsp shrx r15, r11, rsi shrx r15, r11, rbp shrx r15, r12, rax shrx r15, r12, rbx shrx r15, r12, rcx shrx r15, r12, rdx shrx r15, r12, rdi shrx r15, r12, r8 shrx r15, r12, r9 shrx r15, r12, r10 shrx r15, r12, r11 shrx r15, r12, r12 shrx r15, r12, r13 shrx r15, r12, r14 shrx r15, r12, r15 shrx r15, r12, rsp shrx r15, r12, rsi shrx r15, r12, rbp shrx r15, r13, rax shrx r15, r13, rbx shrx r15, r13, rcx shrx r15, r13, rdx shrx r15, r13, rdi shrx r15, r13, r8 shrx r15, r13, r9 shrx r15, r13, r10 shrx r15, r13, r11 shrx r15, r13, r12 shrx r15, r13, r13 shrx r15, r13, r14 shrx r15, r13, r15 shrx r15, r13, rsp shrx r15, r13, rsi shrx r15, r13, rbp shrx r15, r14, rax shrx r15, r14, rbx shrx r15, r14, rcx shrx r15, r14, rdx shrx r15, r14, rdi shrx r15, r14, r8 shrx r15, r14, r9 shrx r15, r14, r10 shrx r15, r14, r11 shrx r15, r14, r12 shrx r15, r14, r13 shrx r15, r14, r14 shrx r15, r14, r15 shrx r15, r14, rsp shrx r15, r14, rsi shrx r15, r14, rbp shrx r15, r15, rax shrx r15, r15, rbx shrx r15, r15, rcx shrx r15, r15, rdx shrx r15, r15, rdi shrx r15, r15, r8 shrx r15, r15, r9 shrx r15, r15, r10 shrx r15, r15, r11 shrx r15, r15, r12 shrx r15, r15, r13 shrx r15, r15, r14 shrx r15, r15, r15 shrx r15, r15, rsp shrx r15, r15, rsi shrx r15, r15, rbp shrx r15, rsp, rax shrx r15, rsp, rbx shrx r15, rsp, rcx shrx r15, rsp, rdx shrx r15, rsp, rdi shrx r15, rsp, r8 shrx r15, rsp, r9 shrx r15, rsp, r10 shrx r15, rsp, r11 shrx r15, rsp, r12 shrx r15, rsp, r13 shrx r15, rsp, r14 shrx r15, rsp, r15 shrx r15, rsp, rsp shrx r15, rsp, rsi shrx r15, rsp, rbp shrx r15, rsi, rax shrx r15, rsi, rbx shrx r15, rsi, rcx shrx r15, rsi, rdx shrx r15, rsi, rdi shrx r15, rsi, r8 shrx r15, rsi, r9 shrx r15, rsi, r10 shrx r15, rsi, r11 shrx r15, rsi, r12 shrx r15, rsi, r13 shrx r15, rsi, r14 shrx r15, rsi, r15 shrx r15, rsi, rsp shrx r15, rsi, rsi shrx r15, rsi, rbp shrx r15, rbp, rax shrx r15, rbp, rbx shrx r15, rbp, rcx shrx r15, rbp, rdx shrx r15, rbp, rdi shrx r15, rbp, r8 shrx r15, rbp, r9 shrx r15, rbp, r10 shrx r15, rbp, r11 shrx r15, rbp, r12 shrx r15, rbp, r13 shrx r15, rbp, r14 shrx r15, rbp, r15 shrx r15, rbp, rsp shrx r15, rbp, rsi shrx r15, rbp, rbp shrx rsp, rax, rax shrx rsp, rax, rbx shrx rsp, rax, rcx shrx rsp, rax, rdx shrx rsp, rax, rdi shrx rsp, rax, r8 shrx rsp, rax, r9 shrx rsp, rax, r10 shrx rsp, rax, r11 shrx rsp, rax, r12 shrx rsp, rax, r13 shrx rsp, rax, r14 shrx rsp, rax, r15 shrx rsp, rax, rsp shrx rsp, rax, rsi shrx rsp, rax, rbp shrx rsp, rbx, rax shrx rsp, rbx, rbx shrx rsp, rbx, rcx shrx rsp, rbx, rdx shrx rsp, rbx, rdi shrx rsp, rbx, r8 shrx rsp, rbx, r9 shrx rsp, rbx, r10 shrx rsp, rbx, r11 shrx rsp, rbx, r12 shrx rsp, rbx, r13 shrx rsp, rbx, r14 shrx rsp, rbx, r15 shrx rsp, rbx, rsp shrx rsp, rbx, rsi shrx rsp, rbx, rbp shrx rsp, rcx, rax shrx rsp, rcx, rbx shrx rsp, rcx, rcx shrx rsp, rcx, rdx shrx rsp, rcx, rdi shrx rsp, rcx, r8 shrx rsp, rcx, r9 shrx rsp, rcx, r10 shrx rsp, rcx, r11 shrx rsp, rcx, r12 shrx rsp, rcx, r13 shrx rsp, rcx, r14 shrx rsp, rcx, r15 shrx rsp, rcx, rsp shrx rsp, rcx, rsi shrx rsp, rcx, rbp shrx rsp, rdx, rax shrx rsp, rdx, rbx shrx rsp, rdx, rcx shrx rsp, rdx, rdx shrx rsp, rdx, rdi shrx rsp, rdx, r8 shrx rsp, rdx, r9 shrx rsp, rdx, r10 shrx rsp, rdx, r11 shrx rsp, rdx, r12 shrx rsp, rdx, r13 shrx rsp, rdx, r14 shrx rsp, rdx, r15 shrx rsp, rdx, rsp shrx rsp, rdx, rsi shrx rsp, rdx, rbp shrx rsp, rdi, rax shrx rsp, rdi, rbx shrx rsp, rdi, rcx shrx rsp, rdi, rdx shrx rsp, rdi, rdi shrx rsp, rdi, r8 shrx rsp, rdi, r9 shrx rsp, rdi, r10 shrx rsp, rdi, r11 shrx rsp, rdi, r12 shrx rsp, rdi, r13 shrx rsp, rdi, r14 shrx rsp, rdi, r15 shrx rsp, rdi, rsp shrx rsp, rdi, rsi shrx rsp, rdi, rbp shrx rsp, r8, rax shrx rsp, r8, rbx shrx rsp, r8, rcx shrx rsp, r8, rdx shrx rsp, r8, rdi shrx rsp, r8, r8 shrx rsp, r8, r9 shrx rsp, r8, r10 shrx rsp, r8, r11 shrx rsp, r8, r12 shrx rsp, r8, r13 shrx rsp, r8, r14 shrx rsp, r8, r15 shrx rsp, r8, rsp shrx rsp, r8, rsi shrx rsp, r8, rbp shrx rsp, r9, rax shrx rsp, r9, rbx shrx rsp, r9, rcx shrx rsp, r9, rdx shrx rsp, r9, rdi shrx rsp, r9, r8 shrx rsp, r9, r9 shrx rsp, r9, r10 shrx rsp, r9, r11 shrx rsp, r9, r12 shrx rsp, r9, r13 shrx rsp, r9, r14 shrx rsp, r9, r15 shrx rsp, r9, rsp shrx rsp, r9, rsi shrx rsp, r9, rbp shrx rsp, r10, rax shrx rsp, r10, rbx shrx rsp, r10, rcx shrx rsp, r10, rdx shrx rsp, r10, rdi shrx rsp, r10, r8 shrx rsp, r10, r9 shrx rsp, r10, r10 shrx rsp, r10, r11 shrx rsp, r10, r12 shrx rsp, r10, r13 shrx rsp, r10, r14 shrx rsp, r10, r15 shrx rsp, r10, rsp shrx rsp, r10, rsi shrx rsp, r10, rbp shrx rsp, r11, rax shrx rsp, r11, rbx shrx rsp, r11, rcx shrx rsp, r11, rdx shrx rsp, r11, rdi shrx rsp, r11, r8 shrx rsp, r11, r9 shrx rsp, r11, r10 shrx rsp, r11, r11 shrx rsp, r11, r12 shrx rsp, r11, r13 shrx rsp, r11, r14 shrx rsp, r11, r15 shrx rsp, r11, rsp shrx rsp, r11, rsi shrx rsp, r11, rbp shrx rsp, r12, rax shrx rsp, r12, rbx shrx rsp, r12, rcx shrx rsp, r12, rdx shrx rsp, r12, rdi shrx rsp, r12, r8 shrx rsp, r12, r9 shrx rsp, r12, r10 shrx rsp, r12, r11 shrx rsp, r12, r12 shrx rsp, r12, r13 shrx rsp, r12, r14 shrx rsp, r12, r15 shrx rsp, r12, rsp shrx rsp, r12, rsi shrx rsp, r12, rbp shrx rsp, r13, rax shrx rsp, r13, rbx shrx rsp, r13, rcx shrx rsp, r13, rdx shrx rsp, r13, rdi shrx rsp, r13, r8 shrx rsp, r13, r9 shrx rsp, r13, r10 shrx rsp, r13, r11 shrx rsp, r13, r12 shrx rsp, r13, r13 shrx rsp, r13, r14 shrx rsp, r13, r15 shrx rsp, r13, rsp shrx rsp, r13, rsi shrx rsp, r13, rbp shrx rsp, r14, rax shrx rsp, r14, rbx shrx rsp, r14, rcx shrx rsp, r14, rdx shrx rsp, r14, rdi shrx rsp, r14, r8 shrx rsp, r14, r9 shrx rsp, r14, r10 shrx rsp, r14, r11 shrx rsp, r14, r12 shrx rsp, r14, r13 shrx rsp, r14, r14 shrx rsp, r14, r15 shrx rsp, r14, rsp shrx rsp, r14, rsi shrx rsp, r14, rbp shrx rsp, r15, rax shrx rsp, r15, rbx shrx rsp, r15, rcx shrx rsp, r15, rdx shrx rsp, r15, rdi shrx rsp, r15, r8 shrx rsp, r15, r9 shrx rsp, r15, r10 shrx rsp, r15, r11 shrx rsp, r15, r12 shrx rsp, r15, r13 shrx rsp, r15, r14 shrx rsp, r15, r15 shrx rsp, r15, rsp shrx rsp, r15, rsi shrx rsp, r15, rbp shrx rsp, rsp, rax shrx rsp, rsp, rbx shrx rsp, rsp, rcx shrx rsp, rsp, rdx shrx rsp, rsp, rdi shrx rsp, rsp, r8 shrx rsp, rsp, r9 shrx rsp, rsp, r10 shrx rsp, rsp, r11 shrx rsp, rsp, r12 shrx rsp, rsp, r13 shrx rsp, rsp, r14 shrx rsp, rsp, r15 shrx rsp, rsp, rsp shrx rsp, rsp, rsi shrx rsp, rsp, rbp shrx rsp, rsi, rax shrx rsp, rsi, rbx shrx rsp, rsi, rcx shrx rsp, rsi, rdx shrx rsp, rsi, rdi shrx rsp, rsi, r8 shrx rsp, rsi, r9 shrx rsp, rsi, r10 shrx rsp, rsi, r11 shrx rsp, rsi, r12 shrx rsp, rsi, r13 shrx rsp, rsi, r14 shrx rsp, rsi, r15 shrx rsp, rsi, rsp shrx rsp, rsi, rsi shrx rsp, rsi, rbp shrx rsp, rbp, rax shrx rsp, rbp, rbx shrx rsp, rbp, rcx shrx rsp, rbp, rdx shrx rsp, rbp, rdi shrx rsp, rbp, r8 shrx rsp, rbp, r9 shrx rsp, rbp, r10 shrx rsp, rbp, r11 shrx rsp, rbp, r12 shrx rsp, rbp, r13 shrx rsp, rbp, r14 shrx rsp, rbp, r15 shrx rsp, rbp, rsp shrx rsp, rbp, rsi shrx rsp, rbp, rbp shrx rsi, rax, rax shrx rsi, rax, rbx shrx rsi, rax, rcx shrx rsi, rax, rdx shrx rsi, rax, rdi shrx rsi, rax, r8 shrx rsi, rax, r9 shrx rsi, rax, r10 shrx rsi, rax, r11 shrx rsi, rax, r12 shrx rsi, rax, r13 shrx rsi, rax, r14 shrx rsi, rax, r15 shrx rsi, rax, rsp shrx rsi, rax, rsi shrx rsi, rax, rbp shrx rsi, rbx, rax shrx rsi, rbx, rbx shrx rsi, rbx, rcx shrx rsi, rbx, rdx shrx rsi, rbx, rdi shrx rsi, rbx, r8 shrx rsi, rbx, r9 shrx rsi, rbx, r10 shrx rsi, rbx, r11 shrx rsi, rbx, r12 shrx rsi, rbx, r13 shrx rsi, rbx, r14 shrx rsi, rbx, r15 shrx rsi, rbx, rsp shrx rsi, rbx, rsi shrx rsi, rbx, rbp shrx rsi, rcx, rax shrx rsi, rcx, rbx shrx rsi, rcx, rcx shrx rsi, rcx, rdx shrx rsi, rcx, rdi shrx rsi, rcx, r8 shrx rsi, rcx, r9 shrx rsi, rcx, r10 shrx rsi, rcx, r11 shrx rsi, rcx, r12 shrx rsi, rcx, r13 shrx rsi, rcx, r14 shrx rsi, rcx, r15 shrx rsi, rcx, rsp shrx rsi, rcx, rsi shrx rsi, rcx, rbp shrx rsi, rdx, rax shrx rsi, rdx, rbx shrx rsi, rdx, rcx shrx rsi, rdx, rdx shrx rsi, rdx, rdi shrx rsi, rdx, r8 shrx rsi, rdx, r9 shrx rsi, rdx, r10 shrx rsi, rdx, r11 shrx rsi, rdx, r12 shrx rsi, rdx, r13 shrx rsi, rdx, r14 shrx rsi, rdx, r15 shrx rsi, rdx, rsp shrx rsi, rdx, rsi shrx rsi, rdx, rbp shrx rsi, rdi, rax shrx rsi, rdi, rbx shrx rsi, rdi, rcx shrx rsi, rdi, rdx shrx rsi, rdi, rdi shrx rsi, rdi, r8 shrx rsi, rdi, r9 shrx rsi, rdi, r10 shrx rsi, rdi, r11 shrx rsi, rdi, r12 shrx rsi, rdi, r13 shrx rsi, rdi, r14 shrx rsi, rdi, r15 shrx rsi, rdi, rsp shrx rsi, rdi, rsi shrx rsi, rdi, rbp shrx rsi, r8, rax shrx rsi, r8, rbx shrx rsi, r8, rcx shrx rsi, r8, rdx shrx rsi, r8, rdi shrx rsi, r8, r8 shrx rsi, r8, r9 shrx rsi, r8, r10 shrx rsi, r8, r11 shrx rsi, r8, r12 shrx rsi, r8, r13 shrx rsi, r8, r14 shrx rsi, r8, r15 shrx rsi, r8, rsp shrx rsi, r8, rsi shrx rsi, r8, rbp shrx rsi, r9, rax shrx rsi, r9, rbx shrx rsi, r9, rcx shrx rsi, r9, rdx shrx rsi, r9, rdi shrx rsi, r9, r8 shrx rsi, r9, r9 shrx rsi, r9, r10 shrx rsi, r9, r11 shrx rsi, r9, r12 shrx rsi, r9, r13 shrx rsi, r9, r14 shrx rsi, r9, r15 shrx rsi, r9, rsp shrx rsi, r9, rsi shrx rsi, r9, rbp shrx rsi, r10, rax shrx rsi, r10, rbx shrx rsi, r10, rcx shrx rsi, r10, rdx shrx rsi, r10, rdi shrx rsi, r10, r8 shrx rsi, r10, r9 shrx rsi, r10, r10 shrx rsi, r10, r11 shrx rsi, r10, r12 shrx rsi, r10, r13 shrx rsi, r10, r14 shrx rsi, r10, r15 shrx rsi, r10, rsp shrx rsi, r10, rsi shrx rsi, r10, rbp shrx rsi, r11, rax shrx rsi, r11, rbx shrx rsi, r11, rcx shrx rsi, r11, rdx shrx rsi, r11, rdi shrx rsi, r11, r8 shrx rsi, r11, r9 shrx rsi, r11, r10 shrx rsi, r11, r11 shrx rsi, r11, r12 shrx rsi, r11, r13 shrx rsi, r11, r14 shrx rsi, r11, r15 shrx rsi, r11, rsp shrx rsi, r11, rsi shrx rsi, r11, rbp shrx rsi, r12, rax shrx rsi, r12, rbx shrx rsi, r12, rcx shrx rsi, r12, rdx shrx rsi, r12, rdi shrx rsi, r12, r8 shrx rsi, r12, r9 shrx rsi, r12, r10 shrx rsi, r12, r11 shrx rsi, r12, r12 shrx rsi, r12, r13 shrx rsi, r12, r14 shrx rsi, r12, r15 shrx rsi, r12, rsp shrx rsi, r12, rsi shrx rsi, r12, rbp shrx rsi, r13, rax shrx rsi, r13, rbx shrx rsi, r13, rcx shrx rsi, r13, rdx shrx rsi, r13, rdi shrx rsi, r13, r8 shrx rsi, r13, r9 shrx rsi, r13, r10 shrx rsi, r13, r11 shrx rsi, r13, r12 shrx rsi, r13, r13 shrx rsi, r13, r14 shrx rsi, r13, r15 shrx rsi, r13, rsp shrx rsi, r13, rsi shrx rsi, r13, rbp shrx rsi, r14, rax shrx rsi, r14, rbx shrx rsi, r14, rcx shrx rsi, r14, rdx shrx rsi, r14, rdi shrx rsi, r14, r8 shrx rsi, r14, r9 shrx rsi, r14, r10 shrx rsi, r14, r11 shrx rsi, r14, r12 shrx rsi, r14, r13 shrx rsi, r14, r14 shrx rsi, r14, r15 shrx rsi, r14, rsp shrx rsi, r14, rsi shrx rsi, r14, rbp shrx rsi, r15, rax shrx rsi, r15, rbx shrx rsi, r15, rcx shrx rsi, r15, rdx shrx rsi, r15, rdi shrx rsi, r15, r8 shrx rsi, r15, r9 shrx rsi, r15, r10 shrx rsi, r15, r11 shrx rsi, r15, r12 shrx rsi, r15, r13 shrx rsi, r15, r14 shrx rsi, r15, r15 shrx rsi, r15, rsp shrx rsi, r15, rsi shrx rsi, r15, rbp shrx rsi, rsp, rax shrx rsi, rsp, rbx shrx rsi, rsp, rcx shrx rsi, rsp, rdx shrx rsi, rsp, rdi shrx rsi, rsp, r8 shrx rsi, rsp, r9 shrx rsi, rsp, r10 shrx rsi, rsp, r11 shrx rsi, rsp, r12 shrx rsi, rsp, r13 shrx rsi, rsp, r14 shrx rsi, rsp, r15 shrx rsi, rsp, rsp shrx rsi, rsp, rsi shrx rsi, rsp, rbp shrx rsi, rsi, rax shrx rsi, rsi, rbx shrx rsi, rsi, rcx shrx rsi, rsi, rdx shrx rsi, rsi, rdi shrx rsi, rsi, r8 shrx rsi, rsi, r9 shrx rsi, rsi, r10 shrx rsi, rsi, r11 shrx rsi, rsi, r12 shrx rsi, rsi, r13 shrx rsi, rsi, r14 shrx rsi, rsi, r15 shrx rsi, rsi, rsp shrx rsi, rsi, rsi shrx rsi, rsi, rbp shrx rsi, rbp, rax shrx rsi, rbp, rbx shrx rsi, rbp, rcx shrx rsi, rbp, rdx shrx rsi, rbp, rdi shrx rsi, rbp, r8 shrx rsi, rbp, r9 shrx rsi, rbp, r10 shrx rsi, rbp, r11 shrx rsi, rbp, r12 shrx rsi, rbp, r13 shrx rsi, rbp, r14 shrx rsi, rbp, r15 shrx rsi, rbp, rsp shrx rsi, rbp, rsi shrx rsi, rbp, rbp shrx rbp, rax, rax shrx rbp, rax, rbx shrx rbp, rax, rcx shrx rbp, rax, rdx shrx rbp, rax, rdi shrx rbp, rax, r8 shrx rbp, rax, r9 shrx rbp, rax, r10 shrx rbp, rax, r11 shrx rbp, rax, r12 shrx rbp, rax, r13 shrx rbp, rax, r14 shrx rbp, rax, r15 shrx rbp, rax, rsp shrx rbp, rax, rsi shrx rbp, rax, rbp shrx rbp, rbx, rax shrx rbp, rbx, rbx shrx rbp, rbx, rcx shrx rbp, rbx, rdx shrx rbp, rbx, rdi shrx rbp, rbx, r8 shrx rbp, rbx, r9 shrx rbp, rbx, r10 shrx rbp, rbx, r11 shrx rbp, rbx, r12 shrx rbp, rbx, r13 shrx rbp, rbx, r14 shrx rbp, rbx, r15 shrx rbp, rbx, rsp shrx rbp, rbx, rsi shrx rbp, rbx, rbp shrx rbp, rcx, rax shrx rbp, rcx, rbx shrx rbp, rcx, rcx shrx rbp, rcx, rdx shrx rbp, rcx, rdi shrx rbp, rcx, r8 shrx rbp, rcx, r9 shrx rbp, rcx, r10 shrx rbp, rcx, r11 shrx rbp, rcx, r12 shrx rbp, rcx, r13 shrx rbp, rcx, r14 shrx rbp, rcx, r15 shrx rbp, rcx, rsp shrx rbp, rcx, rsi shrx rbp, rcx, rbp shrx rbp, rdx, rax shrx rbp, rdx, rbx shrx rbp, rdx, rcx shrx rbp, rdx, rdx shrx rbp, rdx, rdi shrx rbp, rdx, r8 shrx rbp, rdx, r9 shrx rbp, rdx, r10 shrx rbp, rdx, r11 shrx rbp, rdx, r12 shrx rbp, rdx, r13 shrx rbp, rdx, r14 shrx rbp, rdx, r15 shrx rbp, rdx, rsp shrx rbp, rdx, rsi shrx rbp, rdx, rbp shrx rbp, rdi, rax shrx rbp, rdi, rbx shrx rbp, rdi, rcx shrx rbp, rdi, rdx shrx rbp, rdi, rdi shrx rbp, rdi, r8 shrx rbp, rdi, r9 shrx rbp, rdi, r10 shrx rbp, rdi, r11 shrx rbp, rdi, r12 shrx rbp, rdi, r13 shrx rbp, rdi, r14 shrx rbp, rdi, r15 shrx rbp, rdi, rsp shrx rbp, rdi, rsi shrx rbp, rdi, rbp shrx rbp, r8, rax shrx rbp, r8, rbx shrx rbp, r8, rcx shrx rbp, r8, rdx shrx rbp, r8, rdi shrx rbp, r8, r8 shrx rbp, r8, r9 shrx rbp, r8, r10 shrx rbp, r8, r11 shrx rbp, r8, r12 shrx rbp, r8, r13 shrx rbp, r8, r14 shrx rbp, r8, r15 shrx rbp, r8, rsp shrx rbp, r8, rsi shrx rbp, r8, rbp shrx rbp, r9, rax shrx rbp, r9, rbx shrx rbp, r9, rcx shrx rbp, r9, rdx shrx rbp, r9, rdi shrx rbp, r9, r8 shrx rbp, r9, r9 shrx rbp, r9, r10 shrx rbp, r9, r11 shrx rbp, r9, r12 shrx rbp, r9, r13 shrx rbp, r9, r14 shrx rbp, r9, r15 shrx rbp, r9, rsp shrx rbp, r9, rsi shrx rbp, r9, rbp shrx rbp, r10, rax shrx rbp, r10, rbx shrx rbp, r10, rcx shrx rbp, r10, rdx shrx rbp, r10, rdi shrx rbp, r10, r8 shrx rbp, r10, r9 shrx rbp, r10, r10 shrx rbp, r10, r11 shrx rbp, r10, r12 shrx rbp, r10, r13 shrx rbp, r10, r14 shrx rbp, r10, r15 shrx rbp, r10, rsp shrx rbp, r10, rsi shrx rbp, r10, rbp shrx rbp, r11, rax shrx rbp, r11, rbx shrx rbp, r11, rcx shrx rbp, r11, rdx shrx rbp, r11, rdi shrx rbp, r11, r8 shrx rbp, r11, r9 shrx rbp, r11, r10 shrx rbp, r11, r11 shrx rbp, r11, r12 shrx rbp, r11, r13 shrx rbp, r11, r14 shrx rbp, r11, r15 shrx rbp, r11, rsp shrx rbp, r11, rsi shrx rbp, r11, rbp shrx rbp, r12, rax shrx rbp, r12, rbx shrx rbp, r12, rcx shrx rbp, r12, rdx shrx rbp, r12, rdi shrx rbp, r12, r8 shrx rbp, r12, r9 shrx rbp, r12, r10 shrx rbp, r12, r11 shrx rbp, r12, r12 shrx rbp, r12, r13 shrx rbp, r12, r14 shrx rbp, r12, r15 shrx rbp, r12, rsp shrx rbp, r12, rsi shrx rbp, r12, rbp shrx rbp, r13, rax shrx rbp, r13, rbx shrx rbp, r13, rcx shrx rbp, r13, rdx shrx rbp, r13, rdi shrx rbp, r13, r8 shrx rbp, r13, r9 shrx rbp, r13, r10 shrx rbp, r13, r11 shrx rbp, r13, r12 shrx rbp, r13, r13 shrx rbp, r13, r14 shrx rbp, r13, r15 shrx rbp, r13, rsp shrx rbp, r13, rsi shrx rbp, r13, rbp shrx rbp, r14, rax shrx rbp, r14, rbx shrx rbp, r14, rcx shrx rbp, r14, rdx shrx rbp, r14, rdi shrx rbp, r14, r8 shrx rbp, r14, r9 shrx rbp, r14, r10 shrx rbp, r14, r11 shrx rbp, r14, r12 shrx rbp, r14, r13 shrx rbp, r14, r14 shrx rbp, r14, r15 shrx rbp, r14, rsp shrx rbp, r14, rsi shrx rbp, r14, rbp shrx rbp, r15, rax shrx rbp, r15, rbx shrx rbp, r15, rcx shrx rbp, r15, rdx shrx rbp, r15, rdi shrx rbp, r15, r8 shrx rbp, r15, r9 shrx rbp, r15, r10 shrx rbp, r15, r11 shrx rbp, r15, r12 shrx rbp, r15, r13 shrx rbp, r15, r14 shrx rbp, r15, r15 shrx rbp, r15, rsp shrx rbp, r15, rsi shrx rbp, r15, rbp shrx rbp, rsp, rax shrx rbp, rsp, rbx shrx rbp, rsp, rcx shrx rbp, rsp, rdx shrx rbp, rsp, rdi shrx rbp, rsp, r8 shrx rbp, rsp, r9 shrx rbp, rsp, r10 shrx rbp, rsp, r11 shrx rbp, rsp, r12 shrx rbp, rsp, r13 shrx rbp, rsp, r14 shrx rbp, rsp, r15 shrx rbp, rsp, rsp shrx rbp, rsp, rsi shrx rbp, rsp, rbp shrx rbp, rsi, rax shrx rbp, rsi, rbx shrx rbp, rsi, rcx shrx rbp, rsi, rdx shrx rbp, rsi, rdi shrx rbp, rsi, r8 shrx rbp, rsi, r9 shrx rbp, rsi, r10 shrx rbp, rsi, r11 shrx rbp, rsi, r12 shrx rbp, rsi, r13 shrx rbp, rsi, r14 shrx rbp, rsi, r15 shrx rbp, rsi, rsp shrx rbp, rsi, rsi shrx rbp, rsi, rbp shrx rbp, rbp, rax shrx rbp, rbp, rbx shrx rbp, rbp, rcx shrx rbp, rbp, rdx shrx rbp, rbp, rdi shrx rbp, rbp, r8 shrx rbp, rbp, r9 shrx rbp, rbp, r10 shrx rbp, rbp, r11 shrx rbp, rbp, r12 shrx rbp, rbp, r13 shrx rbp, rbp, r14 shrx rbp, rbp, r15 shrx rbp, rbp, rsp shrx rbp, rbp, rsi shrx rbp, rbp, rbp shrx rax, [rsi], r8 shrx rax, [rsi], r9 shrx rax, [rsi], r10 shrx rax, [rsi], r11 shrx rax, [rsi], r12 shrx rax, [rsi], r13 shrx rax, [rsi], r14 shrx rax, [rsi], r15 shrx rax, [rsi], rsp shrx rax, [rsi], rsi shrx rax, [rsi], rbp shrx rax, [rbp], rax shrx rax, [rbp], rbx shrx rax, [rbp], rcx shrx rax, [rbp], rdx shrx rax, [rbp], rdi shrx rax, [rbp], r8 shrx rax, [rbp], r9 shrx rax, [rbp], r10 shrx rax, [rbp], r11 shrx rax, [rbp], r12 shrx rax, [rbp], r13 shrx rax, [rbp], r14 shrx rax, [rbp], r15 shrx rax, [rbp], rsp shrx rax, [rbp], rsi shrx rax, [rbp], rbp shrx rbx, [rax], rax shrx rbx, [rax], rbx shrx rbx, [rax], rcx shrx rbx, [rax], rdx shrx rbx, [rax], rdi shrx rbx, [rax], r8 shrx rbx, [rax], r9 shrx rbx, [rax], r10 shrx rbx, [rax], r11 shrx rbx, [rax], r12 shrx rbx, [rax], r13 shrx rbx, [rax], r14 shrx rbx, [rax], r15 shrx rbx, [rax], rsp shrx rbx, [rax], rsi shrx rbx, [rax], rbp shrx rbx, [rbx], rax shrx rbx, [rbx], rbx shrx rbx, [rbx], rcx shrx rbx, [rbx], rdx shrx rbx, [rbx], rdi shrx rbx, [rbx], r8 shrx rbx, [rbx], r9 shrx rbx, [rbx], r10 shrx rbx, [rbx], r11 shrx rbx, [rbx], r12 shrx rbx, [rbx], r13 shrx rbx, [rbx], r14 shrx rbx, [rbx], r15 shrx rbx, [rbx], rsp shrx rbx, [rbx], rsi shrx rbx, [rbx], rbp shrx rbx, [rcx], rax shrx rbx, [rcx], rbx shrx rbx, [rcx], rcx shrx rbx, [rcx], rdx shrx rbx, [rcx], rdi shrx rbx, [rcx], r8 shrx rbx, [rcx], r9 shrx rbx, [rcx], r10 shrx rbx, [rcx], r11 shrx rbx, [rcx], r12 shrx rbx, [rcx], r13 shrx rbx, [rcx], r14 shrx rbx, [rcx], r15 shrx rbx, [r10], rax shrx rbx, [r10], rbx shrx rbx, [r10], rcx shrx rbx, [r10], rdx shrx rbx, [r10], rdi shrx rbx, [r10], r8 shrx rbx, [r10], r9 shrx rbx, [r10], r10 shrx rbx, [r10], r11 shrx rbx, [r10], r12 shrx rbx, [r10], r13 shrx rbx, [r10], r14 shrx rbx, [r10], r15 shrx rbx, [r10], rsp shrx rbx, [r10], rsi shrx rbx, [r10], rbp shrx rbx, [r11], rax shrx rbx, [r11], rbx shrx rbx, [r11], rcx shrx rbx, [r11], rdx shrx rbx, [r11], rdi shrx rbx, [r11], r8 shrx rbx, [r11], r9 shrx rbx, [r11], r10 shrx rbx, [r11], r11 shrx rbx, [r11], r12 shrx rbx, [r11], r13 shrx rbx, [r11], r14 shrx rbx, [r11], r15 shrx rbx, [r11], rsp shrx rbx, [r11], rsi shrx rbx, [r11], rbp shrx rbx, [r12], rax shrx rbx, [r12], rbx shrx rbx, [r12], rcx shrx rbx, [r12], rdx shrx rbx, [r12], rdi shrx rbx, [r12], r8 shrx rbx, [r12], r9 shrx rbx, [r12], r10 shrx rbx, [r12], r11 shrx rbx, [r12], r12 shrx rbx, [r12], r13 shrx rbx, [r12], r14 shrx rbx, [r12], r15 shrx rbx, [r12], rsp shrx rbx, [r12], rsi shrx rbx, [r12], rbp shrx rbx, [r13], rax shrx rbx, [r13], rbx shrx rbx, [r13], rcx shrx rbx, [r13], rdx shrx rbx, [r13], rdi shrx rbx, [r13], r8 shrx rbx, [r13], r9 shrx rbx, [r13], r10 shrx rbx, [r13], r11 shrx rbx, [r13], r12 shrx rbx, [r13], r13 shrx rbx, [r13], r14 shrx rbx, [r13], r15 shrx rbx, [r13], rsp shrx rbx, [r13], rsi shrx rbx, [r13], rbp shrx rbx, [r14], rax shrx rbx, [r14], rbx shrx rbx, [r14], rcx shrx rbx, [r14], rdx shrx rbx, [r14], rdi shrx rbx, [r14], r8 shrx rbx, [r14], r9 shrx rbx, [r14], r10 shrx rbx, [r14], r11 shrx rbx, [r14], r12 shrx rbx, [r14], r13 shrx rbx, [r14], r14 shrx rbx, [r14], r15 shrx rbx, [r14], rsp shrx rbx, [r14], rsi shrx rbx, [r14], rbp shrx rbx, [r15], rax shrx rbx, [r15], rbx shrx rbx, [r15], rcx shrx rbx, [r15], rdx shrx rbx, [r15], rdi shrx rbx, [r15], r8 shrx rbx, [r15], r9 shrx rbx, [r15], r10 shrx r13, [rbp], r12 shrx r13, [rbp], r13 shrx r13, [rbp], r14 shrx r13, [rbp], r15 shrx r13, [rbp], rsp shrx r13, [rbp], rsi shrx r13, [rbp], rbp shrx r14, [rax], rax shrx r14, [rax], rbx shrx r14, [rax], rcx shrx r14, [rax], rdx shrx r14, [rax], rdi shrx r14, [rax], r8 shrx r14, [rax], r9 shrx r14, [rax], r10 shrx r14, [rax], r11 shrx r14, [rax], r12 shrx r14, [rax], r13 shrx r14, [rax], r14 shrx r14, [rax], r15 shrx r14, [rax], rsp shrx r14, [rax], rsi shrx r14, [rax], rbp shrx r14, [rbx], rax shrx r14, [rbx], rbx shrx r14, [rbx], rcx shrx r14, [rbx], rdx shrx r14, [rbx], rdi shrx r14, [rbx], r8 shrx r14, [rbx], r9 shrx r14, [rbx], r10 shrx r14, [rbx], r11 shrx r14, [rbx], r12 shrx r14, [rbx], r13 shrx r14, [rbx], r14 shrx r14, [rbx], r15 shrx r14, [rbx], rsp shrx r14, [rbx], rsi shrx r14, [rbx], rbp shrx r14, [rcx], rax shrx r14, [rcx], rbx shrx r14, [rcx], rcx shrx r14, [rcx], rdx shrx r14, [rcx], rdi shrx r14, [rcx], r8 shrx r14, [rcx], r9 shrx r14, [rcx], r10 shrx r15, [rbp], r13 shrx r15, [rbp], r14 shrx r15, [rbp], r15 shrx r15, [rbp], rsp shrx r15, [rbp], rsi shrx r15, [rbp], rbp shrx rsp, [rax], rax shrx rsp, [rax], rbx shrx rsp, [rcx], rax shrx rsp, [rcx], rbx shrx rsp, [rcx], rcx shrx rsp, [rcx], rdx shrx rsp, [rcx], rdi shrx rsp, [rcx], r8 shrx rsp, [rcx], r9 shrx rsp, [rcx], r10 shrx rsp, [rcx], r11 shrx rsp, [rcx], r12 shrx rsp, [rcx], r13 shrx rsp, [rcx], r14 shrx rsp, [rbp], rsp shrx rsp, [rbp], rsi shrx rsp, [rbp], rbp shrx rsi, [rax], rax shrx rsi, [rax], rbx shrx rsi, [rax], rcx shrx rsi, [rax], rdx shrx rsi, [rax], rdi shrx rsi, [rax], r8 shrx rsi, [rax], r9 shrx rbp, [r8], rdi shrx rbp, [r8], r8 shrx rbp, [r8], r9 shrx rbp, [r8], r10 shrx rbp, [r8], r11 shrx rbp, [r8], r12 shrx rbp, [r8], r13 shrx rbp, [rsi], r13 shrx rbp, [rsi], r14 shrx rbp, [rsi], r15 shrx rbp, [rsi], rsp shrx rbp, [rsi], rsi shrx rbp, [rsi], rbp shrx rbp, [rbp], rax shrx rbp, [rbp], rbx shrx rbp, [rbp], rcx shrx rbp, [rbp], rdx shrx rbp, [rbp], rdi shrx ecx, eax, eax shrx ecx, eax, ebx shrx ecx, eax, ecx shrx ecx, eax, edx shrx ecx, eax, edi shrx ebp, ebp, eax shrx ebp, ebp, ebx shrx ebp, ebp, ecx shrx ebp, ebp, edx shrx ebp, ebp, edi shrx esi, ebp, eax shrx esi, ebp, ebx shrx esi, ebp, ecx shrx esi, ebp, edx shrx esi, ebp, edi shrx r13d, r12d, ebp shrx r13d, r13d, eax shrx r13d, r13d, ebx shrx r13d, r13d, ecx shrx r13d, r13d, edx shrx r13d, r13d, edi shrx r13d, r13d, r8d shrx r13d, r13d, r9d shrx r13d, [ebp], r10d shrx r13d, [ebp], r11d shrx r13d, [r13d], r12d shrx r13d, [r13d], r13d shrx r13d, [r13d], r14d shrx r13d, [r13d], r15d shrx r13d, [r13d], esp shrx r13d, [r13d], esi shrx r13d, [r13d], ebp shrx r13d, [r14d], eax
#ifndef PMM_HPP_ #define PMM_HPP_ #include <stivale.hpp> #include <memutils.hpp> #include <cpu.hpp> namespace pmm { inline size_t total_mem = 0; inline size_t total_used_mem = 0; void init(stivale *stivale); size_t alloc(size_t cnt, size_t align = 1); size_t calloc(size_t cnt, size_t align = 1); void free(size_t base, size_t cnt); } #endif
[bits 64] section .text [global exec_regs] exec_regs: mov rsp, rdi pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rsi pop rdi pop rbp pop rdx pop rcx pop rbx pop rax add rsp, 16 iretq
SECTION code_fp_math16 PUBLIC ___h2sint_callee PUBLIC _i16_f16_fastcall EXTERN cm16_sdcc___h2sint_callee EXTERN cm16_sdcc___h2sint_fastcall defc ___h2sint_callee = cm16_sdcc___h2sint_callee defc _i16_f16_fastcall = cm16_sdcc___h2sint_fastcall
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 c0 .text@150 lbegin: ld a, 00 ldff(ff), a ld b, 91 call lwaitly_b ld a, b1 ldff(40), a ld a, 07 ldff(4b), a ld c, 41 ld b, 03 lbegin_waitm3: ldff a, (c) and a, b cmp a, b jrnz lbegin_waitm3 ld a, 20 ldff(c), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ld a, 05 ldff(43), a ei .text@1000 lstatint: nop .text@1038 ldff a, (c) and a, b jp lprint_a .text@7000 lprint_a: push af ld b, 91 call lwaitly_b xor a, a ldff(40), a pop af ld(9800), a ld bc, 7a00 ld hl, 8000 ld d, a0 lprint_copytiles: ld a, (bc) inc bc ld(hl++), a dec d jrnz lprint_copytiles ld a, c0 ldff(47), a ld a, 80 ldff(68), a ld a, ff ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a ldff(69), a xor a, a ldff(69), a ldff(69), a ldff(43), a ld a, 91 ldff(40), a lprint_limbo: jr lprint_limbo .text@7400 lwaitly_b: ld c, 44 lwaitly_b_loop: ldff a, (c) cmp a, b jrnz lwaitly_b_loop ret .data@7a00 00 00 7f 7f 41 41 41 41 41 41 41 41 41 41 7f 7f 00 00 08 08 08 08 08 08 08 08 08 08 08 08 08 08 00 00 7f 7f 01 01 01 01 7f 7f 40 40 40 40 7f 7f 00 00 7f 7f 01 01 01 01 3f 3f 01 01 01 01 7f 7f 00 00 41 41 41 41 41 41 7f 7f 01 01 01 01 01 01 00 00 7f 7f 40 40 40 40 7e 7e 01 01 01 01 7e 7e 00 00 7f 7f 40 40 40 40 7f 7f 41 41 41 41 7f 7f 00 00 7f 7f 01 01 02 02 04 04 08 08 10 10 10 10 00 00 3e 3e 41 41 41 41 3e 3e 41 41 41 41 3e 3e 00 00 7f 7f 41 41 41 41 7f 7f 01 01 01 01 7f 7f
// // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.16384 // // /// // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // COLOR 0 xyzw 0 NONE float x // DEPTH 0 x 1 NONE float x // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 x 0 TARGET float x // SV_DepthGreaterEqual 0 N/A oDepthGE DEPTHGE float YES // ps_5_0 dcl_globalFlags refactoringAllowed dcl_input_ps linear v0.x dcl_input_ps linear v1.x dcl_output o0.x dcl_output oDepthGE mov o0.x, v0.x mov oDepthGE, v1.x ret // Approximately 3 instruction slots used
/* ----------------------------------------------------------------------------------- * * File CCScriptSupport.cpp * Ported By Young-Hwan Mun * Contact xmsoft77@gmail.com * * ----------------------------------------------------------------------------------- * * Copyright (c) 2010-2014 XMSoft * Copyright (c) 2010-2013 cocos2d-x.org * * http://www.cocos2d-x.org * * ----------------------------------------------------------------------------------- * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * --------------------------------------------------------------------------------- */ #include "2d/script_support/CCScriptSupport.h" #include "2d/CCScheduler.h" bool CC_DLL cc_assert_script_compatible(const char *msg) { cocos2d::ScriptEngineProtocol* pEngine = cocos2d::ScriptEngineManager::getInstance()->getScriptEngine(); if (pEngine && pEngine->handleAssert(msg)) { return true; } return false; } NS_CC_BEGIN // #pragma mark - // #pragma mark ScriptHandlerEntry ScriptHandlerEntry* ScriptHandlerEntry::create(int nHandler) { ScriptHandlerEntry* entry = new ScriptHandlerEntry(nHandler); entry->autorelease(); return entry; } ScriptHandlerEntry::~ScriptHandlerEntry(void) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(m_nHandler); } // #pragma mark - // #pragma mark SchedulerScriptHandlerEntry SchedulerScriptHandlerEntry* SchedulerScriptHandlerEntry::create(int nHandler, float fInterval, bool bPaused) { SchedulerScriptHandlerEntry* pEntry = new SchedulerScriptHandlerEntry(nHandler); pEntry->init(fInterval, bPaused); pEntry->autorelease(); return pEntry; } bool SchedulerScriptHandlerEntry::init(float fInterval, bool bPaused) { m_pTimer = new Timer(); m_pTimer->initWithScriptHandler(m_nHandler, fInterval); m_pTimer->autorelease(); m_pTimer->retain(); m_bPaused = bPaused; LUALOG("[LUA] ADD script schedule: %d, entryID: %d", m_nHandler, m_nEntryId); return true; } SchedulerScriptHandlerEntry::~SchedulerScriptHandlerEntry(void) { m_pTimer->release(); LUALOG("[LUA] DEL script schedule %d, entryID: %d", m_nHandler, m_nEntryId); } // #pragma mark - // #pragma mark TouchScriptHandlerEntry TouchScriptHandlerEntry* TouchScriptHandlerEntry::create(int nHandler, bool bIsMultiTouches, int nPriority, bool bSwallowsTouches) { TouchScriptHandlerEntry* pEntry = new TouchScriptHandlerEntry(nHandler); pEntry->init(bIsMultiTouches, nPriority, bSwallowsTouches); pEntry->autorelease(); return pEntry; } TouchScriptHandlerEntry::~TouchScriptHandlerEntry(void) { ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(m_nHandler); LUALOG("[LUA] Remove touch event handler: %d", m_nHandler); } bool TouchScriptHandlerEntry::init(bool bIsMultiTouches, int nPriority, bool bSwallowsTouches) { m_bIsMultiTouches = bIsMultiTouches; m_nPriority = nPriority; m_bSwallowsTouches = bSwallowsTouches; return true; } // #pragma mark - // #pragma mark ScriptEngineManager static ScriptEngineManager* s_pSharedScriptEngineManager = NULL; ScriptEngineManager::~ScriptEngineManager(void) { removeScriptEngine(); } void ScriptEngineManager::setScriptEngine(ScriptEngineProtocol *pScriptEngine) { removeScriptEngine(); m_pScriptEngine = pScriptEngine; } void ScriptEngineManager::removeScriptEngine(void) { if (m_pScriptEngine) { delete m_pScriptEngine; m_pScriptEngine = NULL; } } ScriptEngineManager* ScriptEngineManager::getInstance() { if (!s_pSharedScriptEngineManager) { s_pSharedScriptEngineManager = new ScriptEngineManager(); } return s_pSharedScriptEngineManager; } void ScriptEngineManager::destroyInstance() { if (s_pSharedScriptEngineManager) { delete s_pSharedScriptEngineManager; s_pSharedScriptEngineManager = NULL; } } NS_CC_END
; A330033: a(n) = Kronecker(n, 5) * (-1)^floor(n/5). ; 0,1,-1,-1,1,0,-1,1,1,-1,0,1,-1,-1,1,0,-1,1,1,-1,0,1,-1,-1,1,0,-1,1,1,-1,0,1,-1,-1,1,0,-1,1,1,-1,0,1,-1,-1,1,0,-1,1,1,-1,0,1,-1,-1,1,0,-1,1,1,-1,0,1,-1,-1,1,0,-1,1,1,-1,0,1,-1,-1,1,0,-1 mov $2,$0 mul $0,22 mov $3,5 lpb $0,1 sub $0,$2 lpb $0,1 sub $0,5 add $3,$1 sub $1,6 sub $1,$3 lpe lpe div $1,11
; You may customize this and other start-up templates; ; The location of this template is c:\emu8086\inc\0_com_template.txt org 100h ; add your code here ret
; A144721: a(0) = 2, a(1) = 5, a(n) = 4 * a(n-1) - a(n-2). ; 2,5,18,67,250,933,3482,12995,48498,180997,675490,2520963,9408362,35112485,131041578,489053827,1825173730,6811641093,25421390642,94873921475,354074295258,1321423259557,4931618742970,18405051712323,68688588106322,256349300712965,956708614745538,3570485158269187 mov $1,2 lpb $0,1 sub $0,1 add $2,$1 add $2,$1 sub $1,1 add $1,$2 lpe
Name: Ending1-e.asm Type: file Size: 19345 Last-Modified: '1992-11-18T01:42:42Z' SHA-1: A2254FC9252582AD51D0953D882C2A6EEB0811AA Description: null
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r15 push %rax lea addresses_WC_ht+0x121e4, %r12 nop nop nop nop sub %r13, %r13 mov (%r12), %ax nop nop nop nop dec %r15 pop %rax pop %r15 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r8 push %r9 push %rbp push %rdx // Faulty Load lea addresses_WT+0x6290, %r10 nop nop nop nop add $18145, %r11 mov (%r10), %rdx lea oracles, %r10 and $0xff, %rdx shlq $12, %rdx mov (%r10,%rdx,1), %rdx pop %rdx pop %rbp pop %r9 pop %r8 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 2}} {'39': 21829} 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 */
#include<iostream> using namespace std; class Test { public: Test(); }; Test::Test() { cout<<"Constructor Called \n"; } int main() { cout<<"Start \n"; Test t1(); cout<<"End \n"; return 0; }
.386 .model flat, stdcall option casemap : none include sy.inc include sokoban.inc .data levelFileName1 byte "./pic/level-1.bmp", 0h levelFileName2 byte "./pic/level-2.bmp", 0h levelFileName3 byte "./pic/level-3.bmp", 0h levelFileName4 byte "./pic/level-4.bmp", 0h levelFileName5 byte "./pic/level-5.bmp", 0h levelFileName6 byte "./pic/level-6.bmp", 0h levelFileName7 byte "./pic/level-7.bmp", 0h levelFileName8 byte "./pic/level-8.bmp", 0h levelFileName9 byte "./pic/level-9.bmp", 0h levelFileName10 byte "./pic/level-10.bmp", 0h hInstance dd ? ; 主程序句柄 hGuide dd ? ; 引导文字句柄 hLevel dd ? ; 关卡句柄 hLevelText dd ? ; 关卡文本句柄 hStep dd ? ; 步数句柄 hStepText dd ? ; 步数文本句柄 hMenu dd ? ; 菜单句柄 hIcon dd ? ; 图标句柄 hAcce dd ? ; 热键句柄 hStage dd ? ; 矩形外部句柄 hDialogBrush dd ? ; 对话框背景笔刷 hStageBrush dd ? ; 矩形外部背景笔刷 currentLevel dd 0 ;记录当前关卡 cLevel dd 5 dup(0) currentStep dd 0 cStep dd 5 dup(0) CurrPosition dd 0 ; 记录人的位置 OriginMapText dd MAX_LEN dup(0) ; 原始地图矩阵 CurrentMapText dd MAX_LEN dup(0) ; 当前地图矩阵 CurrBestLevel dd 10 ; 当前最好成绩,用于选关 ProgramName db "Game", 0 ; 程序名称 GameName db "sokoban", 0 ; 程序名称 Author db "Ge, Gong, Wang, Xu", 0 ; 作者 cGuide db "Sokoban!", 0 ; 引导信息 isWin db 0 ; 判断是否成功 iprintf db "%d", 0ah, 0 cLevel1 db "1", 0 cLevel2 db "2", 0 cLevel3 db "3", 0 cLevel4 db "4", 0 cLevel5 db "5", 0 cLevel6 db "6", 0 cLevel7 db "7", 0 cLevel8 db "8", 0 cLevel9 db "9", 0 cLevel10 db "10",0 strZero byte "0", 0h hBLEVEL1 dd ? ;选关按钮句柄 hBLEVEL2 dd ? hBLEVEL3 dd ? hBLEVEL4 dd ? hBLEVEL5 dd ? hBLEVEL6 dd ? hBLEVEL7 dd ? hBLEVEL8 dd ? hBLEVEL9 dd ? hBLEVEL10 dd ? hBLEVEL dd 10 dup(0) syBLEVELBitmaps HBITMAP 10 dup(0) .code WinMain PROC hInst : dword, hPrevInst : dword, cmdLine : dword, cmdShow : dword local wc : WNDCLASSEX; 窗口类 local msg : MSG; 消息 local hWnd : HWND; 对话框句柄 invoke RtlZeroMemory, addr wc, sizeof WNDCLASSEX mov wc.cbSize, sizeof WNDCLASSEX; 窗口类的大小 mov wc.style, CS_HREDRAW or CS_VREDRAW; 窗口风格 mov wc.lpfnWndProc, offset Calculate; 窗口消息处理函数地址 mov wc.cbClsExtra, 0; 在窗口类结构体后的附加字节数,共享内存 mov wc.cbWndExtra, DLGWINDOWEXTRA; 在窗口实例后的附加字节数 push hInst pop wc.hInstance; 窗口所属程序句柄 mov wc.hbrBackground, COLOR_WINDOW; 背景画刷句柄 mov wc.lpszMenuName, NULL; 菜单名称指针 mov wc.lpszClassName, offset ProgramName; 窗口类类名称 ; 加载图标句柄 ; invoke LoadIcon, hInst, IDI_ICON ; mov wc.hIcon, eax ; 加载光标句柄 invoke LoadCursor, NULL, IDC_ARROW mov wc.hCursor, eax mov wc.hIconSm, 0; 窗口小图标句柄 invoke RegisterClassEx, addr wc; 注册窗口类 ; 加载对话框窗口 invoke CreateDialogParam, hInst, IDD_DIALOG1, 0, offset Calculate, 0 mov hWnd, eax ; 设置主窗体id invoke sySetMainWinId, eax invoke ShowWindow, hWnd, cmdShow; 显示窗口 invoke UpdateWindow, hWnd; 更新窗口 ; 消息循环 .while TRUE invoke GetMessage, addr msg, NULL, 0, 0; 获取消息 .break .if eax == 0 invoke TranslateAccelerator, hWnd, hAcce, addr msg; 转换快捷键消息 .if eax == 0 invoke TranslateMessage, addr msg; 转换键盘消息 invoke DispatchMessage, addr msg; 分发消息 .endif .endw mov eax, msg.wParam ret WinMain endp ; 判断输赢 JudgeWin proc ; 若图中不出现属性5,证明箱子全部到位 xor eax, eax xor ebx, ebx; ebx记录图中箱子存放点数量 mov eax, 0 .while eax < MAX_LEN .if OriginMapText[eax * 4] == 5 ;如果Origin是5的位置 Current都是4就行了 .if CurrentMapText[eax * 4] == 4 jmp L1 .else ;不等于4,说明没成功 jmp NotWin .endif .endif L1: inc eax .endw mov isWin, 1 ;该局获胜 mov ebx, CurrBestLevel .if currentLevel == ebx inc CurrBestLevel .endif inc currentLevel ;关卡数+1 ret NotWin: mov isWin, 0 ret JudgeWin endp CreateLevelMap proc ; 创建当前关卡地图 .if currentLevel == 0 invoke CreateMap1 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel1 .elseif currentLevel == 1 invoke CreateMap2 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel2 .elseif currentLevel == 2 invoke CreateMap3 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel3 .elseif currentLevel == 3 invoke CreateMap4 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel4 .elseif currentLevel == 4 invoke CreateMap5 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel5 .elseif currentLevel == 5 invoke CreateMap6 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel6 .elseif currentLevel == 6 invoke CreateMap7 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel7 .elseif currentLevel == 7 invoke CreateMap8 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel8 .elseif currentLevel == 8 invoke CreateMap9 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel9 .elseif currentLevel == 9 invoke CreateMap10 invoke SendMessage, hLevelText, WM_SETTEXT, 0, offset cLevel10 .else ; 通关了 invoke syEndGame jmp UPDATE_MAP .endif invoke syStartGame UPDATE_MAP: ; 恢复步数为0,恢复获胜标志 and currentStep, 0 and isWin, 0 invoke SendMessage, hStepText, WM_SETTEXT, 0, offset strZero invoke syUpdateMap ret CreateLevelMap endp Calculate proc hWnd : dword, uMsg : UINT, wParam : WPARAM, lParam : LPARAM local hdc : HDC local ps : PAINTSTRUCT .if uMsg == WM_INITDIALOG ; 获取菜单的句柄并显示菜单 ; invoke LoadMenu, hInstance, IDR_MENU1 ; mov hMenu, eax ; invoke SetMenu, hWnd, hMenu ; 获取快捷键的句柄并显示菜单 invoke LoadAccelerators, hInstance, IDR_ACCELERATOR2 mov hAcce, eax ; 初始化数组和矩阵 invoke InitRec, hWnd invoke InitBrush .elseif uMsg == WM_PAINT ; 绘制对话框背景 invoke BeginPaint, hWnd, addr ps mov hdc, eax invoke FillRect, hdc, addr ps.rcPaint, hDialogBrush ; 绘制地图 invoke syDrawMap, hdc invoke EndPaint, hWnd, addr ps .elseif uMsg == WM_COMMAND mov eax, wParam movzx eax, ax; 获得命令 ; 开始新游戏,此时需要加载当前关卡对应的地图 .if eax == IDC_NEW || eax == ID_NEW ; 隐藏按钮 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw ; 创建当前关卡地图 invoke CreateLevelMap ;重新进入选择关卡界面 .elseif eax == IDC_REMAKE mov currentLevel, 0 mov currentStep, 0 mov isWin, 0 ; invoke syResetGame ; 画按钮 mov ebx, 0 .while ebx <= CurrBestLevel invoke SendMessage, hBLEVEL[ebx * 4], BM_SETIMAGE, IMAGE_BITMAP, syBLEVELBitmaps[ebx * 4] invoke ShowWindow, hBLEVEL[ebx * 4], SW_SHOWNORMAL inc ebx .endw invoke sySelectLevel ; 上方向键 .elseif eax == IDC_UP .if !isWin invoke MoveUp inc currentStep invoke dwtoa, currentStep, offset cStep invoke SendMessage, hStepText, WM_SETTEXT, 0, offset cStep invoke JudgeWin .endif ; 下方向键 .elseif eax == IDC_DOWN .if !isWin invoke MoveDown inc currentStep invoke dwtoa, currentStep, offset cStep invoke SendMessage, hStepText, WM_SETTEXT, 0, offset cStep invoke JudgeWin .endif ; 左方向键 .elseif eax == IDC_LEFT .if !isWin invoke MoveLeft inc currentStep invoke dwtoa, currentStep, offset cStep invoke SendMessage, hStepText, WM_SETTEXT, 0, offset cStep invoke JudgeWin .endif ; 右方向键 .elseif eax == IDC_RIGHT .if !isWin invoke MoveRight inc currentStep invoke dwtoa, currentStep, offset cStep invoke SendMessage, hStepText, WM_SETTEXT, 0, offset cStep invoke JudgeWin .endif .elseif eax == IDC_BLEVEL1 ; 先把按钮擦除,再跳转 mov currentLevel, 0 ;设置当前关卡的数字 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL2 mov currentLevel, 1 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL3 mov currentLevel, 2 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL4 mov currentLevel, 3 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL5 mov currentLevel, 4 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL6 mov currentLevel, 5 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL7 mov currentLevel, 6 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL8 mov currentLevel, 7 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL9 mov currentLevel, 8 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .elseif eax == IDC_BLEVEL10 mov currentLevel, 9 mov ebx, 0 .while ebx <= CurrBestLevel invoke ShowWindow, hBLEVEL[ebx * 4], SW_HIDE inc ebx .endw invoke CreateLevelMap .endif ; 获胜处理 .if isWin == 1 invoke CreateLevelMap .endif .elseif uMsg == WM_ERASEBKGND ret .elseif uMsg == WM_CLOSE invoke DestroyWindow, hWnd .elseif uMsg == WM_DESTROY invoke PostQuitMessage, 0 .else invoke DefWindowProc, hWnd, uMsg, wParam, lParam ret .endif xor eax, eax ret Calculate endp InitRec proc hWnd : dword ; 调用GetDlgItem函数获得句柄 ; 包括整体背景的句柄等 invoke GetDlgItem, hWnd, IDC_STEP mov hStep, eax invoke GetDlgItem, hWnd, IDC_STEPTEXT mov hStepText, eax invoke GetDlgItem, hWnd, IDC_LEVEL mov hLevel, eax invoke GetDlgItem, hWnd, IDC_LEVELTEXT mov hLevelText, eax invoke GetDlgItem, hWnd, IDC_BLEVEL1 mov hBLEVEL1, eax mov hBLEVEL[0], eax invoke GetDlgItem, hWnd, IDC_BLEVEL2 mov hBLEVEL2, eax mov hBLEVEL[4], eax invoke GetDlgItem, hWnd, IDC_BLEVEL3 mov hBLEVEL3, eax mov hBLEVEL[8], eax invoke GetDlgItem, hWnd, IDC_BLEVEL4 mov hBLEVEL4, eax mov hBLEVEL[12], eax invoke GetDlgItem, hWnd, IDC_BLEVEL5 mov hBLEVEL5, eax mov hBLEVEL[16], eax invoke GetDlgItem, hWnd, IDC_BLEVEL6 mov hBLEVEL6, eax mov hBLEVEL[20], eax invoke GetDlgItem, hWnd, IDC_BLEVEL7 mov hBLEVEL7, eax mov hBLEVEL[24], eax invoke GetDlgItem, hWnd, IDC_BLEVEL8 mov hBLEVEL8, eax mov hBLEVEL[28], eax invoke GetDlgItem, hWnd, IDC_BLEVEL9 mov hBLEVEL9, eax mov hBLEVEL[32], eax invoke GetDlgItem, hWnd, IDC_BLEVEL10 mov hBLEVEL10, eax mov hBLEVEL[36], eax ret InitRec endp InitBrush proc ; 创建不同种类的画刷颜色 invoke CreateSolidBrush, DialogBack mov hDialogBrush, eax ; 加载选关按钮对应的位图文件 invoke LoadImage, NULL, offset levelFileName1, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[0], eax invoke LoadImage, NULL, offset levelFileName2, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[4], eax invoke LoadImage, NULL, offset levelFileName3, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[8], eax invoke LoadImage, NULL, offset levelFileName4, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[12], eax invoke LoadImage, NULL, offset levelFileName5, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[16], eax invoke LoadImage, NULL, offset levelFileName6, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[20], eax invoke LoadImage, NULL, offset levelFileName7, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[24], eax invoke LoadImage, NULL, offset levelFileName8, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[28], eax invoke LoadImage, NULL, offset levelFileName9, IMAGE_BITMAP, 46, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[32], eax invoke LoadImage, NULL, offset levelFileName10, IMAGE_BITMAP, 92, 58, LR_LOADFROMFILE mov syBLEVELBitmaps[36], eax ret InitBrush endp MoveUp proc ; 找到当前人的位置 xor esi, esi mov esi, CurrPosition; 假设CurrPosition记录当前人的位置, esi记录当前人位置 mov edi, esi sub edi, 10; edi记录人的上方位置 ; 设置角色脸朝向 invoke sySetPlayerFace, SY_FACE_UP ; 判断上方格子类型 ; 如果是空地或结束点, 人移动 .if CurrentMapText[edi * 4] == 2 || CurrentMapText[edi * 4] == 5 mov CurrPosition, edi; 改变人的当前位置 mov dword ptr CurrentMapText[edi * 4], 3; 改变上方方格属性 mov eax, OriginMapText[esi * 4] mov CurrentMapText[esi * 4], eax ; 刷新格子 invoke syUpdateGrid, edi invoke syUpdateGrid, esi ; 如果是箱子 .elseif CurrentMapText[edi * 4] == 4 ; 判断箱子那边是什么 xor ecx, ecx mov ecx, edi sub ecx, 10; ecx是人的上上方位置 ; 如果是围墙或箱子 .if CurrentMapText[ecx * 4] == 1 || CurrentMapText[ecx * 4] == 4 ; 刷新格子 invoke syUpdateGrid, esi .else ; 只可能是空地或存放点,可以移动 mov CurrPosition, edi; 改变人的当前位置 mov dword ptr CurrentMapText[ecx * 4], 4 mov dword ptr CurrentMapText[edi * 4], 3 mov eax, OriginMapText[esi * 4] mov CurrentMapText[esi * 4], eax ; 刷新格子 invoke syUpdateGrid, ecx invoke syUpdateGrid, edi invoke syUpdateGrid, esi .endif .else ; 是墙 invoke syUpdateGrid, esi .endif ret MoveUp endp MoveDown proc ; 找到当前人的位置 xor esi, esi mov esi, CurrPosition; 假设CurrPosition记录当前人的位置, esi记录当前人位置 mov edi, esi add edi, 10; edi记录人的下方位置 ; 设置角色脸朝向 invoke sySetPlayerFace, SY_FACE_DOWN ; 判断下方格子类型 ; 如果是空地或结束点, 人移动 .if CurrentMapText[edi * 4] == 2 || CurrentMapText[edi * 4] == 5 mov dword ptr CurrPosition, edi; 改变人的当前位置 mov dword ptr CurrentMapText[edi * 4], 3; 改变下方方格属性 mov eax, OriginMapText[esi * 4] mov CurrentMapText[esi * 4], eax ; 刷新格子 invoke syUpdateGrid, edi invoke syUpdateGrid, esi ; 如果是箱子 .elseif CurrentMapText[edi * 4] == 4 ; 判断箱子那边是什么 xor ecx, ecx mov ecx, edi add ecx, 10; ecx是人的下下方位置 ; 如果是围墙或箱子 .if CurrentMapText[ecx * 4] == 1 || CurrentMapText[ecx * 4] == 4 ; 删除了continue ; 刷新格子 invoke syUpdateGrid, esi .else ; 只可能是空地或存放点,可以移动 mov CurrPosition, edi; 改变人的当前位置 mov dword ptr CurrentMapText[ecx * 4], 4 mov dword ptr CurrentMapText[edi * 4], 3 mov eax, OriginMapText[esi * 4] mov CurrentMapText[esi * 4], eax ; 刷新格子 invoke syUpdateGrid, ecx invoke syUpdateGrid, edi invoke syUpdateGrid, esi .endif .else ; 是墙 invoke syUpdateGrid, esi .endif ret MoveDown endp MoveLeft proc ; 找到当前人的位置 xor esi, esi mov esi, CurrPosition; 假设CurrPosition记录当前人的位置, esi记录当前人位置 mov edi, esi sub edi, 1; edi记录人的左方位置 ; 设置角色脸朝向 invoke sySetPlayerFace, SY_FACE_LEFT ; 判断左方格子类型 ; 如果是空地或结束点, 人移动 .if CurrentMapText[edi * 4] == 2 || CurrentMapText[edi * 4] == 5 mov dword ptr CurrPosition, edi; 改变人的当前位置 mov dword ptr CurrentMapText[edi * 4], 3; 改变左方方格属性 mov eax, OriginMapText[esi * 4] mov CurrentMapText[esi * 4], eax ; 刷新格子 invoke syUpdateGrid, edi invoke syUpdateGrid, esi ; 如果是箱子 .elseif CurrentMapText[edi * 4] == 4 ; 判断箱子那边是什么 xor ecx, ecx mov ecx, edi sub ecx, 1; ecx是人的左左方位置 ; 如果是围墙或箱子 .if CurrentMapText[ecx * 4] == 1 || CurrentMapText[ecx * 4] == 4 ; .continue ; 刷新格子 invoke syUpdateGrid, esi .else ; 只可能是空地或存放点,可以移动 mov dword ptr CurrPosition, edi; 改变人的当前位置 mov dword ptr CurrentMapText[ecx * 4], 4 mov dword ptr CurrentMapText[edi * 4], 3 mov eax, OriginMapText[esi * 4] mov CurrentMapText[esi * 4], eax ; 刷新格子 invoke syUpdateGrid, ecx invoke syUpdateGrid, edi invoke syUpdateGrid, esi .endif .else ; 是墙 invoke syUpdateGrid, esi .endif ret MoveLeft endp MoveRight proc ; 找到当前人的位置 xor esi, esi mov esi, CurrPosition; 假设CurrPosition记录当前人的位置, esi记录当前人位置 mov edi, esi add edi, 1; edi记录人的右方位置 ; 设置角色脸朝向 invoke sySetPlayerFace, SY_FACE_RIGHT ; 判断左方格子类型 ; 如果是空地或结束点, 人移动 .if CurrentMapText[edi * 4] == 2 || CurrentMapText[edi * 4] == 5 mov dword ptr CurrPosition, edi; 改变人的当前位置 mov dword ptr CurrentMapText[edi * 4], 3; 改变右方方格属性 mov eax, OriginMapText[esi * 4] mov CurrentMapText[esi * 4], eax ; 刷新格子 invoke syUpdateGrid, edi invoke syUpdateGrid, esi ; 如果是箱子 .elseif CurrentMapText[edi * 4] == 4 ; 判断箱子那边是什么 xor ecx, ecx mov ecx, edi add ecx, 1; ecx是人的右右方位置 ; 如果是围墙或箱子 .if CurrentMapText[ecx * 4] == 1 || CurrentMapText[ecx * 4] == 4 ; .continue ; 刷新格子 invoke syUpdateGrid, esi .else ; 只可能是空地或存放点,可以移动 mov dword ptr CurrPosition, edi; 改变人的当前位置 mov dword ptr CurrentMapText[ecx * 4], 4 mov dword ptr CurrentMapText[edi * 4], 3 mov eax, OriginMapText[esi * 4] mov CurrentMapText[esi * 4], eax ; 刷新格子 invoke syUpdateGrid, ecx invoke syUpdateGrid, edi invoke syUpdateGrid, esi .endif .else ; 是墙 invoke syUpdateGrid, esi ; .continue .endif ret MoveRight endp ; 第一关地图初始化 CreateMap1 proc xor ebx, ebx .while ebx < REC_LEN .if (ebx < 13 || (ebx > 15 && ebx < 23) || (ebx > 25 && ebx < 33) || ebx == 39 || ebx == 40 || ebx == 49 || ebx == 50 || ebx == 59 || ebx == 60 || (ebx > 66 && ebx < 74) || (ebx > 76 && ebx < 84) || ebx > 86) mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .elseif((ebx > 12 && ebx < 16) || ebx == 23 || ebx == 25 || ebx == 33 || (ebx > 34 && ebx < 39) || (ebx > 40 && ebx < 44) || ebx == 48 || ebx == 51 || (ebx > 55 && ebx < 59) || (ebx > 60 && ebx < 65) || ebx == 66 || ebx == 74 || ebx == 76 || (ebx > 83 && ebx < 87)) mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .elseif(ebx == 34 || ebx == 45 || ebx == 53) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 55 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif(ebx == 44 || ebx == 46 || ebx == 54 || ebx == 65) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif(ebx == 24 || ebx == 47 || ebx == 52 || ebx == 75) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition, 55 ret CreateMap1 endp ; 第二关地图初始化 CreateMap2 proc xor ebx, ebx .while ebx < REC_LEN .if (ebx == 0 || (ebx > 5 && ebx < 11) || (ebx > 15 && ebx < 21) || ebx == 26 || ebx == 30 || ebx == 36 || ebx == 40 || (ebx > 49 && ebx < 52) || (ebx > 59 && ebx < 62) || (ebx > 69 && ebx < 72) || (ebx > 79 && ebx < 82) || ebx > 86) mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .elseif((ebx > 0 && ebx < 6) || ebx == 11 || ebx == 15 || ebx == 21 || ebx == 25 || (ebx > 26 && ebx < 30) || ebx == 31 || ebx == 35 || ebx == 37 || ebx == 39 || (ebx > 40 && ebx < 44) || (ebx > 44 && ebx < 48) || ebx == 49 || ebx == 52 || ebx == 53) mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .elseif(ebx == 59 || ebx == 62 || ebx == 66 || ebx == 69 || ebx == 72 || (ebx > 75 && ebx < 80) || (ebx > 81 && ebx < 87)) mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .elseif(ebx == 13 || ebx == 14 || ebx == 22 || ebx == 32 || ebx == 34 || ebx == 44 || (ebx > 53 && ebx < 58) || (ebx > 62 && ebx < 66) || ebx == 67 || ebx == 68 || (ebx > 72 && ebx < 76)) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 12 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif(ebx == 23 || ebx == 24 || ebx == 33) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif(ebx == 38 || ebx == 48 || ebx == 58) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition, 12 ret CreateMap2 endp ; 第三关地图初始化 CreateMap3 proc xor ebx, ebx .while ebx < REC_LEN .if (ebx < 11 || (ebx > 17 && ebx < 21) || ebx == 69 || ebx == 70 || ebx > 78) mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .elseif((ebx > 21 && ebx < 27) || (ebx > 35 && ebx < 39) || ebx == 41 || ebx == 43 || ebx == 45 || ebx == 46 || ebx == 48 || ebx == 51 || ebx == 55 || ebx == 57 || ebx == 65 || ebx == 66 || ebx == 67) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 42 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif(ebx == 32 || ebx == 44 || ebx == 47 || ebx == 56) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif(ebx == 52 || ebx == 53 || ebx == 62 || ebx == 63) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .else mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition, 42 ret CreateMap3 endp ; 第四关地图初始化 CreateMap4 proc xor ebx, ebx .while ebx < REC_LEN .if ((ebx > 12 && ebx < 17) || ebx == 22 || ebx == 23 || ebx == 26 || ebx == 32 || ebx == 36 || ebx == 42 || ebx == 43 || ebx == 46 || ebx == 47 || ebx == 52 || ebx == 53 || ebx == 57 || ebx == 62 || ebx == 67 || ebx == 72 || ebx == 77 || (ebx > 81 && ebx < 88)) mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .elseif(ebx == 24 || ebx == 25 || ebx == 35 || ebx == 45 || ebx == 54 || ebx == 56 || ebx == 65 || ebx == 66) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 33 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif(ebx == 34 || ebx == 44 || ebx == 55 || ebx == 64 || ebx == 75) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif(ebx == 63 || ebx == 73 || ebx == 74 || ebx == 76) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .else mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 .if ebx == 75 mov dword ptr OriginMapText[ebx * 4], 5 .endif inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition,33 ret CreateMap4 endp ; 第五关地图初始化 CreateMap5 proc xor ebx, ebx .while ebx < REC_LEN .if ( ebx < 12 || ( ebx > 16 && ebx < 22 ) || ( ebx > 27 && ebx < 32 ) || ( ebx > 37 && ebx < 41 ) || ebx == 49 || ebx == 50 || ebx == 59 || ebx == 60 || ebx == 69 || ebx == 70 || ebx == 79 || ebx == 80 || ebx > 88 ) mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .elseif ( ebx == 24 || ebx == 33 || ebx == 35 || ebx == 36 || ebx == 44 || ebx == 46 || ebx == 54 || ebx == 56 || ebx == 57 || ebx == 64 || ebx == 65 || ebx == 67 || ebx == 73 || ebx == 74 || ebx == 75 || ebx == 77 ) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 23 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif ( ebx == 34 || ebx == 63 || ebx == 76 ) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif ( ebx == 52 || ebx == 62 || ebx == 72 ) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .else mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition,23 ret CreateMap5 endp ;第六关初始化 CreateMap6 proc xor ebx, ebx .while ebx < REC_LEN .if ( ebx < 13 || (ebx > 19 && ebx < 22) || (ebx > 29 && ebx < 32) || (ebx > 39 && ebx < 42) || (ebx > 49 && ebx < 52) || ebx == 79 || ebx > 88) mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .elseif ( ebx == 24 || ebx == 25 || ebx == 28 || ebx == 33 || ebx == 34 || ebx == 35 || ebx == 37 || ebx == 38 || ebx == 44 || ebx == 46 || ebx == 48 || ebx == 53 || ebx == 57 || ebx == 58 || ebx == 63 || ebx == 65 || ebx == 67 || ebx == 76 || ebx == 77 ) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 27 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif ( ebx == 43 || ebx == 45 || ebx == 47 || ebx == 54 || ebx == 64) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif ( ebx > 70 && ebx < 76 ) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .else mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition,27 ret CreateMap6 endp ;第七关初始化 CreateMap7 proc xor ebx, ebx .while ebx < REC_LEN .if ( (ebx > 12 && ebx < 19) || ebx == 23 || ebx == 28 || (ebx > 30 && ebx < 34) || ebx == 38 || ebx == 41 || ebx == 48 || ebx == 51 || ebx == 57 || ebx == 58 || (ebx > 60 && ebx < 65) || ebx == 67 || (ebx > 73 && ebx < 78)) mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .elseif ( (ebx > 23 && ebx < 28 ) || ebx == 37 || ebx == 43 || ebx == 47 || ebx == 52 || ebx == 65 || ebx == 66) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 42 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif ( ebx == 34 || ebx == 35 || ebx == 36 || ebx == 44 || ebx == 53 ) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif ( ebx == 45 || ebx == 46 || ebx == 54 || ebx == 55 || ebx == 56 ) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .else mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition, 42 ret CreateMap7 endp ;第八关初始化 CreateMap8 proc xor ebx, ebx .while ebx < REC_LEN .if ( (ebx > 12 && ebx < 17) || ebx == 23 || ebx == 26 || ebx == 32 || ebx == 33 || ebx == 36 || ebx == 37 || ebx == 42 || ebx == 47 || ebx == 51 || ebx == 52 || ebx == 57 || ebx == 58 || ebx == 61 || ebx == 64 || ebx == 68 || ebx == 71 || ebx == 78 || (ebx > 80 && ebx < 89) ) mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .elseif ( ebx == 34 || ebx == 43 || ebx == 44 || ebx == 53 || ebx == 55 || ebx == 56 || ebx == 62 || ebx == 63 || ebx == 67 || ebx == 72 || (ebx > 73 && ebx < 78) ) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 73 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif ( ebx == 45 || ebx == 54 || ebx == 65 || ebx == 66) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif ( ebx == 24 || ebx == 25 || ebx == 35 || ebx == 46 ) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .else mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition,73 ret CreateMap8 endp ;第九关初始化 CreateMap9 proc xor ebx, ebx .while ebx < REC_LEN .if ( ebx < 11 || (ebx > 18 && ebx < 21) || (ebx > 28 && ebx < 31) || (ebx > 38 && ebx < 41) || (ebx > 48 && ebx < 51) || (ebx > 58 && ebx < 61) || (ebx > 68 && ebx < 71) || ebx > 78) mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .elseif ( ebx == 22 || ebx == 23 || (ebx > 24 && ebx < 28) || ebx == 37 || ebx ==42 || ebx == 46 || ebx == 52 || ebx == 57 || ebx == 62 || ebx == 63 || (ebx > 64 && ebx < 68 )) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 32 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif ( ebx == 33 || ebx == 36 || ebx == 43 || ebx == 45 || ebx == 53 || ebx == 56 ) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif ( ebx == 34 || ebx == 35 || ebx == 44 || ebx == 54 || ebx == 55 ) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .else mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 .if ebx == 45 mov dword ptr OriginMapText[ebx * 4], 5 .endif inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition, 32 ret CreateMap9 endp ;第十关初始化 CreateMap10 proc xor ebx, ebx .while ebx < REC_LEN .if ( ebx < 12 || ( ebx > 17 && ebx < 22) || ( ebx > 27 && ebx < 32) || ( ebx > 37 && ebx < 41 ) || ( ebx > 48 && ebx < 51 ) || ( ebx > 58 && ebx < 61 ) || ( ebx > 68 && ebx < 71 ) || ( ebx > 78 && ebx < 81 ) || ebx > 88 ) mov dword ptr CurrentMapText[ebx * 4], 0 inc ebx .elseif ( ebx == 24 || ebx == 34 || ebx == 44 || ebx == 45 || ebx == 52 || ebx == 54 || ebx == 55 || ebx == 57 || ebx == 62 || ebx == 67 || ebx == 72 || ebx == 73 || ebx == 74 || ebx == 76 || ebx == 77 ) mov dword ptr CurrentMapText[ebx * 4], 2 inc ebx .elseif ebx == 75 mov dword ptr CurrentMapText[ebx * 4], 3 inc ebx .elseif ( ebx == 35 || ebx == 46 || ebx == 53 || ebx == 56 || ebx == 64) mov dword ptr CurrentMapText[ebx * 4], 4 inc ebx .elseif ( ebx == 23 || ebx == 25 || ebx == 26 || ebx == 33 || ebx == 36 ) mov dword ptr CurrentMapText[ebx * 4], 5 inc ebx .else mov dword ptr CurrentMapText[ebx * 4], 1 inc ebx .endif .endw xor ebx, ebx .while ebx < REC_LEN mov eax, dword ptr CurrentMapText[ebx * 4] .if eax == 3 || eax == 4 mov dword ptr OriginMapText[ebx * 4], 2 inc ebx .else mov dword ptr OriginMapText[ebx * 4], eax inc ebx .endif .endw mov CurrPosition, 75 ret CreateMap10 endp ; 主程序 main proc invoke GetModuleHandle, NULL mov hInstance, eax invoke WinMain, hInstance, 0, 0, SW_SHOWNORMAL invoke ExitProcess, eax main endp end main
; int ba_stack_pop(ba_stack_t *s) SECTION code_clib SECTION code_adt_ba_stack PUBLIC ba_stack_pop EXTERN asm_ba_stack_pop defc ba_stack_pop = asm_ba_stack_pop ; SDCC bridge for Classic IF __CLASSIC PUBLIC _ba_stack_pop defc _ba_stack_pop = ba_stack_pop ENDIF
; size_t fread_unlocked(void *ptr, size_t size, size_t nmemb, FILE *stream) SECTION code_stdio PUBLIC _fread_unlocked EXTERN asm_fread_unlocked _fread_unlocked: pop af pop de pop bc pop hl pop ix push hl push hl push bc push de push af jp asm_fread_unlocked
; SPIR-V ; Version: 1.0 ; Generator: Khronos Glslang Reference Front End; 10 ; Bound: 239 ; Schema: 0 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %4 "main" %33 %89 OpExecutionMode %4 OriginUpperLeft OpSource ESSL 320 OpName %4 "main" OpName %9 "coord" OpName %13 "buf0" OpMemberName %13 0 "_GLF_uniform_float_values" OpName %15 "" OpName %24 "texel" OpName %28 "tex" OpName %33 "_GLF_color" OpName %36 "buf1" OpMemberName %36 0 "_GLF_uniform_int_values" OpName %38 "" OpName %45 "i" OpName %54 "buf_push" OpMemberName %54 0 "one" OpName %56 "" OpName %76 "i" OpName %89 "gl_FragCoord" OpName %100 "i" OpName %112 "i" OpName %124 "i" OpName %166 "i" OpName %178 "i" OpName %209 "i" OpName %221 "i" OpDecorate %12 ArrayStride 16 OpMemberDecorate %13 0 Offset 0 OpDecorate %13 Block OpDecorate %15 DescriptorSet 0 OpDecorate %15 Binding 0 OpDecorate %28 RelaxedPrecision OpDecorate %28 DescriptorSet 0 OpDecorate %28 Binding 2 OpDecorate %29 RelaxedPrecision OpDecorate %31 RelaxedPrecision OpDecorate %33 Location 0 OpDecorate %35 ArrayStride 16 OpMemberDecorate %36 0 Offset 0 OpDecorate %36 Block OpDecorate %38 DescriptorSet 0 OpDecorate %38 Binding 1 OpMemberDecorate %54 0 Offset 0 OpDecorate %54 Block OpDecorate %89 BuiltIn FragCoord OpDecorate %190 RelaxedPrecision OpDecorate %192 RelaxedPrecision %2 = OpTypeVoid %3 = OpTypeFunction %2 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 2 %8 = OpTypePointer Function %7 %10 = OpTypeInt 32 0 %11 = OpConstant %10 4 %12 = OpTypeArray %6 %11 %13 = OpTypeStruct %12 %14 = OpTypePointer Uniform %13 %15 = OpVariable %14 Uniform %16 = OpTypeInt 32 1 %17 = OpConstant %16 0 %18 = OpTypePointer Uniform %6 %22 = OpTypeVector %6 4 %23 = OpTypePointer Function %22 %25 = OpTypeImage %6 2D 0 0 0 1 Unknown %26 = OpTypeSampledImage %25 %27 = OpTypePointer UniformConstant %26 %28 = OpVariable %27 UniformConstant %32 = OpTypePointer Output %22 %33 = OpVariable %32 Output %34 = OpConstant %10 3 %35 = OpTypeArray %16 %34 %36 = OpTypeStruct %35 %37 = OpTypePointer Uniform %36 %38 = OpVariable %37 Uniform %39 = OpTypePointer Uniform %16 %44 = OpTypePointer Function %16 %54 = OpTypeStruct %6 %55 = OpTypePointer PushConstant %54 %56 = OpVariable %55 PushConstant %57 = OpTypePointer PushConstant %6 %61 = OpTypeBool %68 = OpConstant %10 0 %69 = OpTypePointer Function %6 %72 = OpConstant %16 1 %88 = OpTypePointer Input %22 %89 = OpVariable %88 Input %90 = OpConstant %10 1 %91 = OpTypePointer Input %6 %157 = OpConstant %16 2 %160 = OpConstant %16 3 %4 = OpFunction %2 None %3 %5 = OpLabel %9 = OpVariable %8 Function %24 = OpVariable %23 Function %45 = OpVariable %44 Function %76 = OpVariable %44 Function %100 = OpVariable %44 Function %112 = OpVariable %44 Function %124 = OpVariable %44 Function %166 = OpVariable %44 Function %178 = OpVariable %44 Function %209 = OpVariable %44 Function %221 = OpVariable %44 Function %19 = OpAccessChain %18 %15 %17 %17 %20 = OpLoad %6 %19 %21 = OpCompositeConstruct %7 %20 %20 OpStore %9 %21 %29 = OpLoad %26 %28 %30 = OpLoad %7 %9 %31 = OpImageSampleImplicitLod %22 %29 %30 OpStore %24 %31 %40 = OpAccessChain %39 %38 %17 %17 %41 = OpLoad %16 %40 %42 = OpConvertSToF %6 %41 %43 = OpCompositeConstruct %22 %42 %42 %42 %42 OpStore %33 %43 %46 = OpAccessChain %39 %38 %17 %17 %47 = OpLoad %16 %46 OpStore %45 %47 OpBranch %48 %48 = OpLabel OpLoopMerge %50 %51 None OpBranch %52 %52 = OpLabel %53 = OpLoad %16 %45 %58 = OpAccessChain %57 %56 %17 %59 = OpLoad %6 %58 %60 = OpConvertFToS %16 %59 %62 = OpSLessThan %61 %53 %60 OpBranchConditional %62 %49 %50 %49 = OpLabel OpBranch %63 %63 = OpLabel OpLoopMerge %65 %66 None OpBranch %67 %67 = OpLabel %70 = OpAccessChain %69 %24 %68 %71 = OpLoad %6 %70 %73 = OpAccessChain %18 %15 %17 %72 %74 = OpLoad %6 %73 %75 = OpFOrdLessThan %61 %71 %74 OpBranchConditional %75 %64 %65 %64 = OpLabel %77 = OpAccessChain %39 %38 %17 %17 %78 = OpLoad %16 %77 OpStore %76 %78 OpBranch %79 %79 = OpLabel OpLoopMerge %81 %82 None OpBranch %83 %83 = OpLabel %84 = OpLoad %16 %76 %85 = OpAccessChain %39 %38 %17 %72 %86 = OpLoad %16 %85 %87 = OpSLessThan %61 %84 %86 OpBranchConditional %87 %80 %81 %80 = OpLabel %92 = OpAccessChain %91 %89 %90 %93 = OpLoad %6 %92 %94 = OpAccessChain %18 %15 %17 %17 %95 = OpLoad %6 %94 %96 = OpFOrdGreaterThan %61 %93 %95 OpSelectionMerge %98 None OpBranchConditional %96 %97 %99 %97 = OpLabel OpBranch %98 %99 = OpLabel %101 = OpAccessChain %39 %38 %17 %72 %102 = OpLoad %16 %101 OpStore %100 %102 OpBranch %103 %103 = OpLabel OpLoopMerge %105 %106 None OpBranch %107 %107 = OpLabel %108 = OpLoad %16 %100 %109 = OpAccessChain %39 %38 %17 %17 %110 = OpLoad %16 %109 %111 = OpSGreaterThan %61 %108 %110 OpBranchConditional %111 %104 %105 %104 = OpLabel %113 = OpAccessChain %39 %38 %17 %17 %114 = OpLoad %16 %113 OpStore %112 %114 OpBranch %115 %115 = OpLabel OpLoopMerge %117 %118 None OpBranch %119 %119 = OpLabel %120 = OpLoad %16 %112 %121 = OpAccessChain %39 %38 %17 %72 %122 = OpLoad %16 %121 %123 = OpINotEqual %61 %120 %122 OpBranchConditional %123 %116 %117 %116 = OpLabel %125 = OpAccessChain %39 %38 %17 %17 %126 = OpLoad %16 %125 OpStore %124 %126 OpBranch %127 %127 = OpLabel OpLoopMerge %129 %130 None OpBranch %131 %131 = OpLabel %132 = OpLoad %16 %124 %133 = OpAccessChain %57 %56 %17 %134 = OpLoad %6 %133 %135 = OpConvertFToS %16 %134 %136 = OpSLessThan %61 %132 %135 OpBranchConditional %136 %128 %129 %128 = OpLabel %137 = OpAccessChain %91 %89 %90 %138 = OpLoad %6 %137 %139 = OpAccessChain %18 %15 %17 %17 %140 = OpLoad %6 %139 %141 = OpFOrdGreaterThan %61 %138 %140 OpSelectionMerge %143 None OpBranchConditional %141 %142 %144 %142 = OpLabel OpBranch %143 %144 = OpLabel %145 = OpAccessChain %18 %15 %17 %72 %146 = OpLoad %6 %145 %147 = OpCompositeConstruct %7 %146 %146 OpStore %9 %147 OpBranch %143 %143 = OpLabel OpBranch %130 %130 = OpLabel %148 = OpLoad %16 %124 %149 = OpIAdd %16 %148 %72 OpStore %124 %149 OpBranch %127 %129 = OpLabel OpBranch %118 %118 = OpLabel %150 = OpLoad %16 %112 %151 = OpIAdd %16 %150 %72 OpStore %112 %151 OpBranch %115 %117 = OpLabel OpBranch %106 %106 = OpLabel %152 = OpLoad %16 %100 %153 = OpISub %16 %152 %72 OpStore %100 %153 OpBranch %103 %105 = OpLabel OpBranch %98 %98 = OpLabel OpBranch %82 %82 = OpLabel %154 = OpLoad %16 %76 %155 = OpIAdd %16 %154 %72 OpStore %76 %155 OpBranch %79 %81 = OpLabel %156 = OpLoad %7 %9 %158 = OpAccessChain %18 %15 %17 %157 %159 = OpLoad %6 %158 %161 = OpAccessChain %18 %15 %17 %160 %162 = OpLoad %6 %161 %163 = OpFDiv %6 %159 %162 %164 = OpCompositeConstruct %7 %163 %163 %165 = OpFAdd %7 %156 %164 OpStore %9 %165 %167 = OpAccessChain %39 %38 %17 %17 %168 = OpLoad %16 %167 OpStore %166 %168 OpBranch %169 %169 = OpLabel OpLoopMerge %171 %172 None OpBranch %173 %173 = OpLabel %174 = OpLoad %16 %166 %175 = OpAccessChain %39 %38 %17 %72 %176 = OpLoad %16 %175 %177 = OpSLessThan %61 %174 %176 OpBranchConditional %177 %170 %171 %170 = OpLabel %179 = OpAccessChain %39 %38 %17 %72 %180 = OpLoad %16 %179 OpStore %178 %180 OpBranch %181 %181 = OpLabel OpLoopMerge %183 %184 None OpBranch %185 %185 = OpLabel %186 = OpLoad %16 %178 %187 = OpAccessChain %39 %38 %17 %17 %188 = OpLoad %16 %187 %189 = OpINotEqual %61 %186 %188 OpBranchConditional %189 %182 %183 %182 = OpLabel %190 = OpLoad %26 %28 %191 = OpLoad %7 %9 %192 = OpImageSampleImplicitLod %22 %190 %191 OpStore %24 %192 %193 = OpAccessChain %69 %24 %68 %194 = OpLoad %6 %193 %195 = OpAccessChain %39 %38 %17 %17 %196 = OpLoad %16 %195 %197 = OpConvertSToF %6 %196 %198 = OpAccessChain %39 %38 %17 %17 %199 = OpLoad %16 %198 %200 = OpConvertSToF %6 %199 %201 = OpAccessChain %39 %38 %17 %72 %202 = OpLoad %16 %201 %203 = OpConvertSToF %6 %202 %204 = OpCompositeConstruct %22 %194 %197 %200 %203 OpStore %33 %204 OpBranch %184 %184 = OpLabel %205 = OpLoad %16 %178 %206 = OpISub %16 %205 %72 OpStore %178 %206 OpBranch %181 %183 = OpLabel OpBranch %172 %172 = OpLabel %207 = OpLoad %16 %166 %208 = OpIAdd %16 %207 %72 OpStore %166 %208 OpBranch %169 %171 = OpLabel %210 = OpAccessChain %39 %38 %17 %17 %211 = OpLoad %16 %210 OpStore %209 %211 OpBranch %212 %212 = OpLabel OpLoopMerge %214 %215 None OpBranch %216 %216 = OpLabel %217 = OpLoad %16 %209 %218 = OpAccessChain %39 %38 %17 %72 %219 = OpLoad %16 %218 %220 = OpSLessThan %61 %217 %219 OpBranchConditional %220 %213 %214 %213 = OpLabel %222 = OpAccessChain %39 %38 %17 %17 %223 = OpLoad %16 %222 OpStore %221 %223 OpBranch %224 %224 = OpLabel OpLoopMerge %226 %227 None OpBranch %228 %228 = OpLabel %229 = OpLoad %16 %221 %230 = OpAccessChain %39 %38 %17 %72 %231 = OpLoad %16 %230 %232 = OpINotEqual %61 %229 %231 OpBranchConditional %232 %225 %226 %225 = OpLabel OpBranch %227 %227 = OpLabel %233 = OpLoad %16 %221 %234 = OpIAdd %16 %233 %72 OpStore %221 %234 OpBranch %224 %226 = OpLabel OpBranch %215 %215 = OpLabel %235 = OpLoad %16 %209 %236 = OpIAdd %16 %235 %72 OpStore %209 %236 OpBranch %212 %214 = OpLabel OpBranch %66 %66 = OpLabel OpBranch %63 %65 = OpLabel OpBranch %51 %51 = OpLabel %237 = OpLoad %16 %45 %238 = OpIAdd %16 %237 %72 OpStore %45 %238 OpBranch %48 %50 = OpLabel OpReturn OpFunctionEnd
#include "Config.hpp" namespace acid { Config::Config(std::shared_ptr<IFile> file) : m_file(file), m_values(std::map<std::string, std::shared_ptr<ConfigKey>>()) { } Config::~Config() { } void Config::Load() { m_file->Load(); auto fileMap = m_file->ConfigReadValues(); m_values.clear(); for (auto &fm : fileMap) { m_values.emplace(fm.first, new ConfigKey(fm.second, true)); } } void Config::Update() { // TODO: Implement. // for (auto &value : m_values) // { // value.second.SetValue(value.second.GetGetter()()); // } } void Config::Save() { Update(); m_file->Clear(); for (auto &value : m_values) { m_file->ConfigPushValue(value.first, value.second->GetValue()); } m_file->Save(); } std::shared_ptr<ConfigKey> Config::GetRaw(const std::string &key, const std::string &normal) { if (m_values.find(key) == m_values.end()) { auto configKey = std::make_shared<ConfigKey>(normal, false); m_values.emplace(key, configKey); return configKey; } return m_values.at(key); } void Config::SetRaw(const std::string &key, const std::string &value) { if (m_values.find(key) == m_values.end()) { m_values.emplace(key, std::make_shared<ConfigKey>(value, false)); return; } m_values.at(key) = std::make_shared<ConfigKey>(value); } bool Config::Remove(const std::string &key) { auto it = m_values.find(key); if (it != m_values.end()) { m_values.erase(key); return true; } return false; } }
// Copyright (c) Facebook, Inc. and its affiliates. // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. #include "GenericDrawable.h" #include <Corrade/Containers/ArrayViewStl.h> #include <Corrade/Utility/FormatStl.h> #include <Magnum/Math/Color.h> #include <Magnum/Math/Matrix3.h> #include "esp/scene/SceneNode.h" namespace Mn = Magnum; namespace esp { namespace gfx { GenericDrawable::GenericDrawable(scene::SceneNode& node, Mn::GL::Mesh* mesh, Drawable::Flags& meshAttributeFlags, ShaderManager& shaderManager, const Mn::ResourceKey& lightSetupKey, const Mn::ResourceKey& materialDataKey, DrawableGroup* group /* = nullptr */) : Drawable{node, mesh, DrawableType::Generic, group}, shaderManager_{shaderManager}, lightSetup_{shaderManager.get<LightSetup>(lightSetupKey)}, materialData_{ shaderManager.get<MaterialData, PhongMaterialData>(materialDataKey)} { flags_ = Mn::Shaders::PhongGL::Flag::ObjectId; if (materialData_->textureMatrix != Mn::Matrix3{}) { flags_ |= Mn::Shaders::PhongGL::Flag::TextureTransformation; } if (materialData_->ambientTexture) { flags_ |= Mn::Shaders::PhongGL::Flag::AmbientTexture; } if (materialData_->diffuseTexture) { flags_ |= Mn::Shaders::PhongGL::Flag::DiffuseTexture; } if (materialData_->specularTexture) { flags_ |= Mn::Shaders::PhongGL::Flag::SpecularTexture; } if (materialData_->normalTexture) { if (meshAttributeFlags & Drawable::Flag::HasTangent) { flags_ |= Mn::Shaders::PhongGL::Flag::NormalTexture; if (meshAttributeFlags & Drawable::Flag::HasSeparateBitangent) { flags_ |= Mn::Shaders::PhongGL::Flag::Bitangent; } } else { LOG(WARNING) << "Mesh does not have tangents and Magnum cannot generate " "them yet, ignoring a normal map"; } } if (materialData_->perVertexObjectId) { flags_ |= Mn::Shaders::PhongGL::Flag::InstancedObjectId; } if (meshAttributeFlags & Drawable::Flag::HasVertexColor) { flags_ |= Mn::Shaders::PhongGL::Flag::VertexColor; } // update the shader early here to to avoid doing it during the render loop if (glMeshExists()) { updateShader(); } } void GenericDrawable::setLightSetup(const Mn::ResourceKey& resourceKey) { lightSetup_ = shaderManager_.get<LightSetup>(resourceKey); // update the shader early here to to avoid doing it during the render loop updateShader(); } void GenericDrawable::updateShaderLightingParameters( const Mn::Matrix4& transformationMatrix, Mn::SceneGraph::Camera3D& camera) { const Mn::Matrix4 cameraMatrix = camera.cameraMatrix(); std::vector<Mn::Vector4> lightPositions; lightPositions.reserve(lightSetup_->size()); std::vector<Mn::Color3> lightColors; lightColors.reserve(lightSetup_->size()); std::vector<Mn::Color3> lightSpecularColors; lightSpecularColors.reserve(lightSetup_->size()); constexpr float dummyRange = Mn::Constants::inf(); std::vector<float> lightRanges(lightSetup_->size(), dummyRange); const Mn::Color4 ambientLightColor = getAmbientLightColor(*lightSetup_); for (Mn::UnsignedInt i = 0; i < lightSetup_->size(); ++i) { const auto& lightInfo = (*lightSetup_)[i]; lightPositions.emplace_back(Mn::Vector4(getLightPositionRelativeToCamera( lightInfo, transformationMatrix, cameraMatrix))); const auto& lightColor = (*lightSetup_)[i].color; lightColors.emplace_back(lightColor); // In general, a light's specular color should match its base color. // However, negative lights have zero (black) specular. constexpr Mn::Color3 blackColor(0.0, 0.0, 0.0); bool isNegativeLight = lightColor.x() < 0; lightSpecularColors.emplace_back(isNegativeLight ? blackColor : lightColor); } // See documentation in src/deps/magnum/src/Magnum/Shaders/Phong.h (*shader_) .setAmbientColor(materialData_->ambientColor * ambientLightColor) .setDiffuseColor(materialData_->diffuseColor) .setSpecularColor(materialData_->specularColor) .setShininess(materialData_->shininess) .setLightPositions(lightPositions) .setLightColors(lightColors) .setLightRanges(lightRanges); } void GenericDrawable::draw(const Mn::Matrix4& transformationMatrix, Mn::SceneGraph::Camera3D& camera) { CORRADE_ASSERT(glMeshExists(), "GenericDrawable::draw() : GL mesh doesn't exist", ); updateShader(); updateShaderLightingParameters(transformationMatrix, camera); (*shader_) // e.g., semantic mesh has its own per vertex annotation, which has been // uploaded to GPU so simply pass 0 to the uniform "objectId" in the // fragment shader .setObjectId( static_cast<RenderCamera&>(camera).useDrawableIds() ? drawableId_ : (materialData_->perVertexObjectId ? 0 : node_.getSemanticId())) .setTransformationMatrix(transformationMatrix) .setProjectionMatrix(camera.projectionMatrix()) .setNormalMatrix(transformationMatrix.normalMatrix()); if ((flags_ & Mn::Shaders::PhongGL::Flag::TextureTransformation) && materialData_->textureMatrix != Mn::Matrix3{}) { shader_->setTextureMatrix(materialData_->textureMatrix); } if (flags_ & Mn::Shaders::PhongGL::Flag::AmbientTexture) { shader_->bindAmbientTexture(*(materialData_->ambientTexture)); } if (flags_ & Mn::Shaders::PhongGL::Flag::DiffuseTexture) { shader_->bindDiffuseTexture(*(materialData_->diffuseTexture)); } if (flags_ & Mn::Shaders::PhongGL::Flag::SpecularTexture) { shader_->bindSpecularTexture(*(materialData_->specularTexture)); } if (flags_ & Mn::Shaders::PhongGL::Flag::NormalTexture) { shader_->bindNormalTexture(*(materialData_->normalTexture)); } shader_->draw(getMesh()); } void GenericDrawable::updateShader() { Mn::UnsignedInt lightCount = lightSetup_->size(); if (!shader_ || shader_->lightCount() != lightCount || shader_->flags() != flags_) { // if the number of lights or flags have changed, we need to fetch a // compatible shader shader_ = shaderManager_.get<Mn::GL::AbstractShaderProgram, Mn::Shaders::PhongGL>( getShaderKey(lightCount, flags_)); // if no shader with desired number of lights and flags exists, create one if (!shader_) { shaderManager_.set<Mn::GL::AbstractShaderProgram>( shader_.key(), new Mn::Shaders::PhongGL{flags_, lightCount}, Mn::ResourceDataState::Final, Mn::ResourcePolicy::ReferenceCounted); } CORRADE_INTERNAL_ASSERT(shader_ && shader_->lightCount() == lightCount && shader_->flags() == flags_); } } Mn::ResourceKey GenericDrawable::getShaderKey( Mn::UnsignedInt lightCount, Mn::Shaders::PhongGL::Flags flags) const { return Corrade::Utility::formatString( SHADER_KEY_TEMPLATE, lightCount, static_cast<Mn::Shaders::PhongGL::Flags::UnderlyingType>(flags)); } } // namespace gfx } // namespace esp
; A179432: a(n) = C(2*3^(n-1), n). ; 1,2,15,816,316251,873642672,17743125256857,2739097835911193328,3301626910467952067341626,31698997711344336177849363574320,2460103385023594223069956382123378560008 mov $2,$0 sub $0,1 mov $1,3 pow $1,$0 mul $1,2 bin $1,$2 mov $0,$1
; A064310: Generalized Catalan numbers C(-1; n). ; Submitted by Christian Krause ; 1,1,0,1,-2,6,-18,57,-186,622,-2120,7338,-25724,91144,-325878,1174281,-4260282,15548694,-57048048,210295326,-778483932,2892818244,-10786724388,40347919626,-151355847012,569274150156,-2146336125648,8110508473252,-30711521221376,116518215264492,-442862000693438,1686062250699433,-6429286894263738,24552388991392230,-93891870710425440,359526085719652662,-1378379704593824300,5290709340633314596,-20330047491994213884,78201907647506243758,-301111732041234778316,1160507655117628665252 mov $1,1 mov $3,$0 lpb $3 mov $0,$1 mul $0,2 sub $2,2 sub $3,1 mul $1,$3 add $2,1 div $1,$2 add $4,$1 sub $1,$0 lpe mov $0,$4 add $0,1
; A119707: Number of distinct primes appearing in all partitions of n into prime parts. ; Submitted by Christian Krause ; 0,1,1,1,3,2,4,3,4,4,5,4,6,5,6,6,7,6,8,7,8,8,9,8,9,9,9,9,10,9,11,10,11,11,11,11,12,11,12,12,13,12,14,13,14,14,15,14,15,15,15,15,16,15,16,16,16,16,17,16,18,17,18,18,18,18,19,18,19,19,20,19,21,20,21,21,21,21,22 mov $3,$0 sub $3,1 mov $5,$0 lpb $3 mov $2,$5 seq $2,80339 ; Characteristic function of {1} union {primes}: 1 if n is 1 or a prime, else 0. mov $5,$3 sub $3,1 add $4,$2 sub $5,1 lpe add $5,$4 mov $0,$5
#include "main.h" #include <Eigen/MPRealSupport> #include <Eigen/LU> #include <Eigen/Eigenvalues> #include <sstream> using namespace mpfr; using namespace Eigen; void test_mpreal_support() { // set precision to 256 bits (double has only 53 bits) mpreal::set_default_prec(256); typedef Matrix<mpreal,Eigen::Dynamic,Eigen::Dynamic> MatrixXmp; std::cerr << "epsilon = " << NumTraits<mpreal>::epsilon() << "\n"; std::cerr << "dummy_precision = " << NumTraits<mpreal>::dummy_precision() << "\n"; std::cerr << "highest = " << NumTraits<mpreal>::highest() << "\n"; std::cerr << "lowest = " << NumTraits<mpreal>::lowest() << "\n"; std::cerr << "digits10 = " << NumTraits<mpreal>::digits10() << "\n"; for(int i = 0; i < g_repeat; i++) { int s = Eigen::internal::random<int>(1,100); MatrixXmp A = MatrixXmp::Random(s,s); MatrixXmp B = MatrixXmp::Random(s,s); MatrixXmp S = A.adjoint() * A; MatrixXmp X; // Basic stuffs VERIFY_IS_APPROX(A.real(), A); VERIFY(Eigen::internal::isApprox(A.array().abs2().sum(), A.squaredNorm())); VERIFY_IS_APPROX(A.array().exp(), exp(A.array())); VERIFY_IS_APPROX(A.array().abs2().sqrt(), A.array().abs()); VERIFY_IS_APPROX(A.array().sin(), sin(A.array())); VERIFY_IS_APPROX(A.array().cos(), cos(A.array())); // Cholesky X = S.selfadjointView<Lower>().llt().solve(B); VERIFY_IS_APPROX((S.selfadjointView<Lower>()*X).eval(),B); // partial LU X = A.lu().solve(B); VERIFY_IS_APPROX((A*X).eval(),B); // symmetric eigenvalues SelfAdjointEigenSolver<MatrixXmp> eig(S); VERIFY_IS_EQUAL(eig.info(), Success); VERIFY( (S.selfadjointView<Lower>() * eig.eigenvectors()).isApprox(eig.eigenvectors() * eig.eigenvalues().asDiagonal(), NumTraits<mpreal>::dummy_precision()*1e3) ); } { MatrixXmp A(8,3); A.setRandom(); // test output (interesting things happen in this code) std::stringstream stream; stream << A; } }
; A286665: {0->01}-transform of the Pell word, A171588. ; 0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,0 add $0,1 seq $0,159684 ; Sturmian word: limit S(infinity) where S(0) = 0, S(1) = 0,1 and for n>=1, S(n+1) = S(n)S(n)S(n-1). sub $1,$0 add $1,1 mov $0,$1
; Licensed to the .NET Foundation under one or more agreements. ; The .NET Foundation licenses this file to you under the MIT license. ; ==++== ; ; ; ==--== ; *********************************************************************** ; File: JitHelpers_Fast.asm, see jithelp.asm for history ; ; Notes: routinues which we believe to be on the hot path for managed ; code in most scenarios. ; *********************************************************************** include AsmMacros.inc include asmconstants.inc ; Min amount of stack space that a nested function should allocate. MIN_SIZE equ 28h EXTERN g_ephemeral_low:QWORD EXTERN g_ephemeral_high:QWORD EXTERN g_lowest_address:QWORD EXTERN g_highest_address:QWORD EXTERN g_card_table:QWORD ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES EXTERN g_card_bundle_table:QWORD endif ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP EXTERN g_sw_ww_table:QWORD EXTERN g_sw_ww_enabled_for_gc_heap:BYTE endif ifdef WRITE_BARRIER_CHECK ; Those global variables are always defined, but should be 0 for Server GC g_GCShadow TEXTEQU <?g_GCShadow@@3PEAEEA> g_GCShadowEnd TEXTEQU <?g_GCShadowEnd@@3PEAEEA> EXTERN g_GCShadow:QWORD EXTERN g_GCShadowEnd:QWORD endif INVALIDGCVALUE equ 0CCCCCCCDh ifdef _DEBUG extern JIT_WriteBarrier_Debug:proc endif extern JIT_InternalThrow:proc ; Mark start of the code region that we patch at runtime LEAF_ENTRY JIT_PatchedCodeStart, _TEXT ret LEAF_END JIT_PatchedCodeStart, _TEXT ; This is used by the mechanism to hold either the JIT_WriteBarrier_PreGrow ; or JIT_WriteBarrier_PostGrow code (depending on the state of the GC). It _WILL_ ; change at runtime as the GC changes. Initially it should simply be a copy of the ; larger of the two functions (JIT_WriteBarrier_PostGrow) to ensure we have created ; enough space to copy that code in. LEAF_ENTRY JIT_WriteBarrier, _TEXT align 16 ifdef _DEBUG ; In debug builds, this just contains jump to the debug version of the write barrier by default mov rax, JIT_WriteBarrier_Debug jmp rax endif ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP ; JIT_WriteBarrier_WriteWatch_PostGrow64 ; Regarding patchable constants: ; - 64-bit constants have to be loaded into a register ; - The constants have to be aligned to 8 bytes so that they can be patched easily ; - The constant loads have been located to minimize NOP padding required to align the constants ; - Using different registers for successive constant loads helps pipeline better. Should we decide to use a special ; non-volatile calling convention, this should be changed to use just one register. ; Do the move into the GC . It is correct to take an AV here, the EH code ; figures out that this came from a WriteBarrier and correctly maps it back ; to the managed method which called the WriteBarrier (see setup in ; InitializeExceptionHandling, vm\exceptionhandling.cpp). mov [rcx], rdx ; Update the write watch table if necessary mov rax, rcx mov r8, 0F0F0F0F0F0F0F0F0h shr rax, 0Ch ; SoftwareWriteWatch::AddressToTableByteIndexShift NOP_2_BYTE ; padding for alignment of constant mov r9, 0F0F0F0F0F0F0F0F0h add rax, r8 cmp byte ptr [rax], 0h jne CheckCardTable mov byte ptr [rax], 0FFh NOP_3_BYTE ; padding for alignment of constant ; Check the lower and upper ephemeral region bounds CheckCardTable: cmp rdx, r9 jb Exit NOP_3_BYTE ; padding for alignment of constant mov r8, 0F0F0F0F0F0F0F0F0h cmp rdx, r8 jae Exit nop ; padding for alignment of constant mov rax, 0F0F0F0F0F0F0F0F0h ; Touch the card table entry, if not already dirty. shr rcx, 0Bh cmp byte ptr [rcx + rax], 0FFh jne UpdateCardTable REPRET UpdateCardTable: mov byte ptr [rcx + rax], 0FFh ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES mov rax, 0F0F0F0F0F0F0F0F0h shr rcx, 0Ah cmp byte ptr [rcx + rax], 0FFh jne UpdateCardBundleTable REPRET UpdateCardBundleTable: mov byte ptr [rcx + rax], 0FFh endif ret align 16 Exit: REPRET else ; JIT_WriteBarrier_PostGrow64 ; Do the move into the GC . It is correct to take an AV here, the EH code ; figures out that this came from a WriteBarrier and correctly maps it back ; to the managed method which called the WriteBarrier (see setup in ; InitializeExceptionHandling, vm\exceptionhandling.cpp). mov [rcx], rdx NOP_3_BYTE ; padding for alignment of constant ; Can't compare a 64 bit immediate, so we have to move them into a ; register. Values of these immediates will be patched at runtime. ; By using two registers we can pipeline better. Should we decide to use ; a special non-volatile calling convention, this should be changed to ; just one. mov rax, 0F0F0F0F0F0F0F0F0h ; Check the lower and upper ephemeral region bounds cmp rdx, rax jb Exit nop ; padding for alignment of constant mov r8, 0F0F0F0F0F0F0F0F0h cmp rdx, r8 jae Exit nop ; padding for alignment of constant mov rax, 0F0F0F0F0F0F0F0F0h ; Touch the card table entry, if not already dirty. shr rcx, 0Bh cmp byte ptr [rcx + rax], 0FFh jne UpdateCardTable REPRET UpdateCardTable: mov byte ptr [rcx + rax], 0FFh ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES mov rax, 0F0F0F0F0F0F0F0F0h shr rcx, 0Ah cmp byte ptr [rcx + rax], 0FFh jne UpdateCardBundleTable REPRET UpdateCardBundleTable: mov byte ptr [rcx + rax], 0FFh endif ret align 16 Exit: REPRET endif ; make sure this is bigger than any of the others align 16 nop LEAF_END_MARKED JIT_WriteBarrier, _TEXT ; Mark start of the code region that we patch at runtime LEAF_ENTRY JIT_PatchedCodeLast, _TEXT ret LEAF_END JIT_PatchedCodeLast, _TEXT ; JIT_ByRefWriteBarrier has weird symantics, see usage in StubLinkerX86.cpp ; ; Entry: ; RDI - address of ref-field (assigned to) ; RSI - address of the data (source) ; RCX is trashed ; RAX is trashed when FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP is defined ; Exit: ; RDI, RSI are incremented by SIZEOF(LPVOID) LEAF_ENTRY JIT_ByRefWriteBarrier, _TEXT mov rcx, [rsi] ; If !WRITE_BARRIER_CHECK do the write first, otherwise we might have to do some ShadowGC stuff ifndef WRITE_BARRIER_CHECK ; rcx is [rsi] mov [rdi], rcx endif ; When WRITE_BARRIER_CHECK is defined _NotInHeap will write the reference ; but if it isn't then it will just return. ; ; See if this is in GCHeap cmp rdi, [g_lowest_address] jb NotInHeap cmp rdi, [g_highest_address] jnb NotInHeap ifdef WRITE_BARRIER_CHECK ; we can only trash rcx in this function so in _DEBUG we need to save ; some scratch registers. push r10 push r11 push rax ; **ALSO update the shadow GC heap if that is enabled** ; Do not perform the work if g_GCShadow is 0 cmp g_GCShadow, 0 je NoShadow ; If we end up outside of the heap don't corrupt random memory mov r10, rdi sub r10, [g_lowest_address] jb NoShadow ; Check that our adjusted destination is somewhere in the shadow gc add r10, [g_GCShadow] cmp r10, [g_GCShadowEnd] ja NoShadow ; Write ref into real GC mov [rdi], rcx ; Write ref into shadow GC mov [r10], rcx ; Ensure that the write to the shadow heap occurs before the read from ; the GC heap so that race conditions are caught by INVALIDGCVALUE mfence ; Check that GC/ShadowGC values match mov r11, [rdi] mov rax, [r10] cmp rax, r11 je DoneShadow mov r11, INVALIDGCVALUE mov [r10], r11 jmp DoneShadow ; If we don't have a shadow GC we won't have done the write yet NoShadow: mov [rdi], rcx ; If we had a shadow GC then we already wrote to the real GC at the same time ; as the shadow GC so we want to jump over the real write immediately above. ; Additionally we know for sure that we are inside the heap and therefore don't ; need to replicate the above checks. DoneShadow: pop rax pop r11 pop r10 endif ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP ; Update the write watch table if necessary cmp byte ptr [g_sw_ww_enabled_for_gc_heap], 0h je CheckCardTable mov rax, rdi shr rax, 0Ch ; SoftwareWriteWatch::AddressToTableByteIndexShift add rax, qword ptr [g_sw_ww_table] cmp byte ptr [rax], 0h jne CheckCardTable mov byte ptr [rax], 0FFh endif ; See if we can just quick out CheckCardTable: cmp rcx, [g_ephemeral_low] jb Exit cmp rcx, [g_ephemeral_high] jnb Exit ; move current rdi value into rcx and then increment the pointers mov rcx, rdi add rsi, 8h add rdi, 8h ; Check if we need to update the card table ; Calc pCardByte shr rcx, 0Bh add rcx, [g_card_table] ; Check if this card is dirty cmp byte ptr [rcx], 0FFh jne UpdateCardTable REPRET UpdateCardTable: mov byte ptr [rcx], 0FFh ifdef FEATURE_MANUALLY_MANAGED_CARD_BUNDLES ; check if we need to update the card bundle table ; restore destination address from rdi - rdi has been incremented by 8 already lea rcx, [rdi-8] shr rcx, 15h add rcx, [g_card_bundle_table] cmp byte ptr [rcx], 0FFh jne UpdateCardBundleTable REPRET UpdateCardBundleTable: mov byte ptr [rcx], 0FFh endif ret align 16 NotInHeap: ; If WRITE_BARRIER_CHECK then we won't have already done the mov and should do it here ; If !WRITE_BARRIER_CHECK we want _NotInHeap and _Leave to be the same and have both ; 16 byte aligned. ifdef WRITE_BARRIER_CHECK ; rcx is [rsi] mov [rdi], rcx endif Exit: ; Increment the pointers before leaving add rdi, 8h add rsi, 8h ret LEAF_END_MARKED JIT_ByRefWriteBarrier, _TEXT Section segment para 'DATA' align 16 public JIT_WriteBarrier_Loc JIT_WriteBarrier_Loc: dq 0 LEAF_ENTRY JIT_WriteBarrier_Callable, _TEXT ; JIT_WriteBarrier(Object** dst, Object* src) jmp QWORD PTR [JIT_WriteBarrier_Loc] LEAF_END JIT_WriteBarrier_Callable, _TEXT ; There is an even more optimized version of these helpers possible which takes ; advantage of knowledge of which way the ephemeral heap is growing to only do 1/2 ; that check (this is more significant in the JIT_WriteBarrier case). ; ; Additionally we can look into providing helpers which will take the src/dest from ; specific registers (like x86) which _could_ (??) make for easier register allocation ; for the JIT64, however it might lead to having to have some nasty code that treats ; these guys really special like... :(. ; ; Version that does the move, checks whether or not it's in the GC and whether or not ; it needs to have it's card updated ; ; void JIT_CheckedWriteBarrier(Object** dst, Object* src) LEAF_ENTRY JIT_CheckedWriteBarrier, _TEXT ; When WRITE_BARRIER_CHECK is defined _NotInHeap will write the reference ; but if it isn't then it will just return. ; ; See if this is in GCHeap cmp rcx, [g_lowest_address] jb NotInHeap cmp rcx, [g_highest_address] jnb NotInHeap jmp QWORD PTR [JIT_WriteBarrier_Loc] NotInHeap: ; See comment above about possible AV mov [rcx], rdx ret LEAF_END_MARKED JIT_CheckedWriteBarrier, _TEXT ; The following helper will access ("probe") a word on each page of the stack ; starting with the page right beneath rsp down to the one pointed to by r11. ; The procedure is needed to make sure that the "guard" page is pushed down below the allocated stack frame. ; The call to the helper will be emitted by JIT in the function/funclet prolog when large (larger than 0x3000 bytes) stack frame is required. ; ; NOTE: this helper will NOT modify a value of rsp and can be defined as a leaf function. PROBE_PAGE_SIZE equ 1000h LEAF_ENTRY JIT_StackProbe, _TEXT ; On entry: ; r11 - points to the lowest address on the stack frame being allocated (i.e. [InitialSp - FrameSize]) ; rsp - points to some byte on the last probed page ; On exit: ; rax - is not preserved ; r11 - is preserved ; ; NOTE: this helper will probe at least one page below the one pointed by rsp. mov rax, rsp ; rax points to some byte on the last probed page and rax, -PROBE_PAGE_SIZE ; rax points to the **lowest address** on the last probed page ; This is done to make the following loop end condition simpler. ProbeLoop: sub rax, PROBE_PAGE_SIZE ; rax points to the lowest address of the **next page** to probe test dword ptr [rax], eax ; rax points to the lowest address on the **last probed** page cmp rax, r11 jg ProbeLoop ; If (rax > r11), then we need to probe at least one more page. ret LEAF_END_MARKED JIT_StackProbe, _TEXT end
/* * Copyright (c) 2020-2022 Gustavo Valiente gustavo.valiente@protonmail.com * zlib License, see LICENSE file. */ #include "bf_game_hero_bomb.h" #include "bn_keypad.h" #include "bn_blending.h" #include "bn_sound_items.h" #include "bn_regular_bg_builder.h" #include "bn_regular_bg_items_hero_bomb.h" #include "bf_constants.h" #include "bf_game_hero.h" #include "bf_game_intro.h" #include "bf_game_enemies.h" #include "bf_wave_generator.h" #include "bf_game_boss_intro.h" #include "bf_game_background.h" #include "bf_game_enemy_bullets.h" #include "bf_game_rumble_manager.h" namespace bf::game { namespace { constexpr int open_frames = 50; constexpr int close_frames = 130; constexpr bn::array<bn::fixed, bn::display::height()> wave_hbe_deltas = []{ bn::array<bn::fixed, bn::display::height()> result; wave_generator().generate(result); return result; }(); } void hero_bomb::update(const intro& intro, const boss_intro& boss_intro, const bn::camera_ptr& camera, hero& hero, enemies& enemies, enemy_bullets& enemy_bullets, background& background, rumble_manager& rumble_manager) { switch(_status) { case status_type::INACTIVE: if(hero.alive() && ! intro.active() && ! boss_intro.active() && ! enemies.boss_dying() && bn::keypad::a_pressed()) { if(hero.throw_bomb()) { const bn::fixed_point& hero_position = hero.weapon_position(); _center = bn::point(hero_position.x().right_shift_integer(), hero_position.y().right_shift_integer()); bn::regular_bg_builder builder(bn::regular_bg_items::hero_bomb); builder.set_priority(1); builder.set_blending_enabled(true); bn::regular_bg_ptr bg = builder.release_build(); bn::window::outside().set_show_bg(bg, false); _bg_move_action.emplace(bg, bn::fixed(-0.5), 4); bn::rect_window internal_window = bn::rect_window::internal(); internal_window.set_boundaries(hero_position, hero_position); internal_window.set_show_blending(false); internal_window.set_camera(camera); _move_window_top_action.emplace(internal_window, -4); _move_window_bottom_action.emplace(internal_window, 4); _circle_generator.set_origin_y(hero_position.y()); _circle_generator.set_radius(0); _circle_generator.generate(_circle_hbe_deltas); _circle_hbe = bn::rect_window_boundaries_hbe_ptr::create_horizontal( internal_window, _circle_hbe_deltas); _wave_hbe = bn::regular_bg_position_hbe_ptr::create_horizontal(move(bg), wave_hbe_deltas); background.show_bomb_open(open_frames); bn::sound_items::explosion_2.play(); rumble_manager.set_enabled(true); _status = status_type::OPEN; _counter = open_frames; _flame_sound_counter = 0; } else { bn::sound_items::no_ammo.play(); } } break; case status_type::OPEN: _bg_move_action->update(); if(_counter) { --_counter; _move_window_top_action->update(); _move_window_bottom_action->update(); bn::fixed fixed_radius = _circle_generator.radius() + 4; int integer_radius = fixed_radius.right_shift_integer(); enemies.check_hero_bomb(_center, integer_radius * integer_radius, camera); _circle_generator.set_radius(fixed_radius); _circle_generator.generate(_circle_hbe_deltas); _circle_hbe->reload_deltas_ref(); _play_flame_sound(); } else { _move_window_top_action.reset(); _move_window_bottom_action.reset(); bn::rect_window internal_window = bn::rect_window::internal(); internal_window.set_boundaries(-1000, -1000, 1000, 1000); _circle_hbe.reset(); enemy_bullets.clear(); internal_window.set_show_blending(true); bn::blending::set_transparency_alpha(1); _intensity_blending_action.emplace(30, bn::fixed(0.5)); background.show_bomb_close(close_frames - 30); _status = status_type::CLOSE; _counter = close_frames; } break; case status_type::CLOSE: if(_bg_move_action) { _bg_move_action->update(); } if(_transparency_blending_action) { _transparency_blending_action->update(); if(_transparency_blending_action->done()) { _transparency_blending_action.reset(); } } if(_intensity_blending_action) { _intensity_blending_action->update(); if(_intensity_blending_action->done()) { _intensity_blending_action.reset(); } } if(_counter) { --_counter; if(_counter == close_frames - 30) { _transparency_blending_action.emplace(close_frames - 60, 0); _intensity_blending_action.emplace(30, 0); } else if(_counter == close_frames - 60) { background.hide_bomb_close(close_frames - 90); } else if(_counter == 60) { rumble_manager.set_enabled(false); } else if(_counter == 30) { bn::rect_window internal_window = bn::rect_window::internal(); internal_window.set_boundaries(0, 0, 0, 0); internal_window.remove_camera(); background.show_top(30); _bg_move_action.reset(); _wave_hbe.reset(); } if(_counter > 40) { _play_flame_sound(); } } else { _status = status_type::INACTIVE; } break; default: BN_ERROR("Invalid status: ", int(_status)); break; } } void hero_bomb::_play_flame_sound() { ++_flame_sound_counter; if(_flame_sound_counter > 16 && _flame_sound_counter % 16 == 0) { bn::sound_items::flame_thrower.play(); } } }
#include <chrono> #include <iostream> int main() { // create array const int size = 10000; static int x[size][size]; auto t1 = std::chrono::high_resolution_clock::now(); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { x[i][j] = i + j; // std::cout << &x[j][i] << ": i=" << i << ", j=" << j << std::endl; } } // print execution time to console auto t2 = std::chrono::high_resolution_clock::now(); // stop time measurement auto duration = std::chrono::duration_cast<std::chrono::microseconds>(t2 - t1).count(); std::cout << "Execution time: " << duration << " microseconds" << std::endl; auto t3 = std::chrono::high_resolution_clock::now(); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { x[j][i] = i + j; // std::cout << &x[j][i] << ": i=" << i << ", j=" << j << std::endl; } } // print execution time to console auto t4 = std::chrono::high_resolution_clock::now(); // stop time measurement duration = std::chrono::duration_cast<std::chrono::microseconds>(t4 - t3).count(); std::cout << "Execution time: " << duration << " microseconds" << std::endl; return 0; }
; Assembly Level Program 1b ; Read the status of eight input bits from the Logic Controller Interface and display 'FF' if it is the parity of the input read is even; otherwise display 00. .model SMALL .data PA EQU 0E400h PB EQU 0E401h PC EQU 0E402h CR EQU 0E403h CW dB 82h M1 dB 10, 13, 'Select an 8-bit Number from the Logic Controller Interface...$' .code ; Initialize Data Segment MOV AX, @DATA MOV DS, AX ; Set Control Word Format MOV DX, CR MOV AL, CW OUT DX, AL ; Display Message LEA DX, M1 MOV AH, 09h INT 21h ; Take Input from Logic Controller Interface MOV DX, PB IN AL, DX ; Dummy Operation to Set Flags OR AL, AL JPO OddParity ; IF Even Parity MOV DX, PA MOV AL, 0FFh OUT DX, AL JMP Exit OddParity: ; IF Odd Parity MOV DX, PA MOV AL, 00h OUT DX, AL Exit: ; Terminate the Program MOV AH, 4Ch INT 21h END
; A258059: Let n = Sum_{i=0..k} d_i*4^i be the base-4 expansion of n, with 0 <= d_i < 4. Then a(n) = minimal i such that d_i is not 1, or k+1 if there is no such i. ; 1,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,2,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,4,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0 mul $0,3 add $0,4 lpb $0 dif $0,4 add $1,1 lpe mov $0,$1
; The MIT License ; Copyright (c) ocanty <git@ocanty.com> ; Permission is hereby granted, free of charge, to any person obtaining a copy ; of this software and associated documentation files (the "Software"), to deal ; in the Software without restriction, including without limitation the rights ; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ; copies of the Software, and to permit persons to whom the Software is ; furnished to do so, subject to the following conditions: ; The above copyright notice and this permission notice shall be included in ; all copies or substantial portions of the Software. ; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ; THE SOFTWARE. ; Build with: ; yasm -f elf64 rpn86.asm -o rpn86.o ; gcc -m64 rpn86.o -o rpn86 -fno-pie -fno-plt -no-pie; ; ./rpn86 BITS 64 global main extern printf extern read extern strtol extern exit ; Util - Begin section .text die: ; Kill the program with return value -1 mov rdi, -1 call exit ret ; Not like this is needed print: ; Use printf (with ABI stack setup) xor rax, rax ; not using floats / xmm registers sub rsp, 8 ; Stack on C API calls needs to be 16bit aligned call printf add rsp, 8 ret ; Util - End ; RPN Stack Implementation - Begin section .data rpn_stack_max_elements: equ 1024 rpn_stack_sz: equ 8192 ; Total stack size in bytes section .bss rpn_stack: resb rpn_stack_sz rpn_stack_n: dq 0 ; Stack ptr section .data str_rpn_stack_overflow: db "RPN stack overflow: sp - %i", 10, 0 str_rpn_stack_underflow: db "RPN stack underflow: sp - %i", 10, 0 ; pushed: ; db "pushed %i", 10, 0 ; popped: ; db "popped %i", 10, 0 section .text rpn_stack_push: ; Pushes a value onto the RPN stack ; [in] rdi - value ; [mangles] rdi, rax ; Get stack ptr, if it's at its max size -> error ; mov rdi, pushed ; call print ; push rdi ; lea rdi, [pushed] ; mov rsi, rax ; call print ; pop rdi mov rax, [rpn_stack_n] ; Get stack ptr cmp rax, rpn_stack_sz ; Compare to stack size jge rpn_stack_push.fail ; stack overflow if equal or greater jmp rpn_stack_push.good ; normally its good .fail: mov rdi, str_rpn_stack_overflow mov rsi, rpn_stack_sz call print jmp die ret .good: lea rbx, [rpn_stack+rax] mov [rbx], rdi ; store value at stack ptr add rax, 8 ; increment stack ptr mov [rpn_stack_n], rax ; store and return ret rpn_stack_pop: ; Removes a value on the RPN stack ; [out] rax - value ; [mangles] rdi, rax, rbx ; Get stack ptr, if it's at its lowest size -> error mov rax, [rpn_stack_n] cmp rax, 0 jle rpn_stack_pop.fail jmp rpn_stack_pop.good .fail: mov rdi, str_rpn_stack_underflow mov rsi, rax call print jmp die ret .good: sub rax, 8 ; decrement stack ptr mov [rpn_stack_n], rax ; store stack ptr lea rbx, [rpn_stack+rax] ; read val on stack mov rax, [rbx] ; push rax ; lea rdi, [popped] ; mov rsi, rax ; call print ; pop rax ret section .data str_invalid_expr: db "Invalid expression.", 10, 0 str_evaluating: db "Evaluating: %s", 10, 0 str_got_result: db "Result is %i!", 10, 0 section .text rpn_evaluate: ; Evaluate an RPN expression ; Will exit program on error ; [in] rdi - string addr ; [out] rax - value .str_ptr: equ 0 ; offset for string pointer enter 16, 0 ; stack space for string pointer mov [rsp + .str_ptr], rdi ; load string pointer into offset ptr jmp .process_token .increment_str_ptr_and_process_token: mov rbx, [rsp + .str_ptr] inc rbx mov [rsp + .str_ptr], rbx jmp .process_token .process_token: mov rbx, [rsp + .str_ptr] xor rax, rax mov al, byte [rbx] cmp al, 0 je .calculate_result cmp al, ' ' je .increment_str_ptr_and_process_token cmp al, 10 je .increment_str_ptr_and_process_token cmp al, '+' ; check for operands je .got_plus cmp al, '-' je .got_minus cmp al, '*' je .got_multiply cmp al, '/' je .got_divide jmp .check_number ; not operands, check for numbers .got_plus: ; operand 2 call rpn_stack_pop push rax ; operand 1 call rpn_stack_pop pop rbx add rax, rbx mov rdi, rax call rpn_stack_push jmp .increment_str_ptr_and_process_token .got_minus: ; operand 2 call rpn_stack_pop push rax ; operand 1 call rpn_stack_pop pop rbx sub rax, rbx mov rdi, rax call rpn_stack_push jmp .increment_str_ptr_and_process_token .got_multiply: ; operand 2 call rpn_stack_pop push rax ; operand 1 call rpn_stack_pop pop rbx xor rdx, rdx ; clear dividend mul rbx mov rdi, rax call rpn_stack_push jmp .increment_str_ptr_and_process_token .got_divide: ; operand 2 call rpn_stack_pop push rax ; operand 1 call rpn_stack_pop pop rbx xor rdx, rdx ; clear dividend div rbx mov rdi, rax call rpn_stack_push jmp .increment_str_ptr_and_process_token .check_number: ; check if digit is greater/equal to 0 cmp al, '0' jge .maybe_number jmp .got_invalid ; .maybe_number: ; check if digit less than/equal to 9 cmp al, '9' jle .got_number jmp .got_invalid .got_number: ; extract number and push to RPN stack ; long int strtol (const char* str, char** endptr, int base); mov rdi, [rsp + .str_ptr] lea rsi, [rsp + .str_ptr] mov rdx, 10 ; add rsp, 16 ; 16-bit stack alignment, not needed here call strtol ; sub rsp, 16 mov rdi, rax call rpn_stack_push jmp .process_token .got_invalid: mov rdi, str_invalid_expr call print jmp die .calculate_result: call rpn_stack_pop lea rdi, [str_got_result] mov rsi, rax call print leave ret ; RPN Stack Implementation - End ; Entrypoint - Begin section .data str_ask_for_expr: db "Enter a Reverse Polish notation expression: ", 10, 0 section .bss str_expr: resb 1024 section .text main: enter 0, 0 mov rdi, str_ask_for_expr call print lea rsi, [str_expr] ; put the string they supply into a stack var mov rdx, 1024 mov rdi, 0 xor rax, rax ; not using floats ; add rsp, 16 ; 16-bit alignment for C ABI call read ;sub rsp, 16 lea rdi, [str_expr] call rpn_evaluate leave ret ; Entrypoint - End
// Copyright (c) 2011-2015 The Bitcoin Core developers // Copyright (c) 2014-2017 The Dash Core developers // Copyright (c) 2018 The Absolute Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "askpassphrasedialog.h" #include "ui_askpassphrasedialog.h" #include "guiconstants.h" #include "walletmodel.h" #include "support/allocators/secure.h" #include <QKeyEvent> #include <QMessageBox> #include <QPushButton> AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : QDialog(parent), ui(new Ui::AskPassphraseDialog), mode(mode), model(0), fCapsLock(false) { ui->setupUi(this); ui->passEdit1->setMinimumSize(ui->passEdit1->sizeHint()); ui->passEdit2->setMinimumSize(ui->passEdit2->sizeHint()); ui->passEdit3->setMinimumSize(ui->passEdit3->sizeHint()); ui->passEdit1->setMaxLength(MAX_PASSPHRASE_SIZE); ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE); ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE); // Setup Caps Lock detection. ui->passEdit1->installEventFilter(this); ui->passEdit2->installEventFilter(this); ui->passEdit3->installEventFilter(this); switch(mode) { case Encrypt: // Ask passphrase x2 ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>.")); ui->passLabel1->hide(); ui->passEdit1->hide(); setWindowTitle(tr("Encrypt wallet")); break; case UnlockMixing: ui->mixingOnlyCheckBox->show(); ui->mixingOnlyCheckBox->setChecked(true); case Unlock: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Unlock wallet")); break; case Decrypt: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet.")); ui->passLabel2->hide(); ui->passEdit2->hide(); ui->passLabel3->hide(); ui->passEdit3->hide(); setWindowTitle(tr("Decrypt wallet")); break; case ChangePass: // Ask old passphrase + new passphrase x2 setWindowTitle(tr("Change passphrase")); ui->warningLabel->setText(tr("Enter the old passphrase and new passphrase to the wallet.")); break; } textChanged(); connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged())); } AskPassphraseDialog::~AskPassphraseDialog() { secureClearPassFields(); delete ui; } void AskPassphraseDialog::setModel(WalletModel *model) { this->model = model; } void AskPassphraseDialog::accept() { SecureString oldpass, newpass1, newpass2; if(!model) return; oldpass.reserve(MAX_PASSPHRASE_SIZE); newpass1.reserve(MAX_PASSPHRASE_SIZE); newpass2.reserve(MAX_PASSPHRASE_SIZE); // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::string) // Alternately, find a way to make this input mlock()'d to begin with. oldpass.assign(ui->passEdit1->text().toStdString().c_str()); newpass1.assign(ui->passEdit2->text().toStdString().c_str()); newpass2.assign(ui->passEdit3->text().toStdString().c_str()); secureClearPassFields(); switch(mode) { case Encrypt: { if(newpass1.empty() || newpass2.empty()) { // Cannot encrypt with empty passphrase break; } QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wallet encryption"), tr("Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR ABS</b>!") + "<br><br>" + tr("Are you sure you wish to encrypt your wallet?"), QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Cancel); if(retval == QMessageBox::Yes) { if(newpass1 == newpass2) { if(model->setWalletEncrypted(true, newpass1)) { QMessageBox::warning(this, tr("Wallet encrypted"), "<qt>" + tr("Absolute Core will close now to finish the encryption process. " "Remember that encrypting your wallet cannot fully protect " "your absolutes from being stolen by malware infecting your computer.") + "<br><br><b>" + tr("IMPORTANT: Any previous backups you have made of your wallet file " "should be replaced with the newly generated, encrypted wallet file. " "For security reasons, previous backups of the unencrypted wallet file " "will become useless as soon as you start using the new, encrypted wallet.") + "</b></qt>"); QApplication::quit(); } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("Wallet encryption failed due to an internal error. Your wallet was not encrypted.")); } QDialog::accept(); // Success } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The supplied passphrases do not match.")); } } else { QDialog::reject(); // Cancelled } } break; case UnlockMixing: case Unlock: if(!model->setWalletLocked(false, oldpass, ui->mixingOnlyCheckBox->isChecked())) { QMessageBox::critical(this, tr("Wallet unlock failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } else { QDialog::accept(); // Success } break; case Decrypt: if(!model->setWalletEncrypted(false, oldpass)) { QMessageBox::critical(this, tr("Wallet decryption failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } else { QDialog::accept(); // Success } break; case ChangePass: if(newpass1 == newpass2) { if(model->changePassphrase(oldpass, newpass1)) { QMessageBox::information(this, tr("Wallet encrypted"), tr("Wallet passphrase was successfully changed.")); QDialog::accept(); // Success } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); } } else { QMessageBox::critical(this, tr("Wallet encryption failed"), tr("The supplied passphrases do not match.")); } break; } } void AskPassphraseDialog::textChanged() { // Validate input, set Ok button to enabled when acceptable bool acceptable = false; switch(mode) { case Encrypt: // New passphrase x2 acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); break; case UnlockMixing: // Old passphrase x1 case Unlock: // Old passphrase x1 case Decrypt: acceptable = !ui->passEdit1->text().isEmpty(); break; case ChangePass: // Old passphrase x1, new passphrase x2 acceptable = !ui->passEdit1->text().isEmpty() && !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); break; } ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable); } bool AskPassphraseDialog::event(QEvent *event) { // Detect Caps Lock key press. if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast<QKeyEvent *>(event); if (ke->key() == Qt::Key_CapsLock) { fCapsLock = !fCapsLock; } if (fCapsLock) { ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); } else { ui->capsLabel->clear(); } } return QWidget::event(event); } bool AskPassphraseDialog::eventFilter(QObject *object, QEvent *event) { /* Detect Caps Lock. * There is no good OS-independent way to check a key state in Qt, but we * can detect Caps Lock by checking for the following condition: * Shift key is down and the result is a lower case character, or * Shift key is not down and the result is an upper case character. */ if (event->type() == QEvent::KeyPress) { QKeyEvent *ke = static_cast<QKeyEvent *>(event); QString str = ke->text(); if (str.length() != 0) { const QChar *psz = str.unicode(); bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0; if ((fShift && *psz >= 'a' && *psz <= 'z') || (!fShift && *psz >= 'A' && *psz <= 'Z')) { fCapsLock = true; ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); } else if (psz->isLetter()) { fCapsLock = false; ui->capsLabel->clear(); } } } return QDialog::eventFilter(object, event); } static void SecureClearQLineEdit(QLineEdit* edit) { // Attempt to overwrite text so that they do not linger around in memory edit->setText(QString(" ").repeated(edit->text().size())); edit->clear(); } void AskPassphraseDialog::secureClearPassFields() { SecureClearQLineEdit(ui->passEdit1); SecureClearQLineEdit(ui->passEdit2); SecureClearQLineEdit(ui->passEdit3); }
; A263449: Permutation of the natural numbers: [4k+1, 4k+4, 4k+3, 4k+2, ...]. ; 1,4,3,2,5,8,7,6,9,12,11,10,13,16,15,14,17,20,19,18,21,24,23,22,25,28,27,26,29,32,31,30,33,36,35,34,37,40,39,38,41,44,43,42,45,48,47,46,49,52,51,50,53,56,55,54,57,60,59,58,61,64,63,62,65,68,67,66,69,72,71,70,73,76,75,74,77,80,79,78,81,84,83,82,85,88,87,86,89,92,91,90,93,96,95,94,97,100,99,98 mov $2,$0 mov $0,4 lpb $0 add $2,1 gcd $0,$2 add $1,1 lpe add $2,1 add $1,$2 sub $1,2 mov $0,$1
; A070388: a(n) = 5^n mod 42. ; 1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41,37,17,1,5,25,41 mov $1,1 mov $2,$0 lpb $2 mul $1,5 mod $1,42 sub $2,1 lpe mov $0,$1
.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_A_ht+0x1402c, %rsi lea addresses_WT_ht+0x1b5a6, %rdi nop nop nop nop add %r13, %r13 mov $60, %rcx rep movsq nop nop nop nop xor %rdx, %rdx lea addresses_A_ht+0x6a56, %r14 nop nop nop nop nop and $38773, %rsi mov $0x6162636465666768, %rdi movq %rdi, %xmm5 and $0xffffffffffffffc0, %r14 vmovntdq %ymm5, (%r14) nop nop nop nop inc %rsi lea addresses_D_ht+0x1b856, %r14 nop nop nop dec %r10 mov $0x6162636465666768, %rdx movq %rdx, %xmm5 and $0xffffffffffffffc0, %r14 vmovaps %ymm5, (%r14) nop nop nop nop nop sub $13249, %rdx lea addresses_UC_ht+0x7456, %rsi lea addresses_WC_ht+0x1653a, %rdi nop nop cmp $45221, %rax mov $49, %rcx rep movsb nop add %rax, %rax 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 %r10 push %r12 push %r14 push %r8 push %rax push %rsi // Store mov $0x956, %r10 nop nop inc %r14 movw $0x5152, (%r10) nop dec %rax // Store lea addresses_RW+0xcc56, %r8 nop nop nop nop dec %r12 movw $0x5152, (%r8) nop nop nop nop and %r14, %r14 // Faulty Load lea addresses_normal+0xd456, %rsi nop nop nop nop cmp $4916, %r14 mov (%rsi), %r12w lea oracles, %r14 and $0xff, %r12 shlq $12, %r12 mov (%r14,%r12,1), %r12 pop %rsi pop %rax pop %r8 pop %r14 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 4, 'type': 'addresses_normal', 'congruent': 0}} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 2, 'type': 'addresses_P', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_RW', 'congruent': 7}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 8}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 32, 'type': 'addresses_D_ht', 'congruent': 9}, 'OP': 'STOR'} {'dst': {'same': True, 'congruent': 1, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}} {'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 */
#include<bits/stdc++.h> using namespace std; struct trie//creating structure name trie { struct trie* m[26];//creating mapping for the 26 small latters alphabet int end=0;//0 means not a leaf node and 1 means it is a leaf node }; struct trie * BuildtrieTree(struct trie * root,string s, int start, int size){ if(start==size&&root==NULL){//cheking if this is last char of string and that node does not exist already struct trie *temp; temp=(struct trie*)malloc(sizeof(struct trie));//dynamically allocating memory temp->end=1; root=temp; } else if(start==size){//cheking if this is last char of string but node exist already } else if(root!=NULL){//cheking for this is not last char in string and node for that char does not exist //cout<<s; root->end=0; root->m[s[start]-'a']=BuildtrieTree( root->m[s[start]-'a'], s, start+1, size );//recursivly calling child node } else {// finally cheking for this is not last char but that char node exist already struct trie *temp; temp=(struct trie*)malloc(sizeof(struct trie)); temp->end=0; root=temp; root->m[s[start]-'a']=BuildtrieTree( root->m[s[start]-'a'], s, start+1, size ); } return root; } void checkString(struct trie *root, string s, int start ,int size){ if(start==size&&root->end==1){// if the start pointer has reached to the end and this is a leaf node cout<<"YES this string exist in the array of string "; } else if(root->m[s[start]-'a']!=NULL){//start pointer has not reached to the end and there are more //char left in string to be searched checkString(root->m[s[start]-'a'],s,start+1,size);//recursivly calling there child node } else{//start pointer has not reached to the end and no strings from all the string has meached to this string cout<<"SORRY, this string does not exist in the array of string"; } } int main(){ struct trie *root = NULL; //dynamcally alocating the first root node root=(struct trie*)malloc(sizeof(struct trie)); root->end=1; int num; cout<<"Enter the number of strings you want to insert : "; cin>>num; string s[num]; cout<<endl<<"Enter your strings : "; for(int i=0;i<num;i++) cin>>s[i]; for(int i=0;i<num;i++) root=BuildtrieTree(root,s[i],0,s[i].length()); cout<<endl<<"Enter string you want to search : "; string s2; cin>>s2; checkString( root, s2, 0, s2.length()); }
;=============================================================================== ; Constants FlowNumLives = 3 FlowStateMenu = 0 FlowStateAlive = 1 FlowStateDying = 2 ;=============================================================================== ; Variables flowScoreX byte 0 flowScoreNumX byte 0 flowScoreY byte 0 score1 byte 0 score2 byte 0 score3 byte 0 flowLivesX byte 17 flowLivesNumX byte 0 flowLivesY byte 0 lives byte 0 flowHiScoreX byte 31 flowHiScoreNumX byte 0 flowHiScoreY byte 0 hiscore1 byte 0 hiscore2 byte 0 hiscore3 byte 0 flowStartX byte 11 flowStartY byte 20 flowStartText text 'press fire to start' byte 0 flowStartClearText text ' ' byte 0 flowScoreText text 'score:' byte 0 flowLivesText text 'lives:' byte 0 flowHiScoreText text 'hi:' byte 0 flowState byte FlowStateMenu ;=============================================================================== ; Jump Tables gameFlowJumpTableLow byte <gameFlowUpdateMenu byte <gameFlowUpdateAlive byte <gameFlowUpdateDying gameFlowJumpTableHigh byte >gameFlowUpdateMenu byte >gameFlowUpdateAlive byte >gameFlowUpdateDying ;=============================================================================== ; Macros/Subroutines gameFlowInit LIBSCREEN_DRAWTEXT_AAAV flowScoreX, flowScoreY, flowScoreText, White jsr gameFlowScoreDisplay LIBSCREEN_DRAWTEXT_AAAV flowLivesX, flowLivesY, flowLivesText, White jsr gameFlowLivesDisplay LIBSCREEN_DRAWTEXT_AAAV flowHiScoreX, flowHiScoreY, flowHiScoreText, White jsr gameFlowHiScoreDisplay rts ;=============================================================================== gameFlowUpdateMenu ; display the menu text LIBSCREEN_DRAWTEXT_AAAV flowStartX, flowStartY, flowStartText, White LIBINPUT_GETFIREPRESSED bne gFUMEnd ; clear the menu text LIBSCREEN_DRAWTEXT_AAAV flowStartX, flowStartY, flowStartClearText, White ; reset jsr gameFlowResetLives jsr gamePlayerReset ; change state lda #FlowStateAlive sta flowState gFUMEnd rts ;=============================================================================== gameFlowUpdateAlive rts ;=============================================================================== gameFlowUpdateDying LIBSPRITE_ISANIMPLAYING_A playerSprite bne gFUDEnd lda lives bne gFUDHasLives ; change state lda #FlowStateMenu sta flowState jmp gFUDEnd gFUDHasLives LIBINPUT_GETFIREPRESSED bne gFUDEnd ; reset jsr gamePlayerReset ; change state lda #FlowStateAlive sta flowState gFUDEnd rts ;=============================================================================== gameFlowUpdate ; get the current state ldy flowState ; write the subroutine address to a zeropage location lda gameFlowJumpTableLow,y sta ZeroPageLow lda gameFlowJumpTableHigh,y sta ZeroPageHigh ; jump to the subroutine the zeropage location points to jmp (ZeroPageLow) ;=============================================================================== gameFlowIncreaseScore sed ;set decimal mode clc lda #$50 ;50 points scored adc score1 ;ones and tens sta score1 lda score2 ;hundreds and thousands adc #00 sta score2 lda score3 ;ten-thousands and hundred-thousands adc #00 sta score3 cld ;clear decimal mode jsr gameFlowScoreDisplay rts ;=============================================================================== gameFlowResetScore lda #0 sta score1 sta score2 sta score3 jsr gameFlowScoreDisplay rts ;=============================================================================== gameFlowResetLives lda #FlowNumLives sta lives jsr gameFlowLivesDisplay rts ;=============================================================================== gameFlowPlayerDied jsr gameBulletsReset ; stops in flight bullets from scoring jsr gameAliensReset dec lives bne gFPDHasLivesLeft jsr gameFlowUpdateHiScore jsr gameFlowResetScore gFPDHasLivesLeft jsr gameFlowLivesDisplay ; change state lda #FlowStateDying sta flowState rts ;=============================================================================== gameFlowUpdateHiScore ; http://6502.org/tutorials/decimal_mode.html#4.2 ; a common technique for comparing multi-byte numbers lda score1 cmp hiscore1 lda score2 sbc hiscore2 lda score3 sbc hiscore3 bcc gFUHNotHi lda score1 sta hiscore1 lda score2 sta hiscore2 lda score3 sta hiscore3 jsr gameFlowHiScoreDisplay gFUHNotHi rts ;=============================================================================== gameFlowScoreDisplay LIBMATH_ADD8BIT_AVA flowScoreX, 6, flowScoreNumX LIBSCREEN_DRAWDECIMAL_AAAV flowScoreNumX, flowScoreY, score3, White LIBMATH_ADD8BIT_AVA flowScoreX, 8, flowScoreNumX LIBSCREEN_DRAWDECIMAL_AAAV flowScoreNumX, flowScoreY, score2, White LIBMATH_ADD8BIT_AVA flowScoreX, 10, flowScoreNumX LIBSCREEN_DRAWDECIMAL_AAAV flowScoreNumX, flowScoreY, score1, White rts ;=============================================================================== gameFlowLivesDisplay LIBMATH_ADD8BIT_AVA flowLivesX, 6, flowLivesNumX LIBSCREEN_DRAWDECIMAL_AAAV flowLivesNumX, flowLivesY, lives, White rts ;=============================================================================== gameFlowHiScoreDisplay LIBMATH_ADD8BIT_AVA flowHiScoreX, 3, flowHiScoreNumX LIBSCREEN_DRAWDECIMAL_AAAV flowHiScoreNumX, flowHiScoreY, hiscore3, White LIBMATH_ADD8BIT_AVA flowHiScoreX, 5, flowHiScoreNumX LIBSCREEN_DRAWDECIMAL_AAAV flowHiScoreNumX, flowHiScoreY, hiscore2, White LIBMATH_ADD8BIT_AVA flowHiScoreX, 7, flowHiScoreNumX LIBSCREEN_DRAWDECIMAL_AAAV flowHiScoreNumX, flowHiScoreY, hiscore1, White rts
// Copyright (c) 2014-2017 The Crowdcoin Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. //#define ENABLE_CRC_DEBUG #include "activemasternode.h" #include "consensus/validation.h" #include "governance.h" #include "governance-vote.h" #include "governance-classes.h" #include "governance-validators.h" #include "init.h" #include "validation.h" #include "masternode.h" #include "masternode-sync.h" #include "masternodeconfig.h" #include "masternodeman.h" #include "messagesigner.h" #include "rpc/server.h" #include "util.h" #include "utilmoneystr.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #endif // ENABLE_WALLET bool EnsureWalletIsAvailable(bool avoidException); UniValue gobject(const JSONRPCRequest& request) { std::string strCommand; if (request.params.size() >= 1) strCommand = request.params[0].get_str(); if (request.fHelp || ( #ifdef ENABLE_WALLET strCommand != "prepare" && #endif // ENABLE_WALLET strCommand != "vote-many" && strCommand != "vote-conf" && strCommand != "vote-alias" && strCommand != "submit" && strCommand != "count" && strCommand != "deserialize" && strCommand != "get" && strCommand != "getvotes" && strCommand != "getcurrentvotes" && strCommand != "list" && strCommand != "diff" && strCommand != "check" )) throw std::runtime_error( "gobject \"command\"...\n" "Manage governance objects\n" "\nAvailable commands:\n" " check - Validate governance object data (proposal only)\n" #ifdef ENABLE_WALLET " prepare - Prepare governance object by signing and creating tx\n" #endif // ENABLE_WALLET " submit - Submit governance object to network\n" " deserialize - Deserialize governance object from hex string to JSON\n" " count - Count governance objects and votes (additional param: 'json' or 'all', default: 'json')\n" " get - Get governance object by hash\n" " getvotes - Get all votes for a governance object hash (including old votes)\n" " getcurrentvotes - Get only current (tallying) votes for a governance object hash (does not include old votes)\n" " list - List governance objects (can be filtered by signal and/or object type)\n" " diff - List differences since last diff\n" " vote-alias - Vote on a governance object by masternode alias (using masternode.conf setup)\n" " vote-conf - Vote on a governance object by masternode configured in crowdcoin.conf\n" " vote-many - Vote on a governance object by all masternodes (using masternode.conf setup)\n" ); if(strCommand == "count") { std::string strMode{"json"}; if (request.params.size() == 2) { strMode = request.params[1].get_str(); } if (request.params.size() > 2 || (strMode != "json" && strMode != "all")) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject count ( \"json\"|\"all\" )'"); } return strMode == "json" ? governance.ToJson() : governance.ToString(); } /* ------ Example Governance Item ------ gobject submit 6e622bb41bad1fb18e7f23ae96770aeb33129e18bd9efe790522488e580a0a03 0 1 1464292854 "beer-reimbursement" 5b5b22636f6e7472616374222c207b2270726f6a6563745f6e616d65223a20225c22626565722d7265696d62757273656d656e745c22222c20227061796d656e745f61646472657373223a20225c225879324c4b4a4a64655178657948726e34744744514238626a6876464564615576375c22222c2022656e645f64617465223a202231343936333030343030222c20226465736372697074696f6e5f75726c223a20225c227777772e646173687768616c652e6f72672f702f626565722d7265696d62757273656d656e745c22222c2022636f6e74726163745f75726c223a20225c22626565722d7265696d62757273656d656e742e636f6d2f3030312e7064665c22222c20227061796d656e745f616d6f756e74223a20223233342e323334323232222c2022676f7665726e616e63655f6f626a6563745f6964223a2037342c202273746172745f64617465223a202231343833323534303030227d5d5d1 */ // DEBUG : TEST DESERIALIZATION OF GOVERNANCE META DATA if(strCommand == "deserialize") { if (request.params.size() != 2) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject deserialize <data-hex>'"); } std::string strHex = request.params[1].get_str(); std::vector<unsigned char> v = ParseHex(strHex); std::string s(v.begin(), v.end()); UniValue u(UniValue::VOBJ); u.read(s); return u.write().c_str(); } // VALIDATE A GOVERNANCE OBJECT PRIOR TO SUBMISSION if(strCommand == "check") { if (request.params.size() != 2) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject check <data-hex>'"); } // ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS uint256 hashParent; int nRevision = 1; int64_t nTime = GetAdjustedTime(); std::string strDataHex = request.params[1].get_str(); CGovernanceObject govobj(hashParent, nRevision, nTime, uint256(), strDataHex); if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { CProposalValidator validator(strDataHex); if(!validator.Validate()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid proposal data, error messages:" + validator.GetErrorMessages()); } } else { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid object type, only proposals can be validated"); } UniValue objResult(UniValue::VOBJ); objResult.push_back(Pair("Object status", "OK")); return objResult; } #ifdef ENABLE_WALLET // PREPARE THE GOVERNANCE OBJECT BY CREATING A COLLATERAL TRANSACTION if(strCommand == "prepare") { if (!EnsureWalletIsAvailable(request.fHelp)) return NullUniValue; if (request.params.size() != 5) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject prepare <parent-hash> <revision> <time> <data-hex>'"); } // ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS uint256 hashParent; // -- attach to root node (root node doesn't really exist, but has a hash of zero) if(request.params[1].get_str() == "0") { hashParent = uint256(); } else { hashParent = ParseHashV(request.params[1], "fee-txid, parameter 1"); } std::string strRevision = request.params[2].get_str(); std::string strTime = request.params[3].get_str(); int nRevision = atoi(strRevision); int64_t nTime = atoi64(strTime); std::string strDataHex = request.params[4].get_str(); // CREATE A NEW COLLATERAL TRANSACTION FOR THIS SPECIFIC OBJECT CGovernanceObject govobj(hashParent, nRevision, nTime, uint256(), strDataHex); if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { CProposalValidator validator(strDataHex); if(!validator.Validate()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid proposal data, error messages:" + validator.GetErrorMessages()); } } if(govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Trigger objects need not be prepared (however only masternodes can create them)"); } if(govobj.GetObjectType() == GOVERNANCE_OBJECT_WATCHDOG) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Watchdogs are deprecated"); } LOCK2(cs_main, pwalletMain->cs_wallet); std::string strError = ""; if(!govobj.IsValidLocally(strError, false)) throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + govobj.GetHash().ToString() + " - " + strError); EnsureWalletIsUnlocked(); CWalletTx wtx; if(!pwalletMain->GetBudgetSystemCollateralTX(wtx, govobj.GetHash(), govobj.GetMinCollateralFee(), false)) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Error making collateral transaction for governance object. Please check your wallet balance and make sure your wallet is unlocked."); } // -- make our change address CReserveKey reservekey(pwalletMain); // -- send the tx to the network CValidationState state; if (!pwalletMain->CommitTransaction(wtx, reservekey, g_connman.get(), state, NetMsgType::TX)) { throw JSONRPCError(RPC_INTERNAL_ERROR, "CommitTransaction failed! Reason given: " + state.GetRejectReason()); } DBG( std::cout << "gobject: prepare " << " GetDataAsPlainString = " << govobj.GetDataAsPlainString() << ", hash = " << govobj.GetHash().GetHex() << ", txidFee = " << wtx.GetHash().GetHex() << std::endl; ); return wtx.GetHash().ToString(); } #endif // ENABLE_WALLET // AFTER COLLATERAL TRANSACTION HAS MATURED USER CAN SUBMIT GOVERNANCE OBJECT TO PROPAGATE NETWORK if(strCommand == "submit") { if ((request.params.size() < 5) || (request.params.size() > 6)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject submit <parent-hash> <revision> <time> <data-hex> <fee-txid>'"); } if(!masternodeSync.IsBlockchainSynced()) { throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Must wait for client to sync with masternode network. Try again in a minute or so."); } bool fMnFound = mnodeman.Has(activeMasternode.outpoint); DBG( std::cout << "gobject: submit activeMasternode.pubKeyMasternode = " << activeMasternode.pubKeyMasternode.GetHash().ToString() << ", outpoint = " << activeMasternode.outpoint.ToStringShort() << ", params.size() = " << request.params.size() << ", fMnFound = " << fMnFound << std::endl; ); // ASSEMBLE NEW GOVERNANCE OBJECT FROM USER PARAMETERS uint256 txidFee; if(request.params.size() == 6) { txidFee = ParseHashV(request.params[5], "fee-txid, parameter 6"); } uint256 hashParent; if(request.params[1].get_str() == "0") { // attach to root node (root node doesn't really exist, but has a hash of zero) hashParent = uint256(); } else { hashParent = ParseHashV(request.params[1], "parent object hash, parameter 2"); } // GET THE PARAMETERS FROM USER std::string strRevision = request.params[2].get_str(); std::string strTime = request.params[3].get_str(); int nRevision = atoi(strRevision); int64_t nTime = atoi64(strTime); std::string strDataHex = request.params[4].get_str(); CGovernanceObject govobj(hashParent, nRevision, nTime, txidFee, strDataHex); DBG( std::cout << "gobject: submit " << " GetDataAsPlainString = " << govobj.GetDataAsPlainString() << ", hash = " << govobj.GetHash().GetHex() << ", txidFee = " << txidFee.GetHex() << std::endl; ); if(govobj.GetObjectType() == GOVERNANCE_OBJECT_PROPOSAL) { CProposalValidator validator(strDataHex); if(!validator.Validate()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid proposal data, error messages:" + validator.GetErrorMessages()); } } if(govobj.GetObjectType() == GOVERNANCE_OBJECT_WATCHDOG) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Watchdogs are deprecated"); } // Attempt to sign triggers if we are a MN if(govobj.GetObjectType() == GOVERNANCE_OBJECT_TRIGGER) { if(fMnFound) { govobj.SetMasternodeOutpoint(activeMasternode.outpoint); govobj.Sign(activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode); } else { LogPrintf("gobject(submit) -- Object submission rejected because node is not a masternode\n"); throw JSONRPCError(RPC_INVALID_PARAMETER, "Only valid masternodes can submit this type of object"); } } else { if(request.params.size() != 6) { LogPrintf("gobject(submit) -- Object submission rejected because fee tx not provided\n"); throw JSONRPCError(RPC_INVALID_PARAMETER, "The fee-txid parameter must be included to submit this type of object"); } } std::string strHash = govobj.GetHash().ToString(); std::string strError = ""; bool fMissingMasternode; bool fMissingConfirmations; { LOCK(cs_main); if(!govobj.IsValidLocally(strError, fMissingMasternode, fMissingConfirmations, true) && !fMissingConfirmations) { LogPrintf("gobject(submit) -- Object submission rejected because object is not valid - hash = %s, strError = %s\n", strHash, strError); throw JSONRPCError(RPC_INTERNAL_ERROR, "Governance object is not valid - " + strHash + " - " + strError); } } // RELAY THIS OBJECT // Reject if rate check fails but don't update buffer if(!governance.MasternodeRateCheck(govobj)) { LogPrintf("gobject(submit) -- Object submission rejected because of rate check failure - hash = %s\n", strHash); throw JSONRPCError(RPC_INVALID_PARAMETER, "Object creation rate limit exceeded"); } LogPrintf("gobject(submit) -- Adding locally created governance object - %s\n", strHash); if(fMissingConfirmations) { governance.AddPostponedObject(govobj); govobj.Relay(*g_connman); } else { governance.AddGovernanceObject(govobj, *g_connman); } return govobj.GetHash().ToString(); } if(strCommand == "vote-conf") { if(request.params.size() != 4) throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject vote-conf <governance-hash> [funding|valid|delete] [yes|no|abstain]'"); uint256 hash; std::string strVote; hash = ParseHashV(request.params[1], "Object hash"); std::string strVoteSignal = request.params[2].get_str(); std::string strVoteOutcome = request.params[3].get_str(); vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal); if(eVoteSignal == VOTE_SIGNAL_NONE) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote signal. Please using one of the following: " "(funding|valid|delete|endorsed)"); } vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome); if(eVoteOutcome == VOTE_OUTCOME_NONE) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'"); } int nSuccessful = 0; int nFailed = 0; UniValue resultsObj(UniValue::VOBJ); std::vector<unsigned char> vchMasterNodeSignature; std::string strMasterNodeSignMessage; UniValue statusObj(UniValue::VOBJ); UniValue returnObj(UniValue::VOBJ); CMasternode mn; bool fMnFound = mnodeman.Get(activeMasternode.outpoint, mn); if(!fMnFound) { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", "Can't find masternode by collateral output")); resultsObj.push_back(Pair("crowdcoin.conf", statusObj)); returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); returnObj.push_back(Pair("detail", resultsObj)); return returnObj; } CGovernanceVote vote(mn.outpoint, hash, eVoteSignal, eVoteOutcome); if(!vote.Sign(activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode)) { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", "Failure to sign.")); resultsObj.push_back(Pair("crowdcoin.conf", statusObj)); returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); returnObj.push_back(Pair("detail", resultsObj)); return returnObj; } CGovernanceException exception; if(governance.ProcessVoteAndRelay(vote, exception, *g_connman)) { nSuccessful++; statusObj.push_back(Pair("result", "success")); } else { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", exception.GetMessage())); } resultsObj.push_back(Pair("crowdcoin.conf", statusObj)); returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); returnObj.push_back(Pair("detail", resultsObj)); return returnObj; } if(strCommand == "vote-many") { if(request.params.size() != 4) throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject vote-many <governance-hash> [funding|valid|delete] [yes|no|abstain]'"); uint256 hash; std::string strVote; hash = ParseHashV(request.params[1], "Object hash"); std::string strVoteSignal = request.params[2].get_str(); std::string strVoteOutcome = request.params[3].get_str(); vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal); if(eVoteSignal == VOTE_SIGNAL_NONE) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote signal. Please using one of the following: " "(funding|valid|delete|endorsed)"); } vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome); if(eVoteOutcome == VOTE_OUTCOME_NONE) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'"); } int nSuccessful = 0; int nFailed = 0; UniValue resultsObj(UniValue::VOBJ); for (const auto& mne : masternodeConfig.getEntries()) { std::string strError; std::vector<unsigned char> vchMasterNodeSignature; std::string strMasterNodeSignMessage; CPubKey pubKeyCollateralAddress; CKey keyCollateralAddress; CPubKey pubKeyMasternode; CKey keyMasternode; UniValue statusObj(UniValue::VOBJ); if(!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)){ nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", "Masternode signing error, could not set key correctly")); resultsObj.push_back(Pair(mne.getAlias(), statusObj)); continue; } uint256 nTxHash; nTxHash.SetHex(mne.getTxHash()); int nOutputIndex = 0; if(!ParseInt32(mne.getOutputIndex(), &nOutputIndex)) { continue; } COutPoint outpoint(nTxHash, nOutputIndex); CMasternode mn; bool fMnFound = mnodeman.Get(outpoint, mn); if(!fMnFound) { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", "Can't find masternode by collateral output")); resultsObj.push_back(Pair(mne.getAlias(), statusObj)); continue; } CGovernanceVote vote(mn.outpoint, hash, eVoteSignal, eVoteOutcome); if(!vote.Sign(keyMasternode, pubKeyMasternode)){ nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", "Failure to sign.")); resultsObj.push_back(Pair(mne.getAlias(), statusObj)); continue; } CGovernanceException exception; if(governance.ProcessVoteAndRelay(vote, exception, *g_connman)) { nSuccessful++; statusObj.push_back(Pair("result", "success")); } else { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", exception.GetMessage())); } resultsObj.push_back(Pair(mne.getAlias(), statusObj)); } UniValue returnObj(UniValue::VOBJ); returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); returnObj.push_back(Pair("detail", resultsObj)); return returnObj; } // MASTERNODES CAN VOTE ON GOVERNANCE OBJECTS ON THE NETWORK FOR VARIOUS SIGNALS AND OUTCOMES if(strCommand == "vote-alias") { if(request.params.size() != 5) throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject vote-alias <governance-hash> [funding|valid|delete] [yes|no|abstain] <alias-name>'"); uint256 hash; std::string strVote; // COLLECT NEEDED PARAMETRS FROM USER hash = ParseHashV(request.params[1], "Object hash"); std::string strVoteSignal = request.params[2].get_str(); std::string strVoteOutcome = request.params[3].get_str(); std::string strAlias = request.params[4].get_str(); // CONVERT NAMED SIGNAL/ACTION AND CONVERT vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal); if(eVoteSignal == VOTE_SIGNAL_NONE) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote signal. Please using one of the following: " "(funding|valid|delete|endorsed)"); } vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome); if(eVoteOutcome == VOTE_OUTCOME_NONE) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'"); } // EXECUTE VOTE FOR EACH MASTERNODE, COUNT SUCCESSES VS FAILURES int nSuccessful = 0; int nFailed = 0; UniValue resultsObj(UniValue::VOBJ); for (const auto& mne : masternodeConfig.getEntries()) { // IF WE HAVE A SPECIFIC NODE REQUESTED TO VOTE, DO THAT if(strAlias != mne.getAlias()) continue; // INIT OUR NEEDED VARIABLES TO EXECUTE THE VOTE std::string strError; std::vector<unsigned char> vchMasterNodeSignature; std::string strMasterNodeSignMessage; CPubKey pubKeyCollateralAddress; CKey keyCollateralAddress; CPubKey pubKeyMasternode; CKey keyMasternode; // SETUP THE SIGNING KEY FROM MASTERNODE.CONF ENTRY UniValue statusObj(UniValue::VOBJ); if(!CMessageSigner::GetKeysFromSecret(mne.getPrivKey(), keyMasternode, pubKeyMasternode)) { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", strprintf("Invalid masternode key %s.", mne.getPrivKey()))); resultsObj.push_back(Pair(mne.getAlias(), statusObj)); continue; } // SEARCH FOR THIS MASTERNODE ON THE NETWORK, THE NODE MUST BE ACTIVE TO VOTE uint256 nTxHash; nTxHash.SetHex(mne.getTxHash()); int nOutputIndex = 0; if(!ParseInt32(mne.getOutputIndex(), &nOutputIndex)) { continue; } COutPoint outpoint(nTxHash, nOutputIndex); CMasternode mn; bool fMnFound = mnodeman.Get(outpoint, mn); if(!fMnFound) { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", "Masternode must be publicly available on network to vote. Masternode not found.")); resultsObj.push_back(Pair(mne.getAlias(), statusObj)); continue; } // CREATE NEW GOVERNANCE OBJECT VOTE WITH OUTCOME/SIGNAL CGovernanceVote vote(outpoint, hash, eVoteSignal, eVoteOutcome); if(!vote.Sign(keyMasternode, pubKeyMasternode)) { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", "Failure to sign.")); resultsObj.push_back(Pair(mne.getAlias(), statusObj)); continue; } // UPDATE LOCAL DATABASE WITH NEW OBJECT SETTINGS CGovernanceException exception; if(governance.ProcessVoteAndRelay(vote, exception, *g_connman)) { nSuccessful++; statusObj.push_back(Pair("result", "success")); } else { nFailed++; statusObj.push_back(Pair("result", "failed")); statusObj.push_back(Pair("errorMessage", exception.GetMessage())); } resultsObj.push_back(Pair(mne.getAlias(), statusObj)); } // REPORT STATS TO THE USER UniValue returnObj(UniValue::VOBJ); returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed))); returnObj.push_back(Pair("detail", resultsObj)); return returnObj; } // USERS CAN QUERY THE SYSTEM FOR A LIST OF VARIOUS GOVERNANCE ITEMS if(strCommand == "list" || strCommand == "diff") { if (request.params.size() > 3) throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject [list|diff] ( signal type )'"); // GET MAIN PARAMETER FOR THIS MODE, VALID OR ALL? std::string strCachedSignal = "valid"; if (request.params.size() >= 2) strCachedSignal = request.params[1].get_str(); if (strCachedSignal != "valid" && strCachedSignal != "funding" && strCachedSignal != "delete" && strCachedSignal != "endorsed" && strCachedSignal != "all") return "Invalid signal, should be 'valid', 'funding', 'delete', 'endorsed' or 'all'"; std::string strType = "all"; if (request.params.size() == 3) strType = request.params[2].get_str(); if (strType != "proposals" && strType != "triggers" && strType != "all") return "Invalid type, should be 'proposals', 'triggers' or 'all'"; // GET STARTING TIME TO QUERY SYSTEM WITH int nStartTime = 0; //list if(strCommand == "diff") nStartTime = governance.GetLastDiffTime(); // SETUP BLOCK INDEX VARIABLE / RESULTS VARIABLE UniValue objResult(UniValue::VOBJ); // GET MATCHING GOVERNANCE OBJECTS LOCK2(cs_main, governance.cs); std::vector<const CGovernanceObject*> objs = governance.GetAllNewerThan(nStartTime); governance.UpdateLastDiffTime(GetTime()); // CREATE RESULTS FOR USER for (const auto& pGovObj : objs) { if(strCachedSignal == "valid" && !pGovObj->IsSetCachedValid()) continue; if(strCachedSignal == "funding" && !pGovObj->IsSetCachedFunding()) continue; if(strCachedSignal == "delete" && !pGovObj->IsSetCachedDelete()) continue; if(strCachedSignal == "endorsed" && !pGovObj->IsSetCachedEndorsed()) continue; if(strType == "proposals" && pGovObj->GetObjectType() != GOVERNANCE_OBJECT_PROPOSAL) continue; if(strType == "triggers" && pGovObj->GetObjectType() != GOVERNANCE_OBJECT_TRIGGER) continue; UniValue bObj(UniValue::VOBJ); bObj.push_back(Pair("DataHex", pGovObj->GetDataAsHexString())); bObj.push_back(Pair("DataString", pGovObj->GetDataAsPlainString())); bObj.push_back(Pair("Hash", pGovObj->GetHash().ToString())); bObj.push_back(Pair("CollateralHash", pGovObj->GetCollateralHash().ToString())); bObj.push_back(Pair("ObjectType", pGovObj->GetObjectType())); bObj.push_back(Pair("CreationTime", pGovObj->GetCreationTime())); const COutPoint& masternodeOutpoint = pGovObj->GetMasternodeOutpoint(); if(masternodeOutpoint != COutPoint()) { bObj.push_back(Pair("SigningMasternode", masternodeOutpoint.ToStringShort())); } // REPORT STATUS FOR FUNDING VOTES SPECIFICALLY bObj.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING))); bObj.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING))); bObj.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); bObj.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING))); // REPORT VALIDITY AND CACHING FLAGS FOR VARIOUS SETTINGS std::string strError = ""; bObj.push_back(Pair("fBlockchainValidity", pGovObj->IsValidLocally(strError, false))); bObj.push_back(Pair("IsValidReason", strError.c_str())); bObj.push_back(Pair("fCachedValid", pGovObj->IsSetCachedValid())); bObj.push_back(Pair("fCachedFunding", pGovObj->IsSetCachedFunding())); bObj.push_back(Pair("fCachedDelete", pGovObj->IsSetCachedDelete())); bObj.push_back(Pair("fCachedEndorsed", pGovObj->IsSetCachedEndorsed())); objResult.push_back(Pair(pGovObj->GetHash().ToString(), bObj)); } return objResult; } // GET SPECIFIC GOVERNANCE ENTRY if(strCommand == "get") { if (request.params.size() != 2) throw JSONRPCError(RPC_INVALID_PARAMETER, "Correct usage is 'gobject get <governance-hash>'"); // COLLECT VARIABLES FROM OUR USER uint256 hash = ParseHashV(request.params[1], "GovObj hash"); LOCK2(cs_main, governance.cs); // FIND THE GOVERNANCE OBJECT THE USER IS LOOKING FOR CGovernanceObject* pGovObj = governance.FindGovernanceObject(hash); if(pGovObj == NULL) throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown governance object"); // REPORT BASIC OBJECT STATS UniValue objResult(UniValue::VOBJ); objResult.push_back(Pair("DataHex", pGovObj->GetDataAsHexString())); objResult.push_back(Pair("DataString", pGovObj->GetDataAsPlainString())); objResult.push_back(Pair("Hash", pGovObj->GetHash().ToString())); objResult.push_back(Pair("CollateralHash", pGovObj->GetCollateralHash().ToString())); objResult.push_back(Pair("ObjectType", pGovObj->GetObjectType())); objResult.push_back(Pair("CreationTime", pGovObj->GetCreationTime())); const COutPoint& masternodeOutpoint = pGovObj->GetMasternodeOutpoint(); if(masternodeOutpoint != COutPoint()) { objResult.push_back(Pair("SigningMasternode", masternodeOutpoint.ToStringShort())); } // SHOW (MUCH MORE) INFORMATION ABOUT VOTES FOR GOVERNANCE OBJECT (THAN LIST/DIFF ABOVE) // -- FUNDING VOTING RESULTS UniValue objFundingResult(UniValue::VOBJ); objFundingResult.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_FUNDING))); objFundingResult.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_FUNDING))); objFundingResult.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_FUNDING))); objFundingResult.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_FUNDING))); objResult.push_back(Pair("FundingResult", objFundingResult)); // -- VALIDITY VOTING RESULTS UniValue objValid(UniValue::VOBJ); objValid.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_VALID))); objValid.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_VALID))); objValid.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_VALID))); objValid.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_VALID))); objResult.push_back(Pair("ValidResult", objValid)); // -- DELETION CRITERION VOTING RESULTS UniValue objDelete(UniValue::VOBJ); objDelete.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_DELETE))); objDelete.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_DELETE))); objDelete.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_DELETE))); objDelete.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_DELETE))); objResult.push_back(Pair("DeleteResult", objDelete)); // -- ENDORSED VIA MASTERNODE-ELECTED BOARD UniValue objEndorsed(UniValue::VOBJ); objEndorsed.push_back(Pair("AbsoluteYesCount", pGovObj->GetAbsoluteYesCount(VOTE_SIGNAL_ENDORSED))); objEndorsed.push_back(Pair("YesCount", pGovObj->GetYesCount(VOTE_SIGNAL_ENDORSED))); objEndorsed.push_back(Pair("NoCount", pGovObj->GetNoCount(VOTE_SIGNAL_ENDORSED))); objEndorsed.push_back(Pair("AbstainCount", pGovObj->GetAbstainCount(VOTE_SIGNAL_ENDORSED))); objResult.push_back(Pair("EndorsedResult", objEndorsed)); // -- std::string strError = ""; objResult.push_back(Pair("fLocalValidity", pGovObj->IsValidLocally(strError, false))); objResult.push_back(Pair("IsValidReason", strError.c_str())); objResult.push_back(Pair("fCachedValid", pGovObj->IsSetCachedValid())); objResult.push_back(Pair("fCachedFunding", pGovObj->IsSetCachedFunding())); objResult.push_back(Pair("fCachedDelete", pGovObj->IsSetCachedDelete())); objResult.push_back(Pair("fCachedEndorsed", pGovObj->IsSetCachedEndorsed())); return objResult; } // GETVOTES FOR SPECIFIC GOVERNANCE OBJECT if(strCommand == "getvotes") { if (request.params.size() != 2) throw std::runtime_error( "Correct usage is 'gobject getvotes <governance-hash>'" ); // COLLECT PARAMETERS FROM USER uint256 hash = ParseHashV(request.params[1], "Governance hash"); // FIND OBJECT USER IS LOOKING FOR LOCK(governance.cs); CGovernanceObject* pGovObj = governance.FindGovernanceObject(hash); if(pGovObj == NULL) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown governance-hash"); } // REPORT RESULTS TO USER UniValue bResult(UniValue::VOBJ); // GET MATCHING VOTES BY HASH, THEN SHOW USERS VOTE INFORMATION std::vector<CGovernanceVote> vecVotes = governance.GetMatchingVotes(hash); for (const auto& vote : vecVotes) { bResult.push_back(Pair(vote.GetHash().ToString(), vote.ToString())); } return bResult; } // GETVOTES FOR SPECIFIC GOVERNANCE OBJECT if(strCommand == "getcurrentvotes") { if (request.params.size() != 2 && request.params.size() != 4) throw std::runtime_error( "Correct usage is 'gobject getcurrentvotes <governance-hash> [txid vout_index]'" ); // COLLECT PARAMETERS FROM USER uint256 hash = ParseHashV(request.params[1], "Governance hash"); COutPoint mnCollateralOutpoint; if (request.params.size() == 4) { uint256 txid = ParseHashV(request.params[2], "Masternode Collateral hash"); std::string strVout = request.params[3].get_str(); mnCollateralOutpoint = COutPoint(txid, (uint32_t)atoi(strVout)); } // FIND OBJECT USER IS LOOKING FOR LOCK(governance.cs); CGovernanceObject* pGovObj = governance.FindGovernanceObject(hash); if(pGovObj == NULL) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown governance-hash"); } // REPORT RESULTS TO USER UniValue bResult(UniValue::VOBJ); // GET MATCHING VOTES BY HASH, THEN SHOW USERS VOTE INFORMATION std::vector<CGovernanceVote> vecVotes = governance.GetCurrentVotes(hash, mnCollateralOutpoint); for (const auto& vote : vecVotes) { bResult.push_back(Pair(vote.GetHash().ToString(), vote.ToString())); } return bResult; } return NullUniValue; } UniValue voteraw(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 7) throw std::runtime_error( "voteraw <masternode-tx-hash> <masternode-tx-index> <governance-hash> <vote-signal> [yes|no|abstain] <time> <vote-sig>\n" "Compile and relay a governance vote with provided external signature instead of signing vote internally\n" ); uint256 hashMnTx = ParseHashV(request.params[0], "mn tx hash"); int nMnTxIndex = request.params[1].get_int(); COutPoint outpoint = COutPoint(hashMnTx, nMnTxIndex); uint256 hashGovObj = ParseHashV(request.params[2], "Governance hash"); std::string strVoteSignal = request.params[3].get_str(); std::string strVoteOutcome = request.params[4].get_str(); vote_signal_enum_t eVoteSignal = CGovernanceVoting::ConvertVoteSignal(strVoteSignal); if(eVoteSignal == VOTE_SIGNAL_NONE) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote signal. Please using one of the following: " "(funding|valid|delete|endorsed)"); } vote_outcome_enum_t eVoteOutcome = CGovernanceVoting::ConvertVoteOutcome(strVoteOutcome); if(eVoteOutcome == VOTE_OUTCOME_NONE) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid vote outcome. Please use one of the following: 'yes', 'no' or 'abstain'"); } int64_t nTime = request.params[5].get_int64(); std::string strSig = request.params[6].get_str(); bool fInvalid = false; std::vector<unsigned char> vchSig = DecodeBase64(strSig.c_str(), &fInvalid); if (fInvalid) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Malformed base64 encoding"); } CMasternode mn; bool fMnFound = mnodeman.Get(outpoint, mn); if(!fMnFound) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Failure to find masternode in list : " + outpoint.ToStringShort()); } CGovernanceVote vote(outpoint, hashGovObj, eVoteSignal, eVoteOutcome); vote.SetTime(nTime); vote.SetSignature(vchSig); if(!vote.IsValid(true)) { throw JSONRPCError(RPC_INTERNAL_ERROR, "Failure to verify vote."); } CGovernanceException exception; if(governance.ProcessVoteAndRelay(vote, exception, *g_connman)) { return "Voted successfully"; } else { throw JSONRPCError(RPC_INTERNAL_ERROR, "Error voting : " + exception.GetMessage()); } } UniValue getgovernanceinfo(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 0) { throw std::runtime_error( "getgovernanceinfo\n" "Returns an object containing governance parameters.\n" "\nResult:\n" "{\n" " \"governanceminquorum\": xxxxx, (numeric) the absolute minimum number of votes needed to trigger a governance action\n" " \"masternodewatchdogmaxseconds\": xxxxx, (numeric) sentinel watchdog expiration time in seconds (DEPRECATED)\n" " \"sentinelpingmaxseconds\": xxxxx, (numeric) sentinel ping expiration time in seconds\n" " \"proposalfee\": xxx.xx, (numeric) the collateral transaction fee which must be paid to create a proposal in " + CURRENCY_UNIT + "\n" " \"superblockcycle\": xxxxx, (numeric) the number of blocks between superblocks\n" " \"lastsuperblock\": xxxxx, (numeric) the block number of the last superblock\n" " \"nextsuperblock\": xxxxx, (numeric) the block number of the next superblock\n" " \"maxgovobjdatasize\": xxxxx, (numeric) maximum governance object data size in bytes\n" "}\n" "\nExamples:\n" + HelpExampleCli("getgovernanceinfo", "") + HelpExampleRpc("getgovernanceinfo", "") ); } LOCK(cs_main); int nLastSuperblock = 0, nNextSuperblock = 0; int nBlockHeight = chainActive.Height(); CSuperblock::GetNearestSuperblocksHeights(nBlockHeight, nLastSuperblock, nNextSuperblock); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("governanceminquorum", Params().GetConsensus().nGovernanceMinQuorum)); obj.push_back(Pair("masternodewatchdogmaxseconds", MASTERNODE_SENTINEL_PING_MAX_SECONDS)); obj.push_back(Pair("sentinelpingmaxseconds", MASTERNODE_SENTINEL_PING_MAX_SECONDS)); obj.push_back(Pair("proposalfee", ValueFromAmount(GOVERNANCE_PROPOSAL_FEE_TX))); obj.push_back(Pair("superblockcycle", Params().GetConsensus().nSuperblockCycle)); obj.push_back(Pair("lastsuperblock", nLastSuperblock)); obj.push_back(Pair("nextsuperblock", nNextSuperblock)); obj.push_back(Pair("maxgovobjdatasize", MAX_GOVERNANCE_OBJECT_DATA_SIZE)); return obj; } UniValue getsuperblockbudget(const JSONRPCRequest& request) { if (request.fHelp || request.params.size() != 1) { throw std::runtime_error( "getsuperblockbudget index\n" "\nReturns the absolute maximum sum of superblock payments allowed.\n" "\nArguments:\n" "1. index (numeric, required) The block index\n" "\nResult:\n" "n (numeric) The absolute maximum sum of superblock payments allowed, in " + CURRENCY_UNIT + "\n" "\nExamples:\n" + HelpExampleCli("getsuperblockbudget", "1000") + HelpExampleRpc("getsuperblockbudget", "1000") ); } int nBlockHeight = request.params[0].get_int(); if (nBlockHeight < 0) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); } CAmount nBudget = CSuperblock::GetPaymentsLimit(nBlockHeight); std::string strBudget = FormatMoney(nBudget); return strBudget; } static const CRPCCommand commands[] = { // category name actor (function) okSafe argNames // --------------------- ------------------------ ----------------------- ------ ---------- /* Crowdcoin features */ { "crowdcoin", "getgovernanceinfo", &getgovernanceinfo, true, {} }, { "crowdcoin", "getsuperblockbudget", &getsuperblockbudget, true, {"index"} }, { "crowdcoin", "gobject", &gobject, true, {} }, { "crowdcoin", "voteraw", &voteraw, true, {} }, }; void RegisterGovernanceRPCCommands(CRPCTable &t) { for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++) t.appendCommand(commands[vcidx].name, &commands[vcidx]); }
.global s_prepare_buffers s_prepare_buffers: push %r9 push %rcx push %rdi push %rsi lea addresses_WT_ht+0x8a2d, %rsi lea addresses_D_ht+0x17fbd, %rdi clflush (%rdi) dec %r9 mov $1, %rcx rep movsw nop nop nop nop inc %r9 pop %rsi pop %rdi pop %rcx pop %r9 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r15 push %rbx push %rcx push %rdi // Store mov $0x5d639c000000054d, %r10 clflush (%r10) nop nop nop dec %rdi movb $0x51, (%r10) nop nop nop nop and $46395, %rdi // Store mov $0xbbd, %r12 nop nop sub %rbx, %rbx movb $0x51, (%r12) nop nop nop nop nop and $28169, %rdi // Store lea addresses_RW+0x12bbd, %rcx and $26348, %rbx movw $0x5152, (%rcx) nop nop add %rbx, %rbx // Store lea addresses_A+0x17acf, %r10 nop xor %rdi, %rdi movb $0x51, (%r10) nop nop add %rcx, %rcx // Faulty Load mov $0x4aa343000000074d, %r15 nop and %rcx, %rcx vmovups (%r15), %ymm1 vextracti128 $1, %ymm1, %xmm1 vpextrq $0, %xmm1, %rdi lea oracles, %r12 and $0xff, %rdi shlq $12, %rdi mov (%r12,%rdi,1), %rdi pop %rdi pop %rcx pop %rbx pop %r15 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_P', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}} {'00': 9188} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r14 push %r8 push %r9 push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0xbd11, %rsi lea addresses_WT_ht+0x598, %rdi nop nop nop nop add %rbx, %rbx mov $67, %rcx rep movsl nop nop nop nop nop dec %r14 lea addresses_D_ht+0x11c50, %rsi lea addresses_D_ht+0x13b78, %rdi nop xor %rbx, %rbx mov $108, %rcx rep movsl and %rbx, %rbx lea addresses_WC_ht+0x19adc, %r13 nop nop nop nop cmp %r9, %r9 movl $0x61626364, (%r13) cmp %rdi, %rdi lea addresses_D_ht+0xbc50, %rbx add %r13, %r13 movw $0x6162, (%rbx) nop nop cmp %r9, %r9 lea addresses_normal_ht+0x2d50, %rcx clflush (%rcx) sub $40348, %rbx mov $0x6162636465666768, %r13 movq %r13, %xmm6 and $0xffffffffffffffc0, %rcx movntdq %xmm6, (%rcx) nop nop xor %r13, %r13 lea addresses_A_ht+0x183d0, %rsi lea addresses_D_ht+0x1e7ec, %rdi nop nop nop inc %r8 mov $4, %rcx rep movsq xor %rbx, %rbx lea addresses_WC_ht+0x125a6, %rdi nop nop nop xor $16496, %r14 mov $0x6162636465666768, %rbx movq %rbx, (%rdi) nop nop nop add $15078, %rbx lea addresses_normal_ht+0x103d0, %rsi lea addresses_UC_ht+0x76c8, %rdi clflush (%rsi) nop cmp $40927, %r13 mov $40, %rcx rep movsq nop and $41891, %rbx lea addresses_D_ht+0x7070, %rcx clflush (%rcx) nop nop nop nop cmp %r9, %r9 mov (%rcx), %si nop add %rcx, %rcx lea addresses_A_ht+0x9090, %r8 clflush (%r8) nop nop sub $10015, %rbx mov $0x6162636465666768, %rsi movq %rsi, %xmm0 vmovups %ymm0, (%r8) cmp %r13, %r13 pop %rsi pop %rdi pop %rcx pop %rbx pop %r9 pop %r8 pop %r14 pop %r13 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r15 push %rax push %rdi push %rsi // Store lea addresses_D+0x14bd0, %r12 nop sub $16475, %rsi movb $0x51, (%r12) dec %r12 // Store lea addresses_PSE+0x1a3d0, %r15 nop dec %r11 mov $0x5152535455565758, %rsi movq %rsi, (%r15) cmp %r12, %r12 // Store lea addresses_WC+0x53a0, %r12 nop nop nop nop cmp $59067, %rax movb $0x51, (%r12) inc %r11 // Store lea addresses_RW+0x3bd0, %r14 nop nop cmp $42426, %r15 movl $0x51525354, (%r14) nop and %r12, %r12 // Store lea addresses_D+0x14bd0, %r14 clflush (%r14) nop nop nop nop nop xor $20720, %rdi mov $0x5152535455565758, %rax movq %rax, %xmm5 vmovups %ymm5, (%r14) nop nop nop nop add %rdi, %rdi // Store lea addresses_WT+0xa3d0, %r14 nop nop nop nop nop and %r11, %r11 mov $0x5152535455565758, %r15 movq %r15, %xmm5 movups %xmm5, (%r14) nop nop nop add $45137, %r11 // Store lea addresses_A+0x18090, %r14 nop nop nop and %rax, %rax mov $0x5152535455565758, %r12 movq %r12, (%r14) nop cmp %rsi, %rsi // Store lea addresses_WT+0x14fd0, %rsi nop nop inc %r15 mov $0x5152535455565758, %rdi movq %rdi, %xmm7 movups %xmm7, (%rsi) nop sub %r15, %r15 // Store lea addresses_WC+0x9f10, %r12 sub %r14, %r14 movw $0x5152, (%r12) // Exception!!! mov (0), %r11 nop nop nop nop nop cmp %rdi, %rdi // Faulty Load lea addresses_D+0x14bd0, %rdi nop nop nop nop nop xor $65182, %r11 movb (%rdi), %r12b lea oracles, %rax and $0xff, %r12 shlq $12, %r12 mov (%rax,%r12,1), %r12 pop %rsi pop %rdi pop %rax pop %r15 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D', 'congruent': 0}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_D', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_PSE', 'congruent': 10}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': True, 'size': 1, 'type': 'addresses_WC', 'congruent': 4}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_RW', 'congruent': 11}, 'OP': 'STOR'} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_D', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT', 'congruent': 11}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_A', 'congruent': 3}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_WT', 'congruent': 6}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WC', 'congruent': 6}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': True, 'size': 1, 'type': 'addresses_D', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 0, 'type': 'addresses_UC_ht'}} {'dst': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WC_ht', 'congruent': 1}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 4}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 16, 'type': 'addresses_normal_ht', 'congruent': 7}, 'OP': 'STOR'} {'dst': {'same': True, 'congruent': 1, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WC_ht', 'congruent': 1}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 3, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_normal_ht'}} {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D_ht', 'congruent': 4}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_A_ht', 'congruent': 3}, 'OP': 'STOR'} {'58': 21829} 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 */
/// @ref ext_matrix_int4x4_sized /// @file glm/ext/matrix_int4x4_sized.hpp /// /// @see core (dependence) /// /// @defgroup ext_matrix_int4x4_sized GLM_EXT_matrix_int4x4_sized /// @ingroup ext /// /// Include <glm/ext/matrix_int4x4_sized.hpp> to use the features of this extension. /// /// Defines a number of matrices with integer types. #pragma once // Dependency: #include "../mat4x4.hpp" #include "../ext/scalar_int_sized.hpp" #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) # pragma message("GLM: GLM_EXT_matrix_int4x4_sized extension included") #endif namespace args::core::math { /// @addtogroup ext_matrix_int4x4_sized /// @{ /// 8 bit signed integer 4x4 matrix. /// /// @see ext_matrix_int4x4_sized typedef mat<4, 4, int8, defaultp> i8mat4x4; /// 16 bit signed integer 4x4 matrix. /// /// @see ext_matrix_int4x4_sized typedef mat<4, 4, int16, defaultp> i16mat4x4; /// 32 bit signed integer 4x4 matrix. /// /// @see ext_matrix_int4x4_sized typedef mat<4, 4, int32, defaultp> i32mat4x4; /// 64 bit signed integer 4x4 matrix. /// /// @see ext_matrix_int4x4_sized typedef mat<4, 4, int64, defaultp> i64mat4x4; /// 8 bit signed integer 4x4 matrix. /// /// @see ext_matrix_int4x4_sized typedef mat<4, 4, int8, defaultp> i8mat4; /// 16 bit signed integer 4x4 matrix. /// /// @see ext_matrix_int4x4_sized typedef mat<4, 4, int16, defaultp> i16mat4; /// 32 bit signed integer 4x4 matrix. /// /// @see ext_matrix_int4x4_sized typedef mat<4, 4, int32, defaultp> i32mat4; /// 64 bit signed integer 4x4 matrix. /// /// @see ext_matrix_int4x4_sized typedef mat<4, 4, int64, defaultp> i64mat4; /// @} }//namespace args::core::math
TowerMons1: db $00 db $00
; A010011: a(0) = 1, a(n) = 21*n^2 + 2 for n>0. ; 1,23,86,191,338,527,758,1031,1346,1703,2102,2543,3026,3551,4118,4727,5378,6071,6806,7583,8402,9263,10166,11111,12098,13127,14198,15311,16466,17663,18902,20183,21506,22871,24278,25727,27218,28751,30326,31943,33602,35303,37046,38831,40658,42527,44438,46391,48386,50423,52502,54623,56786,58991,61238,63527,65858,68231,70646,73103,75602,78143,80726,83351,86018,88727,91478,94271,97106,99983,102902,105863,108866,111911,114998,118127,121298,124511,127766,131063,134402,137783,141206,144671,148178,151727,155318,158951,162626,166343,170102,173903,177746,181631,185558,189527,193538,197591,201686,205823,210002,214223,218486,222791,227138,231527,235958,240431,244946,249503,254102,258743,263426,268151,272918,277727,282578,287471,292406,297383,302402,307463,312566,317711,322898,328127,333398,338711,344066,349463,354902,360383,365906,371471,377078,382727,388418,394151,399926,405743,411602,417503,423446,429431,435458,441527,447638,453791,459986,466223,472502,478823,485186,491591,498038,504527,511058,517631,524246,530903,537602,544343,551126,557951,564818,571727,578678,585671,592706,599783,606902,614063,621266,628511,635798,643127,650498,657911,665366,672863,680402,687983,695606,703271,710978,718727,726518,734351,742226,750143,758102,766103,774146,782231,790358,798527,806738,814991,823286,831623,840002,848423,856886,865391,873938,882527,891158,899831,908546,917303,926102,934943,943826,952751,961718,970727,979778,988871,998006,1007183,1016402,1025663,1034966,1044311,1053698,1063127,1072598,1082111,1091666,1101263,1110902,1120583,1130306,1140071,1149878,1159727,1169618,1179551,1189526,1199543,1209602,1219703,1229846,1240031,1250258,1260527,1270838,1281191,1291586,1302023 pow $1,$0 gcd $1,2 mov $3,$0 mul $3,$0 mov $2,$3 mul $2,21 add $1,$2
#include <boost/test/unit_test.hpp> #include <eosio/testing/tester.hpp> #include <eosio/testing/tester_network.hpp> #include <eosio/chain/generated_transaction_object.hpp> #include <fc/variant_object.hpp> #include <actx.token/actx.token.wast.hpp> #include <actx.token/actx.token.abi.hpp> #include <deferred_test/deferred_test.wast.hpp> #include <deferred_test/deferred_test.abi.hpp> #ifdef NON_VALIDATING_TEST #define TESTER tester #else #define TESTER validating_tester #endif using namespace eosio; using namespace eosio::chain; using namespace eosio::testing; using mvo = fc::mutable_variant_object; template<class Tester = TESTER> class whitelist_blacklist_tester { public: whitelist_blacklist_tester() {} static controller::config get_default_chain_configuration( const fc::path& p ) { controller::config cfg; cfg.blocks_dir = p / config::default_blocks_dir_name; cfg.state_dir = p / config::default_state_dir_name; cfg.state_size = 1024*1024*8; cfg.state_guard_size = 0; cfg.reversible_cache_size = 1024*1024*8; cfg.reversible_guard_size = 0; cfg.contracts_console = true; cfg.genesis.initial_timestamp = fc::time_point::from_iso_string("2020-01-01T00:00:00.000"); cfg.genesis.initial_key = base_tester::get_public_key( config::system_account_name, "active" ); for(int i = 0; i < boost::unit_test::framework::master_test_suite().argc; ++i) { if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wavm")) cfg.wasm_runtime = chain::wasm_interface::vm_type::wavm; else if(boost::unit_test::framework::master_test_suite().argv[i] == std::string("--wabt")) cfg.wasm_runtime = chain::wasm_interface::vm_type::wabt; } return cfg; } void init( bool bootstrap = true ) { FC_ASSERT( !chain, "chain is already up" ); auto cfg = get_default_chain_configuration( tempdir.path() ); cfg.sender_bypass_whiteblacklist = sender_bypass_whiteblacklist; cfg.actor_whitelist = actor_whitelist; cfg.actor_blacklist = actor_blacklist; cfg.contract_whitelist = contract_whitelist; cfg.contract_blacklist = contract_blacklist; cfg.action_blacklist = action_blacklist; chain.emplace(cfg); wdump((last_produced_block)); chain->set_last_produced_block_map( last_produced_block ); if( !bootstrap ) return; chain->create_accounts({N(actx.token), N(alice), N(bob), N(charlie)}); chain->set_code(N(actx.token), actx_token_wast); chain->set_abi(N(actx.token), actx_token_abi); chain->push_action( N(actx.token), N(create), N(actx.token), mvo() ( "issuer", "actx.token" ) ( "maximum_supply", "1000000.00 TOK" ) ); chain->push_action( N(actx.token), N(issue), N(actx.token), mvo() ( "to", "actx.token" ) ( "quantity", "1000000.00 TOK" ) ( "memo", "issue" ) ); chain->produce_blocks(); } void shutdown() { FC_ASSERT( chain.valid(), "chain is not up" ); last_produced_block = chain->get_last_produced_block_map(); wdump((last_produced_block)); chain.reset(); } transaction_trace_ptr transfer( account_name from, account_name to, string quantity = "1.00 TOK" ) { return chain->push_action( N(actx.token), N(transfer), from, mvo() ( "from", from ) ( "to", to ) ( "quantity", quantity ) ( "memo", "" ) ); } fc::temp_directory tempdir; // Must come before chain fc::optional<Tester> chain; flat_set<account_name> sender_bypass_whiteblacklist; flat_set<account_name> actor_whitelist; flat_set<account_name> actor_blacklist; flat_set<account_name> contract_whitelist; flat_set<account_name> contract_blacklist; flat_set< pair<account_name, action_name> > action_blacklist; map<account_name, block_id_type> last_produced_block; }; struct transfer_args { account_name from; account_name to; asset quantity; string memo; }; FC_REFLECT( transfer_args, (from)(to)(quantity)(memo) ) BOOST_AUTO_TEST_SUITE(whitelist_blacklist_tests) BOOST_AUTO_TEST_CASE( actor_whitelist ) { try { whitelist_blacklist_tester<> test; test.actor_whitelist = {config::system_account_name, N(actx.token), N(alice)}; test.init(); test.transfer( N(actx.token), N(alice), "1000.00 TOK" ); test.transfer( N(alice), N(bob), "100.00 TOK" ); BOOST_CHECK_EXCEPTION( test.transfer( N(bob), N(alice) ), actor_whitelist_exception, fc_exception_message_is("authorizing actor(s) in transaction are not on the actor whitelist: [\"bob\"]") ); signed_transaction trx; trx.actions.emplace_back( vector<permission_level>{{N(alice),config::active_name}, {N(bob),config::active_name}}, N(actx.token), N(transfer), fc::raw::pack(transfer_args{ .from = N(alice), .to = N(bob), .quantity = asset::from_string("10.00 TOK"), .memo = "" }) ); test.chain->set_transaction_headers(trx); trx.sign( test.chain->get_private_key( N(alice), "active" ), test.chain->control->get_chain_id() ); trx.sign( test.chain->get_private_key( N(bob), "active" ), test.chain->control->get_chain_id() ); BOOST_CHECK_EXCEPTION( test.chain->push_transaction( trx ), actor_whitelist_exception, fc_exception_message_starts_with("authorizing actor(s) in transaction are not on the actor whitelist: [\"bob\"]") ); test.chain->produce_blocks(); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( actor_blacklist ) { try { whitelist_blacklist_tester<> test; test.actor_blacklist = {N(bob)}; test.init(); test.transfer( N(actx.token), N(alice), "1000.00 TOK" ); test.transfer( N(alice), N(bob), "100.00 TOK" ); BOOST_CHECK_EXCEPTION( test.transfer( N(bob), N(alice) ), actor_blacklist_exception, fc_exception_message_starts_with("authorizing actor(s) in transaction are on the actor blacklist: [\"bob\"]") ); signed_transaction trx; trx.actions.emplace_back( vector<permission_level>{{N(alice),config::active_name}, {N(bob),config::active_name}}, N(actx.token), N(transfer), fc::raw::pack(transfer_args{ .from = N(alice), .to = N(bob), .quantity = asset::from_string("10.00 TOK"), .memo = "" }) ); test.chain->set_transaction_headers(trx); trx.sign( test.chain->get_private_key( N(alice), "active" ), test.chain->control->get_chain_id() ); trx.sign( test.chain->get_private_key( N(bob), "active" ), test.chain->control->get_chain_id() ); BOOST_CHECK_EXCEPTION( test.chain->push_transaction( trx ), actor_blacklist_exception, fc_exception_message_starts_with("authorizing actor(s) in transaction are on the actor blacklist: [\"bob\"]") ); test.chain->produce_blocks(); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( contract_whitelist ) { try { whitelist_blacklist_tester<> test; test.contract_whitelist = {config::system_account_name, N(actx.token), N(bob)}; test.init(); test.transfer( N(actx.token), N(alice), "1000.00 TOK" ); test.transfer( N(alice), N(actx.token) ); test.transfer( N(alice), N(bob) ); test.transfer( N(alice), N(charlie), "100.00 TOK" ); test.transfer( N(charlie), N(alice) ); test.chain->produce_blocks(); test.chain->set_code(N(bob), actx_token_wast); test.chain->set_abi(N(bob), actx_token_abi); test.chain->produce_blocks(); test.chain->set_code(N(charlie), actx_token_wast); test.chain->set_abi(N(charlie), actx_token_abi); test.chain->produce_blocks(); test.transfer( N(alice), N(bob) ); BOOST_CHECK_EXCEPTION( test.transfer( N(alice), N(charlie) ), contract_whitelist_exception, fc_exception_message_is("account 'charlie' is not on the contract whitelist") ); test.chain->push_action( N(bob), N(create), N(bob), mvo() ( "issuer", "bob" ) ( "maximum_supply", "1000000.00 CUR" ) ); BOOST_CHECK_EXCEPTION( test.chain->push_action( N(charlie), N(create), N(charlie), mvo() ( "issuer", "charlie" ) ( "maximum_supply", "1000000.00 CUR" ) ), contract_whitelist_exception, fc_exception_message_starts_with("account 'charlie' is not on the contract whitelist") ); test.chain->produce_blocks(); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( contract_blacklist ) { try { whitelist_blacklist_tester<> test; test.contract_blacklist = {N(charlie)}; test.init(); test.transfer( N(actx.token), N(alice), "1000.00 TOK" ); test.transfer( N(alice), N(actx.token) ); test.transfer( N(alice), N(bob) ); test.transfer( N(alice), N(charlie), "100.00 TOK" ); test.transfer( N(charlie), N(alice) ); test.chain->produce_blocks(); test.chain->set_code(N(bob), actx_token_wast); test.chain->set_abi(N(bob), actx_token_abi); test.chain->produce_blocks(); test.chain->set_code(N(charlie), actx_token_wast); test.chain->set_abi(N(charlie), actx_token_abi); test.chain->produce_blocks(); test.transfer( N(alice), N(bob) ); BOOST_CHECK_EXCEPTION( test.transfer( N(alice), N(charlie) ), contract_blacklist_exception, fc_exception_message_is("account 'charlie' is on the contract blacklist") ); test.chain->push_action( N(bob), N(create), N(bob), mvo() ( "issuer", "bob" ) ( "maximum_supply", "1000000.00 CUR" ) ); BOOST_CHECK_EXCEPTION( test.chain->push_action( N(charlie), N(create), N(charlie), mvo() ( "issuer", "charlie" ) ( "maximum_supply", "1000000.00 CUR" ) ), contract_blacklist_exception, fc_exception_message_starts_with("account 'charlie' is on the contract blacklist") ); test.chain->produce_blocks(); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( action_blacklist ) { try { whitelist_blacklist_tester<> test; test.contract_whitelist = {config::system_account_name, N(actx.token), N(bob), N(charlie)}; test.action_blacklist = {{N(charlie), N(create)}}; test.init(); test.transfer( N(actx.token), N(alice), "1000.00 TOK" ); test.chain->produce_blocks(); test.chain->set_code(N(bob), actx_token_wast); test.chain->set_abi(N(bob), actx_token_abi); test.chain->produce_blocks(); test.chain->set_code(N(charlie), actx_token_wast); test.chain->set_abi(N(charlie), actx_token_abi); test.chain->produce_blocks(); test.transfer( N(alice), N(bob) ); test.transfer( N(alice), N(charlie) ), test.chain->push_action( N(bob), N(create), N(bob), mvo() ( "issuer", "bob" ) ( "maximum_supply", "1000000.00 CUR" ) ); BOOST_CHECK_EXCEPTION( test.chain->push_action( N(charlie), N(create), N(charlie), mvo() ( "issuer", "charlie" ) ( "maximum_supply", "1000000.00 CUR" ) ), action_blacklist_exception, fc_exception_message_starts_with("action 'charlie::create' is on the action blacklist") ); test.chain->produce_blocks(); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( blacklist_eosio ) { try { whitelist_blacklist_tester<tester> tester1; tester1.init(); tester1.chain->produce_blocks(); tester1.chain->set_code(config::system_account_name, actx_token_wast); tester1.chain->produce_blocks(); tester1.shutdown(); tester1.contract_blacklist = {config::system_account_name}; tester1.init(false); whitelist_blacklist_tester<tester> tester2; tester2.init(false); while( tester2.chain->control->head_block_num() < tester1.chain->control->head_block_num() ) { auto b = tester1.chain->control->fetch_block_by_number( tester2.chain->control->head_block_num()+1 ); tester2.chain->push_block( b ); } tester1.chain->produce_blocks(2); while( tester2.chain->control->head_block_num() < tester1.chain->control->head_block_num() ) { auto b = tester1.chain->control->fetch_block_by_number( tester2.chain->control->head_block_num()+1 ); tester2.chain->push_block( b ); } } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( deferred_blacklist_failure ) { try { whitelist_blacklist_tester<tester> tester1; tester1.init(); tester1.chain->produce_blocks(); tester1.chain->set_code( N(bob), deferred_test_wast ); tester1.chain->set_abi( N(bob), deferred_test_abi ); tester1.chain->set_code( N(charlie), deferred_test_wast ); tester1.chain->set_abi( N(charlie), deferred_test_abi ); tester1.chain->produce_blocks(); tester1.chain->push_action( N(bob), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 0 ) ( "contract", "charlie" ) ( "payload", 10 ) ); tester1.chain->produce_blocks(2); tester1.shutdown(); tester1.contract_blacklist = {N(charlie)}; tester1.init(false); whitelist_blacklist_tester<tester> tester2; tester2.init(false); while( tester2.chain->control->head_block_num() < tester1.chain->control->head_block_num() ) { auto b = tester1.chain->control->fetch_block_by_number( tester2.chain->control->head_block_num()+1 ); tester2.chain->push_block( b ); } tester1.chain->push_action( N(bob), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 1 ) ( "contract", "charlie" ) ( "payload", 10 ) ); BOOST_CHECK_EXCEPTION( tester1.chain->produce_blocks(), fc::exception, fc_exception_message_is("account 'charlie' is on the contract blacklist") ); tester1.chain->produce_blocks(2, true); // Produce 2 empty blocks (other than onblock of course). while( tester2.chain->control->head_block_num() < tester1.chain->control->head_block_num() ) { auto b = tester1.chain->control->fetch_block_by_number( tester2.chain->control->head_block_num()+1 ); tester2.chain->push_block( b ); } } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( blacklist_onerror ) { try { whitelist_blacklist_tester<TESTER> tester1; tester1.init(); tester1.chain->produce_blocks(); tester1.chain->set_code( N(bob), deferred_test_wast ); tester1.chain->set_abi( N(bob), deferred_test_abi ); tester1.chain->set_code( N(charlie), deferred_test_wast ); tester1.chain->set_abi( N(charlie), deferred_test_abi ); tester1.chain->produce_blocks(); tester1.chain->push_action( N(bob), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 0 ) ( "contract", "charlie" ) ( "payload", 13 ) ); tester1.chain->produce_blocks(); tester1.shutdown(); tester1.action_blacklist = {{config::system_account_name, N(onerror)}}; tester1.init(false); tester1.chain->push_action( N(bob), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 0 ) ( "contract", "charlie" ) ( "payload", 13 ) ); BOOST_CHECK_EXCEPTION( tester1.chain->produce_blocks(), fc::exception, fc_exception_message_is("action 'eosio::onerror' is on the action blacklist") ); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( actor_blacklist_inline_deferred ) { try { whitelist_blacklist_tester<tester> tester1; tester1.init(); tester1.chain->produce_blocks(); tester1.chain->set_code( N(alice), deferred_test_wast ); tester1.chain->set_abi( N(alice), deferred_test_abi ); tester1.chain->set_code( N(bob), deferred_test_wast ); tester1.chain->set_abi( N(bob), deferred_test_abi ); tester1.chain->set_code( N(charlie), deferred_test_wast ); tester1.chain->set_abi( N(charlie), deferred_test_abi ); tester1.chain->produce_blocks(); auto auth = authority(eosio::testing::base_tester::get_public_key("alice", "active")); auth.accounts.push_back( permission_level_weight{{N(alice), config::eosio_code_name}, 1} ); tester1.chain->push_action( N(eosio), N(updateauth), N(alice), mvo() ( "account", "alice" ) ( "permission", "active" ) ( "parent", "owner" ) ( "auth", auth ) ); auth = authority(eosio::testing::base_tester::get_public_key("bob", "active")); auth.accounts.push_back( permission_level_weight{{N(alice), config::eosio_code_name}, 1} ); auth.accounts.push_back( permission_level_weight{{N(bob), config::eosio_code_name}, 1} ); tester1.chain->push_action( N(eosio), N(updateauth), N(bob), mvo() ( "account", "bob" ) ( "permission", "active" ) ( "parent", "owner" ) ( "auth", auth ) ); auth = authority(eosio::testing::base_tester::get_public_key("charlie", "active")); auth.accounts.push_back( permission_level_weight{{N(charlie), config::eosio_code_name}, 1} ); tester1.chain->push_action( N(eosio), N(updateauth), N(charlie), mvo() ( "account", "charlie" ) ( "permission", "active" ) ( "parent", "owner" ) ( "auth", auth ) ); tester1.chain->produce_blocks(2); tester1.shutdown(); tester1.actor_blacklist = {N(bob)}; tester1.init(false); whitelist_blacklist_tester<tester> tester2; tester2.init(false); while( tester2.chain->control->head_block_num() < tester1.chain->control->head_block_num() ) { auto b = tester1.chain->control->fetch_block_by_number( tester2.chain->control->head_block_num()+1 ); tester2.chain->push_block( b ); } auto log_trxs = [&]( const transaction_trace_ptr& t) { if( !t || t->action_traces.size() == 0 ) return; const auto& act = t->action_traces[0].act; if( act.account == N(eosio) && act.name == N(onblock) ) return; if( t->receipt && t->receipt->status == transaction_receipt::executed ) { wlog( "${trx_type} ${id} executed (first action is ${code}::${action})", ("trx_type", t->scheduled ? "scheduled trx" : "trx")("id", t->id)("code", act.account)("action", act.name) ); } else { wlog( "${trx_type} ${id} failed (first action is ${code}::${action})", ("trx_type", t->scheduled ? "scheduled trx" : "trx")("id", t->id)("code", act.account)("action", act.name) ); } }; auto c1 = tester1.chain->control->applied_transaction.connect( log_trxs ); // Disallow inline actions authorized by actor in blacklist BOOST_CHECK_EXCEPTION( tester1.chain->push_action( N(alice), N(inlinecall), N(alice), mvo() ( "contract", "alice" ) ( "authorizer", "bob" ) ( "payload", 10 ) ), fc::exception, fc_exception_message_is("authorizing actor(s) in transaction are on the actor blacklist: [\"bob\"]") ); auto num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(0, num_deferred); // Schedule a deferred transaction authorized by charlie@active tester1.chain->push_action( N(charlie), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 0 ) ( "contract", "charlie" ) ( "payload", 10 ) ); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(1, num_deferred); // Do not allow that deferred transaction to retire yet tester1.chain->finish_block(); tester1.chain->produce_blocks(2, true); // Produce 2 empty blocks (other than onblock of course). num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(1, num_deferred); c1.disconnect(); while( tester2.chain->control->head_block_num() < tester1.chain->control->head_block_num() ) { auto b = tester1.chain->control->fetch_block_by_number( tester2.chain->control->head_block_num()+1 ); tester2.chain->push_block( b ); } tester1.shutdown(); tester1.actor_blacklist = {N(bob), N(charlie)}; tester1.init(false); auto c2 = tester1.chain->control->applied_transaction.connect( log_trxs ); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(1, num_deferred); // With charlie now in the actor blacklist, retiring the previously scheduled deferred transaction should now not be possible. BOOST_CHECK_EXCEPTION( tester1.chain->produce_blocks(), fc::exception, fc_exception_message_is("authorizing actor(s) in transaction are on the actor blacklist: [\"charlie\"]") ); // With charlie now in the actor blacklist, it is now not possible to schedule a deferred transaction authorized by charlie@active BOOST_CHECK_EXCEPTION( tester1.chain->push_action( N(charlie), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 1 ) ( "contract", "charlie" ) ( "payload", 10 ) ), fc::exception, fc_exception_message_is("authorizing actor(s) in transaction are on the actor blacklist: [\"charlie\"]") ); c2.disconnect(); } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_CASE( blacklist_sender_bypass ) { try { whitelist_blacklist_tester<tester> tester1; tester1.init(); tester1.chain->produce_blocks(); tester1.chain->set_code( N(alice), deferred_test_wast ); tester1.chain->set_abi( N(alice), deferred_test_abi ); tester1.chain->set_code( N(bob), deferred_test_wast ); tester1.chain->set_abi( N(bob), deferred_test_abi ); tester1.chain->set_code( N(charlie), deferred_test_wast ); tester1.chain->set_abi( N(charlie), deferred_test_abi ); tester1.chain->produce_blocks(); auto auth = authority(eosio::testing::base_tester::get_public_key("alice", "active")); auth.accounts.push_back( permission_level_weight{{N(alice), config::eosio_code_name}, 1} ); tester1.chain->push_action( N(eosio), N(updateauth), N(alice), mvo() ( "account", "alice" ) ( "permission", "active" ) ( "parent", "owner" ) ( "auth", auth ) ); auth = authority(eosio::testing::base_tester::get_public_key("bob", "active")); auth.accounts.push_back( permission_level_weight{{N(bob), config::eosio_code_name}, 1} ); tester1.chain->push_action( N(eosio), N(updateauth), N(bob), mvo() ( "account", "bob" ) ( "permission", "active" ) ( "parent", "owner" ) ( "auth", auth ) ); auth = authority(eosio::testing::base_tester::get_public_key("charlie", "active")); auth.accounts.push_back( permission_level_weight{{N(charlie), config::eosio_code_name}, 1} ); tester1.chain->push_action( N(eosio), N(updateauth), N(charlie), mvo() ( "account", "charlie" ) ( "permission", "active" ) ( "parent", "owner" ) ( "auth", auth ) ); tester1.chain->produce_blocks(2); tester1.shutdown(); tester1.sender_bypass_whiteblacklist = {N(charlie)}; tester1.actor_blacklist = {N(bob), N(charlie)}; tester1.init(false); BOOST_CHECK_EXCEPTION( tester1.chain->push_action( N(bob), N(deferfunc), N(bob), mvo() ( "payload", 10 ) ), fc::exception, fc_exception_message_is("authorizing actor(s) in transaction are on the actor blacklist: [\"bob\"]") ); BOOST_CHECK_EXCEPTION( tester1.chain->push_action( N(charlie), N(deferfunc), N(charlie), mvo() ( "payload", 10 ) ), fc::exception, fc_exception_message_is("authorizing actor(s) in transaction are on the actor blacklist: [\"charlie\"]") ); auto num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(0, num_deferred); BOOST_CHECK_EXCEPTION( tester1.chain->push_action( N(bob), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 0 ) ( "contract", "bob" ) ( "payload", 10 ) ), fc::exception, fc_exception_message_is("authorizing actor(s) in transaction are on the actor blacklist: [\"bob\"]") ); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(0, num_deferred); // Schedule a deferred transaction authorized by charlie@active tester1.chain->push_action( N(charlie), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 0 ) ( "contract", "charlie" ) ( "payload", 10 ) ); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(1, num_deferred); // Retire the deferred transaction successfully despite charlie being on the actor blacklist. // This is allowed due to the fact that the sender of the deferred transaction (also charlie) is in the sender bypass list. tester1.chain->produce_blocks(); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(0, num_deferred); // Schedule another deferred transaction authorized by charlie@active tester1.chain->push_action( N(charlie), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 1 ) ( "contract", "bob" ) ( "payload", 10 ) ); // Do not yet retire the deferred transaction tester1.chain->finish_block(); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(1, num_deferred); tester1.shutdown(); tester1.sender_bypass_whiteblacklist = {N(charlie)}; tester1.actor_blacklist = {N(bob), N(charlie)}; tester1.contract_blacklist = {N(bob)}; // Add bob to the contract blacklist as well tester1.init(false); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(1, num_deferred); // Now retire the deferred transaction successfully despite charlie being on both the actor blacklist and bob being on the contract blacklist // This is allowed due to the fact that the sender of the deferred transaction (also charlie) is in the sender bypass list. tester1.chain->produce_blocks(); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(0, num_deferred); tester1.chain->push_action( N(alice), N(defercall), N(alice), mvo() ( "payer", "alice" ) ( "sender_id", 0 ) ( "contract", "bob" ) ( "payload", 10 ) ); num_deferred = tester1.chain->control->db().get_index<generated_transaction_multi_index,by_trx_id>().size(); BOOST_REQUIRE_EQUAL(1, num_deferred); // Ensure that if there if the sender is not on the sender bypass list, then the contract blacklist is enforced. BOOST_CHECK_EXCEPTION( tester1.chain->produce_blocks(), fc::exception, fc_exception_message_is("account 'bob' is on the contract blacklist") ); whitelist_blacklist_tester<tester> tester2; tester2.init(false); while( tester2.chain->control->head_block_num() < tester1.chain->control->head_block_num() ) { auto b = tester1.chain->control->fetch_block_by_number( tester2.chain->control->head_block_num()+1 ); tester2.chain->push_block( b ); } } FC_LOG_AND_RETHROW() } BOOST_AUTO_TEST_SUITE_END()
/**************************************************************************** * * Copyright (c) 2018-2021 PX4 Development Team. 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 PX4 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. * ****************************************************************************/ #pragma once #include <drivers/drv_hrt.h> #include <lib/conversion/rotation.h> #include <uORB/PublicationMulti.hpp> #include <uORB/topics/sensor_gyro.h> #include <uORB/topics/sensor_gyro_fifo.h> class PX4Gyroscope { public: PX4Gyroscope(uint32_t device_id, enum Rotation rotation = ROTATION_NONE); ~PX4Gyroscope(); uint32_t get_device_id() const { return _device_id; } int32_t get_max_rate_hz() const { return math::constrain(_imu_gyro_rate_max, 100, 4000); } void set_device_id(uint32_t device_id) { _device_id = device_id; } void set_device_type(uint8_t devtype); void set_error_count(uint32_t error_count) { _error_count = error_count; } void increase_error_count() { _error_count++; } void set_range(float range) { _range = range; } void set_scale(float scale) { _scale = scale; } void set_temperature(float temperature) { _temperature = temperature; } void update(const hrt_abstime &timestamp_sample, float x, float y, float z); void updateFIFO(sensor_gyro_fifo_s &sample); int get_instance() { return _sensor_pub.get_instance(); }; private: uORB::PublicationMulti<sensor_gyro_s> _sensor_pub{ORB_ID(sensor_gyro)}; uORB::PublicationMulti<sensor_gyro_fifo_s> _sensor_fifo_pub{ORB_ID(sensor_gyro_fifo)}; uint32_t _device_id{0}; const enum Rotation _rotation; int32_t _imu_gyro_rate_max{0}; float _range{math::radians(2000.f)}; float _scale{1.f}; float _temperature{NAN}; uint32_t _error_count{0}; int16_t _last_sample[3] {}; };
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Copyright (c) 2011-2012 Litecoin Developers // Copyright (c) 2013 DonCoin Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "db.h" #include "util.h" #include "main.h" #include <boost/version.hpp> #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #ifndef WIN32 #include "sys/stat.h" #endif using namespace std; using namespace boost; unsigned int nWalletDBUpdated; // // CDB // CDBEnv bitdb; void CDBEnv::EnvShutdown() { if (!fDbEnvInit) return; fDbEnvInit = false; try { dbenv.close(0); } catch (const DbException& e) { printf("EnvShutdown exception: %s (%d)\n", e.what(), e.get_errno()); } DbEnv(0).remove(GetDataDir().string().c_str(), 0); } CDBEnv::CDBEnv() : dbenv(0) { } CDBEnv::~CDBEnv() { EnvShutdown(); } void CDBEnv::Close() { EnvShutdown(); } bool CDBEnv::Open(boost::filesystem::path pathEnv_) { if (fDbEnvInit) return true; if (fShutdown) return false; pathEnv = pathEnv_; filesystem::path pathDataDir = pathEnv; filesystem::path pathLogDir = pathDataDir / "database"; filesystem::create_directory(pathLogDir); filesystem::path pathErrorFile = pathDataDir / "db.log"; printf("dbenv.open LogDir=%s ErrorFile=%s\n", pathLogDir.string().c_str(), pathErrorFile.string().c_str()); unsigned int nEnvFlags = 0; if (GetBoolArg("-privdb", true)) nEnvFlags |= DB_PRIVATE; int nDbCache = GetArg("-dbcache", 25); dbenv.set_lg_dir(pathLogDir.string().c_str()); dbenv.set_cachesize(nDbCache / 1024, (nDbCache % 1024)*1048576, 1); dbenv.set_lg_bsize(1048576); dbenv.set_lg_max(10485760); dbenv.set_lk_max_locks(10000); dbenv.set_lk_max_objects(10000); dbenv.set_errfile(fopen(pathErrorFile.string().c_str(), "a")); /// debug dbenv.set_flags(DB_AUTO_COMMIT, 1); dbenv.set_flags(DB_TXN_WRITE_NOSYNC, 1); dbenv.log_set_config(DB_LOG_AUTO_REMOVE, 1); int ret = dbenv.open(pathDataDir.string().c_str(), DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_THREAD | DB_RECOVER | nEnvFlags, S_IRUSR | S_IWUSR); if (ret > 0) return error("CDB() : error %d opening database environment", ret); fDbEnvInit = true; return true; } void CDBEnv::CheckpointLSN(std::string strFile) { dbenv.txn_checkpoint(0, 0, 0); dbenv.lsn_reset(strFile.c_str(), 0); } CDB::CDB(const char *pszFile, const char* pszMode) : pdb(NULL), activeTxn(NULL) { int ret; if (pszFile == NULL) return; fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w')); bool fCreate = strchr(pszMode, 'c'); unsigned int nFlags = DB_THREAD; if (fCreate) nFlags |= DB_CREATE; { LOCK(bitdb.cs_db); if (!bitdb.Open(GetDataDir())) throw runtime_error("env open failed"); strFile = pszFile; ++bitdb.mapFileUseCount[strFile]; pdb = bitdb.mapDb[strFile]; if (pdb == NULL) { pdb = new Db(&bitdb.dbenv, 0); ret = pdb->open(NULL, // Txn pointer pszFile, // Filename "main", // Logical db name DB_BTREE, // Database type nFlags, // Flags 0); if (ret > 0) { delete pdb; pdb = NULL; { LOCK(bitdb.cs_db); --bitdb.mapFileUseCount[strFile]; } strFile = ""; throw runtime_error(strprintf("CDB() : can't open database file %s, error %d", pszFile, ret)); } if (fCreate && !Exists(string("version"))) { bool fTmp = fReadOnly; fReadOnly = false; WriteVersion(CLIENT_VERSION); fReadOnly = fTmp; } bitdb.mapDb[strFile] = pdb; } } } static bool IsChainFile(std::string strFile) { if (strFile == "blkindex.dat") return true; return false; } void CDB::Close() { if (!pdb) return; if (activeTxn) activeTxn->abort(); activeTxn = NULL; pdb = NULL; // Flush database activity from memory pool to disk log unsigned int nMinutes = 0; if (fReadOnly) nMinutes = 1; if (IsChainFile(strFile)) nMinutes = 2; if (IsChainFile(strFile) && IsInitialBlockDownload()) nMinutes = 5; bitdb.dbenv.txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100)*1024 : 0, nMinutes, 0); { LOCK(bitdb.cs_db); --bitdb.mapFileUseCount[strFile]; } } void CDBEnv::CloseDb(const string& strFile) { { LOCK(cs_db); if (mapDb[strFile] != NULL) { // Close the database handle Db* pdb = mapDb[strFile]; pdb->close(0); delete pdb; mapDb[strFile] = NULL; } } } bool CDB::Rewrite(const string& strFile, const char* pszSkip) { while (!fShutdown) { { LOCK(bitdb.cs_db); if (!bitdb.mapFileUseCount.count(strFile) || bitdb.mapFileUseCount[strFile] == 0) { // Flush log data to the dat file bitdb.CloseDb(strFile); bitdb.CheckpointLSN(strFile); bitdb.mapFileUseCount.erase(strFile); bool fSuccess = true; printf("Rewriting %s...\n", strFile.c_str()); string strFileRes = strFile + ".rewrite"; { // surround usage of db with extra {} CDB db(strFile.c_str(), "r"); Db* pdbCopy = new Db(&bitdb.dbenv, 0); int ret = pdbCopy->open(NULL, // Txn pointer strFileRes.c_str(), // Filename "main", // Logical db name DB_BTREE, // Database type DB_CREATE, // Flags 0); if (ret > 0) { printf("Cannot create database file %s\n", strFileRes.c_str()); fSuccess = false; } Dbc* pcursor = db.GetCursor(); if (pcursor) while (fSuccess) { CDataStream ssKey(SER_DISK, CLIENT_VERSION); CDataStream ssValue(SER_DISK, CLIENT_VERSION); int ret = db.ReadAtCursor(pcursor, ssKey, ssValue, DB_NEXT); if (ret == DB_NOTFOUND) { pcursor->close(); break; } else if (ret != 0) { pcursor->close(); fSuccess = false; break; } if (pszSkip && strncmp(&ssKey[0], pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0) continue; if (strncmp(&ssKey[0], "\x07version", 8) == 0) { // Update version: ssValue.clear(); ssValue << CLIENT_VERSION; } Dbt datKey(&ssKey[0], ssKey.size()); Dbt datValue(&ssValue[0], ssValue.size()); int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERWRITE); if (ret2 > 0) fSuccess = false; } if (fSuccess) { db.Close(); bitdb.CloseDb(strFile); if (pdbCopy->close(0)) fSuccess = false; delete pdbCopy; } } if (fSuccess) { Db dbA(&bitdb.dbenv, 0); if (dbA.remove(strFile.c_str(), NULL, 0)) fSuccess = false; Db dbB(&bitdb.dbenv, 0); if (dbB.rename(strFileRes.c_str(), NULL, strFile.c_str(), 0)) fSuccess = false; } if (!fSuccess) printf("Rewriting of %s FAILED!\n", strFileRes.c_str()); return fSuccess; } } Sleep(100); } return false; } void CDBEnv::Flush(bool fShutdown) { int64 nStart = GetTimeMillis(); // Flush log data to the actual data file // on all files that are not in use printf("Flush(%s)%s\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started"); if (!fDbEnvInit) return; { LOCK(cs_db); map<string, int>::iterator mi = mapFileUseCount.begin(); while (mi != mapFileUseCount.end()) { string strFile = (*mi).first; int nRefCount = (*mi).second; printf("%s refcount=%d\n", strFile.c_str(), nRefCount); if (nRefCount == 0) { // Move log data to the dat file CloseDb(strFile); printf("%s checkpoint\n", strFile.c_str()); dbenv.txn_checkpoint(0, 0, 0); if (!IsChainFile(strFile) || fDetachDB) { printf("%s detach\n", strFile.c_str()); dbenv.lsn_reset(strFile.c_str(), 0); } printf("%s closed\n", strFile.c_str()); mapFileUseCount.erase(mi++); } else mi++; } printf("DBFlush(%s)%s ended %15"PRI64d"ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart); if (fShutdown) { char** listp; if (mapFileUseCount.empty()) { dbenv.log_archive(&listp, DB_ARCH_REMOVE); Close(); } } } } // // CTxDB // bool CTxDB::ReadTxIndex(uint256 hash, CTxIndex& txindex) { assert(!fClient); txindex.SetNull(); return Read(make_pair(string("tx"), hash), txindex); } bool CTxDB::UpdateTxIndex(uint256 hash, const CTxIndex& txindex) { assert(!fClient); return Write(make_pair(string("tx"), hash), txindex); } bool CTxDB::AddTxIndex(const CTransaction& tx, const CDiskTxPos& pos, int nHeight) { assert(!fClient); // Add to tx index uint256 hash = tx.GetHash(); CTxIndex txindex(pos, tx.vout.size()); return Write(make_pair(string("tx"), hash), txindex); } bool CTxDB::EraseTxIndex(const CTransaction& tx) { assert(!fClient); uint256 hash = tx.GetHash(); return Erase(make_pair(string("tx"), hash)); } bool CTxDB::ContainsTx(uint256 hash) { assert(!fClient); return Exists(make_pair(string("tx"), hash)); } bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx, CTxIndex& txindex) { assert(!fClient); tx.SetNull(); if (!ReadTxIndex(hash, txindex)) return false; return (tx.ReadFromDisk(txindex.pos)); } bool CTxDB::ReadDiskTx(uint256 hash, CTransaction& tx) { CTxIndex txindex; return ReadDiskTx(hash, tx, txindex); } bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx, CTxIndex& txindex) { return ReadDiskTx(outpoint.hash, tx, txindex); } bool CTxDB::ReadDiskTx(COutPoint outpoint, CTransaction& tx) { CTxIndex txindex; return ReadDiskTx(outpoint.hash, tx, txindex); } bool CTxDB::WriteBlockIndex(const CDiskBlockIndex& blockindex) { return Write(make_pair(string("blockindex"), blockindex.GetBlockHash()), blockindex); } bool CTxDB::ReadHashBestChain(uint256& hashBestChain) { return Read(string("hashBestChain"), hashBestChain); } bool CTxDB::WriteHashBestChain(uint256 hashBestChain) { return Write(string("hashBestChain"), hashBestChain); } bool CTxDB::ReadBestInvalidWork(CBigNum& bnBestInvalidWork) { return Read(string("bnBestInvalidWork"), bnBestInvalidWork); } bool CTxDB::WriteBestInvalidWork(CBigNum bnBestInvalidWork) { return Write(string("bnBestInvalidWork"), bnBestInvalidWork); } CBlockIndex static * InsertBlockIndex(uint256 hash) { if (hash == 0) return NULL; // Return existing map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) return (*mi).second; // Create new CBlockIndex* pindexNew = new CBlockIndex(); if (!pindexNew) throw runtime_error("LoadBlockIndex() : new CBlockIndex failed"); mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; pindexNew->phashBlock = &((*mi).first); return pindexNew; } bool CTxDB::LoadBlockIndex() { if (!LoadBlockIndexGuts()) return false; if (fRequestShutdown) return true; // Calculate bnChainWork vector<pair<int, CBlockIndex*> > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); BOOST_FOREACH(const PAIRTYPE(uint256, CBlockIndex*)& item, mapBlockIndex) { CBlockIndex* pindex = item.second; vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex)); } sort(vSortedByHeight.begin(), vSortedByHeight.end()); BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight) { CBlockIndex* pindex = item.second; pindex->bnChainWork = (pindex->pprev ? pindex->pprev->bnChainWork : 0) + pindex->GetBlockWork(); } // Load hashBestChain pointer to end of best chain if (!ReadHashBestChain(hashBestChain)) { if (pindexGenesisBlock == NULL) return true; return error("CTxDB::LoadBlockIndex() : hashBestChain not loaded"); } if (!mapBlockIndex.count(hashBestChain)) return error("CTxDB::LoadBlockIndex() : hashBestChain not found in the block index"); pindexBest = mapBlockIndex[hashBestChain]; nBestHeight = pindexBest->nHeight; bnBestChainWork = pindexBest->bnChainWork; printf("LoadBlockIndex(): hashBestChain=%s height=%d date=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); // Load bnBestInvalidWork, OK if it doesn't exist ReadBestInvalidWork(bnBestInvalidWork); // Verify blocks in the best chain int nCheckLevel = GetArg("-checklevel", 1); int nCheckDepth = GetArg( "-checkblocks", 2500); if (nCheckDepth == 0) nCheckDepth = 1000000000; // suffices until the year 19000 if (nCheckDepth > nBestHeight) nCheckDepth = nBestHeight; printf("Verifying last %i blocks at level %i\n", nCheckDepth, nCheckLevel); CBlockIndex* pindexFork = NULL; map<pair<unsigned int, unsigned int>, CBlockIndex*> mapBlockPos; for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev) { if (fRequestShutdown || pindex->nHeight < nBestHeight-nCheckDepth) break; CBlock block; if (!block.ReadFromDisk(pindex)) return error("LoadBlockIndex() : block.ReadFromDisk failed"); // check level 1: verify block validity if (nCheckLevel>0 && !block.CheckBlock()) { printf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str()); pindexFork = pindex->pprev; } // check level 2: verify transaction index validity if (nCheckLevel>1) { pair<unsigned int, unsigned int> pos = make_pair(pindex->nFile, pindex->nBlockPos); mapBlockPos[pos] = pindex; BOOST_FOREACH(const CTransaction &tx, block.vtx) { uint256 hashTx = tx.GetHash(); CTxIndex txindex; if (ReadTxIndex(hashTx, txindex)) { // check level 3: checker transaction hashes if (nCheckLevel>2 || pindex->nFile != txindex.pos.nFile || pindex->nBlockPos != txindex.pos.nBlockPos) { // either an error or a duplicate transaction CTransaction txFound; if (!txFound.ReadFromDisk(txindex.pos)) { printf("LoadBlockIndex() : *** cannot read mislocated transaction %s\n", hashTx.ToString().c_str()); pindexFork = pindex->pprev; } else if (txFound.GetHash() != hashTx) // not a duplicate tx { printf("LoadBlockIndex(): *** invalid tx position for %s\n", hashTx.ToString().c_str()); pindexFork = pindex->pprev; } } // check level 4: check whether spent txouts were spent within the main chain unsigned int nOutput = 0; if (nCheckLevel>3) { BOOST_FOREACH(const CDiskTxPos &txpos, txindex.vSpent) { if (!txpos.IsNull()) { pair<unsigned int, unsigned int> posFind = make_pair(txpos.nFile, txpos.nBlockPos); if (!mapBlockPos.count(posFind)) { printf("LoadBlockIndex(): *** found bad spend at %d, hashBlock=%s, hashTx=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str(), hashTx.ToString().c_str()); pindexFork = pindex->pprev; } // check level 6: check whether spent txouts were spent by a valid transaction that consume them if (nCheckLevel>5) { CTransaction txSpend; if (!txSpend.ReadFromDisk(txpos)) { printf("LoadBlockIndex(): *** cannot read spending transaction of %s:%i from disk\n", hashTx.ToString().c_str(), nOutput); pindexFork = pindex->pprev; } else if (!txSpend.CheckTransaction()) { printf("LoadBlockIndex(): *** spending transaction of %s:%i is invalid\n", hashTx.ToString().c_str(), nOutput); pindexFork = pindex->pprev; } else { bool fFound = false; BOOST_FOREACH(const CTxIn &txin, txSpend.vin) if (txin.prevout.hash == hashTx && txin.prevout.n == nOutput) fFound = true; if (!fFound) { printf("LoadBlockIndex(): *** spending transaction of %s:%i does not spend it\n", hashTx.ToString().c_str(), nOutput); pindexFork = pindex->pprev; } } } } nOutput++; } } } // check level 5: check whether all prevouts are marked spent if (nCheckLevel>4) { BOOST_FOREACH(const CTxIn &txin, tx.vin) { CTxIndex txindex; if (ReadTxIndex(txin.prevout.hash, txindex)) if (txindex.vSpent.size()-1 < txin.prevout.n || txindex.vSpent[txin.prevout.n].IsNull()) { printf("LoadBlockIndex(): *** found unspent prevout %s:%i in %s\n", txin.prevout.hash.ToString().c_str(), txin.prevout.n, hashTx.ToString().c_str()); pindexFork = pindex->pprev; } } } } } } if (pindexFork && !fRequestShutdown) { // Reorg back to the fork printf("LoadBlockIndex() : *** moving best chain pointer back to block %d\n", pindexFork->nHeight); CBlock block; if (!block.ReadFromDisk(pindexFork)) return error("LoadBlockIndex() : block.ReadFromDisk failed"); CTxDB txdb; block.SetBestChain(txdb, pindexFork); } return true; } bool CTxDB::LoadBlockIndexGuts() { // Get database cursor Dbc* pcursor = GetCursor(); if (!pcursor) return false; // Load mapBlockIndex unsigned int fFlags = DB_SET_RANGE; loop { // Read next record CDataStream ssKey(SER_DISK, CLIENT_VERSION); if (fFlags == DB_SET_RANGE) ssKey << make_pair(string("blockindex"), uint256(0)); CDataStream ssValue(SER_DISK, CLIENT_VERSION); int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags); fFlags = DB_NEXT; if (ret == DB_NOTFOUND) break; else if (ret != 0) return false; // Unserialize try { string strType; ssKey >> strType; if (strType == "blockindex" && !fRequestShutdown) { CDiskBlockIndex diskindex; ssValue >> diskindex; // Construct block index object CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash()); pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev); pindexNew->pnext = InsertBlockIndex(diskindex.hashNext); pindexNew->nFile = diskindex.nFile; pindexNew->nBlockPos = diskindex.nBlockPos; pindexNew->nHeight = diskindex.nHeight; pindexNew->nVersion = diskindex.nVersion; pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot; pindexNew->nTime = diskindex.nTime; pindexNew->nBits = diskindex.nBits; pindexNew->nNonce = diskindex.nNonce; // Watch for genesis block if (pindexGenesisBlock == NULL && diskindex.GetBlockHash() == hashGenesisBlock) pindexGenesisBlock = pindexNew; if (!pindexNew->CheckIndex()) return error("LoadBlockIndex() : CheckIndex failed at %d", pindexNew->nHeight); } else { break; // if shutdown requested or finished loading block index } } // try catch (std::exception &e) { return error("%s() : deserialize error", __PRETTY_FUNCTION__); } } pcursor->close(); return true; } // // CAddrDB // CAddrDB::CAddrDB() { pathAddr = GetDataDir() / "peers.dat"; } bool CAddrDB::Write(const CAddrMan& addr) { // Generate random temporary filename unsigned short randv = 0; RAND_bytes((unsigned char *)&randv, sizeof(randv)); std::string tmpfn = strprintf("peers.dat.%04x", randv); // serialize addresses, checksum data up to that point, then append csum CDataStream ssPeers(SER_DISK, CLIENT_VERSION); ssPeers << FLATDATA(pchMessageStart); ssPeers << addr; uint256 hash = Hash(ssPeers.begin(), ssPeers.end()); ssPeers << hash; // open temp output file, and associate with CAutoFile boost::filesystem::path pathTmp = GetDataDir() / tmpfn; FILE *file = fopen(pathTmp.string().c_str(), "wb"); CAutoFile fileout = CAutoFile(file, SER_DISK, CLIENT_VERSION); if (!fileout) return error("CAddrman::Write() : open failed"); // Write and commit header, data try { fileout << ssPeers; } catch (std::exception &e) { return error("CAddrman::Write() : I/O error"); } FileCommit(fileout); fileout.fclose(); // replace existing peers.dat, if any, with new peers.dat.XXXX if (!RenameOver(pathTmp, pathAddr)) return error("CAddrman::Write() : Rename-into-place failed"); return true; } bool CAddrDB::Read(CAddrMan& addr) { // open input file, and associate with CAutoFile FILE *file = fopen(pathAddr.string().c_str(), "rb"); CAutoFile filein = CAutoFile(file, SER_DISK, CLIENT_VERSION); if (!filein) return error("CAddrman::Read() : open failed"); // use file size to size memory buffer int fileSize = GetFilesize(filein); int dataSize = fileSize - sizeof(uint256); vector<unsigned char> vchData; vchData.resize(dataSize); uint256 hashIn; // read data and checksum from file try { filein.read((char *)&vchData[0], dataSize); filein >> hashIn; } catch (std::exception &e) { return error("CAddrman::Read() 2 : I/O error or stream data corrupted"); } filein.fclose(); CDataStream ssPeers(vchData, SER_DISK, CLIENT_VERSION); // verify stored checksum matches input data uint256 hashTmp = Hash(ssPeers.begin(), ssPeers.end()); if (hashIn != hashTmp) return error("CAddrman::Read() : checksum mismatch; data corrupted"); // de-serialize address data unsigned char pchMsgTmp[4]; try { ssPeers >> FLATDATA(pchMsgTmp); ssPeers >> addr; } catch (std::exception &e) { return error("CAddrman::Read() : I/O error or stream data corrupted"); } // finally, verify the network matches ours if (memcmp(pchMsgTmp, pchMessageStart, sizeof(pchMsgTmp))) return error("CAddrman::Read() : invalid network magic number"); return true; }
; A190619: Binary expansions of odd numbers with a single zero in their binary expansion. ; Submitted by Christian Krause ; 101,1011,1101,10111,11011,11101,101111,110111,111011,111101,1011111,1101111,1110111,1111011,1111101,10111111,11011111,11101111,11110111,11111011,11111101,101111111,110111111,111011111,111101111,111110111,111111011,111111101,1011111111,1101111111,1110111111,1111011111,1111101111,1111110111,1111111011,1111111101,10111111111,11011111111,11101111111,11110111111,11111011111,11111101111,11111110111,11111111011,11111111101,101111111111,110111111111,111011111111,111101111111,111110111111,111111011111 seq $0,164874 ; Triangle read by rows: T(1,1)=2; T(n,k)=2*T(n-1,k)+1, 1<=k<n; T(n,n)=2*(T(n-1,n-1)+1). seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2. sub $0,10 mul $0,10 add $0,101
; A293168: Partial sums of A054868. ; 0,1,2,3,4,5,6,8,9,10,11,13,14,16,18,19,20,21,22,24,25,27,29,30,31,33,35,36,38,39,40,42,43,44,45,47,48,50,52,53,54,56,58,59,61,62,63,65,66,68,70,71,73,74,75,77,79,80,81,83,84,86,88,90,91,92,93,95,96,98,100,101,102,104,106 mov $5,$0 mov $6,$0 lpb $6 mov $0,$5 sub $6,1 sub $0,$6 mov $2,$0 add $2,$0 mov $4,$0 lpb $2 gcd $2,32 mov $3,$4 lpb $4 div $3,2 sub $4,$3 lpe sub $2,1 lpe add $1,$4 lpe
;-Camera Position of Ship---------------------------------------------------------------------------------------------------------- UBnKxlo DB 0 ; INWK+0 UBnKxhi DB 0 ; there are hi medium low as some times these are 24 bit UBnKxsgn DB 0 ; INWK+2 UBnKylo DB 0 ; INWK+3 \ ylo UBnKyhi DB 0 ; INWK+4 \ yHi UBnKysgn DB 0 ; INWK +5 UBnKzlo DB 0 ; INWK +6 UBnKzhi DB 0 ; INWK +7 UBnKzsgn DB 0 ; INWK +8 ;; REDUDANT INWKxlo equ UBnKxlo ;; REDUDANT INWKxhi equ UBnKxhi ; there are hi medium low as some times these are 24 bit ;; REDUDANT INWKxsgn equ UBnKzsgn ; INWK+2 ;; REDUDANT INWKyLo equ UBnKylo ; INWK+3 \ ylo ;; REDUDANT INWKyhi equ UbnKyhi ; Y Hi??? ;; REDUDANT INWKysgn equ UBnKysgn ; INWK +5 ;; REDUDANT INWKzlo equ UBnKzlo ; INWK +6 ;; REDUDANT INWKzhi equ UBnKzhi ; INWK +7 ;; REDUDANT INWKzsgn equ UBnKzsgn ; INWK +8
db MACHOP ; pokedex id db 70 ; base hp db 80 ; base attack db 50 ; base defense db 35 ; base speed db 35 ; base special db FIGHTING ; species type 1 db FIGHTING ; species type 2 db 180 ; catch rate db 88 ; base exp yield INCBIN "pic/gsmon/machop.pic",0,1 ; 55, sprite dimensions dw MachopPicFront dw MachopPicBack ; attacks known at lvl 0 db LOW_KICK db LEER db 0 db 0 db 3 ; growth rate ; learnset tmlearn 1,5,6,8 tmlearn 9,10 tmlearn 17,18,19,20 tmlearn 26,27,28,31,32 tmlearn 34,35,38,40 tmlearn 44,48 tmlearn 50,54 db BANK(MachopPicFront)
#include "CompressorDXT1.h" #include "SingleColorLookup.h" #include "ClusterFit.h" #include "nvimage/ColorBlock.h" #include "nvimage/BlockDXT.h" #include "nvmath/Color.inl" #include "nvmath/Vector.inl" #include "nvmath/Fitting.h" #include "nvmath/ftoi.h" #include "nvcore/Utils.h" // swap #include <string.h> // memset #include <float.h> // FLT_MAX using namespace nv; /////////////////////////////////////////////////////////////////////////////////////////////////// // Color conversion functions. static const float midpoints5[32] = { 0.015686f, 0.047059f, 0.078431f, 0.111765f, 0.145098f, 0.176471f, 0.207843f, 0.241176f, 0.274510f, 0.305882f, 0.337255f, 0.370588f, 0.403922f, 0.435294f, 0.466667f, 0.5f, 0.533333f, 0.564706f, 0.596078f, 0.629412f, 0.662745f, 0.694118f, 0.725490f, 0.758824f, 0.792157f, 0.823529f, 0.854902f, 0.888235f, 0.921569f, 0.952941f, 0.984314f, 1.0f }; static const float midpoints6[64] = { 0.007843f, 0.023529f, 0.039216f, 0.054902f, 0.070588f, 0.086275f, 0.101961f, 0.117647f, 0.133333f, 0.149020f, 0.164706f, 0.180392f, 0.196078f, 0.211765f, 0.227451f, 0.245098f, 0.262745f, 0.278431f, 0.294118f, 0.309804f, 0.325490f, 0.341176f, 0.356863f, 0.372549f, 0.388235f, 0.403922f, 0.419608f, 0.435294f, 0.450980f, 0.466667f, 0.482353f, 0.500000f, 0.517647f, 0.533333f, 0.549020f, 0.564706f, 0.580392f, 0.596078f, 0.611765f, 0.627451f, 0.643137f, 0.658824f, 0.674510f, 0.690196f, 0.705882f, 0.721569f, 0.737255f, 0.754902f, 0.772549f, 0.788235f, 0.803922f, 0.819608f, 0.835294f, 0.850980f, 0.866667f, 0.882353f, 0.898039f, 0.913725f, 0.929412f, 0.945098f, 0.960784f, 0.976471f, 0.992157f, 1.0f }; /*void init_tables() { for (int i = 0; i < 31; i++) { float f0 = float(((i+0) << 3) | ((i+0) >> 2)) / 255.0f; float f1 = float(((i+1) << 3) | ((i+1) >> 2)) / 255.0f; midpoints5[i] = (f0 + f1) * 0.5; } midpoints5[31] = 1.0f; for (int i = 0; i < 63; i++) { float f0 = float(((i+0) << 2) | ((i+0) >> 4)) / 255.0f; float f1 = float(((i+1) << 2) | ((i+1) >> 4)) / 255.0f; midpoints6[i] = (f0 + f1) * 0.5; } midpoints6[63] = 1.0f; }*/ static Color16 vector3_to_color16(const Vector3 & v) { // Truncate. uint r = ftoi_trunc(clamp(v.x * 31.0f, 0.0f, 31.0f)); uint g = ftoi_trunc(clamp(v.y * 63.0f, 0.0f, 63.0f)); uint b = ftoi_trunc(clamp(v.z * 31.0f, 0.0f, 31.0f)); // Round exactly according to 565 bit-expansion. r += (v.x > midpoints5[r]); g += (v.y > midpoints6[g]); b += (v.z > midpoints5[b]); return Color16((r << 11) | (g << 5) | b); } static Color32 bitexpand_color16_to_color32(Color16 c16) { Color32 c32; //c32.b = (c16.b << 3) | (c16.b >> 2); //c32.g = (c16.g << 2) | (c16.g >> 4); //c32.r = (c16.r << 3) | (c16.r >> 2); //c32.a = 0xFF; c32.u = ((c16.u << 3) & 0xf8) | ((c16.u << 5) & 0xfc00) | ((c16.u << 8) & 0xf80000); c32.u |= (c32.u >> 5) & 0x070007; c32.u |= (c32.u >> 6) & 0x000300; return c32; } /*static Color32 bitexpand_color16_to_color32(int r, int g, int b) { Color32 c32; c32.b = (b << 3) | (b >> 2); c32.g = (g << 2) | (g >> 4); c32.r = (r << 3) | (r >> 2); c32.a = 0xFF; return c32; }*/ static Color16 truncate_color32_to_color16(Color32 c32) { Color16 c16; c16.b = (c32.b >> 3); c16.g = (c32.g >> 2); c16.r = (c32.r >> 3); return c16; } /*inline Vector3 r5g6b5_to_vector3(int r, int g, int b) { Vector3 c; c.x = float((r << 3) | (r >> 2)); c.y = float((g << 2) | (g >> 4)); c.z = float((b << 3) | (b >> 2)); return c; }*/ inline Vector3 color_to_vector3(Color32 c) { const float scale = 1.0f / 255.0f; return Vector3(c.r * scale, c.g * scale, c.b * scale); } inline Color32 vector3_to_color(Vector3 v) { Color32 color; color.r = U8(ftoi_round(saturate(v.x) * 255)); color.g = U8(ftoi_round(saturate(v.y) * 255)); color.b = U8(ftoi_round(saturate(v.z) * 255)); color.a = 255; return color; } /////////////////////////////////////////////////////////////////////////////////////////////////// // Input block processing. inline static void color_block_to_vector_block(const ColorBlock & rgba, Vector3 block[16]) { for (int i = 0; i < 16; i++) { const Color32 c = rgba.color(i); block[i] = Vector3(c.r, c.g, c.b); } } // Find first valid color. static bool find_valid_color_rgb(const Vector3 * colors, const float * weights, int count, Vector3 * valid_color) { for (int i = 0; i < count; i++) { if (weights[i] > 0.0f) { *valid_color = colors[i]; return true; } } // No valid colors. return false; } static bool is_single_color_rgb(const Vector3 * colors, const float * weights, int count, Vector3 color) { for (int i = 0; i < count; i++) { if (weights[i] > 0.0f) { if (colors[i] != color) return false; } } return true; } // Find similar colors and combine them together. static int reduce_colors(const Vector4 * input_colors, const float * input_weights, Vector3 * colors, float * weights) { int n = 0; for (int i = 0; i < 16; i++) { Vector3 ci = input_colors[i].xyz(); float wi = input_weights[i]; if (wi > 0) { // Find matching color. int j; for (j = 0; j < n; j++) { if (equal(colors[j].x, ci.x) && equal(colors[j].y, ci.y) && equal(colors[j].z, ci.z)) { weights[j] += wi; break; } } // No match found. Add new color. if (j == n) { colors[n] = ci; weights[n] = wi; n++; } } } nvDebugCheck(n <= 16); return n; } /////////////////////////////////////////////////////////////////////////////////////////////////// // Error evaluation. // Different ways of estimating the error. /*static float evaluate_mse(const Vector3 & p, const Vector3 & c) { //return (square(p.x-c.x) * w2.x + square(p.y-c.y) * w2.y + square(p.z-c.z) * w2.z); Vector3 d = (p - c); return dot(d, d); }*/ static float evaluate_mse(const Vector3 & p, const Vector3 & c, const Vector3 & w) { //return (square(p.x-c.x) * w2.x + square(p.y-c.y) * w2.y + square(p.z-c.z) * w2.z); Vector3 d = (p - c) * w; return dot(d, d); } /*static float evaluate_mse(const Vector3 & p, const Vector3 & c, const Vector3 & w) { return ww.x * square(p.x-c.x) + ww.y * square(p.y-c.y) + ww.z * square(p.z-c.z); }*/ static int evaluate_mse(const Color32 & p, const Color32 & c) { return (square(int(p.r)-c.r) + square(int(p.g)-c.g) + square(int(p.b)-c.b)); } static float evaluate_mse(const Vector3 palette[4], const Vector3 & c, const Vector3 & w) { float e0 = evaluate_mse(palette[0], c, w); float e1 = evaluate_mse(palette[1], c, w); float e2 = evaluate_mse(palette[2], c, w); float e3 = evaluate_mse(palette[3], c, w); return min(min(e0, e1), min(e2, e3)); } static int evaluate_mse(const Color32 palette[4], const Color32 & c) { int e0 = evaluate_mse(palette[0], c); int e1 = evaluate_mse(palette[1], c); int e2 = evaluate_mse(palette[2], c); int e3 = evaluate_mse(palette[3], c); return min(min(e0, e1), min(e2, e3)); } // Returns MSE error in [0-255] range. static int evaluate_mse(const BlockDXT1 * output, Color32 color, int index) { Color32 palette[4]; output->evaluatePalette(palette, /*d3d9=*/false); return evaluate_mse(palette[index], color); } // Returns weighted MSE error in [0-255] range. static float evaluate_palette_error(Color32 palette[4], const Color32 * colors, const float * weights, int count) { float total = 0.0f; for (int i = 0; i < count; i++) { total += weights[i] * evaluate_mse(palette, colors[i]); } return total; } #if 0 static float evaluate_mse(const BlockDXT1 * output, const Vector3 colors[16]) { Color32 palette[4]; output->evaluatePalette(palette, /*d3d9=*/false); // convert palette to float. Vector3 vector_palette[4]; for (int i = 0; i < 4; i++) { vector_palette[i] = color_to_vector3(palette[i]); } // evaluate error for each index. float error = 0.0f; for (int i = 0; i < 16; i++) { int index = (output->indices >> (2*i)) & 3; // @@ Is this the right order? error += evaluate_mse(vector_palette[index], colors[i]); } return error; } #endif static float evaluate_mse(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, const BlockDXT1 * output) { Color32 palette[4]; output->evaluatePalette(palette, /*d3d9=*/false); // convert palette to float. Vector3 vector_palette[4]; for (int i = 0; i < 4; i++) { vector_palette[i] = color_to_vector3(palette[i]); } // evaluate error for each index. float error = 0.0f; for (int i = 0; i < 16; i++) { int index = (output->indices >> (2 * i)) & 3; error += input_weights[i] * evaluate_mse(vector_palette[index], input_colors[i].xyz(), color_weights); } return error; } /////////////////////////////////////////////////////////////////////////////////////////////////// // Palette evaluation. static void evaluate_palette4(Color32 palette[4]) { palette[2].r = (2 * palette[0].r + palette[1].r) / 3; palette[2].g = (2 * palette[0].g + palette[1].g) / 3; palette[2].b = (2 * palette[0].b + palette[1].b) / 3; palette[3].r = (2 * palette[1].r + palette[0].r) / 3; palette[3].g = (2 * palette[1].g + palette[0].g) / 3; palette[3].b = (2 * palette[1].b + palette[0].b) / 3; } static void evaluate_palette3(Color32 palette[4]) { palette[2].r = (palette[0].r + palette[1].r) / 2; palette[2].g = (palette[0].g + palette[1].g) / 2; palette[2].b = (palette[0].b + palette[1].b) / 2; palette[3].r = 0; palette[3].g = 0; palette[3].b = 0; } static void evaluate_palette(Color16 c0, Color16 c1, Color32 palette[4]) { palette[0] = bitexpand_color16_to_color32(c0); palette[1] = bitexpand_color16_to_color32(c1); if (c0.u > c1.u) { evaluate_palette4(palette); } else { evaluate_palette3(palette); } } static void evaluate_palette(Color16 c0, Color16 c1, Vector3 palette[4]) { Color32 palette32[4]; evaluate_palette(c0, c1, palette32); for (int i = 0; i < 4; i++) { palette[i] = color_to_vector3(palette32[i]); } } static void evaluate_palette3(Color16 c0, Color16 c1, Vector3 palette[4]) { nvDebugCheck(c0.u > c1.u); Color32 palette32[4]; evaluate_palette(c0, c1, palette32); for (int i = 0; i < 4; i++) { palette[i] = color_to_vector3(palette32[i]); } } static uint compute_indices4(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 palette[4]) { uint indices = 0; for (int i = 0; i < 16; i++) { float d0 = evaluate_mse(palette[0], input_colors[i].xyz(), color_weights); float d1 = evaluate_mse(palette[1], input_colors[i].xyz(), color_weights); float d2 = evaluate_mse(palette[2], input_colors[i].xyz(), color_weights); float d3 = evaluate_mse(palette[3], input_colors[i].xyz(), color_weights); uint b0 = d0 > d3; uint b1 = d1 > d2; uint b2 = d0 > d2; uint b3 = d1 > d3; uint b4 = d2 > d3; uint x0 = b1 & b2; uint x1 = b0 & b3; uint x2 = b0 & b4; indices |= (x2 | ((x0 | x1) << 1)) << (2 * i); } return indices; } static uint compute_indices(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 palette[4]) { uint indices = 0; for (int i = 0; i < 16; i++) { float d0 = evaluate_mse(palette[0], input_colors[i].xyz(), color_weights); float d1 = evaluate_mse(palette[1], input_colors[i].xyz(), color_weights); float d2 = evaluate_mse(palette[2], input_colors[i].xyz(), color_weights); float d3 = evaluate_mse(palette[3], input_colors[i].xyz(), color_weights); uint index; if (d0 < d1 && d0 < d2 && d0 < d3) index = 0; else if (d1 < d2 && d1 < d3) index = 1; else if (d2 < d3) index = 2; else index = 3; indices |= index << (2 * i); } return indices; } static void output_block3(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 & v0, const Vector3 & v1, BlockDXT1 * block) { Color16 color0 = vector3_to_color16(v0); Color16 color1 = vector3_to_color16(v1); if (color0.u > color1.u) { swap(color0, color1); } Vector3 palette[4]; evaluate_palette(color0, color1, palette); block->col0 = color0; block->col1 = color1; block->indices = compute_indices(input_colors, color_weights, palette); } static void output_block4(const Vector4 input_colors[16], const Vector3 & color_weights, const Vector3 & v0, const Vector3 & v1, BlockDXT1 * block) { Color16 color0 = vector3_to_color16(v0); Color16 color1 = vector3_to_color16(v1); if (color0.u < color1.u) { swap(color0, color1); } Vector3 palette[4]; evaluate_palette(color0, color1, palette); block->col0 = color0; block->col1 = color1; block->indices = compute_indices4(input_colors, color_weights, palette); } // Single color compressor, based on: // https://mollyrocket.com/forums/viewtopic.php?t=392 static void compress_dxt1_single_color_optimal(Color32 c, BlockDXT1 * output) { output->col0.r = OMatch5[c.r][0]; output->col0.g = OMatch6[c.g][0]; output->col0.b = OMatch5[c.b][0]; output->col1.r = OMatch5[c.r][1]; output->col1.g = OMatch6[c.g][1]; output->col1.b = OMatch5[c.b][1]; output->indices = 0xaaaaaaaa; if (output->col0.u < output->col1.u) { swap(output->col0.u, output->col1.u); output->indices ^= 0x55555555; } } float nv::compress_dxt1_single_color_optimal(Color32 c, BlockDXT1 * output) { ::compress_dxt1_single_color_optimal(c, output); // Multiply by 16^2, the weight associated to a single color. // Divide by 255*255 to covert error to [0-1] range. return (256.0f / (255*255)) * evaluate_mse(output, c, output->indices & 3); } float nv::compress_dxt1_single_color_optimal(const Vector3 & color, BlockDXT1 * output) { return compress_dxt1_single_color_optimal(vector3_to_color(color), output); } // Compress block using the average color. float nv::compress_dxt1_single_color(const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, BlockDXT1 * output) { // Compute block average. Vector3 color_sum(0); float weight_sum = 0; for (int i = 0; i < count; i++) { color_sum += colors[i] * weights[i]; weight_sum += weights[i]; } // Compress optimally. ::compress_dxt1_single_color_optimal(vector3_to_color(color_sum / weight_sum), output); // Decompress block color. Color32 palette[4]; output->evaluatePalette(palette, /*d3d9=*/false); Vector3 block_color = color_to_vector3(palette[output->indices & 0x3]); // Evaluate error. float error = 0; for (int i = 0; i < count; i++) { error += weights[i] * evaluate_mse(block_color, colors[i], color_weights); } return error; } /* @@ Not implemented yet. // Low quality baseline compressor. float nv::compress_dxt1_least_squares_fit(const Vector3 * input_colors, const Vector3 * colors, const float * weights, int count, BlockDXT1 * output) { // @@ Iterative best end point fit. return FLT_MAX; }*/ float nv::compress_dxt1_bounding_box_exhaustive(const Vector4 input_colors[16], const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, bool three_color_mode, int max_volume, BlockDXT1 * output) { // Compute bounding box. Vector3 min_color(1.0f); Vector3 max_color(0.0f); for (int i = 0; i < count; i++) { min_color = min(min_color, colors[i]); max_color = max(max_color, colors[i]); } // Convert to 5:6:5 int min_r = ftoi_floor(31 * min_color.x); int min_g = ftoi_floor(63 * min_color.y); int min_b = ftoi_floor(31 * min_color.z); int max_r = ftoi_ceil(31 * max_color.x); int max_g = ftoi_ceil(63 * max_color.y); int max_b = ftoi_ceil(31 * max_color.z); // Expand the box. int range_r = max_r - min_r; int range_g = max_g - min_g; int range_b = max_b - min_b; min_r = max(0, min_r - range_r / 2 - 2); min_g = max(0, min_g - range_g / 2 - 2); min_b = max(0, min_b - range_b / 2 - 2); max_r = min(31, max_r + range_r / 2 + 2); max_g = min(63, max_g + range_g / 2 + 2); max_b = min(31, max_b + range_b / 2 + 2); // Estimate size of search space. int volume = (max_r-min_r+1) * (max_g-min_g+1) * (max_b-min_b+1); // if size under search_limit, then proceed. Note that search_volume is sqrt of number of evaluations. if (volume > max_volume) { return FLT_MAX; } // @@ Convert to fixed point before building box? Color32 colors32[16]; for (int i = 0; i < count; i++) { colors32[i] = toColor32(Vector4(colors[i], 1)); } float best_error = FLT_MAX; Color16 best0, best1; // @@ Record endpoints as Color16? Color16 c0, c1; Color32 palette[4]; for(int r0 = min_r; r0 <= max_r; r0++) for(int g0 = min_g; g0 <= max_g; g0++) for(int b0 = min_b; b0 <= max_b; b0++) { c0.r = r0; c0.g = g0; c0.b = b0; palette[0] = bitexpand_color16_to_color32(c0); for(int r1 = min_r; r1 <= max_r; r1++) for(int g1 = min_g; g1 <= max_g; g1++) for(int b1 = min_b; b1 <= max_b; b1++) { c1.r = r1; c1.g = g1; c1.b = b1; palette[1] = bitexpand_color16_to_color32(c1); if (c0.u > c1.u) { // Evaluate error in 4 color mode. evaluate_palette4(palette); } else { if (three_color_mode) { // Evaluate error in 3 color mode. evaluate_palette3(palette); } else { // Skip 3 color mode. continue; } } float error = evaluate_palette_error(palette, colors32, weights, count); if (error < best_error) { best_error = error; best0 = c0; best1 = c1; } } } output->col0 = best0; output->col1 = best1; Vector3 vector_palette[4]; evaluate_palette(output->col0, output->col1, vector_palette); output->indices = compute_indices(input_colors, color_weights, vector_palette); return best_error / (255 * 255); } void nv::compress_dxt1_cluster_fit(const Vector4 input_colors[16], const Vector3 * colors, const float * weights, int count, const Vector3 & color_weights, bool three_color_mode, BlockDXT1 * output) { ClusterFit fit; fit.setColorWeights(Vector4(color_weights, 1)); fit.setColorSet(colors, weights, count); // start & end are in [0, 1] range. Vector3 start, end; fit.compress4(&start, &end); if (three_color_mode && fit.compress3(&start, &end)) { output_block3(input_colors, color_weights, start, end, output); } else { output_block4(input_colors, color_weights, start, end, output); } } float nv::compress_dxt1(const Vector4 input_colors[16], const float input_weights[16], const Vector3 & color_weights, bool three_color_mode, BlockDXT1 * output) { Vector3 colors[16]; float weights[16]; int count = reduce_colors(input_colors, input_weights, colors, weights); if (count == 0) { // Output trivial block. output->col0.u = 0; output->col1.u = 0; output->indices = 0; return 0; } float error = FLT_MAX; // Sometimes the single color compressor produces better results than the exhaustive. This introduces discontinuities between blocks that // use different compressors. For this reason, this is not enabled by default. if (1) { error = compress_dxt1_single_color(colors, weights, count, color_weights, output); if (error == 0.0f || count == 1) { // Early out. return error; } } // This is too expensive, even with a low threshold. // If high quality: if (0) { BlockDXT1 exhaustive_output; float exhaustive_error = compress_dxt1_bounding_box_exhaustive(input_colors, colors, weights, count, color_weights, three_color_mode, 1400, &exhaustive_output); if (exhaustive_error != FLT_MAX) { float exhaustive_error2 = evaluate_mse(input_colors, input_weights, color_weights, &exhaustive_output); // The exhaustive compressor does not use color_weights, so the results may be different. //nvCheck(equal(exhaustive_error, exhaustive_error2)); if (exhaustive_error2 < error) { *output = exhaustive_output; error = exhaustive_error; } } } // @@ TODO. // This is pretty fast and in some cases can produces better quality than cluster fit. //error = compress_dxt1_least_squares_fit(colors, weigths, error, output); // Cluster fit cannot handle single color blocks, so encode them optimally if we haven't encoded them already. if (error == FLT_MAX && count == 1) { error = compress_dxt1_single_color_optimal(colors[0], output); } if (count > 1) { BlockDXT1 cluster_fit_output; compress_dxt1_cluster_fit(input_colors, colors, weights, count, color_weights, three_color_mode, &cluster_fit_output); float cluster_fit_error = evaluate_mse(input_colors, input_weights, color_weights, &cluster_fit_output); if (cluster_fit_error < error) { *output = cluster_fit_output; error = cluster_fit_error; } } return error; } // Once we have an index assignment we have colors grouped in 1-4 clusters. // If 1 clusters -> Use optimal compressor. // If 2 clusters -> Try: (0, 1), (1, 2), (0, 2), (0, 3) - [0, 1] // If 3 clusters -> Try: (0, 1, 2), (0, 1, 3), (0, 2, 3) - [0, 1, 2] // If 4 clusters -> Try: (0, 1, 2, 3) // @@ How do we do the initial index/cluster assignment? Use standard cluster fit. // Least squares fitting of color end points for the given indices. @@ Take weights into account. static bool optimize_end_points4(uint indices, const Vector3 * colors, const Vector3 * weights, int count, Vector3 * a, Vector3 * b) { float alpha2_sum = 0.0f; float beta2_sum = 0.0f; float alphabeta_sum = 0.0f; Vector3 alphax_sum(0.0f); Vector3 betax_sum(0.0f); for (int i = 0; i < count; i++) { const uint bits = indices >> (2 * i); float beta = float(bits & 1); if (bits & 2) beta = (1 + beta) / 3.0f; float alpha = 1.0f - beta; alpha2_sum += alpha * alpha; beta2_sum += beta * beta; alphabeta_sum += alpha * beta; alphax_sum += alpha * colors[i]; betax_sum += beta * colors[i]; } float denom = alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum; if (equal(denom, 0.0f)) return false; float factor = 1.0f / denom; *a = saturate((alphax_sum * beta2_sum - betax_sum * alphabeta_sum) * factor); *b = saturate((betax_sum * alpha2_sum - alphax_sum * alphabeta_sum) * factor); return true; } // Least squares fitting of color end points for the given indices. @@ This does not support black/transparent index. @@ Take weights into account. static bool optimize_end_points3(uint indices, const Vector3 * colors, const Vector3 * weights, int count, Vector3 * a, Vector3 * b) { float alpha2_sum = 0.0f; float beta2_sum = 0.0f; float alphabeta_sum = 0.0f; Vector3 alphax_sum(0.0f); Vector3 betax_sum(0.0f); for (int i = 0; i < count; i++) { const uint bits = indices >> (2 * i); float beta = float(bits & 1); if (bits & 2) beta = 0.5f; float alpha = 1.0f - beta; alpha2_sum += alpha * alpha; beta2_sum += beta * beta; alphabeta_sum += alpha * beta; alphax_sum += alpha * colors[i]; betax_sum += beta * colors[i]; } float denom = alpha2_sum * beta2_sum - alphabeta_sum * alphabeta_sum; if (equal(denom, 0.0f)) return false; float factor = 1.0f / denom; *a = saturate((alphax_sum * beta2_sum - betax_sum * alphabeta_sum) * factor); *b = saturate((betax_sum * alpha2_sum - alphax_sum * alphabeta_sum) * factor); return true; } // @@ After optimization we need to round end points. Round in all possible directions, and pick best.
;----------------------------------------------- ; User interface sound effects SFX_ui_move: db 7,#b8 ;; SFX all channels to tone db 10,#0b ;; volume db 4,0, 5+MUSIC_CMD_TIME_STEP_FLAG,#02 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#00 ;; silence db SFX_CMD_END SFX_ui_select: db 7,#b8 ;; SFX all channels to tone db 10,#0b ;; volume db 4,#80, 5+MUSIC_CMD_TIME_STEP_FLAG,#01 ;; frequency db 10+MUSIC_CMD_TIME_STEP_FLAG,#09 ;; volume db 10,#0b ;; volume db 4,#40, 5+MUSIC_CMD_TIME_STEP_FLAG,#01 ;; frequency db 10+MUSIC_CMD_TIME_STEP_FLAG,#09 ;; volume db 10,#0b ;; volume db 4,#00, 5+MUSIC_CMD_TIME_STEP_FLAG,#01 ;; frequency db 10+MUSIC_CMD_TIME_STEP_FLAG,#09 ;; volume db 10,#0b ;; volume db 4,#80, 5+MUSIC_CMD_TIME_STEP_FLAG,#00 ;; frequency db MUSIC_CMD_SKIP db 10+MUSIC_CMD_TIME_STEP_FLAG,#09 ;; volume db MUSIC_CMD_SKIP db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume db MUSIC_CMD_SKIP db 10+MUSIC_CMD_TIME_STEP_FLAG,#06 ;; volume db MUSIC_CMD_SKIP db 10+MUSIC_CMD_TIME_STEP_FLAG,#05 ;; volume db MUSIC_CMD_SKIP db 10+MUSIC_CMD_TIME_STEP_FLAG,#03 ;; volume db MUSIC_CMD_SKIP db 10+MUSIC_CMD_TIME_STEP_FLAG,#02 ;; volume db MUSIC_CMD_SKIP db 10,#00 ;; silence db SFX_CMD_END ; SFX_ui_wrong: ; db 7,#b8 ;; SFX all channels to tone ; db 10,#0b ;; volume ; db 4,0, 5+MUSIC_CMD_TIME_STEP_FLAG,#01 ;; frequency ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db 5+MUSIC_CMD_TIME_STEP_FLAG,#04 ;; frequency ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db 10,#00 ;; silence ; db SFX_CMD_END ;----------------------------------------------- ; in-game sound effects SFX_jump: db 7,#b8 ;; SFX all channels to tone db 10,#0c ;; volume db 4,#00, 5,#02 ;; frequency db MUSIC_CMD_SKIP db 4,#08, 5,#01 ;; frequency db MUSIC_CMD_SKIP db 4,#00 ;; frequency db MUSIC_CMD_SKIP db 4,#c0, 5,#00 ;; frequency db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db 10,#00 ;; silence db SFX_CMD_END SFX_playerhit: db 7,#b8 ;; SFX all channels to tone db 10,#0f ;; volume db 4,#00, 5,#08 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 5,#04 ;; frequency db MUSIC_CMD_SKIP db 5,#02 ;; frequency db MUSIC_CMD_SKIP db 5,#01 ;; frequency db MUSIC_CMD_SKIP db 4,#80, 5, #00 ;; frequency db MUSIC_CMD_SKIP db 4,#40 ;; frequency db MUSIC_CMD_SKIP db 4,#20 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#00 ;; silence db SFX_CMD_END SFX_drop_item: SFX_door_open: db 7,#b8 ;; SFX all channels to tone db 10,#0f ;; volume db 4,#00, 5,#06 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#0e ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#0d ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#0c ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#0b ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#0a ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#08 ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#07 ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#06 ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#05 ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#04 ;; volume db 4,#00 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 4,#80 ;; frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP db 10,#00 ;; silence db SFX_CMD_END SFX_explosion: db 7,#9c ;; noise in channel C, and tone in channels B and A db 10,#0f ;; volume db 6+MUSIC_CMD_TIME_STEP_FLAG,#10 ;; noise frequency db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db 6,#14 ;; noise frequency db 10+MUSIC_CMD_TIME_STEP_FLAG,#0c ;; volume db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db 6,#18 ;; noise frequency db 10+MUSIC_CMD_TIME_STEP_FLAG,#09 ;; volume db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db 6,#1c ;; noise frequency db 10+MUSIC_CMD_TIME_STEP_FLAG,#06 ;; volume db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db 6,#1f ;; noise frequency db 10+MUSIC_CMD_TIME_STEP_FLAG,#03 ;; volume db MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db 10,#00 ;; silence db 7, #b8 ;; tone in all three channels db SFX_CMD_END ; SFX_weapon_bullet: ; db 7, #b8 ;; tone in all three channels ; db 10,#08 ;; volume ; db 5, #03, 4+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db 5, #02 ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0b ;; volume ; db 5, #01 ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#09 ;; volume ; db 5, #00, 4, #c0 ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#07 ;; volume ; db MUSIC_CMD_SKIP ; db 4, #a0 ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#05 ;; volume ; db MUSIC_CMD_SKIP ; db 4, #80 ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#03 ;; volume ; db MUSIC_CMD_SKIP ; db 10,#00 ;; silence ; db SFX_CMD_END ; SFX_weapon_flame_bullet: ; db 7,#9c ;; noise in channel C, and tone in channels B and A ; db 10,#04 ;; volume ; db 6+MUSIC_CMD_TIME_STEP_FLAG,#10 ;; noise frequency ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0a ;; volume ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0c ;; volume ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0a ;; volume ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#04 ;; volume ; db MUSIC_CMD_SKIP ; db 10,#00 ;; silence ; db 7, #b8 ;; tone in all three channels ; db SFX_CMD_END ; SFX_weapon_flame: ; db 7,#9c ;; noise in channel C, and tone in channels B and A ; db 10,#0a ;; volume ; db 6+MUSIC_CMD_TIME_STEP_FLAG,#10 ;; noise frequency ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0c ;; volume ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0a ;; volume ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#04 ;; volume ; db MUSIC_CMD_SKIP ; db 10,#00 ;; silence ; db 7, #b8 ;; tone in all three channels ; db SFX_CMD_END ; SFX_weapon_laser_bullet: ; db 7, #b8 ;; tone in all three channels ; db 10,#1f ;; volume set to modulation ; db 11, #08, 12, #00 ; envelope period ; db 13, #0a ; envelope shape ; db 5, #00 ; db 4, #20 ; db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP ; db 4, #40 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #0a ; db MUSIC_CMD_SKIP ; db 4, #60 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #0c ; db MUSIC_CMD_SKIP ; db 4, #80 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #10 ; db MUSIC_CMD_SKIP ; ; db 4, #c0 ; ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #14 ; ; db MUSIC_CMD_SKIP ; ; db 5, #01 ; ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #18 ; ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0a ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#06 ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#00 ;; silence ; db SFX_CMD_END ; SFX_weapon_laser: ; db 7, #b8 ;; tone in all three channels ; db 10,#1f ;; volume set to modulation ; db 11, #08, 12, #00 ; envelope period ; db 13, #0a ; envelope shape ; db 5, #03, 4, #20 ; db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP ; db 4, #40 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #0a ; db MUSIC_CMD_SKIP ; db 4, #60 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #0c ; db MUSIC_CMD_SKIP ; db 4, #c0 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #10 ; db MUSIC_CMD_SKIP ; db 5, #04, 4, #00 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #14 ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0a ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#06 ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#00 ;; silence ; db SFX_CMD_END SFX_enemy_hit: db 7, #b8 ;; tone in all three channels db 10,#0d ;; volume db 5, #01, 4+MUSIC_CMD_TIME_STEP_FLAG, #b0 db 5+MUSIC_CMD_TIME_STEP_FLAG, #02 db 5+MUSIC_CMD_TIME_STEP_FLAG, #03 db 5+MUSIC_CMD_TIME_STEP_FLAG, #04 db 5+MUSIC_CMD_TIME_STEP_FLAG, #05 db 5+MUSIC_CMD_TIME_STEP_FLAG, #06 db 10,#0a ;; volume db 5+MUSIC_CMD_TIME_STEP_FLAG, #01 db 5+MUSIC_CMD_TIME_STEP_FLAG, #02 db 5+MUSIC_CMD_TIME_STEP_FLAG, #03 db 5+MUSIC_CMD_TIME_STEP_FLAG, #04 db 5+MUSIC_CMD_TIME_STEP_FLAG, #05 db 5+MUSIC_CMD_TIME_STEP_FLAG, #06 db 10,#06 ;; volume db 5+MUSIC_CMD_TIME_STEP_FLAG, #01 db 5+MUSIC_CMD_TIME_STEP_FLAG, #02 db 5+MUSIC_CMD_TIME_STEP_FLAG, #03 db 5+MUSIC_CMD_TIME_STEP_FLAG, #04 db 5+MUSIC_CMD_TIME_STEP_FLAG, #05 db 5+MUSIC_CMD_TIME_STEP_FLAG, #06 db 10,#00 ;; silence db SFX_CMD_END ; SFX_power_capsule: ; db 7, #b8 ;; tone in all three channels ; db 10,#0d ;; volume ; db 5, #04, 4+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db 4,#80,5+MUSIC_CMD_TIME_STEP_FLAG, #03 ; db 4+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db 4,#80,5+MUSIC_CMD_TIME_STEP_FLAG, #02 ; db 4+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db 4,#80,5+MUSIC_CMD_TIME_STEP_FLAG, #01 ; db 4+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db 10,#00 ;; silence ; db SFX_CMD_END ; SFX_weapon_select: ; db 7, #b8 ;; tone in all three channels ; db 10,#0d ;; volume ; db 5, #02, 4+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP ; db 4,#c0,5+MUSIC_CMD_TIME_STEP_FLAG, #01 ; db 4+MUSIC_CMD_TIME_STEP_FLAG, #80 ; db 4+MUSIC_CMD_TIME_STEP_FLAG, #40 ; db 4+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db 4,#c0,5+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db 4+MUSIC_CMD_TIME_STEP_FLAG, #80 ; db 4+MUSIC_CMD_TIME_STEP_FLAG, #40 ; db 10,#00 ;; silence ; db SFX_CMD_END ; SFX_moai_laser: ; db 7, #b8 ;; tone in all three channels ; db 10,#1f ;; volume set to modulation ; db 11, #08, 12, #00 ; envelope period ; db 13, #0a ; envelope shape ; db 5, #00, 4, #40 ; db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP ; db 4, #60 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #0a ; db MUSIC_CMD_SKIP ; db 4, #80 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #0c ; db MUSIC_CMD_SKIP ; db 5, #01, 4, #00 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #10 ; db MUSIC_CMD_SKIP ; db 4, #80 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #14 ; db MUSIC_CMD_SKIP ; db 5, #01, 4, #00 ; db 11+MUSIC_CMD_TIME_STEP_FLAG, #18 ; db MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0a ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#06 ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#00 ;; silence ; db SFX_CMD_END ; SFX_destroyable_wall: ; db 7, #b8 ;; tone in all three channels ; db 10,#0d ;; volume ; db 5, #00, 4+MUSIC_CMD_TIME_STEP_FLAG, #b0 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #01 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #02 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #03 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #04 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #05 ; db 10,#0a ;; volume ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #01 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #02 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #03 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #04 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #05 ; db 10,#06 ;; volume ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #00 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #01 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #02 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #03 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #04 ; db 5+MUSIC_CMD_TIME_STEP_FLAG, #05 ; db 10,#00 ;; silence ; db SFX_CMD_END ;----------------------------------------------- ; Sound effects used for the percussion in the songs SFX_drum_shorter_re: db 7,#98 ;; noise in channel C, and tone in channels B and A db 10,#0a ;; volume db 5, 2, 4, #fa ;; RE3 db 6+MUSIC_CMD_TIME_STEP_FLAG,#18 ;; noise frequency db 5, #03, 4, #20 db 7+MUSIC_CMD_TIME_STEP_FLAG,#b8 db 10,#06 db 4+MUSIC_CMD_TIME_STEP_FLAG,#40 db 4+MUSIC_CMD_TIME_STEP_FLAG,#60 db 10,#04 db 4+MUSIC_CMD_TIME_STEP_FLAG,#80 db 4+MUSIC_CMD_TIME_STEP_FLAG,#a0 db 10,#00 ;; channel 3 volume to silence db 7,#b8 ;; SFX all channels to tone db SFX_CMD_END ;----------------------------------------------- ; Sound effects used for the percussion in the songs SFX_drum_short_re: db 7,#98 ;; noise in channel C, and tone in channels B and A db 10,#0b ;; volume db 5, 2, 4, #fa ;; RE3 db 6+MUSIC_CMD_TIME_STEP_FLAG,#18 ;; noise frequency ;db MUSIC_CMD_SKIP db 5, #03, 4, #20 db 7+MUSIC_CMD_TIME_STEP_FLAG,#b8 db 10,#09 db 4+MUSIC_CMD_TIME_STEP_FLAG,#40 db 4+MUSIC_CMD_TIME_STEP_FLAG,#60 db 10,#07 db 4+MUSIC_CMD_TIME_STEP_FLAG,#80 db 4+MUSIC_CMD_TIME_STEP_FLAG,#a0 db 10,#05 db 4+MUSIC_CMD_TIME_STEP_FLAG,#c0 db 4+MUSIC_CMD_TIME_STEP_FLAG,#e0 db 10,#00 ;; channel 3 volume to silence db 7,#b8 ;; SFX all channels to tone db SFX_CMD_END ; SFX_drum_long_re: ; db 7,#98 ;; noise in channel C, and tone in channels B and A ; db 10,#0c ;; volume to envelope ; ; db 5, 5, 4, 244 ;; RE2 ; db 5, 2, 4, 259 ;; RE3 ; ; db 10,#10 ;; volume to envelope ; ; db 11,#08, 12, #00 ; ; db 13, #0e ; db 6+MUSIC_CMD_TIME_STEP_FLAG,#1f ;; noise frequency ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0a ;; volume to envelope ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume to envelope ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#06 ;; volume to envelope ; db MUSIC_CMD_SKIP ; db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP ; db 7,#b8 ;; SFX all channels to tone ; db 10,#00 ;; channel 3 volume to silence ; db SFX_CMD_END SFX_open_hi_hat: db 7,#9c ;; noise in channel C, and tone in channels B and A db 10,#0c ;; volume db 6+MUSIC_CMD_TIME_STEP_FLAG,#01 ;; noise frequency db MUSIC_CMD_SKIP db 10+MUSIC_CMD_TIME_STEP_FLAG,#09 ;; volume db MUSIC_CMD_SKIP db 10+MUSIC_CMD_TIME_STEP_FLAG,#07 ;; volume db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db MUSIC_CMD_SKIP,MUSIC_CMD_SKIP,MUSIC_CMD_SKIP,MUSIC_CMD_SKIP db 7,#b8 ;; SFX all channels to tone db 10,#00 ;; channel 3 volume to silence db SFX_CMD_END SFX_short_hi_hat: db 7,#9c ;; noise in channel C, and tone in channels B and A db 10,#0b ;; volume db 6+MUSIC_CMD_TIME_STEP_FLAG,#01 ;; noise frequency db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume db 10+MUSIC_CMD_TIME_STEP_FLAG,#06 ;; volume db 7,#b8 ;; SFX all channels to tone db 10,#00 ;; channel 3 volume to silence db SFX_CMD_END ; SFX_pedal_hi_hat: ; db 7,#9c ;; noise in channel C, and tone in channels B and A ; db 10,#05 ;; volume ; db 6+MUSIC_CMD_TIME_STEP_FLAG,#04 ;; noise frequency ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#08 ;; volume ; db 10+MUSIC_CMD_TIME_STEP_FLAG,#0b ;; volume ; db 7,#b8 ;; SFX all channels to tone ; db 10,#00 ;; channel 3 volume to silence ; db SFX_CMD_END
; A099902: Multiplies by 2 and shifts right under the XOR BINOMIAL transform (A099901). ; Submitted by Jon Maiga ; 1,3,7,11,23,59,103,139,279,827,1895,2955,5655,14395,24679,32907,65815,197435,460647,723851,1512983,3881019,6774887,9142411,18219287,54002491,123733863,192940939,369104407,939538491,1610637415,2147516555,4295033111,12885099323,30065231719,47245364107,98785760791,253406951483,442388406375,597009596555,1198314094871,3551991956283,8139086759783,12691821300619,24288409163287,61826993764411,105997108535399,141336636326027,282668977684759,847963983381307,1978433735690087,3108869128260491 mov $2,$0 mul $2,2 seq $2,101624 ; Stern-Jacobsthal numbers. mov $0,$2
.thumb @Master Key Usability @r0 holds ram character pointer push {r4,r14} mov r4, r0 ldr r3, ChestCheck @check if on top of a chest tile? bl Jump lsl r0,r0, #0x18 cmp r0, #0x0 bne TrueCase mov r0, r4 ldr r3, DoorCheck @check if next to a door tile? bl Jump lsl r0,r0, #0x18 cmp r0, #0x0 bne TrueCase mov r0, r4 ldr r3, Routine3 bl Jump lsl r0,r0, #0x18 cmp r0, #0x0 bne TrueCase mov r0, #0x0 b PopBack TrueCase: mov r0, #0x1 PopBack: pop {r4} pop {r1} bx r1 Jump: bx r3 .align ChestCheck: .long 0x80290FC | 1 DoorCheck: .long 0x8029138 | 1 Routine3: .long 0x802914C | 1
; int sscanf(char *s, const char *fmt,...) ; 05.2008 aralbrec PUBLIC sscanf EXTERN vsscanf_callee, stdio_varg, stdio_nextarg EXTERN ASMDISP_VSSCANF_CALLEE .sscanf call stdio_varg push de exx pop hl ; hl = char *s exx call stdio_nextarg ; de = char *fmt ld c,l ld b,h ; bc = top of parameter list jp vsscanf_callee + ASMDISP_VSSCANF_CALLEE
;------------------------------------------------------------------------------- ; filter5(int N, int *start, int length, int *dest): ; Applies a median filter to a signal array at start, writes the result to dest ;------------------------------------------------------------------------------- section .data ; error messages msg_blockLength db '-- ERROR : Block length must be odd and positive',0xa,0xa msg_signalLength db '-- ERROR : Signal length cannot be negative',0xa,0xa section .text global filter5 ; Main function: Check parameters, copy array, sort blocks, find and write medians ; edi: int N (block length) ; esi: int *start (start address) ; edx: int length (signal length) ; ecx: int *dest (destination address) filter5: ; check if block length is positive cmp edi, 0 jle error_blockLength ; check if block length is odd test edi, 1 je error_blockLength ; check if signal length is non-negative test edx, edx js error_signalLength ; Copy the array from start to dest call copy_array ; Sort the copied array by blocks call sort_array ; Find medians and write them to dest call find_medians ; End function ret ; Copy the array from start to dest ; esi: start ; edi: dest copy_array: push rax push rsi push rcx push rdx ; Loop over the array at start and copy integers to dest copy_loop: cmp edx, 0 ; if no values are left, end loop je end_copy mov eax, [esi] ; copy current value (4 bytes) mov [ecx], eax ; post value at destination (4 bytes) add esi, 4 ; move to next int (4 bytes) add ecx, 4 ; move to next int (4 bytes) dec edx ; decrement counter jmp copy_loop end_copy: pop rdx pop rcx pop rsi pop rax ret ; Divide the array at dest into blocks of length N and sort them in ascending order ; Incomplete block at the end will be ignored ; edi: N ; edx: length ; esi: dest ; eax: offset ; r10: block start address sort_array: push rax push r10 mov eax, 0 mov r10d, ecx sort_array_loop: ; offset += N add eax, edi ; if offset > length, end loop cmp eax, edx jg end_sort_array ; sort block call sort_block ; dest += N*4 shl edi, 2 add r10d, edi shr edi, 2 jmp sort_array_loop end_sort_array: pop r10 pop rax ret ; Sort single block using the selection sort algorithm ; edi: N ; r10d: block start address sort_block: push rax push rbx push rsi push r8 push r9 mov eax, 0 ; outer loop counter mov r8d, r10d ; outer loop address sort_outer_loop: cmp eax, edi je end_outer_loop mov ebx, eax ; inner loop counter mov r9d, r8d ; address of current minimum mov esi, [r8d] ; value of hold current minimum sort_inner_loop: inc ebx ; if end is reached, then minimum is found cmp ebx, edi je end_inner_loop ; check if minimum needs to be updated cmp esi, [r10d + 4*ebx] jle sort_inner_loop ; set new minimum: mov r9d, r10d shl ebx,2 add r9d, ebx shr ebx,2 mov esi, [r9d] jmp sort_inner_loop end_inner_loop: call swap_int inc eax add r8d, 4 jmp sort_outer_loop end_outer_loop: pop r9 pop r8 pop rsi pop rbx pop rax ret ; swap two integers stored at r8d and r9d swap_int: push rax push rbx mov eax, [r8d] ; save first value mov ebx, [r9d] ; save second value mov [r8d], ebx ; write second value mov [r9d], eax ; write first value pop rbx pop rax ret ; Find medians and write them to dest ; eax: number of blocks ; ebx: current address ; edx: counter ; esi: temp value for median find_medians: push rax push rbx push rdx push rsi ; #blocks = length / N (rounded off) mov eax, edx mov edx, 0 div edi mov edx, 0 ; find first median: ; dest + 4 * (N-1)/2 = dest + 2N - 2 mov ebx, edi shl ebx, 1 sub ebx, 2 add ebx, ecx median_loop: cmp edx, eax ; all blocks traversed je end_median_loop ; write medians sequentially, beginning at dest mov esi, [ebx] mov [ecx + 4*edx], esi ; move to next median (add 4*N) shl edi, 2 add ebx, edi shr edi, 2 inc edx jmp median_loop end_median_loop: pop rsi pop rdx pop rbx pop rax ret ; handle error: block length is even or not positive error_blockLength: push rdx push rcx push rbx push rax mov edx, 50 mov ecx, msg_blockLength mov ebx, 1 mov eax, 4 int 0x80 pop rax pop rbx pop rcx pop rdx ret ; handle error: signal length is negative error_signalLength: push rdx push rcx push rbx push rax mov edx, 45 mov ecx, msg_signalLength mov ebx, 1 mov eax, 4 int 0x80 pop rax pop rbx pop rcx pop rdx ret
SECTION data_clib PUBLIC __brksave __brksave: defb 1 ;; Keeping the BREAK enable flag, used by pc88_break, etc..
// note: **1.11** P11, first **bigger** than second #include <iostream> #include <utility> int main() { std::cout << "Enter 2 integers:" << std::endl; int a = 0, b = 0; std::cin >> a >> b; if (a > b) { std::swap(a, b); } while (a <= b) { std::cout << a++ << std::endl; } return 0; }