text
stringlengths
1
1.05M
Name: ys_enmy11.asm Type: file Size: 59933 Last-Modified: '2016-05-13T04:50:38Z' SHA-1: 756436BFEF912B3C9A91FC35764B730BB8E5C8E1 Description: null
; A082969: Numbers n such that (n/4)^2-n/8=sum(k=1,n, k modulo(sum(i=0,k-1,1-t(i))) where t(i)=A010060(i) is the Thue-Morse sequence. ; 2,10,18,34,58,66,90,106,114,130,154,170,178,202,210,226,250,258,282,298,306,330,338,354,378,394,402,418,442,450,474,490,498,514,538,554,562,586,594,610,634,650,658,674,698,706,730,746,754,778,786,802,826 mov $1,$0 trn $1,1 seq $1,161560 ; a(n) = floor(A000069(n)/2-1/2). add $0,$1 mul $0,8 add $0,2
$DATA 0 $SYMBOL onEmoteTarget L13 $SYMBOL onAct L16 L13: PUSHBP MSPBP PUSHDISP -4 PUSHS BOW EQ PUSHDISP -2 PUSHS name GET PUSHS Syra EQ AND JZ L15 L14: PUSHS say Good day, PUSHDISP -3 PUSHS name GET ADD PUSHS ! ADD TRAP L15: MBPSP POPBP MTSD 3 SUBSP 3 RET L16: PUSHBP MSPBP MBPSP POPBP MTSD 3 SUBSP 3 RET
Name: zel_endt.asm Type: file Size: 217047 Last-Modified: '2016-05-13T04:23:03Z' SHA-1: A1678C6C9F7F53C2A6CBC76F660A289032877DCA Description: null
#include <NormalNavigatorMode.hpp> NormalNavigatorMode::NormalNavigatorMode(RecordSystem &recordSystem, sf::RenderTexture &renderTexture, NavigatorSignals &signals) : NavigatorMode(recordSystem, renderTexture, signals) { } void NormalNavigatorMode::processTasks() { if (mTasks.addFolder) { mTasks.addFolder = false; mCurrentFolder -> addFolder(); mCurrentFolder -> setScrollToLastFolder(); } if (mTasks.addRecord) { mTasks.addRecord = false; mCurrentFolder -> addRecord(); mCurrentFolder -> setScrollToLastRecord(); } } void NormalNavigatorMode::updateFromRecordSystem() { mCurrentFolder = mRecordSystem.getCurrentFolder(); mPathToCurrentFolder = mRecordSystem.getPathToCurrentFolder(); } void NormalNavigatorMode::handleEvent(const sf::Event &event) { NavigatorMode::handleEvent(event); if (event.type == sf::Event::KeyPressed) switch (event.key.code) { /* case sf::Keyboard::Key::T: mTasks.addFolder = true; mNeedUpdate = true; break; case sf::Keyboard::Key::N: mTasks.addRecord = true; mNeedUpdate = true; break; */ default: break; } }
#pragma once namespace nall { template<uint Bits> struct BarrettReduction { using type = typename ArithmeticNatural<1 * Bits>::type; using pair = typename ArithmeticNatural<2 * Bits>::type; explicit BarrettReduction(type modulo) : modulo(modulo), factor(pair(1) + -pair(modulo) / modulo) {} //return => value % modulo inline auto operator()(pair value) const -> type { pair hi, lo; mul(value, factor, hi, lo); pair remainder = value - hi * modulo; return remainder < modulo ? remainder : remainder - modulo; } private: const pair modulo; const pair factor; }; template<typename T, uint Bits> auto operator%(T value, const BarrettReduction<Bits>& modulo) { return modulo(value); } }
#include <vector> #include <SFML/Graphics.hpp> /* Display Constants */ const char SCREEN_TITLE[] = "Game of Life"; // Lol not gonna include string just for one string const unsigned SCREEN_WIDTH = 1200; const unsigned SCREEN_HEIGHT = 700; const unsigned FRAME_RATE = 30; const sf::Color BG_COLOR = sf::Color::White; const sf::Color CELL_COLOR = sf::Color::Black; /* Life Constants */ const long long MEANING_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING = 42; // DO NOT CHANGE OR REMOVE! PROGRAM DOES NOT WORK WITHOUT THIS! const unsigned CELL_SIZE = 20; const unsigned ROWS = SCREEN_HEIGHT / CELL_SIZE; const unsigned COLUMNS = SCREEN_WIDTH / CELL_SIZE; const unsigned POP_SIZE = ROWS * COLUMNS; const unsigned INITIAL_GROWTH_RATE = 1; // The rate at which the population reproduces typedef std::vector<std::vector<bool>> cellgrid; // Fills the cells vector with dead cells. void init_cells(cellgrid &cells) { for(unsigned row = 0; row < ROWS; ++row) { std::vector<bool> gridrow; for(unsigned col = 0; col < COLUMNS; ++col) gridrow.push_back(0); cells.push_back(gridrow); } } // Simply flips the state of the cell void change_cell(cellgrid &cells, unsigned x, unsigned y) { cells[y][x] = !cells[y][x]; } /* Returns the number of neighbors a cell has. Max number of neighbors is 8. Need to explicitly make y and x int and not unsigned or else all arithmetic with them would be unsigned. */ unsigned count_neighbors(const cellgrid &cells, int y, int x) { unsigned total = 0; for(int ny = y - 1; ny <= y + 1; ++ny) { for(int nx = x - 1; nx <= x + 1; ++nx) { // Don't count the current cell as a neighbor, and do some bounds checking if(!(ny == y && nx == x) && ny >= 0 && ny < ROWS && nx >= 0 && nx < COLUMNS) total += cells[ny][nx]; // If neighbor is a alive (true) add 1 } } return total; } // Runs the simulation for one generation. void simulate_life(cellgrid &curgen, cellgrid &nextgen) { for(unsigned y = 0; y < ROWS; ++y) { for(unsigned x = 0; x < COLUMNS; ++x) { unsigned neighbors = count_neighbors(curgen, y, x); if(neighbors < 2 || neighbors > 3) nextgen[y][x] = 0; else if(neighbors == 3 || (curgen[y][x] && neighbors == 2)) // Dead cells come to life with 3 neighbors nextgen[y][x] = 1; } } curgen = nextgen; } // Draws all cells onto the screen. Living cells are black. void draw_cells(const cellgrid &cells, sf::RenderWindow &window) { for(unsigned y = 0; y < ROWS; ++y) { for(unsigned x = 0; x < COLUMNS; ++x) { sf::RectangleShape cell(sf::Vector2f(CELL_SIZE, CELL_SIZE)); cell.setOutlineThickness(1); // The thickness of a rectangle defaults to 0 if(cells[y][x]) { cell.setOutlineColor(BG_COLOR); cell.setFillColor(CELL_COLOR); } else { cell.setOutlineColor(CELL_COLOR); cell.setFillColor(BG_COLOR); } cell.setPosition(CELL_SIZE * x, CELL_SIZE * y); window.draw(cell); } } } int main() { /* DO NOT REMOVE! THIS IS NECESSARY FOR CODE TO RUN! IDK WHY! PLZ HALP! */ if(MEANING_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING == 42) { // Create the window and set frame rate. sf::RenderWindow window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), SCREEN_TITLE); window.setFramerateLimit(FRAME_RATE); // A 2D vector containing all cells. A cell can either be alive (true) or dead (false) cellgrid cells; init_cells(cells); /* This 2D vector contains the "next generation" of cells. Modifying the state of the current generation of cells while determining the next generation would cause problems. */ cellgrid next_gen(cells); unsigned growth_rate = INITIAL_GROWTH_RATE; unsigned ticks = 0; // Number of ticks of the "game" loop unsigned generations = 0;// The number of generations that have passed. bool paused = true; // Begin main loop while(window.isOpen()) { // Check for input sf::Event event; while(window.pollEvent(event)) { switch(event.type) { case sf::Event::Closed: window.close(); break; case sf::Event::KeyPressed: switch(event.key.code) { case sf::Keyboard::Key::Return: paused = !paused; break; case sf::Keyboard::Key::Up: if(growth_rate > 1) --growth_rate; break; case sf::Keyboard::Key::Down: ++growth_rate; break; default: break; } break; case sf::Event::EventType::MouseButtonPressed: /* This needs to be in a block because you can't jump over an initialization of a variable that might still be in scope once the switch statement is over. Putting it in a block keeps its scope confined to this case. */ { sf::Vector2i mouse_pos = sf::Mouse::getPosition(window); change_cell(cells, mouse_pos.x / CELL_SIZE, mouse_pos.y / CELL_SIZE); } break; default: break; } } // Begin game logic if((ticks % growth_rate == 0) && !paused) // Slow down how fast the population reproduces { simulate_life(cells, next_gen); ++generations; // This could be in simulate_life(), but then I'd have to add another parameter } // Draw everything to the screen window.clear(BG_COLOR); draw_cells(cells, window); window.display(); ++ticks; } return 0; } return 42; }
// Copyright (c) 2018 The Open-Transactions developers // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include "stdafx.hpp" #include "opentxs/contact/Contact.hpp" #include "opentxs/api/crypto/Crypto.hpp" #include "opentxs/api/crypto/Encode.hpp" #include "opentxs/api/Native.hpp" #include "opentxs/api/Wallet.hpp" #include "opentxs/contact/ContactData.hpp" #include "opentxs/contact/ContactGroup.hpp" #include "opentxs/contact/ContactItem.hpp" #include "opentxs/contact/ContactSection.hpp" #if OT_CRYPTO_SUPPORTED_SOURCE_BIP47 #include "opentxs/core/crypto/PaymentCode.hpp" #endif #include "opentxs/core/Data.hpp" #include "opentxs/core/Identifier.hpp" #include "opentxs/core/Log.hpp" #include "opentxs/OT.hpp" #include "opentxs/Types.hpp" #include <sstream> #include <stdexcept> #define CURRENT_VERSION 2 #define ID_BYTES 32 #define OT_METHOD "opentxs::Contact::" namespace opentxs { Contact::Contact(const api::Wallet& wallet, const proto::Contact& serialized) : wallet_(wallet) , version_(check_version(serialized.version(), CURRENT_VERSION)) , label_(serialized.label()) , lock_() , id_(Identifier::Factory(Identifier::Factory(serialized.id()))) , parent_(Identifier::Factory(serialized.mergedto())) , primary_nym_(Identifier::Factory()) , nyms_() , merged_children_() , contact_data_(new ContactData( serialized.id(), CONTACT_CONTACT_DATA_VERSION, CONTACT_CONTACT_DATA_VERSION, ContactData::SectionMap{})) , cached_contact_data_() , revision_(serialized.revision()) { if (serialized.has_contactdata()) { contact_data_.reset(new ContactData( serialized.id(), CONTACT_CONTACT_DATA_VERSION, serialized.contactdata())); } OT_ASSERT(contact_data_); for (const auto& child : serialized.merged()) { merged_children_.emplace(Identifier::Factory(child)); } init_nyms(); } Contact::Contact(const api::Wallet& wallet, const std::string& label) : wallet_(wallet) , version_(CURRENT_VERSION) , label_(label) , lock_() , id_(Identifier::Factory(generate_id())) , parent_(Identifier::Factory()) , primary_nym_(Identifier::Factory()) , nyms_() , merged_children_() , contact_data_(nullptr) , cached_contact_data_() , revision_(1) { contact_data_.reset(new ContactData( String::Factory(id_)->Get(), CONTACT_CONTACT_DATA_VERSION, CONTACT_CONTACT_DATA_VERSION, ContactData::SectionMap{})); OT_ASSERT(contact_data_); } Contact::operator proto::Contact() const { Lock lock(lock_); proto::Contact output{}; output.set_version(version_); output.set_id(String::Factory(id_)->Get()); output.set_revision(revision_); output.set_label(label_); if (contact_data_) { auto& data = *output.mutable_contactdata(); data = contact_data_->Serialize(); } output.set_mergedto(String::Factory(parent_)->Get()); for (const auto& child : merged_children_) { output.add_merged(String::Factory(child)->Get()); } return output; } Contact& Contact::operator+=(Contact& rhs) { Lock rLock(rhs.lock_, std::defer_lock); Lock lock(lock_, std::defer_lock); std::lock(rLock, lock); if (label_.empty()) { label_ = rhs.label_; } rhs.parent_ = id_; if (primary_nym_->empty()) { primary_nym_ = rhs.primary_nym_; } for (const auto& it : rhs.nyms_) { const auto& id = it.first; const auto& nym = it.second; if (0 == nyms_.count(id)) { nyms_.emplace(id, nym); } } rhs.nyms_.clear(); for (const auto& it : rhs.merged_children_) { merged_children_.insert(it); } merged_children_.insert(rhs.id_); rhs.merged_children_.clear(); if (contact_data_) { if (rhs.contact_data_) { contact_data_.reset( new ContactData(*contact_data_ + *rhs.contact_data_)); } } else { if (rhs.contact_data_) { contact_data_.reset(new ContactData(*rhs.contact_data_)); } } rhs.contact_data_.reset(); cached_contact_data_.reset(); rhs.cached_contact_data_.reset(); return *this; } bool Contact::add_claim(const std::shared_ptr<ContactItem>& item) { Lock lock(lock_); return add_claim(lock, item); } bool Contact::add_claim( const Lock& lock, const std::shared_ptr<ContactItem>& item) { OT_ASSERT(verify_write_lock(lock)); if (false == bool(item)) { otErr << OT_METHOD << __FUNCTION__ << ": Null claim." << std::endl; return false; } const auto version = std::make_pair(item->Version(), item->Section()); const proto::ContactItem serialized(*item); if (false == proto::Validate<proto::ContactItem>( serialized, VERBOSE, true, version)) { otErr << OT_METHOD << __FUNCTION__ << ": Invalid claim." << std::endl; return false; } add_verified_claim(lock, item); return true; } bool Contact::add_nym( const Lock& lock, const std::shared_ptr<const Nym>& nym, const bool primary) { OT_ASSERT(verify_write_lock(lock)); if (false == bool(nym)) { return false; } const auto contactType = type(lock); const auto nymType = ExtractType(*nym); const bool haveType = (proto::CITEMTYPE_ERROR != contactType) && (proto::CITEMTYPE_UNKNOWN != contactType); const bool typeMismatch = (contactType != nymType); if (haveType && typeMismatch) { otErr << OT_METHOD << __FUNCTION__ << ": Wrong nym type." << std::endl; return false; } const auto& id = nym->ID(); const bool needPrimary = (0 == nyms_.size()); const bool isPrimary = needPrimary || primary; nyms_[id] = nym; if (isPrimary) { primary_nym_ = id; } add_nym_claim(lock, id, isPrimary); return true; } void Contact::add_nym_claim( const Lock& lock, const Identifier& nymID, const bool primary) { OT_ASSERT(verify_write_lock(lock)); std::set<proto::ContactItemAttribute> attr{proto::CITEMATTR_LOCAL, proto::CITEMATTR_ACTIVE}; if (primary) { attr.emplace(proto::CITEMATTR_PRIMARY); } std::shared_ptr<ContactItem> claim{nullptr}; claim.reset(new ContactItem( String::Factory(id_)->Get(), CONTACT_CONTACT_DATA_VERSION, CONTACT_CONTACT_DATA_VERSION, proto::CONTACTSECTION_RELATIONSHIP, proto::CITEMTYPE_CONTACT, String::Factory(nymID)->Get(), attr, NULL_START, NULL_END)); add_claim(lock, claim); } void Contact::add_verified_claim( const Lock& lock, const std::shared_ptr<ContactItem>& item) { OT_ASSERT(verify_write_lock(lock)); OT_ASSERT(contact_data_); contact_data_.reset(new ContactData(contact_data_->AddItem(item))); OT_ASSERT(contact_data_); revision_++; cached_contact_data_.reset(); } bool Contact::AddBlockchainAddress( const std::string& address, const proto::ContactItemType currency) { Lock lock(lock_); std::shared_ptr<ContactItem> claim{nullptr}; claim.reset(new ContactItem( String::Factory(id_)->Get(), CONTACT_CONTACT_DATA_VERSION, CONTACT_CONTACT_DATA_VERSION, proto::CONTACTSECTION_ADDRESS, currency, address, {proto::CITEMATTR_LOCAL, proto::CITEMATTR_ACTIVE}, NULL_START, NULL_END)); return add_claim(lock, claim); } bool Contact::AddEmail( const std::string& value, const bool primary, const bool active) { if (value.empty()) { return false; } Lock lock(lock_); contact_data_.reset( new ContactData(contact_data_->AddEmail(value, primary, active))); OT_ASSERT(contact_data_); revision_++; cached_contact_data_.reset(); return true; } bool Contact::AddNym(const std::shared_ptr<const Nym>& nym, const bool primary) { Lock lock(lock_); return add_nym(lock, nym, primary); } bool Contact::AddNym(const Identifier& nymID, const bool primary) { Lock lock(lock_); const bool needPrimary = (0 == nyms_.size()); const bool isPrimary = needPrimary || primary; if (isPrimary) { primary_nym_ = nymID; } add_nym_claim(lock, nymID, isPrimary); revision_++; return true; } #if OT_CRYPTO_SUPPORTED_SOURCE_BIP47 bool Contact::AddPaymentCode( const class PaymentCode& code, const bool primary, const proto::ContactItemType currency, const bool active) { std::set<proto::ContactItemAttribute> attr{proto::CITEMATTR_LOCAL}; if (active) { attr.emplace(proto::CITEMATTR_ACTIVE); } if (primary) { attr.emplace(proto::CITEMATTR_PRIMARY); } const std::string value = code.asBase58(); std::shared_ptr<ContactItem> claim{nullptr}; claim.reset(new ContactItem( String::Factory(id_)->Get(), CONTACT_CONTACT_DATA_VERSION, CONTACT_CONTACT_DATA_VERSION, proto::CONTACTSECTION_PROCEDURE, currency, value, attr, NULL_START, NULL_END)); if (false == add_claim(claim)) { otErr << OT_METHOD << __FUNCTION__ << ": Unable to add claim." << std::endl; return false; } return true; } #endif bool Contact::AddPhoneNumber( const std::string& value, const bool primary, const bool active) { if (value.empty()) { return false; } Lock lock(lock_); contact_data_.reset( new ContactData(contact_data_->AddPhoneNumber(value, primary, active))); OT_ASSERT(contact_data_); revision_++; cached_contact_data_.reset(); return true; } bool Contact::AddSocialMediaProfile( const std::string& value, const proto::ContactItemType type, const bool primary, const bool active) { if (value.empty()) { return false; } Lock lock(lock_); contact_data_.reset(new ContactData( contact_data_->AddSocialMediaProfile(value, type, primary, active))); OT_ASSERT(contact_data_); revision_++; cached_contact_data_.reset(); return true; } std::shared_ptr<ContactItem> Contact::Best(const ContactGroup& group) { if (0 == group.Size()) { return {}; } const auto primary = group.PrimaryClaim(); if (primary) { return primary; } for (const auto& it : group) { const auto& claim = it.second; if (claim->isActive()) { return claim; } } return group.begin()->second; } std::string Contact::BestEmail() const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } return data->BestEmail(); } std::string Contact::BestPhoneNumber() const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } return data->BestPhoneNumber(); } std::string Contact::BestSocialMediaProfile( const proto::ContactItemType type) const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } return data->BestSocialMediaProfile(type); } std::vector<Contact::BlockchainAddress> Contact::BlockchainAddresses() const { std::vector<BlockchainAddress> output; Lock lock(lock_); auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } const auto& version = data->Version(); const auto section = data->Section(proto::CONTACTSECTION_ADDRESS); if (false == bool(section)) { return {}; } for (const auto& it : *section) { const auto& type = it.first; const auto& group = it.second; OT_ASSERT(group); const bool currency = proto::ValidContactItemType( {version, proto::CONTACTSECTION_CONTRACT}, type); if (false == currency) { continue; } for (const auto& it : *group) { const auto& item = it.second; OT_ASSERT(item); output.push_back({type, item->Value()}); } } return output; } std::uint32_t Contact::check_version( const std::uint32_t in, const std::uint32_t targetVersion) { // Upgrade version if (targetVersion > in) { return targetVersion; } return in; } std::shared_ptr<ContactData> Contact::Data() const { Lock lock(lock_); return merged_data(lock); } OTIdentifier Contact::generate_id() const { auto& crypto = OT::App().Crypto().Encode(); auto random = Data::Factory(); crypto.Nonce(ID_BYTES, random); auto output = Identifier::Factory(); output->CalculateDigest(random); return output; } std::string Contact::EmailAddresses(bool active) const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } return data->EmailAddresses(active); } std::string Contact::ExtractLabel(const Nym& nym) { return nym.Claims().Name(); } proto::ContactItemType Contact::ExtractType(const Nym& nym) { return nym.Claims().Type(); } const Identifier& Contact::ID() const { return id_; } void Contact::init_nyms() { OT_ASSERT(contact_data_); const auto nyms = contact_data_->Group( proto::CONTACTSECTION_RELATIONSHIP, proto::CITEMTYPE_CONTACT); if (false == bool(nyms)) { return; } primary_nym_ = nyms->Primary(); for (const auto& it : *nyms) { const auto& item = it.second; OT_ASSERT(item); const auto nymID = Identifier::Factory(item->Value()); auto& nym = nyms_[nymID]; nym = wallet_.Nym(nymID); if (false == bool(nym)) { otErr << OT_METHOD << __FUNCTION__ << ": Failed to load nym " << String::Factory(nymID) << std::endl; } } } const std::string& Contact::Label() const { return label_; } std::time_t Contact::LastUpdated() const { OT_ASSERT(contact_data_); const auto group = contact_data_->Group( proto::CONTACTSECTION_EVENT, proto::CITEMTYPE_REFRESHED); if (false == bool(group)) { return {}; } const auto claim = group->PrimaryClaim(); if (false == bool(claim)) { return {}; } try { if (sizeof(int) == sizeof(std::time_t)) { return std::stoi(claim->Value()); } else if (sizeof(long) == sizeof(std::time_t)) { return std::stol(claim->Value()); } else if (sizeof(long long) == sizeof(std::time_t)) { return std::stoll(claim->Value()); } else { OT_FAIL; } } catch (const std::out_of_range&) { return {}; } catch (const std::invalid_argument&) { return {}; } } std::shared_ptr<ContactData> Contact::merged_data(const Lock& lock) const { OT_ASSERT(contact_data_); OT_ASSERT(verify_write_lock(lock)); if (cached_contact_data_) { return cached_contact_data_; } cached_contact_data_.reset(new ContactData(*contact_data_)); auto& output = cached_contact_data_; OT_ASSERT(output); if (false == primary_nym_->empty()) { try { auto& primary = nyms_.at(primary_nym_); if (primary) { output.reset(new ContactData(*output + primary->Claims())); } } catch (const std::out_of_range&) { } } for (const auto& it : nyms_) { const auto& nymID = it.first; const auto& nym = it.second; if (false == bool(nym)) { continue; } if (nymID == primary_nym_) { continue; } output.reset(new ContactData(*output + nym->Claims())); } return output; } std::vector<opentxs::OTIdentifier> opentxs::Contact::Nyms( const bool includeInactive) const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } const auto group = data->Group( proto::CONTACTSECTION_RELATIONSHIP, proto::CITEMTYPE_CONTACT); if (false == bool(group)) { return {}; } std::vector<OTIdentifier> output{}; const auto& primaryID = group->Primary(); for (const auto& it : *group) { const auto& item = it.second; OT_ASSERT(item); const auto& itemID = item->ID(); if (false == (includeInactive || item->isActive())) { continue; } if (primaryID == itemID) { output.emplace(output.begin(), Identifier::Factory(item->Value())); } else { output.emplace(output.end(), Identifier::Factory(item->Value())); } } return output; } std::shared_ptr<ContactGroup> Contact::payment_codes( const Lock& lock, const proto::ContactItemType currency) const { const auto data = merged_data(lock); if (false == bool(data)) { return {}; } return data->Group(proto::CONTACTSECTION_PROCEDURE, currency); } std::string Contact::PaymentCode( const ContactData& data, const proto::ContactItemType currency) { auto group = data.Group(proto::CONTACTSECTION_PROCEDURE, currency); if (false == bool(group)) { return {}; } const auto item = Best(*group); if (false == bool(item)) { return {}; } return item->Value(); } std::string Contact::PaymentCode(const proto::ContactItemType currency) const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } return PaymentCode(*data, currency); } std::vector<std::string> Contact::PaymentCodes( const proto::ContactItemType currency) const { Lock lock(lock_); const auto group = payment_codes(lock, currency); lock.unlock(); if (false == bool(group)) { return {}; } std::vector<std::string> output{}; for (const auto& it : *group) { OT_ASSERT(it.second); const auto& item = *it.second; output.emplace_back(item.Value()); } return output; } std::string Contact::PhoneNumbers(bool active) const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } return data->PhoneNumbers(active); } std::string Contact::Print() const { Lock lock(lock_); std::stringstream out{}; out << "Contact: " << String::Factory(id_)->Get() << ", version " << version_ << "revision " << revision_ << "\n" << "Label: " << label_ << "\n"; if (false == parent_->empty()) { out << "Merged to: " << String::Factory(parent_)->Get() << "\n"; } if (false == merged_children_.empty()) { out << "Merged contacts:\n"; for (const auto& id : merged_children_) { out << " * " << String::Factory(id)->Get() << "\n"; } } if (0 < nyms_.size()) { out << "Contains nyms:\n"; for (const auto& it : nyms_) { const auto& id = it.first; out << " * " << String::Factory(id)->Get(); if (id == primary_nym_) { out << " (primary)"; } out << "\n"; } } auto data = merged_data(lock); if (data) { out << std::string(*data); } out << std::endl; return out.str(); } bool Contact::RemoveNym(const Identifier& nymID) { Lock lock(lock_); auto result = nyms_.erase(nymID); if (primary_nym_ == nymID) { primary_nym_ = Identifier::Factory(); } return (0 < result); } void Contact::SetLabel(const std::string& label) { Lock lock(lock_); label_ = label; revision_++; for (const auto& it : nyms_) { const auto& nymID = it.first; wallet_.SetNymAlias(nymID, label); } } std::string Contact::SocialMediaProfiles( const proto::ContactItemType type, bool active) const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); if (false == bool(data)) { return {}; } return data->SocialMediaProfiles(type, active); } const std::set<proto::ContactItemType> Contact::SocialMediaProfileTypes() const { Lock lock(lock_); const auto data = merged_data(lock); lock.unlock(); return data->SocialMediaProfileTypes(); } proto::ContactItemType Contact::type(const Lock& lock) const { OT_ASSERT(verify_write_lock(lock)); const auto data = merged_data(lock); if (false == bool(data)) { return proto::CITEMTYPE_ERROR; } return data->Type(); } proto::ContactItemType Contact::Type() const { Lock lock(lock_); return type(lock); } void Contact::Update(const proto::CredentialIndex& serialized) { auto nym = wallet_.Nym(serialized); if (false == bool(nym)) { otErr << OT_METHOD << __FUNCTION__ << ": Invalid serialized nym." << std::endl; return; } Lock lock(lock_); const auto& nymID = nym->ID(); auto it = nyms_.find(nymID); if (nyms_.end() == it) { add_nym(lock, nym, false); } else { it->second = nym; } update_label(lock, *nym); std::shared_ptr<ContactItem> claim(new ContactItem( String::Factory(id_)->Get(), CONTACT_CONTACT_DATA_VERSION, CONTACT_CONTACT_DATA_VERSION, proto::CONTACTSECTION_EVENT, proto::CITEMTYPE_REFRESHED, std::to_string(std::time(nullptr)), {proto::CITEMATTR_PRIMARY, proto::CITEMATTR_ACTIVE, proto::CITEMATTR_LOCAL}, NULL_START, NULL_END)); add_claim(lock, claim); } void Contact::update_label(const Lock& lock, const Nym& nym) { OT_ASSERT(verify_write_lock(lock)); if (false == label_.empty()) { return; } label_ = ExtractLabel(nym); } bool Contact::verify_write_lock(const Lock& lock) const { if (lock.mutex() != &lock_) { otErr << OT_METHOD << __FUNCTION__ << ": Incorrect mutex." << std::endl; return false; } if (false == lock.owns_lock()) { otErr << OT_METHOD << __FUNCTION__ << ": Lock not owned." << std::endl; return false; } return true; } } // namespace opentxs
// TEst inlining a slightly complex print function (containing a loop) // Commodore 64 PRG executable file .file [name="inline-function-print.prg", type="prg", segments="Program"] .segmentdef Program [segments="Basic, Code, Data"] .segmentdef Basic [start=$0801] .segmentdef Code [start=$80d] .segmentdef Data [startAfter="Code"] .segment Basic :BasicUpstart(main) .label screen = $400 .segment Code main: { .label print2_at = screen+2*$28 ldx #0 ldy #0 print1___b1: // for(byte i=0; msg[i]; i++) lda hello,y cmp #0 bne print1___b2 ldx #0 ldy #0 print2___b1: // for(byte i=0; msg[i]; i++) lda hello,y cmp #0 bne print2___b2 // } rts print2___b2: // at[j] = msg[i] lda hello,y sta print2_at,x // j += 2 inx inx // for(byte i=0; msg[i]; i++) iny jmp print2___b1 print1___b2: // at[j] = msg[i] lda hello,y sta screen,x // j += 2 inx inx // for(byte i=0; msg[i]; i++) iny jmp print1___b1 .segment Data hello: .text "hello world!" .byte 0 }
@******************************************************************************************************** @ uC/OS-II @ The Real-Time Kernel @ @ (c) Copyright 1992-2006, Micrium, Weston, FL @ All Rights Reserved @ @ ARM Cortex-M3 Port @ @ File : OS_CPU_A.ASM @ Version : V2.89 @ By : Jean J. Labrosse @ Brian Nagel @ @ For : ARMv7M Cortex-M3 @ Mode : Thumb2 @ Toolchain : GNU C Compiler @******************************************************************************************************** @******************************************************************************************************** @ PUBLIC FUNCTIONS @******************************************************************************************************** .extern OSRunning @ External references .extern OSPrioCur .extern OSPrioHighRdy .extern OSTCBCur .extern OSTCBHighRdy .extern OSIntExit .extern OSTaskSwHook .extern OS_CPU_ExceptStkBase .global OS_CPU_SR_Save @ Functions declared in this file .global OS_CPU_SR_Restore .global OSStartHighRdy .global OSCtxSw .global OSIntCtxSw .global OS_CPU_PendSVHandler @******************************************************************************************************** @ EQUATES @******************************************************************************************************** .equ NVIC_INT_CTRL, 0xE000ED04 @ Interrupt control state register. .equ NVIC_SYSPRI14, 0xE000ED22 @ System priority register (priority 14). .equ NVIC_PENDSV_PRI, 0xFF @ PendSV priority value (lowest). .equ NVIC_PENDSVSET, 0x10000000 @ Value to trigger PendSV exception. @******************************************************************************************************** @ CODE GENERATION DIRECTIVES @******************************************************************************************************** .text .align 2 .thumb .syntax unified @******************************************************************************************************** @ CRITICAL SECTION METHOD 3 FUNCTIONS @ @ Description: Disable/Enable interrupts by preserving the state of interrupts. Generally speaking you @ would store the state of the interrupt disable flag in the local variable 'cpu_sr' and then @ disable interrupts. 'cpu_sr' is allocated in all of uC/OS-II's functions that need to @ disable interrupts. You would restore the interrupt disable state by copying back 'cpu_sr' @ into the CPU's status register. @ @ Prototypes : OS_CPU_SR OS_CPU_SR_Save(void); @ void OS_CPU_SR_Restore(OS_CPU_SR cpu_sr); @ @ @ Note(s) : 1) These functions are used in general like this: @ @ void Task (void *p_arg) @ { @ #if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */ @ OS_CPU_SR cpu_sr; @ #endif @ @ : @ : @ OS_ENTER_CRITICAL(); /* cpu_sr = OS_CPU_SaveSR(); */ @ : @ : @ OS_EXIT_CRITICAL(); /* OS_CPU_RestoreSR(cpu_sr); */ @ : @ : @ } @******************************************************************************************************** .thumb_func OS_CPU_SR_Save: MRS R0, PRIMASK @ Set prio int mask to mask all (except faults) CPSID I BX LR .thumb_func OS_CPU_SR_Restore: MSR PRIMASK, R0 BX LR @******************************************************************************************************** @ START MULTITASKING @ void OSStartHighRdy(void) @ @ Note(s) : 1) This function triggers a PendSV exception (essentially, causes a context switch) to cause @ the first task to start. @ @ 2) OSStartHighRdy() MUST: @ a) Setup PendSV exception priority to lowest; @ b) Set initial PSP to 0, to tell context switcher this is first run; @ c) Set the main stack to OS_CPU_ExceptStkBase @ d) Set OSRunning to TRUE; @ e) Trigger PendSV exception; @ f) Enable interrupts (tasks will run with interrupts enabled). @******************************************************************************************************** .thumb_func OSStartHighRdy: LDR R0, =NVIC_SYSPRI14 @ Set the PendSV exception priority LDR R1, =NVIC_PENDSV_PRI STRB R1, [R0] MOVS R0, #0 @ Set the PSP to 0 for initial context switch call MSR PSP, R0 LDR R0, =OS_CPU_ExceptStkBase @ Initialize the MSP to the OS_CPU_ExceptStkBase LDR R1, [R0] MSR MSP, R1 LDR R0, =OSRunning @ OSRunning = TRUE MOVS R1, #1 STRB R1, [R0] LDR R0, =NVIC_INT_CTRL @ Trigger the PendSV exception (causes context switch) LDR R1, =NVIC_PENDSVSET STR R1, [R0] CPSIE I @ Enable interrupts at processor level OSStartHang: B OSStartHang @ Should never get here @******************************************************************************************************** @ PERFORM A CONTEXT SWITCH (From task level) @ void OSCtxSw(void) @ @ Note(s) : 1) OSCtxSw() is called when OS wants to perform a task context switch. This function @ triggers the PendSV exception which is where the real work is done. @******************************************************************************************************** .thumb_func OSCtxSw: LDR R0, =NVIC_INT_CTRL @ Trigger the PendSV exception (causes context switch) LDR R1, =NVIC_PENDSVSET STR R1, [R0] BX LR @******************************************************************************************************** @ PERFORM A CONTEXT SWITCH (From interrupt level) @ void OSIntCtxSw(void) @ @ Notes: 1) OSIntCtxSw() is called by OSIntExit() when it determines a context switch is needed as @ the result of an interrupt. This function simply triggers a PendSV exception which will @ be handled when there are no more interrupts active and interrupts are enabled. @******************************************************************************************************** .thumb_func OSIntCtxSw: LDR R0, =NVIC_INT_CTRL @ Trigger the PendSV exception (causes context switch) LDR R1, =NVIC_PENDSVSET STR R1, [R0] BX LR @******************************************************************************************************** @ HANDLE PendSV EXCEPTION @ void OS_CPU_PendSVHandler(void) @ @ Note(s) : 1) PendSV is used to cause a context switch. This is a recommended method for performing @ context switches with Cortex-M3. This is because the Cortex-M3 auto-saves half of the @ processor context on any exception, and restores same on return from exception. So only @ saving of R4-R11 is required and fixing up the stack pointers. Using the PendSV exception @ this way means that context saving and restoring is identical whether it is initiated from @ a thread or occurs due to an interrupt or exception. @ @ 2) Pseudo-code is: @ a) Get the process SP, if 0 then skip (goto d) the saving part (first context switch); @ b) Save remaining regs r4-r11 on process stack; @ c) Save the process SP in its TCB, OSTCBCur->OSTCBStkPtr = SP; @ d) Call OSTaskSwHook(); @ e) Get current high priority, OSPrioCur = OSPrioHighRdy; @ f) Get current ready thread TCB, OSTCBCur = OSTCBHighRdy; @ g) Get new process SP from TCB, SP = OSTCBHighRdy->OSTCBStkPtr; @ h) Restore R4-R11 from new process stack; @ i) Perform exception return which will restore remaining context. @ @ 3) On entry into PendSV handler: @ a) The following have been saved on the process stack (by processor): @ xPSR, PC, LR, R12, R0-R3 @ b) Processor mode is switched to Handler mode (from Thread mode) @ c) Stack is Main stack (switched from Process stack) @ d) OSTCBCur points to the OS_TCB of the task to suspend @ OSTCBHighRdy points to the OS_TCB of the task to resume @ @ 4) Since PendSV is set to lowest priority in the system (by OSStartHighRdy() above), we @ know that it will only be run when no other exception or interrupt is active, and @ therefore safe to assume that context being switched out was using the process stack (PSP). @******************************************************************************************************** .thumb_func OS_CPU_PendSVHandler: CPSID I @ Prevent interruption during context switch MRS R0, PSP @ PSP is process stack pointer CBZ R0, OS_CPU_PendSVHandler_nosave @ Skip register save the first time SUBS R0, R0, #0x20 @ Save remaining regs r4-11 on process stack STM R0, {R4-R11} LDR R1, =OSTCBCur @ OSTCBCur->OSTCBStkPtr = SP; LDR R1, [R1] STR R0, [R1] @ R0 is SP of process being switched out @ At this point, entire context of process has been saved OS_CPU_PendSVHandler_nosave: PUSH {R14} @ Save LR exc_return value LDR R0, =OSTaskSwHook @ OSTaskSwHook(); BLX R0 POP {R14} LDR R0, =OSPrioCur @ OSPrioCur = OSPrioHighRdy; LDR R1, =OSPrioHighRdy LDRB R2, [R1] STRB R2, [R0] LDR R0, =OSTCBCur @ OSTCBCur = OSTCBHighRdy; LDR R1, =OSTCBHighRdy LDR R2, [R1] STR R2, [R0] LDR R0, [R2] @ R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr; LDM R0, {R4-R11} @ Restore r4-11 from new process stack ADDS R0, R0, #0x20 MSR PSP, R0 @ Load PSP with new process SP ORR LR, LR, #0x04 @ Ensure exception return uses process stack CPSIE I BX LR @ Exception return will restore remaining context .end
#echo #echo ===== DATA01-BANK ===== * = $8000 bank_data01_begin: bank_data01_tileset_common_begin: #include "game/data/tilesets/common.asm" bank_data01_tileset_common_end: bank_data01_stage_plateau_begin: #include "game/data/stages/plateau/plateau.asm" bank_data01_stage_plateau_end: bank_data01_tileset_green_grass_begin: #include "game/data/tilesets/green_grass.asm" bank_data01_tileset_green_grass_end: bank_data01_tileset_menus_begin: #include "game/data/tilesets/menus_tileset.asm" bank_data01_tileset_menus_end: bank_data01_tileset_logo_begin: #include "game/data/tilesets/logo.asm" bank_data01_tileset_logo_end: bank_data01_config_screen_extra_begin: #include "game/logic/game_states/config_screen_extra_bank.asm" bank_data01_config_screen_extra_end: bank_data01_char_select_screen_extra_data_begin: #include "game/data/menu_char_select/screen.asm" #include "game/data/menu_char_select/tilesets.asm" #include "game/data/menu_char_select/anims.asm" bank_data01_char_select_screen_extra_data_end: bank_data01_char_select_screen_extra_code_begin: #include "game/logic/game_states/character_selection_screen/character_selection_screen_extra_code.asm" bank_data01_char_select_screen_extra_code_end: bank_data01_gameover_data_begin: #include "game/data/menu_gameover/tilesets.asm" bank_data01_gameover_data_end: bank_data01_end: #echo #echo DATA01-bank data size: #print bank_data01_end-bank_data01_begin #echo #echo DATA01-bank Plateau size: #print bank_data01_stage_plateau_end-bank_data01_stage_plateau_begin #echo #echo DATA01-bank Green grass tileset size: #print bank_data01_tileset_green_grass_end-bank_data01_tileset_green_grass_begin #echo #echo DATA01-bank Menus tileset size: #print bank_data01_tileset_menus_end-bank_data01_tileset_menus_begin #echo #echo DATA01-bank Common tileset size: #print bank_data01_tileset_common_end-bank_data01_tileset_common_begin #echo #echo DATA01-bank Logo tileset size: #print bank_data01_tileset_logo_end-bank_data01_tileset_logo_begin #echo #echo DATA01-bank Configuration screen extras: #print bank_data01_config_screen_extra_end-bank_data01_config_screen_extra_begin #echo #echo DATA01-bank Character selection screen extra data: #print bank_data01_char_select_screen_extra_data_end-bank_data01_char_select_screen_extra_data_begin #echo #echo DATA01-bank Character selection screen extra code: #print bank_data01_char_select_screen_extra_code_end-bank_data01_char_select_screen_extra_code_begin #echo #echo DATA01-bank Gameover screen data: #print bank_data01_gameover_data_end-bank_data01_gameover_data_begin #echo #echo DATA01-bank free space: #print $c000-* #if $c000-* < 0 #echo *** Error: DATA01 bank occupies too much space #else .dsb $c000-*, CURRENT_BANK_NUMBER #endif
; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" extern sym(vp8_bilinear_filters_x86_8) %define BLOCK_HEIGHT_WIDTH 4 %define vp8_filter_weight 128 %define VP8_FILTER_SHIFT 7 ;void vp8_filter_block1d_h6_mmx ;( ; unsigned char *src_ptr, ; unsigned short *output_ptr, ; unsigned int src_pixels_per_line, ; unsigned int pixel_step, ; unsigned int output_height, ; unsigned int output_width, ; short * vp8_filter ;) global sym(vp8_filter_block1d_h6_mmx) PRIVATE sym(vp8_filter_block1d_h6_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 7 GET_GOT rbx push rsi push rdi ; end prolog mov rdx, arg(6) ;vp8_filter movq mm1, [rdx + 16] ; do both the negative taps first!!! movq mm2, [rdx + 32] ; movq mm6, [rdx + 48] ; movq mm7, [rdx + 64] ; mov rdi, arg(1) ;output_ptr mov rsi, arg(0) ;src_ptr movsxd rcx, dword ptr arg(4) ;output_height movsxd rax, dword ptr arg(5) ;output_width ; destination pitch? pxor mm0, mm0 ; mm0 = 00000000 .nextrow: movq mm3, [rsi-2] ; mm3 = p-2..p5 movq mm4, mm3 ; mm4 = p-2..p5 psrlq mm3, 8 ; mm3 = p-1..p5 punpcklbw mm3, mm0 ; mm3 = p-1..p2 pmullw mm3, mm1 ; mm3 *= kernel 1 modifiers. movq mm5, mm4 ; mm5 = p-2..p5 punpckhbw mm4, mm0 ; mm5 = p2..p5 pmullw mm4, mm7 ; mm5 *= kernel 4 modifiers paddsw mm3, mm4 ; mm3 += mm5 movq mm4, mm5 ; mm4 = p-2..p5; psrlq mm5, 16 ; mm5 = p0..p5; punpcklbw mm5, mm0 ; mm5 = p0..p3 pmullw mm5, mm2 ; mm5 *= kernel 2 modifiers paddsw mm3, mm5 ; mm3 += mm5 movq mm5, mm4 ; mm5 = p-2..p5 psrlq mm4, 24 ; mm4 = p1..p5 punpcklbw mm4, mm0 ; mm4 = p1..p4 pmullw mm4, mm6 ; mm5 *= kernel 3 modifiers paddsw mm3, mm4 ; mm3 += mm5 ; do outer positive taps movd mm4, [rsi+3] punpcklbw mm4, mm0 ; mm5 = p3..p6 pmullw mm4, [rdx+80] ; mm5 *= kernel 0 modifiers paddsw mm3, mm4 ; mm3 += mm5 punpcklbw mm5, mm0 ; mm5 = p-2..p1 pmullw mm5, [rdx] ; mm5 *= kernel 5 modifiers paddsw mm3, mm5 ; mm3 += mm5 paddsw mm3, [GLOBAL(rd)] ; mm3 += round value psraw mm3, VP8_FILTER_SHIFT ; mm3 /= 128 packuswb mm3, mm0 ; pack and unpack to saturate punpcklbw mm3, mm0 ; movq [rdi], mm3 ; store the results in the destination %if ABI_IS_32BIT add rsi, dword ptr arg(2) ;src_pixels_per_line ; next line add rdi, rax; %else movsxd r8, dword ptr arg(2) ;src_pixels_per_line add rdi, rax; add rsi, r8 ; next line %endif dec rcx ; decrement count jnz .nextrow ; next row ; begin epilog pop rdi pop rsi RESTORE_GOT UNSHADOW_ARGS pop rbp ret ;void vp8_filter_block1dc_v6_mmx ;( ; short *src_ptr, ; unsigned char *output_ptr, ; int output_pitch, ; unsigned int pixels_per_line, ; unsigned int pixel_step, ; unsigned int output_height, ; unsigned int output_width, ; short * vp8_filter ;) global sym(vp8_filter_block1dc_v6_mmx) PRIVATE sym(vp8_filter_block1dc_v6_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 8 GET_GOT rbx push rsi push rdi ; end prolog movq mm5, [GLOBAL(rd)] push rbx mov rbx, arg(7) ;vp8_filter movq mm1, [rbx + 16] ; do both the negative taps first!!! movq mm2, [rbx + 32] ; movq mm6, [rbx + 48] ; movq mm7, [rbx + 64] ; movsxd rdx, dword ptr arg(3) ;pixels_per_line mov rdi, arg(1) ;output_ptr mov rsi, arg(0) ;src_ptr sub rsi, rdx sub rsi, rdx movsxd rcx, DWORD PTR arg(5) ;output_height movsxd rax, DWORD PTR arg(2) ;output_pitch ; destination pitch? pxor mm0, mm0 ; mm0 = 00000000 .nextrow_cv: movq mm3, [rsi+rdx] ; mm3 = p0..p8 = row -1 pmullw mm3, mm1 ; mm3 *= kernel 1 modifiers. movq mm4, [rsi + 4*rdx] ; mm4 = p0..p3 = row 2 pmullw mm4, mm7 ; mm4 *= kernel 4 modifiers. paddsw mm3, mm4 ; mm3 += mm4 movq mm4, [rsi + 2*rdx] ; mm4 = p0..p3 = row 0 pmullw mm4, mm2 ; mm4 *= kernel 2 modifiers. paddsw mm3, mm4 ; mm3 += mm4 movq mm4, [rsi] ; mm4 = p0..p3 = row -2 pmullw mm4, [rbx] ; mm4 *= kernel 0 modifiers. paddsw mm3, mm4 ; mm3 += mm4 add rsi, rdx ; move source forward 1 line to avoid 3 * pitch movq mm4, [rsi + 2*rdx] ; mm4 = p0..p3 = row 1 pmullw mm4, mm6 ; mm4 *= kernel 3 modifiers. paddsw mm3, mm4 ; mm3 += mm4 movq mm4, [rsi + 4*rdx] ; mm4 = p0..p3 = row 3 pmullw mm4, [rbx +80] ; mm4 *= kernel 3 modifiers. paddsw mm3, mm4 ; mm3 += mm4 paddsw mm3, mm5 ; mm3 += round value psraw mm3, VP8_FILTER_SHIFT ; mm3 /= 128 packuswb mm3, mm0 ; pack and saturate movd [rdi],mm3 ; store the results in the destination ; the subsequent iterations repeat 3 out of 4 of these reads. Since the ; recon block should be in cache this shouldn't cost much. Its obviously ; avoidable!!!. lea rdi, [rdi+rax] ; dec rcx ; decrement count jnz .nextrow_cv ; next row pop rbx ; begin epilog pop rdi pop rsi RESTORE_GOT UNSHADOW_ARGS pop rbp ret ;void bilinear_predict8x8_mmx ;( ; unsigned char *src_ptr, ; int src_pixels_per_line, ; int xoffset, ; int yoffset, ; unsigned char *dst_ptr, ; int dst_pitch ;) global sym(vp8_bilinear_predict8x8_mmx) PRIVATE sym(vp8_bilinear_predict8x8_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 6 GET_GOT rbx push rsi push rdi ; end prolog ;const short *HFilter = vp8_bilinear_filters_x86_8[xoffset]; ;const short *VFilter = vp8_bilinear_filters_x86_8[yoffset]; movsxd rax, dword ptr arg(2) ;xoffset mov rdi, arg(4) ;dst_ptr ; shl rax, 5 ; offset * 32 lea rcx, [GLOBAL(sym(vp8_bilinear_filters_x86_8))] add rax, rcx ; HFilter mov rsi, arg(0) ;src_ptr ; movsxd rdx, dword ptr arg(5) ;dst_pitch movq mm1, [rax] ; movq mm2, [rax+16] ; movsxd rax, dword ptr arg(3) ;yoffset pxor mm0, mm0 ; shl rax, 5 ; offset*32 add rax, rcx ; VFilter lea rcx, [rdi+rdx*8] ; movsxd rdx, dword ptr arg(1) ;src_pixels_per_line ; ; get the first horizontal line done ; movq mm3, [rsi] ; xx 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 movq mm4, mm3 ; make a copy of current line punpcklbw mm3, mm0 ; xx 00 01 02 03 04 05 06 punpckhbw mm4, mm0 ; pmullw mm3, mm1 ; pmullw mm4, mm1 ; movq mm5, [rsi+1] ; movq mm6, mm5 ; punpcklbw mm5, mm0 ; punpckhbw mm6, mm0 ; pmullw mm5, mm2 ; pmullw mm6, mm2 ; paddw mm3, mm5 ; paddw mm4, mm6 ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 paddw mm4, [GLOBAL(rd)] ; psraw mm4, VP8_FILTER_SHIFT ; movq mm7, mm3 ; packuswb mm7, mm4 ; add rsi, rdx ; next line .next_row_8x8: movq mm3, [rsi] ; xx 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 movq mm4, mm3 ; make a copy of current line punpcklbw mm3, mm0 ; xx 00 01 02 03 04 05 06 punpckhbw mm4, mm0 ; pmullw mm3, mm1 ; pmullw mm4, mm1 ; movq mm5, [rsi+1] ; movq mm6, mm5 ; punpcklbw mm5, mm0 ; punpckhbw mm6, mm0 ; pmullw mm5, mm2 ; pmullw mm6, mm2 ; paddw mm3, mm5 ; paddw mm4, mm6 ; movq mm5, mm7 ; movq mm6, mm7 ; punpcklbw mm5, mm0 ; punpckhbw mm6, mm0 pmullw mm5, [rax] ; pmullw mm6, [rax] ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 paddw mm4, [GLOBAL(rd)] ; psraw mm4, VP8_FILTER_SHIFT ; movq mm7, mm3 ; packuswb mm7, mm4 ; pmullw mm3, [rax+16] ; pmullw mm4, [rax+16] ; paddw mm3, mm5 ; paddw mm4, mm6 ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 paddw mm4, [GLOBAL(rd)] ; psraw mm4, VP8_FILTER_SHIFT ; packuswb mm3, mm4 movq [rdi], mm3 ; store the results in the destination %if ABI_IS_32BIT add rsi, rdx ; next line add rdi, dword ptr arg(5) ;dst_pitch ; %else movsxd r8, dword ptr arg(5) ;dst_pitch add rsi, rdx ; next line add rdi, r8 ;dst_pitch %endif cmp rdi, rcx ; jne .next_row_8x8 ; begin epilog pop rdi pop rsi RESTORE_GOT UNSHADOW_ARGS pop rbp ret ;void bilinear_predict8x4_mmx ;( ; unsigned char *src_ptr, ; int src_pixels_per_line, ; int xoffset, ; int yoffset, ; unsigned char *dst_ptr, ; int dst_pitch ;) global sym(vp8_bilinear_predict8x4_mmx) PRIVATE sym(vp8_bilinear_predict8x4_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 6 GET_GOT rbx push rsi push rdi ; end prolog ;const short *HFilter = vp8_bilinear_filters_x86_8[xoffset]; ;const short *VFilter = vp8_bilinear_filters_x86_8[yoffset]; movsxd rax, dword ptr arg(2) ;xoffset mov rdi, arg(4) ;dst_ptr ; lea rcx, [GLOBAL(sym(vp8_bilinear_filters_x86_8))] shl rax, 5 mov rsi, arg(0) ;src_ptr ; add rax, rcx movsxd rdx, dword ptr arg(5) ;dst_pitch movq mm1, [rax] ; movq mm2, [rax+16] ; movsxd rax, dword ptr arg(3) ;yoffset pxor mm0, mm0 ; shl rax, 5 add rax, rcx lea rcx, [rdi+rdx*4] ; movsxd rdx, dword ptr arg(1) ;src_pixels_per_line ; ; get the first horizontal line done ; movq mm3, [rsi] ; xx 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 movq mm4, mm3 ; make a copy of current line punpcklbw mm3, mm0 ; xx 00 01 02 03 04 05 06 punpckhbw mm4, mm0 ; pmullw mm3, mm1 ; pmullw mm4, mm1 ; movq mm5, [rsi+1] ; movq mm6, mm5 ; punpcklbw mm5, mm0 ; punpckhbw mm6, mm0 ; pmullw mm5, mm2 ; pmullw mm6, mm2 ; paddw mm3, mm5 ; paddw mm4, mm6 ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 paddw mm4, [GLOBAL(rd)] ; psraw mm4, VP8_FILTER_SHIFT ; movq mm7, mm3 ; packuswb mm7, mm4 ; add rsi, rdx ; next line .next_row_8x4: movq mm3, [rsi] ; xx 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 movq mm4, mm3 ; make a copy of current line punpcklbw mm3, mm0 ; xx 00 01 02 03 04 05 06 punpckhbw mm4, mm0 ; pmullw mm3, mm1 ; pmullw mm4, mm1 ; movq mm5, [rsi+1] ; movq mm6, mm5 ; punpcklbw mm5, mm0 ; punpckhbw mm6, mm0 ; pmullw mm5, mm2 ; pmullw mm6, mm2 ; paddw mm3, mm5 ; paddw mm4, mm6 ; movq mm5, mm7 ; movq mm6, mm7 ; punpcklbw mm5, mm0 ; punpckhbw mm6, mm0 pmullw mm5, [rax] ; pmullw mm6, [rax] ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 paddw mm4, [GLOBAL(rd)] ; psraw mm4, VP8_FILTER_SHIFT ; movq mm7, mm3 ; packuswb mm7, mm4 ; pmullw mm3, [rax+16] ; pmullw mm4, [rax+16] ; paddw mm3, mm5 ; paddw mm4, mm6 ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 paddw mm4, [GLOBAL(rd)] ; psraw mm4, VP8_FILTER_SHIFT ; packuswb mm3, mm4 movq [rdi], mm3 ; store the results in the destination %if ABI_IS_32BIT add rsi, rdx ; next line add rdi, dword ptr arg(5) ;dst_pitch ; %else movsxd r8, dword ptr arg(5) ;dst_pitch add rsi, rdx ; next line add rdi, r8 %endif cmp rdi, rcx ; jne .next_row_8x4 ; begin epilog pop rdi pop rsi RESTORE_GOT UNSHADOW_ARGS pop rbp ret ;void bilinear_predict4x4_mmx ;( ; unsigned char *src_ptr, ; int src_pixels_per_line, ; int xoffset, ; int yoffset, ; unsigned char *dst_ptr, ; int dst_pitch ;) global sym(vp8_bilinear_predict4x4_mmx) PRIVATE sym(vp8_bilinear_predict4x4_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 6 GET_GOT rbx push rsi push rdi ; end prolog ;const short *HFilter = vp8_bilinear_filters_x86_8[xoffset]; ;const short *VFilter = vp8_bilinear_filters_x86_8[yoffset]; movsxd rax, dword ptr arg(2) ;xoffset mov rdi, arg(4) ;dst_ptr ; lea rcx, [GLOBAL(sym(vp8_bilinear_filters_x86_8))] shl rax, 5 add rax, rcx ; HFilter mov rsi, arg(0) ;src_ptr ; movsxd rdx, dword ptr arg(5) ;ldst_pitch movq mm1, [rax] ; movq mm2, [rax+16] ; movsxd rax, dword ptr arg(3) ;yoffset pxor mm0, mm0 ; shl rax, 5 add rax, rcx lea rcx, [rdi+rdx*4] ; movsxd rdx, dword ptr arg(1) ;src_pixels_per_line ; ; get the first horizontal line done ; movd mm3, [rsi] ; xx 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 punpcklbw mm3, mm0 ; xx 00 01 02 03 04 05 06 pmullw mm3, mm1 ; movd mm5, [rsi+1] ; punpcklbw mm5, mm0 ; pmullw mm5, mm2 ; paddw mm3, mm5 ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 movq mm7, mm3 ; packuswb mm7, mm0 ; add rsi, rdx ; next line .next_row_4x4: movd mm3, [rsi] ; xx 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 punpcklbw mm3, mm0 ; xx 00 01 02 03 04 05 06 pmullw mm3, mm1 ; movd mm5, [rsi+1] ; punpcklbw mm5, mm0 ; pmullw mm5, mm2 ; paddw mm3, mm5 ; movq mm5, mm7 ; punpcklbw mm5, mm0 ; pmullw mm5, [rax] ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 movq mm7, mm3 ; packuswb mm7, mm0 ; pmullw mm3, [rax+16] ; paddw mm3, mm5 ; paddw mm3, [GLOBAL(rd)] ; xmm3 += round value psraw mm3, VP8_FILTER_SHIFT ; xmm3 /= 128 packuswb mm3, mm0 movd [rdi], mm3 ; store the results in the destination %if ABI_IS_32BIT add rsi, rdx ; next line add rdi, dword ptr arg(5) ;dst_pitch ; %else movsxd r8, dword ptr arg(5) ;dst_pitch ; add rsi, rdx ; next line add rdi, r8 %endif cmp rdi, rcx ; jne .next_row_4x4 ; begin epilog pop rdi pop rsi RESTORE_GOT UNSHADOW_ARGS pop rbp ret SECTION_RODATA align 16 rd: times 4 dw 0x40 align 16 global HIDDEN_DATA(sym(vp8_six_tap_mmx)) sym(vp8_six_tap_mmx): times 8 dw 0 times 8 dw 0 times 8 dw 128 times 8 dw 0 times 8 dw 0 times 8 dw 0 times 8 dw 0 times 8 dw -6 times 8 dw 123 times 8 dw 12 times 8 dw -1 times 8 dw 0 times 8 dw 2 times 8 dw -11 times 8 dw 108 times 8 dw 36 times 8 dw -8 times 8 dw 1 times 8 dw 0 times 8 dw -9 times 8 dw 93 times 8 dw 50 times 8 dw -6 times 8 dw 0 times 8 dw 3 times 8 dw -16 times 8 dw 77 times 8 dw 77 times 8 dw -16 times 8 dw 3 times 8 dw 0 times 8 dw -6 times 8 dw 50 times 8 dw 93 times 8 dw -9 times 8 dw 0 times 8 dw 1 times 8 dw -8 times 8 dw 36 times 8 dw 108 times 8 dw -11 times 8 dw 2 times 8 dw 0 times 8 dw -1 times 8 dw 12 times 8 dw 123 times 8 dw -6 times 8 dw 0
#ifndef EVENT_HANDLER_HPP_ #define EVENT_HANDLER_HPP_ #include "abcg.hpp" #include "../camera/Camera.hpp" class EventHandler { public: void handleEvent(SDL_Event& ev, Camera *camera); }; #endif
LXI H,2050 MVI C,05 LXI D,2060 L1: MOV A,M STAX D INX H INX D DCR C JNZ L1 HLT # ORG 2050 # DB 20,23,23,56,35
; A170794: a(n) = n^10*(n^2 + 1)/2. ; 0,1,2560,295245,8912896,126953125,1118624256,7061881225,34896609280,142958160441,505000000000,1582182900661,4489008906240,11717971807165,28491583515136,65161494140625,141287244169216,292319115565105,580200924326400,1109722992661981,2053120000000000,3686253696182421,6440781276920320,10978025471616985,18291875408510976,29850006103515625,47785061878667776,75150263214546885,116257230927953920,177117745219384621,266015745000000000,394241206037765281,577023702256844800,834710546969124705 mov $1,$0 pow $0,10 mov $2,$1 pow $2,2 mul $2,$0 add $0,$2 div $0,2
/**************************************************************************** ** ** Copyright (C) 2014 Governikus GmbH & Co. KG. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL21$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 2.1 or version 3 as published by the Free ** Software Foundation and appearing in the file LICENSE.LGPLv21 and ** LICENSE.LGPLv3 included in the packaging of this file. Please review the ** following information to ensure the GNU Lesser General Public License ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** As a special exception, The Qt Company gives you certain additional ** rights. These rights are described in The Qt Company LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "qsslellipticcurve.h" #ifndef QT_NO_DEBUG_STREAM #include <QDebug> #endif QT_BEGIN_NAMESPACE /*! \class QSslEllipticCurve \since 5.5 \brief Represents an elliptic curve for use by elliptic-curve cipher algorithms. \reentrant \ingroup network \ingroup ssl \inmodule QtNetwork The class QSslEllipticCurve represents an elliptic curve for use by elliptic-curve cipher algorithms. Elliptic curves can be constructed from a "short name" (SN) (fromShortName()), and by a call to QSslConfiguration::supportedEllipticCurves(). QSslEllipticCurve instances can be compared for equality and can be used as keys in QHash and QSet. They cannot be used as key in a QMap. */ /*! \fn QSslEllipticCurve::QSslEllipticCurve() Constructs an invalid elliptic curve. \sa isValid(), QSslConfiguration::supportedEllipticCurves() */ /*! \fn QSslEllipticCurve QSslEllipticCurve::fromShortName(const QString &name) Returns an QSslEllipticCurve instance representing the named curve \a name. The \a name is the conventional short name for the curve, as represented by RFC 4492 (for instance \c{secp521r1}), or as NIST short names (for instance \c{P-256}). The actual set of recognized names depends on the SSL implementation. If the given \a name is not supported, returns an invalid QSslEllipticCurve instance. \note The OpenSSL implementation of this function treats the name case-sensitively. \sa shortName() */ /*! \fn QSslEllipticCurve QSslEllipticCurve::fromLongName(const QString &name) Returns an QSslEllipticCurve instance representing the named curve \a name. The \a name is a long name for the curve, whose exact spelling depends on the SSL implementation. If the given \a name is not supported, returns an invalid QSslEllipticCurve instance. \note The OpenSSL implementation of this function treats the name case-sensitively. \sa longName() */ /*! \fn QString QSslEllipticCurve::shortName() const Returns the conventional short name for this curve. If this curve is invalid, returns an empty string. \sa longName() */ /*! \fn QString QSslEllipticCurve::longName() const Returns the conventional long name for this curve. If this curve is invalid, returns an empty string. \sa shortName() */ /*! \fn bool QSslEllipticCurve::isValid() const Returns true if this elliptic curve is a valid curve, false otherwise. */ /*! \fn bool QSslEllipticCurve::isTlsNamedCurve() const Returns true if this elliptic curve is one of the named curves that can be used in the key exchange when using an elliptic curve cipher with TLS; false otherwise. */ /*! \fn bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) \since 5.5 \relates QSslEllipticCurve Returns true if the curve \a lhs represents the same curve of \a rhs; */ /*! \fn bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) \since 5.5 \relates QSslEllipticCurve Returns true if the curve \a lhs represents a different curve than \a rhs; false otherwise. */ /*! \fn uint qHash(QSslEllipticCurve curve, uint seed) \since 5.5 \relates QHash Returns an hash value for the curve \a curve, using \a seed to seed the calculation. */ #ifndef QT_NO_DEBUG_STREAM /*! \relates QSslEllipticCurve \since 5.5 Writes the elliptic curve \a curve into the debug object \a debug for debugging purposes. \sa {Debugging Techniques} */ QDebug operator<<(QDebug debug, QSslEllipticCurve curve) { QDebugStateSaver saver(debug); debug.resetFormat().nospace(); debug << "QSslEllipticCurve(" << curve.shortName() << ')'; return debug; } #endif QT_END_NAMESPACE
; A024220: a(n) = [ (3rd elementary symmetric function of S(n))/(first elementary symmetric function of S(n)) ], where S(n) = {first n+2 positive integers congruent to 1 mod 3}. ; 2,19,71,188,410,784,1367,2226,3435,5078,7249,10049,13589,17990,23380,29897,37689,46911,57728,70315,84854,101537,120566,142150,166508,193869,224469,258554,296380,338210,384317,434984,490501,551168,617295,689199 mov $8,$0 mov $10,$0 add $10,1 lpb $10 mov $0,$8 mov $6,0 sub $10,1 sub $0,$10 mov $5,$0 mov $7,$0 add $7,1 lpb $7 mov $0,$5 mov $3,0 sub $7,1 sub $0,$7 mov $2,6 sub $2,$0 sub $2,8 add $3,$2 mov $0,$3 mul $3,2 mov $4,$2 add $4,4 add $4,$0 mul $0,$3 mod $0,9 add $4,$2 bin $4,2 mov $9,1 lpb $0 mov $0,1 sub $4,2 add $4,$9 lpe add $6,$4 lpe add $1,$6 lpe mov $0,$1
; ------------------------------------------------------- ; ; Random number generator. ; Based on source code found in: ; http://www.daniweb.com/software-development/assembly/ ; threads/292225/random-number-generating-in-assembly# ; ------------------------------------------------------- ; ; ---------------------------------------- ; ; Random number between 0 and 65535 ; @return [AX]: Random value ; ---------------------------------------- ; RANDOM PROC NEAR ; Lehmer linear congruential random number generator ; z= (a*z+b) mod m = (31*z+13)%19683 ; Rules for a, b, m by D. Knuth: ; 1. b and m must be relatively prime ; 2. a-1 must be divisible without remainder by all prime factors of m (19683 = 3^9), (31-1)%3=0 ; 3. if m is divisible by 4, a-1 must also be divisible by 4, 19683%4 != 0, ok ; 4. if conditions 1 to 3 met, period of {z1, z2, z3,...} is m-1 = 19682 (Donald says) .DATA RANDOM_SEED DW 0ABBAH RANDOM_ANT DW 0ABBAH .CODE ; save used registers push dx push bx mov ax, RANDOM_SEED ; set new initial value z mov dx, 0 mov bx, 001FH ; 31D mul bx ; 31 * z ; result dx:ax, higher value in dx, lower value in ax add ax, 000DH ; +13 ;mov bx, 4CE3H ; 19683D mov bx, 0E6A9H ; 59049D div bx ; div by 19683D ; result ax:dx, quotient in ax, remainder in dx (this is the rnz) mov RANDOM_SEED, dx mov ax, dx ; restore used registers pop bx pop dx ret RANDOM ENDP ; -------------------------------------------------------- ; ; Returns random value in the range [-r, r] ; @param [WORD]: Range (r) ; @return [AX]: Random value ; -------------------------------------------------------- ; RANDOM_RANGE PROC NEAR ; Stack preparation PUSH BP MOV BP, SP PUSH CX PUSH DX CALL RANDOM ; Restrict value to range [0, 2r] MOV DX, 0 MOV CX, [BP+4] ; Range SHL CX, 1 INC CX DIV CX ; Residue is substracted to the range so it becomes [-r, r] MOV CX, [BP+4] ; Range SUB DX, CX MOV AX, DX ; Stack restore POP DX POP CX POP BP RET RANDOM_RANGE ENDP
// Copyright 2020 The IREE Authors // // Licensed under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "iree/compiler/Dialect/Vulkan/Utils/TargetEnvironment.h" #include "iree/compiler/Dialect/Vulkan/Utils/TargetTriple.h" #include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h" #include "mlir/IR/Builders.h" namespace mlir { namespace iree_compiler { namespace IREE { namespace Vulkan { namespace { /// Gets the corresponding SPIR-V version for the ggiven Vulkan target /// environment. spirv::Version convertVersion(Vulkan::TargetEnvAttr vkTargetEnv) { // Vulkan 1.2 supports up to SPIR-V 1.5 by default. if (vkTargetEnv.getVersion() == Version::V_1_2) return spirv::Version::V_1_5; // Special extension to enable SPIR-V 1.4. if (llvm::is_contained(vkTargetEnv.getExtensions(), Extension::VK_KHR_spirv_1_4)) return spirv::Version::V_1_4; switch (vkTargetEnv.getVersion()) { case Version::V_1_0: // Vulkan 1.0 only supports SPIR-V 1.0 by default. return spirv::Version::V_1_0; case Version::V_1_1: // Vulkan 1.1 supports up to SPIR-V 1.3 by default. return spirv::Version::V_1_3; default: break; } llvm_unreachable("unhandled Vulkan version!"); } /// Gets the corresponding SPIR-V extensions for the given Vulkan target /// environment. void convertExtensions(Vulkan::TargetEnvAttr vkTargetEnv, SmallVectorImpl<spirv::Extension> &extensions) { extensions.clear(); for (Extension ext : vkTargetEnv.getExtensions()) { switch (ext) { case Extension::VK_KHR_16bit_storage: extensions.push_back(spirv::Extension::SPV_KHR_16bit_storage); break; case Extension::VK_KHR_8bit_storage: extensions.push_back(spirv::Extension::SPV_KHR_8bit_storage); break; case Extension::VK_KHR_shader_float16_int8: // This extension allows using certain SPIR-V capabilities. break; case Extension::VK_KHR_spirv_1_4: // This extension only affects SPIR-V version. break; case Extension::VK_KHR_storage_buffer_storage_class: extensions.push_back( spirv::Extension::SPV_KHR_storage_buffer_storage_class); break; case Extension::VK_KHR_variable_pointers: extensions.push_back(spirv::Extension::SPV_KHR_variable_pointers); break; case Extension::VK_NV_cooperative_matrix: extensions.push_back(spirv::Extension::SPV_NV_cooperative_matrix); break; } } } /// Gets the corresponding SPIR-V capabilities for the given Vulkan target /// environment. void convertCapabilities(Vulkan::TargetEnvAttr vkTargetEnv, SmallVectorImpl<spirv::Capability> &capabilities) { // Add unconditionally supported capabilities. // Note that "Table 54. List of SPIR-V Capabilities and enabling features or // extensions" in the Vulkan spec contains the full list. Right now omit those // implicitly declared or not useful for us. capabilities.assign({spirv::Capability::Shader}); auto vkCapabilities = vkTargetEnv.getCapabilitiesAttr(); #define MAP_PRIMITIVE_TYPE(type) \ if (vkCapabilities.shader##type()) \ capabilities.push_back(spirv::Capability::type) MAP_PRIMITIVE_TYPE(Float64); MAP_PRIMITIVE_TYPE(Float16); MAP_PRIMITIVE_TYPE(Int64); MAP_PRIMITIVE_TYPE(Int16); MAP_PRIMITIVE_TYPE(Int8); #undef MAP_PRIMITIVE_TYPE #define MAP_8_16_BIT_STORAGE(vkFeature, spvCap) \ if (vkCapabilities.vkFeature()) \ capabilities.push_back(spirv::Capability::spvCap) MAP_8_16_BIT_STORAGE(storageBuffer16BitAccess, StorageBuffer16BitAccess); MAP_8_16_BIT_STORAGE(uniformAndStorageBuffer16BitAccess, StorageUniform16); MAP_8_16_BIT_STORAGE(storagePushConstant16, StoragePushConstant16); MAP_8_16_BIT_STORAGE(storageBuffer8BitAccess, StorageBuffer8BitAccess); MAP_8_16_BIT_STORAGE(uniformAndStorageBuffer8BitAccess, UniformAndStorageBuffer8BitAccess); MAP_8_16_BIT_STORAGE(storagePushConstant8, StoragePushConstant8); #undef MAP_8_16_BIT_STORAGE auto subgroupFeatures = vkCapabilities.subgroupFeatures().getValue(); #define MAP_SUBGROUP_FEATURE(featureBit) \ if ((subgroupFeatures & SubgroupFeature::featureBit) == \ SubgroupFeature::featureBit) \ capabilities.push_back(spirv::Capability::GroupNonUniform##featureBit) if ((subgroupFeatures & SubgroupFeature::Basic) == SubgroupFeature::Basic) { capabilities.push_back(spirv::Capability::GroupNonUniform); } MAP_SUBGROUP_FEATURE(Vote); MAP_SUBGROUP_FEATURE(Arithmetic); MAP_SUBGROUP_FEATURE(Ballot); MAP_SUBGROUP_FEATURE(Shuffle); MAP_SUBGROUP_FEATURE(ShuffleRelative); MAP_SUBGROUP_FEATURE(Clustered); MAP_SUBGROUP_FEATURE(Quad); MAP_SUBGROUP_FEATURE(PartitionedNV); #undef MAP_SUBGROUP_FEATURE if (vkCapabilities.variablePointers()) { capabilities.push_back(spirv::Capability::VariablePointers); } if (vkCapabilities.variablePointersStorageBuffer()) { capabilities.push_back(spirv::Capability::VariablePointersStorageBuffer); } if (ArrayAttr attr = vkCapabilities.cooperativeMatrixPropertiesNV()) { if (!attr.empty()) { capabilities.push_back(spirv::Capability::CooperativeMatrixNV); } } } /// Gets the corresponding SPIR-V resource limits for the given Vulkan target /// environment. spirv::ResourceLimitsAttr convertResourceLimits( Vulkan::TargetEnvAttr vkTargetEnv) { MLIRContext *context = vkTargetEnv.getContext(); auto vkCapabilities = vkTargetEnv.getCapabilitiesAttr(); SmallVector<Attribute, 1> spvAttrs; if (ArrayAttr attr = vkCapabilities.cooperativeMatrixPropertiesNV()) { for (auto cooperativeMatrixPropertiesNV : attr.getAsRange<Vulkan::CooperativeMatrixPropertiesNVAttr>()) { spvAttrs.push_back(spirv::CooperativeMatrixPropertiesNVAttr::get( cooperativeMatrixPropertiesNV.mSize(), cooperativeMatrixPropertiesNV.nSize(), cooperativeMatrixPropertiesNV.kSize(), cooperativeMatrixPropertiesNV.aType(), cooperativeMatrixPropertiesNV.bType(), cooperativeMatrixPropertiesNV.cType(), cooperativeMatrixPropertiesNV.resultType(), cooperativeMatrixPropertiesNV.scope().cast<spirv::ScopeAttr>(), context)); } } return spirv::ResourceLimitsAttr::get( vkCapabilities.maxComputeSharedMemorySize(), vkCapabilities.maxComputeWorkGroupInvocations(), vkCapabilities.maxComputeWorkGroupSize(), vkCapabilities.subgroupSize(), ArrayAttr::get(context, spvAttrs), context); } } // anonymous namespace Vulkan::TargetEnvAttr getTargetEnvForTriple(MLIRContext *context, llvm::StringRef triple) { return TargetTriple::get(triple.data()).getTargetEnv(context); } spirv::TargetEnvAttr convertTargetEnv(Vulkan::TargetEnvAttr vkTargetEnv) { auto spvVersion = convertVersion(vkTargetEnv); SmallVector<spirv::Extension, 4> spvExtensions; convertExtensions(vkTargetEnv, spvExtensions); SmallVector<spirv::Capability, 8> spvCapabilities; convertCapabilities(vkTargetEnv, spvCapabilities); auto spvLimits = convertResourceLimits(vkTargetEnv); auto triple = spirv::VerCapExtAttr::get( spvVersion, spvCapabilities, spvExtensions, vkTargetEnv.getContext()); return spirv::TargetEnvAttr::get(triple, vkTargetEnv.getVendorID(), vkTargetEnv.getDeviceType(), vkTargetEnv.getDeviceID(), spvLimits); } } // namespace Vulkan } // namespace IREE } // namespace iree_compiler } // namespace mlir
; A130624: Binomial transform of A101000. ; 0,1,5,12,23,43,84,169,341,684,1367,2731,5460,10921,21845,43692,87383,174763,349524,699049,1398101,2796204,5592407,11184811,22369620,44739241,89478485,178956972,357913943,715827883,1431655764,2863311529,5726623061,11453246124,22906492247,45812984491,91625968980,183251937961,366503875925,733007751852,1466015503703,2932031007403,5864062014804,11728124029609,23456248059221,46912496118444,93824992236887,187649984473771,375299968947540,750599937895081,1501199875790165,3002399751580332,6004799503160663 lpb $0,1 sub $0,1 add $2,2 add $3,$2 sub $3,1 add $4,1 mul $4,2 add $2,$4 sub $2,$3 lpe add $1,$3
; float __fastcall dot_sse_asm(const float *a, const float *b, size_t len); ; public dot_sse_asm .code dot_sse_asm PROC ; x64 calling convension: ; - rcx ... a (1st argument) ; - rdx ... b (2nd argument) ; - r8d ... len (3rd argument) ; - xmm0 ... return value (for float type) push rbx ; secure RBX address sub rsp, 16 ; allocate `float accum[4]` on stack [*] mov rbx, rsp ; RBX= accum xorps xmm1, xmm1 ; nullify xmm1 register mov rax, 0 ; using RAX as offset multiplication: movaps xmm0, XMMWORD PTR [rcx+rax] ; xmm0= (a[0] a[1] a[2] a[3]) mulps xmm0, XMMWORD PTR [rdx+rax] ; xmm0*=(b[0] b[1] b[2] b[3]) addps xmm1, xmm0 ; xmm0+=xmm0 add rax, 16 ; a+=4; b+=4 sub r8d, 4 ; len-=4 jne multiplication ; if (len != 0) goto multiplication movaps XMMWORD PTR [rbx], xmm1 ; store result to the local float[4] movss xmm0, DWORD PTR [rbx] ; xmm0[0:1]= accum[0] addss xmm0, DWORD PTR [rbx+4] ; xmm0[0:1]+=accum[1] addss xmm0, DWORD PTR [rbx+8] ; xmm0[0:1]+=accum[2] addss xmm0, DWORD PTR [rbx+12] ; xmm0[0:1]+=accum[3] add rsp, 16 pop rbx ret 0 ; [*] "call" of this function and the "push" of RBX moves subtracts RSP ; 8 bytes per each so it is 16-byte aligned there. dot_sse_asm endp end
#pragma once #include <exception> class StatusCodeNotFoundException : std::exception { public: const char* getError() { return "Status code not found!"; } };
<% from pwnlib.shellcraft.arm.linux import syscall %> <%page args="file, tvp"/> <%docstring> Invokes the syscall utimes. See 'man 2 utimes' for more information. Arguments: file(char): file tvp(timeval): tvp </%docstring> ${syscall('SYS_utimes', file, tvp)}
; Substitute Substring in string V2.00  1990 Tony Tebby QJUMP section cv xdef cv_subss include 'dev8_keys_err' ;+++ ; Substitutes a string for a substring in a string. If the resulting string is ; too long, it returns an error. ; ; Registers: ; Entry Exit ; d0 pointer to old substring error code ; d1 length of substring preserved ; d2 max length of string preserved ; a1 pointer to string preserved ; a2 pointer to substitute string preserved ; all other registers preserved ; status standard (err.inam if new length too great) ;--- cv_subss css.reg reg d1/d3/d4/d5/d6/a1/a2 movem.l css.reg,-(sp) move.w (a1),d6 ; old name length move.w (a2)+,d5 ; length of new bit move.w d5,d3 add.w d5,d6 sub.w d1,d6 ; total length add.w d0,d5 ; end of new bit add.w d0,d1 ; end of old bit move.w d0,d4 ; start of old/new bit cmp.w d2,d6 ; name too long? bgt.s css_inam ; ... no css_do move.w d6,(a1)+ ; ... string length sub.w d5,d1 ; string increased or decreased? bge.s css_down css_up add.w d6,a1 ; start at top end sub.w d5,d6 ; copying this much lea (a1,d1.w),a0 bra.s css_uele css_uelp move.b -(a0),-(a1) css_uele dbra d6,css_uelp add.w d3,a2 ; end of new bit bra.s css_usle css_uslp move.b -(a2),-(a1) css_usle dbra d3,css_uslp bra.s css_exok css_down add.w d4,a1 ; put new bit in here bra.s css_dsle css_dslp move.b (a2)+,(a1)+ css_dsle dbra d3,css_dslp tst.w d1 ; any distance to move? beq.s css_exok ; ... no lea (a1,d1.w),a0 sub.w d5,d6 ; amount to move bra.s css_dele css_delp move.b (a0)+,(a1)+ css_dele dbra d6,css_delp css_exok moveq #0,d0 css_exit movem.l (sp)+,css.reg rts css_inam moveq #err.inam,d0 bra.s css_exit end
#ifndef CAFFE_DATA_TRANSFORMER_HPP #define CAFFE_DATA_TRANSFORMER_HPP #include <vector> #include "caffe/blob.hpp" #include "caffe/common.hpp" #include "caffe/proto/caffe.pb.h" namespace caffe { /** * @brief Applies common transformations to the input data, such as * scaling, mirroring, substracting the image mean... */ template <typename Dtype> class DataTransformer { public: explicit DataTransformer(const TransformationParameter& param, Phase phase); virtual ~DataTransformer() {} /** * @brief Initialize the Random number generations if needed by the * transformation. */ void InitRand(); /** * @brief Applies the transformation defined in the data layer's * transform_param block to the data. * * @param datum * Datum containing the data to be transformed. * @param transformed_blob * This is destination blob. It can be part of top blob's data if * set_cpu_data() is used. See data_layer.cpp for an example. */ void Transform(const Datum& datum, Blob<Dtype>* transformed_blob); /** * @brief Applies the transformation defined in the data layer's * transform_param block to a vector of Datum. * * @param datum_vector * A vector of Datum containing the data to be transformed. * @param transformed_blob * This is destination blob. It can be part of top blob's data if * set_cpu_data() is used. See memory_layer.cpp for an example. */ void Transform(const vector<Datum> & datum_vector, Blob<Dtype>* transformed_blob); /** * @brief Applies the transformation defined in the data layer's * transform_param block to a vector of Mat. * * @param mat_vector * A vector of Mat containing the data to be transformed. * @param transformed_blob * This is destination blob. It can be part of top blob's data if * set_cpu_data() is used. See memory_layer.cpp for an example. */ void Transform(const vector<cv::Mat> & mat_vector, Blob<Dtype>* transformed_blob); /** * @brief Applies the transformation defined in the data layer's * transform_param block to a cv::Mat * * @param cv_img * cv::Mat containing the data to be transformed. * @param transformed_blob * This is destination blob. It can be part of top blob's data if * set_cpu_data() is used. See image_data_layer.cpp for an example. */ void Transform(const cv::Mat& cv_img, Blob<Dtype>* transformed_blob); /** * @brief Applies the same transformation defined in the data layer's * transform_param block to all the num images in a input_blob. * * @param input_blob * A Blob containing the data to be transformed. It applies the same * transformation to all the num images in the blob. * @param transformed_blob * This is destination blob, it will contain as many images as the * input blob. It can be part of top blob's data. */ void Transform(Blob<Dtype>* input_blob, Blob<Dtype>* transformed_blob); //#ifndef OSX void LabelmapTransform(const cv::Mat& cv_img, Blob<Dtype>* transformed_blob, const int h_off, const int w_off, const bool do_mirror); //#endif //#ifndef OSX void LocTransform(const cv::Mat& cv_img, Blob<Dtype>* transformed_blob, int &h_off, int &w_off, bool &do_mirror); //#endif /** * @brief Infers the shape of transformed_blob will have when * the transformation is applied to the data. * * @param datum * Datum containing the data to be transformed. */ vector<int> InferBlobShape(const Datum& datum); /** * @brief Infers the shape of transformed_blob will have when * the transformation is applied to the data. * It uses the first element to infer the shape of the blob. * * @param datum_vector * A vector of Datum containing the data to be transformed. */ vector<int> InferBlobShape(const vector<Datum> & datum_vector); /** * @brief Infers the shape of transformed_blob will have when * the transformation is applied to the data. * It uses the first element to infer the shape of the blob. * * @param mat_vector * A vector of Mat containing the data to be transformed. */ vector<int> InferBlobShape(const vector<cv::Mat> & mat_vector); /** * @brief Infers the shape of transformed_blob will have when * the transformation is applied to the data. * * @param cv_img * cv::Mat containing the data to be transformed. */ vector<int> InferBlobShape(const cv::Mat& cv_img); protected: /** * @brief Generates a random integer from Uniform({0, 1, ..., n-1}). * * @param n * The upperbound (exclusive) value of the random number. * @return * A uniformly random integer value from ({0, 1, ..., n-1}). */ virtual int Rand(int n); void Transform(const Datum& datum, Dtype* transformed_data); // Tranformation parameters TransformationParameter param_; shared_ptr<Caffe::RNG> rng_; Phase phase_; Blob<Dtype> data_mean_; vector<Dtype> mean_values_; }; } // namespace caffe #endif // CAFFE_DATA_TRANSFORMER_HPP_
; A049706: a(n) = T(n,n+2), array T as in A049704. ; 1,1,3,5,8,11,15,20,25,30,37,44,52,61,68,76,88,99,111,124,134,145,161,176,190,206,221,236,256,274,293,316,334,352,372,390,414,441,462,482,510,536,563,594,616,639,673,704,733,764,790,818,856,891,920,952,982 seq $0,49697 ; a(n)=T(n,n+1), array T as in A049695. sub $0,2 div $0,2 add $0,1
; A169524: Number of reduced words of length n in Coxeter group on 31 generators S_i with relations (S_i)^2 = (S_i S_j)^34 = I. ; 1,31,930,27900,837000,25110000,753300000,22599000000,677970000000,20339100000000,610173000000000,18305190000000000,549155700000000000,16474671000000000000,494240130000000000000,14827203900000000000000 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,30 lpe mov $0,$2 div $0,30
dnl Intel Pentium-4 mpn_rshift -- right shift. dnl Copyright 2001, 2002 Free Software Foundation, Inc. dnl dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or dnl modify it under the terms of the GNU Lesser General Public License as dnl published by the Free Software Foundation; either version 3 of the dnl License, or (at your option) any later version. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU dnl Lesser General Public License for more details. dnl dnl You should have received a copy of the GNU Lesser General Public License dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. include(`../config.m4') C P4 Willamette, Northwood: 1.75 cycles/limb C P4 Prescott: 2.0 cycles/limb MULFUNC_PROLOGUE(mpn_rshift) include_mpn(`x86/pentium/mmx/rshift.asm')
db DEX_NIDOKING ; pokedex id db 81 ; base hp db 92 ; base attack db 77 ; base defense db 85 ; base speed db 75 ; base special db POISON ; species type 1 db GROUND ; species type 2 db 45 ; catch rate db 195 ; base exp yield INCBIN "pic/ymon/nidoking.pic",0,1 ; 77, sprite dimensions dw NidokingPicFront dw NidokingPicBack ; attacks known at lvl 0 db TACKLE db HORN_ATTACK db POISON_STING db THRASH db 3 ; growth rate ; learnset tmlearn 1,5,6,7,8 tmlearn 9,10,11,12,13,14,15,16 tmlearn 17,18,19,20,24 tmlearn 25,26,27,31,32 tmlearn 33,34,38,40 tmlearn 44,48 tmlearn 50,53,54 db BANK(NidokingPicFront)
; 0 - PUSH argument 0 leaw $0, %A movw %A, %S leaw $ARG, %A movw (%A), %D movw %D, %A addw %S, %A, %A movw (%A), %S leaw $SP, %A movw (%A), %A movw %S, (%A) incw %A movw %A, %S leaw $SP, %A movw %S, (%A) ; 1 - PUSH argument 1 leaw $1, %A movw %A, %S leaw $ARG, %A movw (%A), %D movw %D, %A addw %S, %A, %A movw (%A), %S leaw $SP, %A movw (%A), %A movw %S, (%A) incw %A movw %A, %S leaw $SP, %A movw %S, (%A) ; 2 - PUSH argument 2 leaw $2, %A movw %A, %S leaw $ARG, %A movw (%A), %D movw %D, %A addw %S, %A, %A movw (%A), %S leaw $SP, %A movw (%A), %A movw %S, (%A) incw %A movw %A, %S leaw $SP, %A movw %S, (%A) ; End
#include "common/hash_util.h" #include <cstring> #include <iostream> #include <limits> #include <random> #include <string> #include <thread> // NOLINT #include <unordered_set> #include <vector> #include "gtest/gtest.h" namespace terrier { // NOLINTNEXTLINE TEST(HashUtilTests, HashTest) { // INT std::vector<int> vals0 = {std::numeric_limits<int>::min(), 0, std::numeric_limits<int>::max() - 1}; for (const auto &val : vals0) { auto copy = val; // NOLINT EXPECT_EQ(common::HashUtil::Hash(val), common::HashUtil::Hash(copy)); EXPECT_NE(common::HashUtil::Hash(val + 1), common::HashUtil::Hash(val)); } // FLOAT std::vector<float> vals1 = {std::numeric_limits<float>::min(), 0.0f, std::numeric_limits<float>::max() - 1.0f}; for (const auto &val : vals1) { auto copy = val; // NOLINT EXPECT_EQ(common::HashUtil::Hash(val), common::HashUtil::Hash(copy)); // This fails for max float value // EXPECT_NE(common::HashUtil::Hash(val+1.0f), common::HashUtil::Hash(val)); } // CHAR std::vector<char> vals2 = {'f', 'u', 'c', 'k', 't', 'k'}; for (const auto &val : vals2) { auto copy = val; // NOLINT EXPECT_EQ(common::HashUtil::Hash(val), common::HashUtil::Hash(copy)); EXPECT_NE(common::HashUtil::Hash(val + 1), common::HashUtil::Hash(val)); } // STRING std::vector<std::string> vals3 = {"XXX", "YYY", "ZZZ"}; for (const auto &val : vals3) { auto copy = val; // NOLINT EXPECT_EQ(common::HashUtil::Hash(val), common::HashUtil::Hash(copy)); EXPECT_NE(common::HashUtil::Hash("WUTANG"), common::HashUtil::Hash(val)); } } // NOLINTNEXTLINE TEST(HashUtilTests, HashStringsTest) { std::string val = "ABCXYZ"; // EXPECT_EQ(common::HashUtil::Hash(val), common::HashUtil::Hash(val)); common::hash_t hash0 = common::HashUtil::Hash(val); common::hash_t hash1 = common::HashUtil::Hash("ABCXYZ"); EXPECT_EQ(hash0, hash1); } // NOLINTNEXTLINE TEST(HashUtilTests, HashMixedTest) { // There is nothing special about this test. It's just a sanity // check for me to make sure that things are working correctly in // another part of the system. enum class wutang { RZA, GZA, RAEKWON, METHODMAN, GHOSTFACE, ODB, INSPECTAH }; common::hash_t hash0 = common::HashUtil::Hash(wutang::RAEKWON); common::hash_t hash1 = common::HashUtil::Hash(wutang::RAEKWON); EXPECT_EQ(hash0, hash1); wutang val0 = wutang::ODB; hash0 = common::HashUtil::CombineHashes(hash0, common::HashUtil::Hash(val0)); hash1 = common::HashUtil::CombineHashes(hash1, common::HashUtil::Hash(val0)); EXPECT_EQ(hash0, hash1); std::string val1 = "protect-yo-neck.csv"; hash0 = common::HashUtil::CombineHashes(hash0, common::HashUtil::Hash(val1)); hash1 = common::HashUtil::CombineHashes(hash1, common::HashUtil::Hash(val1)); EXPECT_EQ(hash0, hash1); char val2 = ','; hash0 = common::HashUtil::CombineHashes(hash0, common::HashUtil::Hash(val2)); hash1 = common::HashUtil::CombineHashes(hash1, common::HashUtil::Hash(val2)); EXPECT_EQ(hash0, hash1); } // NOLINTNEXTLINE TEST(HashUtilTests, CombineHashesTest) { // INT std::vector<int> vals0 = {0, 1, 1 << 20}; common::hash_t hash0 = 0; common::hash_t hash1 = 0; for (const auto &val : vals0) { hash0 = common::HashUtil::CombineHashes(hash0, common::HashUtil::Hash(val)); hash1 = common::HashUtil::CombineHashes(hash1, common::HashUtil::Hash(val)); EXPECT_EQ(hash0, hash1); } // STRING std::vector<std::string> vals1 = {"XXX", "YYY", "ZZZ"}; for (const auto &val : vals1) { hash0 = common::HashUtil::CombineHashes(hash0, common::HashUtil::Hash(val)); hash1 = common::HashUtil::CombineHashes(hash1, common::HashUtil::Hash(val)); EXPECT_EQ(hash0, hash1); } // MIXED ASSERT_EQ(vals0.size(), vals1.size()); for (int i = 0; i < static_cast<int>(vals0.size()); i++) { hash0 = common::HashUtil::CombineHashes(hash0, common::HashUtil::Hash(vals0[i])); hash1 = common::HashUtil::CombineHashes(hash1, common::HashUtil::Hash(vals0[i])); EXPECT_EQ(hash0, hash1); hash0 = common::HashUtil::CombineHashes(hash0, common::HashUtil::Hash(vals1[i])); hash1 = common::HashUtil::CombineHashes(hash1, common::HashUtil::Hash(vals1[i])); EXPECT_EQ(hash0, hash1); } } // NOLINTNEXTLINE TEST(HashUtilTests, CombineHashInRangeTest) { std::vector<std::string> vals0 = {"XXX", "YYY", "ZZZ"}; common::hash_t hash0 = 0; for (const auto &val : vals0) { auto copy = val; // NOLINT hash0 = common::HashUtil::CombineHashes(hash0, common::HashUtil::Hash(copy)); } common::hash_t hash1 = 0; hash1 = common::HashUtil::CombineHashInRange(hash1, vals0.begin(), vals0.end()); EXPECT_EQ(hash0, hash1); } // NOLINTNEXTLINE TEST(HashUtilTests, SumHashesTest) { common::hash_t hash0 = common::HashUtil::Hash("ABC"); common::hash_t hash1 = common::HashUtil::Hash("XYZ"); common::hash_t combined0 = common::HashUtil::SumHashes(hash0, hash1); common::hash_t combined1 = common::HashUtil::SumHashes(hash1, hash0); EXPECT_EQ(combined0, combined1); } } // namespace terrier
<% from pwnlib.shellcraft.mips.linux import syscall %> <%page args="pid, param"/> <%docstring> Invokes the syscall sched_setparam. See 'man 2 sched_setparam' for more information. Arguments: pid(pid_t): pid param(sched_param): param </%docstring> ${syscall('SYS_sched_setparam', pid, param)}
#include <xtd/xtd> using namespace std::chrono; using namespace xtd; class program { public: static void main() { date_time century_begin(2001, 1, 1); date_time current_date = date_time::now(); ticks elapsed_ticks = current_date.ticks() - century_begin.ticks(); console::write_line("Elapsed from the beginning of the century to {0:f}:", current_date); console::write_line(" {0:N0} nanoseconds", elapsed_ticks.count() * 100); console::write_line(" {0:N0} ticks", elapsed_ticks.count()); console::write_line(" {0:N2} seconds", duration_cast<seconds>(elapsed_ticks).count()); console::write_line(" {0:N2} minutes", duration_cast<minutes>(elapsed_ticks).count()); console::write_line(" {0:N0} days, {1} hours, {2} minutes, {3} seconds", duration_cast<days>(elapsed_ticks).count(), duration_cast<hours>(elapsed_ticks).count() % 24, duration_cast<minutes>(elapsed_ticks).count() % 60, duration_cast<seconds>(elapsed_ticks).count() % 60); } }; startup_(program); // This code can produces the following output: // // Elapsed from the beginning of the century to Tue Jan 11 23:28:42 2022: // 663636522049162000 nanoseconds // 6636365220491620 ticks // 663636522.00 seconds // 11060608.00 minutes // 7680 days, 23 hours, 28 minutes, 42 seconds
#include <QCoreApplication> #include <QTextCodec> #include <QTimer> #include <QNetworkConfigurationManager> #include <conio.h> #include "Httper.h" #include "H_IO.h" void signByHand(); void quirePassword(QString * _out_str); Httper *myhttp; QString username; QString password; enum passportAccess{ Continue, Ok, Exit }loginFlag=Continue; using namespace IO; //>>>>>>>>>>>>>> 入口函数 int main(int argc, char *argv[]){ QCoreApplication app(argc, argv); QTextCodec *codec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForLocale(codec); QTextCodec::setCodecForCStrings(codec); QTextCodec::setCodecForTr(codec); // cout<<QString("\n\n>>>>>>> 欢迎使用 【百度贴吧自动签到程序PC版 v2.0.0】 By lipeiyi2006 <<<<<<<\n")<<endl; cout<<QString("\t\t【更新记录 v2.0.0 】\n")<<endl; cout<<QString("\t\t1.新增结束后再次列出签到结果.\n")<<endl; cout<<QString("\t\t2.新增开机自动启动.\n")<<endl; cout<<QString("\t\t3.新增自动签到.\n")<<endl; cout<<QString("\t\t4.新增自动自动检查网络连接.\n")<<endl; cout<<QString("\t\t5.取消结束后再次签到其他ID.\n")<<endl; cout<<QString("【特别提醒】在使用过程中所造成的用户和密码等隐私信息的泄露,后果自负.\n")<<endl; cout<<QString("确认使用?(y/n). "); cout.flush(); QString is_confirm; getString(&is_confirm); if(is_confirm=="y") signByHand(); cout<<QString("全部签到已完成: 成功: ")<< myhttp->success<<QString(" 跳过: ")<< myhttp->jump<<QString(" 失败: ")<< myhttp->failed<<"\n"<<endl; myhttp->getForums(); delete myhttp; //######## delete //system("explorer http://tieba.baidu.com/p/2096132957"); cout<<endl; cout<<QString("请按回车键退出!")<<endl; //return app.exec(); getchar(); return 0; }//end of main //手动签到 void signByHand(){ cout<<QString("Notice:签到之前,需要提供百度账户的用户名和密码,以便取得喜爱的贴吧列表 :\n")<<endl; loginFlag = Continue ; while(loginFlag==Continue){ cout<<QString("△用户名:");cout.flush(); getString(&username); cout<<QString("△密 码:");cout.flush(); quirePassword(&password); cout<<endl; cout<<QString("Notice:正在验证用户名和密码...请稍候...\n")<<endl; myhttp=new Httper(&username,&password); //######## new loginFlag = (myhttp->Login())?Ok:Continue; }//end of while if(loginFlag==Ok) myhttp->autoSign(); } //请求密码 void quirePassword(QString *_out_str){ _out_str->clear(); char t; while(true){ t=_getch(); if(t=='\r') break; if(t=='\b'){ if(_out_str->isEmpty()) continue; *_out_str=_out_str->mid(0,_out_str->length()-1); cout<<"\b \b"; cout.flush(); }else{ _out_str->push_back(t); cout<<'*'; cout.flush(); }//end of if }//end of while _out_str->simplified(); _out_str->trimmed(); }
#include <iostream> void swap(int a[], int index1, int index2) { int tmp = a[index1]; a[index1] = a[index2]; a[index2] = tmp; } void PrintArray(int a[], int length) { for (int i = 0; i < length; ++i) { std::cout << a[i] << " " << std::endl; } } int GetMinIndex(int a[], int begin_index, int end_index) { int min_index = begin_index; for (int i = begin_index; i < end_index; ++i) { if (a[min_index] > a[i+1]) { min_index = i+1; } } return min_index; } void SelectionSort(int a[], int n) { for (int i = 0; i < n; ++i) { int min_index = GetMinIndex(a, i, n-1); swap(a, i, min_index); } } int main(int argc, char *argv[]) { int a[8] = {3,1,5,7,2,4,9,6}; SelectionSort(a, 8); PrintArray(a, 8); return 0; }
;-------------------------------------------------------------------------------- ; Routine to first spawn the sprite and put data into sprite tables: ; Input (16 bit): ; $00 = Sprite number ; $02 = Sprite X position (in pixel) ; $04 = Sprite Y position (in pixel) ; $06 = Sprite Z position (in pixel) ; $08 = Extra Byte (not word!) ; Output: ; Carry: Clear = No Spawn, Set = Spawn ; X: Sprite Index (for RAM addresses) ;-------------------------------------------------------------------------------- LDX.b #!OwSprSize*2-2 - LDA !ow_sprite_num,x ; BEQ .found_slot ; If zero then the slot is unused, so jump to found_slot subroutine. DEX #2 ; Decrease Y by 2 for next loop BPL - ; If we're not past Y=0 yet, keep going. CLC ; Clear Carry since we couldn't find a slot RTL ; .found_slot LDA $00 ; \ STA !ow_sprite_num,x ; | LDA $02 ; | STA !ow_sprite_x_pos,x ; | LDA $04 ; | Move data from $00-$08 to their respective addresses. STA !ow_sprite_y_pos,x ; | LDA $06 ; | STA !ow_sprite_z_pos,x ; | LDA $08 ; | AND #$00FF ; | STA !ow_sprite_extra_bits,x ; / STZ !ow_sprite_speed_x,x ; \ STZ !ow_sprite_speed_x_acc,x ; | STZ !ow_sprite_speed_y,x ; | STZ !ow_sprite_speed_y_acc,x ; | STZ !ow_sprite_speed_z,x ; | STZ !ow_sprite_speed_z_acc,x ; | STZ !ow_sprite_timer_1,x ; | STZ !ow_sprite_timer_2,x ; | Clear other tables STZ !ow_sprite_timer_3,x ; | STZ !ow_sprite_misc_1,x ; | STZ !ow_sprite_misc_2,x ; | STZ !ow_sprite_misc_3,x ; | STZ !ow_sprite_misc_4,x ; | STZ !ow_sprite_misc_5,x ; | STZ !ow_sprite_init,x ; / SEC ; Set Carry to indicate we found a slot RTL
/*******************************<GINKGO LICENSE>****************************** Copyright (c) 2017-2019, the Ginkgo authors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ******************************<GINKGO LICENSE>*******************************/ #include <ginkgo/core/solver/upper_trs.hpp> #include <ginkgo/core/base/array.hpp> #include <ginkgo/core/base/exception_helpers.hpp> #include <ginkgo/core/base/executor.hpp> #include <ginkgo/core/base/polymorphic_object.hpp> #include <ginkgo/core/base/types.hpp> #include <ginkgo/core/base/utils.hpp> #include <ginkgo/core/matrix/csr.hpp> #include <ginkgo/core/matrix/dense.hpp> #include "core/solver/upper_trs_kernels.hpp" namespace gko { namespace solver { namespace upper_trs { GKO_REGISTER_OPERATION(generate, upper_trs::generate); GKO_REGISTER_OPERATION(init_struct, upper_trs::init_struct); GKO_REGISTER_OPERATION(should_perform_transpose, upper_trs::should_perform_transpose); GKO_REGISTER_OPERATION(solve, upper_trs::solve); } // namespace upper_trs template <typename ValueType, typename IndexType> void UpperTrs<ValueType, IndexType>::init_trs_solve_struct() { this->get_executor()->run(upper_trs::make_init_struct(this->solve_struct_)); } template <typename ValueType, typename IndexType> void UpperTrs<ValueType, IndexType>::generate() { this->get_executor()->run(upper_trs::make_generate( gko::lend(system_matrix_), gko::lend(this->solve_struct_), parameters_.num_rhs)); } template <typename ValueType, typename IndexType> void UpperTrs<ValueType, IndexType>::apply_impl(const LinOp *b, LinOp *x) const { using Vector = matrix::Dense<ValueType>; const auto exec = this->get_executor(); auto dense_b = as<const Vector>(b); auto dense_x = as<Vector>(x); // This kernel checks if a transpose is needed for the multiple rhs case. // Currently only the algorithm for CUDA version <=9.1 needs this // transposition due to the limitation in the cusparse algorithm. The other // executors (omp and reference) do not use the transpose (trans_x and // trans_b) and hence are passed in empty pointers. bool do_transpose = false; std::shared_ptr<Vector> trans_b; std::shared_ptr<Vector> trans_x; this->get_executor()->run( upper_trs::make_should_perform_transpose(do_transpose)); if (do_transpose) { trans_b = Vector::create(exec, gko::transpose(dense_b->get_size())); trans_x = Vector::create(exec, gko::transpose(dense_x->get_size())); } else { trans_b = Vector::create(exec); trans_x = Vector::create(exec); } exec->run(upper_trs::make_solve( gko::lend(system_matrix_), gko::lend(this->solve_struct_), gko::lend(trans_b), gko::lend(trans_x), dense_b, dense_x)); } template <typename ValueType, typename IndexType> void UpperTrs<ValueType, IndexType>::apply_impl(const LinOp *alpha, const LinOp *b, const LinOp *beta, LinOp *x) const { auto dense_x = as<matrix::Dense<ValueType>>(x); auto x_clone = dense_x->clone(); this->apply(b, x_clone.get()); dense_x->scale(beta); dense_x->add_scaled(alpha, gko::lend(x_clone)); } #define GKO_DECLARE_UPPER_TRS(_vtype, _itype) class UpperTrs<_vtype, _itype> GKO_INSTANTIATE_FOR_EACH_VALUE_AND_INDEX_TYPE(GKO_DECLARE_UPPER_TRS); } // namespace solver } // namespace gko
PAGE 75, 132 TITLE ECE291:MP2:MP2-Compress - Your Name - Date COMMENT * Data Compression. For this MP, you will write an interactive program which uses Huffman compression to compress and decompress textual data. By represents the most frequently used letters with the smallest number of bits, Huffman encoding can achieve significant data compression. ECE291: Machine Problem 2 Prof. John W. Lockwood Unversity of Illinois Dept. of Electrical & Computer Engineering Spring 1998 Ver 2.0 * ;====== Constants ========================================================= BEEP EQU 7 BS EQU 8 CR EQU 13 LF EQU 10 ESCKEY EQU 27 SPACE EQU 32 HuffCode STRUCT letter BYTE ? ; Letter to encode DownEncoding WORD ? ; Encoding: MSBit first UpEncoding WORD ? ; Encoding: LSBit first blength BYTE ? ; Bit Encoding Length HuffCode ENDS TextMsgMaxLength EQU 70 ; Bytes ; Limit text messages to one line BufferMaxLengthBits EQU TextMsgMaxLength * 9 ; Worst case: all 9-bit encodes BufferMaxLength EQU 1 + (BufferMaxLengthBits)/8 ; Bytes ;====== Externals ========================================================= ; -- LIB291 Routines (Free) --- extrn kbdine:near, kbdin:near, dspout:near ; LIB291 Routines extrn dspmsg:near, binasc:near, ascbin:near ; (Always Free) extrn PerformanceTest:near ; Measures performance of your code extrn mp2xit:near ; Exit program with a call to this procedure ; -- LIBMP2 Routines (Replace these with your own code) --- extrn PrintBuffer:near ; Print contents of Buffer extrn ReadBuffer:near ; Read Buffer from keyboard extrn ReadTextMsg:near ; Read TextMsg from keyboard extrn PrintTextMsg:near ; Print contents of TxtMsg extrn Encode:near ; Encode ASCII -> 5-bit extrn AppendBufferN:near ; Append N bits to Buffer extrn EncodeHuff:near ; Huffman Encode TextMsg -> Buffer extrn DecodeHuff:near ; Huffman Decode Buffer -> TextMsg ;====== SECTION 3: Define stack segment =================================== stkseg segment stack ; *** STACK SEGMENT *** db 64 dup ('STACK ') ; 64*8 = 512 Bytes of Stack stkseg ends ;====== SECTION 4: Define code segment ==================================== cseg segment public 'CODE' ; *** CODE SEGMENT *** assume cs:cseg, ds:cseg, ss:stkseg, es:nothing ;====== SECTION 5: Variables ============================================== Buffer db BufferMaxLength dup(0) ; Data Buffer for encoded Message TextMsg db TextMsgMaxLength dup('$'), '$' ; Text Message BufferLength dw 0 ; Number of bits in buffer crlf db CR,LF,'$' ; DOS uses carriage return + Linefeed for new line PBuf db 7 dup(?) PUBLIC Buffer, TextMsg, BufferLength, HuffCodes Include huffcode.inc ; Huffman Encoding Table ;====== Procedures ======================================================== ; Your Subroutines go here ! ; ---- ----------- -- ---- ;====== Main procedure ==================================================== MenuMessage db CR,LF, \ '----------- MP2 Menu -----------',CR,LF,\ ' Enter (T)ext (B)inary',CR,LF, \ ' Print (M)essage (R)buffeR',CR,LF, \ ' Huffman (E)ncode (D)ecode',CR,LF, \ '---- [ESC] or (Q)uit = exit ----',CR,LF,'$' main proc far mov ax, cseg mov ds, ax MOV DX, Offset MenuMessage CALL DSPMSG ; Display Menu MainLoop: MOV DX, Offset CRLF CALL DSPMSG MainRead: CALL KBDIN ; Read Input CMP AL,'a' JB MainOpt CMP AL,'z' ; Convert Lowercase to Uppercase JA MainOpt SUB AL,'a'-'A' MainOpt: CMP AL,'T' JNE MainNotT Call ReadTextMsg ; Read in a text message JMP MainLoop MainNotT: CMP AL,'B' JNE MainNotB Call ReadBuffer ; Read in a binary message JMP MainLoop MainNotB: CMP AL,'M' JNE MainNotM Call PrintTextMsg ; Print TextMsg JMP MainLoop MainNotM: CMP AL,'R' JNE MainNotR ; Print Buffer Call PrintBuffer ; (show least significants bit first) JMP MainLoop MainNotR: CMP AL,'E' JNE MainNotE Call EncodeHuff ; Huffman Encode Message Call PrintBuffer ; and print result JMP MainLoop MainNotE: CMP AL,'D' JNE MainNotD Call DecodeHuff ; Huffman Decode Message Call PrintTextMsg ; and show result JMP MainLoop MainNotD: CMP AL,'P' JNE MainNotP ; Performance Test MOV SI, offset EncodeHuff MOV DI, offset DecodeHuff Call PerformanceTest JMP MainLoop MainNotP: CMP AL,ESCKEY JE MainDone ; Quit program CMP AL,'Q' JE MainDone JMP MainRead ; Ignore any other character MainDone: call MP2xit ; Exit to DOS main endp cseg ends end main
dnl IA-64 mpn_mul_1, mpn_mul_1c -- Multiply a limb vector with a limb and dnl store the result in a second limb vector. dnl Copyright 2000, 2001, 2002, 2003, 2004, 2006, 2007 Free Software dnl Foundation, Inc. dnl This file is part of the GNU MP Library. dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of the GNU Lesser General Public License as published dnl by the Free Software Foundation; either version 3 of the License, or (at dnl your option) any later version. dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public dnl License for more details. dnl You should have received a copy of the GNU Lesser General Public License dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C Itanium: 4.0 C Itanium 2: 2.0 C TODO C * Further optimize feed-in and wind-down code, both for speed and code size. C * Handle low limb input and results specially, using a common stf8 in the C epilogue. C * Use 1 c/l carry propagation scheme in wind-down code. C * Use extra pointer register for `up' to speed up feed-in loads. C * Work out final differences with addmul_1.asm. C INPUT PARAMETERS define(`rp', `r32') define(`up', `r33') define(`n', `r34') define(`vl', `r35') define(`cy', `r36') C for mpn_mul_1c ASM_START() PROLOGUE(mpn_mul_1) .prologue .save ar.lc, r2 .body ifdef(`HAVE_ABI_32', ` addp4 rp = 0, rp C M I addp4 up = 0, up C M I zxt4 n = n C I ;; ') {.mfi adds r15 = -1, n C M I mov f9 = f0 C F mov.i r2 = ar.lc C I0 } {.mmi ldf8 f7 = [up], 8 C M nop.m 0 C M and r14 = 3, n C M I ;; } .Lcommon: {.mii setf.sig f6 = vl C M2 M3 shr.u r31 = r15, 2 C I0 cmp.eq p10, p0 = 0, r14 C M I } {.mii cmp.eq p11, p0 = 2, r14 C M I cmp.eq p12, p0 = 3, r14 C M I nop.i 0 C I ;; } {.mii cmp.ne p6, p7 = r0, r0 C M I mov.i ar.lc = r31 C I0 cmp.ne p8, p9 = r0, r0 C M I } {.bbb (p10) br.dptk .Lb00 C B (p11) br.dptk .Lb10 C B (p12) br.dptk .Lb11 C B ;; } .Lb01: mov r20 = 0 br.cloop.dptk .grt1 C B xma.l f39 = f7, f6, f9 C F xma.hu f43 = f7, f6, f9 C F ;; getf.sig r8 = f43 C M2 stf8 [rp] = f39 C M2 M3 mov.i ar.lc = r2 C I0 br.ret.sptk.many b0 C B .grt1: ldf8 f32 = [up], 8 ;; ldf8 f33 = [up], 8 ;; ldf8 f34 = [up], 8 xma.l f39 = f7, f6, f9 xma.hu f43 = f7, f6, f9 ;; ldf8 f35 = [up], 8 br.cloop.dptk .grt5 xma.l f36 = f32, f6, f0 xma.hu f40 = f32, f6, f0 ;; stf8 [rp] = f39, 8 xma.l f37 = f33, f6, f0 xma.hu f41 = f33, f6, f0 ;; getf.sig r21 = f43 getf.sig r18 = f36 xma.l f38 = f34, f6, f0 xma.hu f42 = f34, f6, f0 ;; getf.sig r22 = f40 getf.sig r19 = f37 xma.l f39 = f35, f6, f0 xma.hu f43 = f35, f6, f0 ;; getf.sig r23 = f41 getf.sig r16 = f38 br .Lcj5 .grt5: xma.l f36 = f32, f6, f0 xma.hu f40 = f32, f6, f0 ;; getf.sig r17 = f39 ldf8 f32 = [up], 8 xma.l f37 = f33, f6, f0 xma.hu f41 = f33, f6, f0 ;; getf.sig r21 = f43 ldf8 f33 = [up], 8 xma.l f38 = f34, f6, f0 ;; getf.sig r18 = f36 xma.hu f42 = f34, f6, f0 ;; getf.sig r22 = f40 ldf8 f34 = [up], 8 xma.l f39 = f35, f6, f0 ;; getf.sig r19 = f37 xma.hu f43 = f35, f6, f0 br .LL01 .Lb10: ldf8 f35 = [up], 8 mov r23 = 0 br.cloop.dptk .grt2 xma.l f38 = f7, f6, f9 xma.hu f42 = f7, f6, f9 ;; stf8 [rp] = f38, 8 xma.l f39 = f35, f6, f42 xma.hu f43 = f35, f6, f42 ;; getf.sig r8 = f43 stf8 [rp] = f39 mov.i ar.lc = r2 br.ret.sptk.many b0 .grt2: ldf8 f32 = [up], 8 ;; ldf8 f33 = [up], 8 xma.l f38 = f7, f6, f9 xma.hu f42 = f7, f6, f9 ;; ldf8 f34 = [up], 8 xma.l f39 = f35, f6, f0 xma.hu f43 = f35, f6, f0 ;; ldf8 f35 = [up], 8 br.cloop.dptk .grt6 stf8 [rp] = f38, 8 xma.l f36 = f32, f6, f0 xma.hu f40 = f32, f6, f0 ;; getf.sig r20 = f42 getf.sig r17 = f39 xma.l f37 = f33, f6, f0 xma.hu f41 = f33, f6, f0 ;; getf.sig r21 = f43 getf.sig r18 = f36 xma.l f38 = f34, f6, f0 xma.hu f42 = f34, f6, f0 ;; getf.sig r22 = f40 getf.sig r19 = f37 xma.l f39 = f35, f6, f0 xma.hu f43 = f35, f6, f0 br .Lcj6 .grt6: getf.sig r16 = f38 xma.l f36 = f32, f6, f0 xma.hu f40 = f32, f6, f0 ;; getf.sig r20 = f42 ldf8 f32 = [up], 8 xma.l f37 = f33, f6, f0 ;; getf.sig r17 = f39 xma.hu f41 = f33, f6, f0 ;; getf.sig r21 = f43 ldf8 f33 = [up], 8 xma.l f38 = f34, f6, f0 ;; getf.sig r18 = f36 xma.hu f42 = f34, f6, f0 br .LL10 .Lb11: ldf8 f34 = [up], 8 mov r22 = 0 ;; ldf8 f35 = [up], 8 br.cloop.dptk .grt3 ;; xma.l f37 = f7, f6, f9 xma.hu f41 = f7, f6, f9 xma.l f38 = f34, f6, f0 xma.hu f42 = f34, f6, f0 xma.l f39 = f35, f6, f0 xma.hu f43 = f35, f6, f0 ;; getf.sig r23 = f41 stf8 [rp] = f37, 8 getf.sig r16 = f38 getf.sig r20 = f42 getf.sig r17 = f39 getf.sig r8 = f43 br .Lcj3 .grt3: ldf8 f32 = [up], 8 xma.l f37 = f7, f6, f9 xma.hu f41 = f7, f6, f9 ;; ldf8 f33 = [up], 8 xma.l f38 = f34, f6, f0 xma.hu f42 = f34, f6, f0 ;; getf.sig r19 = f37 ldf8 f34 = [up], 8 xma.l f39 = f35, f6, f0 xma.hu f43 = f35, f6, f0 ;; getf.sig r23 = f41 ldf8 f35 = [up], 8 br.cloop.dptk .grt7 getf.sig r16 = f38 xma.l f36 = f32, f6, f0 getf.sig r20 = f42 xma.hu f40 = f32, f6, f0 ;; getf.sig r17 = f39 xma.l f37 = f33, f6, f0 getf.sig r21 = f43 xma.hu f41 = f33, f6, f0 ;; getf.sig r18 = f36 st8 [rp] = r19, 8 xma.l f38 = f34, f6, f0 xma.hu f42 = f34, f6, f0 br .Lcj7 .grt7: getf.sig r16 = f38 xma.l f36 = f32, f6, f0 xma.hu f40 = f32, f6, f0 ;; getf.sig r20 = f42 ldf8 f32 = [up], 8 xma.l f37 = f33, f6, f0 ;; getf.sig r17 = f39 xma.hu f41 = f33, f6, f0 br .LL11 .Lb00: ldf8 f33 = [up], 8 mov r21 = 0 ;; ldf8 f34 = [up], 8 ;; ldf8 f35 = [up], 8 xma.l f36 = f7, f6, f9 xma.hu f40 = f7, f6, f9 br.cloop.dptk .grt4 xma.l f37 = f33, f6, f0 xma.hu f41 = f33, f6, f0 xma.l f38 = f34, f6, f0 xma.hu f42 = f34, f6, f0 ;; getf.sig r22 = f40 stf8 [rp] = f36, 8 xma.l f39 = f35, f6, f0 getf.sig r19 = f37 xma.hu f43 = f35, f6, f0 ;; getf.sig r23 = f41 getf.sig r16 = f38 getf.sig r20 = f42 getf.sig r17 = f39 br .Lcj4 .grt4: ldf8 f32 = [up], 8 xma.l f37 = f33, f6, f0 xma.hu f41 = f33, f6, f0 ;; getf.sig r18 = f36 ldf8 f33 = [up], 8 xma.l f38 = f34, f6, f0 xma.hu f42 = f34, f6, f0 ;; getf.sig r22 = f40 ldf8 f34 = [up], 8 xma.l f39 = f35, f6, f0 ;; getf.sig r19 = f37 getf.sig r23 = f41 xma.hu f43 = f35, f6, f0 ldf8 f35 = [up], 8 br.cloop.dptk .grt8 getf.sig r16 = f38 xma.l f36 = f32, f6, f0 getf.sig r20 = f42 xma.hu f40 = f32, f6, f0 ;; getf.sig r17 = f39 st8 [rp] = r18, 8 xma.l f37 = f33, f6, f0 xma.hu f41 = f33, f6, f0 br .Lcj8 .grt8: getf.sig r16 = f38 xma.l f36 = f32, f6, f0 xma.hu f40 = f32, f6, f0 br .LL00 C *** MAIN LOOP START *** ALIGN(32) .Loop: .pred.rel "mutex",p6,p7 getf.sig r16 = f38 xma.l f36 = f32, f6, f0 (p6) cmp.leu p8, p9 = r24, r17 st8 [rp] = r24, 8 xma.hu f40 = f32, f6, f0 (p7) cmp.ltu p8, p9 = r24, r17 ;; .LL00: .pred.rel "mutex",p8,p9 getf.sig r20 = f42 (p8) add r24 = r18, r21, 1 nop.b 0 ldf8 f32 = [up], 8 (p9) add r24 = r18, r21 nop.b 0 ;; .pred.rel "mutex",p8,p9 getf.sig r17 = f39 xma.l f37 = f33, f6, f0 (p8) cmp.leu p6, p7 = r24, r18 st8 [rp] = r24, 8 xma.hu f41 = f33, f6, f0 (p9) cmp.ltu p6, p7 = r24, r18 ;; .LL11: .pred.rel "mutex",p6,p7 getf.sig r21 = f43 (p6) add r24 = r19, r22, 1 nop.b 0 ldf8 f33 = [up], 8 (p7) add r24 = r19, r22 nop.b 0 ;; .pred.rel "mutex",p6,p7 getf.sig r18 = f36 xma.l f38 = f34, f6, f0 (p6) cmp.leu p8, p9 = r24, r19 st8 [rp] = r24, 8 xma.hu f42 = f34, f6, f0 (p7) cmp.ltu p8, p9 = r24, r19 ;; .LL10: .pred.rel "mutex",p8,p9 getf.sig r22 = f40 (p8) add r24 = r16, r23, 1 nop.b 0 ldf8 f34 = [up], 8 (p9) add r24 = r16, r23 nop.b 0 ;; .pred.rel "mutex",p8,p9 getf.sig r19 = f37 xma.l f39 = f35, f6, f0 (p8) cmp.leu p6, p7 = r24, r16 st8 [rp] = r24, 8 xma.hu f43 = f35, f6, f0 (p9) cmp.ltu p6, p7 = r24, r16 ;; .LL01: .pred.rel "mutex",p6,p7 getf.sig r23 = f41 (p6) add r24 = r17, r20, 1 nop.b 0 ldf8 f35 = [up], 8 (p7) add r24 = r17, r20 br.cloop.dptk .Loop C *** MAIN LOOP END *** ;; .Lcj9: .pred.rel "mutex",p6,p7 getf.sig r16 = f38 xma.l f36 = f32, f6, f0 (p6) cmp.leu p8, p9 = r24, r17 st8 [rp] = r24, 8 xma.hu f40 = f32, f6, f0 (p7) cmp.ltu p8, p9 = r24, r17 ;; .pred.rel "mutex",p8,p9 getf.sig r20 = f42 (p8) add r24 = r18, r21, 1 (p9) add r24 = r18, r21 ;; .pred.rel "mutex",p8,p9 getf.sig r17 = f39 xma.l f37 = f33, f6, f0 (p8) cmp.leu p6, p7 = r24, r18 st8 [rp] = r24, 8 xma.hu f41 = f33, f6, f0 (p9) cmp.ltu p6, p7 = r24, r18 ;; .Lcj8: .pred.rel "mutex",p6,p7 getf.sig r21 = f43 (p6) add r24 = r19, r22, 1 (p7) add r24 = r19, r22 ;; .pred.rel "mutex",p6,p7 getf.sig r18 = f36 xma.l f38 = f34, f6, f0 (p6) cmp.leu p8, p9 = r24, r19 st8 [rp] = r24, 8 xma.hu f42 = f34, f6, f0 (p7) cmp.ltu p8, p9 = r24, r19 ;; .Lcj7: .pred.rel "mutex",p8,p9 getf.sig r22 = f40 (p8) add r24 = r16, r23, 1 (p9) add r24 = r16, r23 ;; .pred.rel "mutex",p8,p9 getf.sig r19 = f37 xma.l f39 = f35, f6, f0 (p8) cmp.leu p6, p7 = r24, r16 st8 [rp] = r24, 8 xma.hu f43 = f35, f6, f0 (p9) cmp.ltu p6, p7 = r24, r16 ;; .Lcj6: .pred.rel "mutex",p6,p7 getf.sig r23 = f41 (p6) add r24 = r17, r20, 1 (p7) add r24 = r17, r20 ;; .pred.rel "mutex",p6,p7 (p6) cmp.leu p8, p9 = r24, r17 (p7) cmp.ltu p8, p9 = r24, r17 getf.sig r16 = f38 st8 [rp] = r24, 8 ;; .Lcj5: .pred.rel "mutex",p8,p9 getf.sig r20 = f42 (p8) add r24 = r18, r21, 1 (p9) add r24 = r18, r21 ;; .pred.rel "mutex",p8,p9 (p8) cmp.leu p6, p7 = r24, r18 (p9) cmp.ltu p6, p7 = r24, r18 getf.sig r17 = f39 st8 [rp] = r24, 8 ;; .Lcj4: .pred.rel "mutex",p6,p7 getf.sig r8 = f43 (p6) add r24 = r19, r22, 1 (p7) add r24 = r19, r22 ;; .pred.rel "mutex",p6,p7 st8 [rp] = r24, 8 (p6) cmp.leu p8, p9 = r24, r19 (p7) cmp.ltu p8, p9 = r24, r19 ;; .Lcj3: .pred.rel "mutex",p8,p9 (p8) add r24 = r16, r23, 1 (p9) add r24 = r16, r23 ;; .pred.rel "mutex",p8,p9 st8 [rp] = r24, 8 (p8) cmp.leu p6, p7 = r24, r16 (p9) cmp.ltu p6, p7 = r24, r16 ;; .Lcj2: .pred.rel "mutex",p6,p7 (p6) add r24 = r17, r20, 1 (p7) add r24 = r17, r20 ;; .pred.rel "mutex",p6,p7 st8 [rp] = r24, 8 (p6) cmp.leu p8, p9 = r24, r17 (p7) cmp.ltu p8, p9 = r24, r17 ;; .pred.rel "mutex",p8,p9 (p8) add r8 = 1, r8 mov.i ar.lc = r2 br.ret.sptk.many b0 EPILOGUE() PROLOGUE(mpn_mul_1c) .prologue .save ar.lc, r2 .body ifdef(`HAVE_ABI_32', ` addp4 rp = 0, rp C M I addp4 up = 0, up C M I zxt4 n = n C I ;; ') {.mmi adds r15 = -1, n C M I setf.sig f9 = cy C M2 M3 mov.i r2 = ar.lc C I0 } {.mmb ldf8 f7 = [up], 8 C M and r14 = 3, n C M I br.sptk .Lcommon ;; } EPILOGUE() ASM_END()
; void *w_vector_data(b_vector_t *v) SECTION code_adt_w_vector PUBLIC w_vector_data defc w_vector_data = asm_w_vector_data INCLUDE "adt/w_vector/z80/asm_w_vector_data.asm"
/////////////////////////////////////////////////////////////////////////////// // File: ClusterizerFP420.cc // Date: 12.2006 // Description: ClusterizerFP420 for FP420 // Modifications: /////////////////////////////////////////////////////////////////////////////// #include <memory> #include <string> #include "FWCore/Framework/interface/Frameworkfwd.h" #include "FWCore/Framework/interface/EDProducer.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/Framework/interface/ESHandle.h" #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" #include "Geometry/CommonDetUnit/interface/GeomDetType.h" #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" #include "Geometry/TrackerNumberingBuilder/interface/GeometricDet.h" #include "DataFormats/Common/interface/DetSetVector.h" //#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h" #include "RecoRomanPot/RecoFP420/interface/ClusterizerFP420.h" #include "DataFormats/FP420Digi/interface/DigiCollectionFP420.h" #include "DataFormats/FP420Cluster/interface/ClusterCollectionFP420.h" #include "RecoRomanPot/RecoFP420/interface/ClusterNoiseFP420.h" //Random Number #include "FWCore/ServiceRegistry/interface/Service.h" #include "FWCore/Utilities/interface/RandomNumberGenerator.h" #include "FWCore/Utilities/interface/Exception.h" #include "CLHEP/Random/RandomEngine.h" #include <cstdlib> #include <iostream> using namespace std; namespace cms { ClusterizerFP420::ClusterizerFP420(const edm::ParameterSet& conf): conf_(conf) { std::string alias ( conf.getParameter<std::string>("@module_label") ); produces<ClusterCollectionFP420>().setBranchAlias( alias ); trackerContainers.clear(); trackerContainers = conf.getParameter<std::vector<std::string> >("ROUList"); verbosity = conf_.getUntrackedParameter<int>("VerbosityLevel"); dn0 = conf_.getParameter<int>("NumberFP420Detectors"); sn0 = conf_.getParameter<int>("NumberFP420Stations"); pn0 = conf_.getParameter<int>("NumberFP420SPlanes"); rn0 = 7; if (verbosity > 0) { std::cout << "Creating a ClusterizerFP420" << std::endl; std::cout << "ClusterizerFP420: dn0=" << dn0 << " sn0=" << sn0 << " pn0=" << pn0 << " rn0=" << rn0 << std::endl; } sClusterizerFP420_ = new FP420ClusterMain(conf_,dn0,sn0,pn0,rn0); } // Virtual destructor needed. ClusterizerFP420::~ClusterizerFP420() { delete sClusterizerFP420_; } //Get at the beginning void ClusterizerFP420::beginJob() { if (verbosity > 0) { std::cout << "BeginJob method " << std::endl; } //Getting Calibration data (Noises and BadElectrodes Flag) // bool UseNoiseBadElectrodeFlagFromDB_=conf_.getParameter<bool>("UseNoiseBadElectrodeFlagFromDB"); // if (UseNoiseBadElectrodeFlagFromDB_==true){ // iSetup.get<ClusterNoiseFP420Rcd>().get(noise);// AZ: do corrections for noise here //========================================================= // // Debug: show noise for DetIDs // ElectrodNoiseMapIterator mapit = noise->m_noises.begin(); // for (;mapit!=noise->m_noises.end();mapit++) // { // unsigned int detid = (*mapit).first; // std::cout << "detid " << detid << " # Electrode " << (*mapit).second.size()<<std::endl; // //ElectrodNoiseVector theElectrodVector = (*mapit).second; // const ElectrodNoiseVector theElectrodVector = noise->getElectrodNoiseVector(detid); // int electrode=0; // ElectrodNoiseVectorIterator iter=theElectrodVector.begin(); // //for(; iter!=theElectrodVector.end(); iter++) // { // std::cout << " electrode " << electrode++ << " =\t" // << iter->getNoise() << " \t" // << iter->getDisable() << " \t" // << std::endl; // } // } //=========================================================== // } } void ClusterizerFP420::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { // beginJob; // be lazy and include the appropriate namespaces using namespace edm; using namespace std; if (verbosity > 0) { std::cout << "ClusterizerFP420: produce" << std::endl; } // Get input //A // edm::Handle<DigiCollectionFP420> icf_simhit; /* Handle<DigiCollectionFP420> cf_simhit; std::vector<const DigiCollectionFP420 *> cf_simhitvec; for(uint32_t i = 0; i< trackerContainers.size();i++){ iEvent.getByLabel( trackerContainers[i], cf_simhit); cf_simhitvec.push_back(cf_simhit.product()); } std::unique_ptr<DigiCollectionFP420 > digis(new DigiCollectionFP420(cf_simhitvec)); std::vector<HDigiFP420> input; DigiCollectionFP420::iterator isim; for (isim=digis->begin(); isim!= digis->end();isim++) { input.push_back(*isim); } */ //B Handle<DigiCollectionFP420> input; try{ // iEvent.getByLabel( "FP420Digi" , digis); iEvent.getByLabel( trackerContainers[0] , input); } catch(const Exception&) { // in principal, should never happen, as it's taken care of by Framework throw cms::Exception("InvalidReference") << "Invalid reference to DigiCollectionFP420 \n"; } if (verbosity > 0) { std::cout << "ClusterizerFP420: OK1" << std::endl; } // Step C: create empty output collection auto soutput = std::make_unique<ClusterCollectionFP420>(); ///////////////////////////////////////////////////////////////////////////////////////////// /* std::vector<SimVertex> input; Handle<DigiCollectionFP420> digis; iEvent.getByLabel("FP420Digi",digis); input.insert(input.end(),digis->begin(),digis->end()); std::vector<HDigiFP420> input; for(std::vector<HDigiFP420>::const_iterator vsim=digis->begin(); vsim!=digis->end(); ++vsim){ input.push_back(*vsim); } theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end()); */ // std::vector<HDigiFP420> input; // DigiCollectionFP420 input; //input.push_back(digis); // input.insert(input.end(), digis->begin(), digis->end()); /* std::vector<HDigiFP420> input; input.clear(); DigiCollectionFP420::ContainerIterator sort_begin = digis->begin(); DigiCollectionFP420::ContainerIterator sort_end = digis->end(); for ( ;sort_begin != sort_end; ++sort_begin ) { input.push_back(*sort_begin); } // for */ // put zero to container info from the beginning (important! because not any detID is updated with coming of new event !!!!!! // clean info of container from previous event for (int det=1; det<dn0; det++) { for (int sector=1; sector<sn0; sector++) { for (int zmodule=1; zmodule<pn0; zmodule++) { for (int zside=1; zside<rn0; zside++) { // intindex is a continues numbering of FP420 unsigned int detID = FP420NumberingScheme::packMYIndex(rn0, pn0, sn0, det, zside, sector, zmodule); std::vector<ClusterFP420> collector; collector.clear(); ClusterCollectionFP420::Range inputRange; inputRange.first = collector.begin(); inputRange.second = collector.end(); soutput->putclear(inputRange,detID); }//for }//for }//for }//for // !!!!!! // if we want to keep Cluster container/Collection for one event ---> uncomment the line below and vice versa soutput->clear(); //container_.clear() --> start from the beginning of the container // RUN now: !!!!!! // sClusterizerFP420_.run(input, soutput, noise); if (verbosity > 0) { std::cout << "ClusterizerFP420: OK2" << std::endl; } sClusterizerFP420_->run(input, soutput.get(), noise); if (verbosity > 0) { std::cout << "ClusterizerFP420: OK3" << std::endl; } // if(collectorZS.data.size()>0){ // std::cout <<"======= ClusterizerFP420: end of produce " << std::endl; // Step D: write output to file iEvent.put(std::move(soutput)); if (verbosity > 0) { std::cout << "ClusterizerFP420: OK4" << std::endl; } }//produce } // namespace cms
CopyName1:: ; Copies the name from de to wStringBuffer2 ld hl, wStringBuffer2 CopyName2:: ; Copies the name from de to hl .loop ld a, [de] inc de ld [hli], a cp "@" jr nz, .loop ret
org 100h include 'emu8086.inc' .data m0 dw 10,13,10,13,"*** Welcome to Railway Ticket Booking Coimbatore*** $" m1 dw 10,13,10,13,"1) User",10,13,10,13,"2) Admin $" m2 dw 10,13,10,13,"1) Bangalore",10,13,10,13,"2) Chennai",10,13,10,13,"3) Cochin",10,13,10,13,"4) Palakad $" m3 dw 10,13,10,13,"Enter your choice: $" m4 dw 10,13,10,13,"Available Destinations: $" m5 dw 10,13,10,13,"Invalid choice! Please re-enter: $" m6 dw 10,13,10,13,"Please pay: $" m7 dw 10,13,10,13,"Enter $" m8 dw 10,13,10,13,"All tickets Booked! $" m9 dw 10,13,10,13,"Tickets available $" m10 dw 10,13,10,13,"Confirm booking?",10,13,10,13,"Enter 1 to confirm (or) 0 to Exit $" m11 dw 10,13,10,13,"Your unique user ID is: $" m12 dw 10,13,10,13,"Ticket Booked, enjoy your journey $" m13 dw 10,13,10,13,"Initial ticket count: $" m14 dw 10,13,10,13,"New ticket count: $" m15 dw 10,13,10,13,"1)Add tickets",10,13,10,13,"2)Ckeck unique key",10,13,10,13,"3)End Service $" m16 dw 10,13,10,13,"Select station: $" m17 dw 10,13,10,13,"Base value of Unique key: $" m18 dw 10,13,10,13,"Incrementation value for the keys: $" m19 dw 10,13,10,13,"Enter additional ticket count (with '0' as prefix): $" m20 dw 10,13,10,13,"Ticket count updated $" f dw 100,45,75,60 ;ticket costs array t dw 010,010,010,010 ;no. of tickets for respective trains n db 4 ;no. of stations that has trains from coimbatore k dw 11 ;unique user ID's base value i dw 7 ;incrementation value for user ID d dw 0 ;destination value .code mov cx, k start: call CLEAR_SCREEN ;UI Home mov ah, 09 lea dx, m0 int 21h ; User/ Admin mov ah, 09 lea dx, m1 int 21h mov ah, 09 lea dx, m3 int 21h l0: mov ah, 01 int 21h mov ah, 0 sub ax, 48 cmp ax, 01 jne I1 jmp I3 I1: cmp ax, 02 jne I2 jmp I4 I2: mov ah, 09 lea dx, m5 int 21h loop l0 ; User portal I3: call CLEAR_SCREEN ;Getting the destination as user input and it's validation mov ah, 09 lea dx, m4 int 21h mov ah, 09 lea dx, m2 int 21h mov ah, 09 lea dx, m3 int 21h l1: mov ah, 01 int 21h mov ah, 0 sub ax, 48 cmp al, n ; option <= no. of available stations jle j1 jmp j2 j1: cmp al, 0 ; option > 0 jg j3 j2: mov ah, 09 lea dx, m5 int 21h loop l1 j3: dec ax mov bx, 02 mul bx mov d, ax call CLEAR_SCREEN ;check for tickets mov si, d cmp t[si], 0 jg j4 mov ah, 09 mov dx, m8 int 21h jmp start j4: mov bx, t[si] dec bx mov t[si], bx mov ah, 09 lea dx, m9 int 21h ;Confirmation mov ah, 09 lea dx, m10 int 21h mov ah, 01 int 21h sub ax, 48 cmp al, 01 jne start ;payment mov si, d mov ah, 09 lea dx, m6 int 21h mov ax, f[si] call PRINT_NUM PRINTN 'Rs/-' ;print unique key for user mov ah, 09 lea dx, m11 int 21h mov ax, cx call PRINT_NUM add cx, i jmp end ;Admin portal I4: mov ah, 09 lea dx, m15 int 21h mov ah, 09 lea dx, m3 int 21h l2: mov ah, 01 int 21h mov ah, 0 sub ax, 48 cmp ax, 1 je j5 cmp ax, 2 je j6 cmp ax, 3 je j7 mov ah, 09 lea dx, m5 int 21h loop l2 ;add tickets j5: call CLEAR_SCREEN mov ah, 09 lea dx, m16 int 21h mov ah, 09 lea dx, m2 int 21h mov ah, 09 lea dx, m3 int 21h mov ah, 01 int 21h mov ah, 0 sub ax, 48 mov si, ax dec si mov ax, si mov bx, 02 mul bx mov si, ax ;display initial count mov ah, 09 lea dx, m13 int 21h mov ax, t[si] call PRINT_NUM ;get additional count mov ah, 09 lea dx, m19 int 21h mov ah, 01 int 21h call SCAN_NUM ;update count mov ax, t[si] add ax, cx mov t[si], ax mov ah, 09 lea dx, m20 int 21h ;display updated count mov ah, 09 lea dx, m14 int 21h mov ax, t[si] call PRINT_NUM jmp end ;Display Key details j6: call CLEAR_SCREEN mov ah, 09 lea dx, m17 int 21h mov ax, k call PRINT_NUM mov ah, 09 lea dx, m18 int 21h mov ax, i call PRINT_NUM jmp end ;Terminate j7: jmp terminate end: jmp start terminate: ret DEFINE_PRINT_NUM DEFINE_PRINT_NUM_UNS DEFINE_CLEAR_SCREEN DEFINE_SCAN_NUM end
#include "ofApp.h" //-------------------------------------------------------------- void ofApp::setup(){ ofBackground(0,0,0); ofSetFrameRate(60); //allocate our fbos. //providing the dimensions and the format for the, rgbaFbo.allocate(400, 400, GL_RGBA); // with alpha, 8 bits red, 8 bits green, 8 bits blue, 8 bits alpha, from 0 to 255 in 256 steps #ifdef TARGET_OPENGLES rgbaFboFloat.allocate(400, 400, GL_RGBA ); // with alpha, 32 bits red, 32 bits green, 32 bits blue, 32 bits alpha, from 0 to 1 in 'infinite' steps ofLogWarning("ofApp") << "GL_RGBA32F_ARB is not available for OPENGLES. Using RGBA."; #else rgbaFboFloat.allocate(400, 400, GL_RGBA32F_ARB); // with alpha, 32 bits red, 32 bits green, 32 bits blue, 32 bits alpha, from 0 to 1 in 'infinite' steps #endif // we can also define the fbo with ofFbo::Settings. // this allows us so set more advanced options the width (400), the height (200) and the internal format like this /* ofFbo::Settings s; s.width = 400; s.height = 200; s.internalformat = GL_RGBA; s.useDepth = true; // and assigning this values to the fbo like this: rgbFbo.allocate(s); */ // we have to clear all the fbos so that we don't see any artefacts // the clearing color does not matter here, as the alpha value is 0, that means the fbo is cleared from all colors // whenever we want to draw/update something inside the fbo, we have to write that inbetween fbo.begin() and fbo.end() rgbaFbo.begin(); ofClear(255,255,255, 0); rgbaFbo.end(); rgbaFboFloat.begin(); ofClear(255,255,255, 0); rgbaFboFloat.end(); } //-------------------------------------------------------------- void ofApp::update(){ ofEnableAlphaBlending(); //lets draw some graphics into our two fbos rgbaFbo.begin(); drawFboTest(); rgbaFbo.end(); rgbaFboFloat.begin(); drawFboTest(); rgbaFboFloat.end(); } //-------------------------------------------------------------- void ofApp::drawFboTest(){ //we clear the fbo if c is pressed. //this completely clears the buffer so you won't see any trails if( ofGetKeyPressed('c') ){ ofClear(255,255,255, 0); } //some different alpha values for fading the fbo //the lower the number, the longer the trails will take to fade away. fadeAmnt = 40; if(ofGetKeyPressed('1')){ fadeAmnt = 1; }else if(ofGetKeyPressed('2')){ fadeAmnt = 5; }else if(ofGetKeyPressed('3')){ fadeAmnt = 15; } //1 - Fade Fbo //this is where we fade the fbo //by drawing a rectangle the size of the fbo with a small alpha value, we can slowly fade the current contents of the fbo. ofFill(); ofSetColor(255,255,255, fadeAmnt); ofRect(0,0,400,400); //2 - Draw graphics ofNoFill(); ofSetColor(255,255,255); //we draw a cube in the center of the fbo and rotate it based on time ofPushMatrix(); ofTranslate(200,200,0); ofRotate(ofGetElapsedTimef()*30, 1,0,0.5); ofDrawBox(0,0,0,100); ofPopMatrix(); //also draw based on our mouse position ofFill(); ofCircle(ofGetMouseX() % 410, ofGetMouseY(), 8); //we move a line across the screen based on the time //the %400 makes the number stay in the 0-400 range. int shiftX = (ofGetElapsedTimeMillis() / 8 ) % 400; ofRect(shiftX, rgbaFbo.getHeight()-30, 3, 30); } //-------------------------------------------------------------- void ofApp::draw(){ ofSetColor(255,255,255); rgbaFbo.draw(0,0); rgbaFboFloat.draw(410,0); ofDrawBitmapString("non floating point FBO", ofPoint(10,20)); ofDrawBitmapString("floating point FBO", ofPoint(420,20)); string alphaInfo = "Current alpha fade amnt = " + ofToString(fadeAmnt); alphaInfo += "\nHold '1' to set alpha fade to 1"; alphaInfo += "\nHold '2' to set alpha fade to 5"; alphaInfo += "\nHold '3' to set alpha fade to 15"; alphaInfo += "\nHold 'c' to clear the fbo each frame\n\nMove mouse to draw with a circle"; ofDrawBitmapString(alphaInfo, ofPoint(10,430)); } //-------------------------------------------------------------- void ofApp::keyPressed(int key){ } //-------------------------------------------------------------- void ofApp::keyReleased(int key){ } //-------------------------------------------------------------- void ofApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::mouseReleased(int x, int y, int button){ } //-------------------------------------------------------------- void ofApp::windowResized(int w, int h){ } //-------------------------------------------------------------- void ofApp::gotMessage(ofMessage msg){ } //-------------------------------------------------------------- void ofApp::dragEvent(ofDragInfo dragInfo){ }
.global s_prepare_buffers s_prepare_buffers: push %r13 push %r8 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x80d2, %rax nop add $47345, %rbp mov $0x6162636465666768, %rdx movq %rdx, (%rax) nop nop nop sub $34810, %r8 lea addresses_WC_ht+0xfe09, %rsi lea addresses_UC_ht+0x6c52, %rdi nop nop nop nop nop add %r13, %r13 mov $55, %rcx rep movsl nop nop nop nop cmp $48796, %rbp lea addresses_WC_ht+0x8912, %rcx nop nop add %r13, %r13 mov $0x6162636465666768, %r8 movq %r8, %xmm3 movups %xmm3, (%rcx) nop nop cmp %r13, %r13 lea addresses_WC_ht+0xd412, %rdx nop nop nop nop nop mfence movl $0x61626364, (%rdx) nop add $32199, %rcx lea addresses_A_ht+0x1add2, %rdi clflush (%rdi) nop nop and %rdx, %rdx mov $0x6162636465666768, %r13 movq %r13, (%rdi) nop nop sub $14660, %r8 lea addresses_A_ht+0x12bf2, %rax nop nop add %r13, %r13 movw $0x6162, (%rax) nop nop nop nop nop add %r8, %r8 lea addresses_WC_ht+0x15b2, %r13 nop nop nop nop nop and $52409, %rcx and $0xffffffffffffffc0, %r13 vmovntdqa (%r13), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %rdi inc %rdi lea addresses_WT_ht+0x1b1d2, %rsi lea addresses_WC_ht+0xc352, %rdi clflush (%rsi) nop nop sub %r13, %r13 mov $59, %rcx rep movsw sub %rbp, %rbp lea addresses_WC_ht+0x19312, %r8 nop nop nop xor %rcx, %rcx mov (%r8), %rdx nop nop nop nop inc %rsi lea addresses_A_ht+0x11352, %rsi lea addresses_UC_ht+0x8dd2, %rdi nop nop nop add $50004, %rax mov $64, %rcx rep movsb nop nop nop xor %rdi, %rdi lea addresses_A_ht+0x11fd2, %rax xor $3335, %r8 mov (%rax), %r13d nop sub %rbp, %rbp lea addresses_D_ht+0x1c0e2, %rcx nop nop sub $30659, %r13 mov $0x6162636465666768, %rsi movq %rsi, %xmm7 movups %xmm7, (%rcx) nop nop cmp %r8, %r8 lea addresses_WT_ht+0x15802, %rsi lea addresses_UC_ht+0x49d2, %rdi nop nop nop nop nop add %rax, %rax mov $126, %rcx rep movsb nop nop nop nop nop dec %rdx lea addresses_UC_ht+0x69d2, %rdi nop add %rax, %rax mov (%rdi), %si nop nop nop nop and $1249, %rax lea addresses_D_ht+0x9d2, %rdi nop nop dec %rsi movl $0x61626364, (%rdi) nop nop nop nop and %r8, %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r8 pop %r13 ret .global s_faulty_load s_faulty_load: push %r12 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi // Store mov $0x717df900000009d2, %rsi nop nop nop nop nop and $30207, %rdi movl $0x51525354, (%rsi) nop nop xor %rax, %rax // Store lea addresses_normal+0x15f88, %rbp nop nop nop nop nop cmp %rax, %rax mov $0x5152535455565758, %rdi movq %rdi, (%rbp) nop nop add $25862, %rdi // Faulty Load mov $0x73226600000009d2, %rcx nop nop nop dec %r12 mov (%rcx), %eax lea oracles, %rbx and $0xff, %rax shlq $12, %rax mov (%rbx,%rax,1), %rax pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_NC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_NC'}} {'OP': 'STOR', 'dst': {'congruent': 1, 'AVXalign': True, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_normal'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 0, 'same': True, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_A_ht'}} {'src': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 32, 'NT': True, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}} {'src': {'congruent': 6, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 3, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': True, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_D_ht'}} {'00': 131, '54': 21693, '5f': 5} 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 */
; A033134: Base-7 digits are, in order, the first n terms of the periodic sequence with initial period 1,1,0. ; 1,8,56,393,2752,19264,134849,943944,6607608,46253257,323772800,2266409600,15864867201,111054070408,777378492856,5441649449993,38091546149952,266640823049664,1866485761347649,13065400329433544,91457802306034808,640204616142243657,4481432312995705600,31370026190969939200,219590183336789574401,1537131283357527020808,10759918983502689145656,75319432884518824019593,527236030191631768137152,3690652211341422376960064,25834565479389956638720449,180841958355729696471043144,1265893708490107875297302008 add $0,3 lpb $0 sub $0,3 mov $2,$0 max $2,0 seq $2,170641 ; Number of reduced words of length n in Coxeter group on 8 generators S_i with relations (S_i)^2 = (S_i S_j)^49 = I. add $1,$2 lpe mov $0,$1
org 100h L1: NOP L2: MOV AL, 0FFH AND AL, 10101010B L3: HLT ret
; float __fssqr (float number) SECTION code_clib SECTION code_fp_math32 PUBLIC cm32_sccz80_fssqr EXTERN m32_fssqr ; square (^2) sccz80 floats ; ; enter : stack = sccz80_float number, ret ; ; exit : DEHL = sccz80_float(number^2) ; ; uses : af, bc, de, hl, af' defc cm32_sccz80_fssqr = m32_fssqr
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: FILE: driEntry.asm AUTHOR: Adam de Boor, Oct 30, 1991 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Adam 10/30/91 Initial revision DESCRIPTION: Entry point & jump table. $Id: dosEntry.asm,v 1.1 97/04/10 11:54:59 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ idata segment DriverTable FSDriverInfoStruct < < ; FSDIS_common <DOSStrategy>, ; DIS_strategy, all else default. DriverExtendedInfo >, FSD_FLAGS, DOSPrimaryStrategy, ; FDIS_altStrat < DOS_PRIMARY_FS_PROTO_MAJOR, DOS_PRIMARY_FS_PROTO_MINOR > ; FDIS_altProto > public DriverTable ; avoid warning idata ends if FULL_EXECUTE_IN_PLACE ResidentXIP segment resource else Resident segment resource endif DefFSFunction macro routine, constant .assert ($-fsFunctions) eq constant*2, <Routine for constant in the wrong slot> .assert (type routine eq far) fptr routine endm fsFunctions label fptr.far DRI <DefFSFunction DRIInit, DR_INIT > DRI <DefFSFunction DRIExit, DR_EXIT > MS <DefFSFunction MSInit, DR_INIT > MS <DefFSFunction MSExit, DR_EXIT > OS2 <DefFSFunction OS2Init, DR_INIT > OS2 <DefFSFunction OS2Exit, DR_EXIT > DefFSFunction DOSSuspend, DR_SUSPEND DefFSFunction DOSUnsuspend, DR_UNSUSPEND DefFSFunction DOSTestDevice, DRE_TEST_DEVICE DefFSFunction DOSSetDevice, DRE_SET_DEVICE DefFSFunction DOSDiskID, DR_FS_DISK_ID DefFSFunction DOSDiskInit, DR_FS_DISK_INIT DefFSFunction DOSDiskLock, DR_FS_DISK_LOCK DefFSFunction DOSDiskUnlock, DR_FS_DISK_UNLOCK DefFSFunction DOSDiskFormat, DR_FS_DISK_FORMAT DefFSFunction DOSDiskFindFree, DR_FS_DISK_FIND_FREE DefFSFunction DOSDiskInfo, DR_FS_DISK_INFO DefFSFunction DOSDiskRename, DR_FS_DISK_RENAME DefFSFunction DOSDiskCopy, DR_FS_DISK_COPY DefFSFunction DOSDiskSave, DR_FS_DISK_SAVE DefFSFunction DOSDiskRestore, DR_FS_DISK_RESTORE DefFSFunction DOSCheckNetPath, DR_FS_CHECK_NET_PATH DefFSFunction DOSCurPathSet, DR_FS_CUR_PATH_SET DefFSFunction DOSCurPathGetID, DR_FS_CUR_PATH_GET_ID DefFSFunction DOSCurPathDelete, DR_FS_CUR_PATH_DELETE DefFSFunction DOSCurPathCopy, DR_FS_CUR_PATH_COPY DefFSFunction DOSHandleOp, DR_FS_HANDLE_OP DefFSFunction DOSAllocOp, DR_FS_ALLOC_OP DefFSFunction DOSPathOp, DR_FS_PATH_OP DefFSFunction DOSCompareFiles, DR_FS_COMPARE_FILES DefFSFunction DOSFileEnum, DR_FS_FILE_ENUM DefFSFunction DOSDriveLock, DR_FS_DRIVE_LOCK DefFSFunction DOSDriveUnlock, DR_FS_DRIVE_UNLOCK if DBCS_PCGEOS DefFSFunction DOSConvertString, DR_FS_CONVERT_STRING endif CheckHack <($-fsFunctions)/2 eq FSFunction> DefPFSFunction macro routine, constant .assert ($-dosPrimaryFunctions) eq (constant-FSFunction)*2, <Routine for constant in the wrong slot> .assert (type routine eq far) fptr routine endm dosPrimaryFunctions label fptr.far DefPFSFunction DOSAllocDosHandleFar, DR_DPFS_ALLOC_DOS_HANDLE DefPFSFunction DOSFreeDosHandleFar, DR_DPFS_FREE_DOS_HANDLE DefPFSFunction DOSLockCWDFar, DR_DPFS_LOCK_CWD DefPFSFunction DOSUnlockCWD, DR_DPFS_UNLOCK_CWD DefPFSFunction DOSUtilOpenFar, DR_DPFS_OPEN_INTERNAL DefPFSFunction DOSInitTakeOverFile, DR_DPFS_INIT_HANDLE DefPFSFunction DOSInvalCurPath, DR_DPFS_INVAL_CUR_PATH DefPFSFunction DOSMapVolumeName, DR_DPFS_MAP_VOLUME_NAME DefPFSFunction DOSVirtMapToDOS, DR_DPFS_MAP_TO_DOS DefPFSFunction DOSUtilInt21, DR_DPFS_CALL_DOS DefPFSFunction DOSPreventCriticalErr, DR_DPFS_PREVENT_CRITICAL_ERR DefPFSFunction DOSAllowCriticalErr, DR_DPFS_ALLOW_CRITICAL_ERR DefPFSFunction DOSDiskPLockSectorBuffer, DR_DPFS_P_LOCK_SECTOR_BUFFER DefPFSFunction DOSDiskUnlockVSectorBuffer, DR_DPFS_UNLOCK_V_SECTOR_BUFFER .assert ($-dosPrimaryFunctions)/2 eq (DOSPrimaryFSFunction-first DOSPrimaryFSFunction) COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DOSStrategy %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Perform a function on one of our drives for the kernel. CALLED BY: Kernel PASS: di = function to perform other args as appropriate RETURN: various and sundry. DESTROYED: ? PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/30/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DOSStrategy proc far .enter EC < cmp di, FSFunction > EC < ERROR_AE INVALID_FS_FUNCTION > EC < test di, 1 > EC < ERROR_NZ INVALID_FS_FUNCTION > ; ; If the routine is in fixed memory, call it directly. ; shl di ; *2 to get dwords add di, offset fsFunctions call DOSEntryCallFunction .leave ret DOSStrategy endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DOSEntryCallFunction %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Call the function whose fptr is pointed to by cs:di, dealing with movable/fixed state of the routine. CALLED BY: DOSStrategy, DOSPrimaryStrategy PASS: cs:di = fptr.fptr.far RETURN: whatever DESTROYED: bp destroyed by this function before target function called PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 3/29/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DOSEntryCallFunction proc near .enter push ss:[TPD_callVector].offset, ss:[TPD_dataAX], ss:[TPD_dataBX] pushdw cs:[di] call PROCCALLFIXEDORMOVABLE_PASCAL pop ss:[TPD_callVector].offset, ss:[TPD_dataAX], ss:[TPD_dataBX] .leave ret DOSEntryCallFunction endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DOSPrimaryStrategy %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Similar to DOSStrategy, but the operation is performed on a drive not actually managed by us. In effect, we're acting as a library for a secondary FSD. CALLED BY: Secondary FSD's PASS: di = function to perform other args as appropriate RETURN: values as appropriate to the function performed DESTROYED: ? PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/30/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DOSPrimaryStrategy proc far .enter EC < call ECCheckStack > EC < test di, 1 > EC < ERROR_NZ INVALID_DOS_PRIMARY_FS_FUNCTION > EC < cmp di, DOSPrimaryFSFunction > EC < ERROR_AE INVALID_DOS_PRIMARY_FS_FUNCTION > ; ; If standard FS function, just pass it directly off to our sibling ; strategy function. ; cmp di, FSFunction jae special call DOSStrategy done: .leave ret special: sub di, FSFunction shl di add di, offset dosPrimaryFunctions call DOSEntryCallFunction jmp done DOSPrimaryStrategy endp if FULL_EXECUTE_IN_PLACE ResidentXIP ends Resident segment resource endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DOSTestDevice %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: CALLED BY: PASS: RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/31/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DOSTestDevice proc far .enter clc mov ax, DP_PRESENT .leave ret DOSTestDevice endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DOSSetDevice %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: CALLED BY: PASS: RETURN: DESTROYED: PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- ardeb 10/31/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DOSSetDevice proc far .enter .leave ret DOSSetDevice endp Resident ends
db "WATER FISH@" ; species name dw 407, 1650 ; height, weight db "Its body is always" next "slimy. It often" next "bangs its head on" page "the river bottom" next "as it swims but" next "seems not to care.@"
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ /* * Copyright 2017 Couchbase, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "collections/manifest.h" #include "collections_test_helpers.h" #include <utilities/test_manifest.h> #include <folly/portability/GTest.h> #include <memcached/engine_error.h> #include <cctype> #include <limits> #include <unordered_set> TEST(ManifestTest, defaultState) { Collections::Manifest m; EXPECT_TRUE(m.doesDefaultCollectionExist()); EXPECT_EQ(1, m.size()); EXPECT_EQ(0, m.getUid()); auto collection = m.findCollection(CollectionID::Default); EXPECT_NE(collection, m.end()); EXPECT_EQ(ScopeID::Default, collection->second.sid); EXPECT_EQ("_default", collection->second.name); collection = m.findCollection("_default", "_default"); EXPECT_NE(collection, m.end()); EXPECT_EQ(ScopeID::Default, collection->second.sid); EXPECT_EQ("_default", collection->second.name); auto scope = m.findScope(ScopeID::Default); EXPECT_NE(scope, m.endScopes()); EXPECT_EQ("_default", scope->second.name); EXPECT_EQ(1, scope->second.collections.size()); EXPECT_EQ(CollectionID::Default, scope->second.collections[0].id); auto oScope = m.getScopeID("_default._default"); EXPECT_EQ(ScopeID::Default, oScope.value_or(~0)); auto oCollection = m.getCollectionID(oScope.value(), "_default._default"); EXPECT_EQ(CollectionID::Default, oCollection.value_or(~0)); } TEST(ManifestTest, validation) { std::vector<std::string> invalidManifests = { "", // empty "not json", // definitely not json R"({"uid"})", // illegal json // valid uid, no scopes object R"({"uid" : "1"})", // valid uid, invalid scopes type R"({"uid":"1" "scopes" : 0})", // valid uid, no scopes R"({"uid" : "1", "scopes" : []})", // valid uid, no default scope R"({"uid" : "1", "scopes":[{"name":"not_the_default", "uid":"8", "collections":[]}]})", // default collection not in default scope R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"_default","uid":"0"}]}]})", // valid uid, invalid collections type R"({"uid" : "1", "scopes" : [{"name":"_default", "uid":"0"," "collections":[0]}]})", // valid uid, valid name, no collection uid R"({"uid" : "1", "scopes" : [{"name":"_default", "uid":"0"," "collections":[{"name":"beer"}]}]})", // valid uid, valid name, no scope uid R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}, {"name":"scope1", "collections":[]}]})", // valid uid, valid collection uid, no collection name R"({"uid": "1", "scopes" : [{"name":"_default", "uid":"0"," "collections":[{"uid":"8"}]}]})", // valid uid, valid scope uid, no scope name R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}, {"uid":"8", "collections":[]}]})", // valid name, invalid collection uid (wrong type) R"({"uid": "1", "scopes" : [{"name":"_default", "uid":"0"," "collections":[{"name":"beer", "uid":8}]}]})", // valid name, invalid scope uid (wrong type) R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}, {"name":"1", "uid":8, "collections":[]}]})", // valid name, invalid collection uid (not hex) R"({"uid":"0", "scopes" : [{"name":"_default", "uid":"0"," "collections":[{"name":"beer", "uid":"turkey"}]}]})", // valid name, invalid scope uid (not hex) R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}, {"name":"1", "uid":"turkey", "collections":[]}]})", // invalid collection name (wrong type), valid uid R"({"uid" : "1", "scopes" : [{"name":"_default", "uid":"0"," "collections":[{"name":1, "uid":"8"}]}]})", // invalid scope name (wrong type), valid uid R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}, {"name":1, "uid":"8", "collections":[]}]})", // duplicate CID R"({"uid" : "1", "scopes" : [{"name":"_default", "uid":"0"," "collections":[{"name":"beer", "uid":"8"}, {"name":"lager", "uid":"8"}]}]})", // duplicate scope id R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"brewerA", "uid":"8","collections":[]}, {"name":"brewerB", "uid":"8","collections":[]}]})", // duplicate cid across scopes R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[ {"name":"brewery", "uid":"8"}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"brewery", "uid":"8"}]}]})", // Invalid manifest UIDs // Missing UID R"({"scopes":[{"name":"_default", "uid":"0"}]})", // UID wrong type R"({"uid" : 1, "scopes":[{"name":"_default", "uid":"0"}]})", // UID cannot be converted to a value R"({"uid" : "thisiswrong", "scopes":[{"name":"_default", "uid":"0"}]})", // UID cannot be converted to a value R"({"uid" : "12345678901234567890112111", "scopes":[{"name":"_default", "uid":"0}]})", // UID cannot be 0x prefixed R"({"uid" : "0x101", "scopes":[{"name":"_default", "uid":"0"}]})", // collection cid cannot be 1 R"({"uid" : "101", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"1"}]}]})", // collection cid cannot be 7 (1-7 reserved) R"({"uid" : "101", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"7"}]}]})", // scope uid cannot be 1 R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"brewerA", "uid":"1","collections":[]}]})", // scope uid cannot be 7 (1-7 reserved) R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"brewerA", "uid":"7","collections":[]}]})", // scope uid too long R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"brewerA", "uid":"1234567890","collections":[]}]})", // collection cid too long R"({"uid" : "101", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"1234567890"}]}]})", // scope uid too long R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"brewerA", "uid":"1234567890","collections":[]}]})", // Invalid collection names, no $ prefix allowed yet and empty // also denied R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"$beer", "uid":"8"}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"", "uid":"8"}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"name_is_far_too_long_for_collections", "uid":"8"}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"collection.name", "uid":"8"}]}]})", // Invalid scope names, no $ prefix allowed yet and empty denies R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"$beer", "uid":"8", "collections":[]}]})", R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"", "uid":"8", "collections":[]}]})", R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"name_is_far_too_long_for_collections", "uid":"8", "collections":[]}]})", R"({"uid" : "1", "scopes":[ {"name":"scope.name", "uid":"8", "collections":[]}]})", // maxTTL invalid cases // wrong type R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}, {"name":"brewery","uid":"9","maxTTL":"string"}]}]})", // negative (doesn't make sense) R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}, {"name":"brewery","uid":"9","maxTTL":-700}]}]})", // too big for 32-bit R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}, {"name":"brewery","uid":"9","maxTTL":4294967296}]}]})", // Test duplicate scope names R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[ {"name":"_default","uid":"0"}, {"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"beer", "uid":"a"}, {"name":"brewery", "uid":"b"}]}, {"name":"brewerA", "uid":"9", "collections":[ {"name":"beer", "uid":"c"}, {"name":"brewery", "uid":"d"}]}]})", // Test duplicate collection names within the same scope R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[ {"name":"_default","uid":"0"}, {"name":"brewery", "uid":"8"}, {"name":"brewery","uid":"9"}]}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"beer", "uid":"a"}, {"name":"beer", "uid":"b"}]}]})", // Illegal name for default collection R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"Default","uid":"0"}]}]})", // Illegal name for default scope R"({"uid" : "1", "scopes":[{"name":"Default", "uid":"0", "collections":[{"name":"_default","uid":"0"}]}]})", // Illegal name for default collection R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"Default","uid":"0"}]}]})", }; std::vector<std::string> validManifests = { // this is the 'epoch' state of collections R"({"uid" : "0", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}]})", R"({"uid" : "1", "scopes":[ {"name":"_default", "uid":"0", "collections":[]}, {"name":"brewerA", "uid":"8", "collections":[]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}, {"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[ {"name":"_default","uid":"0"}, {"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"beer", "uid":"a"}, {"name":"brewery", "uid":"b"}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}, {"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[ {"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"beer", "uid":"a"}, {"name":"brewery", "uid":"b"}]}]})", // Extra keys ignored at the moment R"({"extra":"key", "uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"af"}, {"name":"brewery","uid":"8"}]}]})", // lower-case uid is fine R"({"uid" : "abcd1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}]})", // upper-case uid is fine R"({"uid" : "ABCD1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}]})", // mix-case uid is fine R"({"uid" : "AbCd1", "scopes":[{"name":"_default", "uid":"0", "collections":[]}]})", // maxTTL valid cases R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}, {"name":"brewery","uid":"9","maxTTL":0}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}, {"name":"brewery","uid":"9","maxTTL":1}]}]})", // max u32int R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"_default","uid":"0"}, {"name":"brewery","uid":"9","maxTTL":4294967295}]}]})", R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"brewery","uid":"8"}]}]})", }; for (auto& manifest : invalidManifests) { try { Collections::Manifest m(manifest); EXPECT_TRUE(false) << "No exception thrown for invalid manifest:" << manifest << std::endl; } catch (std::invalid_argument&) { } } for (auto& manifest : validManifests) { try { Collections::Manifest m(manifest); } catch (std::exception& e) { EXPECT_TRUE(false) << "Exception thrown for valid manifest:" << manifest << std::endl << " what:" << e.what(); } } // Following logic requires even number of valid manifests ASSERT_EQ(0, validManifests.size() % 2); // Make use of the valid manifests to give some coverage on the compare // operator. auto itr = validManifests.rbegin(); for (auto& manifest : validManifests) { try { Collections::Manifest m1(manifest); Collections::Manifest m2(manifest); Collections::Manifest m3(*itr); EXPECT_EQ(m1, m2); EXPECT_NE(m1, m3); } catch (std::exception& e) { EXPECT_TRUE(false) << "Exception thrown for valid manifest:" << manifest << std::endl << " what:" << e.what(); } itr++; } } TEST(ManifestTest, getUid) { std::vector<std::pair<Collections::ManifestUid, std::string>> validManifests = {{Collections::ManifestUid(1), R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}]})"}, {Collections::ManifestUid(0xabcd), R"({"uid" : "ABCD", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}]})"}, {Collections::ManifestUid(0xabcd), R"({"uid" : "abcd", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}]})"}, {Collections::ManifestUid(0xabcd), R"({"uid" : "aBcD", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}]}]})"}}; for (auto& manifest : validManifests) { Collections::Manifest m(manifest.second); EXPECT_EQ(manifest.first, m.getUid()); } } TEST(ManifestTest, findCollection) { std::string manifest = R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[{"name":"beer", "uid":"8"}, {"name":"brewery","uid":"9"}, {"name":"_default","uid":"0"}]}]})"; std::vector<CollectionID> collectionT = {0, 8, 9}; std::vector<CollectionID> collectionF = {0xa, 0xb, 0xc}; Collections::Manifest m(manifest); for (auto& collection : collectionT) { EXPECT_NE(m.end(), m.findCollection(collection)); } for (auto& collection : collectionF) { EXPECT_EQ(m.end(), m.findCollection(collection)); } } // MB-30547: Initialization of `input` below fails on Clang 7 - temporarily // skip to fix build breakage. #if !defined(__clang_major__) || __clang_major__ > 7 // validate we can construct from JSON, call toJSON and get back valid JSON // containing what went in. TEST(ManifestTest, toJson) { struct TestInput { CollectionEntry::Entry collection; ScopeEntry::Entry scope; cb::ExpiryLimit maxTtl; }; std::vector<std::pair<std::string, std::vector<TestInput>>> input = { {"abc0", {}}, {"abc1", {{CollectionEntry::defaultC, ScopeEntry::defaultS, cb::ExpiryLimit{}}, {CollectionEntry::fruit, ScopeEntry::defaultS, cb::ExpiryLimit{}}, {CollectionEntry::vegetable, ScopeEntry::defaultS, cb::ExpiryLimit{}}}}, {"abc2", {{CollectionEntry::fruit, ScopeEntry::defaultS, cb::ExpiryLimit{}}, {CollectionEntry::vegetable, ScopeEntry::defaultS, cb::ExpiryLimit{}}}}, {"abc3", {{CollectionEntry::fruit, ScopeEntry::shop1, cb::ExpiryLimit{}}, {CollectionEntry::vegetable, ScopeEntry::defaultS, cb::ExpiryLimit{}}}}, {"abc4", {{CollectionEntry::dairy, ScopeEntry::shop1, cb::ExpiryLimit{}}, {CollectionEntry::dairy2, ScopeEntry::shop2, cb::ExpiryLimit{}}}}, {"abc5", {{{CollectionEntry::dairy, ScopeEntry::shop1, std::chrono::seconds(100)}, {CollectionEntry::dairy2, ScopeEntry::shop2, std::chrono::seconds(0)}}}}}; Collections::IsVisibleFunction isVisible = [](ScopeID, std::optional<CollectionID>) -> bool { return true; }; for (auto& manifest : input) { CollectionsManifest cm(NoDefault{}); std::unordered_set<ScopeID> scopesAdded; scopesAdded.insert(ScopeID::Default); // always the default scope for (auto& collection : manifest.second) { if (scopesAdded.count(collection.scope.uid) == 0) { cm.add(collection.scope); scopesAdded.insert(collection.scope.uid); } cm.add(collection.collection, collection.maxTtl, collection.scope); } cm.setUid(manifest.first); Collections::Manifest m = makeManifest(cm); nlohmann::json input; auto output = m.toJson(isVisible); std::string s(cm); try { input = nlohmann::json::parse(s); } catch (const nlohmann::json::exception& e) { FAIL() << "Cannot nlohmann::json::parse input " << s << " " << e.what(); } EXPECT_EQ(input.size(), output.size()); EXPECT_EQ(input["uid"].dump(), output["uid"].dump()); EXPECT_EQ(input["scopes"].size(), output["scopes"].size()); for (const auto& scope1 : output["scopes"]) { auto scope2 = std::find_if( input["scopes"].begin(), input["scopes"].end(), [scope1](const nlohmann::json& scopeEntry) { return scopeEntry["name"] == scope1["name"] && scopeEntry["uid"] == scope1["uid"]; }); ASSERT_NE(scope2, input["scopes"].end()); // If we are here we know scope1 and scope2 have name, uid fields // and they match, check the overall size, should be 3 fields // name, uid and collections EXPECT_EQ(3, scope1.size()); EXPECT_EQ(scope1.size(), scope2->size()); for (const auto& collection1 : scope1["collections"]) { // Find the collection from scope in the output auto collection2 = std::find_if( (*scope2)["collections"].begin(), (*scope2)["collections"].end(), [collection1](const nlohmann::json& collectionEntry) { return collectionEntry["name"] == collection1["name"] && collectionEntry["uid"] == collection1["uid"]; }); ASSERT_NE(collection2, (*scope2)["collections"].end()); // If we are here we know collection1 and collection2 have // matching name and uid fields, check the other fields. // maxTTL is optional EXPECT_EQ(collection1.size(), collection2->size()); auto ttl1 = collection1.find("maxTTL"); if (ttl1 != collection1.end()) { ASSERT_EQ(3, collection1.size()); auto ttl2 = collection2->find("maxTTL"); ASSERT_NE(ttl2, collection2->end()); EXPECT_EQ(*ttl1, *ttl2); } else { EXPECT_EQ(2, collection1.size()); } } } } } #endif // !defined(__clang_major__) || __clang_major__ > 7 TEST(ManifestTest, badNames) { for (char c = 127; c >= 0; c--) { std::string name(1, c); CollectionsManifest cm({name, 8}); if (!(std::isdigit(c) || std::isalpha(c) || c == '_' || c == '-' || c == '%')) { try { auto m = makeManifest(cm); EXPECT_TRUE(false) << "No exception thrown for invalid manifest:" << m << std::endl; } catch (std::exception&) { } } else { try { auto m = makeManifest(cm); } catch (std::exception& e) { EXPECT_TRUE(false) << "Exception thrown for valid manifest" << std::endl << " what:" << e.what(); } } } } TEST(ManifestTest, findCollectionByName) { std::string manifest = R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[ {"name":"_default", "uid":"0"}, {"name":"meat", "uid":"8"}]}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"beer", "uid":"9"}]}]})"; Collections::Manifest cm(manifest); // We expect to find the collections in the default scope, when we do not // specify the scope // Test that the uid matches the collection that we are searching for EXPECT_EQ(cm.findCollection("_default")->first, 0); EXPECT_EQ(cm.findCollection("meat")->first, 8); // We do not expect to find collections not in the default scope, when we // do not specify the scope EXPECT_EQ(cm.findCollection("beer"), cm.end()); // We expect to find collections when searching by collection and scope name // Test that the uid matches the collection that we are searching for EXPECT_EQ(cm.findCollection("_default", "_default")->first, 0); EXPECT_EQ(cm.findCollection("meat", "_default")->first, 8); EXPECT_EQ(cm.findCollection("beer", "brewerA")->first, 9); // We do not expect to find collections with incorrect scope that does exist EXPECT_EQ(cm.findCollection("_default", "brewerA"), cm.end()); EXPECT_EQ(cm.findCollection("meat", "brewerA"), cm.end()); EXPECT_EQ(cm.findCollection("beer", "_default"), cm.end()); // We do not expect to find collections when we give a scope that does // not exist EXPECT_EQ(cm.findCollection("_default", "a_scope_name"), cm.end()); EXPECT_EQ(cm.findCollection("meat", "a_scope_name"), cm.end()); EXPECT_EQ(cm.findCollection("beer", "a_scope_name"), cm.end()); // We do not expect to find collections that do not exist in a scope that // does EXPECT_EQ(cm.findCollection("fruit", "_default"), cm.end()); EXPECT_EQ(cm.findCollection("fruit", "brewerA"), cm.end()); // We do not expect to find collections that do not exist in scopes that // do not exist EXPECT_EQ(cm.findCollection("fruit", "a_scope_name"), cm.end()); } TEST(ManifestTest, getScopeID) { std::string manifest = R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[ {"name":"_default", "uid":"0"}, {"name":"meat", "uid":"8"}]}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"beer", "uid":"9"}, {"name":"meat", "uid":"a"}]}]})"; Collections::Manifest cm(manifest); // getScopeID is called from the context of a get_collection_id or // a get_scope_id command, thus the path it accepts can either be // * "scope.collection" // * "scope" // the function ignores anything after a . // The Manifest::getScopeID expects a valid path, it peforms no validation EXPECT_EQ(ScopeID::Default, cm.getScopeID("").value()); EXPECT_EQ(ScopeID::Default, cm.getScopeID(".").value()); EXPECT_EQ(ScopeID::Default, cm.getScopeID("_default").value()); EXPECT_EQ(ScopeID::Default, cm.getScopeID(".ignorethis").value()); EXPECT_EQ(ScopeID::Default, cm.getScopeID("_default.ignorethis").value()); EXPECT_EQ(8, cm.getScopeID("brewerA").value()); EXPECT_EQ(8, cm.getScopeID("brewerA.ignorethis").value()); // valid input to unknown scopes EXPECT_FALSE(cm.getScopeID("unknown.ignored")); EXPECT_FALSE(cm.getScopeID("unknown")); // validation of the path is not done by getScopeID, the following just // results in an invalid lookup of 'junk' but no throwing because of the // "this.that.what" EXPECT_FALSE(cm.getScopeID("junk.this.that.what")); // However if the scope name is junk we throw for that try { cm.getScopeID("j*nk.this.that.what"); } catch (const cb::engine_error& e) { EXPECT_EQ(cb::engine_errc::invalid_arguments, cb::engine_errc(e.code().value())); } // valid path but invalid names try { cm.getScopeID("invalid***"); } catch (const cb::engine_error& e) { EXPECT_EQ(cb::engine_errc::invalid_arguments, cb::engine_errc(e.code().value())); } try { cm.getScopeID("invalid***.ignored"); } catch (const cb::engine_error& e) { EXPECT_EQ(cb::engine_errc::invalid_arguments, cb::engine_errc(e.code().value())); } } TEST(ManifestTest, getCollectionID) { std::string manifest = R"({"uid" : "1", "scopes":[{"name":"_default", "uid":"0", "collections":[ {"name":"_default", "uid":"0"}, {"name":"meat", "uid":"8"}]}, {"name":"brewerA", "uid":"8", "collections":[ {"name":"beer", "uid":"9"}, {"name":"meat", "uid":"a"}]}]})"; Collections::Manifest cm(manifest); // Note: usage of getCollectionID assumes getScopeID was called first // Note: getCollectionID does not perform validation of the path EXPECT_EQ(CollectionID::Default, cm.getCollectionID(ScopeID::Default, ".").value()); EXPECT_EQ(CollectionID::Default, cm.getCollectionID(ScopeID::Default, "_default.").value()); EXPECT_EQ(8, cm.getCollectionID(ScopeID::Default, ".meat").value()); EXPECT_EQ(8, cm.getCollectionID(ScopeID::Default, "_default.meat").value()); EXPECT_EQ(9, cm.getCollectionID(ScopeID(8), "brewerA.beer").value()); EXPECT_EQ(0xa, cm.getCollectionID(ScopeID(8), "brewerA.meat").value()); // getCollectionID doesn't care about the scope part, correct usage // is always to call getScopeID(path) first which is where scope name errors // are caught EXPECT_EQ(0xa, cm.getCollectionID(ScopeID(8), "ignored.meat").value()); // validation of the path formation is not done by getCollectionID the // following does end up throwing though because it assumes the collection // to lookup is this.that.what, and . is an illegal character try { cm.getScopeID("junk.this.that.what"); } catch (const cb::engine_error& e) { EXPECT_EQ(cb::engine_errc::invalid_arguments, cb::engine_errc(e.code().value())); } // valid path but invalid collection component try { cm.getCollectionID(ScopeID::Default, "_default.collection&"); } catch (const cb::engine_error& e) { EXPECT_EQ(cb::engine_errc::invalid_arguments, cb::engine_errc(e.code().value())); } // unknown scope as first param is invalid EXPECT_THROW(cm.getCollectionID(ScopeID{22}, "_default.meat"), std::invalid_argument); // illegal scope name isn't checked here, getScopeID is expected to have // been called first and the given ScopeID is what is used in the lookup EXPECT_EQ(0xa, cm.getCollectionID(ScopeID(8), "*#illegal.meat").value()); // Unknown names EXPECT_FALSE(cm.getCollectionID(ScopeID::Default, "unknown.collection")); // Unknown scope EXPECT_FALSE(cm.getCollectionID(ScopeID::Default, "unknown.beer")); // Unknown collection EXPECT_FALSE(cm.getCollectionID(ScopeID::Default, "brewerA.ale")); } TEST(ManifestTest, isSuccesor) { CollectionsManifest cm; cm.add(CollectionEntry::meat); cm.add(ScopeEntry::shop1); cm.add(CollectionEntry::dairy, ScopeEntry::shop1); Collections::Manifest a; Collections::Manifest b1; Collections::Manifest b2{std::string{cm}}; Collections::Manifest c{std::string{cm}}; // a and b1 are the same and isSuccessor allows EXPECT_EQ(cb::engine_errc::success, a.isSuccessor(b1).code()); // b2 is a successor in valid ways EXPECT_EQ(cb::engine_errc::success, a.isSuccessor(b2).code()); // b2 and c are the same (but not default constructed) EXPECT_EQ(cb::engine_errc::success, b2.isSuccessor(c).code()); } TEST(ManifestTest, isNotSuccesor) { CollectionsManifest cm; cm.add(CollectionEntry::meat); cm.add(ScopeEntry::shop1); cm.add(CollectionEntry::dairy, ScopeEntry::shop1); Collections::Manifest current{std::string{cm}}; { // switch the name of the scope and test CollectionsManifest cm2 = cm; cm2.rename(ScopeEntry::shop1, "some_shop"); Collections::Manifest incoming{std::string{cm2}}; EXPECT_NE(cb::engine_errc::success, current.isSuccessor(incoming).code()); } { // switch the name of a collection in _default scope and test CollectionsManifest cm2 = cm; cm2.rename(CollectionEntry::meat, ScopeEntry::defaultS, "MEAT"); Collections::Manifest incoming{std::string{cm2}}; EXPECT_NE(cb::engine_errc::success, current.isSuccessor(incoming).code()); } { // switch the name of a collection in a custom scope and test CollectionsManifest cm2 = cm; cm2.rename(CollectionEntry::dairy, ScopeEntry::shop1, "DAIRY"); Collections::Manifest incoming{std::string{cm2}}; EXPECT_NE(cb::engine_errc::success, current.isSuccessor(incoming).code()); } { // lower the uid CollectionsManifest cm2 = cm; Collections::Manifest incoming1{std::string{cm2}}; // prove that the uid shift results in error EXPECT_EQ(cb::engine_errc::success, current.isSuccessor(incoming1).code()); cm2.updateUid(cm2.getUid() - 1); Collections::Manifest incoming2{std::string{cm2}}; EXPECT_NE(cb::engine_errc::success, current.isSuccessor(incoming2).code()); } // Move a collection to a different scope cm.remove(CollectionEntry::meat); cm.add(CollectionEntry::meat, ScopeEntry::shop1); Collections::Manifest incoming3{std::string{cm}}; EXPECT_NE(cb::engine_errc::success, current.isSuccessor(incoming3).code()); }
; Move stack out of the data range LD SP, $6000 ; Load the image LD DE, ($5CF4) ; restore the FDD head position LD BC, $0F05 ; load 15 sectors of compressed image LD HL, $9C40 ; destination address (40000) CALL $3D13 CALL $9C40 ; decompress the image ; Load the data LD DE, ($5CF4) ; restore the FDD head position again LD BC, $A005 ; load 160 sectors of data LD HL, $6000 ; destination address (24576) CALL $3D13 ; Switch to another memory page LD BC,$7FFD LD A,$11 OUT (C),A PUSH BC ; Load the music LD DE, ($5CF4) ; restore the FDD head position LD BC, $1805 ; load 24 sectors of data LD HL, $C000 ; destination address (49152) CALL $3D13 ; Switch memory page back POP BC LD A,$10 OUT (C),A JP $7530
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <folly/futures/Future.h> #include <folly/futures/Promise.h> #include <folly/futures/test/TestExecutor.h> #include <folly/portability/GTest.h> #include <folly/synchronization/Baton.h> using namespace folly; TEST(Interrupt, raise) { using eggs_t = std::runtime_error; Promise<Unit> p; p.setInterruptHandler([&](const exception_wrapper& e) { EXPECT_THROW(e.throw_exception(), eggs_t); }); p.getFuture().raise(eggs_t("eggs")); } TEST(Interrupt, cancel) { Promise<Unit> p; p.setInterruptHandler([&](const exception_wrapper& e) { EXPECT_THROW(e.throw_exception(), FutureCancellation); }); p.getFuture().cancel(); } TEST(Interrupt, handleThenInterrupt) { Promise<int> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getFuture().cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, interruptThenHandle) { Promise<int> p; bool flag = false; p.getFuture().cancel(); p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); EXPECT_TRUE(flag); } TEST(Interrupt, interruptAfterFulfilNoop) { Promise<Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.setValue(); p.getFuture().cancel(); EXPECT_FALSE(flag); } TEST(Interrupt, secondInterruptNoop) { Promise<Unit> p; int count = 0; p.setInterruptHandler([&](const exception_wrapper& /* e */) { count++; }); auto f = p.getFuture(); f.cancel(); f.cancel(); EXPECT_EQ(1, count); } TEST(Interrupt, futureWithinTimedOut) { Promise<int> p; Baton<> done; p.setInterruptHandler([&](const exception_wrapper& /* e */) { done.post(); }); p.getFuture().within(std::chrono::milliseconds(1)); // Give it 100ms to time out and call the interrupt handler EXPECT_TRUE(done.try_wait_for(std::chrono::milliseconds(100))); } TEST(Interrupt, semiFutureWithinTimedOut) { folly::TestExecutor ex(1); Promise<int> p; Baton<> done; p.setInterruptHandler([&](const exception_wrapper& /* e */) { done.post(); }); p.getSemiFuture().within(std::chrono::milliseconds(1)).via(&ex); // Give it 100ms to time out and call the interrupt handler EXPECT_TRUE(done.try_wait_for(std::chrono::milliseconds(100))); } TEST(Interrupt, futureThenValue) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getFuture().thenValue([](folly::Unit&&) {}).cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, semiFutureDeferValue) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getSemiFuture().deferValue([](folly::Unit&&) {}).cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, futureThenValueFuture) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getFuture() .thenValue([](folly::Unit&&) { return folly::makeFuture(); }) .cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, semiFutureDeferValueSemiFuture) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getSemiFuture() .deferValue([](folly::Unit&&) { return folly::makeSemiFuture(); }) .cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, futureThenError) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getFuture().thenError([](const exception_wrapper& /* e */) {}).cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, semiFutureDeferError) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getSemiFuture() .deferError([](const exception_wrapper& /* e */) {}) .cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, futureThenErrorTagged) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getFuture() .thenError( folly::tag_t<std::runtime_error>{}, [](const exception_wrapper& /* e */) {}) .cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, semiFutureDeferErrorTagged) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getSemiFuture() .deferError( folly::tag_t<std::runtime_error>{}, [](const exception_wrapper& /* e */) {}) .cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, futureThenErrorFuture) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getFuture() .thenError([](const exception_wrapper& /* e */) { return makeFuture(); }) .cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, semiFutureDeferErrorSemiFuture) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getSemiFuture() .deferError( [](const exception_wrapper& /* e */) { return makeSemiFuture(); }) .cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, futureThenErrorTaggedFuture) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getFuture() .thenError( folly::tag_t<std::runtime_error>{}, [](const exception_wrapper& /* e */) { return makeFuture(); }) .cancel(); EXPECT_TRUE(flag); } TEST(Interrupt, semiFutureDeferErrorTaggedSemiFuture) { folly::TestExecutor ex(1); Promise<folly::Unit> p; bool flag = false; p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; }); p.getSemiFuture() .deferError( folly::tag_t<std::runtime_error>{}, [](const exception_wrapper& /* e */) { return makeSemiFuture(); }) .cancel(); EXPECT_TRUE(flag); }
; =============================================================== ; Jan 2014 ; =============================================================== ; ; int vfprintf_unlocked(FILE *stream, const char *format, void *arg) ; ; See C11 specification. ; ; =============================================================== INCLUDE "clib_cfg.asm" SECTION code_clib SECTION code_stdio PUBLIC asm_vfprintf_unlocked_int PUBLIC asm0_vfprintf_unlocked_int, asm1_vfprintf_unlocked_int EXTERN __stdio_verify_output, asm_strchrnul, __stdio_send_output_buffer EXTERN l_utod_hl, l_neg_hl, error_einval_zc IF __CLIB_OPT_PRINTF != 0 EXTERN __stdio_nextarg_de, l_atou, __stdio_length_modifier, error_erange_zc ENDIF asm_vfprintf_unlocked_int: ; enter : ix = FILE * ; de = char *format ; bc = void *stack_param = arg ; ; exit : ix = FILE * ; de = char *format (next unexamined char) ; ; success ; ; hl = number of chars output on stream ; carry reset ; ; fail ; ; hl = - (chars output + 1) < 0 ; carry set, errno set as below ; ; eacces = stream not open for writing ; eacces = stream is in an error state ; erange = width or precision out of range ; einval = unknown printf conversion ; ; more errors may be set by underlying driver ; ; uses : all except ix ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_STDIO & $01 EXTERN __stdio_verify_valid call __stdio_verify_valid ret c ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; asm1_vfprintf_unlocked_int: call __stdio_verify_output ; check that output on stream is ok ret c ; if output on stream not possible asm0_vfprintf_unlocked_int: IF __CLIB_OPT_PRINTF != 0 ld hl,-44 add hl,sp ld sp,hl ; create 44 bytes of workspace push bc ENDIF exx ld hl,0 ; initial output count is zero exx ;****************************** ; * FORMAT STRING LOOP ******** format_loop: ; de = char *format ; stack = WORKSPACE_44, stack_param ld l,e ld h,d __format_loop: ld c,'%' call asm_strchrnul ; output format string chars up to '%' push hl or a sbc hl,de ld c,l ld b,h ; bc = num chars to output ex de,hl ; hl = char *format call nz, __stdio_send_output_buffer pop de IF __CLIB_OPT_PRINTF = 0 jr c, error_stream ; if stream error ELSE jp c, error_stream ; if stream error ENDIF ; de = address of format char stopped on ('%' or '\0') ; stack = WORKSPACE_44, stack_param ld a,(de) or a jr z, format_end ; if stopped on string terminator inc de ; next format char to examine ld a,(de) cp '%' jr nz, interpret ; %% ld l,e ld h,d inc hl ; next char to examine is past %% jr __format_loop format_end: ; de = address of format char '\0' ; stack = WORKSPACE_44, stack_param IF __CLIB_OPT_PRINTF != 0 ld hl,46 add hl,sp ld sp,hl ; repair stack ENDIF exx push hl exx pop hl ; hl = number of chars output or a jp l_utod_hl ; hl = max $7fff ; * AA ******************************************************** IF __CLIB_OPT_PRINTF = 0 ; completely disable % logic ; printf can only be used to output format text interpret: ; de = address of format char after '%' call error_einval_zc ;;;; jr error_stream ; could probably just fall through but let's be safe ENDIF ; * BB ******************************************************** IF __CLIB_OPT_PRINTF != 0 ; regular % processing flag_chars: defb '+', $40 defb ' ', $20 defb '#', $10 defb '0', $08 defb '-', $04 interpret: dec de ld c,0 ;****************************** ; * FLAGS FIELD *************** flags: ; consume optional flags "-+ #0" ; default flags is none set inc de ; advance to next char in format string ; de = address of next format char to examine ; c = conversion_flags ; stack = WORKSPACE_44, stack_param ld a,(de) ld hl,flag_chars ld b,5 flags_id: cp (hl) inc hl jr z, flag_found inc hl djnz flags_id ld (ix+5),c ; store conversion_flags ;****************************** ; * WIDTH FIELD *************** width: ; consume optional width specifier ; default width is zero ; a = next format char ; de = address of next format char to examine ; stack = WORKSPACE_44, stack_param cp '*' jr nz, width_from_format ; asterisk means width comes from parameter list pop hl inc de ; consume '*' push de ; hl = stack_param ; stack = WORKSPACE_44, address of next format char to examine call __stdio_nextarg_de ; de = width ex de,hl ; hl = width ; de = stack_param ; stack = WORKSPACE_44, address of next format char to examine bit 7,h jr z, width_positive ; negative field width call l_neg_hl ; width made positive set 2,(ix+5) ; '-' flag set width_positive: ex (sp),hl ex de,hl push hl ; de = address of next format char to examine ; stack = WORKSPACE_44, width, stack_param jr precision flag_found: ld a,(hl) or c ld c,a jr flags width_from_format: ; read width from format string, default = 0 ; de = address of next format char to examine ; stack = WORKSPACE_44, stack_param call l_atou ; hl = width jp c, error_format_width ; width out of range bit 7,h jp nz, error_format_width ; width out of range ex (sp),hl push hl ;****************************** ; * PRECISION FIELD *********** precision: ; consume optional precision specifier ; default precision is one ; de = address of next format char to examine ; stack = WORKSPACE_44, width, stack_param ld hl,1 ; default precision ld a,(de) cp '.' jr nz, end_precision set 0,(ix+5) ; indicate precision is specified inc de ; consume '.' ld a,(de) cp '*' jr nz, precision_from_format ; asterisk means precision comes from parameter list pop hl inc de ; consume '*' push de ; hl = stack_param ; stack = WORKSPACE_44, width, address of next format char to examine call __stdio_nextarg_de ; de = precision ex de,hl ; hl = precision ; de = stack_param ; stack = WORKSPACE_44, width, address of next format char to examine bit 7,h jr z, precision_positive ; negative precision means precision is ignored ld hl,1 ; precision takes default value res 0,(ix+5) ; indicate precision is not specified precision_positive: ex (sp),hl ex de,hl push hl ; de = address of next format char to examine ; stack = WORKSPACE_44, width, precision, stack_param jr length_modifier precision_from_format: ; read precision from format string ; de = address of next format char to examine ; stack = WORKSPACE_44, width, stack_param call l_atou ; hl = precision jp c, error_format_precision ; precision out of range bit 7,h jp nz, error_format_precision ; precision out of range end_precision: ; hl = precision ; de = address of next format char to examine ; stack = WORKSPACE_44, width, stack_param ex (sp),hl push hl ;****************************** ; * LENGTH MODIFIER *********** length_modifier: ; consume optional length modifier ; de = address of next format char to examine ; stack = WORKSPACE_44, width, precision, stack_param call __stdio_length_modifier ;****************************** ; * CONVERSION SPECIFIER ****** converter_specifier: ; identify conversion "aABcdeEfFgGinopsuxIX" ; long modifies "BdinopuxX" not "aAceEfFgGsI" ; de = address of next format char to examine ; c = length modifier id ; stack = WORKSPACE_44, width, precision, stack_param ld a,(de) ; a = specifier inc de IF __CLIB_OPT_PRINTF & $800 cp 'I' jr z, printf_I ; converter does not fit tables ENDIF ld b,a ; b = specifier ld a,c and $30 ; only pay attention to long modifier ; carry must be reset here jr nz, long_spec ; if long modifier selected ;;; without long spec IF __CLIB_OPT_PRINTF & $1ff ld hl,rcon_tbl ; converters without long spec call match_con jr c, printf_return_is_2 ENDIF common_spec: IF __CLIB_OPT_PRINTF & $600 ld hl,acon_tbl ; converters independent of long spec call match_con jr c, printf_return_is_2 ENDIF ;;; converter unrecognized unrecognized: ; de = address of next format char to examine ; stack = WORKSPACE_44, width, precision, stack_param call error_einval_zc ; set errno ld hl,50 jp __error_stream ;;; with long spec long_spec: IF __CLIB_OPT_PRINTF & $1ff000 ld hl,lcon_tbl ; converters with long spec call match_con ENDIF jr nc, common_spec ;;; conversion matched IF __CLIB_OPT_PRINTF & $1ff800 printf_return_is_4: ld bc,printf_return_4 jr printf_invoke_flags ENDIF IF __CLIB_OPT_PRINTF & $800 printf_I: EXTERN __stdio_printf_ii ld hl,__stdio_printf_ii ld a,$80 jr printf_return_is_4 ENDIF IF __CLIB_OPT_PRINTF & $7ff printf_return_is_2: ld bc,printf_return_2 ENDIF printf_invoke_flags: ; a = invoke flags ; hl = & printf converter ; bc = return address after conversion ; de = address of next format char to examine ; stack = WORKSPACE_44, width, precision, stack_param bit 5,a jr z, skip_00 set 1,(ix+5) ; indicates octal conversion skip_00: bit 4,a jr z, skip_11 res 4,(ix+5) ; suppress base indicator skip_11: and $c0 ld (ix+4),a ; capitalize & signed conversion indicators printf_invoke: ; hl = & printf_converter ; de = address of next format char to examine ; bc = return address after printf conversion ; stack = WORKSPACE_44, width, precision, stack_param ex (sp),hl ; push & printf_converter push hl ; de = char *format ; bc = return address ; stack = WORKSPACE_44, width, precision, & converter, stack_param ld hl,15 add hl,sp ld (hl),d dec hl ld (hl),e ; store address of next format char dec hl pop de ; de = stack_param ld (hl),d dec hl ld (hl),e ; store stack_param dec hl ld (hl),b dec hl ld (hl),c ; store return address after printf dec hl ld c,l ld b,h ld hl,10 add hl,bc ; hl = buffer_digits ld a,h ld (bc),a dec bc ld a,l ld (bc),a ; store buffer_digits ex de,hl ; ix = FILE * ; hl = void *stack_param ; de = void *buffer_digits ; stack = WORKSPACE_42, return addr, buffer_digits, width, precision, & printf_conv ; WORSPACE_44 low to high addresses ; ; offset size purpose ; ; 0 2 void *buffer_digits ; 2 2 return address following printf conversion ; 4 2 void *stack_param ; 6 2 address of next format char ; 8 3 prefix buffer space for printf conversion ; 11 33 buffer_digits[ (space for printf conversion) ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; match_con: ; enter : b = conversion specifier ; hl = conversion table ; ; exit : b = conversion specifier ; ; if matched ; ; a = flags ; hl = & printf converter ; carry set ; ; if unmatched ; ; carry reset ld a,(hl) inc hl or a ret z cp b jr z, match_ret inc hl inc hl inc hl jr match_con match_ret: ld a,(hl) ; a = flags inc hl ld b,(hl) inc hl ld h,(hl) ld l,b ; hl = & printf converter scf ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_PRINTF & $600 acon_tbl: IF __CLIB_OPT_PRINTF & $200 defb 's', $80 EXTERN __stdio_printf_s defw __stdio_printf_s ENDIF IF __CLIB_OPT_PRINTF & $400 defb 'c', $80 EXTERN __stdio_printf_c defw __stdio_printf_c ENDIF defb 0 ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_PRINTF & $1ff rcon_tbl: IF __CLIB_OPT_PRINTF & $01 defb 'd', $d0 EXTERN __stdio_printf_d defw __stdio_printf_d ENDIF IF __CLIB_OPT_PRINTF & $02 defb 'u', $90 EXTERN __stdio_printf_u defw __stdio_printf_u ENDIF IF __CLIB_OPT_PRINTF & $04 defb 'x', $00 EXTERN __stdio_printf_x defw __stdio_printf_x ENDIF IF __CLIB_OPT_PRINTF & $08 defb 'X', $80 EXTERN __stdio_printf_x defw __stdio_printf_x ENDIF IF __CLIB_OPT_PRINTF & $10 defb 'o', $a0 EXTERN __stdio_printf_o defw __stdio_printf_o ENDIF IF __CLIB_OPT_PRINTF & $20 defb 'n', $80 EXTERN __stdio_printf_n defw __stdio_printf_n ENDIF IF __CLIB_OPT_PRINTF & $40 defb 'i', $d0 EXTERN __stdio_printf_d defw __stdio_printf_d ENDIF IF __CLIB_OPT_PRINTF & $80 defb 'p', $80 EXTERN __stdio_printf_p defw __stdio_printf_p ENDIF IF __CLIB_OPT_PRINTF & $100 defb 'B', $90 EXTERN __stdio_printf_bb defw __stdio_printf_bb ENDIF defb 0 ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_PRINTF & $1ff000 lcon_tbl: IF __CLIB_OPT_PRINTF & $1000 defb 'd', $d0 EXTERN __stdio_printf_ld defw __stdio_printf_ld ENDIF IF __CLIB_OPT_PRINTF & $2000 defb 'u', $90 EXTERN __stdio_printf_lu defw __stdio_printf_lu ENDIF IF __CLIB_OPT_PRINTF & $4000 defb 'x', $00 EXTERN __stdio_printf_lx defw __stdio_printf_lx ENDIF IF __CLIB_OPT_PRINTF & $8000 defb 'X', $80 EXTERN __stdio_printf_lx defw __stdio_printf_lx ENDIF IF __CLIB_OPT_PRINTF & $10000 defb 'o', $a0 EXTERN __stdio_printf_lo defw __stdio_printf_lo ENDIF IF __CLIB_OPT_PRINTF & $20000 defb 'n', $80 EXTERN __stdio_printf_ln defw __stdio_printf_ln ENDIF IF __CLIB_OPT_PRINTF & $40000 defb 'i', $d0 EXTERN __stdio_printf_ld defw __stdio_printf_ld ENDIF IF __CLIB_OPT_PRINTF & $80000 defb 'p', $80 EXTERN __stdio_printf_lp defw __stdio_printf_lp ENDIF IF __CLIB_OPT_PRINTF & $100000 defb 'B', $90 EXTERN __stdio_printf_lbb defw __stdio_printf_lbb ENDIF defb 0 ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; printf_return_4: ; printf converters that read four bytes from stack_param return here ; ; carry set if error ; stack = WORKSPACE_36, char *format, void *stack_param pop bc _return_join_4: ;****************************** IF __SDCC | __SDCC_IX | __SDCC_IY ;****************************** inc bc inc bc ; bc = stack_param += 2 ;****************************** ELSE ;****************************** dec bc dec bc ; bc = stack_param += 2 ;****************************** ENDIF ;****************************** jr _return_join_2 printf_return_2: ; printf converters that read two bytes from stack_param return here ; ; carry set if error ; stack = WORKSPACE_36, char *format, void *stack_param pop bc _return_join_2: ;****************************** IF __SDCC | __SDCC_IX | __SDCC_IY ;****************************** inc bc inc bc ; bc = stack_param += 2 ;****************************** ELSE ;****************************** dec bc dec bc ; bc = stack_param += 2 ;****************************** ENDIF ;****************************** pop de ; de = char *format jr c, error_printf_converter ld hl,-8 add hl,sp ld sp,hl push bc ; format_loop expects this: ; ; de = char *format ; stack = WORKSPACE_44, stack_param jp format_loop ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; error_format_precision: ; de = address of next format char to examine ; stack = WORKSPACE_44, width, stack_param pop bc ; junk one item ; fall through error_format_width: ; de = address of next format char to examine ; stack = WORKSPACE_44, stack_param call error_erange_zc ; set errno ; fall through ENDIF ; ** AA BB **************************************************** ; all clib options have this code error_stream: IF __CLIB_OPT_PRINTF != 0 ; de = address of format char stopped on ('%' or '\0') ; stack = WORKSPACE_44, stack_param ld hl,46 __error_stream: add hl,sp ld sp,hl ; repair stack ENDIF exx push hl exx pop hl ; hl = number of chars transmitted call l_utod_hl ; hl = max $7fff inc hl scf ; indicate error jp l_neg_hl ; hl = - (chars out + 1) < 0 IF __CLIB_OPT_PRINTF != 0 error_printf_converter: ; de = address of next format char to examine ; stack = WORKSPACE_36 ld hl,36 jr __error_stream ENDIF
; A134517: Primes of form 24n-1. ; Submitted by Jon Maiga ; 23,47,71,167,191,239,263,311,359,383,431,479,503,599,647,719,743,839,863,887,911,983,1031,1103,1151,1223,1319,1367,1439,1487,1511,1559,1583,1607,1823,1847,1871,2039,2063,2087,2111,2207,2351,2399,2423,2447,2543,2591,2663,2687,2711,2879,2903,2927,2999,3023,3119,3167,3191,3359,3407,3527,3623,3671,3719,3767,3863,3911,4007,4079,4127,4271,4391,4463,4583,4679,4703,4751,4799,4871,4919,4943,4967,5039,5087,5231,5279,5303,5351,5399,5471,5519,5591,5639,5711,5783,5807,5879,5903,5927 mov $2,$0 pow $2,2 mov $4,22 lpb $2 mov $3,$4 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 mov $1,$0 max $1,0 cmp $1,$0 mul $2,$1 sub $2,1 add $4,24 lpe mov $0,$4 add $0,1
#include "global.h" /** * Syntax : <new_table> <- GROUP BY <grouping_attribute> FROM <table_name> RETURN MAX|MIN|SUM|AVG(<attribute>) * * A_group_by_a <- GROUP BY c FROM A RETURN SUM(a) * 0 1 2 3 4 5 6 7 8 */ /** * @details Checking syntax of GROUP BY command * @return True if sytactically correct */ bool syntacticParseGROUPBY() { logger.log("syntacticParseGROUPBY"); // for(string s : tokenizedQuery){ // cout<<s<<endl; // } if (tokenizedQuery.size() != 9 || tokenizedQuery[3] != "BY" || tokenizedQuery[5] != "FROM" || tokenizedQuery[7] != "RETURN") { cout << "SYNTAX ERROR Group By" << endl; return false; } parsedQuery.queryType = GROUP_BY; parsedQuery.groupByResultRelationName = tokenizedQuery[0]; parsedQuery.groupByRelationName = tokenizedQuery[6]; parsedQuery.groupByColumnName = tokenizedQuery[4]; string temp = tokenizedQuery[8]; string type = ""; string value = ""; if(temp.size()>5 && temp[3]=='(' && temp[temp.size()-1]==')'){ type = temp.substr(0, 3); cout<<type<<endl; value = temp.substr(4, temp.size()-5); cout<<value<<endl; } else{ return false; } if(type=="SUM"){ parsedQuery.aggregateType = SUM; } else if(type=="MIN"){ parsedQuery.aggregateType = MIN; } else if(type=="MAX"){ parsedQuery.aggregateType = MAX; } else if(type=="AVG"){ parsedQuery.aggregateType = AVG; } else{ return false; } parsedQuery.groupByAggregateAttribute = value; return true; } /** * @brief Checking syntax of GROUP BY command * * @return true if semantically correct */ bool semanticParseGROUPBY() { logger.log("semanticParseGROUPBY"); if(tableCatalogue.isTable(parsedQuery.groupByResultRelationName)){ cout<<"SEMANTIC ERROR: Resultant relation already exists"<<endl; return false; } if(!tableCatalogue.isTable(parsedQuery.groupByRelationName)){ cout<<"SEMANTIC ERROR: Relation doesn't exist " << parsedQuery.groupByRelationName <<endl; return false; } if(!tableCatalogue.isColumnFromTable(parsedQuery.groupByColumnName, parsedQuery.groupByRelationName)){ cout<<"SEMANTIC ERROR: Column doesn't exist in relation"<<endl; return false; } if(!tableCatalogue.isColumnFromTable(parsedQuery.groupByAggregateAttribute, parsedQuery.groupByRelationName)){ cout<<"SEMANTIC ERROR: Aggregate Column doesn't exist in relation"<<endl; return false; } return true; } /** * @brief Execute the GROUP BY command */ void executeGROUPBY() { // cout<<"executeGROUPBY\n"; logger.log("executeGROUPBY"); Table* table = tableCatalogue.getTable(parsedQuery.groupByRelationName); // if(table->indexingStrategy == BTREE){ // } // else if(table->indexingStrategy == HASH){ // // int columnIndex = table->getColumnIndex(table->indexedColumn); // // table->hashTable->insertRecord({inserting_row[columnIndex], 0, 0}); // // table->hashTable->print(); // } // else{ // } int groupColumnIndex = table->getColumnIndex(parsedQuery.groupByColumnName); int aggregateColumnIndex = table->getColumnIndex(parsedQuery.groupByAggregateAttribute); Aggregates type = parsedQuery.aggregateType; vector<int> row; map<int, int> groupMap; Cursor cursor = table->getCursor(); for (int rowCounter = 0; rowCounter < table->rowCount; rowCounter++){ row = cursor.getNext(); if(type == SUM){ if(groupMap.find(row[groupColumnIndex])==groupMap.end()){ groupMap[row[groupColumnIndex]] = row[aggregateColumnIndex]; } else{ groupMap[row[groupColumnIndex]] += row[aggregateColumnIndex]; } } else if(type == MAX){ if(groupMap.find(row[groupColumnIndex])==groupMap.end()){ groupMap[row[groupColumnIndex]] = row[aggregateColumnIndex]; } else{ groupMap[row[groupColumnIndex]] =max(groupMap[row[groupColumnIndex]], row[aggregateColumnIndex]); } } else if(type == MIN){ if(groupMap.find(row[groupColumnIndex])==groupMap.end()){ groupMap[row[groupColumnIndex]] = row[aggregateColumnIndex]; } else{ groupMap[row[groupColumnIndex]] =min(groupMap[row[groupColumnIndex]], row[aggregateColumnIndex]); } } else if(type == AVG){ if(groupMap.find(row[groupColumnIndex])==groupMap.end()){ groupMap[row[groupColumnIndex]] = row[aggregateColumnIndex]; } else{ groupMap[row[groupColumnIndex]] += row[aggregateColumnIndex]; } } } for(auto i : groupMap){ cout<< i.first << " " << i.second <<endl; } vector<string> columns; columns.push_back(parsedQuery.groupByColumnName); if(type==SUM){ columns.push_back("SUM"+parsedQuery.groupByAggregateAttribute); } else if(type==MAX){ columns.push_back("MAX"+parsedQuery.groupByAggregateAttribute); } else if(type==MIN){ columns.push_back("MIN"+parsedQuery.groupByAggregateAttribute); } else if(type==AVG){ columns.push_back("AVG"+parsedQuery.groupByAggregateAttribute); } Table *resultantTable = new Table(parsedQuery.groupByResultRelationName, columns); string line, word; for(auto i : groupMap){ vector<int> row1; row1.push_back(i.first); row1.push_back(i.second); resultantTable->writeRow<int>(row1); } resultantTable->blockify(); tableCatalogue.insertTable(resultantTable); return; }
; ; ANSI Video handling for the VZ200 ; ; set it up with: ; .text_cols = max columns ; .text_rows = max rows ; ; Display a char in location (ansi_ROW),(ansi_COLUMN) ; A=char to display ; ; ; $Id: f_ansi_char.asm,v 1.3 2015/01/19 01:33:19 pauloscustodio Exp $ ; PUBLIC ansi_CHAR PUBLIC text_cols PUBLIC text_rows EXTERN ansi_ROW EXTERN ansi_COLUMN EXTERN vz_inverse .text_cols defb 32 .text_rows defb 16 .ansi_CHAR ; 193 Inverse characters starting from "@". ; 64 "@" char (as normal). ; 127-192 Pseudo-Graphics Chars (like ZX81) ; Some undercase text? Transform in UPPER ! cp 97 jr c,isupper sub 32 .isupper and @00111111 ld hl,vz_inverse or (hl) .setout push af ld hl,$7000 ld a,(ansi_ROW) and a jr z,r_zero ld b,a ld de,32 .r_loop add hl,de djnz r_loop .r_zero ld a,(ansi_COLUMN) ld d,0 ld e,a add hl,de pop af ld (hl),a ret
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %rdx push %rsi lea addresses_D_ht+0x1b45b, %r14 nop nop nop nop sub %rsi, %rsi movl $0x61626364, (%r14) sub $948, %rdx pop %rsi pop %rdx pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r8 push %rcx push %rdi push %rdx push %rsi // Store lea addresses_WC+0x47db, %r13 nop nop nop and %rdi, %rdi movb $0x51, (%r13) dec %r14 // Load lea addresses_UC+0x165cb, %r8 nop nop nop nop dec %rcx mov (%r8), %r14 nop nop nop nop inc %rdx // Faulty Load lea addresses_normal+0x1e2db, %rdx xor %rcx, %rcx mov (%rdx), %r8 lea oracles, %rsi and $0xff, %r8 shlq $12, %r8 mov (%rsi,%r8,1), %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %r8 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': False, 'congruent': 8}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_UC', 'same': False, 'AVXalign': False, 'congruent': 1}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 8, 'NT': True, 'type': 'addresses_normal', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 6}} {'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 */
; A171387: The characteristic function of primes > 3: 1 if n is prime such that neither prime+-1 is prime else 0. ; Submitted by Simon Strandgaard ; 0,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0 seq $0,89026 ; a(n) = n if n is a prime, otherwise a(n) = 1. sub $0,2 max $0,2 mod $0,2
_cat: file format elf32-i386 Disassembly of section .text: 00000000 <main>: } } int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: be 01 00 00 00 mov $0x1,%esi 16: 83 ec 18 sub $0x18,%esp 19: 8b 01 mov (%ecx),%eax 1b: 8b 59 04 mov 0x4(%ecx),%ebx 1e: 83 c3 04 add $0x4,%ebx int fd, i; if(argc <= 1){ 21: 83 f8 01 cmp $0x1,%eax } } int main(int argc, char *argv[]) { 24: 89 45 e4 mov %eax,-0x1c(%ebp) int fd, i; if(argc <= 1){ 27: 7e 54 jle 7d <main+0x7d> 29: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi cat(0); exit(); } for(i = 1; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ 30: 83 ec 08 sub $0x8,%esp 33: 6a 00 push $0x0 35: ff 33 pushl (%ebx) 37: e8 56 03 00 00 call 392 <open> 3c: 83 c4 10 add $0x10,%esp 3f: 85 c0 test %eax,%eax 41: 89 c7 mov %eax,%edi 43: 78 24 js 69 <main+0x69> printf(1, "cat: cannot open %s\n", argv[i]); exit(); } cat(fd); 45: 83 ec 0c sub $0xc,%esp if(argc <= 1){ cat(0); exit(); } for(i = 1; i < argc; i++){ 48: 83 c6 01 add $0x1,%esi 4b: 83 c3 04 add $0x4,%ebx if((fd = open(argv[i], 0)) < 0){ printf(1, "cat: cannot open %s\n", argv[i]); exit(); } cat(fd); 4e: 50 push %eax 4f: e8 3c 00 00 00 call 90 <cat> close(fd); 54: 89 3c 24 mov %edi,(%esp) 57: e8 1e 03 00 00 call 37a <close> if(argc <= 1){ cat(0); exit(); } for(i = 1; i < argc; i++){ 5c: 83 c4 10 add $0x10,%esp 5f: 39 75 e4 cmp %esi,-0x1c(%ebp) 62: 75 cc jne 30 <main+0x30> exit(); } cat(fd); close(fd); } exit(); 64: e8 e9 02 00 00 call 352 <exit> exit(); } for(i = 1; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ printf(1, "cat: cannot open %s\n", argv[i]); 69: 50 push %eax 6a: ff 33 pushl (%ebx) 6c: 68 e3 07 00 00 push $0x7e3 71: 6a 01 push $0x1 73: e8 28 04 00 00 call 4a0 <printf> exit(); 78: e8 d5 02 00 00 call 352 <exit> main(int argc, char *argv[]) { int fd, i; if(argc <= 1){ cat(0); 7d: 83 ec 0c sub $0xc,%esp 80: 6a 00 push $0x0 82: e8 09 00 00 00 call 90 <cat> exit(); 87: e8 c6 02 00 00 call 352 <exit> 8c: 66 90 xchg %ax,%ax 8e: 66 90 xchg %ax,%ax 00000090 <cat>: char buf[512]; void cat(int fd) { 90: 55 push %ebp 91: 89 e5 mov %esp,%ebp 93: 56 push %esi 94: 53 push %ebx 95: 8b 75 08 mov 0x8(%ebp),%esi int n; while((n = read(fd, buf, sizeof(buf))) > 0) { 98: eb 1d jmp b7 <cat+0x27> 9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if (write(1, buf, n) != n) { a0: 83 ec 04 sub $0x4,%esp a3: 53 push %ebx a4: 68 00 0b 00 00 push $0xb00 a9: 6a 01 push $0x1 ab: e8 c2 02 00 00 call 372 <write> b0: 83 c4 10 add $0x10,%esp b3: 39 c3 cmp %eax,%ebx b5: 75 26 jne dd <cat+0x4d> void cat(int fd) { int n; while((n = read(fd, buf, sizeof(buf))) > 0) { b7: 83 ec 04 sub $0x4,%esp ba: 68 00 02 00 00 push $0x200 bf: 68 00 0b 00 00 push $0xb00 c4: 56 push %esi c5: e8 a0 02 00 00 call 36a <read> ca: 83 c4 10 add $0x10,%esp cd: 83 f8 00 cmp $0x0,%eax d0: 89 c3 mov %eax,%ebx d2: 7f cc jg a0 <cat+0x10> if (write(1, buf, n) != n) { printf(1, "cat: write error\n"); exit(); } } if(n < 0){ d4: 75 1b jne f1 <cat+0x61> printf(1, "cat: read error\n"); exit(); } } d6: 8d 65 f8 lea -0x8(%ebp),%esp d9: 5b pop %ebx da: 5e pop %esi db: 5d pop %ebp dc: c3 ret { int n; while((n = read(fd, buf, sizeof(buf))) > 0) { if (write(1, buf, n) != n) { printf(1, "cat: write error\n"); dd: 83 ec 08 sub $0x8,%esp e0: 68 c0 07 00 00 push $0x7c0 e5: 6a 01 push $0x1 e7: e8 b4 03 00 00 call 4a0 <printf> exit(); ec: e8 61 02 00 00 call 352 <exit> } } if(n < 0){ printf(1, "cat: read error\n"); f1: 83 ec 08 sub $0x8,%esp f4: 68 d2 07 00 00 push $0x7d2 f9: 6a 01 push $0x1 fb: e8 a0 03 00 00 call 4a0 <printf> exit(); 100: e8 4d 02 00 00 call 352 <exit> 105: 66 90 xchg %ax,%ax 107: 66 90 xchg %ax,%ax 109: 66 90 xchg %ax,%ax 10b: 66 90 xchg %ax,%ax 10d: 66 90 xchg %ax,%ax 10f: 90 nop 00000110 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 53 push %ebx 114: 8b 45 08 mov 0x8(%ebp),%eax 117: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 11a: 89 c2 mov %eax,%edx 11c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 120: 83 c1 01 add $0x1,%ecx 123: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 127: 83 c2 01 add $0x1,%edx 12a: 84 db test %bl,%bl 12c: 88 5a ff mov %bl,-0x1(%edx) 12f: 75 ef jne 120 <strcpy+0x10> ; return os; } 131: 5b pop %ebx 132: 5d pop %ebp 133: c3 ret 134: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 13a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000140 <strcmp>: int strcmp(const char *p, const char *q) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 56 push %esi 144: 53 push %ebx 145: 8b 55 08 mov 0x8(%ebp),%edx 148: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 14b: 0f b6 02 movzbl (%edx),%eax 14e: 0f b6 19 movzbl (%ecx),%ebx 151: 84 c0 test %al,%al 153: 75 1e jne 173 <strcmp+0x33> 155: eb 29 jmp 180 <strcmp+0x40> 157: 89 f6 mov %esi,%esi 159: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 160: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 163: 0f b6 02 movzbl (%edx),%eax p++, q++; 166: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 169: 0f b6 59 01 movzbl 0x1(%ecx),%ebx 16d: 84 c0 test %al,%al 16f: 74 0f je 180 <strcmp+0x40> 171: 89 f1 mov %esi,%ecx 173: 38 d8 cmp %bl,%al 175: 74 e9 je 160 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; 177: 29 d8 sub %ebx,%eax } 179: 5b pop %ebx 17a: 5e pop %esi 17b: 5d pop %ebp 17c: c3 ret 17d: 8d 76 00 lea 0x0(%esi),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 180: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 182: 29 d8 sub %ebx,%eax } 184: 5b pop %ebx 185: 5e pop %esi 186: 5d pop %ebp 187: c3 ret 188: 90 nop 189: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000190 <strlen>: uint strlen(const char *s) { 190: 55 push %ebp 191: 89 e5 mov %esp,%ebp 193: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 196: 80 39 00 cmpb $0x0,(%ecx) 199: 74 12 je 1ad <strlen+0x1d> 19b: 31 d2 xor %edx,%edx 19d: 8d 76 00 lea 0x0(%esi),%esi 1a0: 83 c2 01 add $0x1,%edx 1a3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 1a7: 89 d0 mov %edx,%eax 1a9: 75 f5 jne 1a0 <strlen+0x10> ; return n; } 1ab: 5d pop %ebp 1ac: c3 ret uint strlen(const char *s) { int n; for(n = 0; s[n]; n++) 1ad: 31 c0 xor %eax,%eax ; return n; } 1af: 5d pop %ebp 1b0: c3 ret 1b1: eb 0d jmp 1c0 <memset> 1b3: 90 nop 1b4: 90 nop 1b5: 90 nop 1b6: 90 nop 1b7: 90 nop 1b8: 90 nop 1b9: 90 nop 1ba: 90 nop 1bb: 90 nop 1bc: 90 nop 1bd: 90 nop 1be: 90 nop 1bf: 90 nop 000001c0 <memset>: void* memset(void *dst, int c, uint n) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 57 push %edi 1c4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1c7: 8b 4d 10 mov 0x10(%ebp),%ecx 1ca: 8b 45 0c mov 0xc(%ebp),%eax 1cd: 89 d7 mov %edx,%edi 1cf: fc cld 1d0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 1d2: 89 d0 mov %edx,%eax 1d4: 5f pop %edi 1d5: 5d pop %ebp 1d6: c3 ret 1d7: 89 f6 mov %esi,%esi 1d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001e0 <strchr>: char* strchr(const char *s, char c) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 53 push %ebx 1e4: 8b 45 08 mov 0x8(%ebp),%eax 1e7: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 1ea: 0f b6 10 movzbl (%eax),%edx 1ed: 84 d2 test %dl,%dl 1ef: 74 1d je 20e <strchr+0x2e> if(*s == c) 1f1: 38 d3 cmp %dl,%bl 1f3: 89 d9 mov %ebx,%ecx 1f5: 75 0d jne 204 <strchr+0x24> 1f7: eb 17 jmp 210 <strchr+0x30> 1f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 200: 38 ca cmp %cl,%dl 202: 74 0c je 210 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 204: 83 c0 01 add $0x1,%eax 207: 0f b6 10 movzbl (%eax),%edx 20a: 84 d2 test %dl,%dl 20c: 75 f2 jne 200 <strchr+0x20> if(*s == c) return (char*)s; return 0; 20e: 31 c0 xor %eax,%eax } 210: 5b pop %ebx 211: 5d pop %ebp 212: c3 ret 213: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000220 <gets>: char* gets(char *buf, int max) { 220: 55 push %ebp 221: 89 e5 mov %esp,%ebp 223: 57 push %edi 224: 56 push %esi 225: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 226: 31 f6 xor %esi,%esi cc = read(0, &c, 1); 228: 8d 7d e7 lea -0x19(%ebp),%edi return 0; } char* gets(char *buf, int max) { 22b: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 22e: eb 29 jmp 259 <gets+0x39> cc = read(0, &c, 1); 230: 83 ec 04 sub $0x4,%esp 233: 6a 01 push $0x1 235: 57 push %edi 236: 6a 00 push $0x0 238: e8 2d 01 00 00 call 36a <read> if(cc < 1) 23d: 83 c4 10 add $0x10,%esp 240: 85 c0 test %eax,%eax 242: 7e 1d jle 261 <gets+0x41> break; buf[i++] = c; 244: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 248: 8b 55 08 mov 0x8(%ebp),%edx 24b: 89 de mov %ebx,%esi if(c == '\n' || c == '\r') 24d: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 24f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 253: 74 1b je 270 <gets+0x50> 255: 3c 0d cmp $0xd,%al 257: 74 17 je 270 <gets+0x50> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 259: 8d 5e 01 lea 0x1(%esi),%ebx 25c: 3b 5d 0c cmp 0xc(%ebp),%ebx 25f: 7c cf jl 230 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 261: 8b 45 08 mov 0x8(%ebp),%eax 264: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 268: 8d 65 f4 lea -0xc(%ebp),%esp 26b: 5b pop %ebx 26c: 5e pop %esi 26d: 5f pop %edi 26e: 5d pop %ebp 26f: c3 ret break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 270: 8b 45 08 mov 0x8(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 273: 89 de mov %ebx,%esi break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 275: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 279: 8d 65 f4 lea -0xc(%ebp),%esp 27c: 5b pop %ebx 27d: 5e pop %esi 27e: 5f pop %edi 27f: 5d pop %ebp 280: c3 ret 281: eb 0d jmp 290 <stat> 283: 90 nop 284: 90 nop 285: 90 nop 286: 90 nop 287: 90 nop 288: 90 nop 289: 90 nop 28a: 90 nop 28b: 90 nop 28c: 90 nop 28d: 90 nop 28e: 90 nop 28f: 90 nop 00000290 <stat>: int stat(const char *n, struct stat *st) { 290: 55 push %ebp 291: 89 e5 mov %esp,%ebp 293: 56 push %esi 294: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 295: 83 ec 08 sub $0x8,%esp 298: 6a 00 push $0x0 29a: ff 75 08 pushl 0x8(%ebp) 29d: e8 f0 00 00 00 call 392 <open> if(fd < 0) 2a2: 83 c4 10 add $0x10,%esp 2a5: 85 c0 test %eax,%eax 2a7: 78 27 js 2d0 <stat+0x40> return -1; r = fstat(fd, st); 2a9: 83 ec 08 sub $0x8,%esp 2ac: ff 75 0c pushl 0xc(%ebp) 2af: 89 c3 mov %eax,%ebx 2b1: 50 push %eax 2b2: e8 f3 00 00 00 call 3aa <fstat> 2b7: 89 c6 mov %eax,%esi close(fd); 2b9: 89 1c 24 mov %ebx,(%esp) 2bc: e8 b9 00 00 00 call 37a <close> return r; 2c1: 83 c4 10 add $0x10,%esp 2c4: 89 f0 mov %esi,%eax } 2c6: 8d 65 f8 lea -0x8(%ebp),%esp 2c9: 5b pop %ebx 2ca: 5e pop %esi 2cb: 5d pop %ebp 2cc: c3 ret 2cd: 8d 76 00 lea 0x0(%esi),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 2d0: b8 ff ff ff ff mov $0xffffffff,%eax 2d5: eb ef jmp 2c6 <stat+0x36> 2d7: 89 f6 mov %esi,%esi 2d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002e0 <atoi>: return r; } int atoi(const char *s) { 2e0: 55 push %ebp 2e1: 89 e5 mov %esp,%ebp 2e3: 53 push %ebx 2e4: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 2e7: 0f be 11 movsbl (%ecx),%edx 2ea: 8d 42 d0 lea -0x30(%edx),%eax 2ed: 3c 09 cmp $0x9,%al 2ef: b8 00 00 00 00 mov $0x0,%eax 2f4: 77 1f ja 315 <atoi+0x35> 2f6: 8d 76 00 lea 0x0(%esi),%esi 2f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 300: 8d 04 80 lea (%eax,%eax,4),%eax 303: 83 c1 01 add $0x1,%ecx 306: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 30a: 0f be 11 movsbl (%ecx),%edx 30d: 8d 5a d0 lea -0x30(%edx),%ebx 310: 80 fb 09 cmp $0x9,%bl 313: 76 eb jbe 300 <atoi+0x20> n = n*10 + *s++ - '0'; return n; } 315: 5b pop %ebx 316: 5d pop %ebp 317: c3 ret 318: 90 nop 319: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000320 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 320: 55 push %ebp 321: 89 e5 mov %esp,%ebp 323: 56 push %esi 324: 53 push %ebx 325: 8b 5d 10 mov 0x10(%ebp),%ebx 328: 8b 45 08 mov 0x8(%ebp),%eax 32b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 32e: 85 db test %ebx,%ebx 330: 7e 14 jle 346 <memmove+0x26> 332: 31 d2 xor %edx,%edx 334: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 338: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 33c: 88 0c 10 mov %cl,(%eax,%edx,1) 33f: 83 c2 01 add $0x1,%edx char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 342: 39 da cmp %ebx,%edx 344: 75 f2 jne 338 <memmove+0x18> *dst++ = *src++; return vdst; } 346: 5b pop %ebx 347: 5e pop %esi 348: 5d pop %ebp 349: c3 ret 0000034a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 34a: b8 01 00 00 00 mov $0x1,%eax 34f: cd 40 int $0x40 351: c3 ret 00000352 <exit>: SYSCALL(exit) 352: b8 02 00 00 00 mov $0x2,%eax 357: cd 40 int $0x40 359: c3 ret 0000035a <wait>: SYSCALL(wait) 35a: b8 03 00 00 00 mov $0x3,%eax 35f: cd 40 int $0x40 361: c3 ret 00000362 <pipe>: SYSCALL(pipe) 362: b8 04 00 00 00 mov $0x4,%eax 367: cd 40 int $0x40 369: c3 ret 0000036a <read>: SYSCALL(read) 36a: b8 05 00 00 00 mov $0x5,%eax 36f: cd 40 int $0x40 371: c3 ret 00000372 <write>: SYSCALL(write) 372: b8 10 00 00 00 mov $0x10,%eax 377: cd 40 int $0x40 379: c3 ret 0000037a <close>: SYSCALL(close) 37a: b8 15 00 00 00 mov $0x15,%eax 37f: cd 40 int $0x40 381: c3 ret 00000382 <kill>: SYSCALL(kill) 382: b8 06 00 00 00 mov $0x6,%eax 387: cd 40 int $0x40 389: c3 ret 0000038a <exec>: SYSCALL(exec) 38a: b8 07 00 00 00 mov $0x7,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <open>: SYSCALL(open) 392: b8 0f 00 00 00 mov $0xf,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <mknod>: SYSCALL(mknod) 39a: b8 11 00 00 00 mov $0x11,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <unlink>: SYSCALL(unlink) 3a2: b8 12 00 00 00 mov $0x12,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <fstat>: SYSCALL(fstat) 3aa: b8 08 00 00 00 mov $0x8,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <link>: SYSCALL(link) 3b2: b8 13 00 00 00 mov $0x13,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <mkdir>: SYSCALL(mkdir) 3ba: b8 14 00 00 00 mov $0x14,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <chdir>: SYSCALL(chdir) 3c2: b8 09 00 00 00 mov $0x9,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <dup>: SYSCALL(dup) 3ca: b8 0a 00 00 00 mov $0xa,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <getpid>: SYSCALL(getpid) 3d2: b8 0b 00 00 00 mov $0xb,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <sbrk>: SYSCALL(sbrk) 3da: b8 0c 00 00 00 mov $0xc,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <sleep>: SYSCALL(sleep) 3e2: b8 0d 00 00 00 mov $0xd,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <uptime>: SYSCALL(uptime) 3ea: b8 0e 00 00 00 mov $0xe,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <ps>: SYSCALL(ps) 3f2: b8 16 00 00 00 mov $0x16,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 3fa: 66 90 xchg %ax,%ax 3fc: 66 90 xchg %ax,%ax 3fe: 66 90 xchg %ax,%ax 00000400 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 400: 55 push %ebp 401: 89 e5 mov %esp,%ebp 403: 57 push %edi 404: 56 push %esi 405: 53 push %ebx 406: 89 c6 mov %eax,%esi 408: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 40b: 8b 5d 08 mov 0x8(%ebp),%ebx 40e: 85 db test %ebx,%ebx 410: 74 7e je 490 <printint+0x90> 412: 89 d0 mov %edx,%eax 414: c1 e8 1f shr $0x1f,%eax 417: 84 c0 test %al,%al 419: 74 75 je 490 <printint+0x90> neg = 1; x = -xx; 41b: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 41d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) x = -xx; 424: f7 d8 neg %eax 426: 89 75 c0 mov %esi,-0x40(%ebp) } else { x = xx; } i = 0; 429: 31 ff xor %edi,%edi 42b: 8d 5d d7 lea -0x29(%ebp),%ebx 42e: 89 ce mov %ecx,%esi 430: eb 08 jmp 43a <printint+0x3a> 432: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 438: 89 cf mov %ecx,%edi 43a: 31 d2 xor %edx,%edx 43c: 8d 4f 01 lea 0x1(%edi),%ecx 43f: f7 f6 div %esi 441: 0f b6 92 00 08 00 00 movzbl 0x800(%edx),%edx }while((x /= base) != 0); 448: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 44a: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 44d: 75 e9 jne 438 <printint+0x38> if(neg) 44f: 8b 45 c4 mov -0x3c(%ebp),%eax 452: 8b 75 c0 mov -0x40(%ebp),%esi 455: 85 c0 test %eax,%eax 457: 74 08 je 461 <printint+0x61> buf[i++] = '-'; 459: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 45e: 8d 4f 02 lea 0x2(%edi),%ecx 461: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi 465: 8d 76 00 lea 0x0(%esi),%esi 468: 0f b6 07 movzbl (%edi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 46b: 83 ec 04 sub $0x4,%esp 46e: 83 ef 01 sub $0x1,%edi 471: 6a 01 push $0x1 473: 53 push %ebx 474: 56 push %esi 475: 88 45 d7 mov %al,-0x29(%ebp) 478: e8 f5 fe ff ff call 372 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 47d: 83 c4 10 add $0x10,%esp 480: 39 df cmp %ebx,%edi 482: 75 e4 jne 468 <printint+0x68> putc(fd, buf[i]); } 484: 8d 65 f4 lea -0xc(%ebp),%esp 487: 5b pop %ebx 488: 5e pop %esi 489: 5f pop %edi 48a: 5d pop %ebp 48b: c3 ret 48c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 490: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 492: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 499: eb 8b jmp 426 <printint+0x26> 49b: 90 nop 49c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000004a0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4a0: 55 push %ebp 4a1: 89 e5 mov %esp,%ebp 4a3: 57 push %edi 4a4: 56 push %esi 4a5: 53 push %ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4a6: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4a9: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4ac: 8b 75 0c mov 0xc(%ebp),%esi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4af: 8b 7d 08 mov 0x8(%ebp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4b2: 89 45 d0 mov %eax,-0x30(%ebp) 4b5: 0f b6 1e movzbl (%esi),%ebx 4b8: 83 c6 01 add $0x1,%esi 4bb: 84 db test %bl,%bl 4bd: 0f 84 b0 00 00 00 je 573 <printf+0xd3> 4c3: 31 d2 xor %edx,%edx 4c5: eb 39 jmp 500 <printf+0x60> 4c7: 89 f6 mov %esi,%esi 4c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4d0: 83 f8 25 cmp $0x25,%eax 4d3: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 4d6: ba 25 00 00 00 mov $0x25,%edx state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 4db: 74 18 je 4f5 <printf+0x55> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4dd: 8d 45 e2 lea -0x1e(%ebp),%eax 4e0: 83 ec 04 sub $0x4,%esp 4e3: 88 5d e2 mov %bl,-0x1e(%ebp) 4e6: 6a 01 push $0x1 4e8: 50 push %eax 4e9: 57 push %edi 4ea: e8 83 fe ff ff call 372 <write> 4ef: 8b 55 d4 mov -0x2c(%ebp),%edx 4f2: 83 c4 10 add $0x10,%esp 4f5: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4f8: 0f b6 5e ff movzbl -0x1(%esi),%ebx 4fc: 84 db test %bl,%bl 4fe: 74 73 je 573 <printf+0xd3> c = fmt[i] & 0xff; if(state == 0){ 500: 85 d2 test %edx,%edx uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 502: 0f be cb movsbl %bl,%ecx 505: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 508: 74 c6 je 4d0 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 50a: 83 fa 25 cmp $0x25,%edx 50d: 75 e6 jne 4f5 <printf+0x55> if(c == 'd'){ 50f: 83 f8 64 cmp $0x64,%eax 512: 0f 84 f8 00 00 00 je 610 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 518: 81 e1 f7 00 00 00 and $0xf7,%ecx 51e: 83 f9 70 cmp $0x70,%ecx 521: 74 5d je 580 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 523: 83 f8 73 cmp $0x73,%eax 526: 0f 84 84 00 00 00 je 5b0 <printf+0x110> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 52c: 83 f8 63 cmp $0x63,%eax 52f: 0f 84 ea 00 00 00 je 61f <printf+0x17f> putc(fd, *ap); ap++; } else if(c == '%'){ 535: 83 f8 25 cmp $0x25,%eax 538: 0f 84 c2 00 00 00 je 600 <printf+0x160> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 53e: 8d 45 e7 lea -0x19(%ebp),%eax 541: 83 ec 04 sub $0x4,%esp 544: c6 45 e7 25 movb $0x25,-0x19(%ebp) 548: 6a 01 push $0x1 54a: 50 push %eax 54b: 57 push %edi 54c: e8 21 fe ff ff call 372 <write> 551: 83 c4 0c add $0xc,%esp 554: 8d 45 e6 lea -0x1a(%ebp),%eax 557: 88 5d e6 mov %bl,-0x1a(%ebp) 55a: 6a 01 push $0x1 55c: 50 push %eax 55d: 57 push %edi 55e: 83 c6 01 add $0x1,%esi 561: e8 0c fe ff ff call 372 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 566: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 56a: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 56d: 31 d2 xor %edx,%edx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 56f: 84 db test %bl,%bl 571: 75 8d jne 500 <printf+0x60> putc(fd, c); } state = 0; } } } 573: 8d 65 f4 lea -0xc(%ebp),%esp 576: 5b pop %ebx 577: 5e pop %esi 578: 5f pop %edi 579: 5d pop %ebp 57a: c3 ret 57b: 90 nop 57c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 580: 83 ec 0c sub $0xc,%esp 583: b9 10 00 00 00 mov $0x10,%ecx 588: 6a 00 push $0x0 58a: 8b 5d d0 mov -0x30(%ebp),%ebx 58d: 89 f8 mov %edi,%eax 58f: 8b 13 mov (%ebx),%edx 591: e8 6a fe ff ff call 400 <printint> ap++; 596: 89 d8 mov %ebx,%eax 598: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 59b: 31 d2 xor %edx,%edx if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 59d: 83 c0 04 add $0x4,%eax 5a0: 89 45 d0 mov %eax,-0x30(%ebp) 5a3: e9 4d ff ff ff jmp 4f5 <printf+0x55> 5a8: 90 nop 5a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 5b0: 8b 45 d0 mov -0x30(%ebp),%eax 5b3: 8b 18 mov (%eax),%ebx ap++; 5b5: 83 c0 04 add $0x4,%eax 5b8: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) s = "(null)"; 5bb: b8 f8 07 00 00 mov $0x7f8,%eax 5c0: 85 db test %ebx,%ebx 5c2: 0f 44 d8 cmove %eax,%ebx while(*s != 0){ 5c5: 0f b6 03 movzbl (%ebx),%eax 5c8: 84 c0 test %al,%al 5ca: 74 23 je 5ef <printf+0x14f> 5cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 5d0: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5d3: 8d 45 e3 lea -0x1d(%ebp),%eax 5d6: 83 ec 04 sub $0x4,%esp 5d9: 6a 01 push $0x1 ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 5db: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5de: 50 push %eax 5df: 57 push %edi 5e0: e8 8d fd ff ff call 372 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 5e5: 0f b6 03 movzbl (%ebx),%eax 5e8: 83 c4 10 add $0x10,%esp 5eb: 84 c0 test %al,%al 5ed: 75 e1 jne 5d0 <printf+0x130> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 5ef: 31 d2 xor %edx,%edx 5f1: e9 ff fe ff ff jmp 4f5 <printf+0x55> 5f6: 8d 76 00 lea 0x0(%esi),%esi 5f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 600: 83 ec 04 sub $0x4,%esp 603: 88 5d e5 mov %bl,-0x1b(%ebp) 606: 8d 45 e5 lea -0x1b(%ebp),%eax 609: 6a 01 push $0x1 60b: e9 4c ff ff ff jmp 55c <printf+0xbc> } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 610: 83 ec 0c sub $0xc,%esp 613: b9 0a 00 00 00 mov $0xa,%ecx 618: 6a 01 push $0x1 61a: e9 6b ff ff ff jmp 58a <printf+0xea> 61f: 8b 5d d0 mov -0x30(%ebp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 622: 83 ec 04 sub $0x4,%esp 625: 8b 03 mov (%ebx),%eax 627: 6a 01 push $0x1 629: 88 45 e4 mov %al,-0x1c(%ebp) 62c: 8d 45 e4 lea -0x1c(%ebp),%eax 62f: 50 push %eax 630: 57 push %edi 631: e8 3c fd ff ff call 372 <write> 636: e9 5b ff ff ff jmp 596 <printf+0xf6> 63b: 66 90 xchg %ax,%ax 63d: 66 90 xchg %ax,%ax 63f: 90 nop 00000640 <free>: static Header base; static Header *freep; void free(void *ap) { 640: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 641: a1 e0 0a 00 00 mov 0xae0,%eax static Header base; static Header *freep; void free(void *ap) { 646: 89 e5 mov %esp,%ebp 648: 57 push %edi 649: 56 push %esi 64a: 53 push %ebx 64b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 64e: 8b 10 mov (%eax),%edx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 650: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 653: 39 c8 cmp %ecx,%eax 655: 73 19 jae 670 <free+0x30> 657: 89 f6 mov %esi,%esi 659: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 660: 39 d1 cmp %edx,%ecx 662: 72 1c jb 680 <free+0x40> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 664: 39 d0 cmp %edx,%eax 666: 73 18 jae 680 <free+0x40> static Header base; static Header *freep; void free(void *ap) { 668: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 66a: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 66c: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 66e: 72 f0 jb 660 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 670: 39 d0 cmp %edx,%eax 672: 72 f4 jb 668 <free+0x28> 674: 39 d1 cmp %edx,%ecx 676: 73 f0 jae 668 <free+0x28> 678: 90 nop 679: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(bp + bp->s.size == p->s.ptr){ 680: 8b 73 fc mov -0x4(%ebx),%esi 683: 8d 3c f1 lea (%ecx,%esi,8),%edi 686: 39 d7 cmp %edx,%edi 688: 74 19 je 6a3 <free+0x63> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 68a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 68d: 8b 50 04 mov 0x4(%eax),%edx 690: 8d 34 d0 lea (%eax,%edx,8),%esi 693: 39 f1 cmp %esi,%ecx 695: 74 23 je 6ba <free+0x7a> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 697: 89 08 mov %ecx,(%eax) freep = p; 699: a3 e0 0a 00 00 mov %eax,0xae0 } 69e: 5b pop %ebx 69f: 5e pop %esi 6a0: 5f pop %edi 6a1: 5d pop %ebp 6a2: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 6a3: 03 72 04 add 0x4(%edx),%esi 6a6: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 6a9: 8b 10 mov (%eax),%edx 6ab: 8b 12 mov (%edx),%edx 6ad: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 6b0: 8b 50 04 mov 0x4(%eax),%edx 6b3: 8d 34 d0 lea (%eax,%edx,8),%esi 6b6: 39 f1 cmp %esi,%ecx 6b8: 75 dd jne 697 <free+0x57> p->s.size += bp->s.size; 6ba: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 6bd: a3 e0 0a 00 00 mov %eax,0xae0 bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 6c2: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 6c5: 8b 53 f8 mov -0x8(%ebx),%edx 6c8: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 6ca: 5b pop %ebx 6cb: 5e pop %esi 6cc: 5f pop %edi 6cd: 5d pop %ebp 6ce: c3 ret 6cf: 90 nop 000006d0 <malloc>: return freep; } void* malloc(uint nbytes) { 6d0: 55 push %ebp 6d1: 89 e5 mov %esp,%ebp 6d3: 57 push %edi 6d4: 56 push %esi 6d5: 53 push %ebx 6d6: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6d9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 6dc: 8b 15 e0 0a 00 00 mov 0xae0,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 6e2: 8d 78 07 lea 0x7(%eax),%edi 6e5: c1 ef 03 shr $0x3,%edi 6e8: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 6eb: 85 d2 test %edx,%edx 6ed: 0f 84 a3 00 00 00 je 796 <malloc+0xc6> 6f3: 8b 02 mov (%edx),%eax 6f5: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 6f8: 39 cf cmp %ecx,%edi 6fa: 76 74 jbe 770 <malloc+0xa0> 6fc: 81 ff 00 10 00 00 cmp $0x1000,%edi 702: be 00 10 00 00 mov $0x1000,%esi 707: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 70e: 0f 43 f7 cmovae %edi,%esi 711: ba 00 80 00 00 mov $0x8000,%edx 716: 81 ff ff 0f 00 00 cmp $0xfff,%edi 71c: 0f 46 da cmovbe %edx,%ebx 71f: eb 10 jmp 731 <malloc+0x61> 721: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 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){ 728: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 72a: 8b 48 04 mov 0x4(%eax),%ecx 72d: 39 cf cmp %ecx,%edi 72f: 76 3f jbe 770 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 731: 39 05 e0 0a 00 00 cmp %eax,0xae0 737: 89 c2 mov %eax,%edx 739: 75 ed jne 728 <malloc+0x58> char *p; Header *hp; if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); 73b: 83 ec 0c sub $0xc,%esp 73e: 53 push %ebx 73f: e8 96 fc ff ff call 3da <sbrk> if(p == (char*)-1) 744: 83 c4 10 add $0x10,%esp 747: 83 f8 ff cmp $0xffffffff,%eax 74a: 74 1c je 768 <malloc+0x98> return 0; hp = (Header*)p; hp->s.size = nu; 74c: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 74f: 83 ec 0c sub $0xc,%esp 752: 83 c0 08 add $0x8,%eax 755: 50 push %eax 756: e8 e5 fe ff ff call 640 <free> return freep; 75b: 8b 15 e0 0a 00 00 mov 0xae0,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 761: 83 c4 10 add $0x10,%esp 764: 85 d2 test %edx,%edx 766: 75 c0 jne 728 <malloc+0x58> return 0; 768: 31 c0 xor %eax,%eax 76a: eb 1c jmp 788 <malloc+0xb8> 76c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) 770: 39 cf cmp %ecx,%edi 772: 74 1c je 790 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 774: 29 f9 sub %edi,%ecx 776: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 779: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 77c: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 77f: 89 15 e0 0a 00 00 mov %edx,0xae0 return (void*)(p + 1); 785: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 788: 8d 65 f4 lea -0xc(%ebp),%esp 78b: 5b pop %ebx 78c: 5e pop %esi 78d: 5f pop %edi 78e: 5d pop %ebp 78f: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 790: 8b 08 mov (%eax),%ecx 792: 89 0a mov %ecx,(%edx) 794: eb e9 jmp 77f <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 796: c7 05 e0 0a 00 00 e4 movl $0xae4,0xae0 79d: 0a 00 00 7a0: c7 05 e4 0a 00 00 e4 movl $0xae4,0xae4 7a7: 0a 00 00 base.s.size = 0; 7aa: b8 e4 0a 00 00 mov $0xae4,%eax 7af: c7 05 e8 0a 00 00 00 movl $0x0,0xae8 7b6: 00 00 00 7b9: e9 3e ff ff ff jmp 6fc <malloc+0x2c>
INCLUDE "common.inc" SECTION "vblankInt", ROM0[$040] jp vblankInt SECTION "statInt", ROM0[$048] jp statInt SECTION "main", ROM0 start: ld a, [rLY] cp 145 jr nz, start ld a, 1 ld hl, $9000 REPT 7 ld [hl+], a inc hl ENDR ld a, $ff ld [hl+], a ld a, LCDCF_BGON | LCDCF_ON ld [rLCDC], a ld a, STATF_LYC ld [rSTAT], a ld a, IEF_LCDC | IEF_VBLANK ld [rIE], a xor a ld [rLYC], a ld c, low(rBGP) ei halt vblankInt: pop hl ei halt statInt: pop hl ei nop ld hl, data loop: REPT 10 ld a, [hl+] ld [c], a ENDR REPT 98 - 12 - 16 nop ENDR jp loop data: REPT 8 db $e4, $e4, $e4, $e4, $e4, $e4, $e4, $e4, $e4, $e4 ENDR REPT 16 db $e4, $e4, $aa, $aa, $aa, $aa, $aa, $aa, $e4, $e4 ENDR REPT 16 db $e4, $aa, $55, $55, $55, $55, $55, $55, $aa, $e4 ENDR REPT 16 db $e4, $aa, $55, $aa, $55, $55, $aa, $55, $aa, $e4 ENDR REPT 16 db $e4, $aa, $55, $55, $55, $55, $55, $55, $aa, $e4 ENDR REPT 8 db $e4, $aa, $55, $55, $55, $55, $55, $55, $aa, $e4 ENDR REPT 8 db $e4, $aa, $55, $aa, $55, $55, $aa, $55, $aa, $e4 ENDR REPT 8 db $e4, $aa, $55, $aa, $aa, $aa, $aa, $55, $aa, $e4 ENDR REPT 8 db $e4, $aa, $55, $55, $aa, $aa, $55, $55, $aa, $e4 ENDR REPT 16 db $e4, $aa, $55, $55, $55, $55, $55, $55, $aa, $e4 ENDR REPT 16 db $e4, $e4, $aa, $aa, $aa, $aa, $aa, $aa, $e4, $e4 ENDR REPT 16 db $e4, $e4, $e4, $e4, $e4, $e4, $e4, $e4, $e4, $e4 ENDR
; uint in_JoyKempston(void) ; 2002 aralbrec PUBLIC in_JoyKempston ; exit : HL = F000RLDU active high ; uses : AF,DE,HL .in_JoyKempston in a,($1f) and $1f ld e,a ld d,0 ld hl,kemptbl add hl,de ld l,(hl) ld h,d ret .kemptbl defb $00,$08,$04,$0c defb $02,$0a,$06,$0e defb $01,$09,$05,$0d defb $03,$0b,$07,$0f defb $80,$88,$84,$8c defb $82,$8a,$86,$8e defb $81,$89,$85,$8d defb $83,$8b,$87,$8f
#include "with_memory_logger.h" void count(int n) { if (!n--) return; LOG(INFO, "$n more", n, n); return count(n); } TEST_F(Sog, MacroFunc) { LOG(INFO, "Calling 3 times."); count(3); EXPECT_EQ(logger.take_pairs(), Pairs({ {"FILE", __FILE__}, {"LINE", 12}, {"FUNC", "virtual void Sog_MacroFunc_Test::TestBody()"}, {"MSG", "Calling 3 times."}})); EXPECT_EQ(logger.take_pairs(), Pairs({ {"FILE", __FILE__}, {"LINE", 7}, {"FUNC", "void count(int)"}, {"MSG", "$n more"}, {"n", 2}})); EXPECT_EQ(logger.take_pairs(), Pairs({ {"FILE", __FILE__}, {"LINE", 7}, {"FUNC", "void count(int)"}, {"MSG", "$n more"}, {"n", 1}})); EXPECT_EQ(logger.take_pairs(), Pairs({ {"FILE", __FILE__}, {"LINE", 7}, {"FUNC", "void count(int)"}, {"MSG", "$n more"}, {"n", 0}})); EXPECT_NO_LOG(); }
; A170285: Number of reduced words of length n in Coxeter group on 36 generators S_i with relations (S_i)^2 = (S_i S_j)^41 = I. ; 1,36,1260,44100,1543500,54022500,1890787500,66177562500,2316214687500,81067514062500,2837362992187500,99307704726562500,3475769665429687500,121651938290039062500,4257817840151367187500,149023624405297851562500 add $0,1 mov $3,1 lpb $0 sub $0,1 add $2,$3 div $3,$2 mul $2,35 lpe mov $0,$2 div $0,35
; A044837: Positive integers having more base-11 runs of even length than odd. ; 12,24,36,48,60,72,84,96,108,120,1452,1464,1476,1488,1500,1512,1524,1536,1548,1560,1572,2904,2916,2928,2940,2952,2964,2976,2988,3000,3012,3024,4356,4368,4380,4392,4404,4416,4428,4440 mov $2,$0 add $2,1 mov $5,$0 lpb $2 mov $0,$5 sub $2,1 sub $0,$2 add $0,1 mov $7,$0 lpb $0 mov $0,4 mov $3,$6 add $3,1 lpe add $3,9 gcd $7,$3 add $0,$7 mov $4,$0 div $4,10 mul $4,1320 add $4,12 add $1,$4 mov $6,1 lpe mov $0,$1
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r15 push %r8 push %rax push %rbp push %rdx // Load lea addresses_D+0x19c36, %rbp sub %r15, %r15 mov (%rbp), %rax nop nop nop nop nop inc %r8 // Store lea addresses_WT+0x361e, %r10 nop nop nop nop nop cmp $8333, %rdx mov $0x5152535455565758, %rbp movq %rbp, (%r10) nop nop nop nop dec %r15 // Store lea addresses_D+0x18f85, %rbp and $38834, %r11 movl $0x51525354, (%rbp) and $24243, %r8 // Faulty Load lea addresses_PSE+0x12b36, %r11 xor $55630, %r8 vmovaps (%r11), %ymm7 vextracti128 $1, %ymm7, %xmm7 vpextrq $1, %xmm7, %rdx lea oracles, %r15 and $0xff, %rdx shlq $12, %rdx mov (%r15,%rdx,1), %rdx pop %rdx pop %rbp pop %rax pop %r8 pop %r15 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D', 'same': False, 'size': 8, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WT', 'same': False, 'size': 8, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D', 'same': False, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_PSE', 'same': True, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} <gen_prepare_buffer> {'00': 113} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// Copyright (c) 2011-2018 The Readercoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <blockencodings.h> #include <consensus/merkle.h> #include <chainparams.h> #include <pow.h> #include <random.h> #include <test/test_readercoin.h> #include <boost/test/unit_test.hpp> std::vector<std::pair<uint256, CTransactionRef>> extra_txn; struct RegtestingSetup : public TestingSetup { RegtestingSetup() : TestingSetup(CBaseChainParams::REGTEST) {} }; BOOST_FIXTURE_TEST_SUITE(blockencodings_tests, RegtestingSetup) static CBlock BuildBlockTestCase() { CBlock block; CMutableTransaction tx; tx.vin.resize(1); tx.vin[0].scriptSig.resize(10); tx.vout.resize(1); tx.vout[0].nValue = 42; block.vtx.resize(3); block.vtx[0] = MakeTransactionRef(tx); block.nVersion = 42; block.hashPrevBlock = InsecureRand256(); block.nBits = 0x207fffff; tx.vin[0].prevout.hash = InsecureRand256(); tx.vin[0].prevout.n = 0; block.vtx[1] = MakeTransactionRef(tx); tx.vin.resize(10); for (size_t i = 0; i < tx.vin.size(); i++) { tx.vin[i].prevout.hash = InsecureRand256(); tx.vin[i].prevout.n = 0; } block.vtx[2] = MakeTransactionRef(tx); bool mutated; block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); assert(!mutated); while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce; return block; } // Number of shared use_counts we expect for a tx we haven't touched // (block + mempool + our copy from the GetSharedTx call) constexpr long SHARED_TX_OFFSET{3}; BOOST_AUTO_TEST_CASE(SimpleRoundTripTest) { CTxMemPool pool; TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); LOCK2(cs_main, pool.cs); pool.addUnchecked(entry.FromTx(block.vtx[2])); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); // Do a simple ShortTxIDs RT { CBlockHeaderAndShortTxIDs shortIDs(block, true); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; CBlockHeaderAndShortTxIDs shortIDs2; stream >> shortIDs2; PartiallyDownloadedBlock partialBlock(&pool); BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); BOOST_CHECK( partialBlock.IsTxAvailable(0)); BOOST_CHECK(!partialBlock.IsTxAvailable(1)); BOOST_CHECK( partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); size_t poolSize = pool.size(); pool.removeRecursive(*block.vtx[2]); BOOST_CHECK_EQUAL(pool.size(), poolSize - 1); CBlock block2; { PartiallyDownloadedBlock tmp = partialBlock; BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_INVALID); // No transactions partialBlock = tmp; } // Wrong transaction { PartiallyDownloadedBlock tmp = partialBlock; partialBlock.FillBlock(block2, {block.vtx[2]}); // Current implementation doesn't check txn here, but don't require that partialBlock = tmp; } bool mutated; BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated)); CBlock block3; BOOST_CHECK(partialBlock.FillBlock(block3, {block.vtx[1]}) == READ_STATUS_OK); BOOST_CHECK_EQUAL(block.GetHash().ToString(), block3.GetHash().ToString()); BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &mutated).ToString()); BOOST_CHECK(!mutated); } } class TestHeaderAndShortIDs { // Utility to encode custom CBlockHeaderAndShortTxIDs public: CBlockHeader header; uint64_t nonce; std::vector<uint64_t> shorttxids; std::vector<PrefilledTransaction> prefilledtxn; explicit TestHeaderAndShortIDs(const CBlockHeaderAndShortTxIDs& orig) { CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << orig; stream >> *this; } explicit TestHeaderAndShortIDs(const CBlock& block) : TestHeaderAndShortIDs(CBlockHeaderAndShortTxIDs(block, true)) {} uint64_t GetShortID(const uint256& txhash) const { CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << *this; CBlockHeaderAndShortTxIDs base; stream >> base; return base.GetShortID(txhash); } ADD_SERIALIZE_METHODS; template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(header); READWRITE(nonce); size_t shorttxids_size = shorttxids.size(); READWRITE(VARINT(shorttxids_size)); shorttxids.resize(shorttxids_size); for (size_t i = 0; i < shorttxids.size(); i++) { uint32_t lsb = shorttxids[i] & 0xffffffff; uint16_t msb = (shorttxids[i] >> 32) & 0xffff; READWRITE(lsb); READWRITE(msb); shorttxids[i] = (uint64_t(msb) << 32) | uint64_t(lsb); } READWRITE(prefilledtxn); } }; BOOST_AUTO_TEST_CASE(NonCoinbasePreforwardRTTest) { CTxMemPool pool; TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); LOCK2(cs_main, pool.cs); pool.addUnchecked(entry.FromTx(block.vtx[2])); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); uint256 txhash; // Test with pre-forwarding tx 1, but not coinbase { TestHeaderAndShortIDs shortIDs(block); shortIDs.prefilledtxn.resize(1); shortIDs.prefilledtxn[0] = {1, block.vtx[1]}; shortIDs.shorttxids.resize(2); shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[0]->GetHash()); shortIDs.shorttxids[1] = shortIDs.GetShortID(block.vtx[2]->GetHash()); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; CBlockHeaderAndShortTxIDs shortIDs2; stream >> shortIDs2; PartiallyDownloadedBlock partialBlock(&pool); BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); BOOST_CHECK(!partialBlock.IsTxAvailable(0)); BOOST_CHECK( partialBlock.IsTxAvailable(1)); BOOST_CHECK( partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); // +1 because of partialBlock CBlock block2; { PartiallyDownloadedBlock tmp = partialBlock; BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_INVALID); // No transactions partialBlock = tmp; } // Wrong transaction { PartiallyDownloadedBlock tmp = partialBlock; partialBlock.FillBlock(block2, {block.vtx[1]}); // Current implementation doesn't check txn here, but don't require that partialBlock = tmp; } BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 2); // +2 because of partialBlock and block2 bool mutated; BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated)); CBlock block3; PartiallyDownloadedBlock partialBlockCopy = partialBlock; BOOST_CHECK(partialBlock.FillBlock(block3, {block.vtx[0]}) == READ_STATUS_OK); BOOST_CHECK_EQUAL(block.GetHash().ToString(), block3.GetHash().ToString()); BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &mutated).ToString()); BOOST_CHECK(!mutated); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 3); // +2 because of partialBlock and block2 and block3 txhash = block.vtx[2]->GetHash(); block.vtx.clear(); block2.vtx.clear(); block3.vtx.clear(); BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1 - 1); // + 1 because of partialBlock; -1 because of block. } BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET - 1); // -1 because of block } BOOST_AUTO_TEST_CASE(SufficientPreforwardRTTest) { CTxMemPool pool; TestMemPoolEntryHelper entry; CBlock block(BuildBlockTestCase()); LOCK2(cs_main, pool.cs); pool.addUnchecked(entry.FromTx(block.vtx[1])); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 0); uint256 txhash; // Test with pre-forwarding coinbase + tx 2 with tx 1 in mempool { TestHeaderAndShortIDs shortIDs(block); shortIDs.prefilledtxn.resize(2); shortIDs.prefilledtxn[0] = {0, block.vtx[0]}; shortIDs.prefilledtxn[1] = {1, block.vtx[2]}; // id == 1 as it is 1 after index 1 shortIDs.shorttxids.resize(1); shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash()); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; CBlockHeaderAndShortTxIDs shortIDs2; stream >> shortIDs2; PartiallyDownloadedBlock partialBlock(&pool); BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); BOOST_CHECK( partialBlock.IsTxAvailable(0)); BOOST_CHECK( partialBlock.IsTxAvailable(1)); BOOST_CHECK( partialBlock.IsTxAvailable(2)); BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1); CBlock block2; PartiallyDownloadedBlock partialBlockCopy = partialBlock; BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_OK); BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString()); bool mutated; BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &mutated).ToString()); BOOST_CHECK(!mutated); txhash = block.vtx[1]->GetHash(); block.vtx.clear(); block2.vtx.clear(); BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET + 1 - 1); // + 1 because of partialBlock; -1 because of block. } BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_OFFSET - 1); // -1 because of block } BOOST_AUTO_TEST_CASE(EmptyBlockRoundTripTest) { CTxMemPool pool; CMutableTransaction coinbase; coinbase.vin.resize(1); coinbase.vin[0].scriptSig.resize(10); coinbase.vout.resize(1); coinbase.vout[0].nValue = 42; CBlock block; block.vtx.resize(1); block.vtx[0] = MakeTransactionRef(std::move(coinbase)); block.nVersion = 42; block.hashPrevBlock = InsecureRand256(); block.nBits = 0x207fffff; bool mutated; block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); assert(!mutated); while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++block.nNonce; // Test simple header round-trip with only coinbase { CBlockHeaderAndShortTxIDs shortIDs(block, false); CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << shortIDs; CBlockHeaderAndShortTxIDs shortIDs2; stream >> shortIDs2; PartiallyDownloadedBlock partialBlock(&pool); BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); BOOST_CHECK(partialBlock.IsTxAvailable(0)); CBlock block2; std::vector<CTransactionRef> vtx_missing; BOOST_CHECK(partialBlock.FillBlock(block2, vtx_missing) == READ_STATUS_OK); BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString()); BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &mutated).ToString()); BOOST_CHECK(!mutated); } } BOOST_AUTO_TEST_CASE(TransactionsRequestSerializationTest) { BlockTransactionsRequest req1; req1.blockhash = InsecureRand256(); req1.indexes.resize(4); req1.indexes[0] = 0; req1.indexes[1] = 1; req1.indexes[2] = 3; req1.indexes[3] = 4; CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << req1; BlockTransactionsRequest req2; stream >> req2; BOOST_CHECK_EQUAL(req1.blockhash.ToString(), req2.blockhash.ToString()); BOOST_CHECK_EQUAL(req1.indexes.size(), req2.indexes.size()); BOOST_CHECK_EQUAL(req1.indexes[0], req2.indexes[0]); BOOST_CHECK_EQUAL(req1.indexes[1], req2.indexes[1]); BOOST_CHECK_EQUAL(req1.indexes[2], req2.indexes[2]); BOOST_CHECK_EQUAL(req1.indexes[3], req2.indexes[3]); } BOOST_AUTO_TEST_CASE(TransactionsRequestDeserializationMaxTest) { // Check that the highest legal index is decoded correctly BlockTransactionsRequest req0; req0.blockhash = InsecureRand256(); req0.indexes.resize(1); req0.indexes[0] = 0xffff; CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << req0; BlockTransactionsRequest req1; stream >> req1; BOOST_CHECK_EQUAL(req0.indexes.size(), req1.indexes.size()); BOOST_CHECK_EQUAL(req0.indexes[0], req1.indexes[0]); } BOOST_AUTO_TEST_CASE(TransactionsRequestDeserializationOverflowTest) { // Any set of index deltas that starts with N values that sum to (0x10000 - N) // causes the edge-case overflow that was originally not checked for. Such // a request cannot be created by serializing a real BlockTransactionsRequest // due to the overflow, so here we'll serialize from raw deltas. BlockTransactionsRequest req0; req0.blockhash = InsecureRand256(); req0.indexes.resize(3); req0.indexes[0] = 0x7000; req0.indexes[1] = 0x10000 - 0x7000 - 2; req0.indexes[2] = 0; CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); stream << req0.blockhash; WriteCompactSize(stream, req0.indexes.size()); WriteCompactSize(stream, req0.indexes[0]); WriteCompactSize(stream, req0.indexes[1]); WriteCompactSize(stream, req0.indexes[2]); BlockTransactionsRequest req1; try { stream >> req1; // before patch: deserialize above succeeds and this check fails, demonstrating the overflow BOOST_CHECK(req1.indexes[1] < req1.indexes[2]); // this shouldn't be reachable before or after patch BOOST_CHECK(0); } catch(std::ios_base::failure &) { // deserialize should fail } } BOOST_AUTO_TEST_SUITE_END()
SECTION code_clib SECTION code_fp_math48 PUBLIC _modf_callee EXTERN cm48_sdcciy_modf_callee defc _modf_callee = cm48_sdcciy_modf_callee
; A218739: a(n) = (36^n-1)/35. ; 0,1,37,1333,47989,1727605,62193781,2238976117,80603140213,2901713047669,104461669716085,3760620109779061,135382323952046197,4873763662273663093,175455491841851871349,6316397706306667368565,227390317427040025268341,8186051427373440909660277,294697851385443872747769973,10609122649875979418919719029,381928415395535259081109885045,13749422954239269326919955861621,494979226352613695769118411018357,17819252148694093047688262796660853,641493077352987349716777460679790709 mov $1,36 pow $1,$0 div $1,35 mov $0,$1
; A073941: a(n) = ceiling((Sum_{k=1..n-1} a(k)) / 2) for n >= 2 starting with a(1) = 1. ; 1,1,1,2,3,4,6,9,14,21,31,47,70,105,158,237,355,533,799,1199,1798,2697,4046,6069,9103,13655,20482,30723,46085,69127,103691,155536,233304,349956,524934,787401,1181102,1771653,2657479,3986219,5979328,8968992,13453488,20180232,30270348,45405522,68108283,102162425,153243637,229865456,344798184,517197276,775795914,1163693871,1745540806,2618311209,3927466814,5891200221,8836800331,13255200497,19882800745,29824201118,44736301677,67104452515,100656678773,150985018159,226477527239,339716290858,509574436287,764361654431,1146542481646,1719813722469,2579720583704,3869580875556,5804371313334,8706556970001,13059835455001,19589753182502,29384629773753,44076944660629,66115416990944,99173125486416,148759688229624,223139532344436,334709298516654,502063947774981,753095921662471,1129643882493707,1694465823740560,2541698735610840,3812548103416260,5718822155124390,8578233232686585 mul $0,2 mov $1,13 lpb $0 sub $0,2 div $1,4 mul $1,6 lpe div $1,6 sub $1,3 div $1,3 add $1,1
global long_mode_start section .text bits 64 long_mode_start: ; load 0 into all data segment registers mov ax, 0 mov ss, ax mov ds, ax mov es, ax mov fs, ax mov gs, ax extern rust_main call rust_main .os_returned: ; rust main returned, print `OS returned!` mov rax, 0x4f724f204f534f4f mov [0xb8000], rax mov rax, 0x4f724f754f744f65 mov [0xb8008], rax mov rax, 0x4f214f644f654f6e mov [0xb8010], rax hlt
; A040870: Continued fraction for sqrt(901). ; 30,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60 pow $1,$0 gcd $1,2 mul $1,30