text
stringlengths
1
1.05M
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2018 The PaydayCoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. // NOTE: This file is intended to be customised by the end user, and includes only local node policy logic #include <policy/policy.h> #include <consensus/validation.h> #include <coins.h> // PAYDAYCOIN #include <services/assetconsensus.h> CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn) { // "Dust" is defined in terms of dustRelayFee, // which has units satoshis-per-kilobyte. // If you'd pay more in fees than the value of the output // to spend something, then we consider it dust. // A typical spendable non-segwit txout is 34 bytes big, and will // need a CTxIn of at least 148 bytes to spend: // so dust is a spendable txout less than // 182*dustRelayFee/1000 (in satoshis). // 546 satoshis at the default rate of 3000 sat/kB. // A typical spendable segwit txout is 31 bytes big, and will // need a CTxIn of at least 67 bytes to spend: // so dust is a spendable txout less than // 98*dustRelayFee/1000 (in satoshis). // 294 satoshis at the default rate of 3000 sat/kB. if (txout.scriptPubKey.IsUnspendable()) return 0; size_t nSize = GetSerializeSize(txout); int witnessversion = 0; std::vector<unsigned char> witnessprogram; if (txout.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) { // sum the sizes of the parts of a transaction input // with 75% segwit discount applied to the script size. nSize += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4); } else { nSize += (32 + 4 + 1 + 107 + 4); // the 148 mentioned above } return dustRelayFeeIn.GetFee(nSize); } bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFeeIn) { return (txout.nValue < GetDustThreshold(txout, dustRelayFeeIn)); } bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) { std::vector<std::vector<unsigned char> > vSolutions; whichType = Solver(scriptPubKey, vSolutions); if (whichType == TX_NONSTANDARD) { return false; } else if (whichType == TX_MULTISIG) { unsigned char m = vSolutions.front()[0]; unsigned char n = vSolutions.back()[0]; // Support up to x-of-3 multisig txns as standard if (n < 1 || n > 3) return false; if (m < 1 || m > n) return false; } else if (whichType == TX_NULL_DATA && (!fAcceptDatacarrier || scriptPubKey.size() > nMaxDatacarrierBytes * 200 )) { return false; } return true; } bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason) { if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) { reason = "version"; return false; } // Extremely large transactions with lots of inputs can cost the network // almost as much to process as they cost the sender in fees, because // computing signature hashes is O(ninputs*txsize). Limiting transactions // to MAX_STANDARD_TX_WEIGHT mitigates CPU exhaustion attacks. unsigned int sz = GetTransactionWeight(tx); if (sz > MAX_STANDARD_TX_WEIGHT) { reason = "tx-size"; return false; } for (const CTxIn& txin : tx.vin) { // Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed // keys (remember the 520 byte limit on redeemScript size). That works // out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 // bytes of scriptSig, which we round off to 1650 bytes for some minor // future-proofing. That's also enough to spend a 20-of-20 // CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not // considered standard. if (txin.scriptSig.size() > 1650) { reason = "scriptsig-size"; return false; } if (!txin.scriptSig.IsPushOnly()) { reason = "scriptsig-not-pushonly"; return false; } } unsigned int nDataOut = 0; txnouttype whichType; for (const CTxOut& txout : tx.vout) { if (!::IsStandard(txout.scriptPubKey, whichType)) { reason = "scriptpubkey"; return false; } if (whichType == TX_NULL_DATA){ // PAYDAYCOIN if not paydaycoin tx and opreturn size is bigger than maxcarrier bytes, return false // we need this because if it is a sys tx then we allow 200x maxcarrier bytes. if (!IsPaydayCoinTx(tx.nVersion) && txout.scriptPubKey.size() > nMaxDatacarrierBytes) { reason = "scriptpubkey"; return false; } nDataOut++; } else if ((whichType == TX_MULTISIG) && (!permit_bare_multisig)) { reason = "bare-multisig"; return false; } else if (IsDust(txout, dust_relay_fee)) { reason = "dust"; return false; } } // only one OP_RETURN txout is permitted if (nDataOut > 1) { reason = "multi-op-return"; return false; } return true; } /** * Check transaction inputs to mitigate two * potential denial-of-service attacks: * * 1. scriptSigs with extra data stuffed into them, * not consumed by scriptPubKey (or P2SH script) * 2. P2SH scripts with a crazy number of expensive * CHECKSIG/CHECKMULTISIG operations * * Why bother? To avoid denial-of-service attacks; an attacker * can submit a standard HASH... OP_EQUAL transaction, * which will get accepted into blocks. The redemption * script can be anything; an attacker could use a very * expensive-to-check-upon-redemption script like: * DUP CHECKSIG DROP ... repeated 100 times... OP_1 */ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) { if (tx.IsCoinBase()) return true; // Coinbases don't use vin normally for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out; std::vector<std::vector<unsigned char> > vSolutions; txnouttype whichType = Solver(prev.scriptPubKey, vSolutions); if (whichType == TX_NONSTANDARD) { return false; } else if (whichType == TX_SCRIPTHASH) { std::vector<std::vector<unsigned char> > stack; // convert the scriptSig into a stack, so we can inspect the redeemScript if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE)) return false; if (stack.empty()) return false; CScript subscript(stack.back().begin(), stack.back().end()); if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) { return false; } } } return true; } bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) { if (tx.IsCoinBase()) return true; // Coinbases are skipped for (unsigned int i = 0; i < tx.vin.size(); i++) { // We don't care if witness for this input is empty, since it must not be bloated. // If the script is invalid without witness, it would be caught sooner or later during validation. if (tx.vin[i].scriptWitness.IsNull()) continue; const CTxOut &prev = mapInputs.AccessCoin(tx.vin[i].prevout).out; // get the scriptPubKey corresponding to this input: CScript prevScript = prev.scriptPubKey; if (prevScript.IsPayToScriptHash()) { std::vector <std::vector<unsigned char> > stack; // If the scriptPubKey is P2SH, we try to extract the redeemScript casually by converting the scriptSig // into a stack. We do not check IsPushOnly nor compare the hash as these will be done later anyway. // If the check fails at this stage, we know that this txid must be a bad one. if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE)) return false; if (stack.empty()) return false; prevScript = CScript(stack.back().begin(), stack.back().end()); } int witnessversion = 0; std::vector<unsigned char> witnessprogram; // Non-witness program must not be associated with any witness if (!prevScript.IsWitnessProgram(witnessversion, witnessprogram)) return false; // Check P2WSH standard limits if (witnessversion == 0 && witnessprogram.size() == WITNESS_V0_SCRIPTHASH_SIZE) { if (tx.vin[i].scriptWitness.stack.back().size() > MAX_STANDARD_P2WSH_SCRIPT_SIZE) return false; size_t sizeWitnessStack = tx.vin[i].scriptWitness.stack.size() - 1; if (sizeWitnessStack > MAX_STANDARD_P2WSH_STACK_ITEMS) return false; for (unsigned int j = 0; j < sizeWitnessStack; j++) { if (tx.vin[i].scriptWitness.stack[j].size() > MAX_STANDARD_P2WSH_STACK_ITEM_SIZE) return false; } } } return true; } int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop) { return (std::max(nWeight, nSigOpCost * bytes_per_sigop) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR; } int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost, unsigned int bytes_per_sigop) { return GetVirtualTransactionSize(GetTransactionWeight(tx), nSigOpCost, bytes_per_sigop); } int64_t GetVirtualTransactionInputSize(const CTxIn& txin, int64_t nSigOpCost, unsigned int bytes_per_sigop) { return GetVirtualTransactionSize(GetTransactionInputWeight(txin), nSigOpCost, bytes_per_sigop); }
; A109313: Difference between prime factors of n-th semiprime. ; Submitted by Jamie Morken(w1) ; 0,1,0,3,5,2,4,9,0,11,8,15,2,17,10,21,0,14,6,16,27,29,8,20,35,4,39,12,41,26,6,28,45,14,51,34,18,57,10,0,59,38,40,12,65,44,69,2,24,71,26,77,50,16,81,0,56,87,58,32,6,95,64,99,22,36,101,8,68,105,38,24,107,70,4,111,42,76,6,80,12,125,30,129,48,86,135,137,34,0,94,54,147,10,36,149,98,56,100,155 seq $0,186621 ; Semiprimes - 1. seq $0,46665 ; Largest prime divisor of n - smallest prime divisor of n (a(1)=0).
#include "_glm.h" namespace autowig { } #if defined(_MSC_VER) #if (_MSC_VER == 1900) namespace boost { template <> class ::statiskit::glm::QuantitativeScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > const volatile * get_pointer<class ::statiskit::glm::QuantitativeScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > const volatile >(class ::statiskit::glm::QuantitativeScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > const volatile *c) { return c; } } #endif #endif void wrapper_d18675c1fb1c538391662efe54c9c111() { std::string name_fa414b05d29e5f4ea0b6d6cb5cf81b01 = boost::python::extract< std::string >(boost::python::scope().attr("__name__") + ".statiskit"); boost::python::object module_fa414b05d29e5f4ea0b6d6cb5cf81b01(boost::python::handle< >(boost::python::borrowed(PyImport_AddModule(name_fa414b05d29e5f4ea0b6d6cb5cf81b01.c_str())))); boost::python::scope().attr("statiskit") = module_fa414b05d29e5f4ea0b6d6cb5cf81b01; boost::python::scope scope_fa414b05d29e5f4ea0b6d6cb5cf81b01 = module_fa414b05d29e5f4ea0b6d6cb5cf81b01; std::string name_dfc470f00ed658a8838b0d698570f3bc = boost::python::extract< std::string >(boost::python::scope().attr("__name__") + ".glm"); boost::python::object module_dfc470f00ed658a8838b0d698570f3bc(boost::python::handle< >(boost::python::borrowed(PyImport_AddModule(name_dfc470f00ed658a8838b0d698570f3bc.c_str())))); boost::python::scope().attr("glm") = module_dfc470f00ed658a8838b0d698570f3bc; boost::python::scope scope_dfc470f00ed658a8838b0d698570f3bc = module_dfc470f00ed658a8838b0d698570f3bc; boost::python::class_< class ::statiskit::glm::QuantitativeScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation >, autowig::Held< class ::statiskit::glm::QuantitativeScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > >::Type, boost::python::bases< class ::statiskit::glm::ScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > > > class_d18675c1fb1c538391662efe54c9c111("_QuantitativeScalarRegressionFisherEstimation_d18675c1fb1c538391662efe54c9c111", "", boost::python::no_init); class_d18675c1fb1c538391662efe54c9c111.def(boost::python::init< >("")); class_d18675c1fb1c538391662efe54c9c111.def(boost::python::init< class ::statiskit::glm::PoissonRegression const *, class ::statiskit::UnivariateConditionalData const * >("")); class_d18675c1fb1c538391662efe54c9c111.def(boost::python::init< class ::statiskit::glm::QuantitativeScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > const & >("")); if(autowig::Held< class ::statiskit::glm::QuantitativeScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > >::is_class) { boost::python::implicitly_convertible< autowig::Held< class ::statiskit::glm::QuantitativeScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > >::Type, autowig::Held< class ::statiskit::glm::ScalarRegressionFisherEstimation< class ::statiskit::glm::PoissonRegression, struct ::statiskit::DiscreteUnivariateConditionalDistributionEstimation > >::Type >(); } }
/// @ref ext_vector_uint1 /// @file glm/ext/vector_uint1.hpp /// /// @defgroup ext_vector_uint1 GLM_EXT_vector_uint1 /// @ingroup ext /// /// Exposes uvec1 vector type. /// /// Include <glm/ext/vector_uvec1.hpp> to use the features of this extension. /// /// @see ext_vector_int1 extension. /// @see ext_vector_uint1_precision extension. #pragma once #include "../detail/type_vec1.hpp" #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED) # pragma message("GLM: GLM_EXT_vector_uint1 extension included") #endif namespace glm { /// @addtogroup ext_vector_uint1 /// @{ /// 1 component vector of unsigned integer numbers. typedef vec<1, unsigned int, defaultp> uvec1; /// @} }//namespace glm
; A033032: Numbers all of whose base 6 digits are odd. ; Submitted by Simon Strandgaard ; 1,3,5,7,9,11,19,21,23,31,33,35,43,45,47,55,57,59,67,69,71,115,117,119,127,129,131,139,141,143,187,189,191,199,201,203,211,213,215,259,261,263,271,273,275,283,285,287,331,333,335,343,345,347,355,357,359,403,405,407,415,417,419,427,429,431,691,693,695,703,705,707,715,717,719,763,765,767,775,777,779,787,789,791,835,837,839,847,849,851,859,861,863,1123,1125,1127,1135,1137,1139,1147 add $0,1 mov $2,1 lpb $0 mul $0,2 sub $0,1 mov $3,$0 div $0,6 mod $3,6 mul $3,$2 add $1,$3 mul $2,6 lpe mov $0,$1
// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/importer/firefox_profile_lock.h" #include "base/file_path.h" // This class is based on Firefox code in: // profile/dirserviceprovider/src/nsProfileLock.cpp // The license block is: /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (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.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 2002 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Conrad Carlen <[email protected]> * Brendan Eich <[email protected]> * Colin Blake <[email protected]> * Javier Pedemonte <[email protected]> * Mats Palmgren <[email protected]> * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ // static #if defined(OS_MACOSX) const FilePath::CharType* FirefoxProfileLock::kLockFileName = FILE_PATH_LITERAL(".parentlock"); const FilePath::CharType* FirefoxProfileLock::kOldLockFileName = FILE_PATH_LITERAL("parent.lock"); #elif defined(OS_POSIX) // http://www.google.com/codesearch/p?hl=en#e_ObwTAVPyo/profile/dirserviceprovider/src/nsProfileLock.cpp&l=433 const FilePath::CharType* FirefoxProfileLock::kLockFileName = FILE_PATH_LITERAL(".parentlock"); const FilePath::CharType* FirefoxProfileLock::kOldLockFileName = FILE_PATH_LITERAL("lock"); #else const FilePath::CharType* FirefoxProfileLock::kLockFileName = FILE_PATH_LITERAL("parent.lock"); #endif FirefoxProfileLock::FirefoxProfileLock(const FilePath& path) { Init(); lock_file_ = path.Append(kLockFileName); Lock(); } FirefoxProfileLock::~FirefoxProfileLock() { Unlock(); }
; A036581: Ternary Thue-Morse sequence: closed under a->abc, b->ac, c->b. ; 0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,0,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,1,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,0,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,1,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,0,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,1,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,0,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,1,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,0,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,2,1,2,0,1,0,2,1,2,0,2,1,0,1,2,0,1,0,2,1,0,1,2,0,2,1,2 cal $0,29883 ; First differences of Thue-Morse sequence A001285. mul $0,3 add $0,7 mov $3,$0 div $3,2 mov $0,$3 mov $2,14 div $2,$3 mod $0,$2 mul $0,2 mov $1,$0 sub $1,2 div $1,2
; ARRAY a DB 1H, 5H, 3H, 4H MOV AL, a[2]
// Copyright (c) 2007-2016 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #if !defined(HPX_PARALLEL_UTIL_LOOP_MAY_27_2014_1040PM) #define HPX_PARALLEL_UTIL_LOOP_MAY_27_2014_1040PM #include <hpx/config.hpp> #if defined(HPX_HAVE_DATAPAR) #include <hpx/parallel/datapar/loop.hpp> #endif #include <hpx/parallel/util/cancellation_token.hpp> #include <hpx/parallel/util/projection_identity.hpp> #include <hpx/traits/is_execution_policy.hpp> #include <hpx/util/assert.hpp> #include <hpx/util/invoke.hpp> #include <hpx/util/result_of.hpp> #include <hpx/util/tuple.hpp> #include <algorithm> #include <cstddef> #include <iterator> #include <type_traits> #include <utility> #include <vector> namespace hpx { namespace parallel { namespace util { /////////////////////////////////////////////////////////////////////////// template <typename ExPolicy, typename VecOnly, typename F, typename ... Iters> HPX_HOST_DEVICE HPX_FORCEINLINE typename std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, typename hpx::util::invoke_result<F, Iters...>::type >::type loop_step(VecOnly, F && f, Iters& ... its) { return hpx::util::invoke(std::forward<F>(f), (its++)...); } template <typename ExPolicy, typename Iter> HPX_HOST_DEVICE HPX_FORCEINLINE HPX_CONSTEXPR typename std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, bool >::type loop_optimization(Iter, Iter) { return false; } /////////////////////////////////////////////////////////////////////////// namespace detail { /////////////////////////////////////////////////////////////////////// // Helper class to repeatedly call a function starting from a given // iterator position. template <typename Iterator> struct loop { /////////////////////////////////////////////////////////////////// template <typename Begin, typename End, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE static Begin call(Begin it, End end, F && f) { for (/**/; it != end; ++it) f(it); return it; } template <typename Begin, typename End, typename CancelToken, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE static Begin call(Begin it, End end, CancelToken& tok, F && f) { for (/**/; it != end; ++it) { if (tok.was_cancelled()) break; f(it); } return it; } }; } template <typename ExPolicy, typename Begin, typename End, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE Begin loop(ExPolicy&&, Begin begin, End end, F && f) { return detail::loop<Begin>::call(begin, end, std::forward<F>(f)); } template <typename ExPolicy, typename Begin, typename End, typename CancelToken, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE Begin loop(ExPolicy&&, Begin begin, End end, CancelToken& tok, F && f) { return detail::loop<Begin>::call(begin, end, tok, std::forward<F>(f)); } /////////////////////////////////////////////////////////////////////////// namespace detail { /////////////////////////////////////////////////////////////////////// // Helper class to repeatedly call a function starting from a given // iterator position. template <typename Iter1, typename Iter2> struct loop2 { /////////////////////////////////////////////////////////////////// template <typename Begin1, typename End1, typename Begin2, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE static std::pair<Begin1, Begin2> call(Begin1 it1, End1 end1, Begin2 it2, F && f) { for (/**/; it1 != end1; (void) ++it1, ++it2) f(it1, it2); return std::make_pair(std::move(it1), std::move(it2)); } }; } template <typename ExPolicy, typename VecOnly, typename Begin1, typename End1, typename Begin2, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE typename std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, std::pair<Begin1, Begin2> >::type loop2(VecOnly, Begin1 begin1, End1 end1, Begin2 begin2, F && f) { return detail::loop2<Begin1, Begin2>::call(begin1, end1, begin2, std::forward<F>(f)); } /////////////////////////////////////////////////////////////////////////// namespace detail { // Helper class to repeatedly call a function a given number of times // starting from a given iterator position. template <typename Iterator> struct loop_n { /////////////////////////////////////////////////////////////////// // handle sequences of non-futures template <typename Iter, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE static Iter call(Iter it, std::size_t count, F && f) { for (/**/; count != 0; (void) --count, ++it) f(it); return it; } template <typename Iter, typename CancelToken, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE static Iter call(Iter it, std::size_t count, CancelToken& tok, F && f) { for (/**/; count != 0; (void) --count, ++it) { if (tok.was_cancelled()) break; f(it); } return it; } }; /////////////////////////////////////////////////////////////////////// template <typename ExPolicy, typename T> HPX_HOST_DEVICE HPX_FORCEINLINE typename std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, T const& >::type extract_value(T const& v) { return v; } template <typename ExPolicy, typename F, typename T> HPX_HOST_DEVICE HPX_FORCEINLINE typename std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, T const& >::type accumulate_values(F &&, T const& v) { return v; } template <typename ExPolicy, typename F, typename T, typename T1> HPX_HOST_DEVICE HPX_FORCEINLINE typename std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, T >::type accumulate_values(F && f, T && v, T1 && init) { return hpx::util::invoke(std::forward<F>(f), std::forward<T1>(init), std::forward<T>(v)); } } template <typename ExPolicy, typename Iter, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE typename std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, Iter >::type loop_n(Iter it, std::size_t count, F && f) { return detail::loop_n<Iter>::call(it, count, std::forward<F>(f)); } template <typename ExPolicy, typename Iter, typename CancelToken, typename F> HPX_HOST_DEVICE HPX_FORCEINLINE typename std::enable_if< !execution::is_vectorpack_execution_policy<ExPolicy>::value, Iter >::type loop_n(Iter it, std::size_t count, CancelToken& tok, F && f) { return detail::loop_n<Iter>::call(it, count, tok, std::forward<F>(f)); } /////////////////////////////////////////////////////////////////////////// // namespace detail // { // /////////////////////////////////////////////////////////////////////// // // Helper class to repeatedly call a function starting from a given // // iterator position. // template <typename Iter1, typename Iter2> // struct loop2_n // { // /////////////////////////////////////////////////////////////////// // template <typename Begin1, typename Begin2, typename F> // HPX_HOST_DEVICE HPX_FORCEINLINE // static std::pair<Begin1, Begin2> // call(Begin1 it1, std::size_t count, Begin2 it2, F && f) // { // for (/**/; count != 0; (void) ++it1, ++it2, --count) // f(it1, it2); // // return std::make_pair(it1, it2); // } // }; // } // // template <typename ExPolicy, typename Begin1, typename Begin2, typename F> // HPX_HOST_DEVICE HPX_FORCEINLINE std::pair<Begin1, Begin2> // loop2_n(ExPolicy&&, Begin1 begin1, std::size_t count, Begin2 begin2, F && f) // { // return detail::loop2_n<Begin1, Begin2>::call(begin1, count, begin2, // std::forward<F>(f)); // } /////////////////////////////////////////////////////////////////////////// namespace detail { // Helper class to repeatedly call a function a given number of times // starting from a given iterator position. If an exception is thrown, // the given cleanup function will be called. template <typename IterCat> struct loop_with_cleanup { /////////////////////////////////////////////////////////////////// template <typename FwdIter, typename F, typename Cleanup> static FwdIter call(FwdIter it, FwdIter last, F && f, Cleanup && cleanup) { FwdIter base = it; try { for (/**/; it != last; ++it) f(it); return it; } catch (...) { for (/**/; base != it; ++base) cleanup(base); throw; } } template <typename Iter, typename FwdIter, typename F, typename Cleanup> static FwdIter call(Iter it, Iter last, FwdIter dest, F && f, Cleanup && cleanup) { FwdIter base = dest; try { for (/**/; it != last; (void) ++it, ++dest) f(it, dest); return dest; } catch (...) { for (/**/; base != dest; ++base) cleanup(base); throw; } } }; } /////////////////////////////////////////////////////////////////////////// template <typename Iter, typename F, typename Cleanup> HPX_FORCEINLINE Iter loop_with_cleanup(Iter it, Iter last, F && f, Cleanup && cleanup) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::loop_with_cleanup<cat>::call(it, last, std::forward<F>(f), std::forward<Cleanup>(cleanup)); } template <typename Iter, typename FwdIter, typename F, typename Cleanup> HPX_FORCEINLINE FwdIter loop_with_cleanup(Iter it, Iter last, FwdIter dest, F && f, Cleanup && cleanup) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::loop_with_cleanup<cat>::call(it, last, dest, std::forward<F>(f), std::forward<Cleanup>(cleanup)); } /////////////////////////////////////////////////////////////////////////// namespace detail { // Helper class to repeatedly call a function a given number of times // starting from a given iterator position. template <typename IterCat> struct loop_with_cleanup_n { /////////////////////////////////////////////////////////////////// template <typename FwdIter, typename F, typename Cleanup> static FwdIter call(FwdIter it, std::size_t count, F && f, Cleanup && cleanup) { FwdIter base = it; try { for (/**/; count != 0; (void) --count, ++it) f(it); return it; } catch (...) { for (/**/; base != it; ++base) cleanup(base); throw; } } template <typename Iter, typename FwdIter, typename F, typename Cleanup> static FwdIter call(Iter it, std::size_t count, FwdIter dest, F && f, Cleanup && cleanup) { FwdIter base = dest; try { for (/**/; count != 0; (void) --count, ++it, ++dest) f(it, dest); return dest; } catch (...) { for (/**/; base != dest; ++base) cleanup(base); throw; } } /////////////////////////////////////////////////////////////////// template <typename FwdIter, typename CancelToken, typename F, typename Cleanup> static FwdIter call_with_token(FwdIter it, std::size_t count, CancelToken& tok, F && f, Cleanup && cleanup) { FwdIter base = it; try { for (/**/; count != 0; (void) --count, ++it) { if (tok.was_cancelled()) break; f(it); } return it; } catch (...) { tok.cancel(); for (/**/; base != it; ++base) cleanup(base); throw; } } template <typename Iter, typename FwdIter, typename CancelToken, typename F, typename Cleanup> static FwdIter call_with_token(Iter it, std::size_t count, FwdIter dest, CancelToken& tok, F && f, Cleanup && cleanup) { FwdIter base = dest; try { for (/**/; count != 0; (void) --count, ++it, ++dest) { if (tok.was_cancelled()) break; f(it, dest); } return dest; } catch (...) { tok.cancel(); for (/**/; base != dest; ++base) cleanup(base); throw; } } }; } /////////////////////////////////////////////////////////////////////////// template <typename Iter, typename F, typename Cleanup> HPX_FORCEINLINE Iter loop_with_cleanup_n(Iter it, std::size_t count, F && f, Cleanup && cleanup) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::loop_with_cleanup_n<cat>::call(it, count, std::forward<F>(f), std::forward<Cleanup>(cleanup)); } template <typename Iter, typename FwdIter, typename F, typename Cleanup> HPX_FORCEINLINE FwdIter loop_with_cleanup_n(Iter it, std::size_t count, FwdIter dest, F && f, Cleanup && cleanup) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::loop_with_cleanup_n<cat>::call(it, count, dest, std::forward<F>(f), std::forward<Cleanup>(cleanup)); } template <typename Iter, typename CancelToken, typename F, typename Cleanup> HPX_FORCEINLINE Iter loop_with_cleanup_n_with_token(Iter it, std::size_t count, CancelToken& tok, F && f, Cleanup && cleanup) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::loop_with_cleanup_n<cat>::call_with_token(it, count, tok, std::forward<F>(f), std::forward<Cleanup>(cleanup)); } template <typename Iter, typename FwdIter, typename CancelToken, typename F, typename Cleanup> HPX_FORCEINLINE FwdIter loop_with_cleanup_n_with_token(Iter it, std::size_t count, FwdIter dest, CancelToken& tok, F && f, Cleanup && cleanup) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::loop_with_cleanup_n<cat>::call_with_token(it, count, dest, tok, std::forward<F>(f), std::forward<Cleanup>(cleanup)); } /////////////////////////////////////////////////////////////////////////// namespace detail { // Helper class to repeatedly call a function a given number of times // starting from a given iterator position. template <typename IterCat> struct loop_idx_n { /////////////////////////////////////////////////////////////////// // handle sequences of non-futures template <typename Iter, typename F> static Iter call(std::size_t base_idx, Iter it, std::size_t count, F && f) { for (/**/; count != 0; (void) --count, ++it, ++base_idx) f(*it, base_idx); return it; } template <typename Iter, typename CancelToken, typename F> static Iter call(std::size_t base_idx, Iter it, std::size_t count, CancelToken& tok, F && f) { for (/**/; count != 0; (void) --count, ++it, ++base_idx) { if (tok.was_cancelled(base_idx)) break; f(*it, base_idx); } return it; } }; } /////////////////////////////////////////////////////////////////////////// template <typename Iter, typename F> HPX_FORCEINLINE Iter loop_idx_n(std::size_t base_idx, Iter it, std::size_t count, F && f) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::loop_idx_n<cat>::call(base_idx, it, count, std::forward<F>(f)); } template <typename Iter, typename CancelToken, typename F> HPX_FORCEINLINE Iter loop_idx_n(std::size_t base_idx, Iter it, std::size_t count, CancelToken& tok, F && f) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::loop_idx_n<cat>::call(base_idx, it, count, tok, std::forward<F>(f)); } /////////////////////////////////////////////////////////////////////////// namespace detail { // Helper class to repeatedly call a function a given number of times // starting from a given iterator position. template <typename IterCat> struct accumulate_n { template <typename Iter, typename T, typename Pred> static T call(Iter it, std::size_t count, T init, Pred && f) { for (/**/; count != 0; (void) --count, ++it) init = f(init, *it); return init; } }; } /////////////////////////////////////////////////////////////////////////// template <typename Iter, typename T, typename Pred> HPX_FORCEINLINE T accumulate_n(Iter it, std::size_t count, T init, Pred && f) { typedef typename std::iterator_traits<Iter>::iterator_category cat; return detail::accumulate_n<cat>::call(it, count, std::move(init), std::forward<Pred>(f)); } template <typename T, typename Iter, typename Reduce, typename Conv = util::projection_identity> HPX_FORCEINLINE T accumulate(Iter first, Iter last, Reduce && r, Conv && conv = Conv()) { T val = hpx::util::invoke(conv, *first); ++first; while(last != first) { val = hpx::util::invoke(r, val, *first); ++first; } return val; } template <typename T, typename Iter1, typename Iter2, typename Reduce, typename Conv> HPX_FORCEINLINE T accumulate(Iter1 first1, Iter1 last1, Iter2 first2, Reduce && r, Conv && conv) { T val = hpx::util::invoke(conv, *first1, *first2); ++first1; ++first2; while(last1 != first1) { val = hpx::util::invoke(r, val, hpx::util::invoke(conv, *first1, *first2)); ++first1; ++first2; } return val; } }}} #endif
; A017152: a(n) = (8*n + 7)^4. ; 2401,50625,279841,923521,2313441,4879681,9150625,15752961,25411681,38950081,57289761,81450625,112550881,151807041,200533921,260144641,332150625,418161601,519885601,639128961,777796321,937890625,1121513121,1330863361,1568239201,1836036801,2136750625,2472973441,2847396321,3262808641,3722098081,4228250625,4784350561,5393580481,6059221281,6784652161,7573350625,8428892481,9354951841,10355301121,11433811041,12594450625,13841287201,15178486401,16610312161,18141126721,19775390625,21517662721,23372600161,25344958401,27439591201,29661450625,32015587041,34507149121,37141383841,39923636481,42859350625,45954068161,49213429281,52643172481,56249134561,60037250625,64013554081,68184176641,72555348321,77133397441,81924750625,86935932801,92173567201,97644375361,103355177121,109312890625,115524532321,121997216961,128738157601,135754665601,143054150625,150644120641,158532181921,166726039041,175233494881,184062450625,193220905761,202716958081,212558803681,222754736961,233313150625,244242535681,255551481441,267248675521,279342903841,291843050625,304758098401,318097128001,331869318561,346083947521,360750390625,375878121921,391476713761,407555836801,424125260001,441194850625,458774574241,476874494721,495504774241,514675673281,534397550625,554680863361,575536166881,596974114881,619005459361,641641050625,664891837281,688768866241,713283282721,738446330241,764269350625,790763784001,817941168801,845813141761,874391437921,903687890625,933714431521,964483090561,996005996001,1028295374401,1061363550625,1095222947841,1129886087521,1165365589441,1201674171681,1238824650625,1276829940961,1315703055681,1355457106081,1396105301761,1437660950625,1480137458881,1523548331041,1567907169921,1613227676641,1659523650625,1706808989601,1755097689601,1804403844961,1854741648321,1906125390625,1958569461121,2012088347361,2066696635201,2122409008801,2179240250625,2237205241441,2296318960321,2356596484641,2418052990081,2480703750625,2544564138561,2609649624481,2675975777281,2743558264161,2812412850625,2882555400481,2954001875841,3026768337121,3100870943041,3176325950625,3253149715201,3331358690401,3410969428161,3491998578721,3574462890625,3658379210721,3743764484161,3830635754401,3919010163201,4008904950625,4100337455041,4193325113121,4287885459841,4384036128481,4481794850625,4581179456161,4682207873281,4784898128481,4889268346561,4995336750625,5103121662081,5212641500641,5323914784321,5436960129441,5551796250625,5668441960801,5786916171201,5907237891361,6029426229121,6153500390625,6279479680321,6407383500961,6537231353601,6669042837601,6802837650625,6938635588641,7076456545921,7216320515041,7358247586881,7502257950625,7648371893761,7796609802081,7946992159681,8099539548961,8254272650625,8411212243681,8570379205441,8731794511521,8895479235841,9061454550625,9229741726401,9400362132001,9573337234561,9748688599521,9926437890625,10106606869921,10289217397761,10474291432801,10661851032001,10851918350625,11044515642241,11239665258721,11437389650241,11637711365281,11840653050625,12046237451361,12254487410881,12465425870881,12679075871361,12895460550625,13114603145281,13336526990241,13561255518721,13788812262241,14019220850625,14252505012001,14488688572801,14727795457761,14969849689921,15214875390625,15462896779521,15713938174561,15968023992001 mov $1,8 mul $1,$0 add $1,7 pow $1,4
; int vasprintf_callee(char **ptr, const char *format, void *arg) SECTION code_clib SECTION code_stdio PUBLIC _vasprintf_callee EXTERN asm_vasprintf _vasprintf_callee: pop af exx pop de exx pop de pop bc push af jp asm_vasprintf
; size_t getline_unlocked_callee(char **lineptr, size_t *n, FILE *stream) SECTION code_stdio PUBLIC _getline_unlocked_callee, l0_getline_unlocked_callee EXTERN asm_getline_unlocked _getline_unlocked_callee: pop af pop hl pop de pop bc push af l0_getline_unlocked_callee: push bc ex (sp),ix call asm_getline_unlocked pop ix ret
# # swap x and y using xor # .data please_x: .string "Please, input integer x: " please_y: .string "Please, input integer y: " x_old: .string "\nSwapping x and y:\n...\ninitial x value is: " y_old: .string "\ninitial y value is: " x_new: .string "\n...\nnew value of x is : " y_new: .string "\nnew value of y is : " complete: .string "\n...\nswap is complete!\n" .text main: #as we know the following order of operation swaps x and y: #x = x xor y; y = x xor y; x = x xor y; li a7, 4 la a0, please_x ecall #x.input() li a7, 5 ecall add t0, zero, a0 li a7, 4 la a0, please_y ecall #y.input() li a7, 5 ecall add t1, zero, a0 li a7, 4 la a0, x_old ecall li a7, 1 add a0, zero, t0 ecall li a7, 4 la a0, y_old ecall li a7, 1 add a0, zero, t1 ecall xor t0, t0, t1 xor t1, t0, t1 xor t0, t0, t1 li a7, 4 la a0, x_new ecall li a7, 1 add a0, zero, t0 ecall li a7, 4 la a0, y_new ecall li a7, 1 add a0, zero, t1 ecall li a7, 4 la a0, complete ecall
MODULE UtilsText ;; By Kevin Thacker from http://cpctech.cpc-live.com/source/sixpix.asm ;; each char is 6 mode 1 pixels wide and 8 mode 1 pixels tall ;; in mode 1, each byte uses 4 pixels ;; so this means that each char uses 2 bytes, with the last 2 pixels of each line are unused. ;; this is done for simplicity. ;; ;; this means each char is 2 bytes wide and 8 bytes tall ;; to work out screen address to draw char to ;; ;; byte 0 byte 2 byte 3 byte 4 byte 5 ;; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ;; first char uses pixels 0,1,2,3,4,5 ;; second char uses pixels 6,7,8,9,10,11 ;; third char uses 12,13,14,15, 16, 17 ;; even/odd x coord @ScreenCharsWidth equ 53 ;; IN: A character to print. ;; Location: txt_x and txt_y @PrintChar: push af push bc ;; x coord, remove bit 0, and multiply by 3 ;; 0->0 ;; 1->0 ;; 2->3 ;; 3->3 ;; 4->6 ;; 5->6 ;; 6->9 ld a, (txt_x) srl a ld c,a add a,a ;; x2 add a,c ;; x3 ld c,a ld a, (txt_x) and 1 add a, c ld (txt_byte_x), a ld a, (txt_x) and 1 ld (txt_right), a ;; l == pixel row == text row * 8 ld a, (txt_y) add a, a add a, a add a, a ld (txt_pixels_y), a pop bc pop af jr PrintCharWithPixels ;; Jump and return from there @PrintCharWithPixels: push hl push de push bc IFDEF UpperROMBuild ; Disable upper ROM so we can read from the screen ld bc, #7F00 + %10001101 out (c),c ENDIF ;; work out location of pixel data ;; 1 bit per pixel font used here sub ' ' ld l,a ld h,0 add hl,hl add hl,hl add hl,hl ld de,font add hl,de ;; convert from 1 bit per pixel to 2 bit per pixel call depack_char ld a, (txt_byte_x) ld h, a ld a, (txt_pixels_y) ld l, a call GetScreenAddress ;; now display char in appropiate location ld de,char_depack_buffer ex de,hl call display_char2 ;; increment text coord position ld hl, txt_x inc (hl) ld a, (txt_right) inc a and 1 ld (txt_right), a ld hl, txt_byte_x inc (hl) or a jr nz, .sameByteGroup inc (hl) .sameByteGroup: IFDEF UpperROMBuild ld bc, RESTORE_ROM_CONFIG out (c),c ENDIF pop bc pop de pop hl ret display_char2: ld a,(txt_right) or a jp nz,display_char_odd jp display_char_even @NewLine: ld hl,(TxtCoords) inc l ld h,0 ld (TxtCoords),hl ret ;; set foreground and background colours @SetTxtColors: ld a,h ld (bk_color),a ld a,l ld (fg_color),a ret ;; convert 1-bit per pixel into 2 bit per pixel depack_char: ld b,8 ld de,char_depack_buffer depack_char2: push bc ld c,(hl) call depack_byte call depack_byte inc hl pop bc djnz depack_char2 ret ;; take 4x 1 bit per pixel from one byte and write out 4 2-bit per pixels to one byte depack_byte: xor a push de call depack_pixel call depack_pixel call depack_pixel call depack_pixel pop de ld (de),a inc de ret depack_pixel: call depack_pix or b rlca ret depack_pix: ;; shift into carry rlc c ld d, a ld a, (bk_color) ld b, a ld a, d ret nc ld d, a ld a, (fg_color) ld b, a ld a, d ret scr_NewLine: ld a,h add a,8 ld h,a ret nc ld a,l add a,#50 ld l,a ld a,h adc a,#c0 ld h,a ret ;; IN: H - x in bytes ;; L - y in pixels ;; OUT: HL screen address GetScreenAddress: push bc push de ld c, h ld h, 0 add hl, hl ld de, scr_table add hl, de ld a, (hl) inc hl ld h, (hl) ld l, a ld b, 0 add hl,bc pop de pop bc ret @MakeScrTable: ld ix,scr_table ld hl,#c000 ld b,200 mst1: ld (ix+0),l ld (ix+1),h inc ix inc ix call scr_NewLine djnz mst1 ret ;; in this example B is the odd char ;; on screen: ;; ;; aaaa aabb bbbb ;; 0 1 2 ;; ;; pixels from char: ;; bbbb bb display_char_odd: ld b,8 dco1: push bc push de ;; read 4 pixels from screen ;; keep left 2 pixels ld a,(de) and %11001100 ld c,a ;; read font data ;; shift data two pixels to right ld a,(hl) rrca rrca and %00110011 ;; combine with screen or c ld (de),a inc de ld a,(hl) rlca rlca and %11001100 ld c,a inc hl ld a,(hl) rrca rrca and %00110011 or c ld (de),a inc hl pop de ex de,hl call scr_NewLine ex de,hl pop bc djnz dco1 ret ;; in this example A is the even char ;; on screen: ;; ;; aaaa aabb bbbb ;; 0 1 2 ;; ;; pixels from char: ;; aaaa aa display_char_even: ld b,8 dce1: push bc push de ;; read 4 pixels ld a,(hl) ;; store to screen ld (de),a inc de inc hl ;; read 4 pixels from screen ld a,(de) ;; isolate the pixels we don't want to change and %00110011 ld c,a ;; now read 4 pixels from font ld a,(hl) ;; isolate pixels we want and %11001100 ;; combine with screen data or c ;; write back to screen ld (de),a ;;inc de inc hl pop de ex de,hl call scr_NewLine ex de,hl pop bc djnz dce1 ret INCLUDE "Font.asm" ENDMODULE
; ; Generic pseudo graphics routines for text-only platforms ; ; Reset pixel at (x,y) coordinate. SECTION code_graphics PUBLIC c_respixel defc NEEDunplot = 1 .c_respixel INCLUDE "w_c_pixel.inc"
;; ;; Copyright (c) 2012-2018, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %define AES_CBC_ENC_X4 aes_cbc_enc_192_x4 %define FLUSH_JOB_AES_ENC flush_job_aes192_enc_sse %include "mb_mgr_aes_flush_sse.asm"
;; ;; Copyright (c) 2018-2020, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %include "include/os.asm" %include "job_aes_hmac.asm" %include "mb_mgr_datastruct.asm" %include "include/reg_sizes.asm" %include "include/memcpy.asm" %include "include/const.inc" ;%define DO_DBGPRINT %include "include/dbgprint.asm" %ifndef NUM_LANES %define NUM_LANES 4 %endif %ifndef AES128_CBC_MAC %define AES128_CBC_MAC aes128_cbc_mac_x4 %define SUBMIT_JOB_AES_CMAC_AUTH submit_job_aes_cmac_auth_sse %define FLUSH_JOB_AES_CMAC_AUTH flush_job_aes_cmac_auth_sse %endif extern AES128_CBC_MAC section .data default rel align 16 len_masks: dq 0x000000000000FFFF, 0x0000000000000000 dq 0x00000000FFFF0000, 0x0000000000000000 dq 0x0000FFFF00000000, 0x0000000000000000 dq 0xFFFF000000000000, 0x0000000000000000 %if NUM_LANES > 4 dq 0x0000000000000000, 0x000000000000FFFF dq 0x0000000000000000, 0x00000000FFFF0000 dq 0x0000000000000000, 0x0000FFFF00000000 dq 0x0000000000000000, 0xFFFF000000000000 %endif %if NUM_LANES > 4 align 16 dupw: dq 0x0100010001000100, 0x0100010001000100 %endif one: dq 1 two: dq 2 three: dq 3 %if NUM_LANES > 4 four: dq 4 five: dq 5 six: dq 6 seven: dq 7 %endif section .text %define APPEND(a,b) a %+ b %ifdef LINUX %define arg1 rdi %define arg2 rsi %else %define arg1 rcx %define arg2 rdx %endif %define state arg1 %define job arg2 %define len2 arg2 %define job_rax rax ; idx needs to be in rbp %define len rbp %define idx rbp %define tmp rbp %define lane r8 %define iv r9 %define m_last r10 %define n r11 %define unused_lanes rbx %define r rbx %define tmp3 r12 %define tmp4 r13 %define tmp2 r14 %define good_lane r15 %define rbits r15 ; STACK_SPACE needs to be an odd multiple of 8 ; This routine and its callee clobbers all GPRs struc STACK _gpr_save: resq 8 _rsp_save: resq 1 endstruc ;;; =========================================================================== ;;; =========================================================================== ;;; MACROS ;;; =========================================================================== ;;; =========================================================================== ;;; =========================================================================== ;;; AES CMAC job submit & flush ;;; =========================================================================== ;;; SUBMIT_FLUSH [in] - SUBMIT, FLUSH job selection %macro GENERIC_SUBMIT_FLUSH_JOB_AES_CMAC_SSE 1 %define %%SUBMIT_FLUSH %1 mov rax, rsp sub rsp, STACK_size and rsp, -16 mov [rsp + _gpr_save + 8*0], rbx mov [rsp + _gpr_save + 8*1], rbp mov [rsp + _gpr_save + 8*2], r12 mov [rsp + _gpr_save + 8*3], r13 mov [rsp + _gpr_save + 8*4], r14 mov [rsp + _gpr_save + 8*5], r15 %ifndef LINUX mov [rsp + _gpr_save + 8*6], rsi mov [rsp + _gpr_save + 8*7], rdi %endif mov [rsp + _rsp_save], rax ; original SP ;; Find free lane mov unused_lanes, [state + _aes_cmac_unused_lanes] %ifidn %%SUBMIT_FLUSH, SUBMIT mov lane, unused_lanes and lane, 0xF shr unused_lanes, 4 mov [state + _aes_cmac_unused_lanes], unused_lanes ;; Copy job info into lane mov [state + _aes_cmac_job_in_lane + lane*8], job ;; Copy keys into lane args mov tmp, [job + _key_expanded] mov [state + _aes_cmac_args_keys + lane*8], tmp mov tmp, lane shl tmp, 4 ; lane*16 ;; Zero IV to store digest pxor xmm0, xmm0 movdqa [state + _aes_cmac_args_IV + tmp], xmm0 lea m_last, [state + _aes_cmac_scratch + tmp] ;; calculate len ;; convert bits to bytes (message length in bits for CMAC) mov len, [job + _msg_len_to_hash_in_bits] mov rbits, len add len, 7 ; inc len if there are remainder bits shr len, 3 and rbits, 7 ;; Check at least 1 or more blocks (get n) mov n, len add n, 0xf shr n, 4 ;; Check for partial block mov r, len and r, 0xf or n, n ; check one or more blocks? jz %%_lt_one_block ;; One or more blocks, potentially partial mov word [state + _aes_cmac_init_done + lane*2], 0 mov tmp2, [job + _src] add tmp2, [job + _hash_start_src_offset_in_bytes] mov [state + _aes_cmac_args_in + lane*8], tmp2 ;; len = (n-1)*16 lea tmp2, [n - 1] shl tmp2, 4 movdqa xmm0, [state + _aes_cmac_lens] XPINSRW xmm0, xmm1, tmp, lane, tmp2, scale_x16 movdqa [state + _aes_cmac_lens], xmm0 ;; check remainder bits or rbits, rbits jnz %%_not_complete_block_3gpp ;; check if complete block or r, r jz %%_complete_block %%_not_complete_block: ;; M_last = padding(M_n) XOR K2 lea tmp, [rel padding_0x80_tab16 + 16] sub tmp, r movdqu xmm0, [tmp] movdqa [m_last], xmm0 mov tmp, [job + _src] add tmp, [job + _hash_start_src_offset_in_bytes] lea tmp3, [n - 1] shl tmp3, 4 add tmp, tmp3 memcpy_sse_16 m_last, tmp, r, tmp4, iv ;; src + n + r mov tmp3, [job + _skey2] movdqa xmm1, [m_last] movdqu xmm0, [tmp3] pxor xmm0, xmm1 movdqa [m_last], xmm0 %%_step_5: ;; Find min length movdqa xmm0, [state + _aes_cmac_lens] phminposuw xmm1, xmm0 cmp byte [state + _aes_cmac_unused_lanes], 0xf jne %%_return_null %else ; end SUBMIT ;; Check at least one job bt unused_lanes, ((NUM_LANES * 4) + 3) jc %%_return_null ;; Find a lane with a non-null job xor good_lane, good_lane cmp qword [state + _aes_cmac_job_in_lane + 1*8], 0 cmovne good_lane, [rel one] cmp qword [state + _aes_cmac_job_in_lane + 2*8], 0 cmovne good_lane, [rel two] cmp qword [state + _aes_cmac_job_in_lane + 3*8], 0 cmovne good_lane, [rel three] %if NUM_LANES > 4 cmp qword [state + _aes_cmac_job_in_lane + 4*8], 0 cmovne good_lane, [rel four] cmp qword [state + _aes_cmac_job_in_lane + 5*8], 0 cmovne good_lane, [rel five] cmp qword [state + _aes_cmac_job_in_lane + 6*8], 0 cmovne good_lane, [rel six] cmp qword [state + _aes_cmac_job_in_lane + 7*8], 0 cmovne good_lane, [rel seven] %endif ; Copy good_lane to empty lanes mov tmp2, [state + _aes_cmac_args_in + good_lane*8] mov tmp3, [state + _aes_cmac_args_keys + good_lane*8] shl good_lane, 4 ; multiply by 16 movdqa xmm2, [state + _aes_cmac_args_IV + good_lane] movdqa xmm0, [state + _aes_cmac_lens] %assign I 0 %rep NUM_LANES cmp qword [state + _aes_cmac_job_in_lane + I*8], 0 jne APPEND(skip_,I) mov [state + _aes_cmac_args_in + I*8], tmp2 mov [state + _aes_cmac_args_keys + I*8], tmp3 movdqa [state + _aes_cmac_args_IV + I*16], xmm2 por xmm0, [rel len_masks + 16*I] APPEND(skip_,I): %assign I (I+1) %endrep ;; Find min length phminposuw xmm1, xmm0 %endif ; end FLUSH %%_cmac_round: pextrw len2, xmm1, 0 ; min value pextrw idx, xmm1, 1 ; min index (0...3) or len2, len2 je %%_len_is_0 %if NUM_LANES > 4 pshufb xmm1, [rel dupw] ; duplicate words across all lanes %else pshuflw xmm1, xmm1, 0 %endif psubw xmm0, xmm1 movdqa [state + _aes_cmac_lens], xmm0 ; "state" and "args" are the same address, arg1 ; len2 is arg2 call AES128_CBC_MAC ; state and idx are intact movdqa xmm0, [state + _aes_cmac_lens] ; preload lens %%_len_is_0: ; Check if job complete test word [state + _aes_cmac_init_done + idx*2], 0xffff jnz %%_copy_complete_digest ; Finish step 6 mov word [state + _aes_cmac_init_done + idx*2], 1 XPINSRW xmm0, xmm1, tmp3, idx, 16, scale_x16 movdqa [state + _aes_cmac_lens], xmm0 phminposuw xmm1, xmm0 ; find min length mov tmp3, idx shl tmp3, 4 ; idx*16 lea m_last, [state + _aes_cmac_scratch + tmp3] mov [state + _aes_cmac_args_in + idx*8], m_last jmp %%_cmac_round %%_copy_complete_digest: ; Job complete, copy digest to AT output mov job_rax, [state + _aes_cmac_job_in_lane + idx*8] mov tmp4, idx shl tmp4, 4 lea tmp3, [state + _aes_cmac_args_IV + tmp4] mov tmp4, [job_rax + _auth_tag_output_len_in_bytes] mov tmp2, [job_rax + _auth_tag_output] cmp tmp4, 16 jne %%_ne_16_copy ;; 16 byte AT copy movdqu xmm0, [tmp3] movdqu [tmp2], xmm0 jmp %%_update_lanes %%_ne_16_copy: memcpy_sse_16 tmp2, tmp3, tmp4, lane, iv %%_update_lanes: ; Update unused lanes mov unused_lanes, [state + _aes_cmac_unused_lanes] shl unused_lanes, 4 or unused_lanes, idx mov [state + _aes_cmac_unused_lanes], unused_lanes ; Set return job mov job_rax, [state + _aes_cmac_job_in_lane + idx*8] mov qword [state + _aes_cmac_job_in_lane + idx*8], 0 or dword [job_rax + _status], STS_COMPLETED_HMAC %ifdef SAFE_DATA pxor xmm0, xmm0 %ifidn %%SUBMIT_FLUSH, SUBMIT ;; Clear digest (in memory for IV) and scratch memory of returned job movdqa [tmp3], xmm0 shl idx, 4 movdqa [state + _aes_cmac_scratch + idx], xmm0 %else ;; Clear digest and scratch memory of returned job and "NULL lanes" %assign I 0 %rep NUM_LANES cmp qword [state + _aes_cmac_job_in_lane + I*8], 0 jne APPEND(skip_clear_,I) movdqa [state + _aes_cmac_args_IV + I*16], xmm0 movdqa [state + _aes_cmac_scratch + I*16], xmm0 APPEND(skip_clear_,I): %assign I (I+1) %endrep %endif ;; SUBMIT %endif ;; SAFE_DATA %%_return: mov rbx, [rsp + _gpr_save + 8*0] mov rbp, [rsp + _gpr_save + 8*1] mov r12, [rsp + _gpr_save + 8*2] mov r13, [rsp + _gpr_save + 8*3] mov r14, [rsp + _gpr_save + 8*4] mov r15, [rsp + _gpr_save + 8*5] %ifndef LINUX mov rsi, [rsp + _gpr_save + 8*6] mov rdi, [rsp + _gpr_save + 8*7] %endif mov rsp, [rsp + _rsp_save] ; original SP ret %%_return_null: xor job_rax, job_rax jmp %%_return %ifidn %%SUBMIT_FLUSH, SUBMIT %%_complete_block: ;; Block size aligned mov tmp2, [job + _src] add tmp2, [job + _hash_start_src_offset_in_bytes] lea tmp3, [n - 1] shl tmp3, 4 add tmp2, tmp3 ;; M_last = M_n XOR K1 mov tmp3, [job + _skey1] movdqu xmm0, [tmp3] movdqu xmm1, [tmp2] pxor xmm0, xmm1 movdqa [m_last], xmm0 jmp %%_step_5 %%_lt_one_block: ;; Single partial block mov word [state + _aes_cmac_init_done + lane*2], 1 mov [state + _aes_cmac_args_in + lane*8], m_last movdqa xmm0, [state + _aes_cmac_lens] XPINSRW xmm0, xmm1, tmp2, lane, 16, scale_x16 movdqa [state + _aes_cmac_lens], xmm0 mov n, 1 jmp %%_not_complete_block %%_not_complete_block_3gpp: ;; bit pad last block ;; xor with skey2 ;; copy to m_last ;; load pointer to src mov tmp, [job + _src] add tmp, [job + _hash_start_src_offset_in_bytes] lea tmp3, [n - 1] shl tmp3, 4 add tmp, tmp3 ;; check if partial block or r, r jz %%_load_full_block_3gpp simd_load_sse_15_1 xmm0, tmp, r dec r %%_update_mlast_3gpp: ;; set last byte padding mask ;; shift into correct xmm idx ;; save and restore rcx on windows %ifndef LINUX mov tmp, rcx %endif mov rcx, rbits mov tmp3, 0xff shr tmp3, cl movq xmm2, tmp3 XPSLLB xmm2, r, xmm1, tmp2 ;; pad final byte pandn xmm2, xmm0 %ifndef LINUX mov rcx, tmp %endif ;; set OR mask to pad final bit mov tmp2, tmp3 shr tmp2, 1 xor tmp2, tmp3 ; XOR to get OR mask movq xmm3, tmp2 ;; xmm1 contains shift table from previous shift pshufb xmm3, xmm1 ;; load skey2 address mov tmp3, [job + _skey2] movdqu xmm1, [tmp3] ;; set final padding bit por xmm2, xmm3 ;; XOR last partial block with skey2 ;; update mlast pxor xmm2, xmm1 movdqa [m_last], xmm2 jmp %%_step_5 %%_load_full_block_3gpp: movdqu xmm0, [tmp] mov r, 0xf jmp %%_update_mlast_3gpp %endif %endmacro align 64 ; JOB_AES_HMAC * submit_job_aes_cmac_auth_sse(MB_MGR_CMAC_OOO *state, JOB_AES_HMAC *job) ; arg 1 : state ; arg 2 : job MKGLOBAL(SUBMIT_JOB_AES_CMAC_AUTH,function,internal) SUBMIT_JOB_AES_CMAC_AUTH: GENERIC_SUBMIT_FLUSH_JOB_AES_CMAC_SSE SUBMIT ; JOB_AES_HMAC * flush_job_aes_cmac_auth_sse(MB_MGR_CMAC_OOO *state) ; arg 1 : state MKGLOBAL(FLUSH_JOB_AES_CMAC_AUTH,function,internal) FLUSH_JOB_AES_CMAC_AUTH: GENERIC_SUBMIT_FLUSH_JOB_AES_CMAC_SSE FLUSH %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif
; A114103: n multiples of n such that a(n) is a multiple of n. The n-th group contains n multiples of n. Arranged sequentially the n-th term is a multiple of n. ; Submitted by Jon Maiga ; 1,2,6,12,15,6,28,8,36,20,55,60,65,70,15,48,102,18,114,60,42,154,161,168,175,182,189,28,232,120,248,32,264,136,280,72,333,342,117,360,369,126,387,396,45,230,470,240,490,50,510,260,530,270,110,616,627,638,649,660,671,682,693,704,715,66,804,204,276,420,852,72,876,444,300,228,924,156,1027,1040,1053,1066,1079,1092,1105,1118,1131,1144,1157,1170,91,644,1302,658,1330,672,1358,98,1386,700 mov $1,$0 seq $0,114104 ; a(n) = A114103(n)/n. add $1,1 mul $0,$1
_usertests: file format elf32-i386 Disassembly of section .text: 00000000 <main>: return randstate; } int main(int argc, char *argv[]) { 0: f3 0f 1e fb endbr32 4: 8d 4c 24 04 lea 0x4(%esp),%ecx 8: 83 e4 f0 and $0xfffffff0,%esp b: ff 71 fc pushl -0x4(%ecx) e: 55 push %ebp f: 89 e5 mov %esp,%ebp 11: 51 push %ecx 12: 83 ec 0c sub $0xc,%esp printf(1, "usertests starting\n"); 15: 68 36 4e 00 00 push $0x4e36 1a: 6a 01 push $0x1 1c: e8 bf 3a 00 00 call 3ae0 <printf> if(open("usertests.ran", 0) >= 0){ 21: 59 pop %ecx 22: 58 pop %eax 23: 6a 00 push $0x0 25: 68 4a 4e 00 00 push $0x4e4a 2a: e8 94 39 00 00 call 39c3 <open> 2f: 83 c4 10 add $0x10,%esp 32: 85 c0 test %eax,%eax 34: 78 13 js 49 <main+0x49> printf(1, "already ran user tests -- rebuild fs.img\n"); 36: 52 push %edx 37: 52 push %edx 38: 68 b4 55 00 00 push $0x55b4 3d: 6a 01 push $0x1 3f: e8 9c 3a 00 00 call 3ae0 <printf> exit(); 44: e8 3a 39 00 00 call 3983 <exit> } close(open("usertests.ran", O_CREATE)); 49: 50 push %eax 4a: 50 push %eax 4b: 68 00 02 00 00 push $0x200 50: 68 4a 4e 00 00 push $0x4e4a 55: e8 69 39 00 00 call 39c3 <open> 5a: 89 04 24 mov %eax,(%esp) 5d: e8 49 39 00 00 call 39ab <close> argptest(); 62: e8 29 36 00 00 call 3690 <argptest> createdelete(); 67: e8 04 12 00 00 call 1270 <createdelete> linkunlink(); 6c: e8 df 1a 00 00 call 1b50 <linkunlink> concreate(); 71: e8 da 17 00 00 call 1850 <concreate> fourfiles(); 76: e8 f5 0f 00 00 call 1070 <fourfiles> sharedfd(); 7b: e8 30 0e 00 00 call eb0 <sharedfd> bigargtest(); 80: e8 ab 32 00 00 call 3330 <bigargtest> bigwrite(); 85: e8 06 24 00 00 call 2490 <bigwrite> bigargtest(); 8a: e8 a1 32 00 00 call 3330 <bigargtest> bsstest(); 8f: e8 2c 32 00 00 call 32c0 <bsstest> sbrktest(); 94: e8 37 2d 00 00 call 2dd0 <sbrktest> validatetest(); 99: e8 62 31 00 00 call 3200 <validatetest> opentest(); 9e: e8 6d 03 00 00 call 410 <opentest> writetest(); a3: e8 08 04 00 00 call 4b0 <writetest> writetest1(); a8: e8 e3 05 00 00 call 690 <writetest1> createtest(); ad: e8 ae 07 00 00 call 860 <createtest> openiputtest(); b2: e8 59 02 00 00 call 310 <openiputtest> exitiputtest(); b7: e8 54 01 00 00 call 210 <exitiputtest> iputtest(); bc: e8 5f 00 00 00 call 120 <iputtest> mem(); c1: e8 1a 0d 00 00 call de0 <mem> pipe1(); c6: e8 95 09 00 00 call a60 <pipe1> preempt(); cb: e8 30 0b 00 00 call c00 <preempt> exitwait(); d0: e8 8b 0c 00 00 call d60 <exitwait> rmdot(); d5: e8 a6 27 00 00 call 2880 <rmdot> fourteen(); da: e8 61 26 00 00 call 2740 <fourteen> bigfile(); df: e8 8c 24 00 00 call 2570 <bigfile> subdir(); e4: e8 b7 1c 00 00 call 1da0 <subdir> linktest(); e9: e8 42 15 00 00 call 1630 <linktest> unlinkread(); ee: e8 ad 13 00 00 call 14a0 <unlinkread> dirfile(); f3: e8 08 29 00 00 call 2a00 <dirfile> iref(); f8: e8 03 2b 00 00 call 2c00 <iref> forktest(); fd: e8 1e 2c 00 00 call 2d20 <forktest> bigdir(); // slow 102: e8 59 1b 00 00 call 1c60 <bigdir> uio(); 107: e8 04 35 00 00 call 3610 <uio> exectest(); 10c: e8 ff 08 00 00 call a10 <exectest> exit(); 111: e8 6d 38 00 00 call 3983 <exit> 116: 66 90 xchg %ax,%ax 118: 66 90 xchg %ax,%ax 11a: 66 90 xchg %ax,%ax 11c: 66 90 xchg %ax,%ax 11e: 66 90 xchg %ax,%ax 00000120 <iputtest>: { 120: f3 0f 1e fb endbr32 124: 55 push %ebp 125: 89 e5 mov %esp,%ebp 127: 83 ec 10 sub $0x10,%esp printf(stdout, "iput test\n"); 12a: 68 dc 3e 00 00 push $0x3edc 12f: ff 35 e0 5e 00 00 pushl 0x5ee0 135: e8 a6 39 00 00 call 3ae0 <printf> if(mkdir("iputdir") < 0){ 13a: c7 04 24 6f 3e 00 00 movl $0x3e6f,(%esp) 141: e8 a5 38 00 00 call 39eb <mkdir> 146: 83 c4 10 add $0x10,%esp 149: 85 c0 test %eax,%eax 14b: 78 58 js 1a5 <iputtest+0x85> if(chdir("iputdir") < 0){ 14d: 83 ec 0c sub $0xc,%esp 150: 68 6f 3e 00 00 push $0x3e6f 155: e8 99 38 00 00 call 39f3 <chdir> 15a: 83 c4 10 add $0x10,%esp 15d: 85 c0 test %eax,%eax 15f: 0f 88 85 00 00 00 js 1ea <iputtest+0xca> if(unlink("../iputdir") < 0){ 165: 83 ec 0c sub $0xc,%esp 168: 68 6c 3e 00 00 push $0x3e6c 16d: e8 61 38 00 00 call 39d3 <unlink> 172: 83 c4 10 add $0x10,%esp 175: 85 c0 test %eax,%eax 177: 78 5a js 1d3 <iputtest+0xb3> if(chdir("/") < 0){ 179: 83 ec 0c sub $0xc,%esp 17c: 68 91 3e 00 00 push $0x3e91 181: e8 6d 38 00 00 call 39f3 <chdir> 186: 83 c4 10 add $0x10,%esp 189: 85 c0 test %eax,%eax 18b: 78 2f js 1bc <iputtest+0x9c> printf(stdout, "iput test ok\n"); 18d: 83 ec 08 sub $0x8,%esp 190: 68 14 3f 00 00 push $0x3f14 195: ff 35 e0 5e 00 00 pushl 0x5ee0 19b: e8 40 39 00 00 call 3ae0 <printf> } 1a0: 83 c4 10 add $0x10,%esp 1a3: c9 leave 1a4: c3 ret printf(stdout, "mkdir failed\n"); 1a5: 50 push %eax 1a6: 50 push %eax 1a7: 68 48 3e 00 00 push $0x3e48 1ac: ff 35 e0 5e 00 00 pushl 0x5ee0 1b2: e8 29 39 00 00 call 3ae0 <printf> exit(); 1b7: e8 c7 37 00 00 call 3983 <exit> printf(stdout, "chdir / failed\n"); 1bc: 50 push %eax 1bd: 50 push %eax 1be: 68 93 3e 00 00 push $0x3e93 1c3: ff 35 e0 5e 00 00 pushl 0x5ee0 1c9: e8 12 39 00 00 call 3ae0 <printf> exit(); 1ce: e8 b0 37 00 00 call 3983 <exit> printf(stdout, "unlink ../iputdir failed\n"); 1d3: 52 push %edx 1d4: 52 push %edx 1d5: 68 77 3e 00 00 push $0x3e77 1da: ff 35 e0 5e 00 00 pushl 0x5ee0 1e0: e8 fb 38 00 00 call 3ae0 <printf> exit(); 1e5: e8 99 37 00 00 call 3983 <exit> printf(stdout, "chdir iputdir failed\n"); 1ea: 51 push %ecx 1eb: 51 push %ecx 1ec: 68 56 3e 00 00 push $0x3e56 1f1: ff 35 e0 5e 00 00 pushl 0x5ee0 1f7: e8 e4 38 00 00 call 3ae0 <printf> exit(); 1fc: e8 82 37 00 00 call 3983 <exit> 201: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 208: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 20f: 90 nop 00000210 <exitiputtest>: { 210: f3 0f 1e fb endbr32 214: 55 push %ebp 215: 89 e5 mov %esp,%ebp 217: 83 ec 10 sub $0x10,%esp printf(stdout, "exitiput test\n"); 21a: 68 a3 3e 00 00 push $0x3ea3 21f: ff 35 e0 5e 00 00 pushl 0x5ee0 225: e8 b6 38 00 00 call 3ae0 <printf> pid = fork(); 22a: e8 4c 37 00 00 call 397b <fork> if(pid < 0){ 22f: 83 c4 10 add $0x10,%esp 232: 85 c0 test %eax,%eax 234: 0f 88 86 00 00 00 js 2c0 <exitiputtest+0xb0> if(pid == 0){ 23a: 75 4c jne 288 <exitiputtest+0x78> if(mkdir("iputdir") < 0){ 23c: 83 ec 0c sub $0xc,%esp 23f: 68 6f 3e 00 00 push $0x3e6f 244: e8 a2 37 00 00 call 39eb <mkdir> 249: 83 c4 10 add $0x10,%esp 24c: 85 c0 test %eax,%eax 24e: 0f 88 83 00 00 00 js 2d7 <exitiputtest+0xc7> if(chdir("iputdir") < 0){ 254: 83 ec 0c sub $0xc,%esp 257: 68 6f 3e 00 00 push $0x3e6f 25c: e8 92 37 00 00 call 39f3 <chdir> 261: 83 c4 10 add $0x10,%esp 264: 85 c0 test %eax,%eax 266: 0f 88 82 00 00 00 js 2ee <exitiputtest+0xde> if(unlink("../iputdir") < 0){ 26c: 83 ec 0c sub $0xc,%esp 26f: 68 6c 3e 00 00 push $0x3e6c 274: e8 5a 37 00 00 call 39d3 <unlink> 279: 83 c4 10 add $0x10,%esp 27c: 85 c0 test %eax,%eax 27e: 78 28 js 2a8 <exitiputtest+0x98> exit(); 280: e8 fe 36 00 00 call 3983 <exit> 285: 8d 76 00 lea 0x0(%esi),%esi wait(); 288: e8 fe 36 00 00 call 398b <wait> printf(stdout, "exitiput test ok\n"); 28d: 83 ec 08 sub $0x8,%esp 290: 68 c6 3e 00 00 push $0x3ec6 295: ff 35 e0 5e 00 00 pushl 0x5ee0 29b: e8 40 38 00 00 call 3ae0 <printf> } 2a0: 83 c4 10 add $0x10,%esp 2a3: c9 leave 2a4: c3 ret 2a5: 8d 76 00 lea 0x0(%esi),%esi printf(stdout, "unlink ../iputdir failed\n"); 2a8: 83 ec 08 sub $0x8,%esp 2ab: 68 77 3e 00 00 push $0x3e77 2b0: ff 35 e0 5e 00 00 pushl 0x5ee0 2b6: e8 25 38 00 00 call 3ae0 <printf> exit(); 2bb: e8 c3 36 00 00 call 3983 <exit> printf(stdout, "fork failed\n"); 2c0: 51 push %ecx 2c1: 51 push %ecx 2c2: 68 89 4d 00 00 push $0x4d89 2c7: ff 35 e0 5e 00 00 pushl 0x5ee0 2cd: e8 0e 38 00 00 call 3ae0 <printf> exit(); 2d2: e8 ac 36 00 00 call 3983 <exit> printf(stdout, "mkdir failed\n"); 2d7: 52 push %edx 2d8: 52 push %edx 2d9: 68 48 3e 00 00 push $0x3e48 2de: ff 35 e0 5e 00 00 pushl 0x5ee0 2e4: e8 f7 37 00 00 call 3ae0 <printf> exit(); 2e9: e8 95 36 00 00 call 3983 <exit> printf(stdout, "child chdir failed\n"); 2ee: 50 push %eax 2ef: 50 push %eax 2f0: 68 b2 3e 00 00 push $0x3eb2 2f5: ff 35 e0 5e 00 00 pushl 0x5ee0 2fb: e8 e0 37 00 00 call 3ae0 <printf> exit(); 300: e8 7e 36 00 00 call 3983 <exit> 305: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 30c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000310 <openiputtest>: { 310: f3 0f 1e fb endbr32 314: 55 push %ebp 315: 89 e5 mov %esp,%ebp 317: 83 ec 10 sub $0x10,%esp printf(stdout, "openiput test\n"); 31a: 68 d8 3e 00 00 push $0x3ed8 31f: ff 35 e0 5e 00 00 pushl 0x5ee0 325: e8 b6 37 00 00 call 3ae0 <printf> if(mkdir("oidir") < 0){ 32a: c7 04 24 e7 3e 00 00 movl $0x3ee7,(%esp) 331: e8 b5 36 00 00 call 39eb <mkdir> 336: 83 c4 10 add $0x10,%esp 339: 85 c0 test %eax,%eax 33b: 0f 88 9b 00 00 00 js 3dc <openiputtest+0xcc> pid = fork(); 341: e8 35 36 00 00 call 397b <fork> if(pid < 0){ 346: 85 c0 test %eax,%eax 348: 78 7b js 3c5 <openiputtest+0xb5> if(pid == 0){ 34a: 75 34 jne 380 <openiputtest+0x70> int fd = open("oidir", O_RDWR); 34c: 83 ec 08 sub $0x8,%esp 34f: 6a 02 push $0x2 351: 68 e7 3e 00 00 push $0x3ee7 356: e8 68 36 00 00 call 39c3 <open> if(fd >= 0){ 35b: 83 c4 10 add $0x10,%esp 35e: 85 c0 test %eax,%eax 360: 78 5e js 3c0 <openiputtest+0xb0> printf(stdout, "open directory for write succeeded\n"); 362: 83 ec 08 sub $0x8,%esp 365: 68 6c 4e 00 00 push $0x4e6c 36a: ff 35 e0 5e 00 00 pushl 0x5ee0 370: e8 6b 37 00 00 call 3ae0 <printf> exit(); 375: e8 09 36 00 00 call 3983 <exit> 37a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi sleep(1); 380: 83 ec 0c sub $0xc,%esp 383: 6a 01 push $0x1 385: e8 89 36 00 00 call 3a13 <sleep> if(unlink("oidir") != 0){ 38a: c7 04 24 e7 3e 00 00 movl $0x3ee7,(%esp) 391: e8 3d 36 00 00 call 39d3 <unlink> 396: 83 c4 10 add $0x10,%esp 399: 85 c0 test %eax,%eax 39b: 75 56 jne 3f3 <openiputtest+0xe3> wait(); 39d: e8 e9 35 00 00 call 398b <wait> printf(stdout, "openiput test ok\n"); 3a2: 83 ec 08 sub $0x8,%esp 3a5: 68 10 3f 00 00 push $0x3f10 3aa: ff 35 e0 5e 00 00 pushl 0x5ee0 3b0: e8 2b 37 00 00 call 3ae0 <printf> 3b5: 83 c4 10 add $0x10,%esp } 3b8: c9 leave 3b9: c3 ret 3ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi exit(); 3c0: e8 be 35 00 00 call 3983 <exit> printf(stdout, "fork failed\n"); 3c5: 52 push %edx 3c6: 52 push %edx 3c7: 68 89 4d 00 00 push $0x4d89 3cc: ff 35 e0 5e 00 00 pushl 0x5ee0 3d2: e8 09 37 00 00 call 3ae0 <printf> exit(); 3d7: e8 a7 35 00 00 call 3983 <exit> printf(stdout, "mkdir oidir failed\n"); 3dc: 51 push %ecx 3dd: 51 push %ecx 3de: 68 ed 3e 00 00 push $0x3eed 3e3: ff 35 e0 5e 00 00 pushl 0x5ee0 3e9: e8 f2 36 00 00 call 3ae0 <printf> exit(); 3ee: e8 90 35 00 00 call 3983 <exit> printf(stdout, "unlink failed\n"); 3f3: 50 push %eax 3f4: 50 push %eax 3f5: 68 01 3f 00 00 push $0x3f01 3fa: ff 35 e0 5e 00 00 pushl 0x5ee0 400: e8 db 36 00 00 call 3ae0 <printf> exit(); 405: e8 79 35 00 00 call 3983 <exit> 40a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000410 <opentest>: { 410: f3 0f 1e fb endbr32 414: 55 push %ebp 415: 89 e5 mov %esp,%ebp 417: 83 ec 10 sub $0x10,%esp printf(stdout, "open test\n"); 41a: 68 22 3f 00 00 push $0x3f22 41f: ff 35 e0 5e 00 00 pushl 0x5ee0 425: e8 b6 36 00 00 call 3ae0 <printf> fd = open("echo", 0); 42a: 58 pop %eax 42b: 5a pop %edx 42c: 6a 00 push $0x0 42e: 68 2d 3f 00 00 push $0x3f2d 433: e8 8b 35 00 00 call 39c3 <open> if(fd < 0){ 438: 83 c4 10 add $0x10,%esp 43b: 85 c0 test %eax,%eax 43d: 78 36 js 475 <opentest+0x65> close(fd); 43f: 83 ec 0c sub $0xc,%esp 442: 50 push %eax 443: e8 63 35 00 00 call 39ab <close> fd = open("doesnotexist", 0); 448: 5a pop %edx 449: 59 pop %ecx 44a: 6a 00 push $0x0 44c: 68 45 3f 00 00 push $0x3f45 451: e8 6d 35 00 00 call 39c3 <open> if(fd >= 0){ 456: 83 c4 10 add $0x10,%esp 459: 85 c0 test %eax,%eax 45b: 79 2f jns 48c <opentest+0x7c> printf(stdout, "open test ok\n"); 45d: 83 ec 08 sub $0x8,%esp 460: 68 70 3f 00 00 push $0x3f70 465: ff 35 e0 5e 00 00 pushl 0x5ee0 46b: e8 70 36 00 00 call 3ae0 <printf> } 470: 83 c4 10 add $0x10,%esp 473: c9 leave 474: c3 ret printf(stdout, "open echo failed!\n"); 475: 50 push %eax 476: 50 push %eax 477: 68 32 3f 00 00 push $0x3f32 47c: ff 35 e0 5e 00 00 pushl 0x5ee0 482: e8 59 36 00 00 call 3ae0 <printf> exit(); 487: e8 f7 34 00 00 call 3983 <exit> printf(stdout, "open doesnotexist succeeded!\n"); 48c: 50 push %eax 48d: 50 push %eax 48e: 68 52 3f 00 00 push $0x3f52 493: ff 35 e0 5e 00 00 pushl 0x5ee0 499: e8 42 36 00 00 call 3ae0 <printf> exit(); 49e: e8 e0 34 00 00 call 3983 <exit> 4a3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 4aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000004b0 <writetest>: { 4b0: f3 0f 1e fb endbr32 4b4: 55 push %ebp 4b5: 89 e5 mov %esp,%ebp 4b7: 56 push %esi 4b8: 53 push %ebx printf(stdout, "small file test\n"); 4b9: 83 ec 08 sub $0x8,%esp 4bc: 68 7e 3f 00 00 push $0x3f7e 4c1: ff 35 e0 5e 00 00 pushl 0x5ee0 4c7: e8 14 36 00 00 call 3ae0 <printf> fd = open("small", O_CREATE|O_RDWR); 4cc: 58 pop %eax 4cd: 5a pop %edx 4ce: 68 02 02 00 00 push $0x202 4d3: 68 8f 3f 00 00 push $0x3f8f 4d8: e8 e6 34 00 00 call 39c3 <open> if(fd >= 0){ 4dd: 83 c4 10 add $0x10,%esp 4e0: 85 c0 test %eax,%eax 4e2: 0f 88 8c 01 00 00 js 674 <writetest+0x1c4> printf(stdout, "creat small succeeded; ok\n"); 4e8: 83 ec 08 sub $0x8,%esp 4eb: 89 c6 mov %eax,%esi for(i = 0; i < 100; i++){ 4ed: 31 db xor %ebx,%ebx printf(stdout, "creat small succeeded; ok\n"); 4ef: 68 95 3f 00 00 push $0x3f95 4f4: ff 35 e0 5e 00 00 pushl 0x5ee0 4fa: e8 e1 35 00 00 call 3ae0 <printf> 4ff: 83 c4 10 add $0x10,%esp 502: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(write(fd, "aaaaaaaaaa", 10) != 10){ 508: 83 ec 04 sub $0x4,%esp 50b: 6a 0a push $0xa 50d: 68 cc 3f 00 00 push $0x3fcc 512: 56 push %esi 513: e8 8b 34 00 00 call 39a3 <write> 518: 83 c4 10 add $0x10,%esp 51b: 83 f8 0a cmp $0xa,%eax 51e: 0f 85 d9 00 00 00 jne 5fd <writetest+0x14d> if(write(fd, "bbbbbbbbbb", 10) != 10){ 524: 83 ec 04 sub $0x4,%esp 527: 6a 0a push $0xa 529: 68 d7 3f 00 00 push $0x3fd7 52e: 56 push %esi 52f: e8 6f 34 00 00 call 39a3 <write> 534: 83 c4 10 add $0x10,%esp 537: 83 f8 0a cmp $0xa,%eax 53a: 0f 85 d6 00 00 00 jne 616 <writetest+0x166> for(i = 0; i < 100; i++){ 540: 83 c3 01 add $0x1,%ebx 543: 83 fb 64 cmp $0x64,%ebx 546: 75 c0 jne 508 <writetest+0x58> printf(stdout, "writes ok\n"); 548: 83 ec 08 sub $0x8,%esp 54b: 68 e2 3f 00 00 push $0x3fe2 550: ff 35 e0 5e 00 00 pushl 0x5ee0 556: e8 85 35 00 00 call 3ae0 <printf> close(fd); 55b: 89 34 24 mov %esi,(%esp) 55e: e8 48 34 00 00 call 39ab <close> fd = open("small", O_RDONLY); 563: 5b pop %ebx 564: 5e pop %esi 565: 6a 00 push $0x0 567: 68 8f 3f 00 00 push $0x3f8f 56c: e8 52 34 00 00 call 39c3 <open> if(fd >= 0){ 571: 83 c4 10 add $0x10,%esp fd = open("small", O_RDONLY); 574: 89 c3 mov %eax,%ebx if(fd >= 0){ 576: 85 c0 test %eax,%eax 578: 0f 88 b1 00 00 00 js 62f <writetest+0x17f> printf(stdout, "open small succeeded ok\n"); 57e: 83 ec 08 sub $0x8,%esp 581: 68 ed 3f 00 00 push $0x3fed 586: ff 35 e0 5e 00 00 pushl 0x5ee0 58c: e8 4f 35 00 00 call 3ae0 <printf> i = read(fd, buf, 2000); 591: 83 c4 0c add $0xc,%esp 594: 68 d0 07 00 00 push $0x7d0 599: 68 c0 86 00 00 push $0x86c0 59e: 53 push %ebx 59f: e8 f7 33 00 00 call 399b <read> if(i == 2000){ 5a4: 83 c4 10 add $0x10,%esp 5a7: 3d d0 07 00 00 cmp $0x7d0,%eax 5ac: 0f 85 94 00 00 00 jne 646 <writetest+0x196> printf(stdout, "read succeeded ok\n"); 5b2: 83 ec 08 sub $0x8,%esp 5b5: 68 21 40 00 00 push $0x4021 5ba: ff 35 e0 5e 00 00 pushl 0x5ee0 5c0: e8 1b 35 00 00 call 3ae0 <printf> close(fd); 5c5: 89 1c 24 mov %ebx,(%esp) 5c8: e8 de 33 00 00 call 39ab <close> if(unlink("small") < 0){ 5cd: c7 04 24 8f 3f 00 00 movl $0x3f8f,(%esp) 5d4: e8 fa 33 00 00 call 39d3 <unlink> 5d9: 83 c4 10 add $0x10,%esp 5dc: 85 c0 test %eax,%eax 5de: 78 7d js 65d <writetest+0x1ad> printf(stdout, "small file test ok\n"); 5e0: 83 ec 08 sub $0x8,%esp 5e3: 68 49 40 00 00 push $0x4049 5e8: ff 35 e0 5e 00 00 pushl 0x5ee0 5ee: e8 ed 34 00 00 call 3ae0 <printf> } 5f3: 83 c4 10 add $0x10,%esp 5f6: 8d 65 f8 lea -0x8(%ebp),%esp 5f9: 5b pop %ebx 5fa: 5e pop %esi 5fb: 5d pop %ebp 5fc: c3 ret printf(stdout, "error: write aa %d new file failed\n", i); 5fd: 83 ec 04 sub $0x4,%esp 600: 53 push %ebx 601: 68 90 4e 00 00 push $0x4e90 606: ff 35 e0 5e 00 00 pushl 0x5ee0 60c: e8 cf 34 00 00 call 3ae0 <printf> exit(); 611: e8 6d 33 00 00 call 3983 <exit> printf(stdout, "error: write bb %d new file failed\n", i); 616: 83 ec 04 sub $0x4,%esp 619: 53 push %ebx 61a: 68 b4 4e 00 00 push $0x4eb4 61f: ff 35 e0 5e 00 00 pushl 0x5ee0 625: e8 b6 34 00 00 call 3ae0 <printf> exit(); 62a: e8 54 33 00 00 call 3983 <exit> printf(stdout, "error: open small failed!\n"); 62f: 51 push %ecx 630: 51 push %ecx 631: 68 06 40 00 00 push $0x4006 636: ff 35 e0 5e 00 00 pushl 0x5ee0 63c: e8 9f 34 00 00 call 3ae0 <printf> exit(); 641: e8 3d 33 00 00 call 3983 <exit> printf(stdout, "read failed\n"); 646: 52 push %edx 647: 52 push %edx 648: 68 4d 43 00 00 push $0x434d 64d: ff 35 e0 5e 00 00 pushl 0x5ee0 653: e8 88 34 00 00 call 3ae0 <printf> exit(); 658: e8 26 33 00 00 call 3983 <exit> printf(stdout, "unlink small failed\n"); 65d: 50 push %eax 65e: 50 push %eax 65f: 68 34 40 00 00 push $0x4034 664: ff 35 e0 5e 00 00 pushl 0x5ee0 66a: e8 71 34 00 00 call 3ae0 <printf> exit(); 66f: e8 0f 33 00 00 call 3983 <exit> printf(stdout, "error: creat small failed!\n"); 674: 50 push %eax 675: 50 push %eax 676: 68 b0 3f 00 00 push $0x3fb0 67b: ff 35 e0 5e 00 00 pushl 0x5ee0 681: e8 5a 34 00 00 call 3ae0 <printf> exit(); 686: e8 f8 32 00 00 call 3983 <exit> 68b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 68f: 90 nop 00000690 <writetest1>: { 690: f3 0f 1e fb endbr32 694: 55 push %ebp 695: 89 e5 mov %esp,%ebp 697: 56 push %esi 698: 53 push %ebx printf(stdout, "big files test\n"); 699: 83 ec 08 sub $0x8,%esp 69c: 68 5d 40 00 00 push $0x405d 6a1: ff 35 e0 5e 00 00 pushl 0x5ee0 6a7: e8 34 34 00 00 call 3ae0 <printf> fd = open("big", O_CREATE|O_RDWR); 6ac: 58 pop %eax 6ad: 5a pop %edx 6ae: 68 02 02 00 00 push $0x202 6b3: 68 d7 40 00 00 push $0x40d7 6b8: e8 06 33 00 00 call 39c3 <open> if(fd < 0){ 6bd: 83 c4 10 add $0x10,%esp 6c0: 85 c0 test %eax,%eax 6c2: 0f 88 5d 01 00 00 js 825 <writetest1+0x195> 6c8: 89 c6 mov %eax,%esi for(i = 0; i < MAXFILE; i++){ 6ca: 31 db xor %ebx,%ebx 6cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(write(fd, buf, 512) != 512){ 6d0: 83 ec 04 sub $0x4,%esp ((int*)buf)[0] = i; 6d3: 89 1d c0 86 00 00 mov %ebx,0x86c0 if(write(fd, buf, 512) != 512){ 6d9: 68 00 02 00 00 push $0x200 6de: 68 c0 86 00 00 push $0x86c0 6e3: 56 push %esi 6e4: e8 ba 32 00 00 call 39a3 <write> 6e9: 83 c4 10 add $0x10,%esp 6ec: 3d 00 02 00 00 cmp $0x200,%eax 6f1: 0f 85 b3 00 00 00 jne 7aa <writetest1+0x11a> for(i = 0; i < MAXFILE; i++){ 6f7: 83 c3 01 add $0x1,%ebx 6fa: 81 fb 8c 00 00 00 cmp $0x8c,%ebx 700: 75 ce jne 6d0 <writetest1+0x40> close(fd); 702: 83 ec 0c sub $0xc,%esp 705: 56 push %esi 706: e8 a0 32 00 00 call 39ab <close> fd = open("big", O_RDONLY); 70b: 5b pop %ebx 70c: 5e pop %esi 70d: 6a 00 push $0x0 70f: 68 d7 40 00 00 push $0x40d7 714: e8 aa 32 00 00 call 39c3 <open> if(fd < 0){ 719: 83 c4 10 add $0x10,%esp fd = open("big", O_RDONLY); 71c: 89 c3 mov %eax,%ebx if(fd < 0){ 71e: 85 c0 test %eax,%eax 720: 0f 88 e8 00 00 00 js 80e <writetest1+0x17e> n = 0; 726: 31 f6 xor %esi,%esi 728: eb 1d jmp 747 <writetest1+0xb7> 72a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else if(i != 512){ 730: 3d 00 02 00 00 cmp $0x200,%eax 735: 0f 85 9f 00 00 00 jne 7da <writetest1+0x14a> if(((int*)buf)[0] != n){ 73b: a1 c0 86 00 00 mov 0x86c0,%eax 740: 39 f0 cmp %esi,%eax 742: 75 7f jne 7c3 <writetest1+0x133> n++; 744: 83 c6 01 add $0x1,%esi i = read(fd, buf, 512); 747: 83 ec 04 sub $0x4,%esp 74a: 68 00 02 00 00 push $0x200 74f: 68 c0 86 00 00 push $0x86c0 754: 53 push %ebx 755: e8 41 32 00 00 call 399b <read> if(i == 0){ 75a: 83 c4 10 add $0x10,%esp 75d: 85 c0 test %eax,%eax 75f: 75 cf jne 730 <writetest1+0xa0> if(n == MAXFILE - 1){ 761: 81 fe 8b 00 00 00 cmp $0x8b,%esi 767: 0f 84 86 00 00 00 je 7f3 <writetest1+0x163> close(fd); 76d: 83 ec 0c sub $0xc,%esp 770: 53 push %ebx 771: e8 35 32 00 00 call 39ab <close> if(unlink("big") < 0){ 776: c7 04 24 d7 40 00 00 movl $0x40d7,(%esp) 77d: e8 51 32 00 00 call 39d3 <unlink> 782: 83 c4 10 add $0x10,%esp 785: 85 c0 test %eax,%eax 787: 0f 88 af 00 00 00 js 83c <writetest1+0x1ac> printf(stdout, "big files ok\n"); 78d: 83 ec 08 sub $0x8,%esp 790: 68 fe 40 00 00 push $0x40fe 795: ff 35 e0 5e 00 00 pushl 0x5ee0 79b: e8 40 33 00 00 call 3ae0 <printf> } 7a0: 83 c4 10 add $0x10,%esp 7a3: 8d 65 f8 lea -0x8(%ebp),%esp 7a6: 5b pop %ebx 7a7: 5e pop %esi 7a8: 5d pop %ebp 7a9: c3 ret printf(stdout, "error: write big file failed\n", i); 7aa: 83 ec 04 sub $0x4,%esp 7ad: 53 push %ebx 7ae: 68 87 40 00 00 push $0x4087 7b3: ff 35 e0 5e 00 00 pushl 0x5ee0 7b9: e8 22 33 00 00 call 3ae0 <printf> exit(); 7be: e8 c0 31 00 00 call 3983 <exit> printf(stdout, "read content of block %d is %d\n", 7c3: 50 push %eax 7c4: 56 push %esi 7c5: 68 d8 4e 00 00 push $0x4ed8 7ca: ff 35 e0 5e 00 00 pushl 0x5ee0 7d0: e8 0b 33 00 00 call 3ae0 <printf> exit(); 7d5: e8 a9 31 00 00 call 3983 <exit> printf(stdout, "read failed %d\n", i); 7da: 83 ec 04 sub $0x4,%esp 7dd: 50 push %eax 7de: 68 db 40 00 00 push $0x40db 7e3: ff 35 e0 5e 00 00 pushl 0x5ee0 7e9: e8 f2 32 00 00 call 3ae0 <printf> exit(); 7ee: e8 90 31 00 00 call 3983 <exit> printf(stdout, "read only %d blocks from big", n); 7f3: 52 push %edx 7f4: 68 8b 00 00 00 push $0x8b 7f9: 68 be 40 00 00 push $0x40be 7fe: ff 35 e0 5e 00 00 pushl 0x5ee0 804: e8 d7 32 00 00 call 3ae0 <printf> exit(); 809: e8 75 31 00 00 call 3983 <exit> printf(stdout, "error: open big failed!\n"); 80e: 51 push %ecx 80f: 51 push %ecx 810: 68 a5 40 00 00 push $0x40a5 815: ff 35 e0 5e 00 00 pushl 0x5ee0 81b: e8 c0 32 00 00 call 3ae0 <printf> exit(); 820: e8 5e 31 00 00 call 3983 <exit> printf(stdout, "error: creat big failed!\n"); 825: 50 push %eax 826: 50 push %eax 827: 68 6d 40 00 00 push $0x406d 82c: ff 35 e0 5e 00 00 pushl 0x5ee0 832: e8 a9 32 00 00 call 3ae0 <printf> exit(); 837: e8 47 31 00 00 call 3983 <exit> printf(stdout, "unlink big failed\n"); 83c: 50 push %eax 83d: 50 push %eax 83e: 68 eb 40 00 00 push $0x40eb 843: ff 35 e0 5e 00 00 pushl 0x5ee0 849: e8 92 32 00 00 call 3ae0 <printf> exit(); 84e: e8 30 31 00 00 call 3983 <exit> 853: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 85a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000860 <createtest>: { 860: f3 0f 1e fb endbr32 864: 55 push %ebp 865: 89 e5 mov %esp,%ebp 867: 53 push %ebx name[2] = '\0'; 868: bb 30 00 00 00 mov $0x30,%ebx { 86d: 83 ec 0c sub $0xc,%esp printf(stdout, "many creates, followed by unlink test\n"); 870: 68 f8 4e 00 00 push $0x4ef8 875: ff 35 e0 5e 00 00 pushl 0x5ee0 87b: e8 60 32 00 00 call 3ae0 <printf> name[0] = 'a'; 880: c6 05 c0 a6 00 00 61 movb $0x61,0xa6c0 name[2] = '\0'; 887: 83 c4 10 add $0x10,%esp 88a: c6 05 c2 a6 00 00 00 movb $0x0,0xa6c2 for(i = 0; i < 52; i++){ 891: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi fd = open(name, O_CREATE|O_RDWR); 898: 83 ec 08 sub $0x8,%esp name[1] = '0' + i; 89b: 88 1d c1 a6 00 00 mov %bl,0xa6c1 fd = open(name, O_CREATE|O_RDWR); 8a1: 83 c3 01 add $0x1,%ebx 8a4: 68 02 02 00 00 push $0x202 8a9: 68 c0 a6 00 00 push $0xa6c0 8ae: e8 10 31 00 00 call 39c3 <open> close(fd); 8b3: 89 04 24 mov %eax,(%esp) 8b6: e8 f0 30 00 00 call 39ab <close> for(i = 0; i < 52; i++){ 8bb: 83 c4 10 add $0x10,%esp 8be: 80 fb 64 cmp $0x64,%bl 8c1: 75 d5 jne 898 <createtest+0x38> name[0] = 'a'; 8c3: c6 05 c0 a6 00 00 61 movb $0x61,0xa6c0 name[2] = '\0'; 8ca: bb 30 00 00 00 mov $0x30,%ebx 8cf: c6 05 c2 a6 00 00 00 movb $0x0,0xa6c2 for(i = 0; i < 52; i++){ 8d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 8dd: 8d 76 00 lea 0x0(%esi),%esi unlink(name); 8e0: 83 ec 0c sub $0xc,%esp name[1] = '0' + i; 8e3: 88 1d c1 a6 00 00 mov %bl,0xa6c1 unlink(name); 8e9: 83 c3 01 add $0x1,%ebx 8ec: 68 c0 a6 00 00 push $0xa6c0 8f1: e8 dd 30 00 00 call 39d3 <unlink> for(i = 0; i < 52; i++){ 8f6: 83 c4 10 add $0x10,%esp 8f9: 80 fb 64 cmp $0x64,%bl 8fc: 75 e2 jne 8e0 <createtest+0x80> printf(stdout, "many creates, followed by unlink; ok\n"); 8fe: 83 ec 08 sub $0x8,%esp 901: 68 20 4f 00 00 push $0x4f20 906: ff 35 e0 5e 00 00 pushl 0x5ee0 90c: e8 cf 31 00 00 call 3ae0 <printf> } 911: 8b 5d fc mov -0x4(%ebp),%ebx 914: 83 c4 10 add $0x10,%esp 917: c9 leave 918: c3 ret 919: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000920 <dirtest>: { 920: f3 0f 1e fb endbr32 924: 55 push %ebp 925: 89 e5 mov %esp,%ebp 927: 83 ec 10 sub $0x10,%esp printf(stdout, "mkdir test\n"); 92a: 68 0c 41 00 00 push $0x410c 92f: ff 35 e0 5e 00 00 pushl 0x5ee0 935: e8 a6 31 00 00 call 3ae0 <printf> if(mkdir("dir0") < 0){ 93a: c7 04 24 18 41 00 00 movl $0x4118,(%esp) 941: e8 a5 30 00 00 call 39eb <mkdir> 946: 83 c4 10 add $0x10,%esp 949: 85 c0 test %eax,%eax 94b: 78 58 js 9a5 <dirtest+0x85> if(chdir("dir0") < 0){ 94d: 83 ec 0c sub $0xc,%esp 950: 68 18 41 00 00 push $0x4118 955: e8 99 30 00 00 call 39f3 <chdir> 95a: 83 c4 10 add $0x10,%esp 95d: 85 c0 test %eax,%eax 95f: 0f 88 85 00 00 00 js 9ea <dirtest+0xca> if(chdir("..") < 0){ 965: 83 ec 0c sub $0xc,%esp 968: 68 bd 46 00 00 push $0x46bd 96d: e8 81 30 00 00 call 39f3 <chdir> 972: 83 c4 10 add $0x10,%esp 975: 85 c0 test %eax,%eax 977: 78 5a js 9d3 <dirtest+0xb3> if(unlink("dir0") < 0){ 979: 83 ec 0c sub $0xc,%esp 97c: 68 18 41 00 00 push $0x4118 981: e8 4d 30 00 00 call 39d3 <unlink> 986: 83 c4 10 add $0x10,%esp 989: 85 c0 test %eax,%eax 98b: 78 2f js 9bc <dirtest+0x9c> printf(stdout, "mkdir test ok\n"); 98d: 83 ec 08 sub $0x8,%esp 990: 68 55 41 00 00 push $0x4155 995: ff 35 e0 5e 00 00 pushl 0x5ee0 99b: e8 40 31 00 00 call 3ae0 <printf> } 9a0: 83 c4 10 add $0x10,%esp 9a3: c9 leave 9a4: c3 ret printf(stdout, "mkdir failed\n"); 9a5: 50 push %eax 9a6: 50 push %eax 9a7: 68 48 3e 00 00 push $0x3e48 9ac: ff 35 e0 5e 00 00 pushl 0x5ee0 9b2: e8 29 31 00 00 call 3ae0 <printf> exit(); 9b7: e8 c7 2f 00 00 call 3983 <exit> printf(stdout, "unlink dir0 failed\n"); 9bc: 50 push %eax 9bd: 50 push %eax 9be: 68 41 41 00 00 push $0x4141 9c3: ff 35 e0 5e 00 00 pushl 0x5ee0 9c9: e8 12 31 00 00 call 3ae0 <printf> exit(); 9ce: e8 b0 2f 00 00 call 3983 <exit> printf(stdout, "chdir .. failed\n"); 9d3: 52 push %edx 9d4: 52 push %edx 9d5: 68 30 41 00 00 push $0x4130 9da: ff 35 e0 5e 00 00 pushl 0x5ee0 9e0: e8 fb 30 00 00 call 3ae0 <printf> exit(); 9e5: e8 99 2f 00 00 call 3983 <exit> printf(stdout, "chdir dir0 failed\n"); 9ea: 51 push %ecx 9eb: 51 push %ecx 9ec: 68 1d 41 00 00 push $0x411d 9f1: ff 35 e0 5e 00 00 pushl 0x5ee0 9f7: e8 e4 30 00 00 call 3ae0 <printf> exit(); 9fc: e8 82 2f 00 00 call 3983 <exit> a01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi a08: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi a0f: 90 nop 00000a10 <exectest>: { a10: f3 0f 1e fb endbr32 a14: 55 push %ebp a15: 89 e5 mov %esp,%ebp a17: 83 ec 10 sub $0x10,%esp printf(stdout, "exec test\n"); a1a: 68 64 41 00 00 push $0x4164 a1f: ff 35 e0 5e 00 00 pushl 0x5ee0 a25: e8 b6 30 00 00 call 3ae0 <printf> if(exec("echo", echoargv) < 0){ a2a: 5a pop %edx a2b: 59 pop %ecx a2c: 68 e4 5e 00 00 push $0x5ee4 a31: 68 2d 3f 00 00 push $0x3f2d a36: e8 80 2f 00 00 call 39bb <exec> a3b: 83 c4 10 add $0x10,%esp a3e: 85 c0 test %eax,%eax a40: 78 02 js a44 <exectest+0x34> } a42: c9 leave a43: c3 ret printf(stdout, "exec echo failed\n"); a44: 50 push %eax a45: 50 push %eax a46: 68 6f 41 00 00 push $0x416f a4b: ff 35 e0 5e 00 00 pushl 0x5ee0 a51: e8 8a 30 00 00 call 3ae0 <printf> exit(); a56: e8 28 2f 00 00 call 3983 <exit> a5b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi a5f: 90 nop 00000a60 <pipe1>: { a60: f3 0f 1e fb endbr32 a64: 55 push %ebp a65: 89 e5 mov %esp,%ebp a67: 57 push %edi a68: 56 push %esi if(pipe(fds) != 0){ a69: 8d 45 e0 lea -0x20(%ebp),%eax { a6c: 53 push %ebx a6d: 83 ec 38 sub $0x38,%esp if(pipe(fds) != 0){ a70: 50 push %eax a71: e8 1d 2f 00 00 call 3993 <pipe> a76: 83 c4 10 add $0x10,%esp a79: 85 c0 test %eax,%eax a7b: 0f 85 38 01 00 00 jne bb9 <pipe1+0x159> pid = fork(); a81: e8 f5 2e 00 00 call 397b <fork> if(pid == 0){ a86: 85 c0 test %eax,%eax a88: 0f 84 8d 00 00 00 je b1b <pipe1+0xbb> } else if(pid > 0){ a8e: 0f 8e 38 01 00 00 jle bcc <pipe1+0x16c> close(fds[1]); a94: 83 ec 0c sub $0xc,%esp a97: ff 75 e4 pushl -0x1c(%ebp) seq = 0; a9a: 31 db xor %ebx,%ebx cc = 1; a9c: be 01 00 00 00 mov $0x1,%esi close(fds[1]); aa1: e8 05 2f 00 00 call 39ab <close> total = 0; aa6: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) while((n = read(fds[0], buf, cc)) > 0){ aad: 83 c4 10 add $0x10,%esp ab0: 83 ec 04 sub $0x4,%esp ab3: 56 push %esi ab4: 68 c0 86 00 00 push $0x86c0 ab9: ff 75 e0 pushl -0x20(%ebp) abc: e8 da 2e 00 00 call 399b <read> ac1: 83 c4 10 add $0x10,%esp ac4: 89 c7 mov %eax,%edi ac6: 85 c0 test %eax,%eax ac8: 0f 8e a7 00 00 00 jle b75 <pipe1+0x115> ace: 8d 0c 3b lea (%ebx,%edi,1),%ecx for(i = 0; i < n; i++){ ad1: 31 c0 xor %eax,%eax ad3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi ad7: 90 nop if((buf[i] & 0xff) != (seq++ & 0xff)){ ad8: 89 da mov %ebx,%edx ada: 83 c3 01 add $0x1,%ebx add: 38 90 c0 86 00 00 cmp %dl,0x86c0(%eax) ae3: 75 1c jne b01 <pipe1+0xa1> for(i = 0; i < n; i++){ ae5: 83 c0 01 add $0x1,%eax ae8: 39 d9 cmp %ebx,%ecx aea: 75 ec jne ad8 <pipe1+0x78> cc = cc * 2; aec: 01 f6 add %esi,%esi total += n; aee: 01 7d d4 add %edi,-0x2c(%ebp) af1: b8 00 20 00 00 mov $0x2000,%eax af6: 81 fe 00 20 00 00 cmp $0x2000,%esi afc: 0f 4f f0 cmovg %eax,%esi aff: eb af jmp ab0 <pipe1+0x50> printf(1, "pipe1 oops 2\n"); b01: 83 ec 08 sub $0x8,%esp b04: 68 9e 41 00 00 push $0x419e b09: 6a 01 push $0x1 b0b: e8 d0 2f 00 00 call 3ae0 <printf> return; b10: 83 c4 10 add $0x10,%esp } b13: 8d 65 f4 lea -0xc(%ebp),%esp b16: 5b pop %ebx b17: 5e pop %esi b18: 5f pop %edi b19: 5d pop %ebp b1a: c3 ret close(fds[0]); b1b: 83 ec 0c sub $0xc,%esp b1e: ff 75 e0 pushl -0x20(%ebp) seq = 0; b21: 31 db xor %ebx,%ebx close(fds[0]); b23: e8 83 2e 00 00 call 39ab <close> b28: 83 c4 10 add $0x10,%esp for(i = 0; i < 1033; i++) b2b: 31 c0 xor %eax,%eax b2d: 8d 76 00 lea 0x0(%esi),%esi buf[i] = seq++; b30: 8d 14 18 lea (%eax,%ebx,1),%edx for(i = 0; i < 1033; i++) b33: 83 c0 01 add $0x1,%eax buf[i] = seq++; b36: 88 90 bf 86 00 00 mov %dl,0x86bf(%eax) for(i = 0; i < 1033; i++) b3c: 3d 09 04 00 00 cmp $0x409,%eax b41: 75 ed jne b30 <pipe1+0xd0> if(write(fds[1], buf, 1033) != 1033){ b43: 83 ec 04 sub $0x4,%esp b46: 81 c3 09 04 00 00 add $0x409,%ebx b4c: 68 09 04 00 00 push $0x409 b51: 68 c0 86 00 00 push $0x86c0 b56: ff 75 e4 pushl -0x1c(%ebp) b59: e8 45 2e 00 00 call 39a3 <write> b5e: 83 c4 10 add $0x10,%esp b61: 3d 09 04 00 00 cmp $0x409,%eax b66: 75 77 jne bdf <pipe1+0x17f> for(n = 0; n < 5; n++){ b68: 81 fb 2d 14 00 00 cmp $0x142d,%ebx b6e: 75 bb jne b2b <pipe1+0xcb> exit(); b70: e8 0e 2e 00 00 call 3983 <exit> if(total != 5 * 1033){ b75: 81 7d d4 2d 14 00 00 cmpl $0x142d,-0x2c(%ebp) b7c: 75 26 jne ba4 <pipe1+0x144> close(fds[0]); b7e: 83 ec 0c sub $0xc,%esp b81: ff 75 e0 pushl -0x20(%ebp) b84: e8 22 2e 00 00 call 39ab <close> wait(); b89: e8 fd 2d 00 00 call 398b <wait> printf(1, "pipe1 ok\n"); b8e: 5a pop %edx b8f: 59 pop %ecx b90: 68 c3 41 00 00 push $0x41c3 b95: 6a 01 push $0x1 b97: e8 44 2f 00 00 call 3ae0 <printf> b9c: 83 c4 10 add $0x10,%esp b9f: e9 6f ff ff ff jmp b13 <pipe1+0xb3> printf(1, "pipe1 oops 3 total %d\n", total); ba4: 53 push %ebx ba5: ff 75 d4 pushl -0x2c(%ebp) ba8: 68 ac 41 00 00 push $0x41ac bad: 6a 01 push $0x1 baf: e8 2c 2f 00 00 call 3ae0 <printf> exit(); bb4: e8 ca 2d 00 00 call 3983 <exit> printf(1, "pipe() failed\n"); bb9: 57 push %edi bba: 57 push %edi bbb: 68 81 41 00 00 push $0x4181 bc0: 6a 01 push $0x1 bc2: e8 19 2f 00 00 call 3ae0 <printf> exit(); bc7: e8 b7 2d 00 00 call 3983 <exit> printf(1, "fork() failed\n"); bcc: 50 push %eax bcd: 50 push %eax bce: 68 cd 41 00 00 push $0x41cd bd3: 6a 01 push $0x1 bd5: e8 06 2f 00 00 call 3ae0 <printf> exit(); bda: e8 a4 2d 00 00 call 3983 <exit> printf(1, "pipe1 oops 1\n"); bdf: 56 push %esi be0: 56 push %esi be1: 68 90 41 00 00 push $0x4190 be6: 6a 01 push $0x1 be8: e8 f3 2e 00 00 call 3ae0 <printf> exit(); bed: e8 91 2d 00 00 call 3983 <exit> bf2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi bf9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000c00 <preempt>: { c00: f3 0f 1e fb endbr32 c04: 55 push %ebp c05: 89 e5 mov %esp,%ebp c07: 57 push %edi c08: 56 push %esi c09: 53 push %ebx c0a: 83 ec 24 sub $0x24,%esp printf(1, "preempt: "); c0d: 68 dc 41 00 00 push $0x41dc c12: 6a 01 push $0x1 c14: e8 c7 2e 00 00 call 3ae0 <printf> pid1 = fork(); c19: e8 5d 2d 00 00 call 397b <fork> if(pid1 == 0) c1e: 83 c4 10 add $0x10,%esp c21: 85 c0 test %eax,%eax c23: 75 0b jne c30 <preempt+0x30> for(;;) c25: eb fe jmp c25 <preempt+0x25> c27: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi c2e: 66 90 xchg %ax,%ax c30: 89 c7 mov %eax,%edi pid2 = fork(); c32: e8 44 2d 00 00 call 397b <fork> c37: 89 c6 mov %eax,%esi if(pid2 == 0) c39: 85 c0 test %eax,%eax c3b: 75 03 jne c40 <preempt+0x40> for(;;) c3d: eb fe jmp c3d <preempt+0x3d> c3f: 90 nop pipe(pfds); c40: 83 ec 0c sub $0xc,%esp c43: 8d 45 e0 lea -0x20(%ebp),%eax c46: 50 push %eax c47: e8 47 2d 00 00 call 3993 <pipe> pid3 = fork(); c4c: e8 2a 2d 00 00 call 397b <fork> if(pid3 == 0){ c51: 83 c4 10 add $0x10,%esp pid3 = fork(); c54: 89 c3 mov %eax,%ebx if(pid3 == 0){ c56: 85 c0 test %eax,%eax c58: 75 3e jne c98 <preempt+0x98> close(pfds[0]); c5a: 83 ec 0c sub $0xc,%esp c5d: ff 75 e0 pushl -0x20(%ebp) c60: e8 46 2d 00 00 call 39ab <close> if(write(pfds[1], "x", 1) != 1) c65: 83 c4 0c add $0xc,%esp c68: 6a 01 push $0x1 c6a: 68 a1 47 00 00 push $0x47a1 c6f: ff 75 e4 pushl -0x1c(%ebp) c72: e8 2c 2d 00 00 call 39a3 <write> c77: 83 c4 10 add $0x10,%esp c7a: 83 f8 01 cmp $0x1,%eax c7d: 0f 85 a4 00 00 00 jne d27 <preempt+0x127> close(pfds[1]); c83: 83 ec 0c sub $0xc,%esp c86: ff 75 e4 pushl -0x1c(%ebp) c89: e8 1d 2d 00 00 call 39ab <close> c8e: 83 c4 10 add $0x10,%esp for(;;) c91: eb fe jmp c91 <preempt+0x91> c93: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c97: 90 nop close(pfds[1]); c98: 83 ec 0c sub $0xc,%esp c9b: ff 75 e4 pushl -0x1c(%ebp) c9e: e8 08 2d 00 00 call 39ab <close> if(read(pfds[0], buf, sizeof(buf)) != 1){ ca3: 83 c4 0c add $0xc,%esp ca6: 68 00 20 00 00 push $0x2000 cab: 68 c0 86 00 00 push $0x86c0 cb0: ff 75 e0 pushl -0x20(%ebp) cb3: e8 e3 2c 00 00 call 399b <read> cb8: 83 c4 10 add $0x10,%esp cbb: 83 f8 01 cmp $0x1,%eax cbe: 75 7e jne d3e <preempt+0x13e> close(pfds[0]); cc0: 83 ec 0c sub $0xc,%esp cc3: ff 75 e0 pushl -0x20(%ebp) cc6: e8 e0 2c 00 00 call 39ab <close> printf(1, "kill... "); ccb: 58 pop %eax ccc: 5a pop %edx ccd: 68 0d 42 00 00 push $0x420d cd2: 6a 01 push $0x1 cd4: e8 07 2e 00 00 call 3ae0 <printf> kill(pid1); cd9: 89 3c 24 mov %edi,(%esp) cdc: e8 d2 2c 00 00 call 39b3 <kill> kill(pid2); ce1: 89 34 24 mov %esi,(%esp) ce4: e8 ca 2c 00 00 call 39b3 <kill> kill(pid3); ce9: 89 1c 24 mov %ebx,(%esp) cec: e8 c2 2c 00 00 call 39b3 <kill> printf(1, "wait... "); cf1: 59 pop %ecx cf2: 5b pop %ebx cf3: 68 16 42 00 00 push $0x4216 cf8: 6a 01 push $0x1 cfa: e8 e1 2d 00 00 call 3ae0 <printf> wait(); cff: e8 87 2c 00 00 call 398b <wait> wait(); d04: e8 82 2c 00 00 call 398b <wait> wait(); d09: e8 7d 2c 00 00 call 398b <wait> printf(1, "preempt ok\n"); d0e: 5e pop %esi d0f: 5f pop %edi d10: 68 1f 42 00 00 push $0x421f d15: 6a 01 push $0x1 d17: e8 c4 2d 00 00 call 3ae0 <printf> d1c: 83 c4 10 add $0x10,%esp } d1f: 8d 65 f4 lea -0xc(%ebp),%esp d22: 5b pop %ebx d23: 5e pop %esi d24: 5f pop %edi d25: 5d pop %ebp d26: c3 ret printf(1, "preempt write error"); d27: 83 ec 08 sub $0x8,%esp d2a: 68 e6 41 00 00 push $0x41e6 d2f: 6a 01 push $0x1 d31: e8 aa 2d 00 00 call 3ae0 <printf> d36: 83 c4 10 add $0x10,%esp d39: e9 45 ff ff ff jmp c83 <preempt+0x83> printf(1, "preempt read error"); d3e: 83 ec 08 sub $0x8,%esp d41: 68 fa 41 00 00 push $0x41fa d46: 6a 01 push $0x1 d48: e8 93 2d 00 00 call 3ae0 <printf> return; d4d: 83 c4 10 add $0x10,%esp d50: eb cd jmp d1f <preempt+0x11f> d52: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi d59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000d60 <exitwait>: { d60: f3 0f 1e fb endbr32 d64: 55 push %ebp d65: 89 e5 mov %esp,%ebp d67: 56 push %esi d68: be 64 00 00 00 mov $0x64,%esi d6d: 53 push %ebx d6e: eb 10 jmp d80 <exitwait+0x20> if(pid){ d70: 74 68 je dda <exitwait+0x7a> if(wait() != pid){ d72: e8 14 2c 00 00 call 398b <wait> d77: 39 d8 cmp %ebx,%eax d79: 75 2d jne da8 <exitwait+0x48> for(i = 0; i < 100; i++){ d7b: 83 ee 01 sub $0x1,%esi d7e: 74 41 je dc1 <exitwait+0x61> pid = fork(); d80: e8 f6 2b 00 00 call 397b <fork> d85: 89 c3 mov %eax,%ebx if(pid < 0){ d87: 85 c0 test %eax,%eax d89: 79 e5 jns d70 <exitwait+0x10> printf(1, "fork failed\n"); d8b: 83 ec 08 sub $0x8,%esp d8e: 68 89 4d 00 00 push $0x4d89 d93: 6a 01 push $0x1 d95: e8 46 2d 00 00 call 3ae0 <printf> return; d9a: 83 c4 10 add $0x10,%esp } d9d: 8d 65 f8 lea -0x8(%ebp),%esp da0: 5b pop %ebx da1: 5e pop %esi da2: 5d pop %ebp da3: c3 ret da4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(1, "wait wrong pid\n"); da8: 83 ec 08 sub $0x8,%esp dab: 68 2b 42 00 00 push $0x422b db0: 6a 01 push $0x1 db2: e8 29 2d 00 00 call 3ae0 <printf> return; db7: 83 c4 10 add $0x10,%esp } dba: 8d 65 f8 lea -0x8(%ebp),%esp dbd: 5b pop %ebx dbe: 5e pop %esi dbf: 5d pop %ebp dc0: c3 ret printf(1, "exitwait ok\n"); dc1: 83 ec 08 sub $0x8,%esp dc4: 68 3b 42 00 00 push $0x423b dc9: 6a 01 push $0x1 dcb: e8 10 2d 00 00 call 3ae0 <printf> dd0: 83 c4 10 add $0x10,%esp } dd3: 8d 65 f8 lea -0x8(%ebp),%esp dd6: 5b pop %ebx dd7: 5e pop %esi dd8: 5d pop %ebp dd9: c3 ret exit(); dda: e8 a4 2b 00 00 call 3983 <exit> ddf: 90 nop 00000de0 <mem>: { de0: f3 0f 1e fb endbr32 de4: 55 push %ebp de5: 89 e5 mov %esp,%ebp de7: 56 push %esi de8: 31 f6 xor %esi,%esi dea: 53 push %ebx printf(1, "mem test\n"); deb: 83 ec 08 sub $0x8,%esp dee: 68 48 42 00 00 push $0x4248 df3: 6a 01 push $0x1 df5: e8 e6 2c 00 00 call 3ae0 <printf> ppid = getpid(); dfa: e8 04 2c 00 00 call 3a03 <getpid> dff: 89 c3 mov %eax,%ebx if((pid = fork()) == 0){ e01: e8 75 2b 00 00 call 397b <fork> e06: 83 c4 10 add $0x10,%esp e09: 85 c0 test %eax,%eax e0b: 74 0f je e1c <mem+0x3c> e0d: e9 8e 00 00 00 jmp ea0 <mem+0xc0> e12: 8d b6 00 00 00 00 lea 0x0(%esi),%esi *(char**)m2 = m1; e18: 89 30 mov %esi,(%eax) e1a: 89 c6 mov %eax,%esi while((m2 = malloc(10001)) != 0){ e1c: 83 ec 0c sub $0xc,%esp e1f: 68 11 27 00 00 push $0x2711 e24: e8 17 2f 00 00 call 3d40 <malloc> e29: 83 c4 10 add $0x10,%esp e2c: 85 c0 test %eax,%eax e2e: 75 e8 jne e18 <mem+0x38> while(m1){ e30: 85 f6 test %esi,%esi e32: 74 18 je e4c <mem+0x6c> e34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi m2 = *(char**)m1; e38: 89 f0 mov %esi,%eax free(m1); e3a: 83 ec 0c sub $0xc,%esp m2 = *(char**)m1; e3d: 8b 36 mov (%esi),%esi free(m1); e3f: 50 push %eax e40: e8 6b 2e 00 00 call 3cb0 <free> while(m1){ e45: 83 c4 10 add $0x10,%esp e48: 85 f6 test %esi,%esi e4a: 75 ec jne e38 <mem+0x58> m1 = malloc(1024*20); e4c: 83 ec 0c sub $0xc,%esp e4f: 68 00 50 00 00 push $0x5000 e54: e8 e7 2e 00 00 call 3d40 <malloc> if(m1 == 0){ e59: 83 c4 10 add $0x10,%esp e5c: 85 c0 test %eax,%eax e5e: 74 20 je e80 <mem+0xa0> free(m1); e60: 83 ec 0c sub $0xc,%esp e63: 50 push %eax e64: e8 47 2e 00 00 call 3cb0 <free> printf(1, "mem ok\n"); e69: 58 pop %eax e6a: 5a pop %edx e6b: 68 6c 42 00 00 push $0x426c e70: 6a 01 push $0x1 e72: e8 69 2c 00 00 call 3ae0 <printf> exit(); e77: e8 07 2b 00 00 call 3983 <exit> e7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(1, "couldn't allocate mem?!!\n"); e80: 83 ec 08 sub $0x8,%esp e83: 68 52 42 00 00 push $0x4252 e88: 6a 01 push $0x1 e8a: e8 51 2c 00 00 call 3ae0 <printf> kill(ppid); e8f: 89 1c 24 mov %ebx,(%esp) e92: e8 1c 2b 00 00 call 39b3 <kill> exit(); e97: e8 e7 2a 00 00 call 3983 <exit> e9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } ea0: 8d 65 f8 lea -0x8(%ebp),%esp ea3: 5b pop %ebx ea4: 5e pop %esi ea5: 5d pop %ebp wait(); ea6: e9 e0 2a 00 00 jmp 398b <wait> eab: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi eaf: 90 nop 00000eb0 <sharedfd>: { eb0: f3 0f 1e fb endbr32 eb4: 55 push %ebp eb5: 89 e5 mov %esp,%ebp eb7: 57 push %edi eb8: 56 push %esi eb9: 53 push %ebx eba: 83 ec 34 sub $0x34,%esp printf(1, "sharedfd test\n"); ebd: 68 74 42 00 00 push $0x4274 ec2: 6a 01 push $0x1 ec4: e8 17 2c 00 00 call 3ae0 <printf> unlink("sharedfd"); ec9: c7 04 24 83 42 00 00 movl $0x4283,(%esp) ed0: e8 fe 2a 00 00 call 39d3 <unlink> fd = open("sharedfd", O_CREATE|O_RDWR); ed5: 5b pop %ebx ed6: 5e pop %esi ed7: 68 02 02 00 00 push $0x202 edc: 68 83 42 00 00 push $0x4283 ee1: e8 dd 2a 00 00 call 39c3 <open> if(fd < 0){ ee6: 83 c4 10 add $0x10,%esp ee9: 85 c0 test %eax,%eax eeb: 0f 88 26 01 00 00 js 1017 <sharedfd+0x167> ef1: 89 c7 mov %eax,%edi memset(buf, pid==0?'c':'p', sizeof(buf)); ef3: 8d 75 de lea -0x22(%ebp),%esi ef6: bb e8 03 00 00 mov $0x3e8,%ebx pid = fork(); efb: e8 7b 2a 00 00 call 397b <fork> memset(buf, pid==0?'c':'p', sizeof(buf)); f00: 83 f8 01 cmp $0x1,%eax pid = fork(); f03: 89 45 d4 mov %eax,-0x2c(%ebp) memset(buf, pid==0?'c':'p', sizeof(buf)); f06: 19 c0 sbb %eax,%eax f08: 83 ec 04 sub $0x4,%esp f0b: 83 e0 f3 and $0xfffffff3,%eax f0e: 6a 0a push $0xa f10: 83 c0 70 add $0x70,%eax f13: 50 push %eax f14: 56 push %esi f15: e8 c6 28 00 00 call 37e0 <memset> f1a: 83 c4 10 add $0x10,%esp f1d: eb 06 jmp f25 <sharedfd+0x75> f1f: 90 nop for(i = 0; i < 1000; i++){ f20: 83 eb 01 sub $0x1,%ebx f23: 74 26 je f4b <sharedfd+0x9b> if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ f25: 83 ec 04 sub $0x4,%esp f28: 6a 0a push $0xa f2a: 56 push %esi f2b: 57 push %edi f2c: e8 72 2a 00 00 call 39a3 <write> f31: 83 c4 10 add $0x10,%esp f34: 83 f8 0a cmp $0xa,%eax f37: 74 e7 je f20 <sharedfd+0x70> printf(1, "fstests: write sharedfd failed\n"); f39: 83 ec 08 sub $0x8,%esp f3c: 68 74 4f 00 00 push $0x4f74 f41: 6a 01 push $0x1 f43: e8 98 2b 00 00 call 3ae0 <printf> break; f48: 83 c4 10 add $0x10,%esp if(pid == 0) f4b: 8b 4d d4 mov -0x2c(%ebp),%ecx f4e: 85 c9 test %ecx,%ecx f50: 0f 84 f5 00 00 00 je 104b <sharedfd+0x19b> wait(); f56: e8 30 2a 00 00 call 398b <wait> close(fd); f5b: 83 ec 0c sub $0xc,%esp nc = np = 0; f5e: 31 db xor %ebx,%ebx close(fd); f60: 57 push %edi f61: 8d 7d e8 lea -0x18(%ebp),%edi f64: e8 42 2a 00 00 call 39ab <close> fd = open("sharedfd", 0); f69: 58 pop %eax f6a: 5a pop %edx f6b: 6a 00 push $0x0 f6d: 68 83 42 00 00 push $0x4283 f72: e8 4c 2a 00 00 call 39c3 <open> if(fd < 0){ f77: 83 c4 10 add $0x10,%esp nc = np = 0; f7a: 31 d2 xor %edx,%edx fd = open("sharedfd", 0); f7c: 89 45 d0 mov %eax,-0x30(%ebp) if(fd < 0){ f7f: 85 c0 test %eax,%eax f81: 0f 88 aa 00 00 00 js 1031 <sharedfd+0x181> f87: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi f8e: 66 90 xchg %ax,%ax while((n = read(fd, buf, sizeof(buf))) > 0){ f90: 83 ec 04 sub $0x4,%esp f93: 89 55 d4 mov %edx,-0x2c(%ebp) f96: 6a 0a push $0xa f98: 56 push %esi f99: ff 75 d0 pushl -0x30(%ebp) f9c: e8 fa 29 00 00 call 399b <read> fa1: 83 c4 10 add $0x10,%esp fa4: 85 c0 test %eax,%eax fa6: 7e 28 jle fd0 <sharedfd+0x120> for(i = 0; i < sizeof(buf); i++){ fa8: 8b 55 d4 mov -0x2c(%ebp),%edx fab: 89 f0 mov %esi,%eax fad: eb 13 jmp fc2 <sharedfd+0x112> faf: 90 nop np++; fb0: 80 f9 70 cmp $0x70,%cl fb3: 0f 94 c1 sete %cl fb6: 0f b6 c9 movzbl %cl,%ecx fb9: 01 cb add %ecx,%ebx for(i = 0; i < sizeof(buf); i++){ fbb: 83 c0 01 add $0x1,%eax fbe: 39 c7 cmp %eax,%edi fc0: 74 ce je f90 <sharedfd+0xe0> if(buf[i] == 'c') fc2: 0f b6 08 movzbl (%eax),%ecx fc5: 80 f9 63 cmp $0x63,%cl fc8: 75 e6 jne fb0 <sharedfd+0x100> nc++; fca: 83 c2 01 add $0x1,%edx if(buf[i] == 'p') fcd: eb ec jmp fbb <sharedfd+0x10b> fcf: 90 nop close(fd); fd0: 83 ec 0c sub $0xc,%esp fd3: ff 75 d0 pushl -0x30(%ebp) fd6: e8 d0 29 00 00 call 39ab <close> unlink("sharedfd"); fdb: c7 04 24 83 42 00 00 movl $0x4283,(%esp) fe2: e8 ec 29 00 00 call 39d3 <unlink> if(nc == 10000 && np == 10000){ fe7: 8b 55 d4 mov -0x2c(%ebp),%edx fea: 83 c4 10 add $0x10,%esp fed: 81 fa 10 27 00 00 cmp $0x2710,%edx ff3: 75 5b jne 1050 <sharedfd+0x1a0> ff5: 81 fb 10 27 00 00 cmp $0x2710,%ebx ffb: 75 53 jne 1050 <sharedfd+0x1a0> printf(1, "sharedfd ok\n"); ffd: 83 ec 08 sub $0x8,%esp 1000: 68 8c 42 00 00 push $0x428c 1005: 6a 01 push $0x1 1007: e8 d4 2a 00 00 call 3ae0 <printf> 100c: 83 c4 10 add $0x10,%esp } 100f: 8d 65 f4 lea -0xc(%ebp),%esp 1012: 5b pop %ebx 1013: 5e pop %esi 1014: 5f pop %edi 1015: 5d pop %ebp 1016: c3 ret printf(1, "fstests: cannot open sharedfd for writing"); 1017: 83 ec 08 sub $0x8,%esp 101a: 68 48 4f 00 00 push $0x4f48 101f: 6a 01 push $0x1 1021: e8 ba 2a 00 00 call 3ae0 <printf> return; 1026: 83 c4 10 add $0x10,%esp } 1029: 8d 65 f4 lea -0xc(%ebp),%esp 102c: 5b pop %ebx 102d: 5e pop %esi 102e: 5f pop %edi 102f: 5d pop %ebp 1030: c3 ret printf(1, "fstests: cannot open sharedfd for reading\n"); 1031: 83 ec 08 sub $0x8,%esp 1034: 68 94 4f 00 00 push $0x4f94 1039: 6a 01 push $0x1 103b: e8 a0 2a 00 00 call 3ae0 <printf> return; 1040: 83 c4 10 add $0x10,%esp } 1043: 8d 65 f4 lea -0xc(%ebp),%esp 1046: 5b pop %ebx 1047: 5e pop %esi 1048: 5f pop %edi 1049: 5d pop %ebp 104a: c3 ret exit(); 104b: e8 33 29 00 00 call 3983 <exit> printf(1, "sharedfd oops %d %d\n", nc, np); 1050: 53 push %ebx 1051: 52 push %edx 1052: 68 99 42 00 00 push $0x4299 1057: 6a 01 push $0x1 1059: e8 82 2a 00 00 call 3ae0 <printf> exit(); 105e: e8 20 29 00 00 call 3983 <exit> 1063: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 106a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00001070 <fourfiles>: { 1070: f3 0f 1e fb endbr32 1074: 55 push %ebp 1075: 89 e5 mov %esp,%ebp 1077: 57 push %edi 1078: 56 push %esi printf(1, "fourfiles test\n"); 1079: be ae 42 00 00 mov $0x42ae,%esi { 107e: 53 push %ebx for(pi = 0; pi < 4; pi++){ 107f: 31 db xor %ebx,%ebx { 1081: 83 ec 34 sub $0x34,%esp char *names[] = { "f0", "f1", "f2", "f3" }; 1084: c7 45 d8 ae 42 00 00 movl $0x42ae,-0x28(%ebp) printf(1, "fourfiles test\n"); 108b: 68 b4 42 00 00 push $0x42b4 1090: 6a 01 push $0x1 char *names[] = { "f0", "f1", "f2", "f3" }; 1092: c7 45 dc f7 43 00 00 movl $0x43f7,-0x24(%ebp) 1099: c7 45 e0 fb 43 00 00 movl $0x43fb,-0x20(%ebp) 10a0: c7 45 e4 b1 42 00 00 movl $0x42b1,-0x1c(%ebp) printf(1, "fourfiles test\n"); 10a7: e8 34 2a 00 00 call 3ae0 <printf> 10ac: 83 c4 10 add $0x10,%esp unlink(fname); 10af: 83 ec 0c sub $0xc,%esp 10b2: 56 push %esi 10b3: e8 1b 29 00 00 call 39d3 <unlink> pid = fork(); 10b8: e8 be 28 00 00 call 397b <fork> if(pid < 0){ 10bd: 83 c4 10 add $0x10,%esp 10c0: 85 c0 test %eax,%eax 10c2: 0f 88 60 01 00 00 js 1228 <fourfiles+0x1b8> if(pid == 0){ 10c8: 0f 84 e5 00 00 00 je 11b3 <fourfiles+0x143> for(pi = 0; pi < 4; pi++){ 10ce: 83 c3 01 add $0x1,%ebx 10d1: 83 fb 04 cmp $0x4,%ebx 10d4: 74 06 je 10dc <fourfiles+0x6c> 10d6: 8b 74 9d d8 mov -0x28(%ebp,%ebx,4),%esi 10da: eb d3 jmp 10af <fourfiles+0x3f> wait(); 10dc: e8 aa 28 00 00 call 398b <wait> for(i = 0; i < 2; i++){ 10e1: 31 f6 xor %esi,%esi wait(); 10e3: e8 a3 28 00 00 call 398b <wait> 10e8: e8 9e 28 00 00 call 398b <wait> 10ed: e8 99 28 00 00 call 398b <wait> fname = names[i]; 10f2: 8b 44 b5 d8 mov -0x28(%ebp,%esi,4),%eax fd = open(fname, 0); 10f6: 83 ec 08 sub $0x8,%esp total = 0; 10f9: 31 db xor %ebx,%ebx fd = open(fname, 0); 10fb: 6a 00 push $0x0 10fd: 50 push %eax fname = names[i]; 10fe: 89 45 d0 mov %eax,-0x30(%ebp) fd = open(fname, 0); 1101: e8 bd 28 00 00 call 39c3 <open> while((n = read(fd, buf, sizeof(buf))) > 0){ 1106: 83 c4 10 add $0x10,%esp fd = open(fname, 0); 1109: 89 45 d4 mov %eax,-0x2c(%ebp) while((n = read(fd, buf, sizeof(buf))) > 0){ 110c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1110: 83 ec 04 sub $0x4,%esp 1113: 68 00 20 00 00 push $0x2000 1118: 68 c0 86 00 00 push $0x86c0 111d: ff 75 d4 pushl -0x2c(%ebp) 1120: e8 76 28 00 00 call 399b <read> 1125: 83 c4 10 add $0x10,%esp 1128: 85 c0 test %eax,%eax 112a: 7e 22 jle 114e <fourfiles+0xde> for(j = 0; j < n; j++){ 112c: 31 d2 xor %edx,%edx 112e: 66 90 xchg %ax,%ax if(buf[j] != '0'+i){ 1130: 83 fe 01 cmp $0x1,%esi 1133: 0f be ba c0 86 00 00 movsbl 0x86c0(%edx),%edi 113a: 19 c9 sbb %ecx,%ecx 113c: 83 c1 31 add $0x31,%ecx 113f: 39 cf cmp %ecx,%edi 1141: 75 5c jne 119f <fourfiles+0x12f> for(j = 0; j < n; j++){ 1143: 83 c2 01 add $0x1,%edx 1146: 39 d0 cmp %edx,%eax 1148: 75 e6 jne 1130 <fourfiles+0xc0> total += n; 114a: 01 c3 add %eax,%ebx 114c: eb c2 jmp 1110 <fourfiles+0xa0> close(fd); 114e: 83 ec 0c sub $0xc,%esp 1151: ff 75 d4 pushl -0x2c(%ebp) 1154: e8 52 28 00 00 call 39ab <close> if(total != 12*500){ 1159: 83 c4 10 add $0x10,%esp 115c: 81 fb 70 17 00 00 cmp $0x1770,%ebx 1162: 0f 85 d4 00 00 00 jne 123c <fourfiles+0x1cc> unlink(fname); 1168: 83 ec 0c sub $0xc,%esp 116b: ff 75 d0 pushl -0x30(%ebp) 116e: e8 60 28 00 00 call 39d3 <unlink> for(i = 0; i < 2; i++){ 1173: 83 c4 10 add $0x10,%esp 1176: 83 fe 01 cmp $0x1,%esi 1179: 75 1a jne 1195 <fourfiles+0x125> printf(1, "fourfiles ok\n"); 117b: 83 ec 08 sub $0x8,%esp 117e: 68 f2 42 00 00 push $0x42f2 1183: 6a 01 push $0x1 1185: e8 56 29 00 00 call 3ae0 <printf> } 118a: 83 c4 10 add $0x10,%esp 118d: 8d 65 f4 lea -0xc(%ebp),%esp 1190: 5b pop %ebx 1191: 5e pop %esi 1192: 5f pop %edi 1193: 5d pop %ebp 1194: c3 ret 1195: be 01 00 00 00 mov $0x1,%esi 119a: e9 53 ff ff ff jmp 10f2 <fourfiles+0x82> printf(1, "wrong char\n"); 119f: 83 ec 08 sub $0x8,%esp 11a2: 68 d5 42 00 00 push $0x42d5 11a7: 6a 01 push $0x1 11a9: e8 32 29 00 00 call 3ae0 <printf> exit(); 11ae: e8 d0 27 00 00 call 3983 <exit> fd = open(fname, O_CREATE | O_RDWR); 11b3: 83 ec 08 sub $0x8,%esp 11b6: 68 02 02 00 00 push $0x202 11bb: 56 push %esi 11bc: e8 02 28 00 00 call 39c3 <open> if(fd < 0){ 11c1: 83 c4 10 add $0x10,%esp fd = open(fname, O_CREATE | O_RDWR); 11c4: 89 c6 mov %eax,%esi if(fd < 0){ 11c6: 85 c0 test %eax,%eax 11c8: 78 45 js 120f <fourfiles+0x19f> memset(buf, '0'+pi, 512); 11ca: 83 ec 04 sub $0x4,%esp 11cd: 83 c3 30 add $0x30,%ebx 11d0: 68 00 02 00 00 push $0x200 11d5: 53 push %ebx 11d6: bb 0c 00 00 00 mov $0xc,%ebx 11db: 68 c0 86 00 00 push $0x86c0 11e0: e8 fb 25 00 00 call 37e0 <memset> 11e5: 83 c4 10 add $0x10,%esp if((n = write(fd, buf, 500)) != 500){ 11e8: 83 ec 04 sub $0x4,%esp 11eb: 68 f4 01 00 00 push $0x1f4 11f0: 68 c0 86 00 00 push $0x86c0 11f5: 56 push %esi 11f6: e8 a8 27 00 00 call 39a3 <write> 11fb: 83 c4 10 add $0x10,%esp 11fe: 3d f4 01 00 00 cmp $0x1f4,%eax 1203: 75 4a jne 124f <fourfiles+0x1df> for(i = 0; i < 12; i++){ 1205: 83 eb 01 sub $0x1,%ebx 1208: 75 de jne 11e8 <fourfiles+0x178> exit(); 120a: e8 74 27 00 00 call 3983 <exit> printf(1, "create failed\n"); 120f: 51 push %ecx 1210: 51 push %ecx 1211: 68 4f 45 00 00 push $0x454f 1216: 6a 01 push $0x1 1218: e8 c3 28 00 00 call 3ae0 <printf> exit(); 121d: e8 61 27 00 00 call 3983 <exit> 1222: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printf(1, "fork failed\n"); 1228: 83 ec 08 sub $0x8,%esp 122b: 68 89 4d 00 00 push $0x4d89 1230: 6a 01 push $0x1 1232: e8 a9 28 00 00 call 3ae0 <printf> exit(); 1237: e8 47 27 00 00 call 3983 <exit> printf(1, "wrong length %d\n", total); 123c: 50 push %eax 123d: 53 push %ebx 123e: 68 e1 42 00 00 push $0x42e1 1243: 6a 01 push $0x1 1245: e8 96 28 00 00 call 3ae0 <printf> exit(); 124a: e8 34 27 00 00 call 3983 <exit> printf(1, "write failed %d\n", n); 124f: 52 push %edx 1250: 50 push %eax 1251: 68 c4 42 00 00 push $0x42c4 1256: 6a 01 push $0x1 1258: e8 83 28 00 00 call 3ae0 <printf> exit(); 125d: e8 21 27 00 00 call 3983 <exit> 1262: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1269: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00001270 <createdelete>: { 1270: f3 0f 1e fb endbr32 1274: 55 push %ebp 1275: 89 e5 mov %esp,%ebp 1277: 57 push %edi 1278: 56 push %esi 1279: 53 push %ebx for(pi = 0; pi < 4; pi++){ 127a: 31 db xor %ebx,%ebx { 127c: 83 ec 44 sub $0x44,%esp printf(1, "createdelete test\n"); 127f: 68 00 43 00 00 push $0x4300 1284: 6a 01 push $0x1 1286: e8 55 28 00 00 call 3ae0 <printf> 128b: 83 c4 10 add $0x10,%esp pid = fork(); 128e: e8 e8 26 00 00 call 397b <fork> if(pid < 0){ 1293: 85 c0 test %eax,%eax 1295: 0f 88 ce 01 00 00 js 1469 <createdelete+0x1f9> if(pid == 0){ 129b: 0f 84 17 01 00 00 je 13b8 <createdelete+0x148> for(pi = 0; pi < 4; pi++){ 12a1: 83 c3 01 add $0x1,%ebx 12a4: 83 fb 04 cmp $0x4,%ebx 12a7: 75 e5 jne 128e <createdelete+0x1e> wait(); 12a9: e8 dd 26 00 00 call 398b <wait> 12ae: 8d 7d c8 lea -0x38(%ebp),%edi name[0] = name[1] = name[2] = 0; 12b1: be ff ff ff ff mov $0xffffffff,%esi wait(); 12b6: e8 d0 26 00 00 call 398b <wait> 12bb: e8 cb 26 00 00 call 398b <wait> 12c0: e8 c6 26 00 00 call 398b <wait> name[0] = name[1] = name[2] = 0; 12c5: c6 45 ca 00 movb $0x0,-0x36(%ebp) for(i = 0; i < N; i++){ 12c9: 89 7d c0 mov %edi,-0x40(%ebp) 12cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(pi = 0; pi < 4; pi++){ 12d0: 8d 46 31 lea 0x31(%esi),%eax 12d3: 89 f7 mov %esi,%edi 12d5: 83 c6 01 add $0x1,%esi 12d8: 83 fe 09 cmp $0x9,%esi 12db: 88 45 c7 mov %al,-0x39(%ebp) 12de: 0f 9f c3 setg %bl 12e1: 85 f6 test %esi,%esi 12e3: 0f 94 c0 sete %al 12e6: 09 c3 or %eax,%ebx 12e8: 88 5d c6 mov %bl,-0x3a(%ebp) name[2] = '\0'; 12eb: bb 70 00 00 00 mov $0x70,%ebx fd = open(name, 0); 12f0: 83 ec 08 sub $0x8,%esp name[1] = '0' + i; 12f3: 0f b6 45 c7 movzbl -0x39(%ebp),%eax name[0] = 'p' + pi; 12f7: 88 5d c8 mov %bl,-0x38(%ebp) fd = open(name, 0); 12fa: 6a 00 push $0x0 12fc: ff 75 c0 pushl -0x40(%ebp) name[1] = '0' + i; 12ff: 88 45 c9 mov %al,-0x37(%ebp) fd = open(name, 0); 1302: e8 bc 26 00 00 call 39c3 <open> if((i == 0 || i >= N/2) && fd < 0){ 1307: 83 c4 10 add $0x10,%esp 130a: 80 7d c6 00 cmpb $0x0,-0x3a(%ebp) 130e: 0f 84 8c 00 00 00 je 13a0 <createdelete+0x130> 1314: 85 c0 test %eax,%eax 1316: 0f 88 21 01 00 00 js 143d <createdelete+0x1cd> } else if((i >= 1 && i < N/2) && fd >= 0){ 131c: 83 ff 08 cmp $0x8,%edi 131f: 0f 86 60 01 00 00 jbe 1485 <createdelete+0x215> close(fd); 1325: 83 ec 0c sub $0xc,%esp 1328: 50 push %eax 1329: e8 7d 26 00 00 call 39ab <close> 132e: 83 c4 10 add $0x10,%esp for(pi = 0; pi < 4; pi++){ 1331: 83 c3 01 add $0x1,%ebx 1334: 80 fb 74 cmp $0x74,%bl 1337: 75 b7 jne 12f0 <createdelete+0x80> for(i = 0; i < N; i++){ 1339: 83 fe 13 cmp $0x13,%esi 133c: 75 92 jne 12d0 <createdelete+0x60> 133e: 8b 7d c0 mov -0x40(%ebp),%edi 1341: be 70 00 00 00 mov $0x70,%esi 1346: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 134d: 8d 76 00 lea 0x0(%esi),%esi for(pi = 0; pi < 4; pi++){ 1350: 8d 46 c0 lea -0x40(%esi),%eax name[0] = name[1] = name[2] = 0; 1353: bb 04 00 00 00 mov $0x4,%ebx 1358: 88 45 c7 mov %al,-0x39(%ebp) unlink(name); 135b: 83 ec 0c sub $0xc,%esp name[0] = 'p' + i; 135e: 89 f0 mov %esi,%eax unlink(name); 1360: 57 push %edi name[0] = 'p' + i; 1361: 88 45 c8 mov %al,-0x38(%ebp) name[1] = '0' + i; 1364: 0f b6 45 c7 movzbl -0x39(%ebp),%eax 1368: 88 45 c9 mov %al,-0x37(%ebp) unlink(name); 136b: e8 63 26 00 00 call 39d3 <unlink> for(pi = 0; pi < 4; pi++){ 1370: 83 c4 10 add $0x10,%esp 1373: 83 eb 01 sub $0x1,%ebx 1376: 75 e3 jne 135b <createdelete+0xeb> for(i = 0; i < N; i++){ 1378: 83 c6 01 add $0x1,%esi 137b: 89 f0 mov %esi,%eax 137d: 3c 84 cmp $0x84,%al 137f: 75 cf jne 1350 <createdelete+0xe0> printf(1, "createdelete ok\n"); 1381: 83 ec 08 sub $0x8,%esp 1384: 68 13 43 00 00 push $0x4313 1389: 6a 01 push $0x1 138b: e8 50 27 00 00 call 3ae0 <printf> } 1390: 8d 65 f4 lea -0xc(%ebp),%esp 1393: 5b pop %ebx 1394: 5e pop %esi 1395: 5f pop %edi 1396: 5d pop %ebp 1397: c3 ret 1398: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 139f: 90 nop } else if((i >= 1 && i < N/2) && fd >= 0){ 13a0: 83 ff 08 cmp $0x8,%edi 13a3: 0f 86 d4 00 00 00 jbe 147d <createdelete+0x20d> if(fd >= 0) 13a9: 85 c0 test %eax,%eax 13ab: 78 84 js 1331 <createdelete+0xc1> 13ad: e9 73 ff ff ff jmp 1325 <createdelete+0xb5> 13b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi name[0] = 'p' + pi; 13b8: 83 c3 70 add $0x70,%ebx name[2] = '\0'; 13bb: c6 45 ca 00 movb $0x0,-0x36(%ebp) 13bf: 8d 7d c8 lea -0x38(%ebp),%edi name[0] = 'p' + pi; 13c2: 88 5d c8 mov %bl,-0x38(%ebp) name[2] = '\0'; 13c5: 31 db xor %ebx,%ebx 13c7: eb 0f jmp 13d8 <createdelete+0x168> 13c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(i = 0; i < N; i++){ 13d0: 83 fb 13 cmp $0x13,%ebx 13d3: 74 63 je 1438 <createdelete+0x1c8> 13d5: 83 c3 01 add $0x1,%ebx fd = open(name, O_CREATE | O_RDWR); 13d8: 83 ec 08 sub $0x8,%esp name[1] = '0' + i; 13db: 8d 43 30 lea 0x30(%ebx),%eax fd = open(name, O_CREATE | O_RDWR); 13de: 68 02 02 00 00 push $0x202 13e3: 57 push %edi name[1] = '0' + i; 13e4: 88 45 c9 mov %al,-0x37(%ebp) fd = open(name, O_CREATE | O_RDWR); 13e7: e8 d7 25 00 00 call 39c3 <open> if(fd < 0){ 13ec: 83 c4 10 add $0x10,%esp 13ef: 85 c0 test %eax,%eax 13f1: 78 62 js 1455 <createdelete+0x1e5> close(fd); 13f3: 83 ec 0c sub $0xc,%esp 13f6: 50 push %eax 13f7: e8 af 25 00 00 call 39ab <close> if(i > 0 && (i % 2 ) == 0){ 13fc: 83 c4 10 add $0x10,%esp 13ff: 85 db test %ebx,%ebx 1401: 74 d2 je 13d5 <createdelete+0x165> 1403: f6 c3 01 test $0x1,%bl 1406: 75 c8 jne 13d0 <createdelete+0x160> if(unlink(name) < 0){ 1408: 83 ec 0c sub $0xc,%esp name[1] = '0' + (i / 2); 140b: 89 d8 mov %ebx,%eax if(unlink(name) < 0){ 140d: 57 push %edi name[1] = '0' + (i / 2); 140e: d1 f8 sar %eax 1410: 83 c0 30 add $0x30,%eax 1413: 88 45 c9 mov %al,-0x37(%ebp) if(unlink(name) < 0){ 1416: e8 b8 25 00 00 call 39d3 <unlink> 141b: 83 c4 10 add $0x10,%esp 141e: 85 c0 test %eax,%eax 1420: 79 ae jns 13d0 <createdelete+0x160> printf(1, "unlink failed\n"); 1422: 52 push %edx 1423: 52 push %edx 1424: 68 01 3f 00 00 push $0x3f01 1429: 6a 01 push $0x1 142b: e8 b0 26 00 00 call 3ae0 <printf> exit(); 1430: e8 4e 25 00 00 call 3983 <exit> 1435: 8d 76 00 lea 0x0(%esi),%esi exit(); 1438: e8 46 25 00 00 call 3983 <exit> 143d: 8b 7d c0 mov -0x40(%ebp),%edi printf(1, "oops createdelete %s didn't exist\n", name); 1440: 83 ec 04 sub $0x4,%esp 1443: 57 push %edi 1444: 68 c0 4f 00 00 push $0x4fc0 1449: 6a 01 push $0x1 144b: e8 90 26 00 00 call 3ae0 <printf> exit(); 1450: e8 2e 25 00 00 call 3983 <exit> printf(1, "create failed\n"); 1455: 83 ec 08 sub $0x8,%esp 1458: 68 4f 45 00 00 push $0x454f 145d: 6a 01 push $0x1 145f: e8 7c 26 00 00 call 3ae0 <printf> exit(); 1464: e8 1a 25 00 00 call 3983 <exit> printf(1, "fork failed\n"); 1469: 83 ec 08 sub $0x8,%esp 146c: 68 89 4d 00 00 push $0x4d89 1471: 6a 01 push $0x1 1473: e8 68 26 00 00 call 3ae0 <printf> exit(); 1478: e8 06 25 00 00 call 3983 <exit> } else if((i >= 1 && i < N/2) && fd >= 0){ 147d: 85 c0 test %eax,%eax 147f: 0f 88 ac fe ff ff js 1331 <createdelete+0xc1> 1485: 8b 7d c0 mov -0x40(%ebp),%edi printf(1, "oops createdelete %s did exist\n", name); 1488: 50 push %eax 1489: 57 push %edi 148a: 68 e4 4f 00 00 push $0x4fe4 148f: 6a 01 push $0x1 1491: e8 4a 26 00 00 call 3ae0 <printf> exit(); 1496: e8 e8 24 00 00 call 3983 <exit> 149b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 149f: 90 nop 000014a0 <unlinkread>: { 14a0: f3 0f 1e fb endbr32 14a4: 55 push %ebp 14a5: 89 e5 mov %esp,%ebp 14a7: 56 push %esi 14a8: 53 push %ebx printf(1, "unlinkread test\n"); 14a9: 83 ec 08 sub $0x8,%esp 14ac: 68 24 43 00 00 push $0x4324 14b1: 6a 01 push $0x1 14b3: e8 28 26 00 00 call 3ae0 <printf> fd = open("unlinkread", O_CREATE | O_RDWR); 14b8: 5b pop %ebx 14b9: 5e pop %esi 14ba: 68 02 02 00 00 push $0x202 14bf: 68 35 43 00 00 push $0x4335 14c4: e8 fa 24 00 00 call 39c3 <open> if(fd < 0){ 14c9: 83 c4 10 add $0x10,%esp 14cc: 85 c0 test %eax,%eax 14ce: 0f 88 e6 00 00 00 js 15ba <unlinkread+0x11a> write(fd, "hello", 5); 14d4: 83 ec 04 sub $0x4,%esp 14d7: 89 c3 mov %eax,%ebx 14d9: 6a 05 push $0x5 14db: 68 5a 43 00 00 push $0x435a 14e0: 50 push %eax 14e1: e8 bd 24 00 00 call 39a3 <write> close(fd); 14e6: 89 1c 24 mov %ebx,(%esp) 14e9: e8 bd 24 00 00 call 39ab <close> fd = open("unlinkread", O_RDWR); 14ee: 58 pop %eax 14ef: 5a pop %edx 14f0: 6a 02 push $0x2 14f2: 68 35 43 00 00 push $0x4335 14f7: e8 c7 24 00 00 call 39c3 <open> if(fd < 0){ 14fc: 83 c4 10 add $0x10,%esp fd = open("unlinkread", O_RDWR); 14ff: 89 c3 mov %eax,%ebx if(fd < 0){ 1501: 85 c0 test %eax,%eax 1503: 0f 88 10 01 00 00 js 1619 <unlinkread+0x179> if(unlink("unlinkread") != 0){ 1509: 83 ec 0c sub $0xc,%esp 150c: 68 35 43 00 00 push $0x4335 1511: e8 bd 24 00 00 call 39d3 <unlink> 1516: 83 c4 10 add $0x10,%esp 1519: 85 c0 test %eax,%eax 151b: 0f 85 e5 00 00 00 jne 1606 <unlinkread+0x166> fd1 = open("unlinkread", O_CREATE | O_RDWR); 1521: 83 ec 08 sub $0x8,%esp 1524: 68 02 02 00 00 push $0x202 1529: 68 35 43 00 00 push $0x4335 152e: e8 90 24 00 00 call 39c3 <open> write(fd1, "yyy", 3); 1533: 83 c4 0c add $0xc,%esp 1536: 6a 03 push $0x3 fd1 = open("unlinkread", O_CREATE | O_RDWR); 1538: 89 c6 mov %eax,%esi write(fd1, "yyy", 3); 153a: 68 92 43 00 00 push $0x4392 153f: 50 push %eax 1540: e8 5e 24 00 00 call 39a3 <write> close(fd1); 1545: 89 34 24 mov %esi,(%esp) 1548: e8 5e 24 00 00 call 39ab <close> if(read(fd, buf, sizeof(buf)) != 5){ 154d: 83 c4 0c add $0xc,%esp 1550: 68 00 20 00 00 push $0x2000 1555: 68 c0 86 00 00 push $0x86c0 155a: 53 push %ebx 155b: e8 3b 24 00 00 call 399b <read> 1560: 83 c4 10 add $0x10,%esp 1563: 83 f8 05 cmp $0x5,%eax 1566: 0f 85 87 00 00 00 jne 15f3 <unlinkread+0x153> if(buf[0] != 'h'){ 156c: 80 3d c0 86 00 00 68 cmpb $0x68,0x86c0 1573: 75 6b jne 15e0 <unlinkread+0x140> if(write(fd, buf, 10) != 10){ 1575: 83 ec 04 sub $0x4,%esp 1578: 6a 0a push $0xa 157a: 68 c0 86 00 00 push $0x86c0 157f: 53 push %ebx 1580: e8 1e 24 00 00 call 39a3 <write> 1585: 83 c4 10 add $0x10,%esp 1588: 83 f8 0a cmp $0xa,%eax 158b: 75 40 jne 15cd <unlinkread+0x12d> close(fd); 158d: 83 ec 0c sub $0xc,%esp 1590: 53 push %ebx 1591: e8 15 24 00 00 call 39ab <close> unlink("unlinkread"); 1596: c7 04 24 35 43 00 00 movl $0x4335,(%esp) 159d: e8 31 24 00 00 call 39d3 <unlink> printf(1, "unlinkread ok\n"); 15a2: 58 pop %eax 15a3: 5a pop %edx 15a4: 68 dd 43 00 00 push $0x43dd 15a9: 6a 01 push $0x1 15ab: e8 30 25 00 00 call 3ae0 <printf> } 15b0: 83 c4 10 add $0x10,%esp 15b3: 8d 65 f8 lea -0x8(%ebp),%esp 15b6: 5b pop %ebx 15b7: 5e pop %esi 15b8: 5d pop %ebp 15b9: c3 ret printf(1, "create unlinkread failed\n"); 15ba: 51 push %ecx 15bb: 51 push %ecx 15bc: 68 40 43 00 00 push $0x4340 15c1: 6a 01 push $0x1 15c3: e8 18 25 00 00 call 3ae0 <printf> exit(); 15c8: e8 b6 23 00 00 call 3983 <exit> printf(1, "unlinkread write failed\n"); 15cd: 51 push %ecx 15ce: 51 push %ecx 15cf: 68 c4 43 00 00 push $0x43c4 15d4: 6a 01 push $0x1 15d6: e8 05 25 00 00 call 3ae0 <printf> exit(); 15db: e8 a3 23 00 00 call 3983 <exit> printf(1, "unlinkread wrong data\n"); 15e0: 53 push %ebx 15e1: 53 push %ebx 15e2: 68 ad 43 00 00 push $0x43ad 15e7: 6a 01 push $0x1 15e9: e8 f2 24 00 00 call 3ae0 <printf> exit(); 15ee: e8 90 23 00 00 call 3983 <exit> printf(1, "unlinkread read failed"); 15f3: 56 push %esi 15f4: 56 push %esi 15f5: 68 96 43 00 00 push $0x4396 15fa: 6a 01 push $0x1 15fc: e8 df 24 00 00 call 3ae0 <printf> exit(); 1601: e8 7d 23 00 00 call 3983 <exit> printf(1, "unlink unlinkread failed\n"); 1606: 50 push %eax 1607: 50 push %eax 1608: 68 78 43 00 00 push $0x4378 160d: 6a 01 push $0x1 160f: e8 cc 24 00 00 call 3ae0 <printf> exit(); 1614: e8 6a 23 00 00 call 3983 <exit> printf(1, "open unlinkread failed\n"); 1619: 50 push %eax 161a: 50 push %eax 161b: 68 60 43 00 00 push $0x4360 1620: 6a 01 push $0x1 1622: e8 b9 24 00 00 call 3ae0 <printf> exit(); 1627: e8 57 23 00 00 call 3983 <exit> 162c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00001630 <linktest>: { 1630: f3 0f 1e fb endbr32 1634: 55 push %ebp 1635: 89 e5 mov %esp,%ebp 1637: 53 push %ebx 1638: 83 ec 0c sub $0xc,%esp printf(1, "linktest\n"); 163b: 68 ec 43 00 00 push $0x43ec 1640: 6a 01 push $0x1 1642: e8 99 24 00 00 call 3ae0 <printf> unlink("lf1"); 1647: c7 04 24 f6 43 00 00 movl $0x43f6,(%esp) 164e: e8 80 23 00 00 call 39d3 <unlink> unlink("lf2"); 1653: c7 04 24 fa 43 00 00 movl $0x43fa,(%esp) 165a: e8 74 23 00 00 call 39d3 <unlink> fd = open("lf1", O_CREATE|O_RDWR); 165f: 58 pop %eax 1660: 5a pop %edx 1661: 68 02 02 00 00 push $0x202 1666: 68 f6 43 00 00 push $0x43f6 166b: e8 53 23 00 00 call 39c3 <open> if(fd < 0){ 1670: 83 c4 10 add $0x10,%esp 1673: 85 c0 test %eax,%eax 1675: 0f 88 1e 01 00 00 js 1799 <linktest+0x169> if(write(fd, "hello", 5) != 5){ 167b: 83 ec 04 sub $0x4,%esp 167e: 89 c3 mov %eax,%ebx 1680: 6a 05 push $0x5 1682: 68 5a 43 00 00 push $0x435a 1687: 50 push %eax 1688: e8 16 23 00 00 call 39a3 <write> 168d: 83 c4 10 add $0x10,%esp 1690: 83 f8 05 cmp $0x5,%eax 1693: 0f 85 98 01 00 00 jne 1831 <linktest+0x201> close(fd); 1699: 83 ec 0c sub $0xc,%esp 169c: 53 push %ebx 169d: e8 09 23 00 00 call 39ab <close> if(link("lf1", "lf2") < 0){ 16a2: 5b pop %ebx 16a3: 58 pop %eax 16a4: 68 fa 43 00 00 push $0x43fa 16a9: 68 f6 43 00 00 push $0x43f6 16ae: e8 30 23 00 00 call 39e3 <link> 16b3: 83 c4 10 add $0x10,%esp 16b6: 85 c0 test %eax,%eax 16b8: 0f 88 60 01 00 00 js 181e <linktest+0x1ee> unlink("lf1"); 16be: 83 ec 0c sub $0xc,%esp 16c1: 68 f6 43 00 00 push $0x43f6 16c6: e8 08 23 00 00 call 39d3 <unlink> if(open("lf1", 0) >= 0){ 16cb: 58 pop %eax 16cc: 5a pop %edx 16cd: 6a 00 push $0x0 16cf: 68 f6 43 00 00 push $0x43f6 16d4: e8 ea 22 00 00 call 39c3 <open> 16d9: 83 c4 10 add $0x10,%esp 16dc: 85 c0 test %eax,%eax 16de: 0f 89 27 01 00 00 jns 180b <linktest+0x1db> fd = open("lf2", 0); 16e4: 83 ec 08 sub $0x8,%esp 16e7: 6a 00 push $0x0 16e9: 68 fa 43 00 00 push $0x43fa 16ee: e8 d0 22 00 00 call 39c3 <open> if(fd < 0){ 16f3: 83 c4 10 add $0x10,%esp fd = open("lf2", 0); 16f6: 89 c3 mov %eax,%ebx if(fd < 0){ 16f8: 85 c0 test %eax,%eax 16fa: 0f 88 f8 00 00 00 js 17f8 <linktest+0x1c8> if(read(fd, buf, sizeof(buf)) != 5){ 1700: 83 ec 04 sub $0x4,%esp 1703: 68 00 20 00 00 push $0x2000 1708: 68 c0 86 00 00 push $0x86c0 170d: 50 push %eax 170e: e8 88 22 00 00 call 399b <read> 1713: 83 c4 10 add $0x10,%esp 1716: 83 f8 05 cmp $0x5,%eax 1719: 0f 85 c6 00 00 00 jne 17e5 <linktest+0x1b5> close(fd); 171f: 83 ec 0c sub $0xc,%esp 1722: 53 push %ebx 1723: e8 83 22 00 00 call 39ab <close> if(link("lf2", "lf2") >= 0){ 1728: 58 pop %eax 1729: 5a pop %edx 172a: 68 fa 43 00 00 push $0x43fa 172f: 68 fa 43 00 00 push $0x43fa 1734: e8 aa 22 00 00 call 39e3 <link> 1739: 83 c4 10 add $0x10,%esp 173c: 85 c0 test %eax,%eax 173e: 0f 89 8e 00 00 00 jns 17d2 <linktest+0x1a2> unlink("lf2"); 1744: 83 ec 0c sub $0xc,%esp 1747: 68 fa 43 00 00 push $0x43fa 174c: e8 82 22 00 00 call 39d3 <unlink> if(link("lf2", "lf1") >= 0){ 1751: 59 pop %ecx 1752: 5b pop %ebx 1753: 68 f6 43 00 00 push $0x43f6 1758: 68 fa 43 00 00 push $0x43fa 175d: e8 81 22 00 00 call 39e3 <link> 1762: 83 c4 10 add $0x10,%esp 1765: 85 c0 test %eax,%eax 1767: 79 56 jns 17bf <linktest+0x18f> if(link(".", "lf1") >= 0){ 1769: 83 ec 08 sub $0x8,%esp 176c: 68 f6 43 00 00 push $0x43f6 1771: 68 be 46 00 00 push $0x46be 1776: e8 68 22 00 00 call 39e3 <link> 177b: 83 c4 10 add $0x10,%esp 177e: 85 c0 test %eax,%eax 1780: 79 2a jns 17ac <linktest+0x17c> printf(1, "linktest ok\n"); 1782: 83 ec 08 sub $0x8,%esp 1785: 68 94 44 00 00 push $0x4494 178a: 6a 01 push $0x1 178c: e8 4f 23 00 00 call 3ae0 <printf> } 1791: 8b 5d fc mov -0x4(%ebp),%ebx 1794: 83 c4 10 add $0x10,%esp 1797: c9 leave 1798: c3 ret printf(1, "create lf1 failed\n"); 1799: 50 push %eax 179a: 50 push %eax 179b: 68 fe 43 00 00 push $0x43fe 17a0: 6a 01 push $0x1 17a2: e8 39 23 00 00 call 3ae0 <printf> exit(); 17a7: e8 d7 21 00 00 call 3983 <exit> printf(1, "link . lf1 succeeded! oops\n"); 17ac: 50 push %eax 17ad: 50 push %eax 17ae: 68 78 44 00 00 push $0x4478 17b3: 6a 01 push $0x1 17b5: e8 26 23 00 00 call 3ae0 <printf> exit(); 17ba: e8 c4 21 00 00 call 3983 <exit> printf(1, "link non-existant succeeded! oops\n"); 17bf: 52 push %edx 17c0: 52 push %edx 17c1: 68 2c 50 00 00 push $0x502c 17c6: 6a 01 push $0x1 17c8: e8 13 23 00 00 call 3ae0 <printf> exit(); 17cd: e8 b1 21 00 00 call 3983 <exit> printf(1, "link lf2 lf2 succeeded! oops\n"); 17d2: 50 push %eax 17d3: 50 push %eax 17d4: 68 5a 44 00 00 push $0x445a 17d9: 6a 01 push $0x1 17db: e8 00 23 00 00 call 3ae0 <printf> exit(); 17e0: e8 9e 21 00 00 call 3983 <exit> printf(1, "read lf2 failed\n"); 17e5: 51 push %ecx 17e6: 51 push %ecx 17e7: 68 49 44 00 00 push $0x4449 17ec: 6a 01 push $0x1 17ee: e8 ed 22 00 00 call 3ae0 <printf> exit(); 17f3: e8 8b 21 00 00 call 3983 <exit> printf(1, "open lf2 failed\n"); 17f8: 53 push %ebx 17f9: 53 push %ebx 17fa: 68 38 44 00 00 push $0x4438 17ff: 6a 01 push $0x1 1801: e8 da 22 00 00 call 3ae0 <printf> exit(); 1806: e8 78 21 00 00 call 3983 <exit> printf(1, "unlinked lf1 but it is still there!\n"); 180b: 50 push %eax 180c: 50 push %eax 180d: 68 04 50 00 00 push $0x5004 1812: 6a 01 push $0x1 1814: e8 c7 22 00 00 call 3ae0 <printf> exit(); 1819: e8 65 21 00 00 call 3983 <exit> printf(1, "link lf1 lf2 failed\n"); 181e: 51 push %ecx 181f: 51 push %ecx 1820: 68 23 44 00 00 push $0x4423 1825: 6a 01 push $0x1 1827: e8 b4 22 00 00 call 3ae0 <printf> exit(); 182c: e8 52 21 00 00 call 3983 <exit> printf(1, "write lf1 failed\n"); 1831: 50 push %eax 1832: 50 push %eax 1833: 68 11 44 00 00 push $0x4411 1838: 6a 01 push $0x1 183a: e8 a1 22 00 00 call 3ae0 <printf> exit(); 183f: e8 3f 21 00 00 call 3983 <exit> 1844: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 184b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 184f: 90 nop 00001850 <concreate>: { 1850: f3 0f 1e fb endbr32 1854: 55 push %ebp 1855: 89 e5 mov %esp,%ebp 1857: 57 push %edi 1858: 56 push %esi for(i = 0; i < 40; i++){ 1859: 31 f6 xor %esi,%esi { 185b: 53 push %ebx 185c: 8d 5d ad lea -0x53(%ebp),%ebx 185f: 83 ec 64 sub $0x64,%esp printf(1, "concreate test\n"); 1862: 68 a1 44 00 00 push $0x44a1 1867: 6a 01 push $0x1 1869: e8 72 22 00 00 call 3ae0 <printf> file[0] = 'C'; 186e: c6 45 ad 43 movb $0x43,-0x53(%ebp) file[2] = '\0'; 1872: 83 c4 10 add $0x10,%esp 1875: c6 45 af 00 movb $0x0,-0x51(%ebp) for(i = 0; i < 40; i++){ 1879: eb 48 jmp 18c3 <concreate+0x73> 187b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 187f: 90 nop 1880: 69 c6 ab aa aa aa imul $0xaaaaaaab,%esi,%eax if(pid && (i % 3) == 1){ 1886: 3d ab aa aa aa cmp $0xaaaaaaab,%eax 188b: 0f 83 af 00 00 00 jae 1940 <concreate+0xf0> fd = open(file, O_CREATE | O_RDWR); 1891: 83 ec 08 sub $0x8,%esp 1894: 68 02 02 00 00 push $0x202 1899: 53 push %ebx 189a: e8 24 21 00 00 call 39c3 <open> if(fd < 0){ 189f: 83 c4 10 add $0x10,%esp 18a2: 85 c0 test %eax,%eax 18a4: 78 5f js 1905 <concreate+0xb5> close(fd); 18a6: 83 ec 0c sub $0xc,%esp for(i = 0; i < 40; i++){ 18a9: 83 c6 01 add $0x1,%esi close(fd); 18ac: 50 push %eax 18ad: e8 f9 20 00 00 call 39ab <close> 18b2: 83 c4 10 add $0x10,%esp wait(); 18b5: e8 d1 20 00 00 call 398b <wait> for(i = 0; i < 40; i++){ 18ba: 83 fe 28 cmp $0x28,%esi 18bd: 0f 84 9f 00 00 00 je 1962 <concreate+0x112> unlink(file); 18c3: 83 ec 0c sub $0xc,%esp file[1] = '0' + i; 18c6: 8d 46 30 lea 0x30(%esi),%eax unlink(file); 18c9: 53 push %ebx file[1] = '0' + i; 18ca: 88 45 ae mov %al,-0x52(%ebp) unlink(file); 18cd: e8 01 21 00 00 call 39d3 <unlink> pid = fork(); 18d2: e8 a4 20 00 00 call 397b <fork> if(pid && (i % 3) == 1){ 18d7: 83 c4 10 add $0x10,%esp 18da: 85 c0 test %eax,%eax 18dc: 75 a2 jne 1880 <concreate+0x30> link("C0", file); 18de: 69 f6 cd cc cc cc imul $0xcccccccd,%esi,%esi } else if(pid == 0 && (i % 5) == 1){ 18e4: 81 fe cd cc cc cc cmp $0xcccccccd,%esi 18ea: 73 34 jae 1920 <concreate+0xd0> fd = open(file, O_CREATE | O_RDWR); 18ec: 83 ec 08 sub $0x8,%esp 18ef: 68 02 02 00 00 push $0x202 18f4: 53 push %ebx 18f5: e8 c9 20 00 00 call 39c3 <open> if(fd < 0){ 18fa: 83 c4 10 add $0x10,%esp 18fd: 85 c0 test %eax,%eax 18ff: 0f 89 39 02 00 00 jns 1b3e <concreate+0x2ee> printf(1, "concreate create %s failed\n", file); 1905: 83 ec 04 sub $0x4,%esp 1908: 53 push %ebx 1909: 68 b4 44 00 00 push $0x44b4 190e: 6a 01 push $0x1 1910: e8 cb 21 00 00 call 3ae0 <printf> exit(); 1915: e8 69 20 00 00 call 3983 <exit> 191a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi link("C0", file); 1920: 83 ec 08 sub $0x8,%esp 1923: 53 push %ebx 1924: 68 b1 44 00 00 push $0x44b1 1929: e8 b5 20 00 00 call 39e3 <link> 192e: 83 c4 10 add $0x10,%esp exit(); 1931: e8 4d 20 00 00 call 3983 <exit> 1936: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 193d: 8d 76 00 lea 0x0(%esi),%esi link("C0", file); 1940: 83 ec 08 sub $0x8,%esp for(i = 0; i < 40; i++){ 1943: 83 c6 01 add $0x1,%esi link("C0", file); 1946: 53 push %ebx 1947: 68 b1 44 00 00 push $0x44b1 194c: e8 92 20 00 00 call 39e3 <link> 1951: 83 c4 10 add $0x10,%esp wait(); 1954: e8 32 20 00 00 call 398b <wait> for(i = 0; i < 40; i++){ 1959: 83 fe 28 cmp $0x28,%esi 195c: 0f 85 61 ff ff ff jne 18c3 <concreate+0x73> memset(fa, 0, sizeof(fa)); 1962: 83 ec 04 sub $0x4,%esp 1965: 8d 45 c0 lea -0x40(%ebp),%eax 1968: 6a 28 push $0x28 196a: 6a 00 push $0x0 196c: 50 push %eax 196d: e8 6e 1e 00 00 call 37e0 <memset> fd = open(".", 0); 1972: 5e pop %esi 1973: 5f pop %edi 1974: 6a 00 push $0x0 1976: 68 be 46 00 00 push $0x46be 197b: 8d 7d b0 lea -0x50(%ebp),%edi 197e: e8 40 20 00 00 call 39c3 <open> n = 0; 1983: c7 45 a4 00 00 00 00 movl $0x0,-0x5c(%ebp) while(read(fd, &de, sizeof(de)) > 0){ 198a: 83 c4 10 add $0x10,%esp fd = open(".", 0); 198d: 89 c6 mov %eax,%esi while(read(fd, &de, sizeof(de)) > 0){ 198f: 90 nop 1990: 83 ec 04 sub $0x4,%esp 1993: 6a 10 push $0x10 1995: 57 push %edi 1996: 56 push %esi 1997: e8 ff 1f 00 00 call 399b <read> 199c: 83 c4 10 add $0x10,%esp 199f: 85 c0 test %eax,%eax 19a1: 7e 3d jle 19e0 <concreate+0x190> if(de.inum == 0) 19a3: 66 83 7d b0 00 cmpw $0x0,-0x50(%ebp) 19a8: 74 e6 je 1990 <concreate+0x140> if(de.name[0] == 'C' && de.name[2] == '\0'){ 19aa: 80 7d b2 43 cmpb $0x43,-0x4e(%ebp) 19ae: 75 e0 jne 1990 <concreate+0x140> 19b0: 80 7d b4 00 cmpb $0x0,-0x4c(%ebp) 19b4: 75 da jne 1990 <concreate+0x140> i = de.name[1] - '0'; 19b6: 0f be 45 b3 movsbl -0x4d(%ebp),%eax 19ba: 83 e8 30 sub $0x30,%eax if(i < 0 || i >= sizeof(fa)){ 19bd: 83 f8 27 cmp $0x27,%eax 19c0: 0f 87 60 01 00 00 ja 1b26 <concreate+0x2d6> if(fa[i]){ 19c6: 80 7c 05 c0 00 cmpb $0x0,-0x40(%ebp,%eax,1) 19cb: 0f 85 3d 01 00 00 jne 1b0e <concreate+0x2be> n++; 19d1: 83 45 a4 01 addl $0x1,-0x5c(%ebp) fa[i] = 1; 19d5: c6 44 05 c0 01 movb $0x1,-0x40(%ebp,%eax,1) n++; 19da: eb b4 jmp 1990 <concreate+0x140> 19dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi close(fd); 19e0: 83 ec 0c sub $0xc,%esp 19e3: 56 push %esi 19e4: e8 c2 1f 00 00 call 39ab <close> if(n != 40){ 19e9: 83 c4 10 add $0x10,%esp 19ec: 83 7d a4 28 cmpl $0x28,-0x5c(%ebp) 19f0: 0f 85 05 01 00 00 jne 1afb <concreate+0x2ab> for(i = 0; i < 40; i++){ 19f6: 31 f6 xor %esi,%esi 19f8: eb 4c jmp 1a46 <concreate+0x1f6> 19fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ((i % 3) == 1 && pid != 0)){ 1a00: 85 ff test %edi,%edi 1a02: 74 05 je 1a09 <concreate+0x1b9> 1a04: 83 f8 01 cmp $0x1,%eax 1a07: 74 6c je 1a75 <concreate+0x225> unlink(file); 1a09: 83 ec 0c sub $0xc,%esp 1a0c: 53 push %ebx 1a0d: e8 c1 1f 00 00 call 39d3 <unlink> unlink(file); 1a12: 89 1c 24 mov %ebx,(%esp) 1a15: e8 b9 1f 00 00 call 39d3 <unlink> unlink(file); 1a1a: 89 1c 24 mov %ebx,(%esp) 1a1d: e8 b1 1f 00 00 call 39d3 <unlink> unlink(file); 1a22: 89 1c 24 mov %ebx,(%esp) 1a25: e8 a9 1f 00 00 call 39d3 <unlink> 1a2a: 83 c4 10 add $0x10,%esp if(pid == 0) 1a2d: 85 ff test %edi,%edi 1a2f: 0f 84 fc fe ff ff je 1931 <concreate+0xe1> wait(); 1a35: e8 51 1f 00 00 call 398b <wait> for(i = 0; i < 40; i++){ 1a3a: 83 c6 01 add $0x1,%esi 1a3d: 83 fe 28 cmp $0x28,%esi 1a40: 0f 84 8a 00 00 00 je 1ad0 <concreate+0x280> file[1] = '0' + i; 1a46: 8d 46 30 lea 0x30(%esi),%eax 1a49: 88 45 ae mov %al,-0x52(%ebp) pid = fork(); 1a4c: e8 2a 1f 00 00 call 397b <fork> 1a51: 89 c7 mov %eax,%edi if(pid < 0){ 1a53: 85 c0 test %eax,%eax 1a55: 0f 88 8c 00 00 00 js 1ae7 <concreate+0x297> if(((i % 3) == 0 && pid == 0) || 1a5b: b8 ab aa aa aa mov $0xaaaaaaab,%eax 1a60: f7 e6 mul %esi 1a62: 89 d0 mov %edx,%eax 1a64: 83 e2 fe and $0xfffffffe,%edx 1a67: d1 e8 shr %eax 1a69: 01 c2 add %eax,%edx 1a6b: 89 f0 mov %esi,%eax 1a6d: 29 d0 sub %edx,%eax 1a6f: 89 c1 mov %eax,%ecx 1a71: 09 f9 or %edi,%ecx 1a73: 75 8b jne 1a00 <concreate+0x1b0> close(open(file, 0)); 1a75: 83 ec 08 sub $0x8,%esp 1a78: 6a 00 push $0x0 1a7a: 53 push %ebx 1a7b: e8 43 1f 00 00 call 39c3 <open> 1a80: 89 04 24 mov %eax,(%esp) 1a83: e8 23 1f 00 00 call 39ab <close> close(open(file, 0)); 1a88: 58 pop %eax 1a89: 5a pop %edx 1a8a: 6a 00 push $0x0 1a8c: 53 push %ebx 1a8d: e8 31 1f 00 00 call 39c3 <open> 1a92: 89 04 24 mov %eax,(%esp) 1a95: e8 11 1f 00 00 call 39ab <close> close(open(file, 0)); 1a9a: 59 pop %ecx 1a9b: 58 pop %eax 1a9c: 6a 00 push $0x0 1a9e: 53 push %ebx 1a9f: e8 1f 1f 00 00 call 39c3 <open> 1aa4: 89 04 24 mov %eax,(%esp) 1aa7: e8 ff 1e 00 00 call 39ab <close> close(open(file, 0)); 1aac: 58 pop %eax 1aad: 5a pop %edx 1aae: 6a 00 push $0x0 1ab0: 53 push %ebx 1ab1: e8 0d 1f 00 00 call 39c3 <open> 1ab6: 89 04 24 mov %eax,(%esp) 1ab9: e8 ed 1e 00 00 call 39ab <close> 1abe: 83 c4 10 add $0x10,%esp 1ac1: e9 67 ff ff ff jmp 1a2d <concreate+0x1dd> 1ac6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1acd: 8d 76 00 lea 0x0(%esi),%esi printf(1, "concreate ok\n"); 1ad0: 83 ec 08 sub $0x8,%esp 1ad3: 68 06 45 00 00 push $0x4506 1ad8: 6a 01 push $0x1 1ada: e8 01 20 00 00 call 3ae0 <printf> } 1adf: 8d 65 f4 lea -0xc(%ebp),%esp 1ae2: 5b pop %ebx 1ae3: 5e pop %esi 1ae4: 5f pop %edi 1ae5: 5d pop %ebp 1ae6: c3 ret printf(1, "fork failed\n"); 1ae7: 83 ec 08 sub $0x8,%esp 1aea: 68 89 4d 00 00 push $0x4d89 1aef: 6a 01 push $0x1 1af1: e8 ea 1f 00 00 call 3ae0 <printf> exit(); 1af6: e8 88 1e 00 00 call 3983 <exit> printf(1, "concreate not enough files in directory listing\n"); 1afb: 51 push %ecx 1afc: 51 push %ecx 1afd: 68 50 50 00 00 push $0x5050 1b02: 6a 01 push $0x1 1b04: e8 d7 1f 00 00 call 3ae0 <printf> exit(); 1b09: e8 75 1e 00 00 call 3983 <exit> printf(1, "concreate duplicate file %s\n", de.name); 1b0e: 83 ec 04 sub $0x4,%esp 1b11: 8d 45 b2 lea -0x4e(%ebp),%eax 1b14: 50 push %eax 1b15: 68 e9 44 00 00 push $0x44e9 1b1a: 6a 01 push $0x1 1b1c: e8 bf 1f 00 00 call 3ae0 <printf> exit(); 1b21: e8 5d 1e 00 00 call 3983 <exit> printf(1, "concreate weird file %s\n", de.name); 1b26: 83 ec 04 sub $0x4,%esp 1b29: 8d 45 b2 lea -0x4e(%ebp),%eax 1b2c: 50 push %eax 1b2d: 68 d0 44 00 00 push $0x44d0 1b32: 6a 01 push $0x1 1b34: e8 a7 1f 00 00 call 3ae0 <printf> exit(); 1b39: e8 45 1e 00 00 call 3983 <exit> close(fd); 1b3e: 83 ec 0c sub $0xc,%esp 1b41: 50 push %eax 1b42: e8 64 1e 00 00 call 39ab <close> 1b47: 83 c4 10 add $0x10,%esp 1b4a: e9 e2 fd ff ff jmp 1931 <concreate+0xe1> 1b4f: 90 nop 00001b50 <linkunlink>: { 1b50: f3 0f 1e fb endbr32 1b54: 55 push %ebp 1b55: 89 e5 mov %esp,%ebp 1b57: 57 push %edi 1b58: 56 push %esi 1b59: 53 push %ebx 1b5a: 83 ec 24 sub $0x24,%esp printf(1, "linkunlink test\n"); 1b5d: 68 14 45 00 00 push $0x4514 1b62: 6a 01 push $0x1 1b64: e8 77 1f 00 00 call 3ae0 <printf> unlink("x"); 1b69: c7 04 24 a1 47 00 00 movl $0x47a1,(%esp) 1b70: e8 5e 1e 00 00 call 39d3 <unlink> pid = fork(); 1b75: e8 01 1e 00 00 call 397b <fork> if(pid < 0){ 1b7a: 83 c4 10 add $0x10,%esp pid = fork(); 1b7d: 89 45 e4 mov %eax,-0x1c(%ebp) if(pid < 0){ 1b80: 85 c0 test %eax,%eax 1b82: 0f 88 b2 00 00 00 js 1c3a <linkunlink+0xea> unsigned int x = (pid ? 1 : 97); 1b88: 83 7d e4 01 cmpl $0x1,-0x1c(%ebp) 1b8c: bb 64 00 00 00 mov $0x64,%ebx if((x % 3) == 0){ 1b91: be ab aa aa aa mov $0xaaaaaaab,%esi unsigned int x = (pid ? 1 : 97); 1b96: 19 ff sbb %edi,%edi 1b98: 83 e7 60 and $0x60,%edi 1b9b: 83 c7 01 add $0x1,%edi 1b9e: eb 1a jmp 1bba <linkunlink+0x6a> } else if((x % 3) == 1){ 1ba0: 83 f8 01 cmp $0x1,%eax 1ba3: 74 7b je 1c20 <linkunlink+0xd0> unlink("x"); 1ba5: 83 ec 0c sub $0xc,%esp 1ba8: 68 a1 47 00 00 push $0x47a1 1bad: e8 21 1e 00 00 call 39d3 <unlink> 1bb2: 83 c4 10 add $0x10,%esp for(i = 0; i < 100; i++){ 1bb5: 83 eb 01 sub $0x1,%ebx 1bb8: 74 41 je 1bfb <linkunlink+0xab> x = x * 1103515245 + 12345; 1bba: 69 cf 6d 4e c6 41 imul $0x41c64e6d,%edi,%ecx 1bc0: 8d b9 39 30 00 00 lea 0x3039(%ecx),%edi if((x % 3) == 0){ 1bc6: 89 f8 mov %edi,%eax 1bc8: f7 e6 mul %esi 1bca: 89 d0 mov %edx,%eax 1bcc: 83 e2 fe and $0xfffffffe,%edx 1bcf: d1 e8 shr %eax 1bd1: 01 c2 add %eax,%edx 1bd3: 89 f8 mov %edi,%eax 1bd5: 29 d0 sub %edx,%eax 1bd7: 75 c7 jne 1ba0 <linkunlink+0x50> close(open("x", O_RDWR | O_CREATE)); 1bd9: 83 ec 08 sub $0x8,%esp 1bdc: 68 02 02 00 00 push $0x202 1be1: 68 a1 47 00 00 push $0x47a1 1be6: e8 d8 1d 00 00 call 39c3 <open> 1beb: 89 04 24 mov %eax,(%esp) 1bee: e8 b8 1d 00 00 call 39ab <close> 1bf3: 83 c4 10 add $0x10,%esp for(i = 0; i < 100; i++){ 1bf6: 83 eb 01 sub $0x1,%ebx 1bf9: 75 bf jne 1bba <linkunlink+0x6a> if(pid) 1bfb: 8b 45 e4 mov -0x1c(%ebp),%eax 1bfe: 85 c0 test %eax,%eax 1c00: 74 4b je 1c4d <linkunlink+0xfd> wait(); 1c02: e8 84 1d 00 00 call 398b <wait> printf(1, "linkunlink ok\n"); 1c07: 83 ec 08 sub $0x8,%esp 1c0a: 68 29 45 00 00 push $0x4529 1c0f: 6a 01 push $0x1 1c11: e8 ca 1e 00 00 call 3ae0 <printf> } 1c16: 8d 65 f4 lea -0xc(%ebp),%esp 1c19: 5b pop %ebx 1c1a: 5e pop %esi 1c1b: 5f pop %edi 1c1c: 5d pop %ebp 1c1d: c3 ret 1c1e: 66 90 xchg %ax,%ax link("cat", "x"); 1c20: 83 ec 08 sub $0x8,%esp 1c23: 68 a1 47 00 00 push $0x47a1 1c28: 68 25 45 00 00 push $0x4525 1c2d: e8 b1 1d 00 00 call 39e3 <link> 1c32: 83 c4 10 add $0x10,%esp 1c35: e9 7b ff ff ff jmp 1bb5 <linkunlink+0x65> printf(1, "fork failed\n"); 1c3a: 52 push %edx 1c3b: 52 push %edx 1c3c: 68 89 4d 00 00 push $0x4d89 1c41: 6a 01 push $0x1 1c43: e8 98 1e 00 00 call 3ae0 <printf> exit(); 1c48: e8 36 1d 00 00 call 3983 <exit> exit(); 1c4d: e8 31 1d 00 00 call 3983 <exit> 1c52: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1c59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00001c60 <bigdir>: { 1c60: f3 0f 1e fb endbr32 1c64: 55 push %ebp 1c65: 89 e5 mov %esp,%ebp 1c67: 57 push %edi 1c68: 56 push %esi 1c69: 53 push %ebx 1c6a: 83 ec 24 sub $0x24,%esp printf(1, "bigdir test\n"); 1c6d: 68 38 45 00 00 push $0x4538 1c72: 6a 01 push $0x1 1c74: e8 67 1e 00 00 call 3ae0 <printf> unlink("bd"); 1c79: c7 04 24 45 45 00 00 movl $0x4545,(%esp) 1c80: e8 4e 1d 00 00 call 39d3 <unlink> fd = open("bd", O_CREATE); 1c85: 5a pop %edx 1c86: 59 pop %ecx 1c87: 68 00 02 00 00 push $0x200 1c8c: 68 45 45 00 00 push $0x4545 1c91: e8 2d 1d 00 00 call 39c3 <open> if(fd < 0){ 1c96: 83 c4 10 add $0x10,%esp 1c99: 85 c0 test %eax,%eax 1c9b: 0f 88 ea 00 00 00 js 1d8b <bigdir+0x12b> close(fd); 1ca1: 83 ec 0c sub $0xc,%esp for(i = 0; i < 500; i++){ 1ca4: 31 f6 xor %esi,%esi 1ca6: 8d 7d de lea -0x22(%ebp),%edi close(fd); 1ca9: 50 push %eax 1caa: e8 fc 1c 00 00 call 39ab <close> 1caf: 83 c4 10 add $0x10,%esp 1cb2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi name[1] = '0' + (i / 64); 1cb8: 89 f0 mov %esi,%eax if(link("bd", name) != 0){ 1cba: 83 ec 08 sub $0x8,%esp name[0] = 'x'; 1cbd: c6 45 de 78 movb $0x78,-0x22(%ebp) name[1] = '0' + (i / 64); 1cc1: c1 f8 06 sar $0x6,%eax if(link("bd", name) != 0){ 1cc4: 57 push %edi name[1] = '0' + (i / 64); 1cc5: 83 c0 30 add $0x30,%eax if(link("bd", name) != 0){ 1cc8: 68 45 45 00 00 push $0x4545 name[1] = '0' + (i / 64); 1ccd: 88 45 df mov %al,-0x21(%ebp) name[2] = '0' + (i % 64); 1cd0: 89 f0 mov %esi,%eax 1cd2: 83 e0 3f and $0x3f,%eax name[3] = '\0'; 1cd5: c6 45 e1 00 movb $0x0,-0x1f(%ebp) name[2] = '0' + (i % 64); 1cd9: 83 c0 30 add $0x30,%eax 1cdc: 88 45 e0 mov %al,-0x20(%ebp) if(link("bd", name) != 0){ 1cdf: e8 ff 1c 00 00 call 39e3 <link> 1ce4: 83 c4 10 add $0x10,%esp 1ce7: 89 c3 mov %eax,%ebx 1ce9: 85 c0 test %eax,%eax 1ceb: 75 76 jne 1d63 <bigdir+0x103> for(i = 0; i < 500; i++){ 1ced: 83 c6 01 add $0x1,%esi 1cf0: 81 fe f4 01 00 00 cmp $0x1f4,%esi 1cf6: 75 c0 jne 1cb8 <bigdir+0x58> unlink("bd"); 1cf8: 83 ec 0c sub $0xc,%esp 1cfb: 68 45 45 00 00 push $0x4545 1d00: e8 ce 1c 00 00 call 39d3 <unlink> 1d05: 83 c4 10 add $0x10,%esp 1d08: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1d0f: 90 nop name[1] = '0' + (i / 64); 1d10: 89 d8 mov %ebx,%eax if(unlink(name) != 0){ 1d12: 83 ec 0c sub $0xc,%esp name[0] = 'x'; 1d15: c6 45 de 78 movb $0x78,-0x22(%ebp) name[1] = '0' + (i / 64); 1d19: c1 f8 06 sar $0x6,%eax if(unlink(name) != 0){ 1d1c: 57 push %edi name[1] = '0' + (i / 64); 1d1d: 83 c0 30 add $0x30,%eax name[3] = '\0'; 1d20: c6 45 e1 00 movb $0x0,-0x1f(%ebp) name[1] = '0' + (i / 64); 1d24: 88 45 df mov %al,-0x21(%ebp) name[2] = '0' + (i % 64); 1d27: 89 d8 mov %ebx,%eax 1d29: 83 e0 3f and $0x3f,%eax 1d2c: 83 c0 30 add $0x30,%eax 1d2f: 88 45 e0 mov %al,-0x20(%ebp) if(unlink(name) != 0){ 1d32: e8 9c 1c 00 00 call 39d3 <unlink> 1d37: 83 c4 10 add $0x10,%esp 1d3a: 85 c0 test %eax,%eax 1d3c: 75 39 jne 1d77 <bigdir+0x117> for(i = 0; i < 500; i++){ 1d3e: 83 c3 01 add $0x1,%ebx 1d41: 81 fb f4 01 00 00 cmp $0x1f4,%ebx 1d47: 75 c7 jne 1d10 <bigdir+0xb0> printf(1, "bigdir ok\n"); 1d49: 83 ec 08 sub $0x8,%esp 1d4c: 68 87 45 00 00 push $0x4587 1d51: 6a 01 push $0x1 1d53: e8 88 1d 00 00 call 3ae0 <printf> 1d58: 83 c4 10 add $0x10,%esp } 1d5b: 8d 65 f4 lea -0xc(%ebp),%esp 1d5e: 5b pop %ebx 1d5f: 5e pop %esi 1d60: 5f pop %edi 1d61: 5d pop %ebp 1d62: c3 ret printf(1, "bigdir link failed\n"); 1d63: 83 ec 08 sub $0x8,%esp 1d66: 68 5e 45 00 00 push $0x455e 1d6b: 6a 01 push $0x1 1d6d: e8 6e 1d 00 00 call 3ae0 <printf> exit(); 1d72: e8 0c 1c 00 00 call 3983 <exit> printf(1, "bigdir unlink failed"); 1d77: 83 ec 08 sub $0x8,%esp 1d7a: 68 72 45 00 00 push $0x4572 1d7f: 6a 01 push $0x1 1d81: e8 5a 1d 00 00 call 3ae0 <printf> exit(); 1d86: e8 f8 1b 00 00 call 3983 <exit> printf(1, "bigdir create failed\n"); 1d8b: 50 push %eax 1d8c: 50 push %eax 1d8d: 68 48 45 00 00 push $0x4548 1d92: 6a 01 push $0x1 1d94: e8 47 1d 00 00 call 3ae0 <printf> exit(); 1d99: e8 e5 1b 00 00 call 3983 <exit> 1d9e: 66 90 xchg %ax,%ax 00001da0 <subdir>: { 1da0: f3 0f 1e fb endbr32 1da4: 55 push %ebp 1da5: 89 e5 mov %esp,%ebp 1da7: 53 push %ebx 1da8: 83 ec 0c sub $0xc,%esp printf(1, "subdir test\n"); 1dab: 68 92 45 00 00 push $0x4592 1db0: 6a 01 push $0x1 1db2: e8 29 1d 00 00 call 3ae0 <printf> unlink("ff"); 1db7: c7 04 24 1b 46 00 00 movl $0x461b,(%esp) 1dbe: e8 10 1c 00 00 call 39d3 <unlink> if(mkdir("dd") != 0){ 1dc3: c7 04 24 b8 46 00 00 movl $0x46b8,(%esp) 1dca: e8 1c 1c 00 00 call 39eb <mkdir> 1dcf: 83 c4 10 add $0x10,%esp 1dd2: 85 c0 test %eax,%eax 1dd4: 0f 85 b3 05 00 00 jne 238d <subdir+0x5ed> fd = open("dd/ff", O_CREATE | O_RDWR); 1dda: 83 ec 08 sub $0x8,%esp 1ddd: 68 02 02 00 00 push $0x202 1de2: 68 f1 45 00 00 push $0x45f1 1de7: e8 d7 1b 00 00 call 39c3 <open> if(fd < 0){ 1dec: 83 c4 10 add $0x10,%esp fd = open("dd/ff", O_CREATE | O_RDWR); 1def: 89 c3 mov %eax,%ebx if(fd < 0){ 1df1: 85 c0 test %eax,%eax 1df3: 0f 88 81 05 00 00 js 237a <subdir+0x5da> write(fd, "ff", 2); 1df9: 83 ec 04 sub $0x4,%esp 1dfc: 6a 02 push $0x2 1dfe: 68 1b 46 00 00 push $0x461b 1e03: 50 push %eax 1e04: e8 9a 1b 00 00 call 39a3 <write> close(fd); 1e09: 89 1c 24 mov %ebx,(%esp) 1e0c: e8 9a 1b 00 00 call 39ab <close> if(unlink("dd") >= 0){ 1e11: c7 04 24 b8 46 00 00 movl $0x46b8,(%esp) 1e18: e8 b6 1b 00 00 call 39d3 <unlink> 1e1d: 83 c4 10 add $0x10,%esp 1e20: 85 c0 test %eax,%eax 1e22: 0f 89 3f 05 00 00 jns 2367 <subdir+0x5c7> if(mkdir("/dd/dd") != 0){ 1e28: 83 ec 0c sub $0xc,%esp 1e2b: 68 cc 45 00 00 push $0x45cc 1e30: e8 b6 1b 00 00 call 39eb <mkdir> 1e35: 83 c4 10 add $0x10,%esp 1e38: 85 c0 test %eax,%eax 1e3a: 0f 85 14 05 00 00 jne 2354 <subdir+0x5b4> fd = open("dd/dd/ff", O_CREATE | O_RDWR); 1e40: 83 ec 08 sub $0x8,%esp 1e43: 68 02 02 00 00 push $0x202 1e48: 68 ee 45 00 00 push $0x45ee 1e4d: e8 71 1b 00 00 call 39c3 <open> if(fd < 0){ 1e52: 83 c4 10 add $0x10,%esp fd = open("dd/dd/ff", O_CREATE | O_RDWR); 1e55: 89 c3 mov %eax,%ebx if(fd < 0){ 1e57: 85 c0 test %eax,%eax 1e59: 0f 88 24 04 00 00 js 2283 <subdir+0x4e3> write(fd, "FF", 2); 1e5f: 83 ec 04 sub $0x4,%esp 1e62: 6a 02 push $0x2 1e64: 68 0f 46 00 00 push $0x460f 1e69: 50 push %eax 1e6a: e8 34 1b 00 00 call 39a3 <write> close(fd); 1e6f: 89 1c 24 mov %ebx,(%esp) 1e72: e8 34 1b 00 00 call 39ab <close> fd = open("dd/dd/../ff", 0); 1e77: 58 pop %eax 1e78: 5a pop %edx 1e79: 6a 00 push $0x0 1e7b: 68 12 46 00 00 push $0x4612 1e80: e8 3e 1b 00 00 call 39c3 <open> if(fd < 0){ 1e85: 83 c4 10 add $0x10,%esp fd = open("dd/dd/../ff", 0); 1e88: 89 c3 mov %eax,%ebx if(fd < 0){ 1e8a: 85 c0 test %eax,%eax 1e8c: 0f 88 de 03 00 00 js 2270 <subdir+0x4d0> cc = read(fd, buf, sizeof(buf)); 1e92: 83 ec 04 sub $0x4,%esp 1e95: 68 00 20 00 00 push $0x2000 1e9a: 68 c0 86 00 00 push $0x86c0 1e9f: 50 push %eax 1ea0: e8 f6 1a 00 00 call 399b <read> if(cc != 2 || buf[0] != 'f'){ 1ea5: 83 c4 10 add $0x10,%esp 1ea8: 83 f8 02 cmp $0x2,%eax 1eab: 0f 85 3a 03 00 00 jne 21eb <subdir+0x44b> 1eb1: 80 3d c0 86 00 00 66 cmpb $0x66,0x86c0 1eb8: 0f 85 2d 03 00 00 jne 21eb <subdir+0x44b> close(fd); 1ebe: 83 ec 0c sub $0xc,%esp 1ec1: 53 push %ebx 1ec2: e8 e4 1a 00 00 call 39ab <close> if(link("dd/dd/ff", "dd/dd/ffff") != 0){ 1ec7: 59 pop %ecx 1ec8: 5b pop %ebx 1ec9: 68 52 46 00 00 push $0x4652 1ece: 68 ee 45 00 00 push $0x45ee 1ed3: e8 0b 1b 00 00 call 39e3 <link> 1ed8: 83 c4 10 add $0x10,%esp 1edb: 85 c0 test %eax,%eax 1edd: 0f 85 c6 03 00 00 jne 22a9 <subdir+0x509> if(unlink("dd/dd/ff") != 0){ 1ee3: 83 ec 0c sub $0xc,%esp 1ee6: 68 ee 45 00 00 push $0x45ee 1eeb: e8 e3 1a 00 00 call 39d3 <unlink> 1ef0: 83 c4 10 add $0x10,%esp 1ef3: 85 c0 test %eax,%eax 1ef5: 0f 85 16 03 00 00 jne 2211 <subdir+0x471> if(open("dd/dd/ff", O_RDONLY) >= 0){ 1efb: 83 ec 08 sub $0x8,%esp 1efe: 6a 00 push $0x0 1f00: 68 ee 45 00 00 push $0x45ee 1f05: e8 b9 1a 00 00 call 39c3 <open> 1f0a: 83 c4 10 add $0x10,%esp 1f0d: 85 c0 test %eax,%eax 1f0f: 0f 89 2c 04 00 00 jns 2341 <subdir+0x5a1> if(chdir("dd") != 0){ 1f15: 83 ec 0c sub $0xc,%esp 1f18: 68 b8 46 00 00 push $0x46b8 1f1d: e8 d1 1a 00 00 call 39f3 <chdir> 1f22: 83 c4 10 add $0x10,%esp 1f25: 85 c0 test %eax,%eax 1f27: 0f 85 01 04 00 00 jne 232e <subdir+0x58e> if(chdir("dd/../../dd") != 0){ 1f2d: 83 ec 0c sub $0xc,%esp 1f30: 68 86 46 00 00 push $0x4686 1f35: e8 b9 1a 00 00 call 39f3 <chdir> 1f3a: 83 c4 10 add $0x10,%esp 1f3d: 85 c0 test %eax,%eax 1f3f: 0f 85 b9 02 00 00 jne 21fe <subdir+0x45e> if(chdir("dd/../../../dd") != 0){ 1f45: 83 ec 0c sub $0xc,%esp 1f48: 68 ac 46 00 00 push $0x46ac 1f4d: e8 a1 1a 00 00 call 39f3 <chdir> 1f52: 83 c4 10 add $0x10,%esp 1f55: 85 c0 test %eax,%eax 1f57: 0f 85 a1 02 00 00 jne 21fe <subdir+0x45e> if(chdir("./..") != 0){ 1f5d: 83 ec 0c sub $0xc,%esp 1f60: 68 bb 46 00 00 push $0x46bb 1f65: e8 89 1a 00 00 call 39f3 <chdir> 1f6a: 83 c4 10 add $0x10,%esp 1f6d: 85 c0 test %eax,%eax 1f6f: 0f 85 21 03 00 00 jne 2296 <subdir+0x4f6> fd = open("dd/dd/ffff", 0); 1f75: 83 ec 08 sub $0x8,%esp 1f78: 6a 00 push $0x0 1f7a: 68 52 46 00 00 push $0x4652 1f7f: e8 3f 1a 00 00 call 39c3 <open> if(fd < 0){ 1f84: 83 c4 10 add $0x10,%esp fd = open("dd/dd/ffff", 0); 1f87: 89 c3 mov %eax,%ebx if(fd < 0){ 1f89: 85 c0 test %eax,%eax 1f8b: 0f 88 e0 04 00 00 js 2471 <subdir+0x6d1> if(read(fd, buf, sizeof(buf)) != 2){ 1f91: 83 ec 04 sub $0x4,%esp 1f94: 68 00 20 00 00 push $0x2000 1f99: 68 c0 86 00 00 push $0x86c0 1f9e: 50 push %eax 1f9f: e8 f7 19 00 00 call 399b <read> 1fa4: 83 c4 10 add $0x10,%esp 1fa7: 83 f8 02 cmp $0x2,%eax 1faa: 0f 85 ae 04 00 00 jne 245e <subdir+0x6be> close(fd); 1fb0: 83 ec 0c sub $0xc,%esp 1fb3: 53 push %ebx 1fb4: e8 f2 19 00 00 call 39ab <close> if(open("dd/dd/ff", O_RDONLY) >= 0){ 1fb9: 58 pop %eax 1fba: 5a pop %edx 1fbb: 6a 00 push $0x0 1fbd: 68 ee 45 00 00 push $0x45ee 1fc2: e8 fc 19 00 00 call 39c3 <open> 1fc7: 83 c4 10 add $0x10,%esp 1fca: 85 c0 test %eax,%eax 1fcc: 0f 89 65 02 00 00 jns 2237 <subdir+0x497> if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){ 1fd2: 83 ec 08 sub $0x8,%esp 1fd5: 68 02 02 00 00 push $0x202 1fda: 68 06 47 00 00 push $0x4706 1fdf: e8 df 19 00 00 call 39c3 <open> 1fe4: 83 c4 10 add $0x10,%esp 1fe7: 85 c0 test %eax,%eax 1fe9: 0f 89 35 02 00 00 jns 2224 <subdir+0x484> if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){ 1fef: 83 ec 08 sub $0x8,%esp 1ff2: 68 02 02 00 00 push $0x202 1ff7: 68 2b 47 00 00 push $0x472b 1ffc: e8 c2 19 00 00 call 39c3 <open> 2001: 83 c4 10 add $0x10,%esp 2004: 85 c0 test %eax,%eax 2006: 0f 89 0f 03 00 00 jns 231b <subdir+0x57b> if(open("dd", O_CREATE) >= 0){ 200c: 83 ec 08 sub $0x8,%esp 200f: 68 00 02 00 00 push $0x200 2014: 68 b8 46 00 00 push $0x46b8 2019: e8 a5 19 00 00 call 39c3 <open> 201e: 83 c4 10 add $0x10,%esp 2021: 85 c0 test %eax,%eax 2023: 0f 89 df 02 00 00 jns 2308 <subdir+0x568> if(open("dd", O_RDWR) >= 0){ 2029: 83 ec 08 sub $0x8,%esp 202c: 6a 02 push $0x2 202e: 68 b8 46 00 00 push $0x46b8 2033: e8 8b 19 00 00 call 39c3 <open> 2038: 83 c4 10 add $0x10,%esp 203b: 85 c0 test %eax,%eax 203d: 0f 89 b2 02 00 00 jns 22f5 <subdir+0x555> if(open("dd", O_WRONLY) >= 0){ 2043: 83 ec 08 sub $0x8,%esp 2046: 6a 01 push $0x1 2048: 68 b8 46 00 00 push $0x46b8 204d: e8 71 19 00 00 call 39c3 <open> 2052: 83 c4 10 add $0x10,%esp 2055: 85 c0 test %eax,%eax 2057: 0f 89 85 02 00 00 jns 22e2 <subdir+0x542> if(link("dd/ff/ff", "dd/dd/xx") == 0){ 205d: 83 ec 08 sub $0x8,%esp 2060: 68 9a 47 00 00 push $0x479a 2065: 68 06 47 00 00 push $0x4706 206a: e8 74 19 00 00 call 39e3 <link> 206f: 83 c4 10 add $0x10,%esp 2072: 85 c0 test %eax,%eax 2074: 0f 84 55 02 00 00 je 22cf <subdir+0x52f> if(link("dd/xx/ff", "dd/dd/xx") == 0){ 207a: 83 ec 08 sub $0x8,%esp 207d: 68 9a 47 00 00 push $0x479a 2082: 68 2b 47 00 00 push $0x472b 2087: e8 57 19 00 00 call 39e3 <link> 208c: 83 c4 10 add $0x10,%esp 208f: 85 c0 test %eax,%eax 2091: 0f 84 25 02 00 00 je 22bc <subdir+0x51c> if(link("dd/ff", "dd/dd/ffff") == 0){ 2097: 83 ec 08 sub $0x8,%esp 209a: 68 52 46 00 00 push $0x4652 209f: 68 f1 45 00 00 push $0x45f1 20a4: e8 3a 19 00 00 call 39e3 <link> 20a9: 83 c4 10 add $0x10,%esp 20ac: 85 c0 test %eax,%eax 20ae: 0f 84 a9 01 00 00 je 225d <subdir+0x4bd> if(mkdir("dd/ff/ff") == 0){ 20b4: 83 ec 0c sub $0xc,%esp 20b7: 68 06 47 00 00 push $0x4706 20bc: e8 2a 19 00 00 call 39eb <mkdir> 20c1: 83 c4 10 add $0x10,%esp 20c4: 85 c0 test %eax,%eax 20c6: 0f 84 7e 01 00 00 je 224a <subdir+0x4aa> if(mkdir("dd/xx/ff") == 0){ 20cc: 83 ec 0c sub $0xc,%esp 20cf: 68 2b 47 00 00 push $0x472b 20d4: e8 12 19 00 00 call 39eb <mkdir> 20d9: 83 c4 10 add $0x10,%esp 20dc: 85 c0 test %eax,%eax 20de: 0f 84 67 03 00 00 je 244b <subdir+0x6ab> if(mkdir("dd/dd/ffff") == 0){ 20e4: 83 ec 0c sub $0xc,%esp 20e7: 68 52 46 00 00 push $0x4652 20ec: e8 fa 18 00 00 call 39eb <mkdir> 20f1: 83 c4 10 add $0x10,%esp 20f4: 85 c0 test %eax,%eax 20f6: 0f 84 3c 03 00 00 je 2438 <subdir+0x698> if(unlink("dd/xx/ff") == 0){ 20fc: 83 ec 0c sub $0xc,%esp 20ff: 68 2b 47 00 00 push $0x472b 2104: e8 ca 18 00 00 call 39d3 <unlink> 2109: 83 c4 10 add $0x10,%esp 210c: 85 c0 test %eax,%eax 210e: 0f 84 11 03 00 00 je 2425 <subdir+0x685> if(unlink("dd/ff/ff") == 0){ 2114: 83 ec 0c sub $0xc,%esp 2117: 68 06 47 00 00 push $0x4706 211c: e8 b2 18 00 00 call 39d3 <unlink> 2121: 83 c4 10 add $0x10,%esp 2124: 85 c0 test %eax,%eax 2126: 0f 84 e6 02 00 00 je 2412 <subdir+0x672> if(chdir("dd/ff") == 0){ 212c: 83 ec 0c sub $0xc,%esp 212f: 68 f1 45 00 00 push $0x45f1 2134: e8 ba 18 00 00 call 39f3 <chdir> 2139: 83 c4 10 add $0x10,%esp 213c: 85 c0 test %eax,%eax 213e: 0f 84 bb 02 00 00 je 23ff <subdir+0x65f> if(chdir("dd/xx") == 0){ 2144: 83 ec 0c sub $0xc,%esp 2147: 68 9d 47 00 00 push $0x479d 214c: e8 a2 18 00 00 call 39f3 <chdir> 2151: 83 c4 10 add $0x10,%esp 2154: 85 c0 test %eax,%eax 2156: 0f 84 90 02 00 00 je 23ec <subdir+0x64c> if(unlink("dd/dd/ffff") != 0){ 215c: 83 ec 0c sub $0xc,%esp 215f: 68 52 46 00 00 push $0x4652 2164: e8 6a 18 00 00 call 39d3 <unlink> 2169: 83 c4 10 add $0x10,%esp 216c: 85 c0 test %eax,%eax 216e: 0f 85 9d 00 00 00 jne 2211 <subdir+0x471> if(unlink("dd/ff") != 0){ 2174: 83 ec 0c sub $0xc,%esp 2177: 68 f1 45 00 00 push $0x45f1 217c: e8 52 18 00 00 call 39d3 <unlink> 2181: 83 c4 10 add $0x10,%esp 2184: 85 c0 test %eax,%eax 2186: 0f 85 4d 02 00 00 jne 23d9 <subdir+0x639> if(unlink("dd") == 0){ 218c: 83 ec 0c sub $0xc,%esp 218f: 68 b8 46 00 00 push $0x46b8 2194: e8 3a 18 00 00 call 39d3 <unlink> 2199: 83 c4 10 add $0x10,%esp 219c: 85 c0 test %eax,%eax 219e: 0f 84 22 02 00 00 je 23c6 <subdir+0x626> if(unlink("dd/dd") < 0){ 21a4: 83 ec 0c sub $0xc,%esp 21a7: 68 cd 45 00 00 push $0x45cd 21ac: e8 22 18 00 00 call 39d3 <unlink> 21b1: 83 c4 10 add $0x10,%esp 21b4: 85 c0 test %eax,%eax 21b6: 0f 88 f7 01 00 00 js 23b3 <subdir+0x613> if(unlink("dd") < 0){ 21bc: 83 ec 0c sub $0xc,%esp 21bf: 68 b8 46 00 00 push $0x46b8 21c4: e8 0a 18 00 00 call 39d3 <unlink> 21c9: 83 c4 10 add $0x10,%esp 21cc: 85 c0 test %eax,%eax 21ce: 0f 88 cc 01 00 00 js 23a0 <subdir+0x600> printf(1, "subdir ok\n"); 21d4: 83 ec 08 sub $0x8,%esp 21d7: 68 9a 48 00 00 push $0x489a 21dc: 6a 01 push $0x1 21de: e8 fd 18 00 00 call 3ae0 <printf> } 21e3: 8b 5d fc mov -0x4(%ebp),%ebx 21e6: 83 c4 10 add $0x10,%esp 21e9: c9 leave 21ea: c3 ret printf(1, "dd/dd/../ff wrong content\n"); 21eb: 50 push %eax 21ec: 50 push %eax 21ed: 68 37 46 00 00 push $0x4637 21f2: 6a 01 push $0x1 21f4: e8 e7 18 00 00 call 3ae0 <printf> exit(); 21f9: e8 85 17 00 00 call 3983 <exit> printf(1, "chdir dd/../../dd failed\n"); 21fe: 50 push %eax 21ff: 50 push %eax 2200: 68 92 46 00 00 push $0x4692 2205: 6a 01 push $0x1 2207: e8 d4 18 00 00 call 3ae0 <printf> exit(); 220c: e8 72 17 00 00 call 3983 <exit> printf(1, "unlink dd/dd/ff failed\n"); 2211: 50 push %eax 2212: 50 push %eax 2213: 68 5d 46 00 00 push $0x465d 2218: 6a 01 push $0x1 221a: e8 c1 18 00 00 call 3ae0 <printf> exit(); 221f: e8 5f 17 00 00 call 3983 <exit> printf(1, "create dd/ff/ff succeeded!\n"); 2224: 51 push %ecx 2225: 51 push %ecx 2226: 68 0f 47 00 00 push $0x470f 222b: 6a 01 push $0x1 222d: e8 ae 18 00 00 call 3ae0 <printf> exit(); 2232: e8 4c 17 00 00 call 3983 <exit> printf(1, "open (unlinked) dd/dd/ff succeeded!\n"); 2237: 53 push %ebx 2238: 53 push %ebx 2239: 68 f4 50 00 00 push $0x50f4 223e: 6a 01 push $0x1 2240: e8 9b 18 00 00 call 3ae0 <printf> exit(); 2245: e8 39 17 00 00 call 3983 <exit> printf(1, "mkdir dd/ff/ff succeeded!\n"); 224a: 51 push %ecx 224b: 51 push %ecx 224c: 68 a3 47 00 00 push $0x47a3 2251: 6a 01 push $0x1 2253: e8 88 18 00 00 call 3ae0 <printf> exit(); 2258: e8 26 17 00 00 call 3983 <exit> printf(1, "link dd/ff dd/dd/ffff succeeded!\n"); 225d: 53 push %ebx 225e: 53 push %ebx 225f: 68 64 51 00 00 push $0x5164 2264: 6a 01 push $0x1 2266: e8 75 18 00 00 call 3ae0 <printf> exit(); 226b: e8 13 17 00 00 call 3983 <exit> printf(1, "open dd/dd/../ff failed\n"); 2270: 50 push %eax 2271: 50 push %eax 2272: 68 1e 46 00 00 push $0x461e 2277: 6a 01 push $0x1 2279: e8 62 18 00 00 call 3ae0 <printf> exit(); 227e: e8 00 17 00 00 call 3983 <exit> printf(1, "create dd/dd/ff failed\n"); 2283: 51 push %ecx 2284: 51 push %ecx 2285: 68 f7 45 00 00 push $0x45f7 228a: 6a 01 push $0x1 228c: e8 4f 18 00 00 call 3ae0 <printf> exit(); 2291: e8 ed 16 00 00 call 3983 <exit> printf(1, "chdir ./.. failed\n"); 2296: 50 push %eax 2297: 50 push %eax 2298: 68 c0 46 00 00 push $0x46c0 229d: 6a 01 push $0x1 229f: e8 3c 18 00 00 call 3ae0 <printf> exit(); 22a4: e8 da 16 00 00 call 3983 <exit> printf(1, "link dd/dd/ff dd/dd/ffff failed\n"); 22a9: 52 push %edx 22aa: 52 push %edx 22ab: 68 ac 50 00 00 push $0x50ac 22b0: 6a 01 push $0x1 22b2: e8 29 18 00 00 call 3ae0 <printf> exit(); 22b7: e8 c7 16 00 00 call 3983 <exit> printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n"); 22bc: 50 push %eax 22bd: 50 push %eax 22be: 68 40 51 00 00 push $0x5140 22c3: 6a 01 push $0x1 22c5: e8 16 18 00 00 call 3ae0 <printf> exit(); 22ca: e8 b4 16 00 00 call 3983 <exit> printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n"); 22cf: 50 push %eax 22d0: 50 push %eax 22d1: 68 1c 51 00 00 push $0x511c 22d6: 6a 01 push $0x1 22d8: e8 03 18 00 00 call 3ae0 <printf> exit(); 22dd: e8 a1 16 00 00 call 3983 <exit> printf(1, "open dd wronly succeeded!\n"); 22e2: 50 push %eax 22e3: 50 push %eax 22e4: 68 7f 47 00 00 push $0x477f 22e9: 6a 01 push $0x1 22eb: e8 f0 17 00 00 call 3ae0 <printf> exit(); 22f0: e8 8e 16 00 00 call 3983 <exit> printf(1, "open dd rdwr succeeded!\n"); 22f5: 50 push %eax 22f6: 50 push %eax 22f7: 68 66 47 00 00 push $0x4766 22fc: 6a 01 push $0x1 22fe: e8 dd 17 00 00 call 3ae0 <printf> exit(); 2303: e8 7b 16 00 00 call 3983 <exit> printf(1, "create dd succeeded!\n"); 2308: 50 push %eax 2309: 50 push %eax 230a: 68 50 47 00 00 push $0x4750 230f: 6a 01 push $0x1 2311: e8 ca 17 00 00 call 3ae0 <printf> exit(); 2316: e8 68 16 00 00 call 3983 <exit> printf(1, "create dd/xx/ff succeeded!\n"); 231b: 52 push %edx 231c: 52 push %edx 231d: 68 34 47 00 00 push $0x4734 2322: 6a 01 push $0x1 2324: e8 b7 17 00 00 call 3ae0 <printf> exit(); 2329: e8 55 16 00 00 call 3983 <exit> printf(1, "chdir dd failed\n"); 232e: 50 push %eax 232f: 50 push %eax 2330: 68 75 46 00 00 push $0x4675 2335: 6a 01 push $0x1 2337: e8 a4 17 00 00 call 3ae0 <printf> exit(); 233c: e8 42 16 00 00 call 3983 <exit> printf(1, "open (unlinked) dd/dd/ff succeeded\n"); 2341: 50 push %eax 2342: 50 push %eax 2343: 68 d0 50 00 00 push $0x50d0 2348: 6a 01 push $0x1 234a: e8 91 17 00 00 call 3ae0 <printf> exit(); 234f: e8 2f 16 00 00 call 3983 <exit> printf(1, "subdir mkdir dd/dd failed\n"); 2354: 53 push %ebx 2355: 53 push %ebx 2356: 68 d3 45 00 00 push $0x45d3 235b: 6a 01 push $0x1 235d: e8 7e 17 00 00 call 3ae0 <printf> exit(); 2362: e8 1c 16 00 00 call 3983 <exit> printf(1, "unlink dd (non-empty dir) succeeded!\n"); 2367: 50 push %eax 2368: 50 push %eax 2369: 68 84 50 00 00 push $0x5084 236e: 6a 01 push $0x1 2370: e8 6b 17 00 00 call 3ae0 <printf> exit(); 2375: e8 09 16 00 00 call 3983 <exit> printf(1, "create dd/ff failed\n"); 237a: 50 push %eax 237b: 50 push %eax 237c: 68 b7 45 00 00 push $0x45b7 2381: 6a 01 push $0x1 2383: e8 58 17 00 00 call 3ae0 <printf> exit(); 2388: e8 f6 15 00 00 call 3983 <exit> printf(1, "subdir mkdir dd failed\n"); 238d: 50 push %eax 238e: 50 push %eax 238f: 68 9f 45 00 00 push $0x459f 2394: 6a 01 push $0x1 2396: e8 45 17 00 00 call 3ae0 <printf> exit(); 239b: e8 e3 15 00 00 call 3983 <exit> printf(1, "unlink dd failed\n"); 23a0: 50 push %eax 23a1: 50 push %eax 23a2: 68 88 48 00 00 push $0x4888 23a7: 6a 01 push $0x1 23a9: e8 32 17 00 00 call 3ae0 <printf> exit(); 23ae: e8 d0 15 00 00 call 3983 <exit> printf(1, "unlink dd/dd failed\n"); 23b3: 52 push %edx 23b4: 52 push %edx 23b5: 68 73 48 00 00 push $0x4873 23ba: 6a 01 push $0x1 23bc: e8 1f 17 00 00 call 3ae0 <printf> exit(); 23c1: e8 bd 15 00 00 call 3983 <exit> printf(1, "unlink non-empty dd succeeded!\n"); 23c6: 51 push %ecx 23c7: 51 push %ecx 23c8: 68 88 51 00 00 push $0x5188 23cd: 6a 01 push $0x1 23cf: e8 0c 17 00 00 call 3ae0 <printf> exit(); 23d4: e8 aa 15 00 00 call 3983 <exit> printf(1, "unlink dd/ff failed\n"); 23d9: 53 push %ebx 23da: 53 push %ebx 23db: 68 5e 48 00 00 push $0x485e 23e0: 6a 01 push $0x1 23e2: e8 f9 16 00 00 call 3ae0 <printf> exit(); 23e7: e8 97 15 00 00 call 3983 <exit> printf(1, "chdir dd/xx succeeded!\n"); 23ec: 50 push %eax 23ed: 50 push %eax 23ee: 68 46 48 00 00 push $0x4846 23f3: 6a 01 push $0x1 23f5: e8 e6 16 00 00 call 3ae0 <printf> exit(); 23fa: e8 84 15 00 00 call 3983 <exit> printf(1, "chdir dd/ff succeeded!\n"); 23ff: 50 push %eax 2400: 50 push %eax 2401: 68 2e 48 00 00 push $0x482e 2406: 6a 01 push $0x1 2408: e8 d3 16 00 00 call 3ae0 <printf> exit(); 240d: e8 71 15 00 00 call 3983 <exit> printf(1, "unlink dd/ff/ff succeeded!\n"); 2412: 50 push %eax 2413: 50 push %eax 2414: 68 12 48 00 00 push $0x4812 2419: 6a 01 push $0x1 241b: e8 c0 16 00 00 call 3ae0 <printf> exit(); 2420: e8 5e 15 00 00 call 3983 <exit> printf(1, "unlink dd/xx/ff succeeded!\n"); 2425: 50 push %eax 2426: 50 push %eax 2427: 68 f6 47 00 00 push $0x47f6 242c: 6a 01 push $0x1 242e: e8 ad 16 00 00 call 3ae0 <printf> exit(); 2433: e8 4b 15 00 00 call 3983 <exit> printf(1, "mkdir dd/dd/ffff succeeded!\n"); 2438: 50 push %eax 2439: 50 push %eax 243a: 68 d9 47 00 00 push $0x47d9 243f: 6a 01 push $0x1 2441: e8 9a 16 00 00 call 3ae0 <printf> exit(); 2446: e8 38 15 00 00 call 3983 <exit> printf(1, "mkdir dd/xx/ff succeeded!\n"); 244b: 52 push %edx 244c: 52 push %edx 244d: 68 be 47 00 00 push $0x47be 2452: 6a 01 push $0x1 2454: e8 87 16 00 00 call 3ae0 <printf> exit(); 2459: e8 25 15 00 00 call 3983 <exit> printf(1, "read dd/dd/ffff wrong len\n"); 245e: 51 push %ecx 245f: 51 push %ecx 2460: 68 eb 46 00 00 push $0x46eb 2465: 6a 01 push $0x1 2467: e8 74 16 00 00 call 3ae0 <printf> exit(); 246c: e8 12 15 00 00 call 3983 <exit> printf(1, "open dd/dd/ffff failed\n"); 2471: 53 push %ebx 2472: 53 push %ebx 2473: 68 d3 46 00 00 push $0x46d3 2478: 6a 01 push $0x1 247a: e8 61 16 00 00 call 3ae0 <printf> exit(); 247f: e8 ff 14 00 00 call 3983 <exit> 2484: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 248b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 248f: 90 nop 00002490 <bigwrite>: { 2490: f3 0f 1e fb endbr32 2494: 55 push %ebp 2495: 89 e5 mov %esp,%ebp 2497: 56 push %esi 2498: 53 push %ebx for(sz = 499; sz < 12*512; sz += 471){ 2499: bb f3 01 00 00 mov $0x1f3,%ebx printf(1, "bigwrite test\n"); 249e: 83 ec 08 sub $0x8,%esp 24a1: 68 a5 48 00 00 push $0x48a5 24a6: 6a 01 push $0x1 24a8: e8 33 16 00 00 call 3ae0 <printf> unlink("bigwrite"); 24ad: c7 04 24 b4 48 00 00 movl $0x48b4,(%esp) 24b4: e8 1a 15 00 00 call 39d3 <unlink> 24b9: 83 c4 10 add $0x10,%esp 24bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi fd = open("bigwrite", O_CREATE | O_RDWR); 24c0: 83 ec 08 sub $0x8,%esp 24c3: 68 02 02 00 00 push $0x202 24c8: 68 b4 48 00 00 push $0x48b4 24cd: e8 f1 14 00 00 call 39c3 <open> if(fd < 0){ 24d2: 83 c4 10 add $0x10,%esp fd = open("bigwrite", O_CREATE | O_RDWR); 24d5: 89 c6 mov %eax,%esi if(fd < 0){ 24d7: 85 c0 test %eax,%eax 24d9: 78 7e js 2559 <bigwrite+0xc9> int cc = write(fd, buf, sz); 24db: 83 ec 04 sub $0x4,%esp 24de: 53 push %ebx 24df: 68 c0 86 00 00 push $0x86c0 24e4: 50 push %eax 24e5: e8 b9 14 00 00 call 39a3 <write> if(cc != sz){ 24ea: 83 c4 10 add $0x10,%esp 24ed: 39 d8 cmp %ebx,%eax 24ef: 75 55 jne 2546 <bigwrite+0xb6> int cc = write(fd, buf, sz); 24f1: 83 ec 04 sub $0x4,%esp 24f4: 53 push %ebx 24f5: 68 c0 86 00 00 push $0x86c0 24fa: 56 push %esi 24fb: e8 a3 14 00 00 call 39a3 <write> if(cc != sz){ 2500: 83 c4 10 add $0x10,%esp 2503: 39 d8 cmp %ebx,%eax 2505: 75 3f jne 2546 <bigwrite+0xb6> close(fd); 2507: 83 ec 0c sub $0xc,%esp for(sz = 499; sz < 12*512; sz += 471){ 250a: 81 c3 d7 01 00 00 add $0x1d7,%ebx close(fd); 2510: 56 push %esi 2511: e8 95 14 00 00 call 39ab <close> unlink("bigwrite"); 2516: c7 04 24 b4 48 00 00 movl $0x48b4,(%esp) 251d: e8 b1 14 00 00 call 39d3 <unlink> for(sz = 499; sz < 12*512; sz += 471){ 2522: 83 c4 10 add $0x10,%esp 2525: 81 fb 07 18 00 00 cmp $0x1807,%ebx 252b: 75 93 jne 24c0 <bigwrite+0x30> printf(1, "bigwrite ok\n"); 252d: 83 ec 08 sub $0x8,%esp 2530: 68 e7 48 00 00 push $0x48e7 2535: 6a 01 push $0x1 2537: e8 a4 15 00 00 call 3ae0 <printf> } 253c: 83 c4 10 add $0x10,%esp 253f: 8d 65 f8 lea -0x8(%ebp),%esp 2542: 5b pop %ebx 2543: 5e pop %esi 2544: 5d pop %ebp 2545: c3 ret printf(1, "write(%d) ret %d\n", sz, cc); 2546: 50 push %eax 2547: 53 push %ebx 2548: 68 d5 48 00 00 push $0x48d5 254d: 6a 01 push $0x1 254f: e8 8c 15 00 00 call 3ae0 <printf> exit(); 2554: e8 2a 14 00 00 call 3983 <exit> printf(1, "cannot create bigwrite\n"); 2559: 83 ec 08 sub $0x8,%esp 255c: 68 bd 48 00 00 push $0x48bd 2561: 6a 01 push $0x1 2563: e8 78 15 00 00 call 3ae0 <printf> exit(); 2568: e8 16 14 00 00 call 3983 <exit> 256d: 8d 76 00 lea 0x0(%esi),%esi 00002570 <bigfile>: { 2570: f3 0f 1e fb endbr32 2574: 55 push %ebp 2575: 89 e5 mov %esp,%ebp 2577: 57 push %edi 2578: 56 push %esi 2579: 53 push %ebx 257a: 83 ec 14 sub $0x14,%esp printf(1, "bigfile test\n"); 257d: 68 f4 48 00 00 push $0x48f4 2582: 6a 01 push $0x1 2584: e8 57 15 00 00 call 3ae0 <printf> unlink("bigfile"); 2589: c7 04 24 10 49 00 00 movl $0x4910,(%esp) 2590: e8 3e 14 00 00 call 39d3 <unlink> fd = open("bigfile", O_CREATE | O_RDWR); 2595: 58 pop %eax 2596: 5a pop %edx 2597: 68 02 02 00 00 push $0x202 259c: 68 10 49 00 00 push $0x4910 25a1: e8 1d 14 00 00 call 39c3 <open> if(fd < 0){ 25a6: 83 c4 10 add $0x10,%esp 25a9: 85 c0 test %eax,%eax 25ab: 0f 88 5a 01 00 00 js 270b <bigfile+0x19b> 25b1: 89 c6 mov %eax,%esi for(i = 0; i < 20; i++){ 25b3: 31 db xor %ebx,%ebx 25b5: 8d 76 00 lea 0x0(%esi),%esi memset(buf, i, 600); 25b8: 83 ec 04 sub $0x4,%esp 25bb: 68 58 02 00 00 push $0x258 25c0: 53 push %ebx 25c1: 68 c0 86 00 00 push $0x86c0 25c6: e8 15 12 00 00 call 37e0 <memset> if(write(fd, buf, 600) != 600){ 25cb: 83 c4 0c add $0xc,%esp 25ce: 68 58 02 00 00 push $0x258 25d3: 68 c0 86 00 00 push $0x86c0 25d8: 56 push %esi 25d9: e8 c5 13 00 00 call 39a3 <write> 25de: 83 c4 10 add $0x10,%esp 25e1: 3d 58 02 00 00 cmp $0x258,%eax 25e6: 0f 85 f8 00 00 00 jne 26e4 <bigfile+0x174> for(i = 0; i < 20; i++){ 25ec: 83 c3 01 add $0x1,%ebx 25ef: 83 fb 14 cmp $0x14,%ebx 25f2: 75 c4 jne 25b8 <bigfile+0x48> close(fd); 25f4: 83 ec 0c sub $0xc,%esp 25f7: 56 push %esi 25f8: e8 ae 13 00 00 call 39ab <close> fd = open("bigfile", 0); 25fd: 5e pop %esi 25fe: 5f pop %edi 25ff: 6a 00 push $0x0 2601: 68 10 49 00 00 push $0x4910 2606: e8 b8 13 00 00 call 39c3 <open> if(fd < 0){ 260b: 83 c4 10 add $0x10,%esp fd = open("bigfile", 0); 260e: 89 c6 mov %eax,%esi if(fd < 0){ 2610: 85 c0 test %eax,%eax 2612: 0f 88 e0 00 00 00 js 26f8 <bigfile+0x188> total = 0; 2618: 31 db xor %ebx,%ebx for(i = 0; ; i++){ 261a: 31 ff xor %edi,%edi 261c: eb 30 jmp 264e <bigfile+0xde> 261e: 66 90 xchg %ax,%ax if(cc != 300){ 2620: 3d 2c 01 00 00 cmp $0x12c,%eax 2625: 0f 85 91 00 00 00 jne 26bc <bigfile+0x14c> if(buf[0] != i/2 || buf[299] != i/2){ 262b: 89 fa mov %edi,%edx 262d: 0f be 05 c0 86 00 00 movsbl 0x86c0,%eax 2634: d1 fa sar %edx 2636: 39 d0 cmp %edx,%eax 2638: 75 6e jne 26a8 <bigfile+0x138> 263a: 0f be 15 eb 87 00 00 movsbl 0x87eb,%edx 2641: 39 d0 cmp %edx,%eax 2643: 75 63 jne 26a8 <bigfile+0x138> total += cc; 2645: 81 c3 2c 01 00 00 add $0x12c,%ebx for(i = 0; ; i++){ 264b: 83 c7 01 add $0x1,%edi cc = read(fd, buf, 300); 264e: 83 ec 04 sub $0x4,%esp 2651: 68 2c 01 00 00 push $0x12c 2656: 68 c0 86 00 00 push $0x86c0 265b: 56 push %esi 265c: e8 3a 13 00 00 call 399b <read> if(cc < 0){ 2661: 83 c4 10 add $0x10,%esp 2664: 85 c0 test %eax,%eax 2666: 78 68 js 26d0 <bigfile+0x160> if(cc == 0) 2668: 75 b6 jne 2620 <bigfile+0xb0> close(fd); 266a: 83 ec 0c sub $0xc,%esp 266d: 56 push %esi 266e: e8 38 13 00 00 call 39ab <close> if(total != 20*600){ 2673: 83 c4 10 add $0x10,%esp 2676: 81 fb e0 2e 00 00 cmp $0x2ee0,%ebx 267c: 0f 85 9c 00 00 00 jne 271e <bigfile+0x1ae> unlink("bigfile"); 2682: 83 ec 0c sub $0xc,%esp 2685: 68 10 49 00 00 push $0x4910 268a: e8 44 13 00 00 call 39d3 <unlink> printf(1, "bigfile test ok\n"); 268f: 58 pop %eax 2690: 5a pop %edx 2691: 68 9f 49 00 00 push $0x499f 2696: 6a 01 push $0x1 2698: e8 43 14 00 00 call 3ae0 <printf> } 269d: 83 c4 10 add $0x10,%esp 26a0: 8d 65 f4 lea -0xc(%ebp),%esp 26a3: 5b pop %ebx 26a4: 5e pop %esi 26a5: 5f pop %edi 26a6: 5d pop %ebp 26a7: c3 ret printf(1, "read bigfile wrong data\n"); 26a8: 83 ec 08 sub $0x8,%esp 26ab: 68 6c 49 00 00 push $0x496c 26b0: 6a 01 push $0x1 26b2: e8 29 14 00 00 call 3ae0 <printf> exit(); 26b7: e8 c7 12 00 00 call 3983 <exit> printf(1, "short read bigfile\n"); 26bc: 83 ec 08 sub $0x8,%esp 26bf: 68 58 49 00 00 push $0x4958 26c4: 6a 01 push $0x1 26c6: e8 15 14 00 00 call 3ae0 <printf> exit(); 26cb: e8 b3 12 00 00 call 3983 <exit> printf(1, "read bigfile failed\n"); 26d0: 83 ec 08 sub $0x8,%esp 26d3: 68 43 49 00 00 push $0x4943 26d8: 6a 01 push $0x1 26da: e8 01 14 00 00 call 3ae0 <printf> exit(); 26df: e8 9f 12 00 00 call 3983 <exit> printf(1, "write bigfile failed\n"); 26e4: 83 ec 08 sub $0x8,%esp 26e7: 68 18 49 00 00 push $0x4918 26ec: 6a 01 push $0x1 26ee: e8 ed 13 00 00 call 3ae0 <printf> exit(); 26f3: e8 8b 12 00 00 call 3983 <exit> printf(1, "cannot open bigfile\n"); 26f8: 53 push %ebx 26f9: 53 push %ebx 26fa: 68 2e 49 00 00 push $0x492e 26ff: 6a 01 push $0x1 2701: e8 da 13 00 00 call 3ae0 <printf> exit(); 2706: e8 78 12 00 00 call 3983 <exit> printf(1, "cannot create bigfile"); 270b: 50 push %eax 270c: 50 push %eax 270d: 68 02 49 00 00 push $0x4902 2712: 6a 01 push $0x1 2714: e8 c7 13 00 00 call 3ae0 <printf> exit(); 2719: e8 65 12 00 00 call 3983 <exit> printf(1, "read bigfile wrong total\n"); 271e: 51 push %ecx 271f: 51 push %ecx 2720: 68 85 49 00 00 push $0x4985 2725: 6a 01 push $0x1 2727: e8 b4 13 00 00 call 3ae0 <printf> exit(); 272c: e8 52 12 00 00 call 3983 <exit> 2731: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 2738: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 273f: 90 nop 00002740 <fourteen>: { 2740: f3 0f 1e fb endbr32 2744: 55 push %ebp 2745: 89 e5 mov %esp,%ebp 2747: 83 ec 10 sub $0x10,%esp printf(1, "fourteen test\n"); 274a: 68 b0 49 00 00 push $0x49b0 274f: 6a 01 push $0x1 2751: e8 8a 13 00 00 call 3ae0 <printf> if(mkdir("12345678901234") != 0){ 2756: c7 04 24 eb 49 00 00 movl $0x49eb,(%esp) 275d: e8 89 12 00 00 call 39eb <mkdir> 2762: 83 c4 10 add $0x10,%esp 2765: 85 c0 test %eax,%eax 2767: 0f 85 97 00 00 00 jne 2804 <fourteen+0xc4> if(mkdir("12345678901234/123456789012345") != 0){ 276d: 83 ec 0c sub $0xc,%esp 2770: 68 a8 51 00 00 push $0x51a8 2775: e8 71 12 00 00 call 39eb <mkdir> 277a: 83 c4 10 add $0x10,%esp 277d: 85 c0 test %eax,%eax 277f: 0f 85 de 00 00 00 jne 2863 <fourteen+0x123> fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); 2785: 83 ec 08 sub $0x8,%esp 2788: 68 00 02 00 00 push $0x200 278d: 68 f8 51 00 00 push $0x51f8 2792: e8 2c 12 00 00 call 39c3 <open> if(fd < 0){ 2797: 83 c4 10 add $0x10,%esp 279a: 85 c0 test %eax,%eax 279c: 0f 88 ae 00 00 00 js 2850 <fourteen+0x110> close(fd); 27a2: 83 ec 0c sub $0xc,%esp 27a5: 50 push %eax 27a6: e8 00 12 00 00 call 39ab <close> fd = open("12345678901234/12345678901234/12345678901234", 0); 27ab: 58 pop %eax 27ac: 5a pop %edx 27ad: 6a 00 push $0x0 27af: 68 68 52 00 00 push $0x5268 27b4: e8 0a 12 00 00 call 39c3 <open> if(fd < 0){ 27b9: 83 c4 10 add $0x10,%esp 27bc: 85 c0 test %eax,%eax 27be: 78 7d js 283d <fourteen+0xfd> close(fd); 27c0: 83 ec 0c sub $0xc,%esp 27c3: 50 push %eax 27c4: e8 e2 11 00 00 call 39ab <close> if(mkdir("12345678901234/12345678901234") == 0){ 27c9: c7 04 24 dc 49 00 00 movl $0x49dc,(%esp) 27d0: e8 16 12 00 00 call 39eb <mkdir> 27d5: 83 c4 10 add $0x10,%esp 27d8: 85 c0 test %eax,%eax 27da: 74 4e je 282a <fourteen+0xea> if(mkdir("123456789012345/12345678901234") == 0){ 27dc: 83 ec 0c sub $0xc,%esp 27df: 68 04 53 00 00 push $0x5304 27e4: e8 02 12 00 00 call 39eb <mkdir> 27e9: 83 c4 10 add $0x10,%esp 27ec: 85 c0 test %eax,%eax 27ee: 74 27 je 2817 <fourteen+0xd7> printf(1, "fourteen ok\n"); 27f0: 83 ec 08 sub $0x8,%esp 27f3: 68 fa 49 00 00 push $0x49fa 27f8: 6a 01 push $0x1 27fa: e8 e1 12 00 00 call 3ae0 <printf> } 27ff: 83 c4 10 add $0x10,%esp 2802: c9 leave 2803: c3 ret printf(1, "mkdir 12345678901234 failed\n"); 2804: 50 push %eax 2805: 50 push %eax 2806: 68 bf 49 00 00 push $0x49bf 280b: 6a 01 push $0x1 280d: e8 ce 12 00 00 call 3ae0 <printf> exit(); 2812: e8 6c 11 00 00 call 3983 <exit> printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n"); 2817: 50 push %eax 2818: 50 push %eax 2819: 68 24 53 00 00 push $0x5324 281e: 6a 01 push $0x1 2820: e8 bb 12 00 00 call 3ae0 <printf> exit(); 2825: e8 59 11 00 00 call 3983 <exit> printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n"); 282a: 52 push %edx 282b: 52 push %edx 282c: 68 d4 52 00 00 push $0x52d4 2831: 6a 01 push $0x1 2833: e8 a8 12 00 00 call 3ae0 <printf> exit(); 2838: e8 46 11 00 00 call 3983 <exit> printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n"); 283d: 51 push %ecx 283e: 51 push %ecx 283f: 68 98 52 00 00 push $0x5298 2844: 6a 01 push $0x1 2846: e8 95 12 00 00 call 3ae0 <printf> exit(); 284b: e8 33 11 00 00 call 3983 <exit> printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n"); 2850: 51 push %ecx 2851: 51 push %ecx 2852: 68 28 52 00 00 push $0x5228 2857: 6a 01 push $0x1 2859: e8 82 12 00 00 call 3ae0 <printf> exit(); 285e: e8 20 11 00 00 call 3983 <exit> printf(1, "mkdir 12345678901234/123456789012345 failed\n"); 2863: 50 push %eax 2864: 50 push %eax 2865: 68 c8 51 00 00 push $0x51c8 286a: 6a 01 push $0x1 286c: e8 6f 12 00 00 call 3ae0 <printf> exit(); 2871: e8 0d 11 00 00 call 3983 <exit> 2876: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 287d: 8d 76 00 lea 0x0(%esi),%esi 00002880 <rmdot>: { 2880: f3 0f 1e fb endbr32 2884: 55 push %ebp 2885: 89 e5 mov %esp,%ebp 2887: 83 ec 10 sub $0x10,%esp printf(1, "rmdot test\n"); 288a: 68 07 4a 00 00 push $0x4a07 288f: 6a 01 push $0x1 2891: e8 4a 12 00 00 call 3ae0 <printf> if(mkdir("dots") != 0){ 2896: c7 04 24 13 4a 00 00 movl $0x4a13,(%esp) 289d: e8 49 11 00 00 call 39eb <mkdir> 28a2: 83 c4 10 add $0x10,%esp 28a5: 85 c0 test %eax,%eax 28a7: 0f 85 b0 00 00 00 jne 295d <rmdot+0xdd> if(chdir("dots") != 0){ 28ad: 83 ec 0c sub $0xc,%esp 28b0: 68 13 4a 00 00 push $0x4a13 28b5: e8 39 11 00 00 call 39f3 <chdir> 28ba: 83 c4 10 add $0x10,%esp 28bd: 85 c0 test %eax,%eax 28bf: 0f 85 1d 01 00 00 jne 29e2 <rmdot+0x162> if(unlink(".") == 0){ 28c5: 83 ec 0c sub $0xc,%esp 28c8: 68 be 46 00 00 push $0x46be 28cd: e8 01 11 00 00 call 39d3 <unlink> 28d2: 83 c4 10 add $0x10,%esp 28d5: 85 c0 test %eax,%eax 28d7: 0f 84 f2 00 00 00 je 29cf <rmdot+0x14f> if(unlink("..") == 0){ 28dd: 83 ec 0c sub $0xc,%esp 28e0: 68 bd 46 00 00 push $0x46bd 28e5: e8 e9 10 00 00 call 39d3 <unlink> 28ea: 83 c4 10 add $0x10,%esp 28ed: 85 c0 test %eax,%eax 28ef: 0f 84 c7 00 00 00 je 29bc <rmdot+0x13c> if(chdir("/") != 0){ 28f5: 83 ec 0c sub $0xc,%esp 28f8: 68 91 3e 00 00 push $0x3e91 28fd: e8 f1 10 00 00 call 39f3 <chdir> 2902: 83 c4 10 add $0x10,%esp 2905: 85 c0 test %eax,%eax 2907: 0f 85 9c 00 00 00 jne 29a9 <rmdot+0x129> if(unlink("dots/.") == 0){ 290d: 83 ec 0c sub $0xc,%esp 2910: 68 5b 4a 00 00 push $0x4a5b 2915: e8 b9 10 00 00 call 39d3 <unlink> 291a: 83 c4 10 add $0x10,%esp 291d: 85 c0 test %eax,%eax 291f: 74 75 je 2996 <rmdot+0x116> if(unlink("dots/..") == 0){ 2921: 83 ec 0c sub $0xc,%esp 2924: 68 79 4a 00 00 push $0x4a79 2929: e8 a5 10 00 00 call 39d3 <unlink> 292e: 83 c4 10 add $0x10,%esp 2931: 85 c0 test %eax,%eax 2933: 74 4e je 2983 <rmdot+0x103> if(unlink("dots") != 0){ 2935: 83 ec 0c sub $0xc,%esp 2938: 68 13 4a 00 00 push $0x4a13 293d: e8 91 10 00 00 call 39d3 <unlink> 2942: 83 c4 10 add $0x10,%esp 2945: 85 c0 test %eax,%eax 2947: 75 27 jne 2970 <rmdot+0xf0> printf(1, "rmdot ok\n"); 2949: 83 ec 08 sub $0x8,%esp 294c: 68 ae 4a 00 00 push $0x4aae 2951: 6a 01 push $0x1 2953: e8 88 11 00 00 call 3ae0 <printf> } 2958: 83 c4 10 add $0x10,%esp 295b: c9 leave 295c: c3 ret printf(1, "mkdir dots failed\n"); 295d: 50 push %eax 295e: 50 push %eax 295f: 68 18 4a 00 00 push $0x4a18 2964: 6a 01 push $0x1 2966: e8 75 11 00 00 call 3ae0 <printf> exit(); 296b: e8 13 10 00 00 call 3983 <exit> printf(1, "unlink dots failed!\n"); 2970: 50 push %eax 2971: 50 push %eax 2972: 68 99 4a 00 00 push $0x4a99 2977: 6a 01 push $0x1 2979: e8 62 11 00 00 call 3ae0 <printf> exit(); 297e: e8 00 10 00 00 call 3983 <exit> printf(1, "unlink dots/.. worked!\n"); 2983: 52 push %edx 2984: 52 push %edx 2985: 68 81 4a 00 00 push $0x4a81 298a: 6a 01 push $0x1 298c: e8 4f 11 00 00 call 3ae0 <printf> exit(); 2991: e8 ed 0f 00 00 call 3983 <exit> printf(1, "unlink dots/. worked!\n"); 2996: 51 push %ecx 2997: 51 push %ecx 2998: 68 62 4a 00 00 push $0x4a62 299d: 6a 01 push $0x1 299f: e8 3c 11 00 00 call 3ae0 <printf> exit(); 29a4: e8 da 0f 00 00 call 3983 <exit> printf(1, "chdir / failed\n"); 29a9: 50 push %eax 29aa: 50 push %eax 29ab: 68 93 3e 00 00 push $0x3e93 29b0: 6a 01 push $0x1 29b2: e8 29 11 00 00 call 3ae0 <printf> exit(); 29b7: e8 c7 0f 00 00 call 3983 <exit> printf(1, "rm .. worked!\n"); 29bc: 50 push %eax 29bd: 50 push %eax 29be: 68 4c 4a 00 00 push $0x4a4c 29c3: 6a 01 push $0x1 29c5: e8 16 11 00 00 call 3ae0 <printf> exit(); 29ca: e8 b4 0f 00 00 call 3983 <exit> printf(1, "rm . worked!\n"); 29cf: 50 push %eax 29d0: 50 push %eax 29d1: 68 3e 4a 00 00 push $0x4a3e 29d6: 6a 01 push $0x1 29d8: e8 03 11 00 00 call 3ae0 <printf> exit(); 29dd: e8 a1 0f 00 00 call 3983 <exit> printf(1, "chdir dots failed\n"); 29e2: 50 push %eax 29e3: 50 push %eax 29e4: 68 2b 4a 00 00 push $0x4a2b 29e9: 6a 01 push $0x1 29eb: e8 f0 10 00 00 call 3ae0 <printf> exit(); 29f0: e8 8e 0f 00 00 call 3983 <exit> 29f5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 29fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00002a00 <dirfile>: { 2a00: f3 0f 1e fb endbr32 2a04: 55 push %ebp 2a05: 89 e5 mov %esp,%ebp 2a07: 53 push %ebx 2a08: 83 ec 0c sub $0xc,%esp printf(1, "dir vs file\n"); 2a0b: 68 b8 4a 00 00 push $0x4ab8 2a10: 6a 01 push $0x1 2a12: e8 c9 10 00 00 call 3ae0 <printf> fd = open("dirfile", O_CREATE); 2a17: 5b pop %ebx 2a18: 58 pop %eax 2a19: 68 00 02 00 00 push $0x200 2a1e: 68 c5 4a 00 00 push $0x4ac5 2a23: e8 9b 0f 00 00 call 39c3 <open> if(fd < 0){ 2a28: 83 c4 10 add $0x10,%esp 2a2b: 85 c0 test %eax,%eax 2a2d: 0f 88 43 01 00 00 js 2b76 <dirfile+0x176> close(fd); 2a33: 83 ec 0c sub $0xc,%esp 2a36: 50 push %eax 2a37: e8 6f 0f 00 00 call 39ab <close> if(chdir("dirfile") == 0){ 2a3c: c7 04 24 c5 4a 00 00 movl $0x4ac5,(%esp) 2a43: e8 ab 0f 00 00 call 39f3 <chdir> 2a48: 83 c4 10 add $0x10,%esp 2a4b: 85 c0 test %eax,%eax 2a4d: 0f 84 10 01 00 00 je 2b63 <dirfile+0x163> fd = open("dirfile/xx", 0); 2a53: 83 ec 08 sub $0x8,%esp 2a56: 6a 00 push $0x0 2a58: 68 fe 4a 00 00 push $0x4afe 2a5d: e8 61 0f 00 00 call 39c3 <open> if(fd >= 0){ 2a62: 83 c4 10 add $0x10,%esp 2a65: 85 c0 test %eax,%eax 2a67: 0f 89 e3 00 00 00 jns 2b50 <dirfile+0x150> fd = open("dirfile/xx", O_CREATE); 2a6d: 83 ec 08 sub $0x8,%esp 2a70: 68 00 02 00 00 push $0x200 2a75: 68 fe 4a 00 00 push $0x4afe 2a7a: e8 44 0f 00 00 call 39c3 <open> if(fd >= 0){ 2a7f: 83 c4 10 add $0x10,%esp 2a82: 85 c0 test %eax,%eax 2a84: 0f 89 c6 00 00 00 jns 2b50 <dirfile+0x150> if(mkdir("dirfile/xx") == 0){ 2a8a: 83 ec 0c sub $0xc,%esp 2a8d: 68 fe 4a 00 00 push $0x4afe 2a92: e8 54 0f 00 00 call 39eb <mkdir> 2a97: 83 c4 10 add $0x10,%esp 2a9a: 85 c0 test %eax,%eax 2a9c: 0f 84 46 01 00 00 je 2be8 <dirfile+0x1e8> if(unlink("dirfile/xx") == 0){ 2aa2: 83 ec 0c sub $0xc,%esp 2aa5: 68 fe 4a 00 00 push $0x4afe 2aaa: e8 24 0f 00 00 call 39d3 <unlink> 2aaf: 83 c4 10 add $0x10,%esp 2ab2: 85 c0 test %eax,%eax 2ab4: 0f 84 1b 01 00 00 je 2bd5 <dirfile+0x1d5> if(link("README", "dirfile/xx") == 0){ 2aba: 83 ec 08 sub $0x8,%esp 2abd: 68 fe 4a 00 00 push $0x4afe 2ac2: 68 62 4b 00 00 push $0x4b62 2ac7: e8 17 0f 00 00 call 39e3 <link> 2acc: 83 c4 10 add $0x10,%esp 2acf: 85 c0 test %eax,%eax 2ad1: 0f 84 eb 00 00 00 je 2bc2 <dirfile+0x1c2> if(unlink("dirfile") != 0){ 2ad7: 83 ec 0c sub $0xc,%esp 2ada: 68 c5 4a 00 00 push $0x4ac5 2adf: e8 ef 0e 00 00 call 39d3 <unlink> 2ae4: 83 c4 10 add $0x10,%esp 2ae7: 85 c0 test %eax,%eax 2ae9: 0f 85 c0 00 00 00 jne 2baf <dirfile+0x1af> fd = open(".", O_RDWR); 2aef: 83 ec 08 sub $0x8,%esp 2af2: 6a 02 push $0x2 2af4: 68 be 46 00 00 push $0x46be 2af9: e8 c5 0e 00 00 call 39c3 <open> if(fd >= 0){ 2afe: 83 c4 10 add $0x10,%esp 2b01: 85 c0 test %eax,%eax 2b03: 0f 89 93 00 00 00 jns 2b9c <dirfile+0x19c> fd = open(".", 0); 2b09: 83 ec 08 sub $0x8,%esp 2b0c: 6a 00 push $0x0 2b0e: 68 be 46 00 00 push $0x46be 2b13: e8 ab 0e 00 00 call 39c3 <open> if(write(fd, "x", 1) > 0){ 2b18: 83 c4 0c add $0xc,%esp 2b1b: 6a 01 push $0x1 fd = open(".", 0); 2b1d: 89 c3 mov %eax,%ebx if(write(fd, "x", 1) > 0){ 2b1f: 68 a1 47 00 00 push $0x47a1 2b24: 50 push %eax 2b25: e8 79 0e 00 00 call 39a3 <write> 2b2a: 83 c4 10 add $0x10,%esp 2b2d: 85 c0 test %eax,%eax 2b2f: 7f 58 jg 2b89 <dirfile+0x189> close(fd); 2b31: 83 ec 0c sub $0xc,%esp 2b34: 53 push %ebx 2b35: e8 71 0e 00 00 call 39ab <close> printf(1, "dir vs file OK\n"); 2b3a: 58 pop %eax 2b3b: 5a pop %edx 2b3c: 68 95 4b 00 00 push $0x4b95 2b41: 6a 01 push $0x1 2b43: e8 98 0f 00 00 call 3ae0 <printf> } 2b48: 8b 5d fc mov -0x4(%ebp),%ebx 2b4b: 83 c4 10 add $0x10,%esp 2b4e: c9 leave 2b4f: c3 ret printf(1, "create dirfile/xx succeeded!\n"); 2b50: 50 push %eax 2b51: 50 push %eax 2b52: 68 09 4b 00 00 push $0x4b09 2b57: 6a 01 push $0x1 2b59: e8 82 0f 00 00 call 3ae0 <printf> exit(); 2b5e: e8 20 0e 00 00 call 3983 <exit> printf(1, "chdir dirfile succeeded!\n"); 2b63: 52 push %edx 2b64: 52 push %edx 2b65: 68 e4 4a 00 00 push $0x4ae4 2b6a: 6a 01 push $0x1 2b6c: e8 6f 0f 00 00 call 3ae0 <printf> exit(); 2b71: e8 0d 0e 00 00 call 3983 <exit> printf(1, "create dirfile failed\n"); 2b76: 51 push %ecx 2b77: 51 push %ecx 2b78: 68 cd 4a 00 00 push $0x4acd 2b7d: 6a 01 push $0x1 2b7f: e8 5c 0f 00 00 call 3ae0 <printf> exit(); 2b84: e8 fa 0d 00 00 call 3983 <exit> printf(1, "write . succeeded!\n"); 2b89: 51 push %ecx 2b8a: 51 push %ecx 2b8b: 68 81 4b 00 00 push $0x4b81 2b90: 6a 01 push $0x1 2b92: e8 49 0f 00 00 call 3ae0 <printf> exit(); 2b97: e8 e7 0d 00 00 call 3983 <exit> printf(1, "open . for writing succeeded!\n"); 2b9c: 53 push %ebx 2b9d: 53 push %ebx 2b9e: 68 78 53 00 00 push $0x5378 2ba3: 6a 01 push $0x1 2ba5: e8 36 0f 00 00 call 3ae0 <printf> exit(); 2baa: e8 d4 0d 00 00 call 3983 <exit> printf(1, "unlink dirfile failed!\n"); 2baf: 50 push %eax 2bb0: 50 push %eax 2bb1: 68 69 4b 00 00 push $0x4b69 2bb6: 6a 01 push $0x1 2bb8: e8 23 0f 00 00 call 3ae0 <printf> exit(); 2bbd: e8 c1 0d 00 00 call 3983 <exit> printf(1, "link to dirfile/xx succeeded!\n"); 2bc2: 50 push %eax 2bc3: 50 push %eax 2bc4: 68 58 53 00 00 push $0x5358 2bc9: 6a 01 push $0x1 2bcb: e8 10 0f 00 00 call 3ae0 <printf> exit(); 2bd0: e8 ae 0d 00 00 call 3983 <exit> printf(1, "unlink dirfile/xx succeeded!\n"); 2bd5: 50 push %eax 2bd6: 50 push %eax 2bd7: 68 44 4b 00 00 push $0x4b44 2bdc: 6a 01 push $0x1 2bde: e8 fd 0e 00 00 call 3ae0 <printf> exit(); 2be3: e8 9b 0d 00 00 call 3983 <exit> printf(1, "mkdir dirfile/xx succeeded!\n"); 2be8: 50 push %eax 2be9: 50 push %eax 2bea: 68 27 4b 00 00 push $0x4b27 2bef: 6a 01 push $0x1 2bf1: e8 ea 0e 00 00 call 3ae0 <printf> exit(); 2bf6: e8 88 0d 00 00 call 3983 <exit> 2bfb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2bff: 90 nop 00002c00 <iref>: { 2c00: f3 0f 1e fb endbr32 2c04: 55 push %ebp 2c05: 89 e5 mov %esp,%ebp 2c07: 53 push %ebx printf(1, "empty file name\n"); 2c08: bb 33 00 00 00 mov $0x33,%ebx { 2c0d: 83 ec 0c sub $0xc,%esp printf(1, "empty file name\n"); 2c10: 68 a5 4b 00 00 push $0x4ba5 2c15: 6a 01 push $0x1 2c17: e8 c4 0e 00 00 call 3ae0 <printf> 2c1c: 83 c4 10 add $0x10,%esp 2c1f: 90 nop if(mkdir("irefd") != 0){ 2c20: 83 ec 0c sub $0xc,%esp 2c23: 68 b6 4b 00 00 push $0x4bb6 2c28: e8 be 0d 00 00 call 39eb <mkdir> 2c2d: 83 c4 10 add $0x10,%esp 2c30: 85 c0 test %eax,%eax 2c32: 0f 85 bb 00 00 00 jne 2cf3 <iref+0xf3> if(chdir("irefd") != 0){ 2c38: 83 ec 0c sub $0xc,%esp 2c3b: 68 b6 4b 00 00 push $0x4bb6 2c40: e8 ae 0d 00 00 call 39f3 <chdir> 2c45: 83 c4 10 add $0x10,%esp 2c48: 85 c0 test %eax,%eax 2c4a: 0f 85 b7 00 00 00 jne 2d07 <iref+0x107> mkdir(""); 2c50: 83 ec 0c sub $0xc,%esp 2c53: 68 6b 42 00 00 push $0x426b 2c58: e8 8e 0d 00 00 call 39eb <mkdir> link("README", ""); 2c5d: 59 pop %ecx 2c5e: 58 pop %eax 2c5f: 68 6b 42 00 00 push $0x426b 2c64: 68 62 4b 00 00 push $0x4b62 2c69: e8 75 0d 00 00 call 39e3 <link> fd = open("", O_CREATE); 2c6e: 58 pop %eax 2c6f: 5a pop %edx 2c70: 68 00 02 00 00 push $0x200 2c75: 68 6b 42 00 00 push $0x426b 2c7a: e8 44 0d 00 00 call 39c3 <open> if(fd >= 0) 2c7f: 83 c4 10 add $0x10,%esp 2c82: 85 c0 test %eax,%eax 2c84: 78 0c js 2c92 <iref+0x92> close(fd); 2c86: 83 ec 0c sub $0xc,%esp 2c89: 50 push %eax 2c8a: e8 1c 0d 00 00 call 39ab <close> 2c8f: 83 c4 10 add $0x10,%esp fd = open("xx", O_CREATE); 2c92: 83 ec 08 sub $0x8,%esp 2c95: 68 00 02 00 00 push $0x200 2c9a: 68 a0 47 00 00 push $0x47a0 2c9f: e8 1f 0d 00 00 call 39c3 <open> if(fd >= 0) 2ca4: 83 c4 10 add $0x10,%esp 2ca7: 85 c0 test %eax,%eax 2ca9: 78 0c js 2cb7 <iref+0xb7> close(fd); 2cab: 83 ec 0c sub $0xc,%esp 2cae: 50 push %eax 2caf: e8 f7 0c 00 00 call 39ab <close> 2cb4: 83 c4 10 add $0x10,%esp unlink("xx"); 2cb7: 83 ec 0c sub $0xc,%esp 2cba: 68 a0 47 00 00 push $0x47a0 2cbf: e8 0f 0d 00 00 call 39d3 <unlink> for(i = 0; i < 50 + 1; i++){ 2cc4: 83 c4 10 add $0x10,%esp 2cc7: 83 eb 01 sub $0x1,%ebx 2cca: 0f 85 50 ff ff ff jne 2c20 <iref+0x20> chdir("/"); 2cd0: 83 ec 0c sub $0xc,%esp 2cd3: 68 91 3e 00 00 push $0x3e91 2cd8: e8 16 0d 00 00 call 39f3 <chdir> printf(1, "empty file name OK\n"); 2cdd: 58 pop %eax 2cde: 5a pop %edx 2cdf: 68 e4 4b 00 00 push $0x4be4 2ce4: 6a 01 push $0x1 2ce6: e8 f5 0d 00 00 call 3ae0 <printf> } 2ceb: 8b 5d fc mov -0x4(%ebp),%ebx 2cee: 83 c4 10 add $0x10,%esp 2cf1: c9 leave 2cf2: c3 ret printf(1, "mkdir irefd failed\n"); 2cf3: 83 ec 08 sub $0x8,%esp 2cf6: 68 bc 4b 00 00 push $0x4bbc 2cfb: 6a 01 push $0x1 2cfd: e8 de 0d 00 00 call 3ae0 <printf> exit(); 2d02: e8 7c 0c 00 00 call 3983 <exit> printf(1, "chdir irefd failed\n"); 2d07: 83 ec 08 sub $0x8,%esp 2d0a: 68 d0 4b 00 00 push $0x4bd0 2d0f: 6a 01 push $0x1 2d11: e8 ca 0d 00 00 call 3ae0 <printf> exit(); 2d16: e8 68 0c 00 00 call 3983 <exit> 2d1b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2d1f: 90 nop 00002d20 <forktest>: { 2d20: f3 0f 1e fb endbr32 2d24: 55 push %ebp 2d25: 89 e5 mov %esp,%ebp 2d27: 53 push %ebx for(n=0; n<1000; n++){ 2d28: 31 db xor %ebx,%ebx { 2d2a: 83 ec 0c sub $0xc,%esp printf(1, "fork test\n"); 2d2d: 68 f8 4b 00 00 push $0x4bf8 2d32: 6a 01 push $0x1 2d34: e8 a7 0d 00 00 call 3ae0 <printf> 2d39: 83 c4 10 add $0x10,%esp 2d3c: eb 0f jmp 2d4d <forktest+0x2d> 2d3e: 66 90 xchg %ax,%ax if(pid == 0) 2d40: 74 4a je 2d8c <forktest+0x6c> for(n=0; n<1000; n++){ 2d42: 83 c3 01 add $0x1,%ebx 2d45: 81 fb e8 03 00 00 cmp $0x3e8,%ebx 2d4b: 74 6b je 2db8 <forktest+0x98> pid = fork(); 2d4d: e8 29 0c 00 00 call 397b <fork> if(pid < 0) 2d52: 85 c0 test %eax,%eax 2d54: 79 ea jns 2d40 <forktest+0x20> for(; n > 0; n--){ 2d56: 85 db test %ebx,%ebx 2d58: 74 14 je 2d6e <forktest+0x4e> 2d5a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(wait() < 0){ 2d60: e8 26 0c 00 00 call 398b <wait> 2d65: 85 c0 test %eax,%eax 2d67: 78 28 js 2d91 <forktest+0x71> for(; n > 0; n--){ 2d69: 83 eb 01 sub $0x1,%ebx 2d6c: 75 f2 jne 2d60 <forktest+0x40> if(wait() != -1){ 2d6e: e8 18 0c 00 00 call 398b <wait> 2d73: 83 f8 ff cmp $0xffffffff,%eax 2d76: 75 2d jne 2da5 <forktest+0x85> printf(1, "fork test OK\n"); 2d78: 83 ec 08 sub $0x8,%esp 2d7b: 68 2a 4c 00 00 push $0x4c2a 2d80: 6a 01 push $0x1 2d82: e8 59 0d 00 00 call 3ae0 <printf> } 2d87: 8b 5d fc mov -0x4(%ebp),%ebx 2d8a: c9 leave 2d8b: c3 ret exit(); 2d8c: e8 f2 0b 00 00 call 3983 <exit> printf(1, "wait stopped early\n"); 2d91: 83 ec 08 sub $0x8,%esp 2d94: 68 03 4c 00 00 push $0x4c03 2d99: 6a 01 push $0x1 2d9b: e8 40 0d 00 00 call 3ae0 <printf> exit(); 2da0: e8 de 0b 00 00 call 3983 <exit> printf(1, "wait got too many\n"); 2da5: 52 push %edx 2da6: 52 push %edx 2da7: 68 17 4c 00 00 push $0x4c17 2dac: 6a 01 push $0x1 2dae: e8 2d 0d 00 00 call 3ae0 <printf> exit(); 2db3: e8 cb 0b 00 00 call 3983 <exit> printf(1, "fork claimed to work 1000 times!\n"); 2db8: 50 push %eax 2db9: 50 push %eax 2dba: 68 98 53 00 00 push $0x5398 2dbf: 6a 01 push $0x1 2dc1: e8 1a 0d 00 00 call 3ae0 <printf> exit(); 2dc6: e8 b8 0b 00 00 call 3983 <exit> 2dcb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2dcf: 90 nop 00002dd0 <sbrktest>: { 2dd0: f3 0f 1e fb endbr32 2dd4: 55 push %ebp 2dd5: 89 e5 mov %esp,%ebp 2dd7: 57 push %edi for(i = 0; i < 5000; i++){ 2dd8: 31 ff xor %edi,%edi { 2dda: 56 push %esi 2ddb: 53 push %ebx 2ddc: 83 ec 54 sub $0x54,%esp printf(stdout, "sbrk test\n"); 2ddf: 68 38 4c 00 00 push $0x4c38 2de4: ff 35 e0 5e 00 00 pushl 0x5ee0 2dea: e8 f1 0c 00 00 call 3ae0 <printf> oldbrk = sbrk(0); 2def: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2df6: e8 10 0c 00 00 call 3a0b <sbrk> a = sbrk(0); 2dfb: c7 04 24 00 00 00 00 movl $0x0,(%esp) oldbrk = sbrk(0); 2e02: 89 c3 mov %eax,%ebx a = sbrk(0); 2e04: e8 02 0c 00 00 call 3a0b <sbrk> 2e09: 83 c4 10 add $0x10,%esp 2e0c: 89 c6 mov %eax,%esi for(i = 0; i < 5000; i++){ 2e0e: eb 02 jmp 2e12 <sbrktest+0x42> a = b + 1; 2e10: 89 c6 mov %eax,%esi b = sbrk(1); 2e12: 83 ec 0c sub $0xc,%esp 2e15: 6a 01 push $0x1 2e17: e8 ef 0b 00 00 call 3a0b <sbrk> if(b != a){ 2e1c: 83 c4 10 add $0x10,%esp 2e1f: 39 f0 cmp %esi,%eax 2e21: 0f 85 84 02 00 00 jne 30ab <sbrktest+0x2db> for(i = 0; i < 5000; i++){ 2e27: 83 c7 01 add $0x1,%edi *b = 1; 2e2a: c6 06 01 movb $0x1,(%esi) a = b + 1; 2e2d: 8d 46 01 lea 0x1(%esi),%eax for(i = 0; i < 5000; i++){ 2e30: 81 ff 88 13 00 00 cmp $0x1388,%edi 2e36: 75 d8 jne 2e10 <sbrktest+0x40> pid = fork(); 2e38: e8 3e 0b 00 00 call 397b <fork> 2e3d: 89 c7 mov %eax,%edi if(pid < 0){ 2e3f: 85 c0 test %eax,%eax 2e41: 0f 88 91 03 00 00 js 31d8 <sbrktest+0x408> c = sbrk(1); 2e47: 83 ec 0c sub $0xc,%esp if(c != a + 1){ 2e4a: 83 c6 02 add $0x2,%esi c = sbrk(1); 2e4d: 6a 01 push $0x1 2e4f: e8 b7 0b 00 00 call 3a0b <sbrk> c = sbrk(1); 2e54: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2e5b: e8 ab 0b 00 00 call 3a0b <sbrk> if(c != a + 1){ 2e60: 83 c4 10 add $0x10,%esp 2e63: 39 c6 cmp %eax,%esi 2e65: 0f 85 56 03 00 00 jne 31c1 <sbrktest+0x3f1> if(pid == 0) 2e6b: 85 ff test %edi,%edi 2e6d: 0f 84 49 03 00 00 je 31bc <sbrktest+0x3ec> wait(); 2e73: e8 13 0b 00 00 call 398b <wait> a = sbrk(0); 2e78: 83 ec 0c sub $0xc,%esp 2e7b: 6a 00 push $0x0 2e7d: e8 89 0b 00 00 call 3a0b <sbrk> 2e82: 89 c6 mov %eax,%esi amt = (BIG) - (uint)a; 2e84: b8 00 00 40 06 mov $0x6400000,%eax 2e89: 29 f0 sub %esi,%eax p = sbrk(amt); 2e8b: 89 04 24 mov %eax,(%esp) 2e8e: e8 78 0b 00 00 call 3a0b <sbrk> if (p != a) { 2e93: 83 c4 10 add $0x10,%esp 2e96: 39 c6 cmp %eax,%esi 2e98: 0f 85 07 03 00 00 jne 31a5 <sbrktest+0x3d5> a = sbrk(0); 2e9e: 83 ec 0c sub $0xc,%esp *lastaddr = 99; 2ea1: c6 05 ff ff 3f 06 63 movb $0x63,0x63fffff a = sbrk(0); 2ea8: 6a 00 push $0x0 2eaa: e8 5c 0b 00 00 call 3a0b <sbrk> c = sbrk(-4096); 2eaf: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp) a = sbrk(0); 2eb6: 89 c6 mov %eax,%esi c = sbrk(-4096); 2eb8: e8 4e 0b 00 00 call 3a0b <sbrk> if(c == (char*)0xffffffff){ 2ebd: 83 c4 10 add $0x10,%esp 2ec0: 83 f8 ff cmp $0xffffffff,%eax 2ec3: 0f 84 c5 02 00 00 je 318e <sbrktest+0x3be> c = sbrk(0); 2ec9: 83 ec 0c sub $0xc,%esp 2ecc: 6a 00 push $0x0 2ece: e8 38 0b 00 00 call 3a0b <sbrk> if(c != a - 4096){ 2ed3: 8d 96 00 f0 ff ff lea -0x1000(%esi),%edx 2ed9: 83 c4 10 add $0x10,%esp 2edc: 39 d0 cmp %edx,%eax 2ede: 0f 85 93 02 00 00 jne 3177 <sbrktest+0x3a7> a = sbrk(0); 2ee4: 83 ec 0c sub $0xc,%esp 2ee7: 6a 00 push $0x0 2ee9: e8 1d 0b 00 00 call 3a0b <sbrk> c = sbrk(4096); 2eee: c7 04 24 00 10 00 00 movl $0x1000,(%esp) a = sbrk(0); 2ef5: 89 c6 mov %eax,%esi c = sbrk(4096); 2ef7: e8 0f 0b 00 00 call 3a0b <sbrk> if(c != a || sbrk(0) != a + 4096){ 2efc: 83 c4 10 add $0x10,%esp c = sbrk(4096); 2eff: 89 c7 mov %eax,%edi if(c != a || sbrk(0) != a + 4096){ 2f01: 39 c6 cmp %eax,%esi 2f03: 0f 85 57 02 00 00 jne 3160 <sbrktest+0x390> 2f09: 83 ec 0c sub $0xc,%esp 2f0c: 6a 00 push $0x0 2f0e: e8 f8 0a 00 00 call 3a0b <sbrk> 2f13: 8d 96 00 10 00 00 lea 0x1000(%esi),%edx 2f19: 83 c4 10 add $0x10,%esp 2f1c: 39 c2 cmp %eax,%edx 2f1e: 0f 85 3c 02 00 00 jne 3160 <sbrktest+0x390> if(*lastaddr == 99){ 2f24: 80 3d ff ff 3f 06 63 cmpb $0x63,0x63fffff 2f2b: 0f 84 18 02 00 00 je 3149 <sbrktest+0x379> a = sbrk(0); 2f31: 83 ec 0c sub $0xc,%esp 2f34: 6a 00 push $0x0 2f36: e8 d0 0a 00 00 call 3a0b <sbrk> c = sbrk(-(sbrk(0) - oldbrk)); 2f3b: c7 04 24 00 00 00 00 movl $0x0,(%esp) a = sbrk(0); 2f42: 89 c6 mov %eax,%esi c = sbrk(-(sbrk(0) - oldbrk)); 2f44: e8 c2 0a 00 00 call 3a0b <sbrk> 2f49: 89 d9 mov %ebx,%ecx 2f4b: 29 c1 sub %eax,%ecx 2f4d: 89 0c 24 mov %ecx,(%esp) 2f50: e8 b6 0a 00 00 call 3a0b <sbrk> if(c != a){ 2f55: 83 c4 10 add $0x10,%esp 2f58: 39 c6 cmp %eax,%esi 2f5a: 0f 85 d2 01 00 00 jne 3132 <sbrktest+0x362> for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 2f60: be 00 00 00 80 mov $0x80000000,%esi 2f65: 8d 76 00 lea 0x0(%esi),%esi ppid = getpid(); 2f68: e8 96 0a 00 00 call 3a03 <getpid> 2f6d: 89 c7 mov %eax,%edi pid = fork(); 2f6f: e8 07 0a 00 00 call 397b <fork> if(pid < 0){ 2f74: 85 c0 test %eax,%eax 2f76: 0f 88 9e 01 00 00 js 311a <sbrktest+0x34a> if(pid == 0){ 2f7c: 0f 84 76 01 00 00 je 30f8 <sbrktest+0x328> wait(); 2f82: e8 04 0a 00 00 call 398b <wait> for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 2f87: 81 c6 50 c3 00 00 add $0xc350,%esi 2f8d: 81 fe 80 84 1e 80 cmp $0x801e8480,%esi 2f93: 75 d3 jne 2f68 <sbrktest+0x198> if(pipe(fds) != 0){ 2f95: 83 ec 0c sub $0xc,%esp 2f98: 8d 45 b8 lea -0x48(%ebp),%eax 2f9b: 50 push %eax 2f9c: e8 f2 09 00 00 call 3993 <pipe> 2fa1: 83 c4 10 add $0x10,%esp 2fa4: 85 c0 test %eax,%eax 2fa6: 0f 85 34 01 00 00 jne 30e0 <sbrktest+0x310> 2fac: 8d 75 c0 lea -0x40(%ebp),%esi 2faf: 89 f7 mov %esi,%edi if((pids[i] = fork()) == 0){ 2fb1: e8 c5 09 00 00 call 397b <fork> 2fb6: 89 07 mov %eax,(%edi) 2fb8: 85 c0 test %eax,%eax 2fba: 0f 84 8f 00 00 00 je 304f <sbrktest+0x27f> if(pids[i] != -1) 2fc0: 83 f8 ff cmp $0xffffffff,%eax 2fc3: 74 14 je 2fd9 <sbrktest+0x209> read(fds[0], &scratch, 1); 2fc5: 83 ec 04 sub $0x4,%esp 2fc8: 8d 45 b7 lea -0x49(%ebp),%eax 2fcb: 6a 01 push $0x1 2fcd: 50 push %eax 2fce: ff 75 b8 pushl -0x48(%ebp) 2fd1: e8 c5 09 00 00 call 399b <read> 2fd6: 83 c4 10 add $0x10,%esp for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 2fd9: 83 c7 04 add $0x4,%edi 2fdc: 8d 45 e8 lea -0x18(%ebp),%eax 2fdf: 39 c7 cmp %eax,%edi 2fe1: 75 ce jne 2fb1 <sbrktest+0x1e1> c = sbrk(4096); 2fe3: 83 ec 0c sub $0xc,%esp 2fe6: 68 00 10 00 00 push $0x1000 2feb: e8 1b 0a 00 00 call 3a0b <sbrk> 2ff0: 83 c4 10 add $0x10,%esp 2ff3: 89 c7 mov %eax,%edi if(pids[i] == -1) 2ff5: 8b 06 mov (%esi),%eax 2ff7: 83 f8 ff cmp $0xffffffff,%eax 2ffa: 74 11 je 300d <sbrktest+0x23d> kill(pids[i]); 2ffc: 83 ec 0c sub $0xc,%esp 2fff: 50 push %eax 3000: e8 ae 09 00 00 call 39b3 <kill> wait(); 3005: e8 81 09 00 00 call 398b <wait> 300a: 83 c4 10 add $0x10,%esp for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 300d: 83 c6 04 add $0x4,%esi 3010: 8d 45 e8 lea -0x18(%ebp),%eax 3013: 39 f0 cmp %esi,%eax 3015: 75 de jne 2ff5 <sbrktest+0x225> if(c == (char*)0xffffffff){ 3017: 83 ff ff cmp $0xffffffff,%edi 301a: 0f 84 a9 00 00 00 je 30c9 <sbrktest+0x2f9> if(sbrk(0) > oldbrk) 3020: 83 ec 0c sub $0xc,%esp 3023: 6a 00 push $0x0 3025: e8 e1 09 00 00 call 3a0b <sbrk> 302a: 83 c4 10 add $0x10,%esp 302d: 39 c3 cmp %eax,%ebx 302f: 72 61 jb 3092 <sbrktest+0x2c2> printf(stdout, "sbrk test OK\n"); 3031: 83 ec 08 sub $0x8,%esp 3034: 68 e0 4c 00 00 push $0x4ce0 3039: ff 35 e0 5e 00 00 pushl 0x5ee0 303f: e8 9c 0a 00 00 call 3ae0 <printf> } 3044: 83 c4 10 add $0x10,%esp 3047: 8d 65 f4 lea -0xc(%ebp),%esp 304a: 5b pop %ebx 304b: 5e pop %esi 304c: 5f pop %edi 304d: 5d pop %ebp 304e: c3 ret sbrk(BIG - (uint)sbrk(0)); 304f: 83 ec 0c sub $0xc,%esp 3052: 6a 00 push $0x0 3054: e8 b2 09 00 00 call 3a0b <sbrk> 3059: 89 c2 mov %eax,%edx 305b: b8 00 00 40 06 mov $0x6400000,%eax 3060: 29 d0 sub %edx,%eax 3062: 89 04 24 mov %eax,(%esp) 3065: e8 a1 09 00 00 call 3a0b <sbrk> write(fds[1], "x", 1); 306a: 83 c4 0c add $0xc,%esp 306d: 6a 01 push $0x1 306f: 68 a1 47 00 00 push $0x47a1 3074: ff 75 bc pushl -0x44(%ebp) 3077: e8 27 09 00 00 call 39a3 <write> 307c: 83 c4 10 add $0x10,%esp 307f: 90 nop for(;;) sleep(1000); 3080: 83 ec 0c sub $0xc,%esp 3083: 68 e8 03 00 00 push $0x3e8 3088: e8 86 09 00 00 call 3a13 <sleep> 308d: 83 c4 10 add $0x10,%esp 3090: eb ee jmp 3080 <sbrktest+0x2b0> sbrk(-(sbrk(0) - oldbrk)); 3092: 83 ec 0c sub $0xc,%esp 3095: 6a 00 push $0x0 3097: e8 6f 09 00 00 call 3a0b <sbrk> 309c: 29 c3 sub %eax,%ebx 309e: 89 1c 24 mov %ebx,(%esp) 30a1: e8 65 09 00 00 call 3a0b <sbrk> 30a6: 83 c4 10 add $0x10,%esp 30a9: eb 86 jmp 3031 <sbrktest+0x261> printf(stdout, "sbrk test failed %d %x %x\n", i, a, b); 30ab: 83 ec 0c sub $0xc,%esp 30ae: 50 push %eax 30af: 56 push %esi 30b0: 57 push %edi 30b1: 68 43 4c 00 00 push $0x4c43 30b6: ff 35 e0 5e 00 00 pushl 0x5ee0 30bc: e8 1f 0a 00 00 call 3ae0 <printf> exit(); 30c1: 83 c4 20 add $0x20,%esp 30c4: e8 ba 08 00 00 call 3983 <exit> printf(stdout, "failed sbrk leaked memory\n"); 30c9: 50 push %eax 30ca: 50 push %eax 30cb: 68 c5 4c 00 00 push $0x4cc5 30d0: ff 35 e0 5e 00 00 pushl 0x5ee0 30d6: e8 05 0a 00 00 call 3ae0 <printf> exit(); 30db: e8 a3 08 00 00 call 3983 <exit> printf(1, "pipe() failed\n"); 30e0: 52 push %edx 30e1: 52 push %edx 30e2: 68 81 41 00 00 push $0x4181 30e7: 6a 01 push $0x1 30e9: e8 f2 09 00 00 call 3ae0 <printf> exit(); 30ee: e8 90 08 00 00 call 3983 <exit> 30f3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 30f7: 90 nop printf(stdout, "oops could read %x = %x\n", a, *a); 30f8: 0f be 06 movsbl (%esi),%eax 30fb: 50 push %eax 30fc: 56 push %esi 30fd: 68 ac 4c 00 00 push $0x4cac 3102: ff 35 e0 5e 00 00 pushl 0x5ee0 3108: e8 d3 09 00 00 call 3ae0 <printf> kill(ppid); 310d: 89 3c 24 mov %edi,(%esp) 3110: e8 9e 08 00 00 call 39b3 <kill> exit(); 3115: e8 69 08 00 00 call 3983 <exit> printf(stdout, "fork failed\n"); 311a: 83 ec 08 sub $0x8,%esp 311d: 68 89 4d 00 00 push $0x4d89 3122: ff 35 e0 5e 00 00 pushl 0x5ee0 3128: e8 b3 09 00 00 call 3ae0 <printf> exit(); 312d: e8 51 08 00 00 call 3983 <exit> printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c); 3132: 50 push %eax 3133: 56 push %esi 3134: 68 8c 54 00 00 push $0x548c 3139: ff 35 e0 5e 00 00 pushl 0x5ee0 313f: e8 9c 09 00 00 call 3ae0 <printf> exit(); 3144: e8 3a 08 00 00 call 3983 <exit> printf(stdout, "sbrk de-allocation didn't really deallocate\n"); 3149: 51 push %ecx 314a: 51 push %ecx 314b: 68 5c 54 00 00 push $0x545c 3150: ff 35 e0 5e 00 00 pushl 0x5ee0 3156: e8 85 09 00 00 call 3ae0 <printf> exit(); 315b: e8 23 08 00 00 call 3983 <exit> printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c); 3160: 57 push %edi 3161: 56 push %esi 3162: 68 34 54 00 00 push $0x5434 3167: ff 35 e0 5e 00 00 pushl 0x5ee0 316d: e8 6e 09 00 00 call 3ae0 <printf> exit(); 3172: e8 0c 08 00 00 call 3983 <exit> printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c); 3177: 50 push %eax 3178: 56 push %esi 3179: 68 fc 53 00 00 push $0x53fc 317e: ff 35 e0 5e 00 00 pushl 0x5ee0 3184: e8 57 09 00 00 call 3ae0 <printf> exit(); 3189: e8 f5 07 00 00 call 3983 <exit> printf(stdout, "sbrk could not deallocate\n"); 318e: 53 push %ebx 318f: 53 push %ebx 3190: 68 91 4c 00 00 push $0x4c91 3195: ff 35 e0 5e 00 00 pushl 0x5ee0 319b: e8 40 09 00 00 call 3ae0 <printf> exit(); 31a0: e8 de 07 00 00 call 3983 <exit> printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n"); 31a5: 56 push %esi 31a6: 56 push %esi 31a7: 68 bc 53 00 00 push $0x53bc 31ac: ff 35 e0 5e 00 00 pushl 0x5ee0 31b2: e8 29 09 00 00 call 3ae0 <printf> exit(); 31b7: e8 c7 07 00 00 call 3983 <exit> exit(); 31bc: e8 c2 07 00 00 call 3983 <exit> printf(stdout, "sbrk test failed post-fork\n"); 31c1: 57 push %edi 31c2: 57 push %edi 31c3: 68 75 4c 00 00 push $0x4c75 31c8: ff 35 e0 5e 00 00 pushl 0x5ee0 31ce: e8 0d 09 00 00 call 3ae0 <printf> exit(); 31d3: e8 ab 07 00 00 call 3983 <exit> printf(stdout, "sbrk test fork failed\n"); 31d8: 50 push %eax 31d9: 50 push %eax 31da: 68 5e 4c 00 00 push $0x4c5e 31df: ff 35 e0 5e 00 00 pushl 0x5ee0 31e5: e8 f6 08 00 00 call 3ae0 <printf> exit(); 31ea: e8 94 07 00 00 call 3983 <exit> 31ef: 90 nop 000031f0 <validateint>: { 31f0: f3 0f 1e fb endbr32 } 31f4: c3 ret 31f5: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 31fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00003200 <validatetest>: { 3200: f3 0f 1e fb endbr32 3204: 55 push %ebp 3205: 89 e5 mov %esp,%ebp 3207: 56 push %esi for(p = 0; p <= (uint)hi; p += 4096){ 3208: 31 f6 xor %esi,%esi { 320a: 53 push %ebx printf(stdout, "validate test\n"); 320b: 83 ec 08 sub $0x8,%esp 320e: 68 ee 4c 00 00 push $0x4cee 3213: ff 35 e0 5e 00 00 pushl 0x5ee0 3219: e8 c2 08 00 00 call 3ae0 <printf> 321e: 83 c4 10 add $0x10,%esp 3221: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if((pid = fork()) == 0){ 3228: e8 4e 07 00 00 call 397b <fork> 322d: 89 c3 mov %eax,%ebx 322f: 85 c0 test %eax,%eax 3231: 74 63 je 3296 <validatetest+0x96> sleep(0); 3233: 83 ec 0c sub $0xc,%esp 3236: 6a 00 push $0x0 3238: e8 d6 07 00 00 call 3a13 <sleep> sleep(0); 323d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 3244: e8 ca 07 00 00 call 3a13 <sleep> kill(pid); 3249: 89 1c 24 mov %ebx,(%esp) 324c: e8 62 07 00 00 call 39b3 <kill> wait(); 3251: e8 35 07 00 00 call 398b <wait> if(link("nosuchfile", (char*)p) != -1){ 3256: 58 pop %eax 3257: 5a pop %edx 3258: 56 push %esi 3259: 68 fd 4c 00 00 push $0x4cfd 325e: e8 80 07 00 00 call 39e3 <link> 3263: 83 c4 10 add $0x10,%esp 3266: 83 f8 ff cmp $0xffffffff,%eax 3269: 75 30 jne 329b <validatetest+0x9b> for(p = 0; p <= (uint)hi; p += 4096){ 326b: 81 c6 00 10 00 00 add $0x1000,%esi 3271: 81 fe 00 40 11 00 cmp $0x114000,%esi 3277: 75 af jne 3228 <validatetest+0x28> printf(stdout, "validate ok\n"); 3279: 83 ec 08 sub $0x8,%esp 327c: 68 21 4d 00 00 push $0x4d21 3281: ff 35 e0 5e 00 00 pushl 0x5ee0 3287: e8 54 08 00 00 call 3ae0 <printf> } 328c: 83 c4 10 add $0x10,%esp 328f: 8d 65 f8 lea -0x8(%ebp),%esp 3292: 5b pop %ebx 3293: 5e pop %esi 3294: 5d pop %ebp 3295: c3 ret exit(); 3296: e8 e8 06 00 00 call 3983 <exit> printf(stdout, "link should not succeed\n"); 329b: 83 ec 08 sub $0x8,%esp 329e: 68 08 4d 00 00 push $0x4d08 32a3: ff 35 e0 5e 00 00 pushl 0x5ee0 32a9: e8 32 08 00 00 call 3ae0 <printf> exit(); 32ae: e8 d0 06 00 00 call 3983 <exit> 32b3: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 32ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000032c0 <bsstest>: { 32c0: f3 0f 1e fb endbr32 32c4: 55 push %ebp 32c5: 89 e5 mov %esp,%ebp 32c7: 83 ec 10 sub $0x10,%esp printf(stdout, "bss test\n"); 32ca: 68 2e 4d 00 00 push $0x4d2e 32cf: ff 35 e0 5e 00 00 pushl 0x5ee0 32d5: e8 06 08 00 00 call 3ae0 <printf> 32da: 83 c4 10 add $0x10,%esp for(i = 0; i < sizeof(uninit); i++){ 32dd: 31 c0 xor %eax,%eax 32df: 90 nop if(uninit[i] != '\0'){ 32e0: 80 b8 a0 5f 00 00 00 cmpb $0x0,0x5fa0(%eax) 32e7: 75 22 jne 330b <bsstest+0x4b> for(i = 0; i < sizeof(uninit); i++){ 32e9: 83 c0 01 add $0x1,%eax 32ec: 3d 10 27 00 00 cmp $0x2710,%eax 32f1: 75 ed jne 32e0 <bsstest+0x20> printf(stdout, "bss test ok\n"); 32f3: 83 ec 08 sub $0x8,%esp 32f6: 68 49 4d 00 00 push $0x4d49 32fb: ff 35 e0 5e 00 00 pushl 0x5ee0 3301: e8 da 07 00 00 call 3ae0 <printf> } 3306: 83 c4 10 add $0x10,%esp 3309: c9 leave 330a: c3 ret printf(stdout, "bss test failed\n"); 330b: 83 ec 08 sub $0x8,%esp 330e: 68 38 4d 00 00 push $0x4d38 3313: ff 35 e0 5e 00 00 pushl 0x5ee0 3319: e8 c2 07 00 00 call 3ae0 <printf> exit(); 331e: e8 60 06 00 00 call 3983 <exit> 3323: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 332a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00003330 <bigargtest>: { 3330: f3 0f 1e fb endbr32 3334: 55 push %ebp 3335: 89 e5 mov %esp,%ebp 3337: 83 ec 14 sub $0x14,%esp unlink("bigarg-ok"); 333a: 68 56 4d 00 00 push $0x4d56 333f: e8 8f 06 00 00 call 39d3 <unlink> pid = fork(); 3344: e8 32 06 00 00 call 397b <fork> if(pid == 0){ 3349: 83 c4 10 add $0x10,%esp 334c: 85 c0 test %eax,%eax 334e: 74 40 je 3390 <bigargtest+0x60> } else if(pid < 0){ 3350: 0f 88 c1 00 00 00 js 3417 <bigargtest+0xe7> wait(); 3356: e8 30 06 00 00 call 398b <wait> fd = open("bigarg-ok", 0); 335b: 83 ec 08 sub $0x8,%esp 335e: 6a 00 push $0x0 3360: 68 56 4d 00 00 push $0x4d56 3365: e8 59 06 00 00 call 39c3 <open> if(fd < 0){ 336a: 83 c4 10 add $0x10,%esp 336d: 85 c0 test %eax,%eax 336f: 0f 88 8b 00 00 00 js 3400 <bigargtest+0xd0> close(fd); 3375: 83 ec 0c sub $0xc,%esp 3378: 50 push %eax 3379: e8 2d 06 00 00 call 39ab <close> unlink("bigarg-ok"); 337e: c7 04 24 56 4d 00 00 movl $0x4d56,(%esp) 3385: e8 49 06 00 00 call 39d3 <unlink> } 338a: 83 c4 10 add $0x10,%esp 338d: c9 leave 338e: c3 ret 338f: 90 nop args[i] = "bigargs test: failed\n "; 3390: c7 04 85 00 5f 00 00 movl $0x54b0,0x5f00(,%eax,4) 3397: b0 54 00 00 for(i = 0; i < MAXARG-1; i++) 339b: 83 c0 01 add $0x1,%eax 339e: 83 f8 1f cmp $0x1f,%eax 33a1: 75 ed jne 3390 <bigargtest+0x60> printf(stdout, "bigarg test\n"); 33a3: 51 push %ecx 33a4: 51 push %ecx 33a5: 68 60 4d 00 00 push $0x4d60 33aa: ff 35 e0 5e 00 00 pushl 0x5ee0 args[MAXARG-1] = 0; 33b0: c7 05 7c 5f 00 00 00 movl $0x0,0x5f7c 33b7: 00 00 00 printf(stdout, "bigarg test\n"); 33ba: e8 21 07 00 00 call 3ae0 <printf> exec("echo", args); 33bf: 58 pop %eax 33c0: 5a pop %edx 33c1: 68 00 5f 00 00 push $0x5f00 33c6: 68 2d 3f 00 00 push $0x3f2d 33cb: e8 eb 05 00 00 call 39bb <exec> printf(stdout, "bigarg test ok\n"); 33d0: 59 pop %ecx 33d1: 58 pop %eax 33d2: 68 6d 4d 00 00 push $0x4d6d 33d7: ff 35 e0 5e 00 00 pushl 0x5ee0 33dd: e8 fe 06 00 00 call 3ae0 <printf> fd = open("bigarg-ok", O_CREATE); 33e2: 58 pop %eax 33e3: 5a pop %edx 33e4: 68 00 02 00 00 push $0x200 33e9: 68 56 4d 00 00 push $0x4d56 33ee: e8 d0 05 00 00 call 39c3 <open> close(fd); 33f3: 89 04 24 mov %eax,(%esp) 33f6: e8 b0 05 00 00 call 39ab <close> exit(); 33fb: e8 83 05 00 00 call 3983 <exit> printf(stdout, "bigarg test failed!\n"); 3400: 50 push %eax 3401: 50 push %eax 3402: 68 96 4d 00 00 push $0x4d96 3407: ff 35 e0 5e 00 00 pushl 0x5ee0 340d: e8 ce 06 00 00 call 3ae0 <printf> exit(); 3412: e8 6c 05 00 00 call 3983 <exit> printf(stdout, "bigargtest: fork failed\n"); 3417: 52 push %edx 3418: 52 push %edx 3419: 68 7d 4d 00 00 push $0x4d7d 341e: ff 35 e0 5e 00 00 pushl 0x5ee0 3424: e8 b7 06 00 00 call 3ae0 <printf> exit(); 3429: e8 55 05 00 00 call 3983 <exit> 342e: 66 90 xchg %ax,%ax 00003430 <fsfull>: { 3430: f3 0f 1e fb endbr32 3434: 55 push %ebp 3435: 89 e5 mov %esp,%ebp 3437: 57 push %edi 3438: 56 push %esi for(nfiles = 0; ; nfiles++){ 3439: 31 f6 xor %esi,%esi { 343b: 53 push %ebx 343c: 83 ec 54 sub $0x54,%esp printf(1, "fsfull test\n"); 343f: 68 ab 4d 00 00 push $0x4dab 3444: 6a 01 push $0x1 3446: e8 95 06 00 00 call 3ae0 <printf> 344b: 83 c4 10 add $0x10,%esp 344e: 66 90 xchg %ax,%ax name[1] = '0' + nfiles / 1000; 3450: b8 d3 4d 62 10 mov $0x10624dd3,%eax name[3] = '0' + (nfiles % 100) / 10; 3455: b9 cd cc cc cc mov $0xcccccccd,%ecx printf(1, "writing %s\n", name); 345a: 83 ec 04 sub $0x4,%esp name[0] = 'f'; 345d: c6 45 a8 66 movb $0x66,-0x58(%ebp) name[1] = '0' + nfiles / 1000; 3461: f7 e6 mul %esi name[5] = '\0'; 3463: c6 45 ad 00 movb $0x0,-0x53(%ebp) name[1] = '0' + nfiles / 1000; 3467: c1 ea 06 shr $0x6,%edx 346a: 8d 42 30 lea 0x30(%edx),%eax name[2] = '0' + (nfiles % 1000) / 100; 346d: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx name[1] = '0' + nfiles / 1000; 3473: 88 45 a9 mov %al,-0x57(%ebp) name[2] = '0' + (nfiles % 1000) / 100; 3476: 89 f0 mov %esi,%eax 3478: 29 d0 sub %edx,%eax 347a: 89 c2 mov %eax,%edx 347c: b8 1f 85 eb 51 mov $0x51eb851f,%eax 3481: f7 e2 mul %edx name[3] = '0' + (nfiles % 100) / 10; 3483: b8 1f 85 eb 51 mov $0x51eb851f,%eax name[2] = '0' + (nfiles % 1000) / 100; 3488: c1 ea 05 shr $0x5,%edx 348b: 83 c2 30 add $0x30,%edx 348e: 88 55 aa mov %dl,-0x56(%ebp) name[3] = '0' + (nfiles % 100) / 10; 3491: f7 e6 mul %esi 3493: 89 f0 mov %esi,%eax 3495: c1 ea 05 shr $0x5,%edx 3498: 6b d2 64 imul $0x64,%edx,%edx 349b: 29 d0 sub %edx,%eax 349d: f7 e1 mul %ecx name[4] = '0' + (nfiles % 10); 349f: 89 f0 mov %esi,%eax name[3] = '0' + (nfiles % 100) / 10; 34a1: c1 ea 03 shr $0x3,%edx 34a4: 83 c2 30 add $0x30,%edx 34a7: 88 55 ab mov %dl,-0x55(%ebp) name[4] = '0' + (nfiles % 10); 34aa: f7 e1 mul %ecx 34ac: 89 f1 mov %esi,%ecx 34ae: c1 ea 03 shr $0x3,%edx 34b1: 8d 04 92 lea (%edx,%edx,4),%eax 34b4: 01 c0 add %eax,%eax 34b6: 29 c1 sub %eax,%ecx 34b8: 89 c8 mov %ecx,%eax 34ba: 83 c0 30 add $0x30,%eax 34bd: 88 45 ac mov %al,-0x54(%ebp) printf(1, "writing %s\n", name); 34c0: 8d 45 a8 lea -0x58(%ebp),%eax 34c3: 50 push %eax 34c4: 68 b8 4d 00 00 push $0x4db8 34c9: 6a 01 push $0x1 34cb: e8 10 06 00 00 call 3ae0 <printf> int fd = open(name, O_CREATE|O_RDWR); 34d0: 58 pop %eax 34d1: 8d 45 a8 lea -0x58(%ebp),%eax 34d4: 5a pop %edx 34d5: 68 02 02 00 00 push $0x202 34da: 50 push %eax 34db: e8 e3 04 00 00 call 39c3 <open> if(fd < 0){ 34e0: 83 c4 10 add $0x10,%esp int fd = open(name, O_CREATE|O_RDWR); 34e3: 89 c7 mov %eax,%edi if(fd < 0){ 34e5: 85 c0 test %eax,%eax 34e7: 78 4d js 3536 <fsfull+0x106> int total = 0; 34e9: 31 db xor %ebx,%ebx 34eb: eb 05 jmp 34f2 <fsfull+0xc2> 34ed: 8d 76 00 lea 0x0(%esi),%esi total += cc; 34f0: 01 c3 add %eax,%ebx int cc = write(fd, buf, 512); 34f2: 83 ec 04 sub $0x4,%esp 34f5: 68 00 02 00 00 push $0x200 34fa: 68 c0 86 00 00 push $0x86c0 34ff: 57 push %edi 3500: e8 9e 04 00 00 call 39a3 <write> if(cc < 512) 3505: 83 c4 10 add $0x10,%esp 3508: 3d ff 01 00 00 cmp $0x1ff,%eax 350d: 7f e1 jg 34f0 <fsfull+0xc0> printf(1, "wrote %d bytes\n", total); 350f: 83 ec 04 sub $0x4,%esp 3512: 53 push %ebx 3513: 68 d4 4d 00 00 push $0x4dd4 3518: 6a 01 push $0x1 351a: e8 c1 05 00 00 call 3ae0 <printf> close(fd); 351f: 89 3c 24 mov %edi,(%esp) 3522: e8 84 04 00 00 call 39ab <close> if(total == 0) 3527: 83 c4 10 add $0x10,%esp 352a: 85 db test %ebx,%ebx 352c: 74 1e je 354c <fsfull+0x11c> for(nfiles = 0; ; nfiles++){ 352e: 83 c6 01 add $0x1,%esi 3531: e9 1a ff ff ff jmp 3450 <fsfull+0x20> printf(1, "open %s failed\n", name); 3536: 83 ec 04 sub $0x4,%esp 3539: 8d 45 a8 lea -0x58(%ebp),%eax 353c: 50 push %eax 353d: 68 c4 4d 00 00 push $0x4dc4 3542: 6a 01 push $0x1 3544: e8 97 05 00 00 call 3ae0 <printf> break; 3549: 83 c4 10 add $0x10,%esp name[1] = '0' + nfiles / 1000; 354c: bf d3 4d 62 10 mov $0x10624dd3,%edi name[2] = '0' + (nfiles % 1000) / 100; 3551: bb 1f 85 eb 51 mov $0x51eb851f,%ebx 3556: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 355d: 8d 76 00 lea 0x0(%esi),%esi name[1] = '0' + nfiles / 1000; 3560: 89 f0 mov %esi,%eax 3562: 89 f1 mov %esi,%ecx unlink(name); 3564: 83 ec 0c sub $0xc,%esp name[0] = 'f'; 3567: c6 45 a8 66 movb $0x66,-0x58(%ebp) name[1] = '0' + nfiles / 1000; 356b: f7 ef imul %edi 356d: c1 f9 1f sar $0x1f,%ecx name[5] = '\0'; 3570: c6 45 ad 00 movb $0x0,-0x53(%ebp) name[1] = '0' + nfiles / 1000; 3574: c1 fa 06 sar $0x6,%edx 3577: 29 ca sub %ecx,%edx 3579: 8d 42 30 lea 0x30(%edx),%eax name[2] = '0' + (nfiles % 1000) / 100; 357c: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx name[1] = '0' + nfiles / 1000; 3582: 88 45 a9 mov %al,-0x57(%ebp) name[2] = '0' + (nfiles % 1000) / 100; 3585: 89 f0 mov %esi,%eax 3587: 29 d0 sub %edx,%eax 3589: f7 e3 mul %ebx name[3] = '0' + (nfiles % 100) / 10; 358b: 89 f0 mov %esi,%eax name[2] = '0' + (nfiles % 1000) / 100; 358d: c1 ea 05 shr $0x5,%edx 3590: 83 c2 30 add $0x30,%edx 3593: 88 55 aa mov %dl,-0x56(%ebp) name[3] = '0' + (nfiles % 100) / 10; 3596: f7 eb imul %ebx 3598: 89 f0 mov %esi,%eax 359a: c1 fa 05 sar $0x5,%edx 359d: 29 ca sub %ecx,%edx 359f: 6b d2 64 imul $0x64,%edx,%edx 35a2: 29 d0 sub %edx,%eax 35a4: ba cd cc cc cc mov $0xcccccccd,%edx 35a9: f7 e2 mul %edx name[4] = '0' + (nfiles % 10); 35ab: 89 f0 mov %esi,%eax name[3] = '0' + (nfiles % 100) / 10; 35ad: c1 ea 03 shr $0x3,%edx 35b0: 83 c2 30 add $0x30,%edx 35b3: 88 55 ab mov %dl,-0x55(%ebp) name[4] = '0' + (nfiles % 10); 35b6: ba 67 66 66 66 mov $0x66666667,%edx 35bb: f7 ea imul %edx 35bd: c1 fa 02 sar $0x2,%edx 35c0: 29 ca sub %ecx,%edx 35c2: 89 f1 mov %esi,%ecx nfiles--; 35c4: 83 ee 01 sub $0x1,%esi name[4] = '0' + (nfiles % 10); 35c7: 8d 04 92 lea (%edx,%edx,4),%eax 35ca: 01 c0 add %eax,%eax 35cc: 29 c1 sub %eax,%ecx 35ce: 89 c8 mov %ecx,%eax 35d0: 83 c0 30 add $0x30,%eax 35d3: 88 45 ac mov %al,-0x54(%ebp) unlink(name); 35d6: 8d 45 a8 lea -0x58(%ebp),%eax 35d9: 50 push %eax 35da: e8 f4 03 00 00 call 39d3 <unlink> while(nfiles >= 0){ 35df: 83 c4 10 add $0x10,%esp 35e2: 83 fe ff cmp $0xffffffff,%esi 35e5: 0f 85 75 ff ff ff jne 3560 <fsfull+0x130> printf(1, "fsfull test finished\n"); 35eb: 83 ec 08 sub $0x8,%esp 35ee: 68 e4 4d 00 00 push $0x4de4 35f3: 6a 01 push $0x1 35f5: e8 e6 04 00 00 call 3ae0 <printf> } 35fa: 83 c4 10 add $0x10,%esp 35fd: 8d 65 f4 lea -0xc(%ebp),%esp 3600: 5b pop %ebx 3601: 5e pop %esi 3602: 5f pop %edi 3603: 5d pop %ebp 3604: c3 ret 3605: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 360c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00003610 <uio>: { 3610: f3 0f 1e fb endbr32 3614: 55 push %ebp 3615: 89 e5 mov %esp,%ebp 3617: 83 ec 10 sub $0x10,%esp printf(1, "uio test\n"); 361a: 68 fa 4d 00 00 push $0x4dfa 361f: 6a 01 push $0x1 3621: e8 ba 04 00 00 call 3ae0 <printf> pid = fork(); 3626: e8 50 03 00 00 call 397b <fork> if(pid == 0){ 362b: 83 c4 10 add $0x10,%esp 362e: 85 c0 test %eax,%eax 3630: 74 1b je 364d <uio+0x3d> } else if(pid < 0){ 3632: 78 3d js 3671 <uio+0x61> wait(); 3634: e8 52 03 00 00 call 398b <wait> printf(1, "uio test done\n"); 3639: 83 ec 08 sub $0x8,%esp 363c: 68 04 4e 00 00 push $0x4e04 3641: 6a 01 push $0x1 3643: e8 98 04 00 00 call 3ae0 <printf> } 3648: 83 c4 10 add $0x10,%esp 364b: c9 leave 364c: c3 ret asm volatile("outb %0,%1"::"a"(val), "d" (port)); 364d: b8 09 00 00 00 mov $0x9,%eax 3652: ba 70 00 00 00 mov $0x70,%edx 3657: ee out %al,(%dx) asm volatile("inb %1,%0" : "=a" (val) : "d" (port)); 3658: ba 71 00 00 00 mov $0x71,%edx 365d: ec in (%dx),%al printf(1, "uio: uio succeeded; test FAILED\n"); 365e: 52 push %edx 365f: 52 push %edx 3660: 68 90 55 00 00 push $0x5590 3665: 6a 01 push $0x1 3667: e8 74 04 00 00 call 3ae0 <printf> exit(); 366c: e8 12 03 00 00 call 3983 <exit> printf (1, "fork failed\n"); 3671: 50 push %eax 3672: 50 push %eax 3673: 68 89 4d 00 00 push $0x4d89 3678: 6a 01 push $0x1 367a: e8 61 04 00 00 call 3ae0 <printf> exit(); 367f: e8 ff 02 00 00 call 3983 <exit> 3684: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 368b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 368f: 90 nop 00003690 <argptest>: { 3690: f3 0f 1e fb endbr32 3694: 55 push %ebp 3695: 89 e5 mov %esp,%ebp 3697: 53 push %ebx 3698: 83 ec 0c sub $0xc,%esp fd = open("init", O_RDONLY); 369b: 6a 00 push $0x0 369d: 68 13 4e 00 00 push $0x4e13 36a2: e8 1c 03 00 00 call 39c3 <open> if (fd < 0) { 36a7: 83 c4 10 add $0x10,%esp 36aa: 85 c0 test %eax,%eax 36ac: 78 39 js 36e7 <argptest+0x57> read(fd, sbrk(0) - 1, -1); 36ae: 83 ec 0c sub $0xc,%esp 36b1: 89 c3 mov %eax,%ebx 36b3: 6a 00 push $0x0 36b5: e8 51 03 00 00 call 3a0b <sbrk> 36ba: 83 c4 0c add $0xc,%esp 36bd: 83 e8 01 sub $0x1,%eax 36c0: 6a ff push $0xffffffff 36c2: 50 push %eax 36c3: 53 push %ebx 36c4: e8 d2 02 00 00 call 399b <read> close(fd); 36c9: 89 1c 24 mov %ebx,(%esp) 36cc: e8 da 02 00 00 call 39ab <close> printf(1, "arg test passed\n"); 36d1: 58 pop %eax 36d2: 5a pop %edx 36d3: 68 25 4e 00 00 push $0x4e25 36d8: 6a 01 push $0x1 36da: e8 01 04 00 00 call 3ae0 <printf> } 36df: 8b 5d fc mov -0x4(%ebp),%ebx 36e2: 83 c4 10 add $0x10,%esp 36e5: c9 leave 36e6: c3 ret printf(2, "open failed\n"); 36e7: 51 push %ecx 36e8: 51 push %ecx 36e9: 68 18 4e 00 00 push $0x4e18 36ee: 6a 02 push $0x2 36f0: e8 eb 03 00 00 call 3ae0 <printf> exit(); 36f5: e8 89 02 00 00 call 3983 <exit> 36fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00003700 <rand>: { 3700: f3 0f 1e fb endbr32 randstate = randstate * 1664525 + 1013904223; 3704: 69 05 dc 5e 00 00 0d imul $0x19660d,0x5edc,%eax 370b: 66 19 00 370e: 05 5f f3 6e 3c add $0x3c6ef35f,%eax 3713: a3 dc 5e 00 00 mov %eax,0x5edc } 3718: c3 ret 3719: 66 90 xchg %ax,%ax 371b: 66 90 xchg %ax,%ax 371d: 66 90 xchg %ax,%ax 371f: 90 nop 00003720 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 3720: f3 0f 1e fb endbr32 3724: 55 push %ebp char *os; os = s; while((*s++ = *t++) != 0) 3725: 31 c0 xor %eax,%eax { 3727: 89 e5 mov %esp,%ebp 3729: 53 push %ebx 372a: 8b 4d 08 mov 0x8(%ebp),%ecx 372d: 8b 5d 0c mov 0xc(%ebp),%ebx while((*s++ = *t++) != 0) 3730: 0f b6 14 03 movzbl (%ebx,%eax,1),%edx 3734: 88 14 01 mov %dl,(%ecx,%eax,1) 3737: 83 c0 01 add $0x1,%eax 373a: 84 d2 test %dl,%dl 373c: 75 f2 jne 3730 <strcpy+0x10> ; return os; } 373e: 89 c8 mov %ecx,%eax 3740: 5b pop %ebx 3741: 5d pop %ebp 3742: c3 ret 3743: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 374a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00003750 <strcmp>: int strcmp(const char *p, const char *q) { 3750: f3 0f 1e fb endbr32 3754: 55 push %ebp 3755: 89 e5 mov %esp,%ebp 3757: 53 push %ebx 3758: 8b 4d 08 mov 0x8(%ebp),%ecx 375b: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) 375e: 0f b6 01 movzbl (%ecx),%eax 3761: 0f b6 1a movzbl (%edx),%ebx 3764: 84 c0 test %al,%al 3766: 75 19 jne 3781 <strcmp+0x31> 3768: eb 26 jmp 3790 <strcmp+0x40> 376a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 3770: 0f b6 41 01 movzbl 0x1(%ecx),%eax p++, q++; 3774: 83 c1 01 add $0x1,%ecx 3777: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 377a: 0f b6 1a movzbl (%edx),%ebx 377d: 84 c0 test %al,%al 377f: 74 0f je 3790 <strcmp+0x40> 3781: 38 d8 cmp %bl,%al 3783: 74 eb je 3770 <strcmp+0x20> return (uchar)*p - (uchar)*q; 3785: 29 d8 sub %ebx,%eax } 3787: 5b pop %ebx 3788: 5d pop %ebp 3789: c3 ret 378a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 3790: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 3792: 29 d8 sub %ebx,%eax } 3794: 5b pop %ebx 3795: 5d pop %ebp 3796: c3 ret 3797: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 379e: 66 90 xchg %ax,%ax 000037a0 <strlen>: uint strlen(const char *s) { 37a0: f3 0f 1e fb endbr32 37a4: 55 push %ebp 37a5: 89 e5 mov %esp,%ebp 37a7: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) 37aa: 80 3a 00 cmpb $0x0,(%edx) 37ad: 74 21 je 37d0 <strlen+0x30> 37af: 31 c0 xor %eax,%eax 37b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 37b8: 83 c0 01 add $0x1,%eax 37bb: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 37bf: 89 c1 mov %eax,%ecx 37c1: 75 f5 jne 37b8 <strlen+0x18> ; return n; } 37c3: 89 c8 mov %ecx,%eax 37c5: 5d pop %ebp 37c6: c3 ret 37c7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 37ce: 66 90 xchg %ax,%ax for(n = 0; s[n]; n++) 37d0: 31 c9 xor %ecx,%ecx } 37d2: 5d pop %ebp 37d3: 89 c8 mov %ecx,%eax 37d5: c3 ret 37d6: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 37dd: 8d 76 00 lea 0x0(%esi),%esi 000037e0 <memset>: void* memset(void *dst, int c, uint n) { 37e0: f3 0f 1e fb endbr32 37e4: 55 push %ebp 37e5: 89 e5 mov %esp,%ebp 37e7: 57 push %edi 37e8: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 37eb: 8b 4d 10 mov 0x10(%ebp),%ecx 37ee: 8b 45 0c mov 0xc(%ebp),%eax 37f1: 89 d7 mov %edx,%edi 37f3: fc cld 37f4: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 37f6: 89 d0 mov %edx,%eax 37f8: 5f pop %edi 37f9: 5d pop %ebp 37fa: c3 ret 37fb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 37ff: 90 nop 00003800 <strchr>: char* strchr(const char *s, char c) { 3800: f3 0f 1e fb endbr32 3804: 55 push %ebp 3805: 89 e5 mov %esp,%ebp 3807: 8b 45 08 mov 0x8(%ebp),%eax 380a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 380e: 0f b6 10 movzbl (%eax),%edx 3811: 84 d2 test %dl,%dl 3813: 75 16 jne 382b <strchr+0x2b> 3815: eb 21 jmp 3838 <strchr+0x38> 3817: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 381e: 66 90 xchg %ax,%ax 3820: 0f b6 50 01 movzbl 0x1(%eax),%edx 3824: 83 c0 01 add $0x1,%eax 3827: 84 d2 test %dl,%dl 3829: 74 0d je 3838 <strchr+0x38> if(*s == c) 382b: 38 d1 cmp %dl,%cl 382d: 75 f1 jne 3820 <strchr+0x20> return (char*)s; return 0; } 382f: 5d pop %ebp 3830: c3 ret 3831: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return 0; 3838: 31 c0 xor %eax,%eax } 383a: 5d pop %ebp 383b: c3 ret 383c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00003840 <gets>: char* gets(char *buf, int max) { 3840: f3 0f 1e fb endbr32 3844: 55 push %ebp 3845: 89 e5 mov %esp,%ebp 3847: 57 push %edi 3848: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 3849: 31 f6 xor %esi,%esi { 384b: 53 push %ebx 384c: 89 f3 mov %esi,%ebx 384e: 83 ec 1c sub $0x1c,%esp 3851: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 3854: eb 33 jmp 3889 <gets+0x49> 3856: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 385d: 8d 76 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 3860: 83 ec 04 sub $0x4,%esp 3863: 8d 45 e7 lea -0x19(%ebp),%eax 3866: 6a 01 push $0x1 3868: 50 push %eax 3869: 6a 00 push $0x0 386b: e8 2b 01 00 00 call 399b <read> if(cc < 1) 3870: 83 c4 10 add $0x10,%esp 3873: 85 c0 test %eax,%eax 3875: 7e 1c jle 3893 <gets+0x53> break; buf[i++] = c; 3877: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 387b: 83 c7 01 add $0x1,%edi 387e: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 3881: 3c 0a cmp $0xa,%al 3883: 74 23 je 38a8 <gets+0x68> 3885: 3c 0d cmp $0xd,%al 3887: 74 1f je 38a8 <gets+0x68> for(i=0; i+1 < max; ){ 3889: 83 c3 01 add $0x1,%ebx 388c: 89 fe mov %edi,%esi 388e: 3b 5d 0c cmp 0xc(%ebp),%ebx 3891: 7c cd jl 3860 <gets+0x20> 3893: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 3895: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 3898: c6 03 00 movb $0x0,(%ebx) } 389b: 8d 65 f4 lea -0xc(%ebp),%esp 389e: 5b pop %ebx 389f: 5e pop %esi 38a0: 5f pop %edi 38a1: 5d pop %ebp 38a2: c3 ret 38a3: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 38a7: 90 nop 38a8: 8b 75 08 mov 0x8(%ebp),%esi 38ab: 8b 45 08 mov 0x8(%ebp),%eax 38ae: 01 de add %ebx,%esi 38b0: 89 f3 mov %esi,%ebx buf[i] = '\0'; 38b2: c6 03 00 movb $0x0,(%ebx) } 38b5: 8d 65 f4 lea -0xc(%ebp),%esp 38b8: 5b pop %ebx 38b9: 5e pop %esi 38ba: 5f pop %edi 38bb: 5d pop %ebp 38bc: c3 ret 38bd: 8d 76 00 lea 0x0(%esi),%esi 000038c0 <stat>: int stat(const char *n, struct stat *st) { 38c0: f3 0f 1e fb endbr32 38c4: 55 push %ebp 38c5: 89 e5 mov %esp,%ebp 38c7: 56 push %esi 38c8: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 38c9: 83 ec 08 sub $0x8,%esp 38cc: 6a 00 push $0x0 38ce: ff 75 08 pushl 0x8(%ebp) 38d1: e8 ed 00 00 00 call 39c3 <open> if(fd < 0) 38d6: 83 c4 10 add $0x10,%esp 38d9: 85 c0 test %eax,%eax 38db: 78 2b js 3908 <stat+0x48> return -1; r = fstat(fd, st); 38dd: 83 ec 08 sub $0x8,%esp 38e0: ff 75 0c pushl 0xc(%ebp) 38e3: 89 c3 mov %eax,%ebx 38e5: 50 push %eax 38e6: e8 f0 00 00 00 call 39db <fstat> close(fd); 38eb: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 38ee: 89 c6 mov %eax,%esi close(fd); 38f0: e8 b6 00 00 00 call 39ab <close> return r; 38f5: 83 c4 10 add $0x10,%esp } 38f8: 8d 65 f8 lea -0x8(%ebp),%esp 38fb: 89 f0 mov %esi,%eax 38fd: 5b pop %ebx 38fe: 5e pop %esi 38ff: 5d pop %ebp 3900: c3 ret 3901: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return -1; 3908: be ff ff ff ff mov $0xffffffff,%esi 390d: eb e9 jmp 38f8 <stat+0x38> 390f: 90 nop 00003910 <atoi>: int atoi(const char *s) { 3910: f3 0f 1e fb endbr32 3914: 55 push %ebp 3915: 89 e5 mov %esp,%ebp 3917: 53 push %ebx 3918: 8b 55 08 mov 0x8(%ebp),%edx int n; n = 0; while('0' <= *s && *s <= '9') 391b: 0f be 02 movsbl (%edx),%eax 391e: 8d 48 d0 lea -0x30(%eax),%ecx 3921: 80 f9 09 cmp $0x9,%cl n = 0; 3924: b9 00 00 00 00 mov $0x0,%ecx while('0' <= *s && *s <= '9') 3929: 77 1a ja 3945 <atoi+0x35> 392b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 392f: 90 nop n = n*10 + *s++ - '0'; 3930: 83 c2 01 add $0x1,%edx 3933: 8d 0c 89 lea (%ecx,%ecx,4),%ecx 3936: 8d 4c 48 d0 lea -0x30(%eax,%ecx,2),%ecx while('0' <= *s && *s <= '9') 393a: 0f be 02 movsbl (%edx),%eax 393d: 8d 58 d0 lea -0x30(%eax),%ebx 3940: 80 fb 09 cmp $0x9,%bl 3943: 76 eb jbe 3930 <atoi+0x20> return n; } 3945: 89 c8 mov %ecx,%eax 3947: 5b pop %ebx 3948: 5d pop %ebp 3949: c3 ret 394a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00003950 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 3950: f3 0f 1e fb endbr32 3954: 55 push %ebp 3955: 89 e5 mov %esp,%ebp 3957: 57 push %edi 3958: 8b 45 10 mov 0x10(%ebp),%eax 395b: 8b 55 08 mov 0x8(%ebp),%edx 395e: 56 push %esi 395f: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 3962: 85 c0 test %eax,%eax 3964: 7e 0f jle 3975 <memmove+0x25> 3966: 01 d0 add %edx,%eax dst = vdst; 3968: 89 d7 mov %edx,%edi 396a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi *dst++ = *src++; 3970: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) 3971: 39 f8 cmp %edi,%eax 3973: 75 fb jne 3970 <memmove+0x20> return vdst; } 3975: 5e pop %esi 3976: 89 d0 mov %edx,%eax 3978: 5f pop %edi 3979: 5d pop %ebp 397a: c3 ret 0000397b <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 397b: b8 01 00 00 00 mov $0x1,%eax 3980: cd 40 int $0x40 3982: c3 ret 00003983 <exit>: SYSCALL(exit) 3983: b8 02 00 00 00 mov $0x2,%eax 3988: cd 40 int $0x40 398a: c3 ret 0000398b <wait>: SYSCALL(wait) 398b: b8 03 00 00 00 mov $0x3,%eax 3990: cd 40 int $0x40 3992: c3 ret 00003993 <pipe>: SYSCALL(pipe) 3993: b8 04 00 00 00 mov $0x4,%eax 3998: cd 40 int $0x40 399a: c3 ret 0000399b <read>: SYSCALL(read) 399b: b8 05 00 00 00 mov $0x5,%eax 39a0: cd 40 int $0x40 39a2: c3 ret 000039a3 <write>: SYSCALL(write) 39a3: b8 10 00 00 00 mov $0x10,%eax 39a8: cd 40 int $0x40 39aa: c3 ret 000039ab <close>: SYSCALL(close) 39ab: b8 15 00 00 00 mov $0x15,%eax 39b0: cd 40 int $0x40 39b2: c3 ret 000039b3 <kill>: SYSCALL(kill) 39b3: b8 06 00 00 00 mov $0x6,%eax 39b8: cd 40 int $0x40 39ba: c3 ret 000039bb <exec>: SYSCALL(exec) 39bb: b8 07 00 00 00 mov $0x7,%eax 39c0: cd 40 int $0x40 39c2: c3 ret 000039c3 <open>: SYSCALL(open) 39c3: b8 0f 00 00 00 mov $0xf,%eax 39c8: cd 40 int $0x40 39ca: c3 ret 000039cb <mknod>: SYSCALL(mknod) 39cb: b8 11 00 00 00 mov $0x11,%eax 39d0: cd 40 int $0x40 39d2: c3 ret 000039d3 <unlink>: SYSCALL(unlink) 39d3: b8 12 00 00 00 mov $0x12,%eax 39d8: cd 40 int $0x40 39da: c3 ret 000039db <fstat>: SYSCALL(fstat) 39db: b8 08 00 00 00 mov $0x8,%eax 39e0: cd 40 int $0x40 39e2: c3 ret 000039e3 <link>: SYSCALL(link) 39e3: b8 13 00 00 00 mov $0x13,%eax 39e8: cd 40 int $0x40 39ea: c3 ret 000039eb <mkdir>: SYSCALL(mkdir) 39eb: b8 14 00 00 00 mov $0x14,%eax 39f0: cd 40 int $0x40 39f2: c3 ret 000039f3 <chdir>: SYSCALL(chdir) 39f3: b8 09 00 00 00 mov $0x9,%eax 39f8: cd 40 int $0x40 39fa: c3 ret 000039fb <dup>: SYSCALL(dup) 39fb: b8 0a 00 00 00 mov $0xa,%eax 3a00: cd 40 int $0x40 3a02: c3 ret 00003a03 <getpid>: SYSCALL(getpid) 3a03: b8 0b 00 00 00 mov $0xb,%eax 3a08: cd 40 int $0x40 3a0a: c3 ret 00003a0b <sbrk>: SYSCALL(sbrk) 3a0b: b8 0c 00 00 00 mov $0xc,%eax 3a10: cd 40 int $0x40 3a12: c3 ret 00003a13 <sleep>: SYSCALL(sleep) 3a13: b8 0d 00 00 00 mov $0xd,%eax 3a18: cd 40 int $0x40 3a1a: c3 ret 00003a1b <uptime>: SYSCALL(uptime) 3a1b: b8 0e 00 00 00 mov $0xe,%eax 3a20: cd 40 int $0x40 3a22: c3 ret 00003a23 <getprocs>: SYSCALL(getprocs) 3a23: b8 16 00 00 00 mov $0x16,%eax 3a28: cd 40 int $0x40 3a2a: c3 ret 3a2b: 66 90 xchg %ax,%ax 3a2d: 66 90 xchg %ax,%ax 3a2f: 90 nop 00003a30 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 3a30: 55 push %ebp 3a31: 89 e5 mov %esp,%ebp 3a33: 57 push %edi 3a34: 56 push %esi 3a35: 53 push %ebx 3a36: 83 ec 3c sub $0x3c,%esp 3a39: 89 4d c4 mov %ecx,-0x3c(%ebp) uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 3a3c: 89 d1 mov %edx,%ecx { 3a3e: 89 45 b8 mov %eax,-0x48(%ebp) if(sgn && xx < 0){ 3a41: 85 d2 test %edx,%edx 3a43: 0f 89 7f 00 00 00 jns 3ac8 <printint+0x98> 3a49: f6 45 08 01 testb $0x1,0x8(%ebp) 3a4d: 74 79 je 3ac8 <printint+0x98> neg = 1; 3a4f: c7 45 bc 01 00 00 00 movl $0x1,-0x44(%ebp) x = -xx; 3a56: f7 d9 neg %ecx } else { x = xx; } i = 0; 3a58: 31 db xor %ebx,%ebx 3a5a: 8d 75 d7 lea -0x29(%ebp),%esi 3a5d: 8d 76 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 3a60: 89 c8 mov %ecx,%eax 3a62: 31 d2 xor %edx,%edx 3a64: 89 cf mov %ecx,%edi 3a66: f7 75 c4 divl -0x3c(%ebp) 3a69: 0f b6 92 e8 55 00 00 movzbl 0x55e8(%edx),%edx 3a70: 89 45 c0 mov %eax,-0x40(%ebp) 3a73: 89 d8 mov %ebx,%eax 3a75: 8d 5b 01 lea 0x1(%ebx),%ebx }while((x /= base) != 0); 3a78: 8b 4d c0 mov -0x40(%ebp),%ecx buf[i++] = digits[x % base]; 3a7b: 88 14 1e mov %dl,(%esi,%ebx,1) }while((x /= base) != 0); 3a7e: 39 7d c4 cmp %edi,-0x3c(%ebp) 3a81: 76 dd jbe 3a60 <printint+0x30> if(neg) 3a83: 8b 4d bc mov -0x44(%ebp),%ecx 3a86: 85 c9 test %ecx,%ecx 3a88: 74 0c je 3a96 <printint+0x66> buf[i++] = '-'; 3a8a: c6 44 1d d8 2d movb $0x2d,-0x28(%ebp,%ebx,1) buf[i++] = digits[x % base]; 3a8f: 89 d8 mov %ebx,%eax buf[i++] = '-'; 3a91: ba 2d 00 00 00 mov $0x2d,%edx while(--i >= 0) 3a96: 8b 7d b8 mov -0x48(%ebp),%edi 3a99: 8d 5c 05 d7 lea -0x29(%ebp,%eax,1),%ebx 3a9d: eb 07 jmp 3aa6 <printint+0x76> 3a9f: 90 nop 3aa0: 0f b6 13 movzbl (%ebx),%edx 3aa3: 83 eb 01 sub $0x1,%ebx write(fd, &c, 1); 3aa6: 83 ec 04 sub $0x4,%esp 3aa9: 88 55 d7 mov %dl,-0x29(%ebp) 3aac: 6a 01 push $0x1 3aae: 56 push %esi 3aaf: 57 push %edi 3ab0: e8 ee fe ff ff call 39a3 <write> while(--i >= 0) 3ab5: 83 c4 10 add $0x10,%esp 3ab8: 39 de cmp %ebx,%esi 3aba: 75 e4 jne 3aa0 <printint+0x70> putc(fd, buf[i]); } 3abc: 8d 65 f4 lea -0xc(%ebp),%esp 3abf: 5b pop %ebx 3ac0: 5e pop %esi 3ac1: 5f pop %edi 3ac2: 5d pop %ebp 3ac3: c3 ret 3ac4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 3ac8: c7 45 bc 00 00 00 00 movl $0x0,-0x44(%ebp) 3acf: eb 87 jmp 3a58 <printint+0x28> 3ad1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3ad8: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3adf: 90 nop 00003ae0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3ae0: f3 0f 1e fb endbr32 3ae4: 55 push %ebp 3ae5: 89 e5 mov %esp,%ebp 3ae7: 57 push %edi 3ae8: 56 push %esi 3ae9: 53 push %ebx 3aea: 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++){ 3aed: 8b 75 0c mov 0xc(%ebp),%esi 3af0: 0f b6 1e movzbl (%esi),%ebx 3af3: 84 db test %bl,%bl 3af5: 0f 84 b4 00 00 00 je 3baf <printf+0xcf> ap = (uint*)(void*)&fmt + 1; 3afb: 8d 45 10 lea 0x10(%ebp),%eax 3afe: 83 c6 01 add $0x1,%esi write(fd, &c, 1); 3b01: 8d 7d e7 lea -0x19(%ebp),%edi state = 0; 3b04: 31 d2 xor %edx,%edx ap = (uint*)(void*)&fmt + 1; 3b06: 89 45 d0 mov %eax,-0x30(%ebp) 3b09: eb 33 jmp 3b3e <printf+0x5e> 3b0b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3b0f: 90 nop 3b10: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 3b13: ba 25 00 00 00 mov $0x25,%edx if(c == '%'){ 3b18: 83 f8 25 cmp $0x25,%eax 3b1b: 74 17 je 3b34 <printf+0x54> write(fd, &c, 1); 3b1d: 83 ec 04 sub $0x4,%esp 3b20: 88 5d e7 mov %bl,-0x19(%ebp) 3b23: 6a 01 push $0x1 3b25: 57 push %edi 3b26: ff 75 08 pushl 0x8(%ebp) 3b29: e8 75 fe ff ff call 39a3 <write> 3b2e: 8b 55 d4 mov -0x2c(%ebp),%edx } else { putc(fd, c); 3b31: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 3b34: 0f b6 1e movzbl (%esi),%ebx 3b37: 83 c6 01 add $0x1,%esi 3b3a: 84 db test %bl,%bl 3b3c: 74 71 je 3baf <printf+0xcf> c = fmt[i] & 0xff; 3b3e: 0f be cb movsbl %bl,%ecx 3b41: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 3b44: 85 d2 test %edx,%edx 3b46: 74 c8 je 3b10 <printf+0x30> } } else if(state == '%'){ 3b48: 83 fa 25 cmp $0x25,%edx 3b4b: 75 e7 jne 3b34 <printf+0x54> if(c == 'd'){ 3b4d: 83 f8 64 cmp $0x64,%eax 3b50: 0f 84 9a 00 00 00 je 3bf0 <printf+0x110> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 3b56: 81 e1 f7 00 00 00 and $0xf7,%ecx 3b5c: 83 f9 70 cmp $0x70,%ecx 3b5f: 74 5f je 3bc0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 3b61: 83 f8 73 cmp $0x73,%eax 3b64: 0f 84 d6 00 00 00 je 3c40 <printf+0x160> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 3b6a: 83 f8 63 cmp $0x63,%eax 3b6d: 0f 84 8d 00 00 00 je 3c00 <printf+0x120> putc(fd, *ap); ap++; } else if(c == '%'){ 3b73: 83 f8 25 cmp $0x25,%eax 3b76: 0f 84 b4 00 00 00 je 3c30 <printf+0x150> write(fd, &c, 1); 3b7c: 83 ec 04 sub $0x4,%esp 3b7f: c6 45 e7 25 movb $0x25,-0x19(%ebp) 3b83: 6a 01 push $0x1 3b85: 57 push %edi 3b86: ff 75 08 pushl 0x8(%ebp) 3b89: e8 15 fe ff ff call 39a3 <write> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 3b8e: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 3b91: 83 c4 0c add $0xc,%esp 3b94: 6a 01 push $0x1 3b96: 83 c6 01 add $0x1,%esi 3b99: 57 push %edi 3b9a: ff 75 08 pushl 0x8(%ebp) 3b9d: e8 01 fe ff ff call 39a3 <write> for(i = 0; fmt[i]; i++){ 3ba2: 0f b6 5e ff movzbl -0x1(%esi),%ebx putc(fd, c); 3ba6: 83 c4 10 add $0x10,%esp } state = 0; 3ba9: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ 3bab: 84 db test %bl,%bl 3bad: 75 8f jne 3b3e <printf+0x5e> } } } 3baf: 8d 65 f4 lea -0xc(%ebp),%esp 3bb2: 5b pop %ebx 3bb3: 5e pop %esi 3bb4: 5f pop %edi 3bb5: 5d pop %ebp 3bb6: c3 ret 3bb7: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3bbe: 66 90 xchg %ax,%ax printint(fd, *ap, 16, 0); 3bc0: 83 ec 0c sub $0xc,%esp 3bc3: b9 10 00 00 00 mov $0x10,%ecx 3bc8: 6a 00 push $0x0 3bca: 8b 5d d0 mov -0x30(%ebp),%ebx 3bcd: 8b 45 08 mov 0x8(%ebp),%eax 3bd0: 8b 13 mov (%ebx),%edx 3bd2: e8 59 fe ff ff call 3a30 <printint> ap++; 3bd7: 89 d8 mov %ebx,%eax 3bd9: 83 c4 10 add $0x10,%esp state = 0; 3bdc: 31 d2 xor %edx,%edx ap++; 3bde: 83 c0 04 add $0x4,%eax 3be1: 89 45 d0 mov %eax,-0x30(%ebp) 3be4: e9 4b ff ff ff jmp 3b34 <printf+0x54> 3be9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printint(fd, *ap, 10, 1); 3bf0: 83 ec 0c sub $0xc,%esp 3bf3: b9 0a 00 00 00 mov $0xa,%ecx 3bf8: 6a 01 push $0x1 3bfa: eb ce jmp 3bca <printf+0xea> 3bfc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, *ap); 3c00: 8b 5d d0 mov -0x30(%ebp),%ebx write(fd, &c, 1); 3c03: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 3c06: 8b 03 mov (%ebx),%eax write(fd, &c, 1); 3c08: 6a 01 push $0x1 ap++; 3c0a: 83 c3 04 add $0x4,%ebx write(fd, &c, 1); 3c0d: 57 push %edi 3c0e: ff 75 08 pushl 0x8(%ebp) putc(fd, *ap); 3c11: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 3c14: e8 8a fd ff ff call 39a3 <write> ap++; 3c19: 89 5d d0 mov %ebx,-0x30(%ebp) 3c1c: 83 c4 10 add $0x10,%esp state = 0; 3c1f: 31 d2 xor %edx,%edx 3c21: e9 0e ff ff ff jmp 3b34 <printf+0x54> 3c26: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3c2d: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); 3c30: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); 3c33: 83 ec 04 sub $0x4,%esp 3c36: e9 59 ff ff ff jmp 3b94 <printf+0xb4> 3c3b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3c3f: 90 nop s = (char*)*ap; 3c40: 8b 45 d0 mov -0x30(%ebp),%eax 3c43: 8b 18 mov (%eax),%ebx ap++; 3c45: 83 c0 04 add $0x4,%eax 3c48: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) 3c4b: 85 db test %ebx,%ebx 3c4d: 74 17 je 3c66 <printf+0x186> while(*s != 0){ 3c4f: 0f b6 03 movzbl (%ebx),%eax state = 0; 3c52: 31 d2 xor %edx,%edx while(*s != 0){ 3c54: 84 c0 test %al,%al 3c56: 0f 84 d8 fe ff ff je 3b34 <printf+0x54> 3c5c: 89 75 d4 mov %esi,-0x2c(%ebp) 3c5f: 89 de mov %ebx,%esi 3c61: 8b 5d 08 mov 0x8(%ebp),%ebx 3c64: eb 1a jmp 3c80 <printf+0x1a0> s = "(null)"; 3c66: bb de 55 00 00 mov $0x55de,%ebx while(*s != 0){ 3c6b: 89 75 d4 mov %esi,-0x2c(%ebp) 3c6e: b8 28 00 00 00 mov $0x28,%eax 3c73: 89 de mov %ebx,%esi 3c75: 8b 5d 08 mov 0x8(%ebp),%ebx 3c78: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3c7f: 90 nop write(fd, &c, 1); 3c80: 83 ec 04 sub $0x4,%esp s++; 3c83: 83 c6 01 add $0x1,%esi 3c86: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); 3c89: 6a 01 push $0x1 3c8b: 57 push %edi 3c8c: 53 push %ebx 3c8d: e8 11 fd ff ff call 39a3 <write> while(*s != 0){ 3c92: 0f b6 06 movzbl (%esi),%eax 3c95: 83 c4 10 add $0x10,%esp 3c98: 84 c0 test %al,%al 3c9a: 75 e4 jne 3c80 <printf+0x1a0> 3c9c: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; 3c9f: 31 d2 xor %edx,%edx 3ca1: e9 8e fe ff ff jmp 3b34 <printf+0x54> 3ca6: 66 90 xchg %ax,%ax 3ca8: 66 90 xchg %ax,%ax 3caa: 66 90 xchg %ax,%ax 3cac: 66 90 xchg %ax,%ax 3cae: 66 90 xchg %ax,%ax 00003cb0 <free>: static Header base; static Header *freep; void free(void *ap) { 3cb0: f3 0f 1e fb endbr32 3cb4: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 3cb5: a1 80 5f 00 00 mov 0x5f80,%eax { 3cba: 89 e5 mov %esp,%ebp 3cbc: 57 push %edi 3cbd: 56 push %esi 3cbe: 53 push %ebx 3cbf: 8b 5d 08 mov 0x8(%ebp),%ebx 3cc2: 8b 10 mov (%eax),%edx bp = (Header*)ap - 1; 3cc4: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 3cc7: 39 c8 cmp %ecx,%eax 3cc9: 73 15 jae 3ce0 <free+0x30> 3ccb: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3ccf: 90 nop 3cd0: 39 d1 cmp %edx,%ecx 3cd2: 72 14 jb 3ce8 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 3cd4: 39 d0 cmp %edx,%eax 3cd6: 73 10 jae 3ce8 <free+0x38> { 3cd8: 89 d0 mov %edx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 3cda: 8b 10 mov (%eax),%edx 3cdc: 39 c8 cmp %ecx,%eax 3cde: 72 f0 jb 3cd0 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 3ce0: 39 d0 cmp %edx,%eax 3ce2: 72 f4 jb 3cd8 <free+0x28> 3ce4: 39 d1 cmp %edx,%ecx 3ce6: 73 f0 jae 3cd8 <free+0x28> break; if(bp + bp->s.size == p->s.ptr){ 3ce8: 8b 73 fc mov -0x4(%ebx),%esi 3ceb: 8d 3c f1 lea (%ecx,%esi,8),%edi 3cee: 39 fa cmp %edi,%edx 3cf0: 74 1e je 3d10 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 3cf2: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 3cf5: 8b 50 04 mov 0x4(%eax),%edx 3cf8: 8d 34 d0 lea (%eax,%edx,8),%esi 3cfb: 39 f1 cmp %esi,%ecx 3cfd: 74 28 je 3d27 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 3cff: 89 08 mov %ecx,(%eax) freep = p; } 3d01: 5b pop %ebx freep = p; 3d02: a3 80 5f 00 00 mov %eax,0x5f80 } 3d07: 5e pop %esi 3d08: 5f pop %edi 3d09: 5d pop %ebp 3d0a: c3 ret 3d0b: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3d0f: 90 nop bp->s.size += p->s.ptr->s.size; 3d10: 03 72 04 add 0x4(%edx),%esi 3d13: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 3d16: 8b 10 mov (%eax),%edx 3d18: 8b 12 mov (%edx),%edx 3d1a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 3d1d: 8b 50 04 mov 0x4(%eax),%edx 3d20: 8d 34 d0 lea (%eax,%edx,8),%esi 3d23: 39 f1 cmp %esi,%ecx 3d25: 75 d8 jne 3cff <free+0x4f> p->s.size += bp->s.size; 3d27: 03 53 fc add -0x4(%ebx),%edx freep = p; 3d2a: a3 80 5f 00 00 mov %eax,0x5f80 p->s.size += bp->s.size; 3d2f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 3d32: 8b 53 f8 mov -0x8(%ebx),%edx 3d35: 89 10 mov %edx,(%eax) } 3d37: 5b pop %ebx 3d38: 5e pop %esi 3d39: 5f pop %edi 3d3a: 5d pop %ebp 3d3b: c3 ret 3d3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00003d40 <malloc>: return freep; } void* malloc(uint nbytes) { 3d40: f3 0f 1e fb endbr32 3d44: 55 push %ebp 3d45: 89 e5 mov %esp,%ebp 3d47: 57 push %edi 3d48: 56 push %esi 3d49: 53 push %ebx 3d4a: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 3d4d: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 3d50: 8b 3d 80 5f 00 00 mov 0x5f80,%edi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 3d56: 8d 70 07 lea 0x7(%eax),%esi 3d59: c1 ee 03 shr $0x3,%esi 3d5c: 83 c6 01 add $0x1,%esi if((prevp = freep) == 0){ 3d5f: 85 ff test %edi,%edi 3d61: 0f 84 a9 00 00 00 je 3e10 <malloc+0xd0> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 3d67: 8b 07 mov (%edi),%eax if(p->s.size >= nunits){ 3d69: 8b 48 04 mov 0x4(%eax),%ecx 3d6c: 39 f1 cmp %esi,%ecx 3d6e: 73 6d jae 3ddd <malloc+0x9d> 3d70: 81 fe 00 10 00 00 cmp $0x1000,%esi 3d76: bb 00 10 00 00 mov $0x1000,%ebx 3d7b: 0f 43 de cmovae %esi,%ebx p = sbrk(nu * sizeof(Header)); 3d7e: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx 3d85: 89 4d e4 mov %ecx,-0x1c(%ebp) 3d88: eb 17 jmp 3da1 <malloc+0x61> 3d8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 3d90: 8b 10 mov (%eax),%edx if(p->s.size >= nunits){ 3d92: 8b 4a 04 mov 0x4(%edx),%ecx 3d95: 39 f1 cmp %esi,%ecx 3d97: 73 4f jae 3de8 <malloc+0xa8> 3d99: 8b 3d 80 5f 00 00 mov 0x5f80,%edi 3d9f: 89 d0 mov %edx,%eax p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 3da1: 39 c7 cmp %eax,%edi 3da3: 75 eb jne 3d90 <malloc+0x50> p = sbrk(nu * sizeof(Header)); 3da5: 83 ec 0c sub $0xc,%esp 3da8: ff 75 e4 pushl -0x1c(%ebp) 3dab: e8 5b fc ff ff call 3a0b <sbrk> if(p == (char*)-1) 3db0: 83 c4 10 add $0x10,%esp 3db3: 83 f8 ff cmp $0xffffffff,%eax 3db6: 74 1b je 3dd3 <malloc+0x93> hp->s.size = nu; 3db8: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 3dbb: 83 ec 0c sub $0xc,%esp 3dbe: 83 c0 08 add $0x8,%eax 3dc1: 50 push %eax 3dc2: e8 e9 fe ff ff call 3cb0 <free> return freep; 3dc7: a1 80 5f 00 00 mov 0x5f80,%eax if((p = morecore(nunits)) == 0) 3dcc: 83 c4 10 add $0x10,%esp 3dcf: 85 c0 test %eax,%eax 3dd1: 75 bd jne 3d90 <malloc+0x50> return 0; } } 3dd3: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 3dd6: 31 c0 xor %eax,%eax } 3dd8: 5b pop %ebx 3dd9: 5e pop %esi 3dda: 5f pop %edi 3ddb: 5d pop %ebp 3ddc: c3 ret if(p->s.size >= nunits){ 3ddd: 89 c2 mov %eax,%edx 3ddf: 89 f8 mov %edi,%eax 3de1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 3de8: 39 ce cmp %ecx,%esi 3dea: 74 54 je 3e40 <malloc+0x100> p->s.size -= nunits; 3dec: 29 f1 sub %esi,%ecx 3dee: 89 4a 04 mov %ecx,0x4(%edx) p += p->s.size; 3df1: 8d 14 ca lea (%edx,%ecx,8),%edx p->s.size = nunits; 3df4: 89 72 04 mov %esi,0x4(%edx) freep = prevp; 3df7: a3 80 5f 00 00 mov %eax,0x5f80 } 3dfc: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 3dff: 8d 42 08 lea 0x8(%edx),%eax } 3e02: 5b pop %ebx 3e03: 5e pop %esi 3e04: 5f pop %edi 3e05: 5d pop %ebp 3e06: c3 ret 3e07: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3e0e: 66 90 xchg %ax,%ax base.s.ptr = freep = prevp = &base; 3e10: c7 05 80 5f 00 00 84 movl $0x5f84,0x5f80 3e17: 5f 00 00 base.s.size = 0; 3e1a: bf 84 5f 00 00 mov $0x5f84,%edi base.s.ptr = freep = prevp = &base; 3e1f: c7 05 84 5f 00 00 84 movl $0x5f84,0x5f84 3e26: 5f 00 00 for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 3e29: 89 f8 mov %edi,%eax base.s.size = 0; 3e2b: c7 05 88 5f 00 00 00 movl $0x0,0x5f88 3e32: 00 00 00 if(p->s.size >= nunits){ 3e35: e9 36 ff ff ff jmp 3d70 <malloc+0x30> 3e3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi prevp->s.ptr = p->s.ptr; 3e40: 8b 0a mov (%edx),%ecx 3e42: 89 08 mov %ecx,(%eax) 3e44: eb b1 jmp 3df7 <malloc+0xb7>
// Copyright 2014 Stellar Development Foundation and contributors. Licensed // under the Apache License, Version 2.0. See the COPYING file at the root // of this distribution or at http://www.apache.org/licenses/LICENSE-2.0 #include "crypto/ShortHash.h" #include "util/Decoder.h" #include "util/GlobalChecks.h" #include <filesystem> #include <json/json.h> #include <sstream> #define CATCH_CONFIG_RUNNER #include "util/asio.h" #include <autocheck/autocheck.hpp> #include "ledger/LedgerTxn.h" #include "ledger/LedgerTxnHeader.h" #include "main/Config.h" #include "main/StellarCoreVersion.h" #include "main/dumpxdr.h" #include "test.h" #include "test/TestUtils.h" #include "util/Logging.h" #include "util/Math.h" #include "util/TmpDir.h" #include "util/XDRCereal.h" #include <cstdlib> #include <fmt/format.h> #include <numeric> #include <time.h> #ifdef _WIN32 #include <process.h> #define GETPID _getpid #include <direct.h> #else #include <unistd.h> #define GETPID getpid #include <sys/stat.h> #endif #include "test/SimpleTestReporter.h" namespace Catch { SimpleTestReporter::~SimpleTestReporter() { } } namespace stellar { // We use a Catch event-listener to re-seed all the PRNGs we know about on every // test, to minimize nondeterministic bleed from one test to the next. struct ReseedPRNGListener : Catch::TestEventListenerBase { using TestEventListenerBase::TestEventListenerBase; static unsigned int sCommandLineSeed; virtual void testCaseStarting(Catch::TestCaseInfo const& testInfo) override { reinitializeAllGlobalStateWithSeed(sCommandLineSeed); } }; unsigned int ReseedPRNGListener::sCommandLineSeed = 0; CATCH_REGISTER_LISTENER(ReseedPRNGListener) // We also use a Catch event-listener to capture a global "current test context" // string that we can retrieve elsewhere (eg. in tx tests that record and // compare metadata). enum class TestTxMetaMode { META_TEST_IGNORE, META_TEST_RECORD, META_TEST_CHECK }; static TestTxMetaMode gTestTxMetaMode{TestTxMetaMode::META_TEST_IGNORE}; struct TestContextListener : Catch::TestEventListenerBase { using TestEventListenerBase::TestEventListenerBase; static std::optional<Catch::TestCaseInfo> sTestCtx; static std::vector<Catch::SectionInfo> sSectCtx; void testCaseStarting(Catch::TestCaseInfo const& testInfo) override { if (gTestTxMetaMode != TestTxMetaMode::META_TEST_IGNORE) { assertThreadIsMain(); releaseAssert(!sTestCtx.has_value()); sTestCtx.emplace(testInfo); } } void testCaseEnded(Catch::TestCaseStats const& testCaseStats) override { if (gTestTxMetaMode != TestTxMetaMode::META_TEST_IGNORE) { assertThreadIsMain(); releaseAssert(sTestCtx.has_value()); releaseAssert(sSectCtx.empty()); sTestCtx.reset(); } } void sectionStarting(Catch::SectionInfo const& sectionInfo) override { if (gTestTxMetaMode != TestTxMetaMode::META_TEST_IGNORE) { assertThreadIsMain(); sSectCtx.emplace_back(sectionInfo); } } void sectionEnded(Catch::SectionStats const& sectionStats) override { if (gTestTxMetaMode != TestTxMetaMode::META_TEST_IGNORE) { assertThreadIsMain(); sSectCtx.pop_back(); } } }; CATCH_REGISTER_LISTENER(TestContextListener) namespace stdfs = std::filesystem; std::optional<Catch::TestCaseInfo> TestContextListener::sTestCtx; std::vector<Catch::SectionInfo> TestContextListener::sSectCtx; static std::map<stdfs::path, std::map<std::string, std::pair<bool, std::vector<uint64_t>>>> gTestTxMetadata; static std::optional<std::ofstream> gDebugTestTxMeta; static std::vector<std::string> gTestMetrics; static std::vector<std::unique_ptr<Config>> gTestCfg[Config::TESTDB_MODES]; static std::vector<TmpDir> gTestRoots; static bool gTestAllVersions{false}; static std::vector<uint32> gVersionsToTest; int gBaseInstance{0}; bool force_sqlite = (std::getenv("STELLAR_FORCE_SQLITE") != nullptr); static void saveTestTxMeta(stdfs::path const& dir); static void loadTestTxMeta(stdfs::path const& dir); static void reportTestTxMeta(); // if this method is used outside of the catch test cases, gTestRoots needs to // be manually cleared using cleanupTmpDirs. If this isn't done, gTestRoots will // try to use the logger when it is destructed, which is an issue because the // logger will have been destroyed. Config const& getTestConfig(int instanceNumber, Config::TestDbMode mode) { instanceNumber += gBaseInstance; if (mode == Config::TESTDB_DEFAULT) { // by default, tests should be run with in memory SQLITE as it's faster // you can change this by enabling the appropriate line below mode = Config::TESTDB_IN_MEMORY_SQLITE; // mode = Config::TESTDB_ON_DISK_SQLITE; // mode = Config::TESTDB_POSTGRESQL; } auto& cfgs = gTestCfg[mode]; if (cfgs.size() <= static_cast<size_t>(instanceNumber)) { cfgs.resize(instanceNumber + 1); } if (!cfgs[instanceNumber]) { if (gTestRoots.empty()) { gTestRoots.emplace_back( fmt::format("stellar-core-test-{}", gBaseInstance)); } auto const& testBase = gTestRoots[0].getName(); gTestRoots.emplace_back( fmt::format("{}/test-{}", testBase, instanceNumber)); std::string rootDir = gTestRoots.back().getName(); rootDir += "/"; cfgs[instanceNumber] = std::make_unique<Config>(); Config& thisConfig = *cfgs[instanceNumber]; thisConfig.USE_CONFIG_FOR_GENESIS = true; thisConfig.BUCKET_DIR_PATH = rootDir + "bucket"; thisConfig.INVARIANT_CHECKS = {".*"}; thisConfig.ALLOW_LOCALHOST_FOR_TESTING = true; // this forces to pick up any other potential upgrades thisConfig.TESTING_UPGRADE_DATETIME = VirtualClock::from_time_t(1); // Tests are run in standalone by default, meaning that no external // listening interfaces are opened (all sockets must be manually created // and connected loopback sockets), no external connections are // attempted. thisConfig.RUN_STANDALONE = true; thisConfig.FORCE_SCP = true; thisConfig.MANUAL_CLOSE = true; thisConfig.TEST_CASES_ENABLED = true; thisConfig.PEER_PORT = static_cast<unsigned short>(DEFAULT_PEER_PORT + instanceNumber * 2); thisConfig.HTTP_PORT = static_cast<unsigned short>( DEFAULT_PEER_PORT + instanceNumber * 2 + 1); // We set a secret key by default as FORCE_SCP is true by // default and we do need a NODE_SEED to start a new network. // // Because test configs are built lazily and cached / persist across // tests, we do _not_ use the reset-per-test global PRNG to derive their // secret keys (this would produce inter-test coupling, including // collisions). Instead we derive each from command-line seed and test // config instance number, and try to avoid zero, one, or other default // seeds the global PRNG might have been seeded with by default (which // could thereby collide). thisConfig.NODE_SEED = SecretKey::pseudoRandomForTestingFromSeed( 0xFFFF0000 + (instanceNumber ^ ReseedPRNGListener::sCommandLineSeed)); thisConfig.NODE_IS_VALIDATOR = true; // single node setup thisConfig.QUORUM_SET.validators.push_back( thisConfig.NODE_SEED.getPublicKey()); thisConfig.QUORUM_SET.threshold = 1; thisConfig.UNSAFE_QUORUM = true; thisConfig.NETWORK_PASSPHRASE = "(V) (;,,;) (V)"; std::ostringstream dbname; switch (mode) { case Config::TESTDB_IN_MEMORY_SQLITE: dbname << "sqlite3://:memory:"; // When we're running on an in-memory sqlite we're // probably not concerned with bucket durability. thisConfig.DISABLE_XDR_FSYNC = true; break; case Config::TESTDB_ON_DISK_SQLITE: dbname << "sqlite3://" << rootDir << "test.db"; break; #ifdef USE_POSTGRES case Config::TESTDB_POSTGRESQL: dbname << "postgresql://dbname=test" << instanceNumber; break; #endif default: abort(); } thisConfig.DATABASE = SecretValue{dbname.str()}; thisConfig.REPORT_METRICS = gTestMetrics; // disable maintenance thisConfig.AUTOMATIC_MAINTENANCE_COUNT = 0; // disable self-check thisConfig.AUTOMATIC_SELF_CHECK_PERIOD = std::chrono::seconds(0); // only spin up a small number of worker threads thisConfig.WORKER_THREADS = 2; thisConfig.QUORUM_INTERSECTION_CHECKER = false; thisConfig.METADATA_DEBUG_LEDGERS = 0; #ifdef BEST_OFFER_DEBUGGING thisConfig.BEST_OFFER_DEBUGGING_ENABLED = true; #endif } return *cfgs[instanceNumber]; } int runTest(CommandLineArgs const& args) { LogLevel logLevel{LogLevel::LVL_INFO}; Catch::Session session{}; auto& seed = session.configData().rngSeed; // rotate the seed every 24 hours seed = static_cast<unsigned int>(std::time(nullptr)) / (24 * 3600); std::string recordTestTxMeta; std::string checkTestTxMeta; std::string debugTestTxMeta; auto parser = session.cli(); parser |= Catch::clara::Opt( [&](std::string const& arg) { logLevel = Logging::getLLfromString(arg); }, "LEVEL")["--ll"]("set the log level"); parser |= Catch::clara::Opt(gTestMetrics, "METRIC-NAME")["--metric"]( "report metric METRIC-NAME on exit"); parser |= Catch::clara::Opt(gTestAllVersions)["--all-versions"]( "test all versions"); parser |= Catch::clara::Opt(gVersionsToTest, "version")["--version"]( "test specific version(s)"); parser |= Catch::clara::Opt(gBaseInstance, "offset")["--base-instance"]( "instance number offset so multiple instances of " "stellar-core can run tests concurrently"); parser |= Catch::clara::Opt(recordTestTxMeta, "DIRNAME")["--record-test-tx-meta"]( "record baseline TxMeta from all tests"); parser |= Catch::clara::Opt(checkTestTxMeta, "DIRNAME")["--check-test-tx-meta"]( "check TxMeta from all tests against recorded baseline"); parser |= Catch::clara::Opt(debugTestTxMeta, "FILENAME")["--debug-test-tx-meta"]( "dump full TxMeta from all tests to FILENAME"); session.cli(parser); auto result = session.cli().parse( args.mCommandName, Catch::clara::detail::TokenStream{ std::begin(args.mArgs), std::end(args.mArgs)}); if (!result) { writeWithTextFlow(std::cerr, result.errorMessage()); writeWithTextFlow(std::cerr, args.mCommandDescription); session.cli().writeToStream(std::cerr); return 1; } if (session.configData().showHelp) { writeWithTextFlow(std::cout, args.mCommandDescription); session.cli().writeToStream(std::cout); return 0; } if (session.configData().libIdentify) { session.libIdentify(); return 0; } ReseedPRNGListener::sCommandLineSeed = seed; reinitializeAllGlobalStateWithSeed(seed); if (gVersionsToTest.empty()) { gVersionsToTest.emplace_back(Config::CURRENT_LEDGER_PROTOCOL_VERSION); } if (!recordTestTxMeta.empty()) { if (!checkTestTxMeta.empty()) { LOG_ERROR(DEFAULT_LOG, "Options --record-test-tx-meta and --check-test-tx-meta " "are mutually exclusive"); return 1; } gTestTxMetaMode = TestTxMetaMode::META_TEST_RECORD; } if (!checkTestTxMeta.empty()) { gTestTxMetaMode = TestTxMetaMode::META_TEST_CHECK; loadTestTxMeta(checkTestTxMeta); } if (!debugTestTxMeta.empty()) { gDebugTestTxMeta.emplace(debugTestTxMeta); releaseAssert(gDebugTestTxMeta.value().good()); } // Note: Have to setLogLevel twice here to ensure --list-test-names-only is // not mixed with stellar-core logging. Logging::setFmt("<test>"); Logging::setLogLevel(logLevel, nullptr); // use base instance for logging as we're guaranteed to not have conflicting // instances of stellar-core running at the same time with the same base // instance auto logFile = fmt::format("stellar{}.log", gBaseInstance); Logging::setLoggingToFile(logFile); Logging::setLogLevel(logLevel, nullptr); LOG_INFO(DEFAULT_LOG, "Testing stellar-core {}", STELLAR_CORE_VERSION); LOG_INFO(DEFAULT_LOG, "Logging to {}", logFile); auto r = session.run(); gTestRoots.clear(); gTestCfg->clear(); if (r != 0) { LOG_ERROR(DEFAULT_LOG, "Nonzero test result with --rng-seed {}", seed); } if (gTestTxMetaMode == TestTxMetaMode::META_TEST_RECORD) { saveTestTxMeta(recordTestTxMeta); } else if (gTestTxMetaMode == TestTxMetaMode::META_TEST_CHECK) { reportTestTxMeta(); } return r; } void cleanupTmpDirs() { gTestRoots.clear(); } void for_versions_to(uint32 to, Application& app, std::function<void(void)> const& f) { for_versions(1, to, app, f); } void for_versions_from(uint32 from, Application& app, std::function<void(void)> const& f) { for_versions(from, Config::CURRENT_LEDGER_PROTOCOL_VERSION, app, f); } void for_versions_from(std::vector<uint32> const& versions, Application& app, std::function<void(void)> const& f) { for_versions(versions, app, f); for_versions_from(versions.back() + 1, app, f); } void for_all_versions(Application& app, std::function<void(void)> const& f) { for_versions(1, Config::CURRENT_LEDGER_PROTOCOL_VERSION, app, f); } void for_all_versions(Config const& cfg, std::function<void(Config const&)> const& f) { for_versions(1, Config::CURRENT_LEDGER_PROTOCOL_VERSION, cfg, f); } void for_versions(uint32 from, uint32 to, Application& app, std::function<void(void)> const& f) { if (from > to) { return; } auto versions = std::vector<uint32>{}; versions.resize(to - from + 1); std::iota(std::begin(versions), std::end(versions), from); for_versions(versions, app, f); } void for_versions(uint32 from, uint32 to, Config const& cfg, std::function<void(Config const&)> const& f) { if (from > to) { return; } auto versions = std::vector<uint32>{}; versions.resize(to - from + 1); std::iota(std::begin(versions), std::end(versions), from); for_versions(versions, cfg, f); } void for_versions(std::vector<uint32> const& versions, Application& app, std::function<void(void)> const& f) { uint32_t previousVersion = 0; { LedgerTxn ltx(app.getLedgerTxnRoot()); previousVersion = ltx.loadHeader().current().ledgerVersion; } for (auto v : versions) { if (!gTestAllVersions && std::find(gVersionsToTest.begin(), gVersionsToTest.end(), v) == gVersionsToTest.end()) { continue; } SECTION("protocol version " + std::to_string(v)) { { LedgerTxn ltx(app.getLedgerTxnRoot()); ltx.loadHeader().current().ledgerVersion = v; ltx.commit(); } f(); } } { LedgerTxn ltx(app.getLedgerTxnRoot()); ltx.loadHeader().current().ledgerVersion = previousVersion; ltx.commit(); } } void for_versions(std::vector<uint32> const& versions, Config const& cfg, std::function<void(Config const&)> const& f) { for (auto v : versions) { if (!gTestAllVersions && std::find(gVersionsToTest.begin(), gVersionsToTest.end(), v) == gVersionsToTest.end()) { continue; } SECTION("protocol version " + std::to_string(v)) { Config vcfg = cfg; vcfg.LEDGER_PROTOCOL_VERSION = v; vcfg.TESTING_UPGRADE_LEDGER_PROTOCOL_VERSION = v; f(vcfg); } } } void for_all_versions_except(std::vector<uint32> const& versions, Application& app, std::function<void(void)> const& f) { uint32 lastExcept = 0; for (uint32 except : versions) { for_versions(lastExcept + 1, except - 1, app, f); lastExcept = except; } for_versions_from(lastExcept + 1, app, f); } static void logFatalAndThrow(std::string const& msg) { LOG_FATAL(DEFAULT_LOG, "{}", msg); throw std::runtime_error(msg); } static std::pair<stdfs::path, std::string> getCurrentTestContext() { assertThreadIsMain(); releaseAssert(TestContextListener::sTestCtx.has_value()); auto& tc = TestContextListener::sTestCtx.value(); stdfs::path file(tc.lineInfo.file); file = file.filename().stem(); std::stringstream oss; bool first = true; for (auto const& sc : TestContextListener::sSectCtx) { if (!first) { oss << '|'; } else { first = false; } oss << sc.name; } return std::make_pair(file, oss.str()); } void recordOrCheckGlobalTestTxMetadata(TransactionMeta const& txMetaIn) { if (gTestTxMetaMode == TestTxMetaMode::META_TEST_IGNORE) { return; } TransactionMeta txMeta = txMetaIn; normalizeMeta(txMeta); auto ctx = getCurrentTestContext(); if (gDebugTestTxMeta.has_value()) { gDebugTestTxMeta.value() << "=== " << ctx.first << " : " << ctx.second << " ===" << std::endl << xdr_to_string(txMeta, "TransactionMeta", false) << std::endl; } uint64_t gotTxMetaHash = shortHash::xdrComputeHash(txMeta); if (gTestTxMetaMode == TestTxMetaMode::META_TEST_RECORD) { auto& pair = gTestTxMetadata[ctx.first][ctx.second]; auto& testRan = pair.first; auto& testHashes = pair.second; testRan = false; testHashes.emplace_back(gotTxMetaHash); } else { releaseAssert(gTestTxMetaMode == TestTxMetaMode::META_TEST_CHECK); auto i = gTestTxMetadata.find(ctx.first); CHECK(i != gTestTxMetadata.end()); if (i == gTestTxMetadata.end()) { return; } auto j = i->second.find(ctx.second); CHECK(j != i->second.end()); if (j == i->second.end()) { return; } bool& testRan = j->second.first; testRan = true; std::vector<uint64_t>& vec = j->second.second; CHECK(!vec.empty()); if (vec.empty()) { return; } uint64_t& expectedTxMetaHash = vec.back(); CHECK(expectedTxMetaHash == gotTxMetaHash); vec.pop_back(); } } static char const* TESTKEY_PROTOCOL_VERSION = "!cfg protocol version"; static char const* TESTKEY_RNG_SEED = "!rng seed"; static char const* TESTKEY_ALL_VERSIONS = "!test all versions"; static char const* TESTKEY_VERSIONS_TO_TEST = "!versions to test"; template <typename T> void checkTestKeyVal(std::string const& k, T const& expected, T const& got, stdfs::path const& path) { if (expected != got) { throw std::runtime_error(fmt::format("Expected '{}' = {}, got {} in {}", k, expected, got, path)); } } template <typename T> void checkTestKeyVals(std::string const& k, T const& expected, T const& got, stdfs::path const& path) { if (expected != got) { throw std::runtime_error(fmt::format("Expected '{}' = {}, got {} in {}", k, fmt::join(expected, ", "), fmt::join(got, ", "), path)); } } static void loadTestTxMeta(stdfs::path const& dir) { if (!stdfs::is_directory(dir)) { logFatalAndThrow(fmt::format("{} is not a directory", dir)); } size_t n = 0; for (auto const& dirent : stdfs::directory_iterator{dir}) { auto path = dirent.path(); if (path.extension() != ".json") { continue; } std::ifstream in(path); if (!in) { logFatalAndThrow(fmt::format("Failed to open {}", path)); } in.exceptions(std::ios::failbit | std::ios::badbit); Json::Value root; in >> root; auto basename = path.filename().stem(); auto& fileTestCases = gTestTxMetadata[basename]; for (auto entry = root.begin(); entry != root.end(); ++entry) { std::string name = entry.key().asString(); if (!name.empty() && name.at(0) == '!') { if (name == TESTKEY_PROTOCOL_VERSION) { checkTestKeyVal(name, Config::CURRENT_LEDGER_PROTOCOL_VERSION, entry->asUInt(), path); } else if (name == TESTKEY_RNG_SEED) { checkTestKeyVal(name, ReseedPRNGListener::sCommandLineSeed, entry->asUInt(), path); } else if (name == TESTKEY_ALL_VERSIONS) { checkTestKeyVal(name, gTestAllVersions, entry->asBool(), path); } else if (name == TESTKEY_VERSIONS_TO_TEST) { std::vector<uint32> versions; for (auto v : *entry) { versions.emplace_back(v.asUInt()); } checkTestKeyVals(name, gVersionsToTest, versions, path); } continue; } std::vector<uint64_t> hashes; for (auto const& h : *entry) { ++n; // To keep the baseline files small, we store each // 64-bit SIPHash as a base64 encoded string. std::vector<uint8_t> buf; decoder::decode_b64(h.asString(), buf); uint64_t tmp = 0; for (size_t i = 0; i < sizeof(uint64_t); ++i) { tmp <<= 8; tmp |= buf.at(i); } hashes.emplace_back(tmp); } std::reverse(hashes.begin(), hashes.end()); auto pair = fileTestCases.emplace(name, std::make_pair(false, hashes)); if (!pair.second) { logFatalAndThrow( fmt::format("Duplicate test TxMeta found for key: {}:{}", basename, name)); } } } LOG_INFO(DEFAULT_LOG, "Loaded {} TxMetas to check during replay", n); } static void saveTestTxMeta(stdfs::path const& dir) { for (auto const& filePair : gTestTxMetadata) { Json::Value fileRoot; fileRoot[TESTKEY_PROTOCOL_VERSION] = Config::CURRENT_LEDGER_PROTOCOL_VERSION; fileRoot[TESTKEY_RNG_SEED] = ReseedPRNGListener::sCommandLineSeed; fileRoot[TESTKEY_ALL_VERSIONS] = gTestAllVersions; { Json::Value versions; for (auto v : gVersionsToTest) { versions.append(v); } fileRoot[TESTKEY_VERSIONS_TO_TEST] = versions; } for (auto const& testCasePair : filePair.second) { Json::Value& hashes = fileRoot[testCasePair.first]; for (auto const& h : testCasePair.second.second) { uint64_t tmp = h; std::vector<uint8_t> buf; for (size_t i = sizeof(uint64_t); i > 0; --i) { buf.emplace_back(uint8_t(0xff & (tmp >> (8 * (i - 1))))); } hashes.append(decoder::encode_b64(buf)); } } stdfs::path path = dir / filePair.first; path.replace_extension(".json"); std::ofstream out(path, std::ios_base::trunc); if (!out) { logFatalAndThrow(fmt::format("Failed to open {}", path)); } out.exceptions(std::ios::failbit | std::ios::badbit); out << fileRoot; } } static void reportTestTxMeta() { size_t contexts = 0, nonempty = 0, hashes = 0; for (auto const& filePair : gTestTxMetadata) { for (auto const& testCasePair : filePair.second) { ++contexts; auto const& testRan = testCasePair.second.first; auto const& testHashes = testCasePair.second.second; if (testRan && !testHashes.empty()) { LOG_FATAL(DEFAULT_LOG, "Tests did not check {} TxMeta hashes in test " "context '{}' in file '{}'", testHashes.size(), testCasePair.first, filePair.first); ++nonempty; hashes += testHashes.size(); } } } if (nonempty == 0) { LOG_INFO(DEFAULT_LOG, "Checked all expected TxMeta for {} test contexts.", contexts); } else { logFatalAndThrow(fmt::format( "Found {} un-checked TxMeta hashes in {} of {} test contexts.", hashes, nonempty, contexts)); } } }
org 256 start: mov ax, 90 mov bx, 9 xor dx, dx div bx mov bx, dx mov dx, divi call sprint mov dx, ax call iprintCRLF mov dx, rema call sprint mov dx, bx call iprintCRLF int 20h include 'procs.inc' divi db '90 div 9 is ', 0h rema db 'remain with ', 0h
/** * @file LoRaPHYIN865.cpp * * @brief Implements LoRaPHY for Indian 865 MHz band * * \code * ______ _ * / _____) _ | | * ( (____ _____ ____ _| |_ _____ ____| |__ * \____ \| ___ | (_ _) ___ |/ ___) _ \ * _____) ) ____| | | || |_| ____( (___| | | | * (______/|_____)_|_|_| \__)_____)\____)_| |_| * (C)2013 Semtech * ___ _____ _ ___ _ _____ ___ ___ ___ ___ * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| * embedded.connectivity.solutions=============== * * \endcode * * * License: Revised BSD License, see LICENSE.TXT file include in the project * * Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE ) * * Copyright (c) 2017, Arm Limited and affiliates. * SPDX-License-Identifier: BSD-3-Clause * */ #include "LoRaPHYIN865.h" #include "lora_phy_ds.h" /*! * Number of default channels */ #define IN865_NUMB_DEFAULT_CHANNELS 3 /*! * Number of channels to apply for the CF list */ #define IN865_NUMB_CHANNELS_CF_LIST 5 /*! * Minimal datarate that can be used by the node */ #define IN865_TX_MIN_DATARATE DR_0 /*! * Maximal datarate that can be used by the node */ #define IN865_TX_MAX_DATARATE DR_7 /*! * Minimal datarate that can be used by the node */ #define IN865_RX_MIN_DATARATE DR_0 /*! * Maximal datarate that can be used by the node */ #define IN865_RX_MAX_DATARATE DR_7 /*! * Default datarate used by the node */ #define IN865_DEFAULT_DATARATE DR_0 #define IN865_DEFAULT_MAX_DATARATE DR_5 /*! * Minimal Rx1 receive datarate offset */ #define IN865_MIN_RX1_DR_OFFSET 0 /*! * Maximal Rx1 receive datarate offset */ #define IN865_MAX_RX1_DR_OFFSET 7 /*! * Default Rx1 receive datarate offset */ #define IN865_DEFAULT_RX1_DR_OFFSET 0 /*! * Minimal Tx output power that can be used by the node */ #define IN865_MIN_TX_POWER TX_POWER_10 /*! * Maximal Tx output power that can be used by the node */ #define IN865_MAX_TX_POWER TX_POWER_0 /*! * Default Tx output power used by the node */ #define IN865_DEFAULT_TX_POWER TX_POWER_0 /*! * Default Max EIRP */ #define IN865_DEFAULT_MAX_EIRP 30.0f /*! * Default antenna gain */ #define IN865_DEFAULT_ANTENNA_GAIN 2.15f /*! * ADR Ack limit */ #define IN865_ADR_ACK_LIMIT 64 /*! * ADR Ack delay */ #define IN865_ADR_ACK_DELAY 32 /*! * Enabled or disabled the duty cycle */ #define IN865_DUTY_CYCLE_ENABLED 1 /*! * Maximum RX window duration */ #define IN865_MAX_RX_WINDOW 3000 /*! * Receive delay 1 */ #define IN865_RECEIVE_DELAY1 1000 /*! * Receive delay 2 */ #define IN865_RECEIVE_DELAY2 2000 /*! * Join accept delay 1 */ #define IN865_JOIN_ACCEPT_DELAY1 5000 /*! * Join accept delay 2 */ #define IN865_JOIN_ACCEPT_DELAY2 6000 /*! * Maximum frame counter gap */ #define IN865_MAX_FCNT_GAP 16384 /*! * Ack timeout */ #define IN865_ACKTIMEOUT 2000 /*! * Random ack timeout limits */ #define IN865_ACK_TIMEOUT_RND 1000 #if ( IN865_DEFAULT_DATARATE > DR_5 ) #error "A default DR higher than DR_5 may lead to connectivity loss." #endif /*! * Second reception window channel frequency definition. */ #define IN865_RX_WND_2_FREQ 866550000 /*! * Second reception window channel datarate definition. */ #define IN865_RX_WND_2_DR DR_2 /*! * Band 0 definition * { DutyCycle, TxMaxPower, LastJoinTxDoneTime, LastTxDoneTime, TimeOff } */ static const band_t IN865_BAND0 = { 1 , IN865_MAX_TX_POWER, 0, 0, 0, 865000000, 867000000 }; // 100.0 % /*! * LoRaMac default channel 1 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } */ static const channel_params_t IN865_LC1 = { 865062500, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }; /*! * LoRaMac default channel 2 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } */ static const channel_params_t IN865_LC2 = { 865402500, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }; /*! * LoRaMac default channel 3 * Channel = { Frequency [Hz], RX1 Frequency [Hz], { ( ( DrMax << 4 ) | DrMin ) }, Band } */ static const channel_params_t IN865_LC3 = { 865985000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }; /*! * LoRaMac channels which are allowed for the join procedure */ #define IN865_JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) | LC( 3 ) ) /*! * Data rates table definition */ static const uint8_t datarates_IN865[] = { 12, 11, 10, 9, 8, 7, 0, 50 }; /*! * Bandwidths table definition in Hz */ static const uint32_t bandwidths_IN865[] = { 125000, 125000, 125000, 125000, 125000, 125000, 250000, 0 }; /*! * Maximum payload with respect to the datarate index. Cannot operate with repeater. */ static const uint8_t max_payloads_IN865[] = { 51, 51, 51, 115, 242, 242, 242, 242 }; /*! * Maximum payload with respect to the datarate index. Can operate with repeater. */ static const uint8_t max_payloads_with_repeater[] = { 51, 51, 51, 115, 222, 222, 222, 222 }; /*! * Effective datarate offsets for receive window 1. */ static const int8_t rx1_dr_offset_IN865[] = { 0, 1, 2, 3, 4, 5, -1, -2 }; LoRaPHYIN865::LoRaPHYIN865(LoRaWANTimeHandler &lora_time) : LoRaPHY(lora_time) { bands[0] = IN865_BAND0; // Default Channels are always enabled, rest will be added later channels[0] = IN865_LC1; channels[0].band = 0; channels[1] = IN865_LC2; channels[1].band = 0; channels[2] = IN865_LC3; channels[2].band = 0; // Initialize the channels default mask default_channel_mask[0] = LC(1) + LC(2) + LC(3); // Update the channels mask copy_channel_mask(channel_mask, default_channel_mask, 1); // set default channels phy_params.channels.channel_list = channels; phy_params.channels.channel_list_size = IN865_MAX_NB_CHANNELS; phy_params.channels.mask = channel_mask; phy_params.channels.default_mask = default_channel_mask; phy_params.channels.mask_size = IN865_CHANNEL_MASK_SIZE; // set bands for IN865 spectrum phy_params.bands.table = (void *) bands; phy_params.bands.size = IN865_MAX_NB_BANDS; // set bandwidths available in IN865 spectrum phy_params.bandwidths.table = (void *) bandwidths_IN865; phy_params.bandwidths.size = 8; // set data rates available in IN865 spectrum phy_params.datarates.table = (void *) datarates_IN865; phy_params.datarates.size = 8; // set payload sizes with respect to data rates phy_params.payloads.table = (void *) max_payloads_IN865; phy_params.payloads.size = 8; phy_params.payloads_with_repeater.table = (void *) max_payloads_with_repeater; phy_params.payloads_with_repeater.size = 8; // dwell time setting phy_params.ul_dwell_time_setting = 0; phy_params.dl_dwell_time_setting = 0; // set initial and default parameters phy_params.duty_cycle_enabled = IN865_DUTY_CYCLE_ENABLED; phy_params.accept_tx_param_setup_req = false; phy_params.fsk_supported = true; phy_params.cflist_supported = true; phy_params.dl_channel_req_supported = true; phy_params.custom_channelplans_supported = true; phy_params.default_channel_cnt = IN865_NUMB_DEFAULT_CHANNELS; phy_params.max_channel_cnt = IN865_MAX_NB_CHANNELS; phy_params.cflist_channel_cnt = IN865_NUMB_CHANNELS_CF_LIST; phy_params.min_tx_datarate = IN865_TX_MIN_DATARATE; phy_params.max_tx_datarate = IN865_TX_MAX_DATARATE; phy_params.min_rx_datarate = IN865_RX_MIN_DATARATE; phy_params.max_rx_datarate = IN865_RX_MAX_DATARATE; phy_params.default_datarate = IN865_DEFAULT_DATARATE; phy_params.default_max_datarate = IN865_DEFAULT_MAX_DATARATE; phy_params.min_rx1_dr_offset = IN865_MIN_RX1_DR_OFFSET; phy_params.max_rx1_dr_offset = IN865_MAX_RX1_DR_OFFSET; phy_params.default_rx1_dr_offset = IN865_DEFAULT_RX1_DR_OFFSET; phy_params.min_tx_power = IN865_MIN_TX_POWER; phy_params.max_tx_power = IN865_MAX_TX_POWER; phy_params.default_tx_power = IN865_DEFAULT_TX_POWER; phy_params.default_max_eirp = IN865_DEFAULT_MAX_EIRP; phy_params.default_antenna_gain = IN865_DEFAULT_ANTENNA_GAIN; phy_params.adr_ack_limit = IN865_ADR_ACK_LIMIT; phy_params.adr_ack_delay = IN865_ADR_ACK_DELAY; phy_params.max_rx_window = IN865_MAX_RX_WINDOW; phy_params.recv_delay1 = IN865_RECEIVE_DELAY1; phy_params.recv_delay2 = IN865_RECEIVE_DELAY2; phy_params.join_channel_mask = IN865_JOIN_CHANNELS; phy_params.join_accept_delay1 = IN865_JOIN_ACCEPT_DELAY1; phy_params.join_accept_delay2 = IN865_JOIN_ACCEPT_DELAY2; phy_params.max_fcnt_gap = IN865_MAX_FCNT_GAP; phy_params.ack_timeout = IN865_ACKTIMEOUT; phy_params.ack_timeout_rnd = IN865_ACK_TIMEOUT_RND; phy_params.rx_window2_datarate = IN865_RX_WND_2_DR; phy_params.rx_window2_frequency = IN865_RX_WND_2_FREQ; } LoRaPHYIN865::~LoRaPHYIN865() { } uint8_t LoRaPHYIN865::apply_DR_offset(int8_t dr, int8_t dr_offset) { // Apply offset formula return MIN(DR_5, MAX(DR_0, dr - rx1_dr_offset_IN865[dr_offset])); }
; BSD 3-Clause License ; ; Copyright (c) 2019, k4m1 <[email protected]> ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; * Redistributions of source code must retain the above copyright notice, ; this list of conditions and the following disclaimer. ; ; * Redistributions in binary form must reproduce the above copyright notice, ; this list of conditions and the following disclaimer in the documentation ; and/or other materials provided with the distribution. ; ; * Neither the name of the copyright 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. ; ; later on, add ifdef <TARGET PLATFORM> or smhn like that. %include "src/log.asm" %include "src/fixed_pointers.asm" %include "src/drivers/qemu/superio.asm" ; ======================================================================== ; ; This is the first entry point of our BIOS code after reset vector. ; Offset from ROM beginning is 0x10000. ; ; ======================================================================== ; bits 16 %define VER_NUM "0.3" main: cli cld ; save BIST result mov ebp, eax ; disable TLB xor eax, eax mov cr3, eax ; this macro is provided by drivers/dev/superio.asm SUPERIO_INIT_MACRO ; this macro is provided by drivers/cpu/YOURCPU.asm %ifdef USE_CAR INIT_CAR_IF_ENABLED %endif ; ======================================================================== ; ; At this point, ram init is completed, we can go on with our boot process ; ; ======================================================================== ; xor ax, ax mov ss, ax mov sp, 0x7c00 push ebp ; store ebp/BIST to stack mov bp, sp ; Show a simple bootsplash over serial port mov si, msg_boot_early call serial_print call mm_heap_init call cpuid_print_cpu_vendor call pci_init call pci_ide_test call pci_find_vga_dev .ata_start: ; setup ATA disk addr list to 0's mov cx, 16 mov di, ata_disk_addr_list xor ax, ax rep stosw ; check for ATA disks call ata_check_disks mov si, ata_disk_addr_list .find_boot_sector: lodsw test ax, ax jz .boot_failed_no_bootsector mov dx, ax ; we read disk up to 10 times, as disk-read may randomly ; return all 0's for reson or another... mov cx, 10 .read_retry_loop: call find_boot_sector jnc .read_success loop .read_retry_loop jmp .find_boot_sector .read_success: mov si, TMP_BOOTSECTOR_ADDR call bootsector_to_ram mov si, msg_bootsector_found call serial_print mov si, msg_init_interrupts call serial_print ; ======================================================================== ; ; We now have bootloader set up at 0x0000:0x7c00, do not overwrite it ; accidentally. ; ; Now, to do: ; - setup interrupt controller + clear all IVT entries ; - set device specific interrupt handlers ; ======================================================================== ; .setup_runtime: ; setup bios data area before int handlers call setup_bda call init_interrupts call set_serial_ivt_entry call set_disk_ivt_entry call init_fault_interrupts xor esi, esi mov si, msg_jump_to_loader call serial_print ; set boot device to dl mov dl, 0x80 jmp 0x0000:0x7c00 .hang: cli hlt jmp .hang .boot_failed_no_bootsector: mov si, msg_no_bootsector call serial_print jmp .hang LBAPTR: db 1 ; bits 0 - 8 db 0 ; 8 - 16 db 0 ; ... db 0 msg_no_bootsector: db "FAILED TO FIND BOOTABLE DISK!", 0x0A, 0x0D, 0 msg_boot_early: db 0x0A, 0x0D, "TinyBIOS " db VER_NUM db " (C) 2019 k4m1, <[email protected]>" db 0x0A, 0x0D db "RAM READ/WRITE OK" db 0x0A, 0x0D, 0 msg_not_boot_sector: db "ATA DISK HAS NO BOOTLOADER, EXPECTED 55AA, GOT: ", 0 msg_disk_read_failed: db "FAILED TO READ DISK 0x", 0 msg_bootsector_found: db "FOUND BOOT SECTOR SIGNATURE (55AA) FROM DISK", 0x0A, 0x0D, 0 msg_init_interrupts: db "SETTING UP IVT & INTERRUPT HANDLERS", 0x0A, 0x0D, 0 msg_jump_to_loader: db "JUMP TO 0x0000:0x7C00", 0x0A, 0x0D, 0 ; Driver includes ; %include "src/drivers/8259_pic.asm" %include "src/drivers/ata_pio.asm" %include "src/drivers/serial.asm" %include "src/drivers/parallel.asm" %include "src/drivers/pci/pci_core.asm" %include "src/drivers/pci/pci_helpers.asm" %include "src/drivers/pci/pci_ide.asm" %include "src/drivers/pci/pci_vga.asm" %include "src/drivers/vga/vga_core.asm" %include "src/drivers/cpu/common_ia86.asm" ; Random helper & such includes ; %include "src/test_ram.asm" %include "src/bootdisk.asm" %include "src/mm.asm" %include "src/interrupts.asm" %include "src/bda.asm" ; Interrupt handlers %include "src/int_handlers/serial.asm" %include "src/int_handlers/disk.asm" %include "src/int_handlers/faults.asm"
copyright zengfr site:http://github.com/zengfr/romhack 0168DA move.b #$0, ($5,A6) [base+6BB8] 0168E0 lea $90a814.l, A0 016E40 move.b #$0, ($5,A6) 016E46 move.b (A0,D2.w), ($4,A3) 016EBC move.b #$0, ($5,A6) [base+6BE4, base+6BF4, base+6C04, base+6C24, base+6C34, base+6C44, base+6C54, base+6C84, base+6C94, base+6CA4, base+6CC4, base+6CD4, base+6CE4, base+6D04, base+6D14, base+6D24, base+6D54, base+6D64, base+6D74, base+6DB4, base+6DC4, base+6DE4, base+6DF4, base+6E04, base+6E24, base+6E34, base+6E44, base+6E54, base+6E84, base+6E94, base+6EA4, base+6ED4] 016EC2 tst.w D0 016EC8 move.b #$3c, ($5,A6) 016ECE move.b ($4,A3), ($e,A6) [base+6BAD, base+6BBD, base+6BCD] 017234 move.b #$0, ($5,A6) 01723A tst.w D0 0173BC tst.b ($5,A6) 0173C0 beq $17424 [base+6BAD, base+6BBD, base+6BCD] 0173C4 subi.b #$1, ($5,A6) 0173CA moveq #$0, D0 [base+6BAD, base+6BBD, base+6BCD] 0173CC move.b ($5,A6), D0 0173D0 andi.b #$2, D0 [base+6BAD, base+6BBD, base+6BCD] 0173E2 move.b ($5,A6), D0 0173E6 beq $173fa [base+6BAD, base+6BBD, base+6BCD] 017462 move.b ($5,A6), D0 017466 andi.b #$1, D0 [base+6BAD, base+6BBD, base+6BCD] 023FE4 clr.b ($5,A6) [base+6BAB, base+6BBB, base+6BCB] 023FE8 rts copyright zengfr site:http://github.com/zengfr/romhack
#include <iostream> #include <string> #include <stdlib.h> // Included stdlib for srand and rand #include <time.h> // Included time.h for (TIME), seeds srand #include <map> #include <stack> #include <queue> #include <vector> #include <list> #include "template.h" // Going to try making a list of Students using namespace std; int main() { // **************************************************************** // Map stuff here // **************************************************************** map<string, string> ID; // Map, which associates student IDs with Student names ID["1234"] = "Jason"; ID["9999"] = "Huy"; ID["5643"] = "JT"; // Try basic outputting of a map cout << "1234 -> " << ID["1234"] << "\n"; cout << "9999 -> " << ID["9999"] << "\n"; cout << "5643 -> " << ID["5643"] << "\n"; map<string, string> JSON; // Map, which could be used for JSON data map<string, string>::iterator json_ptr; // iterator for the JSON map JSON["title"] = "Awesome title"; JSON["data"] = "FDfe7rf9F*823713"; JSON["array"] = "[1, 2, 3, 5, 8, 13, 21]"; int size_of_map = JSON.size(); // Get the map's size cout << "\nSize of this map is: " << size_of_map << "\n\n"; // Make the iterator start at the beginning of the JSON map json_ptr = JSON.begin(); // Print out all the items in the map using the iterator for(json_ptr = JSON.begin(); json_ptr != JSON.end(); json_ptr++) { cout << "Key: " << json_ptr -> first << "\n"; cout << "Mapped value: " << json_ptr -> second << "\n"; } cout << "======================================================= \n\n"; // **************************************************************** // Stack stuff here // **************************************************************** stack<int> numberz; // Making a stack of ints // Going to push 100 numbers into this stack and have some fun for(int i = 0; i < 100; i++) { numberz.push(i); // Pushes i back to the correct position in the stack. } cout << "Outputting 5 numbers on the stack: \n"; // Output the first 5 numbers for(int i = 0; i < 5; i++) { cout << numberz.top() << "\n"; numberz.pop(); } // Pop a bunch of numbers off the stack for(int i = 0; i < 50; i++) { numberz.pop(); } cout << "\nWhat's on top of the stack now? \n"; cout << "Looks like: " << numberz.top() << "\n\n"; // Pop all the numbers on the stack for(;numberz.empty() == false; numberz.pop()) { // This will just loop through and pop all the elements on the stack. // .empty() will force the for loop to quit once we've popped all the elements. } // Let's make sure the stack is empty if(numberz.empty() == true) { cout << "Yay the stack is empty! \n"; } else { cout << "Boooo the stack isn't empty! \n"; } cout << "======================================================= \n\n"; // **************************************************************** // Queue stuff here // **************************************************************** queue<float> fqueue; // queue of floats // Let's push a bunch of random numbers into this queue. srand(time(NULL)); // Push 50 random numbers into fqueue. for(int i = 0; i < 50; i++) { fqueue.push(rand()); } // Check out what's on at the front/back of the queue cout << "Front of the queue: " << fqueue.front() << "\n"; cout << "Back of the queue: " << fqueue.back() << "\n"; // Make sure size is 50 cout << "Size of the queue: " << fqueue.size() << "\n\n"; // Pop a few numbers off for(int i = 0; i < 5; i++) { fqueue.pop(); } // Check out what's on at the front/back of the queue (again) cout << "Front of the queue: " << fqueue.front() << "\n"; cout << "Back of the queue: " << fqueue.back() << "\n"; // Make sure size is 45 cout << "Size of the queue: " << fqueue.size() << "\n\n"; // Pop all the numbers on the queue for(;fqueue.empty() == false; fqueue.pop()) { // This will just loop through and pop all the elements on the fqueue // .empty() will force the for loop to quit once we've popped all the elements. } // Let's make sure the queue is empty if(fqueue.empty() == true) { cout << "Yay the queue is empty! \n"; } else { cout << "Boooo the queue isn't empty! \n"; } cout << "======================================================= \n\n"; // **************************************************************** // Vector stuff here // **************************************************************** vector<char> charz; // A vector of characters //vector<char>::iterator; // Iterator for the char vector // Going to insert a word char by char charz.push_back('H'); charz.push_back('E'); charz.push_back('L'); charz.push_back('L'); charz.push_back('O'); // Now let's find the size of the vector. cout << "Size of the character vector is: " << charz.size() << "\n\n"; cout << "Outputting the vector of characters to the screen: \n"; // Let's output the vector to the screen for(int i = 0; i < 5; i++) { cout << charz[i] << "\n"; // using the vector as an array. } // Let's reserve more space, and make room for 20 total characters. charz.reserve(20); // Let's check that size and capacity are different cout << "\nCapacity of the vector: " << charz.capacity() << "\n"; // should be 20 cout << "Size of the vector: " << charz.size() << "\n"; // should be 5 cout << "Outputting the vector of characters again: "; // Now to push another 40 characters, it will auto resize for(int i = 0; i < 40; i++) { charz.push_back('-'); } // Let's output the vector to the screen for(int i = 0; i < charz.size(); i++) { cout << charz[i]; // using the vector as an array. } // Let's check that size and capacity are different cout << "\n\nCapacity of the vector: " << charz.capacity() << "\n"; cout << "Size of the vector: " << charz.size() << "\n"; cout << "======================================================= \n\n"; // **************************************************************** // List here // **************************************************************** list<Student> students; // List of students list<Student>::iterator ptr; // iterator of the student list // 3 Student objects Student JT("JT", "Sophomore", "Read Chap 5"); Student Jason("Jason", "Sophomore", "None"); Student Huy("Huy", "Sophomore", "None"); // Pushing those three students back into the list students.push_back(JT); students.push_back(Jason); students.push_back(Huy); cout << "Forward through the list: \n\n"; // Print all of the student's names for(ptr = students.begin(); ptr != students.end(); ptr++) { Student temp; temp = *ptr; cout << "This student's name: " << temp.get_element(1) << "\n"; } cout << "\nBackward through the list: \n\n"; // Print them out in reverse order for(ptr = students.end(); ptr != students.begin(); ) { --ptr; // Had to put this here in order for the list to reverse correctly // and not output a bunch of gibberish Student temp; temp = *ptr; cout << "This student's name: " << temp.get_element(1) << "\n"; } return 0; }
; this sample checks if string is a palindrome or not. ; palindrome is a text that can be read backwards ; and give the same meaning as if it was read forward. ; for example: "abba" is polindrome. ; note: this program is case sensitive, "abba" is not "abba". name "pali" org 100h jmp start m1: s db 'able was ere ere saw elba' s_size = $ - m1 db 0Dh,0Ah,'$' start: ; first let's print it: mov ah, 9 mov dx, offset s int 21h lea di, s mov si, di add si, s_size dec si ; point to last char! mov cx, s_size cmp cx, 1 je is_palindrome ; single char is always palindrome! shr cx, 1 ; divide by 2! next_char: mov al, [di] mov bl, [si] cmp al, bl jne not_palindrome inc di dec si loop next_char is_palindrome: ; the string is "palindrome!" mov ah, 9 mov dx, offset msg1 int 21h jmp stop not_palindrome: ; the string is "not palindrome!" mov ah, 9 mov dx, offset msg2 int 21h stop: ; wait for any key press: mov ah, 0 int 16h ret msg1 db " this is palindrome!$" msg2 db " this is not a palindrome!$"
; A002313: Primes congruent to 1 or 2 modulo 4; or, primes of form x^2 + y^2; or, -1 is a square mod p. ; 2,5,13,17,29,37,41,53,61,73,89,97,101,109,113,137,149,157,173,181,193,197,229,233,241,257,269,277,281,293,313,317,337,349,353,373,389,397,401,409,421,433,449,457,461,509,521,541,557,569,577,593,601,613,617,641,653,661,673,677,701,709,733,757,761,769,773,797,809,821,829,853,857,877,881,929,937,941,953,977,997,1009,1013,1021,1033,1049,1061,1069,1093,1097,1109,1117,1129,1153,1181,1193,1201,1213,1217,1229 seq $0,280084 ; 1 together with the Pythagorean primes. max $0,2
; A007396: Add 2, then reverse digits!. ; 0,2,4,6,8,1,3,5,7,9,11,31,33,53,55,75,77,97,99,101,301,303,503,505,705,707,907,909,119,121,321,323,523,525,725,727,927,929,139,141,341,343,543,545,745,747,947,949,159,161,361,363,563,565,765,767,967,969,179,181,381,383,583,585,785,787,987,989,199,102,401,304,603,506,805,708,17,91,39,14,61,36,83,58,6,8,1,3,5,7,9,11,31,33,53,55,75,77,97,99 mov $2,$0 mov $0,2 lpb $2 seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences). add $0,2 sub $2,1 lpe sub $0,2
; A131128: Binomial transform of [1, 1, 5, 1, 5, 1, 5, ...]. ; 1,2,8,20,44,92,188,380,764,1532,3068,6140,12284,24572,49148,98300,196604,393212,786428,1572860,3145724,6291452,12582908,25165820,50331644,100663292,201326588,402653180,805306364,1610612732,3221225468,6442450940,12884901884,25769803772,51539607548,103079215100,206158430204,412316860412,824633720828,1649267441660,3298534883324,6597069766652,13194139533308,26388279066620,52776558133244,105553116266492,211106232532988,422212465065980,844424930131964,1688849860263932,3377699720527868,6755399441055740,13510798882111484,27021597764222972,54043195528445948,108086391056891900,216172782113783804,432345564227567612,864691128455135228,1729382256910270460,3458764513820540924,6917529027641081852,13835058055282163708,27670116110564327420,55340232221128654844,110680464442257309692,221360928884514619388,442721857769029238780,885443715538058477564,1770887431076116955132,3541774862152233910268,7083549724304467820540,14167099448608935641084,28334198897217871282172,56668397794435742564348,113336795588871485128700,226673591177742970257404,453347182355485940514812,906694364710971881029628,1813388729421943762059260,3626777458843887524118524,7253554917687775048237052,14507109835375550096474108,29014219670751100192948220,58028439341502200385896444,116056878683004400771792892,232113757366008801543585788,464227514732017603087171580,928455029464035206174343164,1856910058928070412348686332,3713820117856140824697372668,7427640235712281649394745340,14855280471424563298789490684,29710560942849126597578981372,59421121885698253195157962748,118842243771396506390315925500,237684487542793012780631851004,475368975085586025561263702012,950737950171172051122527404028,1901475900342344102245054808060 mov $1,2 pow $1,$0 mul $1,3 trn $1,5 add $1,1 mov $0,$1
; --------------------------------------------------------------------------- ; Sprite mappings - Orbinaut enemy (LZ, SLZ, SBZ) ; --------------------------------------------------------------------------- dc.w byte_11EEC-Map_obj60, byte_11EF2-Map_obj60 dc.w byte_11EF8-Map_obj60, byte_11EFE-Map_obj60 byte_11EEC: dc.b 1 dc.b $F4, $A, 0, 0, $F4 byte_11EF2: dc.b 1 dc.b $F4, $A, $20, 9, $F4 byte_11EF8: dc.b 1 dc.b $F4, $A, 0, $12, $F4 byte_11EFE: dc.b 1 dc.b $F8, 5, 0, $1B, $F8 even
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/sys_info.h" #include <zircon/syscalls.h> #include "base/logging.h" namespace base { // static int64_t SysInfo::AmountOfPhysicalMemoryImpl() { return zx_system_get_physmem(); } // static int64_t SysInfo::AmountOfAvailablePhysicalMemoryImpl() { // TODO(fuchsia): https://crbug.com/706592 This is not exposed. NOTREACHED(); return 0; } // static int SysInfo::NumberOfProcessors() { return zx_system_get_num_cpus(); } // static int64_t SysInfo::AmountOfVirtualMemory() { return 0; } } // namespace base
; A239462: A239459(n) / n. ; 11,41,91,161,251,361,491,641,811,10001,12101,14401,16901,19601,22501,25601,28901,32401,36101,40001,44101,48401,52901,57601,62501,67601,72901,78401,84101,90001,96101,102401,108901,115601,122501,129601,136901,144401,152101,160001,168101,176401,184901,193601,202501,211601,220901,230401,240101,250001,260101,270401,280901,291601,302501,313601,324901,336401,348101,360001,372101,384401,396901,409601,422501,435601,448901,462401,476101,490001,504101,518401,532901,547601,562501,577601,592901,608401,624101,640001,656101,672401,688901,705601,722501,739601,756901,774401,792101,810001,828101,846401,864901,883601,902501,921601,940901,960401,980101,10000001,10201001,10404001,10609001,10816001,11025001,11236001,11449001,11664001,11881001,12100001,12321001,12544001,12769001,12996001,13225001,13456001,13689001,13924001,14161001,14400001,14641001,14884001,15129001,15376001,15625001,15876001,16129001,16384001,16641001,16900001,17161001,17424001,17689001,17956001,18225001,18496001,18769001,19044001,19321001,19600001,19881001,20164001,20449001,20736001,21025001,21316001,21609001,21904001,22201001,22500001,22801001,23104001,23409001,23716001,24025001,24336001,24649001,24964001,25281001,25600001,25921001,26244001,26569001,26896001,27225001,27556001,27889001,28224001,28561001,28900001,29241001,29584001,29929001,30276001,30625001,30976001,31329001,31684001,32041001,32400001,32761001,33124001,33489001,33856001,34225001,34596001,34969001,35344001,35721001,36100001,36481001,36864001,37249001,37636001,38025001,38416001,38809001,39204001,39601001,40000001,40401001,40804001,41209001,41616001,42025001,42436001,42849001,43264001,43681001,44100001,44521001,44944001,45369001,45796001,46225001,46656001,47089001,47524001,47961001,48400001,48841001,49284001,49729001,50176001,50625001,51076001,51529001,51984001,52441001,52900001,53361001,53824001,54289001,54756001,55225001,55696001,56169001,56644001,57121001,57600001,58081001,58564001,59049001,59536001,60025001,60516001,61009001,61504001,62001001,62500001 add $0,1 mov $1,$0 mov $2,$0 lpb $0,1 div $0,10 mul $1,$2 mov $2,1 mov $3,3 sub $3,$0 add $2,$3 add $2,$0 add $2,1 mul $2,2 lpe sub $1,1 mul $1,10 add $1,11
TITLE GRCOORD - graphics point specification PAGE 56,132 ;*** ;GRCOORD - graphics point specification ; ; Copyright <C> 1986 - 1988, Microsoft Corporation ; ;Purpose: ; This module contains point specification routines, and routines which will ; transform and convert those points as required. ; ;****************************************************************************** INCLUDE switch.inc INCLUDE rmacros.inc ;Runtime Macro Defintions useSeg _BSS ;Uninitialized data useSeg _DATA ; Initialized data useSeg GR_TEXT ;Graphics segments useSeg RT_TEXT INCLUDE seg.inc ;segment definitions & cmacros INCLUDE baslibma.inc ;useful macros ;****************************************************************************** ; ; point data structure ; ;****************************************************************************** POINT STRUC fPoint DB (?) ;content flags xI2 DW (?) ;x coordinate as an I2 xR4 DW 2 DUP (?) ;x coordinate as an I4 yI2 DW (?) ;y coordinate as an I2 yR4 DW 2 DUP (?) ;y coordinate as an I4 POINT ENDS fxI2 EQU 00000001B ;xI2 is valid fxR4 EQU 00000010B ;xR4 is valid fxStep EQU 00001000B ;x represents a STEP value fyI2 EQU 00010000B ;yI2 is valid fyR4 EQU 00100000B ;yR4 is valid fyStep EQU 10000000B ;y represents a STEP value b$cbPoint EQU SIZE POINT PUBLIC b$cbPoint ;Size of the point structure ;****************************************************************************** ; ; point data storage ; ;****************************************************************************** sBegin _BSS globalB b$point1,,<b$cbPoint> ;first coordinate pair globalB b$point2,,<b$cbPoint> ;second coordinate pair globalB b$fpoint,,1 ; point statement being processed flag externB b$ScreenMode externB B$COPTFL ; CIRCLE option flag externW B$GRPACX ;graphics accumulator X externW B$GRPACY ;graphics accumulator Y externW B$GXPOS externW B$GYPOS externW B$VXOFF ;Viewport offset X externW B$VYOFF ;Viewport offset Y externB B$WNDWSW ; flag indicates WINDOW active externB B$DFRACX ;8 bit fraction x after sEnd _BSS sBegin _DATA globalW b$pFPCOORD,B$ERR_FC,1 ; vector to B$FPCOORD globalW b$pFPCOORDW,B$ERR_FC,1 ; vector to B$FPCOORDW sEnd _DATA sBegin RT_TEXT externNP B$ERR_FC sEnd sBegin GR_TEXT assumes CS,GR_TEXT externNP B$INVIEW ;determine if points within viewport SUBTTL Integer point specification entrypoints PAGE ;*** ; B$N1I2, B$S1I2, B$N2I2, B$S2I2 - Integer point specification ; void pascal B$N1I2(I2 x, I2 y) ; ;Purpose: ; Specify integer coordinate pairs. ; B$N1I2 - "normal" first coordinate pair ; B$S1I2 - STEP first coordinate pair ; B$N2I2 - "normal" second coordinate pair ; B$S2I2 - STEP second coordinate pair ; ;Entry: ; x,y = integer x and y values. ; ;Exit: ; None. ; ;Uses: ; per convention ; ;****************************************************************************** cProc B$S1I2,<FAR,PUBLIC> ;First STEP pair cBegin nogen MOV CL,fxI2+fxStep+fyI2+fyStep ;indicate type of values SKIP 2 ;fall into next routine cEnd nogen cProc B$N1I2,<FAR,PUBLIC> ;First pair cBegin nogen MOV CL,fxI2+fyI2 ;indicate type of values MOV BX,OFFSET DGROUP: b$point1 ;point at first pair table cEnd nogen cProc B$I2POINT,<FAR,PUBLIC> ;Common routine to set point struct parmW x parmW y cBegin nogen POP AX POP DX ;[DX:AX] = return address POP [BX].yI2 ;store y coordinate POP [BX].xI2 ;store x coordinate labelNP <PUBLIC,B$STOREFLAGS> ; entry point from R4 code MOV [BX].fPoint,CL ;store flags MOV B$COPTFL,0 ; Reset it - CIRCLE may have left it set. PUSH DX PUSH AX ;put return address back on stack RET ;and we are done cEnd nogen cProc B$S2I2,<FAR,PUBLIC> ;Second STEP pair parmW x parmW y cBegin nogen MOV CL,fxI2+fxStep+fyI2+fyStep ;indicate type of values SKIP 2 ;fall into next routine cEnd nogen cProc B$N2I2,<FAR,PUBLIC> ;Second pair parmW x parmW y cBegin nogen MOV CL,fxI2+fyI2 ;indicate type of values MOV BX,OFFSET DGROUP: b$point2 ;point at second pair table JMP B$I2POINT cEnd nogen SUBTTL B$COORD - process & return integer coordinates PAGE ;*** ;B$COORD, B$COORD1, B$COORD2 - get a coordinate pair ; ;Purpose: ; Calculate the physical screen coordinates of the given point. Relative ; coordinates, viewports and windowing are all considered in determining the ; final coordinates. Clipping is not done in this routine. ; ;Entry: ; [BX] = pointer to point to be processed (B$COORD only) ; ;Exit: ; [CX] = x value ; [DX] = y value ; Graphics accumulators updated ; ;Modifies: ; per convention ; ;Notes: ; This routine used to be $COORDS, and contained switches for FG_SCRNROT ; ;****************************************************************************** cProc B$COORD2,<NEAR,PUBLIC> ;Get second point in coord pair cBegin <nogen> MOV BX,OFFSET DGROUP:b$point2 JMP SHORT B$COORD cEnd <nogen> cProc B$COORD1,<NEAR,PUBLIC> ;Get first point cBegin <nogen> MOV BX,OFFSET DGROUP:b$point1 cEnd <nogen> cProc B$COORD,<NEAR,PUBLIC> cBegin MOV AL,[BX].fPoint ;[AL] = flags relating to coordinate pair OR AL,AL ;See if there is a point to process JNZ COORD_5 ;Jump if there is MOV CX,B$GRPACX ;Return Graphics Accumulator x MOV DX,B$GRPACY ;Return Graphics Accumulator y RET COORD_5: PUSH SI ;Save me MOV SI,BX ;[SI] = pointer to point struct CMP [B$WNDWSW],0 ; Is window active? JZ CORINT ;Jump if not, we should have INT's JMP [b$pFPCOORDW] ; resumes at B$COORD_NOSTEP ; ; No window is active, so we expect to do integer calculations. Make sure that ; we have I2 representations for both our points. ; CORINT: TEST AL,fxR4+fyR4 ;Is either coord an R4? JZ CORINT1 ;brif not - no conversion needed CALL [b$pFPCOORD] ; make coords I2 CORINT1: MOV CX,[SI].xI2 ;[CX] = I2 representation of X MOV DX,[SI].yI2 ;[DX] = I2 representation of Y CMP b$fpoint,1 ;processing point function ? JZ B$COORD_NOSTEP ; if so do not add the bases TEST AL,fxStep ;only need to test one, they come in pairs JZ B$COORD_NOSTEP ; If not step, then don't add base ADD CX,B$GRPACX ;Add current graphics accum to create step. ADD DX,B$GRPACY JMP SHORT COORD_STEP labelNP <PUBLIC,B$COORD_NOSTEP> ; B$FPCOORDW returns here ADD CX,B$VXOFF ;ABSx = Vx1 +x ADD DX,B$VYOFF ;ABSy = Vy1 +y COORD_STEP: MOV B$GRPACX,CX ;Update Graphics Accumulator x MOV B$GXPOS,CX ;Copy MOV B$GRPACY,DX ;Update Graphics Accumulator y MOV B$GYPOS,DX ;Copy MOV WORD PTR B$DFRACX,8080H ;Set Fractional x,y to 1/2 XOR AX,AX MOV [SI].fPoint,AL ;clear point flag for next time... CMP b$ScreenMode,0 ; graphics mode? JZ FC_ERRR ;Illegal function call POP SI JMP B$INVIEW ;See if point in viewport cEnd nogen FC_ERRR: JMP B$ERR_FC ;ILLEGAL FUNCTION CALL sEnd GR_TEXT END
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chromecast/media/base/media_codec_support.h" #include "base/bind.h" #include "base/strings/string_util.h" namespace chromecast { namespace media { AudioCodec ToCastAudioCodec(const ::media::AudioCodec codec) { switch (codec) { case ::media::kCodecAAC: return kCodecAAC; case ::media::kCodecMP3: return kCodecMP3; case ::media::kCodecPCM: return kCodecPCM; case ::media::kCodecPCM_S16BE: return kCodecPCM_S16BE; case ::media::kCodecVorbis: return kCodecVorbis; case ::media::kCodecOpus: return kCodecOpus; case ::media::kCodecEAC3: return kCodecEAC3; case ::media::kCodecAC3: return kCodecAC3; case ::media::kCodecFLAC: return kCodecFLAC; case ::media::kCodecMpegHAudio: return kCodecMpegHAudio; default: LOG(ERROR) << "Unsupported audio codec " << codec; } return kAudioCodecUnknown; } VideoCodec ToCastVideoCodec(const ::media::VideoCodec video_codec, const ::media::VideoCodecProfile codec_profile) { switch (video_codec) { case ::media::kCodecH264: return kCodecH264; case ::media::kCodecVP8: return kCodecVP8; case ::media::kCodecVP9: return kCodecVP9; case ::media::kCodecHEVC: return kCodecHEVC; case ::media::kCodecDolbyVision: if (codec_profile == ::media::DOLBYVISION_PROFILE0) { return kCodecDolbyVisionH264; } else if (codec_profile == ::media::DOLBYVISION_PROFILE4 || codec_profile == ::media::DOLBYVISION_PROFILE5 || codec_profile == ::media::DOLBYVISION_PROFILE7) { return kCodecDolbyVisionHEVC; } LOG(ERROR) << "Unsupported video codec profile " << codec_profile; break; default: LOG(ERROR) << "Unsupported video codec " << video_codec; } return kVideoCodecUnknown; } VideoProfile ToCastVideoProfile( const ::media::VideoCodecProfile codec_profile) { switch (codec_profile) { case ::media::H264PROFILE_BASELINE: return kH264Baseline; case ::media::H264PROFILE_MAIN: return kH264Main; case ::media::H264PROFILE_EXTENDED: return kH264Extended; case ::media::H264PROFILE_HIGH: return kH264High; case ::media::H264PROFILE_HIGH10PROFILE: return kH264High10; case ::media::H264PROFILE_HIGH422PROFILE: return kH264High422; case ::media::H264PROFILE_HIGH444PREDICTIVEPROFILE: return kH264High444Predictive; case ::media::H264PROFILE_SCALABLEBASELINE: return kH264ScalableBaseline; case ::media::H264PROFILE_SCALABLEHIGH: return kH264ScalableHigh; case ::media::H264PROFILE_STEREOHIGH: return kH264StereoHigh; case ::media::H264PROFILE_MULTIVIEWHIGH: return kH264MultiviewHigh; case ::media::HEVCPROFILE_MAIN: return kHEVCMain; case ::media::HEVCPROFILE_MAIN10: return kHEVCMain10; case ::media::HEVCPROFILE_MAIN_STILL_PICTURE: return kHEVCMainStillPicture; case ::media::VP8PROFILE_ANY: return kVP8ProfileAny; case ::media::VP9PROFILE_PROFILE0: return kVP9Profile0; case ::media::VP9PROFILE_PROFILE1: return kVP9Profile1; case ::media::VP9PROFILE_PROFILE2: return kVP9Profile2; case ::media::VP9PROFILE_PROFILE3: return kVP9Profile3; case ::media::DOLBYVISION_PROFILE0: return kDolbyVisionCompatible_EL_MD; case ::media::DOLBYVISION_PROFILE4: return kDolbyVisionCompatible_EL_MD; case ::media::DOLBYVISION_PROFILE5: return kDolbyVisionNonCompatible_BL_MD; case ::media::DOLBYVISION_PROFILE7: return kDolbyVisionNonCompatible_BL_EL_MD; default: LOG(INFO) << "Unsupported video codec profile " << codec_profile; } return kVideoProfileUnknown; } CodecProfileLevel ToCastCodecProfileLevel( const ::media::CodecProfileLevel& codec_profile_level) { CodecProfileLevel result; result.codec = ToCastVideoCodec(codec_profile_level.codec, codec_profile_level.profile); result.profile = ToCastVideoProfile(codec_profile_level.profile); result.level = codec_profile_level.level; return result; } } // namespace media } // namespace chromecast
; void *zx_saddrcup_fastcall(void *saddr) SECTION code_arch PUBLIC _zx_saddrcup_fastcall _zx_saddrcup_fastcall: INCLUDE "arch/zx/display/z80/asm_zx_saddrcup.asm"
// Copyright Oliver Kowalke 2013. // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #include "boost/fiber/recursive_mutex.hpp" #include <algorithm> #include <functional> #include "boost/fiber/exceptions.hpp" #include "boost/fiber/scheduler.hpp" #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_PREFIX #endif namespace boost { namespace fibers { void recursive_mutex::lock() { while ( true) { context * active_ctx = context::active(); // store this fiber in order to be notified later detail::spinlock_lock lk{ wait_queue_splk_ }; if ( active_ctx == owner_) { ++count_; return; } else if ( nullptr == owner_) { owner_ = active_ctx; count_ = 1; return; } BOOST_ASSERT( ! active_ctx->wait_is_linked() ); active_ctx->wait_link( wait_queue_); // suspend this fiber active_ctx->suspend( lk); BOOST_ASSERT( ! active_ctx->wait_is_linked() ); } } bool recursive_mutex::try_lock() noexcept { context * active_ctx = context::active(); detail::spinlock_lock lk{ wait_queue_splk_ }; if ( nullptr == owner_) { owner_ = active_ctx; count_ = 1; } else if ( active_ctx == owner_) { ++count_; } lk.unlock(); // let other fiber release the lock context::active()->yield(); return active_ctx == owner_; } void recursive_mutex::unlock() { context * active_ctx = context::active(); detail::spinlock_lock lk( wait_queue_splk_); if ( BOOST_UNLIKELY( active_ctx != owner_) ) { throw lock_error( std::make_error_code( std::errc::operation_not_permitted), "boost fiber: no privilege to perform the operation"); } if ( 0 == --count_) { owner_ = nullptr; if ( ! wait_queue_.empty() ) { context * ctx = & wait_queue_.front(); wait_queue_.pop_front(); active_ctx->schedule( ctx); } } } }} #ifdef BOOST_HAS_ABI_HEADERS # include BOOST_ABI_SUFFIX #endif
; A129760: Bitwise AND of binary representation of n-1 and n. ; 0,0,2,0,4,4,6,0,8,8,10,8,12,12,14,0,16,16,18,16,20,20,22,16,24,24,26,24,28,28,30,0,32,32,34,32,36,36,38,32,40,40,42,40,44,44,46,32,48,48,50,48,52,52,54,48,56,56,58,56,60,60,62,0,64,64,66,64,68,68,70,64,72,72,74,72,76,76,78,64,80,80,82,80,84,84,86,80,88,88,90,88,92,92,94,64,96,96,98,96,100,100,102,96,104,104,106,104,108,108,110,96,112,112,114,112,116,116,118,112,120,120,122,120,124,124,126,0,128,128,130,128,132,132,134,128,136,136,138,136,140,140,142,128,144,144,146,144,148,148,150,144,152,152,154,152,156,156,158,128,160,160,162,160,164,164,166,160,168,168,170,168,172,172,174,160,176,176,178,176,180,180,182,176,184,184,186,184,188,188,190,128,192,192,194,192,196,196,198,192,200,200,202,200,204,204,206,192,208,208,210,208,212,212,214,208,216,216,218,216,220,220,222,192,224,224,226,224,228,228,230,224,232,232,234,232,236,236,238,224,240,240,242,240,244,244,246,240,248,248 add $0,1 mov $1,$0 gcd $0,262144 sub $1,$0
.data .text addi $s0, $s0, -1 addi $s1, $s1, -4096 and $t0, $s0, $s1 or $t1, $s0, $s1 xor $t2, $s0, $s1 nor $t3, $s0, $s1 slt $t4, $s1, $s0 # Termino do programa li $v0, 10 # Codigo para terminar o programa = 10 syscall
bits 16 jmp start CR equ 0Dh LF equ 0Ah K_CS_ADDR equ 0050h ; data drive0: dw 0 banner: db "MINOS Bootloader", CR, LF, 0 ; General messages msg_loading: db "Loading", 0 msg_done: db "done!", CR, LF, 0 ; Error messages error_msg_panic: db "PANIC: ", 0 error_msg_disk_reset: db "Drive reset failed!", CR, LF, 0 error_msg_disk_read: db "Drive read failed!", CR, LF, 0 start: cli mov ax, 07C0h ; load bootstrap address mov ds, ax ; set data segment mov es, ax ; set extra segment mov ax, stack_end ; load address of temp stack segment mov ss, ax ; set stack end mov cx, 01FCh sub ax, cx mov sp, ax ; set stack top before boot signature sti mov [drive0], dx ; save first detected drive push banner ; call puts ; print version add sp, 2 ; clean up push word [drive0] call disk_reset add sp, 2 push msg_loading call puts add sp, 2 ; begin disk operations xor cx, cx mov ax, K_CS_ADDR mov es, ax mov bx, 0000h ; starting address (es:bx) mov di, 2 ; start at sector .loader: mov al, 1 ; read one sector mov cx, di ; track/cyl | sector number mov dh, 0 ; head number mov dl, [drive0] ; drive number call disk_read push '.' call putc add sp, 2 add bx, 0200h ; increment address by 512 bytes inc di ; increment track read count cmp di, 12h ; transfer 9K (512 * 18) jle .loader ; keep reading push msg_done call puts add sp, 2 mov dx, [drive0] ; the kernel will need the boot drive number jmp K_CS_ADDR:0000h ; jump to kernel address cli ; disable interrupts jmp $ ; hang panic: ; Hang system with supplied error message push bp mov bp, sp push error_msg_panic ; i.e. 'PANIC:' call puts add sp, 2 push word [bp + 4] ; address of error string buffer call puts ; print error add sp, 2 cli ; disable interrupts jmp $ ; hang (no return) ; stack is dead disk_reset: mov ah, 00h ; reset disk ; dl is drive number int 13h ; BIOS disk service jnc .success push error_msg_disk_reset call panic .success: ret disk_read: push bp mov bp, sp push di mov di, 3 ; retry counter .readloop: push ax push bx push cx mov ah, 02h ; BIOS - read disk sectors int 13h ; BIOS disk service jnc .success call disk_reset pop cx pop bx pop ax dec di jnz .readloop push error_msg_disk_read call panic add sp, 2 .success: pop di mov sp, bp pop bp ret putc: ; Write single character at cursor position push bp mov bp, sp pusha mov ah, 0eh ; BIOS - teletype mov al, [bp + 4] ; character mov bx, 0 ; video page zero int 10h ; BIOS video service popa mov sp, bp pop bp ret puts: ; Write string buffer at cursor position push bp mov bp, sp pusha mov si, [bp + 4] ; address of string buffer mov bx, 0000h ; mov ah, 0eh ; BIOS - teletype .loop: lodsb ; load byte at [si] into al or al, 0 ; 0 | 0 = 0 (detect null terminator) je .end int 10h ; BIOS video service jmp .loop .end: popa mov sp, bp pop bp ret stack_end: ; address of stack end ; boot signature times 510-($-$$) db 0 dw 0xAA55
; A008779: Number of n-dimensional partitions of 5. ; 1,7,24,59,120,216,357,554,819,1165,1606,2157,2834,3654,4635,5796,7157,8739,10564,12655,15036,17732,20769,24174,27975,32201,36882,42049,47734,53970,60791,68232,76329,85119,94640,104931,116032,127984,140829,154610,169371,185157,202014,219989,239130,259486,281107,304044,328349,354075,381276,410007,440324,472284,505945,541366,578607,617729,658794,701865,747006,794282,843759,895504,949585,1006071,1065032,1126539,1190664,1257480,1327061,1399482,1474819,1553149,1634550,1719101,1806882,1897974,1992459,2090420,2191941,2297107,2406004,2518719,2635340,2755956,2880657,3009534,3142679,3280185,3422146,3568657,3719814,3875714,4036455,4202136,4372857,4548719,4729824,4916275,5108176,5305632,5508749,5717634,5932395,6153141,6379982,6613029,6852394,7098190,7350531,7609532,7875309,8147979,8427660,8714471,9008532,9309964,9618889,9935430,10259711,10591857,10931994,11280249,11636750,12001626,12375007,12757024,13147809,13547495,13956216,14374107,14801304,15237944,15684165,16140106,16605907,17081709,17567654,18063885,18570546,19087782,19615739,20154564,20704405,21265411,21837732,22421519,23016924,23624100,24243201,24874382,25517799,26173609,26841970,27523041,28216982,28923954,29644119,30377640,31124681,31885407,32659984,33448579,34251360,35068496,35900157,36746514,37607739,38484005,39375486,40282357,41204794,42142974,43097075,44067276,45053757,46056699,47076284,48112695,49166116,50236732,51324729,52430294,53553615,54694881,55854282,57032009,58228254,59443210,60677071,61930032,63202289,64494039,65805480,67136811,68488232,69859944,71252149,72665050,74098851,75553757,77029974,78527709,80047170,81588566,83152107,84738004,86346469,87977715,89631956,91309407,93010284,94734804,96483185,98255646,100052407,101873689,103719714,105590705,107486886,109408482,111355719,113328824,115328025,117353551,119405632,121484499,123590384,125723520,127884141,130072482,132288779,134533269,136806190,139107781,141438282,143797934,146186979,148605660,151054221,153532907,156041964,158581639,161152180,163753836,166386857,169051494,171747999,174476625 add $0,1 mov $4,$0 mov $5,1 lpb $0 add $2,$4 add $1,$2 mov $3,$5 mov $5,$2 sub $2,$3 add $2,$5 add $5,$0 sub $0,1 lpe
include "src/registers.asm" SECTION "crash", ROM0 jp crash SECTION "vblank", ROM0 jp vblank_interrupt SECTION "hblank", ROM0 jp hblank_interrupt SECTION "timer", ROM0 jp timer_interrupt SECTION "serial", ROM0 jp serial_interrupt SECTION "joypad", ROM0 jp joypad_interrupt crash:: di ld b, b ld hl, lcdLine .loop: ld a, $90 cp [hl] jr nc, .loop xor a dec l ld [hld], a ld [hld], a dec l ld [hl], a ld hl, crashText ld c, 16 xor a ld [VRAMBankSelect], a ld de, $9800 .copyLoop: ld a, [hli] ld [de], a inc e dec c jr nz, .copyLoop ld a, 1 ld [VRAMBankSelect], a ld c, 16 xor a ld hl, $9800 .copyLoop2: ld [hli], a dec c jr nz, .copyLoop2 ld a, %10010001 ld [lcdCtrl], a jp lockup SECTION "Start", ROM0 nop jp main SECTION "Header", ROM0 ds $150 - $104
; A291305: The arithmetic function v_5(n,1). ; 1,2,3,0,5,6,7,8,5,10,11,12,13,10,15,16,17,18,15,20,21,22,23,20,25,26,27,28,25,30,31,32,33,30,35,36,37,38,35,40,41,42,43,40,45,46,47,48,45,50,51,52,53,50,55,56,57,58,55,60,61,62,63,60,65,66,67,68,65 add $0,2 mov $2,5 gcd $2,$0 sub $0,$2
; A131723: a(2*n) = 1-n^2, a(2*n+1) = n*(n+1). ; 0,2,-3,6,-8,12,-15,20,-24,30,-35,42,-48,56,-63,72,-80,90,-99,110,-120,132,-143,156,-168,182,-195,210,-224,240,-255,272,-288,306,-323,342,-360,380,-399,420,-440,462,-483,506,-528,552,-575,600,-624,650,-675,702,-728,756,-783,812,-840,870,-899,930,-960,992,-1023,1056,-1088,1122,-1155,1190,-1224,1260,-1295,1332,-1368,1406,-1443,1482,-1520,1560,-1599,1640,-1680,1722,-1763,1806,-1848,1892,-1935,1980,-2024,2070,-2115,2162,-2208,2256,-2303,2352,-2400,2450,-2499,2550,-2600,2652,-2703,2756,-2808,2862,-2915,2970,-3024,3080,-3135,3192,-3248,3306,-3363,3422,-3480,3540,-3599,3660,-3720,3782,-3843,3906,-3968,4032,-4095,4160,-4224,4290,-4355,4422,-4488,4556,-4623,4692,-4760,4830,-4899,4970,-5040,5112,-5183,5256,-5328,5402,-5475,5550,-5624,5700,-5775,5852,-5928,6006,-6083,6162,-6240,6320,-6399,6480,-6560,6642,-6723,6806,-6888,6972,-7055,7140,-7224,7310,-7395,7482,-7568,7656,-7743,7832,-7920,8010,-8099,8190,-8280,8372,-8463,8556,-8648,8742,-8835,8930,-9024,9120,-9215,9312,-9408,9506,-9603,9702,-9800,9900,-9999,10100,-10200,10302,-10403,10506,-10608,10712,-10815,10920,-11024,11130,-11235,11342,-11448,11556,-11663,11772,-11880,11990,-12099,12210,-12320,12432,-12543,12656,-12768,12882,-12995,13110,-13224,13340,-13455,13572,-13688,13806,-13923,14042,-14160,14280,-14399,14520,-14640,14762,-14883,15006,-15128,15252,-15375,15500,-15624,15750 mov $3,1 add $3,$0 mov $4,$3 add $3,2 lpb $0 sub $0,1 mul $3,$4 mov $1,$3 mov $2,1 sub $2,$3 mov $3,$2 mov $4,1 lpe div $1,4
; A073851: Cumulative sum of initial digits of (n base 5). ; 0,1,3,6,10,11,12,13,14,15,17,19,21,23,25,28,31,34,37,40,44,48,52,56,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,87,89,91,93,95,97,99,101,103,105,107,109,111,113,115,117,119,121 mov $3,$0 mov $5,$0 lpb $3,1 mov $0,$5 sub $3,1 sub $0,$3 lpb $0,1 mov $2,$0 div $0,5 mov $6,7 mul $6,$2 lpe mov $4,$6 div $4,7 add $1,$4 lpe
; A097076: Expansion of x/(1-x-3x^2-x^3). ; 0,1,1,4,8,21,49,120,288,697,1681,4060,9800,23661,57121,137904,332928,803761,1940449,4684660,11309768,27304197,65918161,159140520,384199200,927538921,2239277041,5406093004,13051463048,31509019101,76069501249,183648021600 lpb $0 sub $0,1 mov $1,$0 mov $0,0 max $1,0 seq $1,228797 ; Number of 2 X n binary arrays with top left element equal to 1 and no two ones adjacent horizontally or nw-se. lpe div $1,2 mov $0,$1
#include <cstdlib> #include <iostream> #include <stdexcept> #include <string> #include <vector> #include <boost/algorithm/string/classification.hpp> #include <boost/algorithm/string/split.hpp> #include <boost/filesystem/operations.hpp> #include <castel/runtime/Box.hh> #include <castel/toolchain/Source.hh> #include "Evaluator.hh" #include "require.hh" static std::string getPath( void ) { char const * env = std::getenv( "CASTEL_PATH" ); if ( env ) return env; return ""; } castel::runtime::Box * require( std::string const & module ) { std::vector< std::string > pathFolders; std::string path = getPath( ); boost::split( pathFolders, path, boost::is_any_of( ":" ) ); for ( auto const & folder : pathFolders ) { if ( folder.size( ) == 0 ) continue ; std::string filePath = path + "/" + module + ".ct"; if ( ! boost::filesystem::exists( filePath ) ) continue ; std::ifstream stream( filePath ); if ( stream.bad( ) ) throw std::runtime_error( "I/O error while loading module '" + module + "'" ); return Evaluator( ).run( castel::toolchain::Source::fromStream( stream ) ); } throw std::runtime_error( "Module '" + module + "' not found" ); }
;; ;; Copyright (c) 2021 Antti Tiihala ;; ;; Permission to use, copy, modify, and/or distribute this software for any ;; purpose with or without fee is hereby granted, provided that the above ;; copyright notice and this permission notice appear in all copies. ;; ;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ;; ;; base/a64/gdt.asm ;; Global Descriptor Table ;; bits 64 section .text global gdt_load global gdt_load_cs global gdt_load_es global gdt_load_ss global gdt_load_ds global gdt_load_fs global gdt_load_gs global gdt_load_tss global gdt_read_segment align 16 ; void gdt_load(const void *gdt_ptr) gdt_load: lgdt [rcx] ; load global descriptor table xor ecx, ecx ; ecx = 0 (segment selector) lldt cx ; load local descriptor table ret align 16 ; void gdt_load_cs(int sel) gdt_load_cs: push rbx ; save register rbx mov eax, gdt_load_cs_end ; eax = address of gdt_load_cs_end sub rsp, 8 ; decrement stack pointer mov rbx, rsp ; rbx = stack pointer mov [rbx+0], eax ; offset mov [rbx+4], ecx ; selector db 0xFF, 0x2B ; jmp far [rbx] (32-bit) gdt_load_cs_end: add rsp, 8 ; restore stack pointer pop rbx ; restore register rbx ret align 16 ; void gdt_load_es(int sel) gdt_load_es: mov es, ecx ; set segment register es ret align 16 ; void gdt_load_ss(int sel) gdt_load_ss: mov ss, ecx ; set segment register ss ret align 16 ; void gdt_load_ds(int sel) gdt_load_ds: mov ds, ecx ; set segment register ds ret align 16 ; void gdt_load_fs(int sel) gdt_load_fs: mov fs, ecx ; set segment register fs ret align 16 ; void gdt_load_gs(int sel) gdt_load_gs: mov gs, ecx ; set segment register gs ret align 16 ; void gdt_load_tss(int sel) gdt_load_tss: ltr cx ; load task register ret align 16 ; uint32_t gdt_read_segment(int sel, size_t offset) ; ; Interrupts should be disabled before calling this function. gdt_read_segment: push fs ; save segment register fs mov fs, ecx ; set segment register fs mov eax, [fs:rdx] ; eax = return value pop fs ; restore segment register fs ret
;Write a program for the 8051 to transfer ‘VIT’ serially to 9600 baud, 8 bit data, 1 stop b it, do this continuously. ORG 0000H MOV TMOD,#20H MOV TH1,#0FDH MOV SCON,#50H SETB TR1 AGAIN:MOV A,#'V' ACALL TRANS MOV A,#'I' ACALL TRANS MOV A,#'T' ACALL TRANS MOV A,#' ' ACALL TRANS SJMP AGAIN TRANS:MOV SBUF,A HERE:JNB TI,HERE CLR TI RET END ;Deeptimaan Banerjee
; A050476: a(n) = C(n)*(6n+1) where C(n)=Catalan numbers (A000108). ; Submitted by Jon Maiga ; 1,7,26,95,350,1302,4884,18447,70070,267410,1024556,3938662,15184876,58689100,227327400,882230895,3429693990,13353413370,52062618300,203235266850,794258570820,3107215911540,12167180964120,47685286297350,187036101361980,734153906619252,2883674432327864,11333968799308652,44573403845810840,175392387913989400,690512556878707024,2719846939335431983,10718074521270302214,42254889952036378890,166653528640694806620,657536239425440566282,2595276249731718407764,10247029364390648547172 mov $2,$0 seq $0,108 ; Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). mul $2,$0 mul $2,6 add $0,$2
; SBAS_PAITM - SuperBASIC Parser Items  1992 Tony Tebby section sbas xdef sb_patxt ; parse text item xdef sb_pastr ; parse string item xdef sb_pakey ; parse keywords xdef sb_panky ; parse non-keywords xref sb_parcl xref sbp_dkey xref sbp_skey xref sbp_nkey xref sbp_intb include 'dev8_keys_sbasic' include 'dev8_keys_err' include 'dev8_smsq_sbas_parser_keys' include 'dev8_keys_k' include 'dev8_mac_assert' ;+++ ; Check string (text) ;--- sb_pastr addq.l #1,a0 move.l a0,a1 ; save start of text sbp_gstr move.b (a6,a0.l),d0 cmp.b d1,d0 ; delimiter beq.s sbp_stxt addq.l #1,a0 cmp.b #k.nl,d0 ; end of line? bne.s sbp_gstr moveq #sbe.bstr,d0 ; bad string bra.s sbp_rts sbp_stxt bsr.s sbp_stext addq.l #1,a0 ; skip delimiter rts ;+++ ; Get text item ;--- sb_patxt move.l a0,a1 ; text goes from here move.l sb_buffp(a6),a0 ; ... to here subq.l #1,a0 ; ... nearly move.w #tkw.text,d1 moveq #tki.text,d2 sbp_stext move.w d1,(a6,a4.l) ; string/text token move.l a0,d1 sub.l a1,d1 ; length of string move.w d1,2(a6,a4.l) addq.l #4,a4 sub.l a0,a1 ; buffer may move, only A0/A4 are adjusted jsr sb_parcl ; reserve command line space add.l a0,a1 bra.s sbp_ctxe sbp_ctext move.b (a6,a1.l),(a6,a4.l) ; copy byte addq.l #1,a1 addq.l #1,a4 sbp_ctxe cmp.l a0,a1 ; more to copy? blt.s sbp_ctext move.l a4,d0 and.w #1,d0 add.w d0,a4 ; round up moveq #0,d0 ; always OK sbp_rts rts ;+++ ; Check keywords ;--- sb_pakey sbk.reg reg a1/a2 sbk_item equ $00 movem.l sbk.reg,-(sp) moveq #$ffffffdf,d3 ; upper / lower case diff ; start off with the doubles lea sbp_dkey,a3 ; table of double keywords sbk_dloop assert sbg_ditm,sbg_dabb-1,0 move.w (a3)+,d5 ; token / abbreviation beq.s sbk_sing ; ... no more doubles cmp.b d5,d2 ; long enough? blt.s sbk_nxtd lea sbg_nam1-2(a3),a2 add.w (a2),a2 ; first name addq.w #2,a2 ; skip length move.w d2,d0 ; length to check subq.w #1,d0 sbk_ck1 move.b (a6,a1.l),d1 ; next to check addq.l #1,a1 move.b (a2)+,d5 ; against this eor.b d5,d1 and.b d3,d1 dbne d0,sbk_ck1 addq.w #1,d0 move.w d2,d1 sub.w d0,d1 ; actual number of chars which match cmp.b sbg_abb1-2(a3),d1 ; enough chars for a match? blt.s sbk_nxtd ; ... no cmp.b sbg_abb2-2(a3),d0 ; enough chars in second bit? blt.s sbk_nxtd ; ... no lea sbg_nam2-2(a3),a2 add.w (a2),a2 ; second name addq.w #2,a2 ; skip length subq.w #1,d0 sbk_ck2 move.b -1(a6,a1.l),d1 ; next to check addq.l #1,a1 move.b (a2)+,d5 ; against this eor.b d5,d1 and.b d3,d1 dbne d0,sbk_ck2 beq.s sbk_setd ; match set double sbk_nxtd move.l sbk_item(sp),a1 ; restore item pointer addq.l #sbg.ditm-2,a3 ; next double item bra.s sbk_dloop sbk_setd move.b sbg_ditm-2(a3),d2 ; item moveq #0,d0 assert sbg_itm1,sbg_itm2-1 move.w sbg_itm1-2(a3),d1 move.b d1,d0 lsr.w #7,d1 ; first item add.b d0,d0 ; second item lea sbp_intb,a2 move.w (a2,d1.w),(a6,a4.l) ; set tokens move.w (a2,d0.w),2(a6,a4.l) addq.l #4,a4 bra.s sbk_exok ; now try the singles sbk_sing lea sbp_skey,a3 ; table of single keywords sbk_sloop move.l sbk_item(sp),a1 ; restore item pointer assert sbg_item,sbg_iabb-1,0 move.w (a3)+,d5 ; token / abbreviation beq.s sbk_nf ; ... no more singles assert sbg_name,2 move.l a3,a2 add.w (a3)+,a2 ; pointer to name cmp.b d5,d2 ; long enough? blt.s sbk_sloop cmp.w (a2)+,d2 ; too long? bgt.s sbk_sloop move.w d2,d0 subq.w #1,d0 sbk_ckc move.b (a6,a1.l),d1 ; next to check addq.l #1,a1 move.b (a2)+,d5 ; against this eor.b d5,d1 and.b d3,d1 dbne d0,sbk_ckc bne.s sbk_sloop ; no match, try again sbk_seti move.b sbg_item-sbg.item(a3),d2 ; item moveq #0,d0 move.b d2,d0 add.b d0,d0 ; item index lea sbp_intb,a2 move.w (a2,d0.w),(a6,a4.l) ; set token addq.l #2,a4 sbk_exok moveq #0,d0 sbk_exit movem.l (sp)+,sbk.reg rts sbk_nf moveq #err.itnf,d0 bra.s sbk_exit ;+++ ; Check non-keyword items ;--- sb_panky movem.l sbk.reg,-(sp) lea sbp_nkey,a3 ; table of non keywords sbk_nloop assert sbg_item,sbg_iabb-1,0 move.w (a3)+,d5 ; token / abbreviation = length beq.s sbk_nf ; ... no more non-keywords assert sbg_name,2 move.l a3,a2 add.w (a3)+,a2 ; pointer to characters move.w (a2)+,d0 cmp.b (a2)+,d1 bne.s sbk_nloop ; first char does not match lea 1(a0),a1 ; set next char pointer subq.w #2,d0 blt.s sbk_seta0 ; only one char, done sbk_ckn move.b (a6,a1.l),d2 ; next to check addq.l #1,a1 sub.b (a2)+,d2 ; against this dbne d0,sbk_ckn bne.s sbk_nloop ; no match, try again sbk_seta0 move.l a1,a0 ; update buffer pointer bra.s sbk_seti ; set item end
; A010650: Decimal expansion of cube root of 80. ; Submitted by Christian Krause ; 4,3,0,8,8,6,9,3,8,0,0,6,3,7,6,7,4,4,3,5,1,8,5,8,7,1,3,3,0,3,8,7,0,0,9,9,0,5,1,8,6,8,9,8,8,4,3,8,4,2,1,7,1,6,4,9,7,8,4,7,1,0,1,2,6,9,2,8,2,2,2,1,3,2,9,6,6,8,1,6,0,0,3,7,0,8,8,3,0,0,7,0,8,6,4,8,6,5,5,2 mov $2,1 mov $3,$0 mul $3,4 lpb $3 add $1,$5 add $5,$2 add $5,$2 add $5,$2 add $2,$1 mul $1,2 sub $3,1 sub $5,48 lpe mov $4,10 pow $4,$0 div $2,$4 sub $5,3 mul $5,2 div $5,$2 mov $0,$5 add $0,10 mod $0,10
; PUTSYS for 2014 systems with 64MB CF ; ; Adapted from: ;================================================================================== ; Grant Searle's code, modified for use with Small Computer Workshop IDE. ; Also embedded CP/M hex files into this utility to make it easier to use. ; Compile options for LiNC80 and RC2014 systems. ; SCC 2018-04-13 ; Added option for 64MB compact flash. ; JL 2018-04-28 ;================================================================================== ; Contents of this file are copyright Grant Searle ; ; You have permission to use this for NON COMMERCIAL USE ONLY ; If you wish to use it elsewhere, please include an acknowledgement to myself. ; ; http://searle.hostei.com/grant/index.html ; ; eMail: [email protected] ; ; If the above don't work, please perform an Internet search to see if I have ; updated the web page hosting service. ; ;================================================================================== PSECT text ; NOTE: Some memory locations are overwritten when HEX files are inserted CodeORG EQU 08000H ;Code runs here loadAddr EQU 09000H ;CP/M hex files load here numSecs EQU 24 ;Number of 512 sectors to be loaded ; CF registers CF_DATA EQU 10H CF_FEATURES EQU 11H CF_ERROR EQU 11H CF_SECCOUNT EQU 12H CF_SECTOR EQU 13H CF_CYL_LOW EQU 14H CF_CYL_HI EQU 15H CF_HEAD EQU 16H CF_STATUS EQU 17H CF_COMMAND EQU 17H CF_LBA0 EQU 13H CF_LBA1 EQU 14H CF_LBA2 EQU 15H CF_LBA3 EQU 16H ;CF Features CF_8BIT EQU 1 CF_NOCACHE EQU 082H ;CF Commands CF_READ_SEC EQU 020H CF_WRITE_SEC EQU 030H CF_SET_FEAT EQU 0EFH LF EQU 0AH ;line feed FF EQU 0CH ;form feed CR EQU 0DH ;carriage RETurn ;================================================================================================ ORG CodeORG ;Code runs here CALL printInline DEFM 'CP/M System Transfer by G. Searle 2012' DEFB CR,LF,0 CALL cfWait LD A,CF_8BIT ; Set IDE to be 8bit OUT (CF_FEATURES),A LD A,CF_SET_FEAT OUT (CF_COMMAND),A CALL cfWait LD A,CF_NOCACHE ; No write cache OUT (CF_FEATURES),A LD A,CF_SET_FEAT OUT (CF_COMMAND),A LD B,numSecs LD A,0 LD (secNo),A LD HL,loadAddr LD (dmaAddr),HL processSectors: CALL cfWait LD A,(secNo) OUT (CF_LBA0),A LD A,0 OUT (CF_LBA1),A OUT (CF_LBA2),A LD A,0E0H OUT (CF_LBA3),A LD A,1 OUT (CF_SECCOUNT),A CALL write LD DE,0200H LD HL,(dmaAddr) ADD HL,DE LD (dmaAddr),HL LD A,(secNo) INC A LD (secNo),A LD A,'.' RST 08 DJNZ processSectors CALL printInline DEFB CR,LF DEFM 'System transfer complete' DEFB CR,LF,0 RET ;================================================================================================ ; Write physical sector to host ;================================================================================================ write: PUSH AF PUSH BC PUSH HL CALL cfWait LD A,CF_WRITE_SEC OUT (CF_COMMAND),A CALL cfWait TstDRQ: IN A,(CF_STATUS) ;Read status register BIT 3,A ;Test DRQ flag JR Z,TstDRQ ;Low so not ready LD C,4 LD HL,(dmaAddr) wr4secs: LD B,128 wrByte: LD A,(HL) NOP NOP OUT (CF_DATA),A INC HL DEC B JR NZ, wrByte DEC C JR NZ,wr4secs POP HL POP BC POP AF RET ;================================================================================================ ; Wait for disk to be ready (busy=0,ready=1) ;================================================================================================ cfWait: PUSH AF TstBusy: IN A,(CF_STATUS) ;Read status register BIT 7,A ;Test Busy flag JR NZ,TstBusy ;High so busy TstReady: IN A,(CF_STATUS) ;Read status register BIT 6,A ;Test Ready flag JR Z,TstBusy ;Low so not ready POP AF RET ;================================================================================================ ; Utilities ;================================================================================================ printInline: EX (SP),HL ; PUSH HL and put RET ADDress into HL PUSH AF PUSH BC nextILChar: LD A,(HL) CP 0 JR Z,endOfPrint RST 08H INC HL JR nextILChar endOfPrint: INC HL ; Get past 'null' terminator POP BC POP AF EX (SP),HL ; PUSH new RET ADDress on stack and restore HL RET dmaAddr: DEFW 0 secNo: DEFB 0
// -*- indent-tabs-mode: nil -*- #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <stdlib.h> #include <iostream> #include <fstream> #include <ctype.h> #include <getopt.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <sys/stat.h> #include <sys/types.h> #include <time.h> #include <unistd.h> #include <arc/Thread.h> #include <arc/Logger.h> #include <arc/URL.h> #include <arc/FileUtils.h> #include <arc/FileAccess.h> #include <arc/StringConv.h> #include <arc/data/DataBuffer.h> #include <arc/data/DataCallback.h> //#include <arc/CheckSum.h> #include <arc/Utils.h> #include "DataPointS3.h" #if defined(HAVE_S3_TIMEOUT) #define S3_TIMEOUTMS 0 #endif namespace ArcDMCS3 { using namespace Arc; // Static class variables Logger DataPointS3::logger(Logger::getRootLogger(), "DataPoint.S3"); S3Status DataPointS3::request_status = S3Status(0); unsigned long long int DataPointS3::offset = 0; char ArcDMCS3::DataPointS3::error_details[4096] = { 0 }; S3Status DataPointS3::responsePropertiesCallback(const S3ResponseProperties *properties, void *callbackData) { return S3StatusOK; } void DataPointS3::getCompleteCallback(S3Status status, const S3ErrorDetails *error, void *callbackData) { request_status = status; if (status == S3StatusOK) { DataBuffer *buf = (DataBuffer *)callbackData; buf->eof_read(true); } else { int len = 0; if (error && error->message) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Message: %s\n", error->message); } if (error && error->resource) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Resource: %s\n", error->resource); } if (error && error->furtherDetails) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Further Details: %s\n", error->furtherDetails); } if (error && error->extraDetailsCount) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, "%s", " Extra Details:\n"); int i; for (i = 0; i < error->extraDetailsCount; i++) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " %s: %s\n", error->extraDetails[i].name, error->extraDetails[i].value); } } } } void DataPointS3::putCompleteCallback(S3Status status, const S3ErrorDetails *error, void *callbackData) { request_status = status; if (status == S3StatusOK) { DataBuffer *buf = (DataBuffer *)callbackData; buf->eof_write(true); } else { int len = 0; if (error && error->message) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Message: %s\n", error->message); } if (error && error->resource) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Resource: %s\n", error->resource); } if (error && error->furtherDetails) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Further Details: %s\n", error->furtherDetails); } if (error && error->extraDetailsCount) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, "%s", " Extra Details:\n"); int i; for (i = 0; i < error->extraDetailsCount; i++) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " %s: %s\n", error->extraDetails[i].name, error->extraDetails[i].value); } } } } void DataPointS3::responseCompleteCallback(S3Status status, const S3ErrorDetails *error, void *callbackData) { request_status = status; int len = 0; if (error && error->message) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Message: %s\n", error->message); } if (error && error->resource) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Resource: %s\n", error->resource); } if (error && error->furtherDetails) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " Further Details: %s\n", error->furtherDetails); } if (error && error->extraDetailsCount) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, "%s", " Extra Details:\n"); int i; for (i = 0; i < error->extraDetailsCount; i++) { len += snprintf(&(error_details[len]), sizeof(error_details) - len, " %s: %s\n", error->extraDetails[i].name, error->extraDetails[i].value); } } } // get object ---------------------------------------------------------------- S3Status DataPointS3::getObjectDataCallback(int bufferSize, const char *buffer, void *callbackData) { DataBuffer *buf = (DataBuffer *)callbackData; /* 1. claim buffer */ int h; unsigned int l; if (!buf->for_read(h, l, true)) { /* failed to get buffer - must be error or request to exit */ buf->error_read(true); return S3StatusOK; } /* 2. read */ memcpy((*(buf))[h], buffer, bufferSize); /* 3. announce */ buf->is_read(h, bufferSize, DataPointS3::offset); DataPointS3::offset += bufferSize; return S3StatusOK; } static int putObjectDataCallback(int bufferSize, char *buffer, void *callbackData) { DataBuffer *buf = (DataBuffer *)callbackData; /* 1. claim buffer */ int h; unsigned int l; unsigned long long int p; if (!buf->for_write(h, l, p, true)) { // no more data from the buffer, did the other side finished? buf->eof_write(true); return 0; } /* 2. write */ int toCopy = ((l > (unsigned)bufferSize) ? (unsigned)bufferSize : l); memcpy(buffer, (*(buf))[h], toCopy); /* 3. announce */ buf->is_written(h); return toCopy; } DataPointS3::DataPointS3(const URL &url, const UserConfig &usercfg, PluginArgument *parg) : DataPointDirect(url, usercfg, parg), fd(-1), reading(false), writing(false) { hostname = std::string(url.Host() + ":" + tostring(url.Port())); access_key = Arc::GetEnv("S3_ACCESS_KEY"); secret_key = Arc::GetEnv("S3_SECRET_KEY"); #if defined(S3_DEFAULT_REGION) auth_region = Arc::GetEnv("S3_AUTH_REGION"); #endif // Extract bucket bucket_name = url.Path(); // Remove leading slash if (bucket_name.find('/') == 0) { bucket_name = bucket_name.substr(1); } // Remove trailing slash if (bucket_name.rfind('/') == bucket_name.length() - 1) { bucket_name = bucket_name.substr(0, bucket_name.length() - 1); } // extract key std::size_t found = bucket_name.find('/'); if (found != std::string::npos) { key_name = bucket_name.substr(found + 1, bucket_name.length() - 1); bucket_name = bucket_name.substr(0, found); } // S3_validate_bucket_name // if / in key_name or bucket_name then Invalid bucket/key name if (bucket_name.find('/') || key_name.find("/")) { } // Check scheme if (url.Protocol() == "s3+https") { protocol = S3ProtocolHTTPS; } else { protocol = S3ProtocolHTTP; } uri_style = S3UriStylePath; S3_initialize("s3", S3_INIT_ALL, hostname.c_str()); bufsize = 16384; } DataPointS3::~DataPointS3() { S3_deinitialize(); } Plugin *DataPointS3::Instance(PluginArgument *arg) { DataPointPluginArgument *dmcarg = dynamic_cast<DataPointPluginArgument *>(arg); if (!dmcarg) return NULL; if (((const URL &)(*dmcarg)).Protocol() != "s3" && ((const URL &)(*dmcarg)).Protocol() != "s3+http" && ((const URL &)(*dmcarg)).Protocol() != "s3+https") return NULL; return new DataPointS3(*dmcarg, *dmcarg, dmcarg); } DataStatus DataPointS3::Check(bool check_meta) { return DataStatus::Success; } S3Status DataPointS3::headResponsePropertiesCallback( const S3ResponseProperties *properties, void *callbackData) { FileInfo *file = (FileInfo *)callbackData; file->SetType(FileInfo::file_type_file); file->SetSize(properties->contentLength); file->SetModified(properties->lastModified); return S3StatusOK; } DataStatus DataPointS3::Stat(FileInfo &file, DataPointInfoType verb) { if (!bucket_name.empty() && !key_name.empty()) { S3BucketContext bucketContext = { 0, bucket_name.c_str(), protocol, uri_style, access_key.c_str(), secret_key.c_str(), #if defined(S3_DEFAULT_REGION) NULL, auth_region.c_str() }; #else 0 }; #endif S3ResponseHandler responseHandler = { &headResponsePropertiesCallback, &responseCompleteCallback }; file.SetName(key_name); #if defined(S3_TIMEOUTMS) S3_head_object(&bucketContext, key_name.c_str(), NULL, S3_TIMEOUTMS, &responseHandler, #else S3_head_object(&bucketContext, key_name.c_str(), NULL, &responseHandler, #endif &file); if (request_status == S3StatusOK) { return DataStatus::Success; } return DataStatus(DataStatus::StatError, S3_get_status_name(request_status)); } return DataStatus::StatError; } S3Status DataPointS3::listBucketCallback( int isTruncated, const char *nextMarker, int contentsCount, const S3ListBucketContent *contents, int commonPrefixesCount, const char **commonPrefixes, void *callbackData) { std::list<FileInfo> *files = (std::list<FileInfo> *)callbackData; for (int i = 0; i < contentsCount; i++) { const S3ListBucketContent *content = &(contents[i]); time_t t = (time_t)content->lastModified; FileInfo file = FileInfo(content->key); file.SetType(FileInfo::file_type_file); file.SetSize((unsigned long long)content->size); file.SetModified(t); file.SetMetaData("group", content->ownerDisplayName); file.SetMetaData("owner", content->ownerDisplayName); std::list<FileInfo>::iterator f = files->insert(files->end(), file); } return S3StatusOK; } S3Status DataPointS3::listServiceCallback(const char *ownerId, const char *ownerDisplayName, const char *bucketName, int64_t creationDate, void *callbackData) { std::list<FileInfo> *files = (std::list<FileInfo> *)callbackData; FileInfo file = FileInfo(bucketName); file.SetType(FileInfo::file_type_dir); file.SetMetaData("group", ownerDisplayName); file.SetMetaData("owner", ownerDisplayName); file.SetModified(creationDate); std::list<FileInfo>::iterator f = files->insert(files->end(), file); return S3StatusOK; } DataStatus DataPointS3::List(std::list<FileInfo> &files, DataPointInfoType verb) { if (!bucket_name.empty() && !key_name.empty()) { FileInfo file(key_name); S3BucketContext bucketContext = { 0, bucket_name.c_str(), protocol, uri_style, access_key.c_str(), secret_key.c_str(), #if defined(S3_DEFAULT_REGION) NULL, auth_region.c_str() }; #else 0 }; #endif S3ResponseHandler responseHandler = { &headResponsePropertiesCallback, &responseCompleteCallback }; #if defined(S3_TIMEOUTMS) S3_head_object(&bucketContext, key_name.c_str(), NULL, S3_TIMEOUTMS, &responseHandler, #else S3_head_object(&bucketContext, key_name.c_str(), NULL, &responseHandler, #endif &file); if (request_status == S3StatusOK) { std::list<FileInfo>::iterator f = files.insert(files.end(), file); return DataStatus::Success; } return DataStatus(DataStatus::StatError, S3_get_status_name(request_status)); } else if (!bucket_name.empty()) { S3BucketContext bucketContext = { 0, bucket_name.c_str(), protocol, uri_style, access_key.c_str(), secret_key.c_str(), #if defined(S3_DEFAULT_REGION) NULL, auth_region.c_str() }; #else 0 }; #endif S3ListBucketHandler listBucketHandler = { { &responsePropertiesCallback, &responseCompleteCallback }, &listBucketCallback }; S3_list_bucket(&bucketContext, NULL, NULL, NULL, 0, NULL, #if defined(S3_TIMEOUTMS) S3_TIMEOUTMS, #endif &listBucketHandler, &files); } else { S3ListServiceHandler listServiceHandler = { { &responsePropertiesCallback, &responseCompleteCallback }, &listServiceCallback }; S3_list_service(S3ProtocolHTTP, access_key.c_str(), secret_key.c_str(), 0, #if defined(S3_DEFAULT_REGION) NULL, auth_region.c_str(), NULL, #if defined(S3_TIMEOUTMS) S3_TIMEOUTMS, #endif &listServiceHandler, &files); #else 0, 0, &listServiceHandler, &files); #endif } if (request_status == S3StatusOK) { return DataStatus::Success; } logger.msg(ERROR, "Failed to read object %s: %s", url.Path(), S3_get_status_name(request_status)); return DataStatus(DataStatus::ListError, S3_get_status_name(request_status)); } DataStatus DataPointS3::Remove() { if (key_name.empty()) { S3ResponseHandler responseHandler = { &responsePropertiesCallback, &responseCompleteCallback }; S3_delete_bucket(S3ProtocolHTTP, S3UriStylePath, access_key.c_str(), #if defined(S3_DEFAULT_REGION) secret_key.c_str(), 0, 0, bucket_name.c_str(), auth_region.c_str(), NULL, #else secret_key.c_str(), 0, 0, bucket_name.c_str(), 0, #endif #if defined(S3_TIMEOUTMS) S3_TIMEOUTMS, #endif &responseHandler, 0); } else { S3BucketContext bucketContext = { 0, bucket_name.c_str(), protocol, uri_style, access_key.c_str(), secret_key.c_str(), #if defined(S3_DEFAULT_REGION) NULL, auth_region.c_str() }; #else 0 }; #endif S3ResponseHandler responseHandler = { 0, &responseCompleteCallback }; #if defined(S3_TIMEOUTMS) S3_delete_object(&bucketContext, key_name.c_str(), NULL, S3_TIMEOUTMS, &responseHandler, 0); #else S3_delete_object(&bucketContext, key_name.c_str(), 0, &responseHandler, 0); #endif } if (request_status == S3StatusOK) { return DataStatus::Success; } return DataStatus(DataStatus::DeleteError, EINVAL, S3_get_status_name(request_status)); } DataStatus DataPointS3::Rename(const URL &newurl) { return DataStatus(DataStatus::RenameError, ENOTSUP, "Renaming in S3 is not supported"); } DataStatus DataPointS3::CreateDirectory(bool with_parents) { if (!key_name.empty()) { return DataStatus(DataStatus::CreateDirectoryError, EINVAL, "key should not be given"); } S3ResponseHandler responseHandler = { &responsePropertiesCallback, &responseCompleteCallback }; S3CannedAcl cannedAcl = S3CannedAclPrivate; S3_create_bucket(S3ProtocolHTTP, access_key.c_str(), secret_key.c_str(), 0, 0, #if defined(S3_DEFAULT_REGION) bucket_name.c_str(), auth_region.c_str(), cannedAcl, 0, 0, #if defined(S3_TIMEOUTMS) S3_TIMEOUTMS, #endif &responseHandler, 0); #else bucket_name.c_str(), cannedAcl, 0, 0, &responseHandler, 0); #endif if (request_status == S3StatusOK) { return DataStatus::Success; } return DataStatus(DataStatus::CreateDirectoryError, EINVAL, S3_get_status_name(request_status)); } void DataPointS3::read_file_start(void *arg) { ((DataPointS3 *)arg)->read_file(); } void DataPointS3::read_file() { S3GetObjectHandler getObjectHandler = { { &responsePropertiesCallback, &DataPointS3::getCompleteCallback }, &DataPointS3::getObjectDataCallback }; S3BucketContext bucketContext = { 0, bucket_name.c_str(), protocol, uri_style, access_key.c_str(), secret_key.c_str(), #if defined(S3_DEFAULT_REGION) 0, auth_region.c_str() }; #else 0 }; #endif uint64_t startByte = 0, byteCount = 0; S3_get_object(&bucketContext, key_name.c_str(), 0, startByte, byteCount, 0, #if defined(S3_TIMEOUTMS) S3_TIMEOUTMS, #endif &getObjectHandler, buffer); if (request_status != S3StatusOK) { logger.msg(ERROR, "Failed to read object %s: %s", url.Path(), S3_get_status_name(request_status)); buffer->error_read(true); } } DataStatus DataPointS3::StartReading(DataBuffer &buf) { if (reading) return DataStatus::IsReadingError; if (writing) return DataStatus::IsWritingError; reading = true; buffer = &buf; // create thread to maintain reading if (!CreateThreadFunction(&DataPointS3::read_file_start, this, &transfers_started)) { reading = false; buffer = NULL; return DataStatus::ReadStartError; } return DataStatus::Success; } DataStatus DataPointS3::StopReading() { transfers_started.wait(); return DataStatus::Success; } void DataPointS3::write_file_start(void *arg) { ((DataPointS3 *)arg)->write_file(); } void DataPointS3::write_file() { S3BucketContext bucketContext = { 0, bucket_name.c_str(), protocol, uri_style, access_key.c_str(), secret_key.c_str(), #if defined(S3_AUTH_REGION) 0, auth_region.c_str() }; #else 0 }; #endif S3PutObjectHandler putObjectHandler = { { &responsePropertiesCallback, &putCompleteCallback }, &putObjectDataCallback }; const char *cacheControl = 0, *contentType = 0, *md5 = 0; const char *contentDispositionFilename = 0, *contentEncoding = 0; int64_t expires = -1; S3CannedAcl cannedAcl = S3CannedAclPrivate; int metaPropertiesCount = 0; S3NameValue metaProperties[S3_MAX_METADATA_COUNT]; char useServerSideEncryption = 0; S3PutProperties putProperties = { contentType, md5, cacheControl, contentDispositionFilename, contentEncoding, expires, cannedAcl, metaPropertiesCount, metaProperties, useServerSideEncryption }; S3_put_object(&bucketContext, key_name.c_str(), size, &putProperties, NULL, #if defined(S3_TIMEOUTMS) S3_TIMEOUTMS, #endif &putObjectHandler, buffer); if (request_status != S3StatusOK) { logger.msg(ERROR, "Failed to write object %s: %s", url.Path(), S3_get_status_name(request_status)); buffer->error_write(true); } } DataStatus DataPointS3::StartWriting(DataBuffer &buf, DataCallback *space_cb) { if (reading) return DataStatus::IsReadingError; if (writing) return DataStatus::IsWritingError; writing = true; /* Check if size for source is defined */ if (!CheckSize()) { return DataStatus(DataStatus::WriteStartError, "Size of the source file missing. S3 needs to know it."); } /* try to open */ buffer = &buf; buffer->set(NULL, 16384, 3); buffer->speed.reset(); buffer->speed.hold(false); /* create thread to maintain writing */ if (!CreateThreadFunction(&DataPointS3::write_file_start, this, &transfers_started)) { buffer->error_write(true); buffer->eof_write(true); writing = false; return DataStatus(DataStatus::WriteStartError, "Failed to create new thread"); } return DataStatus::Success; } DataStatus DataPointS3::StopWriting() { writing = false; transfers_started.wait(); /* wait till writing thread exited */ buffer = NULL; return DataStatus::Success; } bool DataPointS3::WriteOutOfOrder() { return false; } } // namespace Arc extern Arc::PluginDescriptor const ARC_PLUGINS_TABLE_NAME[] = { { "s3", "HED:DMC", "Amazon S3 Store", 0, &ArcDMCS3::DataPointS3::Instance }, { NULL, NULL, NULL, 0, NULL } };
; A153056: a(0)=2, a(n) = n^2+a(n-1). ; 2,3,7,16,32,57,93,142,206,287,387,508,652,821,1017,1242,1498,1787,2111,2472,2872,3313,3797,4326,4902,5527,6203,6932,7716,8557,9457,10418,11442,12531,13687,14912,16208,17577,19021,20542,22142,23823,25587,27436,29372,31397,33513,35722,38026,40427,42927,45528,48232,51041,53957,56982,60118,63367,66731,70212,73812,77533,81377,85346,89442,93667,98023,102512,107136,111897,116797,121838,127022,132351,137827,143452,149228,155157,161241,167482,173882,180443,187167,194056,201112,208337,215733,223302 mul $0,-2 bin $0,3 sub $1,$0 div $1,4 add $1,2 mov $0,$1
; A288134: Positions of 1 in A288132; complement of A288133. ; 3,5,6,8,9,10,11,13,14,15,16,17,18,19,20,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259 add $0,1 mov $1,$0 log $1,2 add $1,$0 add $1,2
; A008589: Multiples of 7. ; 0,7,14,21,28,35,42,49,56,63,70,77,84,91,98,105,112,119,126,133,140,147,154,161,168,175,182,189,196,203,210,217,224,231,238,245,252,259,266,273,280,287,294,301,308,315,322,329,336,343,350,357,364,371,378,385,392,399,406,413,420,427,434,441,448,455,462,469,476,483,490,497,504,511,518,525,532,539,546,553,560,567,574,581,588,595,602,609,616,623,630,637,644,651,658,665,672,679,686,693,700,707,714,721,728,735,742,749,756,763,770,777,784,791,798,805,812,819,826,833,840,847,854,861,868,875,882,889,896,903,910,917,924,931,938,945,952,959,966,973,980,987,994,1001,1008,1015,1022,1029,1036,1043,1050,1057,1064,1071,1078,1085,1092,1099,1106,1113,1120,1127,1134,1141,1148,1155,1162,1169,1176,1183,1190,1197,1204,1211,1218,1225,1232,1239,1246,1253,1260,1267,1274,1281,1288,1295,1302,1309,1316,1323,1330,1337,1344,1351,1358,1365,1372,1379,1386,1393,1400 mov $1,$0 mul $1,7
#include "leveldb/db.h" #include "leveldb/write_batch.h" #include <cassert> #include <iostream> int main() { leveldb::DB * pDb; leveldb::Options tOptions; { tOptions.create_if_missing = true; } leveldb::Status tStatus = leveldb::DB::Open(tOptions, "testdb", &pDb); assert(tStatus.ok()); std::string const & strKey1 = "TestKey1"; std::string const & strKey2 = "TestKey2"; leveldb::WriteBatch oWriteBatch; { oWriteBatch.Put(strKey1, "TestValue1"); oWriteBatch.Put(strKey2, "TestValue2"); } tStatus = pDb->Write(leveldb::WriteOptions(), &oWriteBatch); std::string strValue1, strValue2; tStatus = pDb->Get(leveldb::ReadOptions(), strKey1, &strValue1); tStatus = pDb->Get(leveldb::ReadOptions(), strKey2, &strValue2); // iterator all key leveldb::Iterator* it = pDb->NewIterator(leveldb::ReadOptions()); for (it->SeekToFirst(); it->Valid(); it->Next()) { std::cout << it->key().ToString() << ": " << it->value().ToString() << std::endl; } assert(it->status().ok()); // Check for any errors found during the scan delete it; delete pDb; return 0; }
; A051871: 19-gonal (or enneadecagonal) numbers: n(17n-15)/2. ; 0,1,19,54,106,175,261,364,484,621,775,946,1134,1339,1561,1800,2056,2329,2619,2926,3250,3591,3949,4324,4716,5125,5551,5994,6454,6931,7425,7936,8464,9009,9571,10150,10746,11359,11989,12636,13300,13981,14679,15394,16126,16875,17641,18424,19224,20041,20875,21726,22594,23479,24381,25300,26236,27189,28159,29146,30150,31171,32209,33264,34336,35425,36531,37654,38794,39951,41125,42316,43524,44749,45991,47250,48526,49819,51129,52456,53800,55161,56539,57934,59346,60775,62221,63684,65164,66661,68175,69706,71254,72819,74401,76000,77616,79249,80899,82566,84250,85951,87669,89404,91156,92925,94711,96514,98334,100171,102025,103896,105784,107689,109611,111550,113506,115479,117469,119476,121500,123541,125599,127674,129766,131875,134001,136144,138304,140481,142675,144886,147114,149359,151621,153900,156196,158509,160839,163186,165550,167931,170329,172744,175176,177625,180091,182574,185074,187591,190125,192676,195244,197829,200431,203050,205686,208339,211009,213696,216400,219121,221859,224614,227386,230175,232981,235804,238644,241501,244375,247266,250174,253099,256041,259000,261976,264969,267979,271006,274050,277111,280189,283284,286396,289525,292671,295834,299014,302211,305425,308656,311904,315169,318451,321750,325066,328399,331749,335116,338500,341901,345319,348754,352206,355675,359161,362664,366184,369721,373275,376846,380434,384039,387661,391300,394956,398629,402319,406026,409750,413491,417249,421024,424816,428625,432451,436294,440154,444031,447925,451836,455764,459709,463671,467650,471646,475659,479689,483736,487800,491881,495979,500094,504226,508375,512541,516724,520924,525141 mov $1,$0 bin $0,2 mul $0,17 add $1,$0
; Performance for copying 0 into a 100000 bytes buffer for all the versions (lower is better) : ; 386 : 252241/73458 = 3.43 ; SSE : 254930/74463 = 3.43 ; SSE2 : 80673/75956 = 1.06 ; SSSE3 : 79104/78349 = 1.01 ; AVX : 76435/75405 = 1.01 ; AVX2 : 53782/75036 = 0.72 global @ASM_memset@12 extern _getInstructionSet segment .data align=16 actualASM_memsetPtr dd actualASM_memsetGetPtr segment .text align=16 %define buffer ecx %define character edx %define loCharacter dl %define result eax %define size 4 %define regSize esi actualASM_memset386: push ebp push edi push regSize push ebx sub esp, 12 mov result, buffer mov regSize, dword [esp + 28 + size] test regSize, regSize je .return mov ebx, result lea edi, [regSize - 1] neg ebx and ebx, 3 mov cl, loCharacter mov dword [esp], ebx cmp edi, 7 jbe .lessThan8Bytes test ebx, ebx je .noAlign lea ebp, [result + 1] mov byte [result], loCharacter lea edi, [regSize - 2] cmp ebx, 1 je .endAlign lea ebp, [result + 2] mov byte [result + 1], loCharacter lea edi, [regSize - 3] cmp ebx, 3 jne .endAlign lea ebp, [result + 3] mov byte [result + 2], loCharacter lea edi, [regSize - 4] .endAlign: mov ebx, dword [esp] sub esi, ebx xor ebx, ebx mov bl, cl mov dword [esp + 4], esi movzx ecx, loCharacter mov esi, ecx mov bh, dl sal esi, 16 sal ecx, 24 mov dword [esp + 8], esi movzx esi, bx mov ebx, dword [esp + 8] or esi, ebx mov ebx, dword [esp] or ecx, esi mov esi, dword [esp + 4] add ebx, result and esi, -4 add esi, ebx .dwordLoop: mov dword [ebx], ecx add ebx, 4 cmp ebx, esi jne .dwordLoop mov esi, dword [esp + 4] mov ebx, esi and ebx, -4 sub edi, ebx cmp esi, ebx lea ecx, [ebp + ebx] je .return .doTrailingBytes: mov byte [ecx], loCharacter test edi, edi je .return %macro doTrailingByte386 1 mov byte [ecx + %1], loCharacter cmp edi, %1 je .return %endmacro doTrailingByte386 1 doTrailingByte386 2 doTrailingByte386 3 doTrailingByte386 4 doTrailingByte386 5 doTrailingByte386 6 mov byte [ecx + 7], loCharacter .return: add esp, 12 pop ebx pop regSize pop edi pop ebp ret 4 .noAlign: mov ebp, result jmp .endAlign .lessThan8Bytes: mov ecx, result jmp .doTrailingBytes align 16 %define regSize esi actualASM_memsetSSE: push ebp push edi push esi push ebx sub esp, 44 mov result, buffer mov regSize, dword [esp + 60 + size] lea ecx, [regSize - 1] test regSize, regSize mov dword [esp + 4], ecx je .return mov byte [esp + 15], loCharacter mov ebx, result mov ebp, 23 neg ebx and ebx, 15 lea edi, [ebx + 15] cmp edi, 23 cmovb edi, ebp cmp ecx, edi jb .lessThan16Bytes test ebx, ebx je .noAlign %macro do1ByteAlignSSE 1 mov byte [result + %1 - 1], loCharacter lea edi, [result + %1] cmp ebx, %1 mov dword [esp + 8], edi lea edi, [regSize - %1 - 1] mov dword [esp + 4], edi je .endAlign %endmacro do1ByteAlignSSE 1 do1ByteAlignSSE 2 do1ByteAlignSSE 3 do1ByteAlignSSE 4 do1ByteAlignSSE 5 do1ByteAlignSSE 6 do1ByteAlignSSE 7 do1ByteAlignSSE 8 %macro do1ByteAlign2SSE 1 lea edi, [result + %1] cmp ebx, %1 mov dword [esp + 8], edi lea ecx, [regSize - %1 - 1] mov byte [result + %1 - 1], loCharacter mov dword [esp + 4], ecx je .endAlign %endmacro do1ByteAlign2SSE 9 do1ByteAlign2SSE 10 do1ByteAlign2SSE 11 do1ByteAlign2SSE 12 do1ByteAlign2SSE 13 lea edi, [result + 14] cmp ebx, 15 mov dword [esp + 8], edi lea ecx, [regSize - 15] mov byte [result + 13], loCharacter mov dword [esp + 4], ecx jne .endAlign mov byte [result + 14], loCharacter lea edi, [result + 15] mov dword [esp + 8], edi lea ecx, [regSize - 16] mov dword [esp + 4], ecx .endAlign: movzx ebp, byte [esp + 15] sub esi, ebx mov dword [esp + 24], esi mov ecx, ebp mov edi, ebp sal edi, 16 mov ch, loCharacter mov dword [esp + 16], edi mov esi, ecx mov ecx, ebp sal ecx, 24 or esi, edi mov edi, dword [esp + 16] mov dword [esp + 20], ecx or esi, ecx mov ecx, ebp mov dword [esp + 28], esi mov ch, loCharacter mov esi, dword [esp + 16] or edi, ecx mov ecx, dword [esp + 20] or edi, ecx mov ecx, ebp mov ch, loCharacter or esi, ecx mov ecx, dword [esp + 20] or esi, ecx mov ecx, ebp mov ebp, dword [esp + 16] mov ch, loCharacter mov edx, dword [esp + 20] or ebp, ecx mov ecx, dword [esp + 28] or ebp, edx lea edx, [result + ebx] mov ebx, dword [esp + 24] and ebx, -16 add ebx, edx align 16 .dwordLoop: mov dword [edx], ecx add edx, 16 mov dword [edx - 12], edi mov dword [edx - 8], esi mov dword [edx - 4], ebp cmp edx, ebx jne .dwordLoop mov edi, dword [esp + 24] mov edx, dword [esp + 8] mov ebx, edi and ebx, -16 sub dword [esp + 4], ebx add edx, ebx cmp edi, ebx je .return .doTrailingBytes: mov edi, dword [esp + 4] movzx ecx, byte [esp + 15] lea ebx, [edx + edi + 1] .doTrailingBytesLoop: mov byte [edx], cl inc edx cmp edx, ebx jne .doTrailingBytesLoop .return: add esp, 44 pop ebx pop esi pop edi pop ebp ret 4 .lessThan16Bytes: mov edx, result jmp .doTrailingBytes .noAlign: mov dword [esp + 8], result jmp .endAlign align 16 %define regSize ecx actualASM_memsetSSE2: push ebp push edi push esi push ebx sub esp, 28 mov result, buffer mov regSize, dword [esp + 44 + size] test regSize, regSize je .return lea esi, [regSize - 1] mov byte [esp + 15], loCharacter mov ebx, result neg ebx and ebx, 15 lea ebp, [ebx + 15] cmp ebp, 23 mov edi, 23 cmovb ebp, edi cmp esi, ebp jb .lessThan16Bytes test ebx, ebx je .skipAlign %macro do1ByteAlignSSE2 1 lea ebp, [result + %1] mov byte [result + %1 - 1], loCharacter lea esi, [regSize - %1 - 1] cmp ebx, %1 je .endAlign %endmacro do1ByteAlignSSE2 1 do1ByteAlignSSE2 2 do1ByteAlignSSE2 3 do1ByteAlignSSE2 4 do1ByteAlignSSE2 5 do1ByteAlignSSE2 6 do1ByteAlignSSE2 7 do1ByteAlignSSE2 8 do1ByteAlignSSE2 9 do1ByteAlignSSE2 10 do1ByteAlignSSE2 11 do1ByteAlignSSE2 12 do1ByteAlignSSE2 13 lea ebp, [result + 14] mov byte [result + 13], loCharacter lea esi, [regSize - 15] cmp ebx, 15 jne .endAlign lea ebp, [result + 15] mov byte [result + 14], loCharacter lea esi, [regSize - 16] .endAlign: sub ecx, ebx movd xmm0, character punpcklbw xmm0, xmm0 punpcklwd xmm0, xmm0 pshufd xmm0, xmm0, 0 add ebx, result mov edx, ecx and edx, -16 add edx, ebx movzx edi, byte [esp + 15] .xmmLoop: movdqa oword [ebx], xmm0 add ebx, 16 cmp ebx, edx jne .xmmLoop mov ebx, edi mov byte [esp + 15], bl mov edx, ecx and edx, -16 add ebp, edx sub esi, edx cmp ecx, edx je .return .doTrailingBytes: inc esi add esi, ebp movzx edx, byte [esp + 15] .doTrailingBytesLoop: mov byte [ebp], dl inc ebp cmp ebp, esi jne .doTrailingBytesLoop .return: add esp, 28 pop ebx pop esi pop edi pop ebp ret 4 .lessThan16Bytes: mov ebp, result jmp .doTrailingBytes .skipAlign: mov ebp, result jmp .endAlign align 16 %define regSize ecx actualASM_memsetSSSE3: push edi push esi push ebx mov result, buffer mov regSize, dword [esp + 12 + size] test regSize, regSize je .return lea esi, [regSize - 1] cmp esi, 14 jbe .lessThan16Bytes mov edi, regSize movd xmm0, character mov ebx, result pxor xmm1, xmm1 and edi, -16 pshufb xmm0, xmm1 add edi, result .xmmLoop: movups oword [ebx], xmm0 add ebx, 16 cmp ebx, edi jne .xmmLoop mov edi, buffer and edi, -16 lea ebx, [result + edi] sub esi, edi cmp buffer, edi je .return .doTrailingBytes: mov byte [ebx], loCharacter test esi, esi je .return %macro doTrailingByteSSSE3 1 mov byte [ebx + %1], loCharacter cmp esi, %1 je .return %endmacro doTrailingByteSSSE3 1 doTrailingByteSSSE3 2 doTrailingByteSSSE3 3 doTrailingByteSSSE3 4 doTrailingByteSSSE3 5 doTrailingByteSSSE3 6 doTrailingByteSSSE3 7 doTrailingByteSSSE3 8 doTrailingByteSSSE3 9 doTrailingByteSSSE3 10 doTrailingByteSSSE3 11 doTrailingByteSSSE3 12 doTrailingByteSSSE3 13 mov byte [ebx + 14], loCharacter .return: pop ebx pop esi pop edi ret 4 .lessThan16Bytes: mov ebx, result jmp .doTrailingBytes align 16 %define regSize esi actualASM_memsetAVX: push ebp mov ebp, esp push edi push regSize push ebx mov result, buffer mov regSize, dword [ebp + 4 + size] test regSize, regSize je .return lea ecx, [regSize - 1] mov ebx, character cmp ecx, 30 jbe .lessThan32Bytes mov edi, regSize vmovd xmm0, character mov edx, result vpxor xmm1, xmm1, xmm1 and edi, -32 vpshufb xmm0, xmm0, xmm1 vinsertf128 ymm0, ymm0, xmm0, 1 add edi, result .avxLoop: vmovups oword [edx], xmm0 vextractf128 oword [edx + 16], ymm0, 1 add edx, 32 cmp edx, edi jne .avxLoop mov edi, esi and edi, -32 lea edx, [result + edi] sub ecx, edi cmp esi, edi je .avxReturn vzeroupper .doTrailingBytes: lea ecx, [edx + ecx + 1] .trailingBytesLoop: mov byte [edx], bl inc edx cmp edx, ecx jne .trailingBytesLoop .return: pop ebx pop esi pop edi pop ebp ret 4 .lessThan32Bytes: mov edx, result jmp .doTrailingBytes .avxReturn: vzeroupper jmp .return align 16 %define regSize ecx actualASM_memsetAVX2: push ebp mov ebp, esp push edi push esi push ebx mov result, buffer mov regSize, dword [ebp + 4 + size] test regSize, regSize je .return lea esi, [regSize - 1] cmp esi, 30 jbe .lessThan32Bytes vmovd xmm0, character vpbroadcastb ymm0, xmm0 mov ebx, result mov edi, regSize and edi, -32 add edi, result .avxLoop: vmovdqu yword [ebx], ymm0 add ebx, 32 cmp ebx, edi jne .avxLoop mov edi, ecx and edi, -32 lea ebx, [result + edi] sub esi, edi cmp ecx, edi je .avxReturn vzeroupper .doTrailingBytes: lea esi, [ebx + esi + 1] .trailingBytesLoop: mov byte [ebx], loCharacter inc ebx cmp ebx, esi jne .trailingBytesLoop .return: pop ebx pop esi pop edi pop ebp ret 4 .lessThan32Bytes: mov ebx, result jmp .doTrailingBytes .avxReturn: vzeroupper jmp .return align 16 %define SSESupported 3 %define SSE2Supported 4 %define SSSE3Supported 6 %define AVXSupported 11 %define AVX2Supported 13 @ASM_memset@12: jmp dword [actualASM_memsetPtr] align 16 actualASM_memsetGetPtr: push ebx sub esp, 24 mov dword [esp + 12], buffer mov dword [esp + 8], character mov ebx, [esp + 28 + size] call _getInstructionSet cmp eax, SSESupported - 1 mov character, dword [esp + 8] mov buffer, dword [esp + 12] jg .not386 mov dword [actualASM_memsetPtr], actualASM_memset386 jmp .doJmp .not386: cmp eax, SSE2Supported - 1 jne .notSSE mov dword [actualASM_memsetPtr], actualASM_memsetSSE jmp .doJmp .notSSE: cmp eax, SSSE3Supported - 1 jg .notSSE2 mov dword [actualASM_memsetPtr], actualASM_memsetSSE2 jmp .doJmp .notSSE2: cmp eax, AVXSupported - 1 jg .notSSSE3 mov dword [actualASM_memsetPtr], actualASM_memsetSSSE3 jmp .doJmp .notSSSE3: cmp eax, AVX2Supported - 1 jg .notAVX mov dword [actualASM_memsetPtr], actualASM_memsetAVX jmp .doJmp .notAVX: mov dword [actualASM_memsetPtr], actualASM_memsetAVX2 .doJmp: mov dword [esp + 28 + size], ebx add esp, 24 pop ebx jmp dword [actualASM_memsetPtr]
# Exception Handler # Interrupt: Excode = 0 # Overflow: ExCode = 12 # Status $12 # Cause $13 # EPC $14 .kdata 0x90000000 # Espa�o para salvamento de contexto: save: .word 0,0,0,0 # Espa�o para salvamento do valor que est� sendo digitado: _temp: .word 0 .ktext 0x80000180 # Reloca o tratador para residir no endere�o emitido pelo HW # Etapa 1: Salvamento de contexto em mem�ria (pilha n�o pode ser usada) lui $k0,0x9000 sw $ra,0($k0) sw $at,4($k0) sw $t0,8($k0) sw $t1,12($k0) # Etapa 2: Decodifica��o do registrador Cause # Completar: Isole o ExcCode do registrador Cause para identificar a exce��o (armazenar em $k0) --- mfc0 $k0, $13 srl $k0, $k0, 2 andi $k0, $k0 0x1F # ------------------------------------------------------------------------------------------------- # Etapa 3: Leitura de caracteres em caso de interrup��o # Completar: Se o c�digo for o de uma interrup��o, chame o precedimento "lechar" e pule ---- # para "done". Sen�o, pule para "_continua". ------------------------------------ bnez $k0, _continua jal lechar j done # ------------------------------------------------------------------------------------------ # Etapa 4: Tratamento de overflow, se for o caso # Completar: Se o c�digo for de overflow, o tratador deve, ao final de sua execu��o, ------- # reiniciar o programa. Fa�o o teste apropriado e mude o registrador necess�rio - # para que o programa seja reiniciado apenas ao final do tratamento da exce��o.-- _continua: addi $t1, $zero, 12 bne $k0, $t1, done #li $k0,0x49 #lui $k1,0xffff #sw $k0,12($k1) # - Imprime algo no display la $t0, main mtc0 $t0, $14 # ------------------------------------------------------------------------------------------ # Etapa 5: Preparacao do sistema para novas excecoes # Completar: Limpe o registrador Cause e habilite novas exce��es no registrador Status ----- done: mtc0 $zero, $13 mfc0 $k1, $12 ori $k1, $k1, 1 mtc0 $k1, $12 # ------------------------------------------------------------------------------------------ # Etapa 6: Restauracao de contexto lui $k0,0x9000 lw $ra,0($k0) lw $at,4($k0) lw $t0,8($k0) lw $t1,12($k0) # Etapa 7: Retorno ao fluxo normal de execucao eret # retorna para o endere�o indicado em EPC # Fun��o para leitura do caractere lechar: lui $k0,0xffff lw $k0,4($k0) # - L� o valor digitado no teclado da mem�ria li $k1,0x0A bne $k0,$k1,cont1 la $t0,_temp # - Se o valor for ENTER (ASCII 0xA), grava o valor previamente lw $k1,0($t0) # digitado na posi��o "argumento" de mem�ria. sw $zero,0($t0) la $t0,argumento sw $k1,0($t0) j fim1 cont1: addi $k0,$k0,-0x30 # Subtrai 0x30, convertendo ASCII para inteiro # Marca 1 sltiu $k1,$k0,10 beq $k1,$zero,erro1 la $k1,_temp # - Se o valor for num�rico (de 0 a 9), l� o valor armazenado em lw $t0,0($k1) # "_temp", multiplica por 10, e soma ao valor digitado. li $t1,10 # Isso � feito para "construir" o n�mero a partir dos valores digitados. mul $t0,$t0,$t1 add $t0,$t0,$k0 sw $t0,0($k1) # Marca 2 addi $k0,$k0,0x30 j fim1 erro1: la $k1,_temp # - Em caso de erro (digita��o de letras por exemplo) prepara "e" sw $zero,0($k1) # para ser impresso no display. li $k0,0x65 fim1: lui $k1,0xffff sw $k0,12($k1) # - Imprime algo no display e retorna jr $ra
SECTION code_clib SECTION code_fp_am9511 PUBLIC cam32_sdcc___mulsint2slong EXTERN asm_am9511_imul cam32_sdcc___mulsint2slong: ; 16-bit multiplication, 32-bit result ; ; enter : stack = multiplicand, multiplicand, ret ; ; exit : dehl = product pop af pop hl pop de push de push hl push af jp asm_am9511_imul ; product in dehl
/* * (C) 2016 Daniel Neus * (C) 2016 Philipp Weber * * Botan is released under the Simplified BSD License (see license.txt) */ #include "tests.h" #include "test_pkcs11.h" #include <string> #include <vector> #include <functional> #include <memory> #include <array> #include <map> #if defined(BOTAN_HAS_PKCS11) #include <botan/p11.h> #endif #if defined(BOTAN_HAS_DYNAMIC_LOADER) #include <botan/dyn_load.h> #endif namespace Botan_Tests { namespace { #if defined(BOTAN_HAS_PKCS11) #if defined(BOTAN_HAS_DYNAMIC_LOADER) using namespace Botan; using namespace PKCS11; class RAII_LowLevel { public: RAII_LowLevel() : m_module(Test::pkcs11_lib()), m_func_list(nullptr), m_low_level(), m_session_handle(0), m_is_session_open(false), m_is_logged_in(false) { LowLevel::C_GetFunctionList(m_module, &m_func_list); m_low_level.reset(new LowLevel(m_func_list)); C_InitializeArgs init_args = { nullptr, nullptr, nullptr, nullptr, static_cast<CK_FLAGS>(Flag::OsLockingOk), nullptr }; m_low_level->C_Initialize(&init_args); } ~RAII_LowLevel() noexcept { try { if(m_is_session_open) { if(m_is_logged_in) { m_low_level.get()->C_Logout(m_session_handle, nullptr); } m_low_level.get()->C_CloseSession(m_session_handle, nullptr); } m_low_level.get()->C_Finalize(nullptr, nullptr); } catch(...) { // ignore errors here } } std::vector<SlotId> get_slots(bool token_present) const { std::vector<SlotId> slots; m_low_level.get()->C_GetSlotList(token_present, slots); if(slots.empty()) { throw Exception("No slot with attached token found"); } return slots; } inline SessionHandle open_session(Flags session_flags) { std::vector<SlotId> slots = get_slots(true); m_low_level.get()->C_OpenSession(slots.at(0), session_flags, nullptr, nullptr, &m_session_handle); m_is_session_open = true; return m_session_handle; } inline SessionHandle open_rw_session_with_user_login() { Flags session_flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); SessionHandle handle = open_session(session_flags); login(UserType::User, PIN_SECVEC); return handle; } inline SessionHandle get_session_handle() const { if(!m_is_session_open) { throw Exception("no open session"); } return m_session_handle; } inline void close_session() { if(!m_is_session_open) { throw Exception("no open session"); } m_low_level.get()->C_CloseSession(m_session_handle); m_is_session_open = false; } inline void login(UserType user_type, const secure_vector<uint8_t>& pin) { if(!m_is_session_open) { throw Exception("no open session"); } if(m_is_logged_in) { throw Exception("Already logged in"); } m_low_level.get()->C_Login(m_session_handle, user_type, pin); m_is_logged_in = true; } inline void logout() { if(!m_is_logged_in) { throw Exception("Not logged in"); } m_low_level.get()->C_Logout(m_session_handle); m_is_logged_in = false; } LowLevel* get() const { return m_low_level.get(); } private: Dynamically_Loaded_Library m_module; FunctionListPtr m_func_list; std::unique_ptr<LowLevel> m_low_level; SessionHandle m_session_handle; bool m_is_session_open; bool m_is_logged_in; }; bool no_op(ReturnValue*) { return true; } using PKCS11_BoundTestFunction = std::function<bool(ReturnValue* return_value)>; // tests all 3 variants Test::Result test_function(const std::string& name, const PKCS11_BoundTestFunction& test_func, const std::string& revert_fn_name, const PKCS11_BoundTestFunction& revert_func, bool expect_failure, ReturnValue expected_return_value) { std::string test_name = revert_fn_name.empty() ? "PKCS 11 low level - " + name : "PKCS 11 low level - " + name + "/" + revert_fn_name; Test::Result result(test_name); // test throw variant if(expect_failure) { result.test_throws(name + " fails as expected", [ test_func ]() { test_func(ThrowException); }); } else { test_func(ThrowException); result.test_success(name + " did not throw and completed successfully"); if(!revert_fn_name.empty()) { revert_func(ThrowException); result.test_success(revert_fn_name + " did not throw and completed successfully"); } } // test bool return variant bool success = test_func(nullptr); result.test_eq(name, success, !expect_failure); if(success && !revert_fn_name.empty()) { success = revert_func(nullptr); result.test_eq(revert_fn_name, success, !expect_failure); } // test ReturnValue variant ReturnValue rv; success = test_func(&rv); result.test_eq(name, success, !expect_failure); if(!expect_failure) { result.test_rc_ok(name, static_cast< uint32_t >(rv)); } else { result.test_rc_fail(name, "return value should be: " + std::to_string(static_cast< uint32_t >(expected_return_value)), static_cast< uint32_t >(rv)); } if(success && !revert_fn_name.empty()) { success = revert_func(&rv); result.test_eq(revert_fn_name, success, !expect_failure); result.test_rc_ok(revert_fn_name, static_cast< uint32_t >(rv)); } return result; } Test::Result test_function(const std::string& name, const PKCS11_BoundTestFunction& test_func, bool expect_failure, ReturnValue expected_return_value) { return test_function(name, test_func, std::string(), no_op, expect_failure, expected_return_value); } Test::Result test_function(const std::string& name, const PKCS11_BoundTestFunction& test_func) { return test_function(name, test_func, std::string(), no_op, false, ReturnValue::OK); } Test::Result test_function(const std::string& name, const PKCS11_BoundTestFunction& test_func, const std::string& revert_fn_name, const PKCS11_BoundTestFunction& revert_func) { return test_function(name, test_func, revert_fn_name, revert_func, false, ReturnValue::OK); } Test::Result test_low_level_ctor() { Test::Result result("PKCS 11 low level - LowLevel ctor"); Dynamically_Loaded_Library pkcs11_module(Test::pkcs11_lib()); FunctionListPtr func_list(nullptr); LowLevel::C_GetFunctionList(pkcs11_module, &func_list); LowLevel p11_low_level(func_list); result.test_success("LowLevel ctor does complete for valid function list"); result.test_throws("LowLevel ctor fails for invalid function list pointer", []() { LowLevel p11_low_level2(nullptr); }); return result; } Test::Result test_c_get_function_list() { Dynamically_Loaded_Library pkcs11_module(Test::pkcs11_lib()); FunctionListPtr func_list = nullptr; return test_function("C_GetFunctionList", std::bind(&LowLevel::C_GetFunctionList, std::ref(pkcs11_module), &func_list, std::placeholders::_1)); } Test::Result test_initialize_finalize() { Dynamically_Loaded_Library pkcs11_module(Test::pkcs11_lib()); FunctionListPtr func_list = nullptr; LowLevel::C_GetFunctionList(pkcs11_module, &func_list); LowLevel p11_low_level(func_list); // setting Flag::OsLockingOk should be the normal use case C_InitializeArgs init_args = { nullptr, nullptr, nullptr, nullptr, static_cast<CK_FLAGS>(Flag::OsLockingOk), nullptr }; auto init_bind = std::bind(&LowLevel::C_Initialize, p11_low_level, &init_args, std::placeholders::_1); auto finalize_bind = std::bind(&LowLevel::C_Finalize, p11_low_level, nullptr, std::placeholders::_1); return test_function("C_Initialize", init_bind, "C_Finalize", finalize_bind); } Test::Result test_c_get_info() { RAII_LowLevel p11_low_level; Info info = {}; Test::Result result = test_function("C_GetInfo", std::bind(&LowLevel::C_GetInfo, *p11_low_level.get(), &info, std::placeholders::_1)); result.test_ne("C_GetInfo crypto major version", info.cryptokiVersion.major, 0); return result; } Test::Result test_c_get_slot_list() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec; // assumes at least one smartcard reader is attached bool token_present = false; auto binder = std::bind(static_cast< bool (LowLevel::*)(bool, std::vector<SlotId>&, ReturnValue*) const> (&LowLevel::C_GetSlotList), *p11_low_level.get(), std::ref(token_present), std::ref(slot_vec), std::placeholders::_1); Test::Result result = test_function("C_GetSlotList", binder); result.test_ne("C_GetSlotList number of slots without attached token > 0", slot_vec.size(), 0); // assumes at least one smartcard reader with connected smartcard is attached slot_vec.clear(); token_present = true; result.merge(test_function("C_GetSlotList", binder)); result.test_ne("C_GetSlotList number of slots with attached token > 0", slot_vec.size(), 0); return result; } Test::Result test_c_get_slot_info() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec = p11_low_level.get_slots(false); SlotInfo slot_info = {}; Test::Result result = test_function("C_GetSlotInfo", std::bind(&LowLevel::C_GetSlotInfo, *p11_low_level.get(), slot_vec.at(0), &slot_info, std::placeholders::_1)); std::string slot_desc(reinterpret_cast< char* >(slot_info.slotDescription)); result.test_ne("C_GetSlotInfo returns non empty description", slot_desc.size(), 0); return result; } Test::Result test_c_get_token_info() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec = p11_low_level.get_slots(true); TokenInfo token_info = {}; Test::Result result = test_function("C_GetTokenInfo", std::bind(&LowLevel::C_GetTokenInfo, *p11_low_level.get(), slot_vec.at(0), &token_info, std::placeholders::_1)); std::string serial(reinterpret_cast< char* >(token_info.serialNumber)); result.test_ne("C_GetTokenInfo returns non empty serial number", serial.size(), 0); return result; } Test::Result test_c_wait_for_slot_event() { RAII_LowLevel p11_low_level; Flags flags = PKCS11::flags(Flag::DontBlock); SlotId slot_id = 0; return test_function("C_WaitForSlotEvent", std::bind(&LowLevel::C_WaitForSlotEvent, *p11_low_level.get(), flags, &slot_id, nullptr, std::placeholders::_1), true, ReturnValue::NoEvent); } Test::Result test_c_get_mechanism_list() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec = p11_low_level.get_slots(true); std::vector<MechanismType> mechanisms; auto binder = std::bind(static_cast< bool (LowLevel::*)(SlotId, std::vector<MechanismType>&, ReturnValue*) const> (&LowLevel::C_GetMechanismList), *p11_low_level.get(), slot_vec.at(0), std::ref(mechanisms), std::placeholders::_1); Test::Result result = test_function("C_GetMechanismList", binder); result.confirm("C_GetMechanismList returns non empty mechanisms list", !mechanisms.empty()); return result; } Test::Result test_c_get_mechanism_info() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec = p11_low_level.get_slots(true); std::vector<MechanismType> mechanisms; p11_low_level.get()->C_GetMechanismList(slot_vec.at(0), mechanisms); MechanismInfo mechanism_info = {}; return test_function("C_GetMechanismInfo", std::bind(&LowLevel::C_GetMechanismInfo, *p11_low_level.get(), slot_vec.at(0), mechanisms.at(0), &mechanism_info, std::placeholders::_1)); } Test::Result test_c_init_token() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec = p11_low_level.get_slots(true); const std::string label = "Botan PKCS#11 tests"; auto sec_vec_binder = std::bind( static_cast< bool (LowLevel::*)(SlotId, const secure_vector<uint8_t>&, const std::string&, ReturnValue*) const> (&LowLevel::C_InitToken<secure_allocator<uint8_t>>), *p11_low_level.get(), slot_vec.at(0), std::ref(SO_PIN_SECVEC), std::ref(label), std::placeholders::_1); return test_function("C_InitToken", sec_vec_binder); } Test::Result test_open_close_session() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec = p11_low_level.get_slots(true); // public read only session Flags flags = PKCS11::flags(Flag::SerialSession); SessionHandle session_handle = 0; auto open_session_bind = std::bind(&LowLevel::C_OpenSession, *p11_low_level.get(), slot_vec.at(0), std::ref(flags), nullptr, nullptr, &session_handle, std::placeholders::_1); auto close_session_bind = std::bind(&LowLevel::C_CloseSession, *p11_low_level.get(), std::ref(session_handle), std::placeholders::_1); Test::Result result = test_function("C_OpenSession", open_session_bind, "C_CloseSession", close_session_bind); // public read write session flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); result.merge(test_function("C_OpenSession", open_session_bind, "C_CloseSession", close_session_bind)); return result; } Test::Result test_c_close_all_sessions() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec = p11_low_level.get_slots(true); auto open_two_sessions = [ &slot_vec, &p11_low_level ]() -> void { // public read only session Flags flags = PKCS11::flags(Flag::SerialSession); SessionHandle first_session_handle = 0, second_session_handle = 0; p11_low_level.get()->C_OpenSession(slot_vec.at(0), flags, nullptr, nullptr, &first_session_handle); flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); p11_low_level.get()->C_OpenSession(slot_vec.at(0), flags, nullptr, nullptr, &second_session_handle); }; open_two_sessions(); Test::Result result("PKCS 11 low level - C_CloseAllSessions"); // test throw variant p11_low_level.get()->C_CloseAllSessions(slot_vec.at(0)); result.test_success("C_CloseAllSessions does not throw"); // test bool return variant open_two_sessions(); bool success = p11_low_level.get()->C_CloseAllSessions(slot_vec.at(0), nullptr); result.test_eq("C_CloseAllSessions", success, true); // test ReturnValue variant open_two_sessions(); ReturnValue rv = static_cast< ReturnValue >(-1); success = p11_low_level.get()->C_CloseAllSessions(slot_vec.at(0), &rv); result.test_eq("C_CloseAllSessions", success, true); result.test_rc_ok("C_CloseAllSessions", static_cast< uint32_t >(rv)); return result; } Test::Result test_c_get_session_info() { RAII_LowLevel p11_low_level; std::vector<SlotId> slot_vec = p11_low_level.get_slots(true); // public read only session Flags flags = PKCS11::flags(Flag::SerialSession); SessionHandle session_handle = p11_low_level.open_session(flags); SessionInfo session_info = {}; Test::Result result = test_function("C_GetSessionInfo", std::bind(&LowLevel::C_GetSessionInfo, *p11_low_level.get(), session_handle, &session_info, std::placeholders::_1)); result.confirm("C_GetSessionInfo returns same slot id as during call to C_OpenSession", session_info.slotID == slot_vec.at(0)); result.confirm("C_GetSessionInfo returns same flags as during call to C_OpenSession", session_info.flags == flags); result.confirm("C_GetSessionInfo returns public read only session state", session_info.state == static_cast<CK_FLAGS>(SessionState::RoPublicSession)); return result; } Test::Result login_logout_helper(const RAII_LowLevel& p11_low_level, SessionHandle handle, UserType user_type, const std::string& pin) { secure_vector<uint8_t> pin_as_sec_vec(pin.begin(), pin.end()); auto login_secvec_binder = std::bind(static_cast< bool (LowLevel::*)(SessionHandle, UserType, const secure_vector<uint8_t>&, ReturnValue*) const> (&LowLevel::C_Login<secure_allocator<uint8_t>>), *p11_low_level.get(), handle, user_type, std::ref(pin_as_sec_vec), std::placeholders::_1); auto logout_binder = std::bind(static_cast< bool (LowLevel::*)(SessionHandle, ReturnValue*) const> (&LowLevel::C_Logout), *p11_low_level.get(), handle, std::placeholders::_1); return test_function("C_Login", login_secvec_binder, "C_Logout", logout_binder); } Test::Result test_c_login_logout_security_officier() { RAII_LowLevel p11_low_level; // can only login to R/W session Flags session_flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); SessionHandle session_handle = p11_low_level.open_session(session_flags); return login_logout_helper(p11_low_level, session_handle, UserType::SO, SO_PIN); } Test::Result test_c_login_logout_user() { RAII_LowLevel p11_low_level; // R/O session Flags session_flags = PKCS11::flags(Flag::SerialSession); SessionHandle session_handle = p11_low_level.open_session(session_flags); Test::Result result = login_logout_helper(p11_low_level, session_handle, UserType::User, PIN); p11_low_level.close_session(); // R/W session session_flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); session_handle = p11_low_level.open_session(session_flags); result.merge(login_logout_helper(p11_low_level, session_handle, UserType::User, PIN)); return result; } Test::Result test_c_init_pin() { RAII_LowLevel p11_low_level; // C_InitPIN can only be called in the "R/W SO Functions" state Flags session_flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); SessionHandle session_handle = p11_low_level.open_session(session_flags); p11_low_level.login(UserType::SO, SO_PIN_SECVEC); auto sec_vec_binder = std::bind( static_cast< bool (LowLevel::*)(SessionHandle, const secure_vector<uint8_t>&, ReturnValue*) const> (&LowLevel::C_InitPIN<secure_allocator<uint8_t>>), *p11_low_level.get(), session_handle, std::ref(PIN_SECVEC), std::placeholders::_1); return test_function("C_InitPIN", sec_vec_binder); } Test::Result test_c_set_pin() { RAII_LowLevel p11_low_level; // C_SetPIN can only be called in the "R / W Public Session" state, "R / W SO Functions" state, or "R / W User Functions" state Flags session_flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); SessionHandle session_handle = p11_low_level.open_session(session_flags); // now we are in "R / W Public Session" state: this will change the pin of the user auto get_pin_bind = [ &session_handle, &p11_low_level ](const secure_vector<uint8_t>& old_pin, const secure_vector<uint8_t>& new_pin) -> PKCS11_BoundTestFunction { return std::bind(static_cast< bool (LowLevel::*)(SessionHandle, const secure_vector<uint8_t>&, const secure_vector<uint8_t>&, ReturnValue*) const> (&LowLevel::C_SetPIN<secure_allocator<uint8_t>>), *p11_low_level.get(), session_handle, old_pin, new_pin, std::placeholders::_1); }; const std::string test_pin("654321"); const auto test_pin_secvec = secure_vector<uint8_t>(test_pin.begin(), test_pin.end()); PKCS11_BoundTestFunction set_pin_bind = get_pin_bind(PIN_SECVEC, test_pin_secvec); PKCS11_BoundTestFunction revert_pin_bind = get_pin_bind(test_pin_secvec, PIN_SECVEC); Test::Result result = test_function("C_SetPIN", set_pin_bind, "C_SetPIN", revert_pin_bind); // change pin in "R / W User Functions" state p11_low_level.login(UserType::User, PIN_SECVEC); result.merge(test_function("C_SetPIN", set_pin_bind, "C_SetPIN", revert_pin_bind)); p11_low_level.logout(); // change so_pin in "R / W SO Functions" state const std::string test_so_pin = "87654321"; secure_vector<uint8_t> test_so_pin_secvec(test_so_pin.begin(), test_so_pin.end()); p11_low_level.login(UserType::SO, SO_PIN_SECVEC); PKCS11_BoundTestFunction set_so_pin_bind = get_pin_bind(SO_PIN_SECVEC, test_so_pin_secvec); PKCS11_BoundTestFunction revert_so_pin_bind = get_pin_bind(test_so_pin_secvec, SO_PIN_SECVEC); result.merge(test_function("C_SetPIN", set_so_pin_bind, "C_SetPIN", revert_so_pin_bind)); return result; } // Simple data object ObjectClass object_class = ObjectClass::Data; std::string label = "A data object"; std::string data = "Sample data"; Bbool btrue = True; std::array<Attribute, 4> dtemplate = { { { static_cast<CK_ATTRIBUTE_TYPE>(AttributeType::Class), &object_class, sizeof(object_class) }, { static_cast<CK_ATTRIBUTE_TYPE>(AttributeType::Token), &btrue, sizeof(btrue) }, { static_cast<CK_ATTRIBUTE_TYPE>(AttributeType::Label), const_cast< char* >(label.c_str()), label.size() }, { static_cast<CK_ATTRIBUTE_TYPE>(AttributeType::Value), const_cast< char* >(data.c_str()), data.size() } } }; ObjectHandle create_simple_data_object(const RAII_LowLevel& p11_low_level) { ObjectHandle object_handle; p11_low_level.get()->C_CreateObject(p11_low_level.get_session_handle(), dtemplate.data(), dtemplate.size(), &object_handle); return object_handle; } Test::Result test_c_create_object_c_destroy_object() { RAII_LowLevel p11_low_level; SessionHandle session_handle = p11_low_level.open_rw_session_with_user_login(); ObjectHandle object_handle(0); auto create_bind = std::bind(&LowLevel::C_CreateObject, *p11_low_level.get(), session_handle, dtemplate.data(), dtemplate.size(), &object_handle, std::placeholders::_1); auto destroy_bind = std::bind(&LowLevel::C_DestroyObject, *p11_low_level.get(), session_handle, std::ref(object_handle), std::placeholders::_1); return test_function("C_CreateObject", create_bind, "C_DestroyObject", destroy_bind); } Test::Result test_c_get_object_size() { RAII_LowLevel p11_low_level; Flags session_flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); SessionHandle session_handle = p11_low_level.open_session(session_flags); p11_low_level.login(UserType::User, PIN_SECVEC); ObjectHandle object_handle = create_simple_data_object(p11_low_level); Ulong object_size = 0; auto bind = std::bind(&LowLevel::C_GetObjectSize, *p11_low_level.get(), session_handle, object_handle, &object_size, std::placeholders::_1); Test::Result result = test_function("C_GetObjectSize", bind); result.test_ne("Object size", object_size, 0); // cleanup p11_low_level.get()->C_DestroyObject(session_handle, object_handle); return result; } Test::Result test_c_get_attribute_value() { RAII_LowLevel p11_low_level; SessionHandle session_handle = p11_low_level.open_rw_session_with_user_login(); ObjectHandle object_handle = create_simple_data_object(p11_low_level); std::map < AttributeType, secure_vector<uint8_t>> getter = { { AttributeType::Label, secure_vector<uint8_t>() }, { AttributeType::Value, secure_vector<uint8_t>() } }; auto bind = std::bind(static_cast< bool (LowLevel::*)(SessionHandle, ObjectHandle, std::map<AttributeType, secure_vector<uint8_t>>&, ReturnValue*) const> (&LowLevel::C_GetAttributeValue<secure_allocator<uint8_t>>), *p11_low_level.get(), session_handle, object_handle, std::ref(getter), std::placeholders::_1); Test::Result result = test_function("C_GetAttributeValue", bind); std::string _label(getter[ AttributeType::Label ].begin(), getter[ AttributeType::Label ].end()); std::string value(getter[ AttributeType::Value ].begin(), getter[ AttributeType::Value ].end()); result.test_eq("label", _label, "A data object"); result.test_eq("value", value, "Sample data"); // cleanup p11_low_level.get()->C_DestroyObject(session_handle, object_handle); return result; } std::map < AttributeType, std::vector<uint8_t>> get_attribute_values(const RAII_LowLevel& p11_low_level, SessionHandle session_handle, ObjectHandle object_handle, const std::vector<AttributeType>& attribute_types) { std::map < AttributeType, std::vector<uint8_t>> received_attributes; for(const auto& type : attribute_types) { received_attributes.emplace(type, std::vector<uint8_t>()); } p11_low_level.get()->C_GetAttributeValue(session_handle, object_handle, received_attributes); return received_attributes; } Test::Result test_c_set_attribute_value() { RAII_LowLevel p11_low_level; Flags session_flags = PKCS11::flags(Flag::SerialSession | Flag::RwSession); SessionHandle session_handle = p11_low_level.open_session(session_flags); p11_low_level.login(UserType::User, PIN_SECVEC); ObjectHandle object_handle = create_simple_data_object(p11_low_level); std::string new_label = "A modified data object"; std::map < AttributeType, secure_vector<uint8_t>> new_attributes = { { AttributeType::Label, secure_vector<uint8_t>(new_label.begin(), new_label.end()) } }; auto bind = std::bind(static_cast< bool (LowLevel::*)(SessionHandle, ObjectHandle, std::map<AttributeType, secure_vector<uint8_t>>&, ReturnValue*) const> (&LowLevel::C_SetAttributeValue<secure_allocator<uint8_t>>), *p11_low_level.get(), session_handle, object_handle, std::ref(new_attributes), std::placeholders::_1); Test::Result result = test_function("C_SetAttributeValue", bind); // get attributes and check if they are changed correctly std::vector<AttributeType> types = { AttributeType::Label, AttributeType::Value }; auto received_attributes = get_attribute_values(p11_low_level, session_handle, object_handle, types); std::string retrieved_label(received_attributes[ AttributeType::Label ].begin(), received_attributes[ AttributeType::Label ].end()); result.test_eq("label", new_label, retrieved_label); // cleanup p11_low_level.get()->C_DestroyObject(session_handle, object_handle); return result; } Test::Result test_c_copy_object() { RAII_LowLevel p11_low_level; SessionHandle session_handle = p11_low_level.open_rw_session_with_user_login(); ObjectHandle object_handle = create_simple_data_object(p11_low_level); ObjectHandle copied_object_handle = 0; std::string copied_label = "A copied data object"; Attribute copy_attribute_values = { static_cast< CK_ATTRIBUTE_TYPE >(AttributeType::Label), const_cast< char* >(copied_label.c_str()), copied_label.size() }; auto binder = std::bind(&LowLevel::C_CopyObject, *p11_low_level.get(), session_handle, object_handle, &copy_attribute_values, 1, &copied_object_handle, std::placeholders::_1); Test::Result result = test_function("C_CopyObject", binder); // get attributes and check if its copied correctly std::vector<AttributeType> types = { AttributeType::Label, AttributeType::Value }; auto received_attributes = get_attribute_values(p11_low_level, session_handle, copied_object_handle, types); std::string retrieved_label(received_attributes[ AttributeType::Label ].begin(), received_attributes[ AttributeType::Label ].end()); result.test_eq("label", copied_label, retrieved_label); // cleanup p11_low_level.get()->C_DestroyObject(session_handle, object_handle); p11_low_level.get()->C_DestroyObject(session_handle, copied_object_handle); return result; } class LowLevelTests final : public Test { public: std::vector<Test::Result> run() override { std::vector<Test::Result> results; std::vector<std::function<Test::Result()>> fns = { test_c_get_function_list , test_low_level_ctor , test_initialize_finalize , test_c_get_info , test_c_get_slot_list , test_c_get_slot_info , test_c_get_token_info , test_c_wait_for_slot_event , test_c_get_mechanism_list , test_c_get_mechanism_info , test_open_close_session , test_c_close_all_sessions , test_c_get_session_info , test_c_init_token , test_c_login_logout_security_officier /* only possible if token is initialized */ , test_c_init_pin , test_c_login_logout_user /* only possible if token is initialized and user pin is set */ , test_c_set_pin , test_c_create_object_c_destroy_object , test_c_get_object_size , test_c_get_attribute_value , test_c_set_attribute_value , test_c_copy_object }; for(size_t i = 0; i != fns.size(); ++i) { try { results.push_back(fns[ i ]()); } catch(PKCS11_ReturnError& e) { results.push_back(Test::Result::Failure("PKCS11 low level test " + std::to_string(i), e.what())); if(e.get_return_value() == ReturnValue::PinIncorrect) { break; // Do not continue to not potentially lock the token } } catch(std::exception& e) { results.push_back(Test::Result::Failure("PKCS11 low level test " + std::to_string(i), e.what())); } } return results; } }; BOTAN_REGISTER_TEST("pkcs11-lowlevel", LowLevelTests); #endif #endif } }
; ; Set flags E to 11111110 ; Loop: A << 2 ; if carry was 0 ; if a >= D ; A = A - D ; clear carry (probably irrelevant really) ; else ; sla flags << bringing in carry of 1 ; if bit 7 of flag was set then loop ; elase a = e and exit ; ; ">BC_Div_DE: BC = BC / DE. HL = remainder fast divide with unrolled loop BC/DE ==> BC, remainder in HL ; ;INPUTS: hl = dividend dbc = divisor ;OUTPUTS: hl/de -> AHL = quotient CDE = remainder, Carryflag set if divide by 0 Div16by24usgn: inc d ; can we fast retu dec d jr nz,.ResultZero ld de,bc ; so prep for bc/de ld bc,hl .div16by16usng: ld a,d or e jr z,.DivideByZero inc d dec d call BC_Div_DE ZeroA ex de,hl ; de = remainder (need to fix c after hl = nothing of worth) ld hl,bc ; hl = result (a is zero from above) ld c,a ; now fix c ret .ResultZero: xor a ; set AHL to 0 as d was 0 so h is zero ld c,a ; c = 0 ld h,a ld l,a ret .DivideByZero: ld a,$FF ld h,a ld l,a SetCarryFlag ret ;DIVD4 P-R=A/Qunsg \P.R = A/Q unsigned called by Hall HLEquAmul256DivD: ld b,8 ; counter sla a ; ld h,a ; r a * 2 we will build result in hl .DivideLoop: rl a ; a = a * 2 jr c,.StraightToSubtraction ; jump on carry to subtraction cp d ; what was var Q jr c,.SkipSubtraction ; if a < d skip subtraction, note this will come to skip subtraction with carry the wrong way round .StraightToSubtraction: ClearCarryFlag ; in 6502 the borrow flag is inverted carry, z80 just uses carry so we need to clear it sbc a,d ; a = a - q ClearCarryFlag ; set carry so it gets shifted into bit 0 of b. we do this as we have to flip carry due to jr c from earlier cp d .SkipSubtraction: ccf ; we need to do this as 6502 does opposite on carry, i.e. if we jumped direct here then carry would be set in z80 rl h ; roll d left bringing in carry if there was an sbc performed djnz .DivideLoop ; 8 cycles .CalculateRemainder: cp d ; calulate 256 * a / d if q >= q then answer will not fit in one byte d is still set, a holds remainder to be subtracted jr nc, .RemainderTooBig ClearCarryFlag ; remove carry as the previous cp will have set it and mess up the sla in the remainder loop .InitRemainderLoop: ld b,%11111110 ; loop for bits 1 to 7 ld l,b ; and set l to capture result bits (R) .RemainderLoop: sla a ; shift a left jr c, .RemainderSubtraction ; if there was a carry go to subtraction cp d ; if a < d then skip subtraction jr c,.RemainderSkipSubtract ; . sbc d ; a > q so a = a - q, carry will be clear here .RemainderSkipSubtract: ccf ; as the jr used z80 we need to flip the carry to behave like 6502 rl l ; rotate counter to the left jr c, .RemainderLoop ; if there was a bit pushed to carry then loop ret .RemainderSubtraction: sbc d ; as the carry came from an sla we want to retain it SetCarryFlag ; roll in a carry bit to result rl l ; jr c, .RemainderLoop ; and loop if there was a carry bit that came out ret .RemainderTooBig: ld l,$FF ; now hl = result ret AEquAmul256DivD: cp d jr z,.BothSame jr nc,.DgtA ld e,%11111110 ; Set R to have bits 1-7 set, so we can rotate through 7 .DivideLoop: sla a jr c,.LL29 JumpIfALTNusng d, .SkipSub ; will jump if carry set, so we need to reset on the rol sub d ClearCarryFlag ; reset clarry as it will be complimented for rotate as 6502 does carry flags inverted .SkipSub: FlipCarryFlag ; if we did the subtract the carry will be clear so we need to invert to roll in. rl e jr c,.DivideLoop ld a,e ret .LL29: sub d ; A >= Q, so set A = A - Q SetCarryFlag ; Set the C flag to rotate into the result in R rl e ; rotate counter e left jr c,.DivideLoop ; if a bit was spat off teh end then loop ld a,e ; stick result in a ret .BothSame: ld a,1 ret .DgtA: ld a,255 ; Fail with FF as result ret ; Divide 8-bit values ; In: Divide E by divider C ; Out: A = result, B = rest ; ;;;Div8: ;;; xor a ;;; ld b,8 ;;;Div8_Loop: ;;; rl e ;;; rla ;;; sub c ;;; jr nc,Div8_NoAdd ;;; add a,c ;;;Div8_NoAdd: ;;; djnz Div8_Loop ;;; ld b,a0 ;;; ld a,e ;;; rla ;;; cpl ;;; ret ;;Inputs: DE is the numerator, BC is the divisor ;;Outputs: DE is the result ;; A is a copy of E ;; HL is the remainder ;; BC is not changed ;; so DE = DE /BC ;140 bytes ;145cc MacroDEDivBC: MACRO rla adc hl,hl sbc hl,bc jr nc,$+3 add hl,bc ENDM DEequDEDivBC: xor a sbc hl,hl ld a,d MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC rla cpl ld d,a ld a,e MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC MacroDEDivBC rla cpl ld e,a ret ;divdide by 16 using undocumented instrunctions ;Input: BC = Dividend, DE = Divisor, HL = 0 ;Output: BC = Quotient, HL = Remainder ; Our use ; BC = A0 ; DE = 0C ; so BC = a * 256 / C DIV16Amul256dCUNDOC: JumpIfAGTENusng c,DEV16ATooLarge ; first off if a > c ten return 255 ld b,a ld e,c ld c,0 ld d,0 jp DIV16UNDOC DIV16Amul256dQUNDOC: ld b,a ld c,0 ld hl,varQ ld a,(hl) ld d,0 ld e,a DIV16BCDivDEUNDOC: DIV16UNDOC: ld hl,0 ld a,b ld b,16 DIV16UNDOCLOOP: sll c ; unroll 16 times rla ; ... adc hl,hl ; ... sbc hl,de ; ... jr nc,DIV16UNDOCSKIP ; ... add hl,de ; ... dec c ; ... DIV16UNDOCSKIP: djnz DIV16UNDOCLOOP ld b,a ret DEV16ATooLarge: ld bc,$00FF ret ; "> asm_div8 C_Div_D - C is the numerator, D is the denominator, A is the remainder, B is 0, C is the result of C/D,D,E,H,L are not changed" asm_div8: ld b,8 xor a .div8_loop: sla c rla cp d jr c,.div8_skip: inc c sub d .div8_skip: djnz .div8_loop ret ; ">asm_div16: HL_Div_C: HL is the numerator, C is the denominator, output A is the remainder, B is 0, C,DE is not changedHL is the quotient" asm_div16: ld b,16 xor a div16_loop: sla l rl h ; add hl,hl rla cp c jr c,div16_skip inc l sub c div16_skip: djnz div16_loop ret ; ; Divide 16-bit values (with 16-bit result) ; In: Divide BC by divider DE ; Out: BC = result, HL = rest ; HLDivC_Iteration: MACRO add hl,hl ; unroll 16 times rla ; ... cp c ; ... jr 1F sub c ; ... 1: inc l ; ... ENDM ; ">div1616: BC = BC / DE. HL = remainder" Div1616: ld hl,0 ld a,b ld b,8 .Div16_Loop1: rla adc hl,hl sbc hl,de jr nc,.Div16_NoAdd1 add hl,de .Div16_NoAdd1: djnz .Div16_Loop1 rla cpl ld b,a ld a,c ld c,b ld b,8 .Div16_Loop2: rla adc hl,hl sbc hl,de jr nc,.Div16_NoAdd2 add hl,de .Div16_NoAdd2: djnz .Div16_Loop2 rla cpl ld b,c ld c,a ret EDivC_Iteration: MACRO rl e rla sub c jr nc,.Div8_NoAdd add a,c .Div8_NoAdd: ENDM ; Divide E by divider C Out: A = result, B = rest E_Div_C: ZeroA EDivC_Iteration EDivC_Iteration EDivC_Iteration EDivC_Iteration EDivC_Iteration EDivC_Iteration EDivC_Iteration EDivC_Iteration ld b,a ld a,e rla cpl ret BCDIVDE_Iteration: MACRO rla adc hl,hl add hl,de jr c,1F sbc hl,de 1: ENDM ; ">BC_Div_DE: BC = BC / DE. HL = remainder fast divide with unrolled loop" ;BC/DE ==> BC, remainder in HL ;NOTE: BC/0 returns 0 as the quotient. ;min: 738cc ;max: 898cc ;avg: 818cc ;144 bytes BC_Div_DE: xor a ld h,a ld l,a sub e ld e,a sbc a,a sub d ld d,a ld a,b BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration rla ld b,a ld a,c BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration BCDIVDE_Iteration rla ld c,a ret ;Inputs: ; DE,BC are 8.8 Fixed Point numbers ;Outputs: ; DE is the 8.8 Fixed Point result (rounded to the least significant bit) ;if DE is 0 : 122cc or 136cc if BC is negative ;if |BC|>=128*|DE| : 152cc or 166cc if BC is negative ;Otherwise: ;min: 1107cc ;max: 1319cc ;avg: 1201cc BC_Div_DE_88: ld a,b ; First, find out if the output is positive or negative xor d push af ;sign bit is the result sign bit ; Now make sure the inputs are positive xor b ;A now has the value of B, since I XORed it with D twice (cancelling) jp p,BC_Div_DE_88_lbl1 ;if Positive, don't negate xor a sub c ld c,a sbc a,a sub b ld b,a BC_Div_DE_88_lbl1: ld a,d ;now make DE negative to optimize the remainder comparison or d jp m,BC_Div_DE_88_lbl2 xor a sub e ld e,a sbc a,a sub d ld d,a BC_Div_DE_88_lbl2: or e ;if DE is 0, we can call it an overflow ;A is the current value of D jr z,div_fixed88_overflow ld h,0 ;The accumulator gets set to B if no overflow.;We can use H=0 to save a few cc in the meantime ld a,b;if B+DE>=0, then we'll have overflow add a,e ld a,d adc a,h jr c,div_fixed88_overflow ld l,b ;Now we can load the accumulator/remainder with B;H is already 0 ld a,c call div_fixed88_sub ld c,a ld a,b ;A is now 0 call div_fixed88_sub ld d,c ld e,a pop af ret p xor a sub e ld e,a sbc a,a sub d ld d,a ret div_fixed88_overflow: ld de,$7FFF pop af ret p inc de inc e ret ;min: 456cc ;max: 536cc ;avg: 496cc div_fixed88_sub: ld b,8 BC_Div_DE_88_lbl3: rla adc hl,hl add hl,de jr c,$+4 sbc hl,de djnz BC_Div_DE_88_lbl3 adc a,a ret
; A211661: Number of iterations log_3(log_3(log_3(...(n)...))) such that the result is < 1. ; 1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 div $0,2 lpb $0 div $0,13 add $1,1 lpe add $1,1 mov $0,$1
; A033885: a(n) = 3*n - sum of divisors of n. ; 2,3,5,5,9,6,13,9,14,12,21,8,25,18,21,17,33,15,37,18,31,30,45,12,44,36,41,28,57,18,61,33,51,48,57,17,73,54,61,30,81,30,85,48,57,66,93,20,90,57,81,58,105,42,93,48,91,84,117,12,121,90,85,65,111,54,133,78,111,66,141,21,145,108,101,88,135,66,157,54,122,120,165,28,147,126,141,84,177,36,161,108,151,138,165,36,193,123,141,83 mov $2,$0 seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n). sub $0,$2 mov $1,$2 add $1,7 sub $0,$1 sub $1,$0 sub $1,11 mov $0,$1
C x86_64/umac-nh.asm ifelse(< Copyright (C) 2013 Niels Möller This file is part of GNU Nettle. GNU Nettle is free software: you can redistribute it and/or modify it under the terms of either: * the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. or * the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. or both in parallel, as here. GNU Nettle is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received copies of the GNU General Public License and the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/. >) define(<KEY>, <%rdi>) define(<LENGTH>, <%rsi>) define(<MSG>, <%rdx>) define(<XA>, <%xmm0>) define(<XB>, <%xmm1>) define(<XK0>, <%xmm2>) define(<XK1>, <%xmm3>) define(<XY>, <%xmm4>) define(<XT0>, <%xmm5>) define(<XT1>, <%xmm6>) C FIXME: Would be nice if we could force the key array to be 16-byte C aligned. .file "umac-nh.asm" C umac_nh(const uint32_t *key, unsigned length, const uint8_t *msg) .text ALIGN(16) PROLOGUE(_nettle_umac_nh) W64_ENTRY(3, 7) pxor XY, XY .Loop: movups (KEY), XK0 movups 16(KEY), XK1 movups (MSG), XA movups 16(MSG), XB paddd XK0, XA paddd XK1, XB pshufd $0x31, XA, XT0 pshufd $0x31, XB, XT1 pmuludq XT0, XT1 paddq XT1, XY pmuludq XA, XB paddq XB, XY C Length is only 32 bits subl $32, XREG(LENGTH) lea 32(KEY), KEY lea 32(MSG), MSG ja .Loop pshufd $0xe, XY, XT0 paddq XT0, XY C Really a movq, but write as movd to please Apple's assembler movd XY, %rax W64_EXIT(3, 7) ret EPILOGUE(_nettle_umac_nh)
//********************************************************* // // Copyright (c) Microsoft. All rights reserved. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //********************************************************* #include "pch.h" #include "xsapi/game_server_platform.h" #include "xbox_system_factory.h" #include "utils.h" #include "user_context.h" using namespace pplx; NAMESPACE_MICROSOFT_XBOX_SERVICES_GAMESERVERPLATFORM_CPP_BEGIN game_server_ticket_status::game_server_ticket_status() : m_titleId(0), m_status(game_server_host_status::unknown) { } game_server_ticket_status::game_server_ticket_status( _In_ string_t ticketId, _In_ string_t clusterId, _In_ uint32_t titleId, _In_ string_t hostName, _In_ game_server_host_status status, _In_ string_t description, _In_ string_t secureContext, _In_ std::vector< game_server_port_mapping > portMappings, _In_ string_t gameHostId, _In_ string_t region ) : m_ticketId(std::move(ticketId)), m_clusterId(std::move(clusterId)), m_titleId(titleId), m_hostName(std::move(hostName)), m_status(status), m_description(std::move(description)), m_secureContext(std::move(secureContext)), m_portMappings(std::move(portMappings)), m_gameHostId(std::move(gameHostId)), m_region(std::move(region)) { } const string_t& game_server_ticket_status::ticket_id() const { return m_ticketId; } const string_t& game_server_ticket_status::cluster_id() const { return m_clusterId; } uint32_t game_server_ticket_status::title_id() const { return m_titleId; } const string_t& game_server_ticket_status::host_name() const { return m_hostName; } game_server_host_status game_server_ticket_status::status() const { return m_status; } const string_t& game_server_ticket_status::description() const { return m_description; } const string_t& game_server_ticket_status::secure_context() const { return m_secureContext; } std::vector< game_server_port_mapping > game_server_ticket_status::port_mappings() const { return m_portMappings; } const string_t& game_server_ticket_status::game_host_id() const { return m_gameHostId; } const string_t& game_server_ticket_status::region() const { return m_region; } xbox_live_result<game_server_ticket_status> game_server_ticket_status::_Deserialize(_In_ const web::json::value& json) { if (json.is_null()) return xbox_live_result<game_server_ticket_status>(); std::error_code errc; auto portMappings = utils::extract_json_vector<game_server_port_mapping>(game_server_port_mapping::_Deserialize, json, _T("portMappings"), errc, false); auto result = game_server_ticket_status( utils::extract_json_string(json, _T("ticketId"), errc), utils::extract_json_string(json, _T("clusterId"), errc), utils::extract_json_int(json, _T("titleId"), errc), utils::extract_json_string(json, _T("hostName"), errc), convert_string_to_host_status(utils::extract_json_string(json, _T("status"), errc)), utils::extract_json_string(json, _T("description"), errc), utils::extract_json_string(json, _T("secureContext"), errc), std::move(portMappings), utils::extract_json_string(json, _T("gameHostId"), errc), utils::extract_json_string(json, _T("region"), errc) ); return xbox_live_result<game_server_ticket_status>(result, errc); } game_server_host_status game_server_ticket_status::convert_string_to_host_status( _In_ const string_t& value ) { if (utils::str_icmp(value, _T("active")) == 0) { return game_server_host_status::active; } else if (utils::str_icmp(value, _T("queued")) == 0) { return game_server_host_status::queued; } else if (utils::str_icmp(value, _T("aborted")) == 0) { return game_server_host_status::aborted; } else if (utils::str_icmp(value, _T("error")) == 0) { return game_server_host_status::error; } return game_server_host_status::unknown; } NAMESPACE_MICROSOFT_XBOX_SERVICES_GAMESERVERPLATFORM_CPP_END
%ifdef CONFIG { "RegData": { "RAX": "0x4142434445464748", "RBX": "0x41424344FFFFFFFF", "RCX": "0xFFFFFFFFFFFFFFFF" } } %endif mov rdx, 0xe0000000 mov rax, 0x4142434445464748 mov [rdx + 8 * 0], rax mov rax, 0x8080808080808080 mov [rdx + 8 * 1], rax mov rax, 0x8080808000000000 mov [rdx + 8 * 2], rax mov rax, 0 mov [rdx + 8 * 3], rax mov rax, -1 mov [rdx + 8 * 4], rax mov [rdx + 8 * 5], rax mov [rdx + 8 * 6], rax movq mm0, [rdx + 8 * 0] movq mm1, [rdx + 8 * 1] movq mm2, [rdx + 8 * 2] movq mm3, [rdx + 8 * 3] lea rdi, [rdx + 8 * 4] maskmovq mm0, mm1 lea rdi, [rdx + 8 * 5] maskmovq mm0, mm2 lea rdi, [rdx + 8 * 6] maskmovq mm0, mm3 mov rax, qword [rdx + 8 * 4] mov rbx, qword [rdx + 8 * 5] mov rcx, qword [rdx + 8 * 6] hlt
.data coeff: .word 2 exp: .word -3 .text: main: lw $a0, coeff lw $a1, exp jal create_term #write test code move $a0, $v0 li $v0, 1 syscall li $v0, 10 syscall .include "hw5.asm"
; A023891: Sum of composite divisors of n. ; Submitted by Jon Maiga ; 0,0,0,4,0,6,0,12,9,10,0,22,0,14,15,28,0,33,0,34,21,22,0,54,25,26,36,46,0,61,0,60,33,34,35,85,0,38,39,82,0,83,0,70,69,46,0,118,49,85,51,82,0,114,55,110,57,58,0,157,0,62,93,124,65,127,0,106,69,129,0,189,0,74,115,118,77,149,0,178,117,82,0,211,85,86,87,166,0,223,91,142,93,94,95,246,0,161,141,209 mov $1,$0 seq $0,203 ; a(n) = sigma(n), the sum of the divisors of n. Also called sigma_1(n). seq $1,74372 ; 1 + the sum of the distinct primes dividing n. sub $0,$1
; A206735: Triangle T(n,k), read by rows, given by (0, 2, -1/2, 1/2, 0, 0, 0, 0, 0, 0, 0, ...) DELTA (1, 0, -1/2, 1/2, 0, 0, 0, 0, 0, 0, 0, ...) where DELTA is the operator defined in A084938. ; 1,0,1,0,2,1,0,3,3,1,0,4,6,4,1,0,5,10,10,5,1,0,6,15,20,15,6,1,0,7,21,35,35,21,7,1,0,8,28,56,70,56,28,8,1,0,9,36,84,126,126,84,36,9,1,0,10,45,120,210,252,210,120,45,10,1,0,11,55,165,330,462,462,330,165,55,11,1 mov $4,$0 lpb $4,$4 add $3,1 sub $4,$3 lpe bin $3,$4 mov $1,$3
CheckReceivedItemPropertiesBeforeLoad: LDA $A0 : BEQ .normalCode LDA $7EC005 : BNE .lightOff .normalCode LDA.l AddReceivedItemExpanded_properties, X ;Restore Rando Code RTL .lightOff PHX : PHY : PHB LDA.l AddReceivedItemExpanded_properties, X ; get palette REP #$30 AND #$0007 ; mask out palette ASL #5 ; multiply by 32 ADC #$C610 ; offset to latter half TAX ; give to destination LDY #$C610 ; target palette SP0 colors 8-F LDA #$000F ; 16 bytes MVN $7E, $7E ; move palette SEP #$30 PLB : PLY : PLX INC $15 LDA #$00 RTL
/******************************************************************************* * Copyright (c) 2015-2018 Skymind, Inc. * * This program and the accompanying materials are made available under the * terms of the Apache License, Version 2.0 which is available at * https://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. * * SPDX-License-Identifier: Apache-2.0 ******************************************************************************/ // // Created by raver on 8/4/2018. // #include "testlayers.h" #include <ops/declarable/CustomOperations.h> #include <NDArray.h> #include <ops/ops.h> #include <GradCheck.h> using namespace nd4j; class DeclarableOpsTests10 : public testing::Test { public: DeclarableOpsTests10() { printf("\n"); fflush(stdout); } }; TEST_F(DeclarableOpsTests10, Test_ArgMax_1) { NDArray<double> x('c', {3, 3}); NDArray<double> e(8); x.linspace(1.0); nd4j::ops::argmax<double> op; auto result = op.execute({&x}, {}, {}); ASSERT_EQ(Status::OK(), result->status()); auto z = *result->at(0); ASSERT_EQ(e, z); delete result; } TEST_F(DeclarableOpsTests10, Test_ArgMax_2) { NDArray<double> x('c', {3, 3}); NDArray<double> y('c', {1}, {1.0}); NDArray<double> e('c', {3}, {2.0, 2.0, 2.0}); x.linspace(1.0); nd4j::ops::argmax<double> op; auto result = op.execute({&x, &y}, {}, {}); ASSERT_EQ(Status::OK(), result->status()); auto z = *result->at(0); //z.printIndexedBuffer("z"); //z.printShapeInfo("z shape"); ASSERT_EQ(e, z); delete result; } TEST_F(DeclarableOpsTests10, Test_And_1) { NDArray<double> x('c', {4}, {1, 1, 0, 1}); NDArray<double> y('c', {4}, {0, 0, 0, 1}); NDArray<double> e('c', {4}, {0, 0, 0, 1}); nd4j::ops::boolean_and<double> op; auto result = op.execute({&x, &y}, {}, {}); ASSERT_EQ(Status::OK(), result->status()); ASSERT_EQ(e, *result->at(0)); delete result; } TEST_F(DeclarableOpsTests10, Test_Or_1) { NDArray<double> x('c', {4}, {1, 1, 0, 1}); NDArray<double> y('c', {4}, {0, 0, 0, 1}); NDArray<double> e('c', {4}, {1, 1, 0, 1}); nd4j::ops::boolean_or<double> op; auto result = op.execute({&x, &y}, {}, {}); ASSERT_EQ(Status::OK(), result->status()); ASSERT_EQ(e, *result->at(0)); delete result; } TEST_F(DeclarableOpsTests10, Test_Not_1) { NDArray<double> x('c', {4}, {1, 1, 0, 1}); NDArray<double> y('c', {4}, {0, 0, 0, 1}); NDArray<double> e('c', {4}, {1, 1, 1, 0}); nd4j::ops::boolean_not<double> op; auto result = op.execute({&x, &y}, {}, {}); ASSERT_EQ(Status::OK(), result->status()); ASSERT_EQ(e, *result->at(0)); delete result; } TEST_F(DeclarableOpsTests10, Test_Size_at_1) { NDArray<double> x('c', {10, 20, 30}); NDArray<double> e(20.0); nd4j::ops::size_at<double> op; auto result = op.execute({&x}, {}, {1}); ASSERT_EQ(Status::OK(), result->status()); ASSERT_EQ(e, *result->at(0)); delete result; } //////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, Pad_SGO_Test_1) { NDArray<double> in({1., 1., 1., 1., 1.}); // NDArray<double> pad('c', {1, 2}, {1., 1.});// = Nd4j.create(new double[]{1, 1}, new long[]{1, 2}); NDArray<double> pad('c', {1, 2}, {1., 1.}); // NDArray<double> value(10.0); NDArray<double> exp({10., 1., 1., 1., 1., 1., 10.}); nd4j::ops::pad<double> op; auto res = op.execute({&in, &pad}, {10.0}, {0}); ASSERT_EQ(res->status(), ND4J_STATUS_OK); ASSERT_TRUE(exp.equalsTo(res->at(0))); delete res; } //////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, Unique_SGO_Test_1) { NDArray<double> input({3., 4., 3., 1., 3., 0., 2., 4., 2., 4.}); NDArray<double> expIdx({0., 1., 0., 2., 0., 3., 4., 1., 4., 1.}); NDArray<double> exp({3., 4., 1., 0., 2.}); nd4j::ops::unique<double> op; auto res = op.execute({&input}, {}, {}); ASSERT_TRUE(res->status() == ND4J_STATUS_OK); //res->at(0)->printIndexedBuffer("Unique values"); //res->at(1)->printIndexedBuffer("Unique idxs"); ASSERT_TRUE(exp.equalsTo(res->at(0))); ASSERT_TRUE(expIdx.equalsTo(res->at(1))); delete res; } //////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, Where_SGO_Test_1) { NDArray<double> input('c', {3, 3}, {1., 0., 0., 1., 1., 0., 1., 1., 1.}); //NDArray<double> expIdx({0., 1., 0., 2., 0., 3., 4., 1., 4., 1.}); NDArray<double> exp('c', {6, 2}, {0., 0., 1., 0., 1., 1., 2., 0., 2., 1., 2., 2.}); nd4j::ops::Where<double> op; auto res = op.execute({&input}, {}, {}); ASSERT_TRUE(res->status() == ND4J_STATUS_OK); NDArray<double>* resA = res->at(0); ASSERT_TRUE(exp.equalsTo(resA)); ASSERT_TRUE(exp.isSameShape(resA)); // ASSERT_TRUE(expIdx.equalsTo(res->at(1))); delete res; } //////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, WhereNP_SGO_Test_1) { NDArray<double> cond3d('c', {2, 2, 2}, {1., 0., 0., 1., 1., 1., 1., 0.}); // NDArray<double> expIdx({0., 1., 0., 2., 0., 3., 4., 1., 4., 1.}); NDArray<double> exp1({0., 0., 1., 1., 1.}); NDArray<double> exp2({0., 1., 0., 0., 1.}); NDArray<double> exp3({0., 1., 0., 1., 0.}); nd4j::ops::where_np<double> op; auto res = op.execute({&cond3d}, {}, {}); ASSERT_TRUE(res->size() == 3); ASSERT_TRUE(res->status() == ND4J_STATUS_OK); ASSERT_TRUE(exp1.equalsTo(res->at(0))); ASSERT_TRUE(exp2.equalsTo(res->at(1))); ASSERT_TRUE(exp3.equalsTo(res->at(2))); //ASSERT_TRUE(expIdx.equalsTo(res->at(1))); delete res; } //////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, WhereNP_SGO_Test_2) { NDArray<double> cond2d('c', {3, 5}, {1., 1., 0., 0., 1., 1., 1., 1., 1., 1., 0., 1., 1., 1., 1.}); // NDArray<double> expIdx({0., 1., 0., 2., 0., 3., 4., 1., 4., 1.}); NDArray<double> exp1({0., 0., 0., 1., 1., 1., 1., 1., 2., 2., 2., 2.}); NDArray<double> exp2({0., 1., 4., 0., 1., 2., 3., 4., 1., 2., 3., 4.}); nd4j::ops::where_np<double> op; auto res = op.execute({&cond2d}, {}, {}); ASSERT_TRUE(res->size() == 2); ASSERT_TRUE(res->status() == ND4J_STATUS_OK); ASSERT_TRUE(exp1.equalsTo(res->at(0))); ASSERT_TRUE(exp2.equalsTo(res->at(1))); //ASSERT_TRUE(expIdx.equalsTo(res->at(1))); delete res; } /////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, svd_test11) { NDArray<double> x('c', {3,3}, {1.,2.,3.,4.,5.,6.,7.,8.,9.}); NDArray<double> expS('c', {3}); NDArray<double> expU('c', {3,3}); NDArray<double> expV('c', {3,3}); nd4j::ops::svd<double> op; nd4j::ResultSet<double>* results = op.execute({&x}, {}, {0, 1, 16}); ASSERT_EQ(ND4J_STATUS_OK, results->status()); NDArray<double> *s = results->at(0); NDArray<double> *u = results->at(1); NDArray<double> *v = results->at(2); ASSERT_TRUE(expS.isSameShape(s)); ASSERT_TRUE(expU.isSameShape(u)); ASSERT_TRUE(expV.isSameShape(v)); delete results; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, atan2_test1) { NDArray<double> y('c', {2, 3, 4}, {-1.001 ,-0.915 ,-0.829 ,-0.743 ,-0.657 ,-0.571 ,-0.485 ,-0.399 ,-0.313 ,-0.227 ,-0.141 ,-0.055 ,0.031 ,0.117 ,0.203 ,0.289 ,0.375 ,0.461 ,0.547 ,0.633 ,0.719 ,0.805 ,0.891 ,0.977}); NDArray<double> x('c', {2, 3, 4}, {-0.51, -0.46, -0.41, -0.36, -0.31, -0.26, -0.21, -0.16, -0.11, -0.06, -0.01, 0.04, 0.09, 0.14, 0.19, 0.24, 0.29, 0.34, 0.39, 0.44, 0.49, 0.54, 0.59, 0.61}); NDArray<double> exp('c', {2,3,4}, {-2.04201, -2.03663, -2.03009, -2.02199,-2.01166, -1.99808, -1.97941, -1.95217,-1.90875, -1.8292 , -1.6416 , -0.942 , 0.33172, 0.69614, 0.81846, 0.87776, 0.91253, 0.93533, 0.95141, 0.96336, 0.97259, 0.97993, 0.98591, 1.01266,}); nd4j::ops::tf_atan2<double> op; auto result = op.execute({&y, &x}, {}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, atan2_test2) { NDArray<double> y('c', {2, 3, 4}, {-1.001 ,-0.915 ,-0.829 ,-0.743 ,-0.657 ,-0.571 ,-0.485 ,-0.399 ,-0.313 ,-0.227 ,-0.141 ,-0.055 ,0.031 ,0.117 ,0.203 ,0.289 ,0.375 ,0.461 ,0.547 ,0.633 ,0.719 ,0.805 ,0.891 ,0.977}); NDArray<double> x('c', { 3, 4}, {-1.05, -0.82, -0.639, -0.458, -0.277, -0.096, 0.085, 0.266, 0.447, 0.628, 0.809, 0.99}); NDArray<double> exp('c', {2,3,4}, {-2.38008, -2.30149, -2.22748, -2.1232 ,-1.96979, -1.73736, -1.3973 , -0.98279,-0.61088, -0.34685, -0.17256, -0.0555 , 3.11208, 2.99987, 2.83399, 2.57869, 2.207 , 1.77611, 1.41664, 1.17298, 1.01458, 0.90829, 0.8336 , 0.77879}); nd4j::ops::tf_atan2<double> op; auto result = op.execute({&y, &x}, {}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, atan2_test3) { NDArray<double> y('c', {2, 3, 4}, {-1.001 ,-0.915 ,-0.829 ,-0.743 ,-0.657 ,-0.571 ,-0.485 ,-0.399 ,-0.313 ,-0.227 ,-0.141 ,-0.055 ,0.031 ,0.117 ,0.203 ,0.289 ,0.375 ,0.461 ,0.547 ,0.633 ,0.719 ,0.805 ,0.891 ,0.977}); NDArray<double> x('c', { 3, 4}, {-1.05, -0.82, -0.639, -0.458, -0.277, -0.096, 0.085, 0.266, 0.447, 0.628, 0.809, 0.99}); NDArray<double> exp('c', {2,3,4}, {-2.33231, -2.41089, -2.48491, -2.58919,-2.74259, -2.97502, 2.9681 , 2.55359, 2.18167, 1.91765, 1.74335, 1.62629, -1.54128, -1.42907, -1.2632 , -1.00789,-0.63621, -0.20531, 0.15416, 0.39782, 0.55622, 0.6625 , 0.7372 , 0.79201}); nd4j::ops::tf_atan2<double> op; auto result = op.execute({&x, &y}, {}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, atan2_test4) { NDArray<double> y('c', {1, 3, 4}, {-1.001 ,-0.829 ,-0.657 ,-0.485 ,-0.313 ,-0.141 ,0.031 ,0.203 ,0.375 ,0.547 ,0.719 ,0.891}); NDArray<double> x('c', {2, 3, 1}, {-0.82, -0.458, -0.096, 0.085, 0.447, 0.809}); NDArray<double> exp('c', {2,3,4}, {-2.45527, -2.36165, -2.24628, -2.10492,-2.1703 , -1.86945, -1.50321, -1.15359,-0.25062, -0.17373, -0.13273, -0.10733, 3.05688, 3.03942, 3.01293, 2.9681 , 2.18167, 1.87635, 1.50156, 1.14451, 1.13674, 0.97626, 0.84423, 0.7372 }); nd4j::ops::tf_atan2<double> op; auto result = op.execute({&x, &y}, {}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, atan2_test5) { NDArray<double> y('c', {1, 3, 4}, {-1.001 ,-0.829 ,-0.657 ,-0.485 ,-0.313 ,-0.141 ,0.031 ,0.203 ,0.375 ,0.547 ,0.719 ,0.891}); NDArray<double> x('c', {2, 3, 1}, {-0.82, -0.458, -0.096, 0.085, 0.447, 0.809}); NDArray<double> exp('c', {2,3,4}, {-2.25712, -2.35074, -2.46611, -2.60747,-2.54209, -2.84294, 3.07401, 2.72438, 1.82141, 1.74453, 1.70353, 1.67813, -1.48608, -1.46862, -1.44214, -1.3973 ,-0.61088, -0.30556, 0.06924, 0.42629, 0.43405, 0.59453, 0.72657, 0.8336 }); nd4j::ops::tf_atan2<double> op; auto result = op.execute({&y, &x}, {}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, atan2_test6) { NDArray<double> y('c', {1, 3, 4}, {-1.001 ,-0.829 ,-0.657 ,-0.485 ,-0.313 ,-0.141 ,0.031 ,0.203 ,0.375 ,0.547 ,0.719 ,0.891}); NDArray<double> x('c', { 4}, {-0.82, -0.096, 0.085, 0.809}); NDArray<double> exp('c', {1,3,4}, {-2.25712, -1.68608, -1.44214, -0.54006,-2.77695, -2.16855, 0.34972, 0.24585, 2.71267, 1.74453, 1.45312, 0.8336 }); nd4j::ops::tf_atan2<double> op; auto result = op.execute({&y, &x}, {}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, range_test10) { NDArray<double> limit('c', {1, 3, 4}); limit = 5.; NDArray<double> exp('c', {5}, {0.,1.,2.,3.,4.}); nd4j::ops::range<double> op; auto result = op.execute({&limit}, {}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, range_test11) { NDArray<double> limit('c', {1, 3, 4}); NDArray<double> start('c', {2, 4}); limit = 5.; start = 0.5; NDArray<double> exp('c', {5}, {0.5,1.5,2.5,3.5,4.5}); nd4j::ops::range<double> op; auto result = op.execute({&start, &limit}, {}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; } ////////////////////////////////////////////////////////////////////////////// TEST_F(DeclarableOpsTests10, range_test12) { NDArray<double> exp('c', {9}, {0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5}); nd4j::ops::range<double> op; auto result = op.execute({}, {0.5, 5, 0.5}, {}); ASSERT_EQ(ND4J_STATUS_OK, result->status()); auto z = result->at(0); ASSERT_TRUE(exp.isSameShape(z)); ASSERT_TRUE(exp.equalsTo(z)); delete result; }
; Map 09 exec Map9Exec: lda MapVar3 bmi L32ED lda Map9Lamps+0*4 bne L32ED dec MapVar3 lda #VINE_DN ;=1 sta VineDir lda #$07 sta VineSpeed L32ED: lda Map9Lamps+1*4 bne L330A lda MapVar1 bmi L330A dec MapVar1 lda #$07 ldy #$17 jsr Entrance31aa lda #VINE_UP ;=0 sta VineDir lda #$07 sta VineSpeed L330A: lda PlayerMap9LampsCount bne L332B lda MapVar2 bmi L332B dec MapVar2 lda #VINE_UP sta VineDir lda #$07 sta VineSpeed jsr PlaySfxEntrance lda #$18 ;---------------------------------- ldx #$02 ;Removes spikes at the top of the ldy #$23 ;Moving vines on screen 9 jsr PlotChars ;---------------------------------- L332B: dec MapVar4 beq L3360 bpl L3337 lda #$01 sta MapVar4 L3337: lda Map9Lamps+2*4 ora Map9Lamps+3*4 bne L334F lda BUFCNT sta BUFSTR+1 dec BUFCNT cmp #$05 bcs L335D lda #$18 sta BUFCNT bne L335D L334F: lda BUFCNT sta BUFSTR+1 inc BUFCNT cmp #$18 bcc L335D lda #$04 sta BUFCNT L335D: jsr UpdateRat1 L3360: lda MapSomething beq L3367 jmp L33C5 L3367: inc ENDPT bmi L3396 lda ENDPT cmp #$03 beq L337B cmp #$07 beq L338E L3375: jsr PlotFireL378C jmp L3396 L337B: ldx Fire1X cpx #$14 bcs L3375 lda #$06 jsr PlotFireL378C inc Fire1X lda #$02 sta ENDPT bne L3375 L338E: lda #$10 sta Fire1X lda #$D0 sta ENDPT L3396: inc ENDPT+1 bmi L33C5 lda ENDPT+1 cmp #$03 beq L33AA cmp #$07 beq L33BD L33A4: jsr PlotFireL3794 jmp L33C5 L33AA: ldx Fire2X cpx #$14 bcs L33A4 lda #$06 jsr PlotFireL3794 inc Fire2X lda #$02 sta ENDPT+1 bne L33A4 L33BD: lda #$10 sta Fire2X lda #$D0 sta ENDPT+1 L33C5: jmp UpdateVines
COPY START 0 FIRST STL RETADR 17202D LDB #LENGTH 69202D BASE LENGTH CLOOP +JSUB RDREC 4B101036 LDA LENGTH 032026 COMP #0 290000 JEQ ENDFIL 332007 +JSUB WRREC 4B10105D J CLOOP 3F2FEC ENDFIL LDA EOF 032010 STA BUFFER 0F2016 LDA #3 010003 STA LENGTH 0F200D +JSUB WRREC 4B10105D J @RETADR 3E2003 EOF BYTE C’EOF’ 454F46 RETADR RESW 1 LENGTH RESW 1 BUFFER RESB 4096 . . READ RECORD INTO BUFFER . RDREC CLEAR X B410 CLEAR A B400 CLEAR S B440 +LDT #4096 75101000 RLOOP TD INPUT E32019 JEQ RLOOP 332FFA RD INPUT DB2013 COMPR A,S A004 JEQ EXIT 332008 STCH BUFFER,X 57C003 TIXR T B850 JLT RLOOP 3B2FEA EXIT STX LENGTH 134000 RSUB 4F0000 INPUT BYTE X'FI' F1 . . SUBROUTINE TO WRITE RECORD FROM BUFFER . WRREC CLEAR X B410 LDT LENGTH 774000 WLOOP TD OUTPUT E32011 JEQ WLOOP 332FFA LDCH BUFFER,X 53C003 WD OUTPUT DF2008 TIXR T B850 JLT WLOOP 3B2FEF RSUB 4F0000 OUTPUT BYTE X'05' 05 END FIRST
/******************************************************************************* * Copyright 2021 Intel Corporation * * 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 "dnnl_types.h" #include "common/bfloat16.hpp" #include "common/c_types_map.hpp" #include "common/dnnl_thread.hpp" #include "common/memory_tracking.hpp" #include "common/type_helpers.hpp" #include "common/utils.hpp" #include "cpu/x64/cpu_isa_traits.hpp" #include "cpu/x64/injectors/jit_uni_postops_injector.hpp" #include "cpu/x64/jit_brgemm_conv_utils.hpp" #include "cpu/x64/jit_generator.hpp" namespace dnnl { namespace impl { namespace cpu { namespace x64 { using namespace dnnl::impl::status; using namespace dnnl::impl::format_tag; using namespace dnnl::impl::memory_tracking::names; using namespace dnnl::impl::utils; using namespace prop_kind; using namespace data_type; namespace brgemm_convolution_utils { inline status_t init_tag(format_tag_t &tag, memory_desc_t &md, const memory_desc_wrapper &mdw, const format_tag_t tag_value, bool any_eligible) { if (mdw.format_kind() == format_kind::any) { if (any_eligible) { CHECK(memory_desc_init_by_tag(md, tag_value)); tag = tag_value; } else { tag = format_tag::undef; } } else { tag = mdw.matches_one_of_tag(tag_value); } if (tag != tag_value) return status::unimplemented; return status::success; } bool post_ops_ok(jit_brgemm_conv_conf_t &jcp, const primitive_attr_t &attr, const memory_desc_wrapper &dst_d) { using namespace injector; const auto &post_ops = attr.post_ops_; return injector::post_ops_ok(post_ops_ok_args_t(avx512_common, {sum, eltwise, binary}, post_ops, &dst_d, false /*sum_at_pos_0_only*/, false /*sum_requires_scale_one*/, {broadcasting_strategy_t::per_oc, broadcasting_strategy_t::scalar})); } status_t pick_tags(jit_brgemm_conv_conf_t &jcp, memory_desc_t &src_md, memory_desc_t &weights_md, memory_desc_t &dst_md, memory_desc_t &bias_md) { format_tag_t src_tag, dst_tag, wei_tag; dst_tag = pick(jcp.ndims - 3, nwc, nhwc, ndhwc); const memory_desc_wrapper src_d(&src_md); const memory_desc_wrapper weights_d(&weights_md); const memory_desc_wrapper dst_d(&dst_md); const memory_desc_wrapper bias_d(&bias_md); const bool with_groups = weights_d.ndims() == src_d.ndims() + 1; const bool is_1d = jcp.ndims == 3; const bool is_2d = jcp.ndims == 4; const bool is_3d = jcp.ndims == 5; if (jcp.wei_plain) { jcp.LDB = jcp.oc; if (is_3d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gdhwio : dhwio; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gdhwIo4i : dhwIo4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gdhwIo2i : dhwIo2i; } else return status::unimplemented; } else if (is_1d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gwio : wio; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gwIo4i : wIo4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gwIo2i : wIo2i; } else return status::unimplemented; } else { assert(is_2d); UNUSED(is_2d); if (jcp.wei_dt == f32) wei_tag = with_groups ? ghwio : hwio; else if (jcp.wei_dt == s8) wei_tag = with_groups ? ghwIo4i : hwIo4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? ghwIo2i : hwIo2i; } else return status::unimplemented; } } else { jcp.LDB = jcp.oc_block; if (jcp.oc_block == 64) { if (is_3d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gOdhwi64o : Odhwi64o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOdhwI64o4i : OdhwI64o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOdhwI64o2i : OdhwI64o2i; } else return status::unimplemented; } else if (is_1d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gOwi64o : Owi64o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOwI64o4i : OwI64o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOwI64o2i : OwI64o2i; } else return status::unimplemented; } else { assert(is_2d); UNUSED(is_2d); if (jcp.wei_dt == f32) wei_tag = with_groups ? gOhwi64o : Ohwi64o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOhwI64o4i : OhwI64o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOhwI64o2i : OhwI64o2i; } else return status::unimplemented; } } else if (jcp.oc_block == 48) { if (is_3d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gOdhwi48o : Odhwi48o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOdhwI48o4i : OdhwI48o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOdhwI48o2i : OdhwI48o2i; } else return status::unimplemented; } else if (is_1d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gOwi48o : Owi48o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOwI48o4i : OwI48o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOwI48o2i : OwI48o2i; } else return status::unimplemented; } else { assert(is_2d); UNUSED(is_2d); if (jcp.wei_dt == f32) wei_tag = with_groups ? gOhwi48o : Ohwi48o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOhwI48o4i : OhwI48o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOhwI48o2i : OhwI48o2i; } else return status::unimplemented; } } else if (jcp.oc_block == 32) { if (is_3d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gOdhwi32o : Odhwi32o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOdhwI32o4i : OdhwI32o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOdhwI32o2i : OdhwI32o2i; } else return status::unimplemented; } else if (is_1d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gOwi32o : Owi32o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOwI32o4i : OwI32o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOwI32o2i : OwI32o2i; } else return status::unimplemented; } else { assert(is_2d); UNUSED(is_2d); if (jcp.wei_dt == f32) wei_tag = with_groups ? gOhwi32o : Ohwi32o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOhwI32o4i : OhwI32o4i; else if (jcp.wei_dt == bf16) { wei_tag = with_groups ? gOhwI32o2i : OhwI32o2i; } else return status::unimplemented; } } else { if (is_3d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gOdhwi16o : Odhwi16o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOdhwI16o4i : OdhwI16o4i; else if (jcp.wei_dt == bf16) wei_tag = with_groups ? gOdhwI16o2i : OdhwI16o2i; else return status::unimplemented; } else if (is_1d) { if (jcp.wei_dt == f32) wei_tag = with_groups ? gOwi16o : Owi16o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOwI16o4i : OwI16o4i; else if (jcp.wei_dt == bf16) wei_tag = with_groups ? gOwI16o2i : OwI16o2i; else return status::unimplemented; } else { assert(is_2d); UNUSED(is_2d); if (jcp.wei_dt == f32) wei_tag = with_groups ? gOhwi16o : Ohwi16o; else if (jcp.wei_dt == s8) wei_tag = with_groups ? gOhwI16o4i : OhwI16o4i; else if (jcp.wei_dt == bf16) wei_tag = with_groups ? gOhwI16o2i : OhwI16o2i; else return status::unimplemented; } } } src_tag = dst_tag; const bool any_eligible = (jcp.prop_kind == prop_kind::forward_inference); CHECK(init_tag(jcp.src_tag, src_md, src_d, src_tag, any_eligible)); CHECK(init_tag(jcp.dst_tag, dst_md, dst_d, dst_tag, any_eligible)); CHECK(init_tag(jcp.wei_tag, weights_md, weights_d, wei_tag, true)); return status::success; } struct brg_blocking_t : public jit_brgemm_conv_conf_t { struct array_in_loop_t { dim_t itersize; float repeatn; float overlap; void set(dim_t iter_s, float rpt, float ovlp = 1.f) { itersize = iter_s; repeatn = rpt; overlap = ovlp; } }; struct loop_t { array_in_loop_t src; array_in_loop_t wei; array_in_loop_t dst; }; brg_blocking_t() : jit_brgemm_conv_conf_t() { init(); } brg_blocking_t(const jit_brgemm_conv_conf_t &jcp) : jit_brgemm_conv_conf_t(jcp) { init(); } void init() { ur = 0; eff = 0.f; nb_kd = 0; nb_kh = 0; nb_kw = 0; is_os_block = false; sp = 0; sp_block = 0; nb_sp = 0; eff = 0; } int ur; int nb_kd, nb_kh, nb_kw; float eff; bool is_os_block; static unsigned L1; static unsigned L2; static unsigned L3; static cpu_isa_t isa; // These are rough estimates of the latency (relative) of access to various // cache levels. This is enough for an estimation of data access cost. // TODO: Improve memory access estimates static constexpr float L1_k = 1.f; static constexpr float L2_k = 3.f; static constexpr float L3_k = 15.f; // TODO: At the moment, we are primarily evaluating the fit of the data into // the L1/L2. Need to take into account the difference between the L3 and // memory. static constexpr float mem_k = 15.f; static constexpr int bench_iterations = 1; static constexpr int max_regs = 32; static constexpr int bcast_simd = 16; int sp, sp_block, nb_sp; void get_from_jcp(const jit_brgemm_conv_conf_t &jcp) { *this = jcp; } void save_to_jcp(jit_brgemm_conv_conf_t &jcp) const { jcp = *this; } int estimate_brgemm_ur(int spb) const; int get_brgemm_ur(const primitive_attr_t *attr, const memory_desc_t &dst_md, bool is_1x1) const; float io_k(dim_t src, dim_t wei, dim_t dst, float n, float pk, bool is_broadcast, bool is_shared) const; float io_k(const loop_t loop, const array_in_loop_t arr, float pk, bool is_broadcast, bool is_shared) const; void select_ic_block(); void update_blocks(); bool fast_check_oc_block() const; float est_eff(); void iterate_ker_block(brg_blocking_t &best_brgb, int kd_block, int kh_block, bool maybe_use_buffer, int max_ow_block_thr); void calc_blocks(); bool fast_check_oc_block_1x1() const; float est_eff_1x1(); void calc_blocks_1x1(); // utils static int get_inp_size( int max_src_size, int dst_size, int k, int stride, int dilate) { auto adj_str = nstl::min(k, stride); const auto res = nstl::min(max_src_size, calculate_end_padding(0, dst_size, 0, adj_str, calculate_extended_filter_size(k, dilate))); return res; } static float squeeze_val(float eff, float koeff) { if (koeff <= 0) return 1; if (koeff == 1) return eff; const auto k = 1.f / koeff; return (k > 1.f) ? (k - 1 + eff) / k : eff * koeff; } static int estimate_ur(int oc_block) { const auto est_ur = (oc_block == 64) ? 6 : ((oc_block == 48) ? 9 : ((oc_block == 32) ? 14 : 28)); return est_ur; } int inp_w(int out_w, int ker_w) const { return get_inp_size(iw, out_w, ker_w, stride_w, dilate_w); } int rnd_simd(int val) const { return rnd_up(val, simd_w); } int rnd_inp_simd(int out_w, int ker_w, int vic) const { const auto vsp = inp_w(out_w, ker_w); return ((stride_w == 1 && vic >= ic) ? rnd_up(vsp * vic, simd_w) : vsp * rnd_up(vic, simd_w)); } static constexpr int MAXNLOOPS = 32; loop_t loop[MAXNLOOPS]; }; unsigned brg_blocking_t::L1; unsigned brg_blocking_t::L2; unsigned brg_blocking_t::L3; cpu_isa_t brg_blocking_t::isa; float brg_blocking_t::io_k(dim_t src, dim_t wei, dim_t dst, float n, float pk, bool is_broadcast, bool is_shared) const { if (n < 1) return 0; if (n == 1) return pk; const auto amount = src * src_dsz + wei * wei_dsz + dst * dst_dsz + (use_buffer ? dst * acc_dsz : 0); const auto amount_L1 = is_broadcast ? src * src_dsz : amount; const auto k = is_broadcast ? ((amount_L1 < L1) ? L1_k : ((amount < L2) ? L2_k : (is_shared ? L3_k : mem_k))) : ((amount < L2) ? L2_k : (is_shared ? L3_k : mem_k)); const auto cost = pk + k * (n - 1); return cost / n; } float brg_blocking_t::io_k(const loop_t loop, const array_in_loop_t arr, float pk, bool is_broadcast, bool is_shared) const { return io_k(loop.src.itersize, loop.wei.itersize, loop.dst.itersize, arr.repeatn * arr.overlap, pk, is_broadcast, is_shared); } void brg_blocking_t::select_ic_block() { auto max_simd_blocks = nstl::min(5 * simd_w, div_up(ic, simd_w)); const auto est_ur = nstl::min(sp_block, estimate_ur(oc_block)); const auto inp_ur = is_os_block ? est_ur : inp_w(est_ur, kw_block); if (kw_block > 1) { // try to fit src into L1 const auto inp_per_ic = (unsigned int)inp_ur * src_dsz; max_simd_blocks = saturate( 1, max_simd_blocks, (int)(L1 / (inp_per_ic * simd_w))); } { // try to fit all batch for ur into L2 const auto wei_per_ic = (unsigned int)kd_block * kh_block * kw_block * oc_block * wei_dsz; const auto inp_per_ic = (unsigned int)kd_block * kh_block * inp_ur * src_dsz; const auto out_size = (unsigned int)ur * oc_block * dst_dsz; max_simd_blocks = saturate(1, max_simd_blocks, (int)((L2 - out_size) / ((wei_per_ic + inp_per_ic) * simd_w))); } auto nb_simd = utils::div_up(ic, simd_w); const auto nb_icb_eff_threshold = 0.5f; auto simd_blocks = 1; for (int nb_icb = nstl::min(max_simd_blocks, nb_simd); nb_icb >= 1; nb_icb--) { auto nb_icb_eff = (float)nb_simd / rnd_up(nb_simd, nb_icb); if (nb_icb_eff >= nb_icb_eff_threshold) { simd_blocks = nb_icb; break; } } ic_block = simd_blocks * simd_w; nb_ic = utils::div_up(ic, ic_block); } int brg_blocking_t::estimate_brgemm_ur(int spb) const { // Simple simulation of brgemm_desc init brgemm_t brg; const auto LDA = (exec_type == exec_trans) ? stride_w * ic_block : stride_w * ic_without_padding; const auto LDB = oc_block; const auto LDC = use_buffer ? oc_block : oc_without_padding; const auto N = oc >= oc_block ? oc_block : oc; const auto K = ic >= ic_block ? ic_block : ic; const float alpha = 1.0; const float beta = 0.0; auto status = brgemm_desc_init(&brg, isa, brgemm_addr, src_dt, wei_dt, false, false, brgemm_row_major, alpha, beta, LDA, LDB, LDC, spb, N, K); return status == success ? brg.bd_block : 0; } int brg_blocking_t::get_brgemm_ur(const primitive_attr_t *attr, const memory_desc_t &dst_md, bool is_1x1) const { // Detailed simulation of brgemm convolution init brgemm_t brg; const auto LDA = (exec_type == exec_trans) ? stride_w * ic_block : stride_w * ic_without_padding; const auto LDB = oc_block; const auto LDC = (use_buffer) ? oc_block : oc_without_padding; const auto LDD = oc_without_padding; const float alpha = 1.0; const float beta = 1.0; const float beta_init = 0.0; const auto M = sp_block; const auto M_tail = is_os_block ? os % sp_block : ow % sp_block; const auto K = ic >= ic_block ? ic_block : 0; const auto K_tail = ic % ic_block; const auto N = oc >= oc_block ? oc_block : 0; const auto N_tail = oc % oc_block; status_t status = success; int res_ur = estimate_brgemm_ur(is_os_block ? os_block : ow_block); for (int i = 0; i < M; i++) { auto vM = i + 1; // init only needed brgemm descriptors if ((utils::one_of(exec_type, exec_trans, exec_vpad) || is_1x1) && vM != M && vM != M_tail) continue; for (int i_init = 0; i_init < 2; i_init++) { for (int i_N = 0; i_N < 2; i_N++) { for (int i_K = 0; i_K < 2; i_K++) { auto vbeta = (i_init) ? beta_init : beta; auto vN = (i_N) ? N_tail : N; auto vK = (i_K) ? K_tail : K; if (vN == 0 || vK == 0) continue; brgemm_strides_t brg_strides; brg_strides.stride_a = ic_without_padding * (dilate_w + 1) * src_dsz; //weights are padded by oc_block and last_ic_block const auto last_ic_block = (wei_dt == f32) ? 1 : ((wei_dt == bf16) ? 2 : 4); brg_strides.stride_b = rnd_up(ic, last_ic_block) * rnd_up(oc, oc_block) * wei_dsz; const auto strides_ptr = (brg_type == brgemm_strd) ? &brg_strides : nullptr; status = brgemm_desc_init(&brg, isa, brg_type, src_dt, wei_dt, false, false, brgemm_row_major, alpha, vbeta, LDA, LDB, LDC, vM, vN, vK, strides_ptr); if (status != success) break; brgemm_attr_t brgattr; brgattr.max_bs = max_batch; const auto max_vpad = (exec_type == exec_vpad) ? nstl::max(l_pad, r_pad) : 0; brgattr.max_top_vpad = max_vpad; brgattr.max_bottom_vpad = max_vpad; status = brgemm_desc_set_attr(&brg, brgattr); if (status != success) break; brg.with_sum = with_sum; status = brgemm_desc_set_postops( &brg, attr, &dst_md, LDD, bia_dt); if (status != success) break; } if (status != success) break; } if (status != success) break; } if (status != success) break; } return status == success ? res_ur : 0; } void brg_blocking_t::update_blocks() { nb_od = div_up(od, od_blk_size); nb_oh = div_up(oh, oh_blk_size); nb_ic = div_up(ic, ic_block); nb_oc = div_up(oc, oc_block); nb_kd = div_up(kd, kd_block); nb_kh = div_up(kh, kh_block); nb_kw = div_up(kw, kw_block); if (is_os_block) { nb_os = div_up(os, os_block); sp = os; sp_block = os_block; nb_sp = nb_os; } else { nb_ow = div_up(ow, ow_block); sp = ow; sp_block = ow_block; nb_sp = nb_ow; } } bool brg_blocking_t::fast_check_oc_block() const { // This function for reducing the number of blocking variants // TODO: eliminate heuristic in this function const auto rnd_oc = rnd_up(oc, 16); auto res = false; if (oc_block == 64) { res = (rnd_oc % oc_block == 0 && rnd_oc * wei_dsz < 192 * 4); } else if (oc_block == 48) { const bool big_spatial = id * ih * iw > 81 * stride_d * stride_h * stride_w; res = (rnd_oc % oc_block == 0 && rnd_oc * wei_dsz <= 384 * 4 && big_spatial); } else res = true; return res; } float brg_blocking_t::est_eff() { const auto ocblock = oc_block / 16; const auto od_block = od_blk_size; const auto oh_block = oh_blk_size; const auto brgemm_microkernel_eff = ((float)ocblock * ur) / ((ur + ocblock) * max_regs); const auto ur_eff = (float)sp_block / rnd_up(sp_block, ur); const auto brgemm_eff = squeeze_val( ur * (2.f - nstl::min(1.9f, (float)ur / sp_block)) / 64, 0.5f); const auto sp_amount = nb_od * nb_oh * nb_sp; const auto work_amount = mb * ngroups * nb_oc * sp_amount; const auto sp_eff = ((float)sp / rnd_up(sp, sp_block)); const auto thr_eff = (float)work_amount / utils::rnd_up(work_amount, nthr); const auto oc_block_eff = (float)oc / rnd_up(oc, oc_block); const auto job = div_up(work_amount, nthr); auto job_eff = 1.f; if (job < nthr) { std::vector<dim_t> thr_jobs(nthr); for (int ithr = 0; ithr < nthr; ithr++) { thr_jobs[ithr] = 0; if (ithr >= work_amount) continue; dim_t thr_job = 0; int start {0}, end {0}; balance211(work_amount, nthr, ithr, start, end); int n {0}, g {0}, ocb {0}, odp {0}, ohp {0}, spb {0}; if (loop_order == loop_ndhwgc) nd_iterator_init(start, n, mb, odp, od, ohp, oh, spb, nb_sp, g, ngroups, ocb, nb_oc); else if (loop_order == loop_ngcdhw) nd_iterator_init(start, n, mb, g, ngroups, ocb, nb_oc, odp, od, ohp, oh, spb, nb_sp); for (auto work = start; work < end; work++) { const int ocp = ocb * oc_block; const auto oc_sz = nstl::min(oc - ocp, oc_block); int sp_sz = 0; const int spp = spb * sp_block; sp_sz = nstl::min(sp - spp, sp_block); thr_job += sp_sz * oc_sz; if (loop_order == loop_ndhwgc) nd_iterator_step(n, mb, odp, od, ohp, oh, spb, nb_sp, g, ngroups, ocb, nb_oc); else if (loop_order == loop_ngcdhw) nd_iterator_step(n, mb, g, ngroups, ocb, nb_oc, odp, od, ohp, oh, spb, nb_sp); } thr_jobs[ithr] = thr_job; } dim_t max_job = 0; dim_t sum_job = 0; for (int ithr = 0; ithr < nthr; ithr++) { if (thr_jobs[ithr] > max_job) max_job = thr_jobs[ithr]; sum_job += thr_jobs[ithr]; } job_eff = max_job == 0 ? 1 : (float)sum_job / (max_job * nthr); } else { job_eff = thr_eff; } const auto ic_blocking_size = ic_block * nb_ic_blocking; const auto oc_blocking_size = oc_block * ic_blocking_size; int l = -1; // -- brgemm kernel: loop by simd_w -- l++; const auto inp_ur = inp_w(ur, kw_block); loop[l].src.set(inp_ur * simd_w, 1, bcast_simd); loop[l].dst.set(0, 1); loop[l].wei.set(oc_block, 1); // -- brgemm kernel: loop by kw in kw_block -- l++; auto src_is = rnd_inp_simd(ur, kw_block, ic_blocking_size); loop[l].src.set(src_is, 1, kw_block); loop[l].dst.set(0, 1); loop[l].wei.set(oc_blocking_size, 1); // -- brgemm kernel: loop by batch (grouped by kw_block) in ur -- l++; loop[l].src.set(src_is, 1); loop[l].dst.set(0, 1); auto wei_is = kw_block * oc_blocking_size; loop[l].wei.set(wei_is, 1); // -- brgemm kernel: loop by ur in sp_block -- l++; const auto nb_ur = div_up(sp_block, ur); loop[l].src.set(kd_block * kh_block * src_is, 1); loop[l].dst.set(ur * oc_block, 1); wei_is = kd_block * kh_block * kw_block * oc_blocking_size; loop[l].wei.set(wei_is, nb_ur); // -- harness: loop by k_blocks in ks -- l++; loop[l].src.set(kd_block * kh_block * rnd_inp_simd(sp_block, kw_block, ic_blocking_size), 1); loop[l].dst.set(sp_block * oc_block, nb_kd * nb_kh * nb_kw); loop[l].wei.set(wei_is, 1); // -- brgemm kernel: loop by ic_chunks -- l++; const auto ic_chunks = div_up(nb_ic, nb_ic_blocking); loop[l].src.set(kd * kh * rnd_inp_simd(sp_block, kw, ic_blocking_size), 1); loop[l].dst.set(sp_block * oc_block, ic_chunks); wei_is = kd * kh * kw * oc_blocking_size; loop[l].wei.set(wei_is, 1); const auto dim_oc = (loop_order == loop_ndhwgc) ? 1 : sp_amount; const auto nb_oc_thr = nstl::min(nb_oc, div_up(job, dim_oc)); const auto oc_thr = nstl::min(oc, nb_oc_thr * oc_block); const auto nsimd_oc_thr = div_up(oc_thr, simd_w); const auto dim_sp = (loop_order == loop_ndhwgc) ? ngroups * nb_oc : 1; const auto nb_sp_thr = nstl::min(nb_sp, div_up(job, dim_sp)); const auto sp_thr = nstl::min(sp, nb_sp_thr * sp_block); const auto dim_oh = nb_sp * dim_sp; const auto nb_oh_thr = nstl::min(nb_oh, div_up(job, dim_oh)); const auto oh_thr = nstl::min(oh, nb_oh_thr * oh_block); const auto dim_od = nb_oh * dim_oh; const auto nb_od_thr = nstl::min(nb_od, div_up(job, dim_od)); const auto od_thr = nstl::min(od, nb_od_thr * od_block); src_is = kd * kh * rnd_inp_simd(sp_block, kw, ic); auto wei_op = kd * kh * kw * ocblock * ic; if (loop_order == loop_ndhwgc) { // -- harness: loop by oc_block -- l++; loop[l].src.set(src_is, nb_oc_thr); loop[l].dst.set(sp_block * oc_block, 1); wei_is = kd * kh * kw * oc_block * ic; wei_op = kd * kh * kw * nsimd_oc_thr * ic; loop[l].wei.set(wei_is, 1); } // -- harness: loop by sp_blocks -- l++; loop[l].src.set(src_is, 1); const auto rnd_oc_for_sp = simd_w * ((loop_order == loop_ndhwgc) ? nsimd_oc_thr : ocblock); loop[l].dst.set(sp_block * rnd_oc_for_sp, 1); loop[l].wei.set(wei_op * simd_w, nb_sp_thr); // oh_block almost all is 1. TODO: manage oh_block != 1 // -- harness: loop by oh_blocks -- l++; src_is = kd * kh * rnd_inp_simd(sp_thr, kw, ic); loop[l].src.set(oh_block * src_is, 1); loop[l].dst.set(sp_thr * rnd_oc_for_sp, 1); loop[l].wei.set(wei_op * simd_w, nb_oh_thr); // od_block almost all is 1. TODO: manage oh_block != 1 // -- harness: loop by od_blocks -- l++; loop[l].src.set(od_block * oh_thr * src_is, 1); loop[l].dst.set(oh_thr * sp_thr * rnd_oc_for_sp, 1); loop[l].wei.set(wei_op * simd_w, nb_od_thr); if (loop_order != loop_ndhwgc) { // -- harness: loop by oc_block -- l++; loop[l].src.set(od_thr * oh_thr * src_is, nb_oc_thr); loop[l].dst.set(oc_block * od_thr * oh_thr * sp_thr, 1); loop[l].wei.set(kd * kh * kw * oc_block * ic, 1); } // -- harness: loop by mb -- l++; const auto mb_thr = nstl::min(mb, div_up(job, sp_amount * ngroups * nb_oc)); loop[l].src.set(od_thr * oh_thr * src_is, 1); loop[l].dst.set(od_thr * oh_thr * sp_thr * nsimd_oc_thr * simd_w, 1); loop[l].wei.set(kd * kh * kw * nsimd_oc_thr * simd_w * ic, mb_thr); const auto src_op = mb_thr * od_thr * oh_thr * sp_thr * kd * kh * kw * ic; const auto dst_op = mb_thr * od_thr * oh_thr * sp_thr * nsimd_oc_thr; wei_op = kd * kh * kw * nsimd_oc_thr * ic; // for "real" application set bench_iterations to 1 const auto iterations = bench_iterations; l++; loop[l].src.set(src_op, iterations); loop[l].dst.set(dst_op * simd_w, iterations); loop[l].wei.set(wei_op * simd_w, iterations); auto src_mem_k = mem_k; auto dst_mem_k = mem_k; auto wei_mem_k = mem_k; float src_rp = 1; float dst_rp = 1; float wei_rp = 1; for (auto il = l; il >= 0; il--) { src_mem_k = io_k(loop[il], loop[il].src, src_mem_k, true, loop_order == loop_ndhwgc ? false : true); dst_mem_k = io_k(loop[il], loop[il].dst, dst_mem_k, false, false); wei_mem_k = io_k(loop[il], loop[il].wei, wei_mem_k, false, loop_order == loop_ndhwgc ? true : false); src_rp *= loop[il].src.repeatn; dst_rp *= loop[il].dst.repeatn; wei_rp *= loop[il].wei.repeatn; } const auto src_ops = (src_op * src_rp) / iterations; const auto dst_ops = (dst_op * dst_rp) / iterations; const auto wei_ops = (wei_op * wei_rp) / iterations; const auto src_cost = src_mem_k * src_ops; const auto dst_cost = dst_mem_k * dst_ops; const auto wei_cost = wei_mem_k * wei_ops; const auto call_kernel_cost = 1000.f * job * ic_chunks * nb_kd * nb_kh * nb_kw; const auto cache_eff = ((dim_t)mb * od * oh * sp * ic * oc) / (nthr * (src_cost + dst_cost + wei_cost + call_kernel_cost)); const auto res_eff = oc_block_eff * brgemm_microkernel_eff * sp_eff * job_eff * ur_eff * cache_eff * brgemm_eff; return res_eff; } void brg_blocking_t::iterate_ker_block(brg_blocking_t &best_brgb, int kd_block_, int kh_block_, bool maybe_use_buffer, int max_ow_block_thr) { unsigned est_k_amount = ic * oc_block * wei_dsz; kd_block = kd_block_; kh_block = kh_block_; if (one_of(exec_type, exec_vpad, exec_trans)) { kw_block = kw; kd_block_pad = kd_block; kh_block_pad = kh_block; kw_block_pad = kw_block; } else { kw_block = (est_k_amount * kw < L2) ? kw : 1; kd_block_pad = kh_block >= kd ? kd : 1; kh_block_pad = kw_block >= kh ? kh : 1; kw_block_pad = kw; } if (exec_type == exec_vpad) { od_blk_size = 1; oh_blk_size = 1; } else if (exec_type == exec_trans) { // TODO: select od/oh block size for best balancing // and performance const auto w_block_size = 2 * src_dsz * ic * iwp + dst_dsz * oc_block * ow; const auto L2_available = L2 - wei_dsz * kd * kh * kw * ic * oc_block; if (idp * ihp * w_block_size > L2_available) { od_blk_size = utils::saturate(1, od, int(L2 / (ihp * w_block_size))); if (od_blk_size == 1) oh_blk_size = utils::saturate(1, oh, int(L2 / (w_block_size))); else oh_blk_size = oh; } else { od_blk_size = 1; oh_blk_size = oh; } } else { od_blk_size = 1; oh_blk_size = 1; } // --- Select ow_block ---- const auto max_ow_block_L2 = ow; auto start_ow_block = nstl::min(max_ow_block_thr, max_ow_block_L2); sp = ow; const auto start_sp_block = start_ow_block; auto prev_spb = 0; for (auto ns = 1; ns <= sp; ns++) { const auto spb = div_up(sp, ns); if (spb == prev_spb || spb > start_sp_block) continue; prev_spb = spb; ow_block = spb; sp_block = ow_block; select_ic_block(); use_buffer = maybe_use_buffer && (ic_block * nb_ic_blocking < ic || kd_block != kd || kh_block != kh || kw_block != kw || kd_block_pad != kd || kh_block_pad != kh || kw_block_pad != kw); if (exec_type == exec_base) use_buffer = use_buffer || (maybe_use_buffer && iwp != iw); ur = estimate_brgemm_ur(ow_block); update_blocks(); eff = est_eff(); if (eff > best_brgb.eff || best_brgb.eff == 0) best_brgb = *this; } } void brg_blocking_t::calc_blocks() { sp = ow; is_os_block = false; nb_ic_blocking = 1; // --- Select kernel blocking --- // if dst_dt != acc_dt and we need to store intermediate // results then we need the out buffer const auto maybe_use_buffer = (dst_dt != acc_dt || with_sum); std::vector<int> kd_blocks(1), kh_blocks(1); kd_blocks[0] = kd; kh_blocks[0] = kh; if (kd != 1) { kd_blocks.resize(2); kd_blocks[1] = 1; } if (kh != 1) { kh_blocks.resize(2); kh_blocks[1] = 1; } const auto thr_eff_threshold = 0.9f; const auto max_ow_block_thr = utils::saturate(1, ow, (int)div_up(mb * ngroups * nb_oc * os, thr_eff_threshold * nthr)); ow_block = -1; brg_blocking_t best_brgb = *this; for (const auto &kd_block : kd_blocks) { for (const auto &kh_block : kh_blocks) { iterate_ker_block(best_brgb, kd_block, kh_block, maybe_use_buffer, max_ow_block_thr); } } *this = best_brgb; ow_block = os_block = sp_block; update_blocks(); } bool brg_blocking_t::fast_check_oc_block_1x1() const { // This function for reducing the number of blocking variants // TODO: eliminate heuristic in this function const auto rnd_oc = rnd_up(oc, 16); auto res = false; if (oc_block == 64) { const auto big_spatial = od * oh * ow >= 64 * stride_d * stride_h * stride_w; res = (rnd_oc % oc_block == 0 && big_spatial); } else if (oc_block == 48) { const auto oc_block_eff = (float)oc / rnd_up(oc, oc_block); res = (oc_block_eff >= 0.95); } else res = true; return res; } float brg_blocking_t::est_eff_1x1() { const auto ocblock = oc_block / 16; const auto od_block = od_blk_size; const auto oh_block = oh_blk_size; const auto brgemm_microkernel_eff = ((float)ocblock * ur) / ((ur + ocblock) * max_regs); const auto ur_eff = (float)sp_block / rnd_up(sp_block, ur); const auto brgemm_eff = squeeze_val( ur * (2.f - nstl::min(1.9f, (float)ur / sp_block)) / 64, 0.5f); const auto sp_amount = is_os_block ? div_up(nb_os, nb_os_blocking) : nb_od * nb_oh * nb_sp; const auto work_amount = mb * ngroups * nb_oc * sp_amount; const auto sp_eff = (float)sp / rnd_up(sp, sp_block); const auto thr_eff = (float)work_amount / utils::rnd_up(work_amount, nthr); const auto oc_block_eff = (float)oc / rnd_up(oc, oc_block); const auto job = div_up(work_amount, nthr); const auto dim_oc = (loop_order == loop_ndhwgc) ? 1 : sp_amount; const auto nb_oc_thr = nstl::min(nb_oc, div_up(job, dim_oc)); const auto oc_thr = nstl::min(oc, nb_oc_thr * oc_block); const auto nsimd_oc_thr = div_up(oc_thr, simd_w); const auto dim_sp = (loop_order == loop_ndhwgc) ? ngroups * nb_oc : 1; const auto nb_sp_thr = nstl::min(nb_sp, div_up(job, dim_sp)); const auto sp_thr = nstl::min(sp, nb_sp_thr * sp_block); const auto dim_oh = nb_sp * dim_sp; const auto nb_oh_thr = nstl::min(nb_oh, div_up(job, dim_oh)); const auto oh_thr = is_os_block ? 1 : nstl::min(oh, nb_oh_thr * oh_block); const auto dim_od = nb_oh * dim_oh; const auto nb_od_thr = nstl::min(nb_od, div_up(job, dim_od)); const auto od_thr = is_os_block ? 1 : nstl::min(od, nb_od_thr * od_block); auto job_eff = 1.f; if (job < nthr) { std::vector<dim_t> thr_jobs(nthr); for (int ithr = 0; ithr < nthr; ithr++) { thr_jobs[ithr] = 0; if (ithr >= work_amount) continue; dim_t thr_job = 0; int start {0}, end {0}; balance211(work_amount, nthr, ithr, start, end); int n {0}, g {0}, ocb {0}, oss {0}, odp {0}, ohp {0}, spb {0}; if (loop_order == loop_ndhwgc) { if (is_os_block) nd_iterator_init(start, n, mb, oss, sp_amount, g, ngroups, ocb, nb_oc); else nd_iterator_init(start, n, mb, odp, od, ohp, oh, spb, nb_sp, g, ngroups, ocb, nb_oc); } else if (loop_order == loop_ngcdhw) { if (is_os_block) nd_iterator_init(start, n, mb, g, ngroups, ocb, nb_oc, oss, sp_amount); else nd_iterator_init(start, n, mb, g, ngroups, ocb, nb_oc, odp, od, ohp, oh, spb, nb_sp); } for (auto work = start; work < end; work++) { const int ocp = ocb * oc_block; const auto oc_sz = nstl::min(oc - ocp, oc_block); int sp_sz = 0; if (is_os_block) { const auto osb_start = oss * nb_os_blocking; const auto osb_range = nstl::min(nb_os - osb_start, nb_os_blocking); for (int osb = 0; osb < osb_range; osb++) { const int osp = (osb_start + osb) * sp_block; sp_sz = nstl::min(os - osp, sp_block); } } else { const int spp = spb * sp_block; sp_sz = nstl::min(sp - spp, sp_block); } thr_job += sp_sz * oc_sz; if (loop_order == loop_ndhwgc) { if (is_os_block) nd_iterator_step( n, mb, oss, sp_amount, g, ngroups, ocb, nb_oc); else nd_iterator_step(n, mb, odp, od, ohp, oh, spb, nb_sp, g, ngroups, ocb, nb_oc); } else if (loop_order == loop_ngcdhw) { if (is_os_block) nd_iterator_step( n, mb, g, ngroups, ocb, nb_oc, oss, sp_amount); else nd_iterator_step(n, mb, g, ngroups, ocb, nb_oc, odp, od, ohp, oh, spb, nb_sp); } } thr_jobs[ithr] = thr_job; } dim_t max_job = 0; dim_t sum_job = 0; for (int ithr = 0; ithr < nthr; ithr++) { if (thr_jobs[ithr] > max_job) max_job = thr_jobs[ithr]; sum_job += thr_jobs[ithr]; } job_eff = max_job == 0 ? 1 : (float)sum_job / (max_job * nthr); } else { job_eff = thr_eff; } const auto ic_blocking_size = ic_block * nb_ic_blocking; const auto oc_blocking_size = oc_block * ic_blocking_size; int l = -1; // -- brgemm kernel: loop by simd_w -- l++; loop[l].src.set(ur * simd_w, 1, bcast_simd); loop[l].dst.set(0, 1); loop[l].wei.set(oc_block, 1); // -- brgemm kernel: loop by ur in sp_block -- l++; const auto nb_ur = div_up(sp_block, ur); loop[l].src.set(ur * rnd_simd(ic_blocking_size), 1); loop[l].dst.set(ur * oc_block, 1); loop[l].wei.set(oc_blocking_size, nb_ur); // -- brgemm kernel: loop by ic_chunks -- l++; const auto ic_chunks = div_up(nb_ic, nb_ic_blocking); loop[l].src.set(sp_block * ic_blocking_size, 1); loop[l].dst.set(sp_block * oc_block, ic_chunks); auto wei_is = oc_blocking_size; auto wei_op = ocblock * ic; loop[l].wei.set(wei_is, 1); if (loop_order == loop_ndhwgc) { // -- harness: loop by oc_block -- l++; loop[l].src.set(sp_block * rnd_simd(ic), nb_oc_thr); loop[l].dst.set(sp_block * oc_block, 1); wei_is = oc_block * ic; wei_op = nsimd_oc_thr * ic; loop[l].wei.set(wei_is, 1); } const auto rnd_oc_for_sp = simd_w * ((loop_order == loop_ndhwgc) ? nsimd_oc_thr : ocblock); if (is_os_block) { // -- harness: loop by os_blocks -- l++; loop[l].src.set(sp_block * ic_blocking_size, 1); loop[l].dst.set(sp_block * rnd_oc_for_sp, 1); loop[l].wei.set(wei_op * simd_w, nb_sp_thr); } else { // -- harness: loop by sp_blocks -- l++; loop[l].src.set(sp_block * ic_blocking_size, 1); loop[l].dst.set(sp_block * rnd_oc_for_sp, 1); loop[l].wei.set(wei_op * simd_w, nb_sp_thr); // -- harness: loop by oh_blocks -- l++; loop[l].src.set(oh_block * sp_thr * rnd_simd(ic_blocking_size), 1); loop[l].dst.set(oh_block * sp_thr * rnd_oc_for_sp, 1); loop[l].wei.set(wei_op * simd_w, nb_oh_thr); // -- harness: loop by od_blocks -- l++; loop[l].src.set( od_block * oh_thr * sp_thr * rnd_simd(ic_blocking_size), 1); loop[l].dst.set(od_block * oh_thr * sp_thr * rnd_oc_for_sp, 1); loop[l].wei.set(wei_op * simd_w, nb_od_thr); } if (loop_order != loop_ndhwgc) { // -- harness: loop by oc_block -- l++; loop[l].src.set(od_thr * oh_thr * rnd_simd(sp_thr * ic_blocking_size), nb_oc_thr); loop[l].dst.set(oc_block * od_thr * oh_thr * sp_thr, 1); loop[l].wei.set(oc_block * ic, 1); } // -- harness: loop by mb -- l++; const auto mb_thr = nstl::min(mb, div_up(job, sp_amount * ngroups * nb_oc)); loop[l].src.set(od_thr * oh_thr * sp_thr * rnd_simd(ic_blocking_size), 1); loop[l].dst.set(nsimd_oc_thr * simd_w * od_thr * oh_thr * sp_thr, 1); loop[l].wei.set(nsimd_oc_thr * ic * simd_w, mb_thr); const auto src_op = mb_thr * od_thr * oh_thr * sp_thr * ic_blocking_size; const auto dst_op = mb_thr * nsimd_oc_thr * od_thr * oh_thr * sp_thr; wei_op = nsimd_oc_thr * ic; // for "real" application set bench_iterations to 1 const auto iterations = bench_iterations; l++; loop[l].src.set(src_op, iterations); loop[l].dst.set(dst_op * simd_w, iterations); loop[l].wei.set(wei_op * simd_w, iterations); auto src_mem_k = mem_k; auto dst_mem_k = mem_k; auto wei_mem_k = mem_k; float src_rp = 1; float dst_rp = 1; float wei_rp = 1; for (auto il = l; il >= 0; il--) { src_mem_k = io_k(loop[il], loop[il].src, src_mem_k, true, false); dst_mem_k = io_k(loop[il], loop[il].dst, dst_mem_k, false, false); wei_mem_k = io_k(loop[il], loop[il].wei, wei_mem_k, false, true); src_rp *= loop[il].src.repeatn; dst_rp *= loop[il].dst.repeatn; wei_rp *= loop[il].wei.repeatn; } const auto src_ops = (src_op * src_rp) / iterations; const auto dst_ops = (dst_op * dst_rp) / iterations; const auto wei_ops = (wei_op * wei_rp) / iterations; const auto src_cost = src_mem_k * src_ops; const auto dst_cost = dst_mem_k * dst_ops; const auto wei_cost = wei_mem_k * wei_ops; const auto call_kernel_cost = 1000.f * job * ic_chunks; const auto up_sp_size = is_os_block ? 1 : od * oh; const auto cache_eff = ((dim_t)mb * up_sp_size * sp * ic * oc) / (nthr * (src_cost + dst_cost + wei_cost + call_kernel_cost)); const auto res_eff = oc_block_eff * brgemm_microkernel_eff * sp_eff * job_eff * ur_eff * cache_eff * brgemm_eff; return res_eff; } void brg_blocking_t::calc_blocks_1x1() { if (stride_d == 1 && stride_h == 1) { sp = os; is_os_block = true; } else { sp = ow; is_os_block = false; } od_blk_size = 1; oh_blk_size = 1; kd_block = kh_block = kw_block = 1; kd_block_pad = kh_block_pad = kw_block_pad = 1; nb_ic_blocking = 1; const auto thr_eff_threshold = 0.9f; const auto max_sp_block_L2 = os; // TODO: nb_os_blocking always is 1 for now. Update this code nb_os_blocking = 1; int start_sp_block = 0; if (stride_d == 1 && stride_h == 1) { ow_block = 0; const auto max_os_block_thr = nstl::max( div_up(2048, oc_block), (int)div_up(mb * ngroups * os, nthr)); const auto max_os_block_L2 = max_sp_block_L2; auto max_os_block_aliasing = 1000000 / nthr; if ((oc_without_padding * os * dst_dsz) % 4096 == 0) { max_os_block_aliasing /= 1; for (auto cur_oc = oc_without_padding; max_os_block_aliasing * dst_dsz > 400 && cur_oc % 2 == 0 && cur_oc * os * dst_dsz >= 4096; cur_oc /= 2) { max_os_block_aliasing /= 2; } max_os_block_aliasing += max_os_block_aliasing % 2 ? 0 : 1; } max_os_block_aliasing = nstl::min(div_up(1001, dst_dsz), max_os_block_aliasing); start_sp_block = utils::saturate(1, os, nstl::min(nstl::min(max_os_block_thr, max_os_block_L2), max_os_block_aliasing)); } else { os_block = 0; const auto max_ow_block_thr = utils::saturate(1, ow, (int)div_up( mb * ngroups * nb_oc * os, thr_eff_threshold * nthr)); const auto max_ow_block_L2 = max_sp_block_L2; start_sp_block = utils::saturate( 1, ow, nstl::min(max_ow_block_thr, max_ow_block_L2)); } brg_blocking_t best_brgb = *this; auto prev_spb = 0; for (auto ns = 1; ns <= sp; ns++) { const auto spb = div_up(sp, ns); if (spb == prev_spb || spb > start_sp_block) continue; prev_spb = spb; if (is_os_block) os_block = spb; else ow_block = spb; select_ic_block(); ur = estimate_brgemm_ur(spb); update_blocks(); use_buffer = (dst_dt != acc_dt || with_sum) && (ic_block * nb_ic_blocking < ic); eff = est_eff_1x1(); if (eff > best_brgb.eff || best_brgb.eff == 0) { best_brgb = *this; } } *this = best_brgb; os_block = ow_block = sp_block; update_blocks(); } status_t init_jcp(jit_brgemm_conv_conf_t &jcp, cpu_isa_t isa, const convolution_desc_t &cd, memory_desc_t &src_md, memory_desc_t &weights_md, memory_desc_t &dst_md, memory_desc_t &bias_md, const primitive_attr_t &attr, int nthreads) { using namespace prop_kind; brg_blocking_t::L1 = platform::get_per_core_cache_size(1); brg_blocking_t::L2 = platform::get_per_core_cache_size(2); brg_blocking_t::L3 = platform::get_per_core_cache_size(2); brg_blocking_t::isa = isa; if (!mayiuse(avx512_core)) return status::unimplemented; const memory_desc_wrapper src_d(&src_md); const memory_desc_wrapper weights_d(&weights_md); const memory_desc_wrapper dst_d(&dst_md); const memory_desc_wrapper bias_d(&bias_md); const bool with_groups = weights_d.ndims() == src_d.ndims() + 1; int ndims = src_d.ndims(); jcp = zero<decltype(jcp)>(); jcp.ndims = ndims; jcp.prop_kind = cd.prop_kind; jcp.ngroups = with_groups ? weights_d.dims()[0] : 1; jcp.mb = src_d.dims()[0]; jcp.oc_without_padding = dst_d.dims()[1]; jcp.oc = jcp.oc_without_padding / jcp.ngroups; jcp.ic_without_padding = src_d.dims()[1]; jcp.ic = jcp.ic_without_padding / jcp.ngroups; jcp.id = (ndims == 5) ? src_d.dims()[2] : 1; jcp.ih = (ndims == 3) ? 1 : src_d.dims()[ndims - 2]; jcp.iw = src_d.dims()[ndims - 1]; jcp.od = (ndims == 5) ? dst_d.dims()[2] : 1; jcp.oh = (ndims == 3) ? 1 : dst_d.dims()[ndims - 2]; jcp.ow = dst_d.dims()[ndims - 1]; jcp.kd = (ndims == 5) ? weights_d.dims()[with_groups + 2] : 1; jcp.kh = (ndims == 3) ? 1 : weights_d.dims()[with_groups + ndims - 2]; jcp.kw = weights_d.dims()[with_groups + ndims - 1]; jcp.f_pad = (ndims == 5) ? cd.padding[0][0] : 0; jcp.t_pad = (ndims == 3) ? 0 : cd.padding[0][ndims - 4]; jcp.l_pad = cd.padding[0][ndims - 3]; jcp.stride_d = (ndims == 5) ? cd.strides[0] : 1; jcp.stride_h = (ndims == 3) ? 1 : cd.strides[ndims - 4]; jcp.stride_w = cd.strides[ndims - 3]; jcp.dilate_d = (ndims == 5) ? cd.dilates[0] : 0; jcp.dilate_h = (ndims == 3) ? 0 : cd.dilates[ndims - 4]; jcp.dilate_w = cd.dilates[ndims - 3]; jcp.os = jcp.od * jcp.oh * jcp.ow; int ext_kd = calculate_extended_filter_size(jcp.kd, jcp.dilate_d); int ext_kh = calculate_extended_filter_size(jcp.kh, jcp.dilate_h); int ext_kw = calculate_extended_filter_size(jcp.kw, jcp.dilate_w); jcp.back_pad = calculate_end_padding( jcp.f_pad, jcp.od, jcp.id, jcp.stride_d, ext_kd); jcp.b_pad = calculate_end_padding( jcp.t_pad, jcp.oh, jcp.ih, jcp.stride_h, ext_kh); jcp.r_pad = calculate_end_padding( jcp.l_pad, jcp.ow, jcp.iw, jcp.stride_w, ext_kw); jcp.with_bias = cd.bias_desc.format_kind != format_kind::undef; jcp.src_dt = cd.src_desc.data_type; jcp.dst_dt = cd.dst_desc.data_type; jcp.wei_dt = cd.weights_desc.data_type; jcp.bia_dt = jcp.with_bias ? cd.bias_desc.data_type : data_type::undef; // TODO: optimize depthwise convolutions (for now direct approach is faster) const bool is_depthwise = with_groups && everyone_is(1, jcp.ic, jcp.oc); if (is_depthwise) return status::unimplemented; // TODO: support s8 by brgemm convolutions if (jcp.src_dt == s8) return status::unimplemented; if (!IMPLICATION(jcp.wei_dt == s8, mayiuse(avx512_core_vnni))) return status::unimplemented; if (!IMPLICATION(jcp.wei_dt == bf16, mayiuse(avx512_core_bf16))) return status::unimplemented; if (one_of(jcp.src_dt, u8, s8)) { jcp.acc_dt = s32; } else if (one_of(jcp.src_dt, f32, bf16)) { jcp.acc_dt = f32; } else return status::unimplemented; jcp.src_dsz = types::data_type_size(jcp.src_dt); jcp.wei_dsz = types::data_type_size(jcp.wei_dt); jcp.dst_dsz = types::data_type_size(jcp.dst_dt); jcp.acc_dsz = types::data_type_size(jcp.acc_dt); jcp.bia_dsz = jcp.with_bias ? types::data_type_size(jcp.bia_dt) : 0; if (!post_ops_ok(jcp, attr, dst_d)) return status::unimplemented; jcp.simd_w = cpu_isa_traits<avx512_common>::vlen / jcp.src_dsz; const auto &p = attr.post_ops_; jcp.with_sum = p.find(primitive_kind::sum) != -1; const int eltwise_ind = p.find(primitive_kind::eltwise); jcp.with_eltwise = eltwise_ind != -1; const int binary_ind = p.find(primitive_kind::binary); jcp.with_binary = binary_ind != -1; if (jcp.with_bias) { if (bias_d.format_kind() == format_kind::any) CHECK(memory_desc_init_by_tag(bias_md, x)); } jcp.nthr = nthreads; // fast check data layout before spending time for blocking selection format_tag_t src_tag = pick(jcp.ndims - 3, nwc, nhwc, ndhwc); const bool any_eligible = (jcp.prop_kind == prop_kind::forward_inference); CHECK(init_tag(jcp.src_tag, src_md, src_d, src_tag, any_eligible)); return status::success; } status_t init_conf(jit_brgemm_conv_conf_t &jcp, cpu_isa_t isa, const convolution_desc_t &cd, memory_desc_t &src_md, memory_desc_t &weights_md, memory_desc_t &dst_md, memory_desc_t &bias_md, const primitive_attr_t &attr, int nthreads) { using namespace prop_kind; CHECK(init_jcp( jcp, isa, cd, src_md, weights_md, dst_md, bias_md, attr, nthreads)); const memory_desc_wrapper src_d(&src_md); const memory_desc_wrapper weights_d(&weights_md); const memory_desc_wrapper dst_d(&dst_md); const memory_desc_wrapper bias_d(&bias_md); jcp.idp = jcp.id + jcp.f_pad + jcp.back_pad; jcp.ihp = jcp.ih + jcp.t_pad + jcp.b_pad; jcp.iwp = jcp.iw + jcp.l_pad + jcp.r_pad; using namespace data_type; // ======================= blocking ================================= auto bcast_amount = (size_t)jcp.id * jcp.ih * jcp.iw * jcp.src_dsz; auto wei_amount = (size_t)jcp.oc * jcp.kd * jcp.kh * jcp.kw * jcp.wei_dsz; jcp.loop_order = (bcast_amount < wei_amount) ? loop_ngcdhw : loop_ndhwgc; const int min_oc_block = 16; int selected_ur = 0; MAYBE_UNUSED(selected_ur); auto try_exec_type = [&]() { brg_blocking_t best_brgb = zero<decltype(best_brgb)>(); best_brgb.oc_block = min_oc_block; brg_blocking_t cur_brgb = zero<decltype(best_brgb)>(); cur_brgb.get_from_jcp(jcp); auto start_ocb = 4; if (jcp.wei_plain) start_ocb = nstl::min(jcp.ic > 128 ? (jcp.ic > 256 ? 8 : 16) : 32, div_up(jcp.oc, 16)); start_ocb = nstl::min(div_up(jcp.oc, 16), start_ocb); auto finish_ocb = 1; for (auto ocb = start_ocb; ocb >= finish_ocb; ocb--) { cur_brgb.oc_block = ocb * 16; cur_brgb.nb_oc = utils::div_up(jcp.oc, cur_brgb.oc_block); if (!cur_brgb.fast_check_oc_block()) continue; cur_brgb.calc_blocks(); const bool is_1x1 = false; const auto ur = cur_brgb.get_brgemm_ur(&attr, dst_md, is_1x1); if (ur == 0) continue; cur_brgb.ur = ur; cur_brgb.eff = cur_brgb.est_eff(); if (cur_brgb.eff > best_brgb.eff) best_brgb = cur_brgb; } if (best_brgb.oc_block == 0 || best_brgb.ic_block == 0 || best_brgb.ow_block == 0) return false; best_brgb.save_to_jcp(jcp); selected_ur = best_brgb.ur; return true; }; //----------------------------------------------------------------------- jcp.exec_type = exec_base; jcp.brg_type = brgemm_addr; // TODO: Choose right type of BRGEMM bool try_exec_vpad = false; bool try_exec_trans = false; if (div_up(jcp.l_pad, jcp.stride_w) < jcp.kw && div_up(jcp.r_pad, jcp.stride_w) < jcp.kw) { try_exec_vpad = true; } // TODO: remove this restriction if (jcp.dilate_d == 0 && jcp.dilate_h == 0 && jcp.dilate_w == 0 && jcp.stride_w == 1) { // conv with transpose does not work well for 3d try_exec_trans = (jcp.l_pad > 0 || jcp.r_pad > 0) && (1.f - float(jcp.iw) / jcp.iwp) / nstl::max(1, jcp.iwp - jcp.iw) < 0.1f && jcp.id == 1; } // TODO: in future use (kd/kh/kw) and (kd/kh/kw)_pad blocks for more // precise calculation of jcp.max_batch jcp.max_batch = jcp.kd * jcp.kh * jcp.kw; //TODO: check wei plain jcp.wei_plain = false; jcp.wei_plain = jcp.exec_type == exec_vpad ? jcp.wei_plain : false; bool try_exec_type_res = false; if (try_exec_vpad) { jcp.exec_type = exec_vpad; try_exec_type_res = try_exec_type(); const auto iw_block = (jcp.ow_block - 1) * jcp.stride_w + 1; // to avoid case when both top and bottom virtual padding are non-zero // TODO: remove this restriction if (iw_block > jcp.iw) try_exec_type_res = false; } if (try_exec_type_res == false && try_exec_trans) { jcp.exec_type = exec_trans; try_exec_type_res = try_exec_type(); const auto iw_block = (jcp.ow_block - 1) * jcp.stride_w + 1; // transform kernel doesn't work well with big padding // TODO: remove this restriction if (iw_block < jcp.l_pad || iw_block < jcp.r_pad) try_exec_type_res = false; } if (try_exec_type_res == false) { jcp.exec_type = exec_base; try_exec_type_res = try_exec_type(); } // ============ end blocking =========================================== if (jcp.exec_type == exec_vpad) jcp.max_vpad = nstl::max(jcp.l_pad, jcp.r_pad); else jcp.max_vpad = 0; if (jcp.ow_block == 0 || jcp.ic_block == 0 || jcp.oc_block == 0) return status::unimplemented; // Configure matrix sizes jcp.M = jcp.ow >= jcp.ow_block ? jcp.ow_block : 0; jcp.K = jcp.ic >= jcp.ic_block ? jcp.ic_block : 0; jcp.N = jcp.oc >= jcp.oc_block ? jcp.oc_block : 0; jcp.M_tail = jcp.ow % jcp.ow_block; jcp.K_tail = jcp.ic % jcp.ic_block; jcp.N_tail = jcp.oc % jcp.oc_block; jcp.gemm_batch_size = jcp.nb_ic_blocking * nstl::max(jcp.kd_block * jcp.kh_block * jcp.kw_block, jcp.kd_block_pad * jcp.kh_block_pad * jcp.kw_block_pad); // to avoid cache concurrent write access from different threads size_t sc_size = sizeof(brgemm_batch_element_t); jcp.adjusted_batch_size = div_up(rnd_up(jcp.gemm_batch_size * sc_size, 4096), sc_size); jcp.LDA = (jcp.exec_type == exec_trans) ? jcp.stride_w * jcp.ic_block : jcp.stride_w * jcp.ic_without_padding; jcp.LDC = (jcp.use_buffer) ? jcp.oc_block : jcp.oc_without_padding; jcp.LDD = jcp.oc_without_padding; CHECK(pick_tags(jcp, src_md, weights_md, dst_md, bias_md)); const auto &oscales = attr.output_scales_; jcp.is_oc_scale = oscales.mask_ == 1 << 1; // only common and per-oc-channel scales are supported const bool oscales_ok = one_of(oscales.mask_, 0, 1 << 1); if (!oscales_ok) return status::unimplemented; jcp.buffer_size = jcp.LDC * jcp.M; jcp.nb_od = div_up(jcp.od, jcp.od_blk_size); jcp.nb_oh = div_up(jcp.oh, jcp.oh_blk_size); if (jcp.exec_type == exec_trans) { // TODO: this is rough estimation of buffer for transpose input jcp.inp_buffer_size = rnd_up((dim_t)jcp.idp * jcp.ihp * jcp.iwp * jcp.ngroups * jcp.nb_ic * jcp.ic_block, 4096); jcp.inp_buffer_mask_size = rnd_up((dim_t)jcp.nb_od * jcp.nb_oh * jcp.nb_ow * jcp.ngroups * jcp.nb_ic, 4096); } return status::success; } status_t init_1x1_conf(jit_brgemm_conv_conf_t &jcp, cpu_isa_t isa, const convolution_desc_t &cd, memory_desc_t &src_md, memory_desc_t &weights_md, memory_desc_t &dst_md, memory_desc_t &bias_md, const primitive_attr_t &attr, int nthreads) { using namespace prop_kind; CHECK(init_jcp( jcp, isa, cd, src_md, weights_md, dst_md, bias_md, attr, nthreads)); const memory_desc_wrapper src_d(&src_md); const memory_desc_wrapper weights_d(&weights_md); const memory_desc_wrapper dst_d(&dst_md); const memory_desc_wrapper bias_d(&bias_md); bool args_ok = true && jcp.f_pad <= 0 && jcp.back_pad <= 0 && jcp.t_pad <= 0 && jcp.b_pad <= 0 && jcp.l_pad <= 0 && jcp.r_pad <= 0 && jcp.kd == 1 && jcp.kh == 1 && jcp.kw == 1; if (!args_ok) return status::unimplemented; using namespace data_type; // ===================== blocking ================================= auto bcast_amount = (size_t)jcp.id * jcp.ih * jcp.iw * jcp.src_dsz; auto wei_amount = (size_t)jcp.oc * jcp.wei_dsz; jcp.loop_order = (bcast_amount < wei_amount) ? loop_ngcdhw : loop_ndhwgc; const auto min_oc_block = 16; jcp.brg_type = brgemm_addr; // TODO: Choose right type of BRGEMM // max_batch is 1 and max_vpad is 0 for 1x1 convolutions jcp.max_batch = 1; jcp.max_vpad = 0; jcp.wei_plain = false; brg_blocking_t best_brgb = zero<decltype(best_brgb)>(); best_brgb.oc_block = min_oc_block; brg_blocking_t cur_brgb = zero<decltype(cur_brgb)>(); cur_brgb.get_from_jcp(jcp); auto start_ocb = 4; if (jcp.wei_plain) start_ocb = nstl::min(jcp.ic > 128 ? (jcp.ic > 256 ? 8 : 16) : 32, div_up(jcp.oc, 16)); start_ocb = nstl::min(div_up(jcp.oc, 16), start_ocb); auto finish_ocb = 1; for (auto ocb = start_ocb; ocb >= finish_ocb; ocb--) { cur_brgb.oc_block = ocb * min_oc_block; cur_brgb.nb_oc = utils::div_up(jcp.oc, cur_brgb.oc_block); if (!cur_brgb.fast_check_oc_block_1x1()) continue; cur_brgb.calc_blocks_1x1(); const bool is_1x1 = true; const auto ur = cur_brgb.get_brgemm_ur(&attr, dst_md, is_1x1); if (ur == 0) continue; cur_brgb.ur = ur; cur_brgb.eff = cur_brgb.est_eff_1x1(); if (cur_brgb.eff > best_brgb.eff) best_brgb = cur_brgb; } best_brgb.save_to_jcp(jcp); // =============== end blocking ================================= jcp.brg_stride_a = jcp.ic_block * jcp.src_dsz; jcp.brg_stride_b = jcp.ic_block * jcp.oc * jcp.wei_dsz; if (jcp.ic_block == 0 || jcp.oc_block == 0) return status::unimplemented; // Configure matrix sizes if (best_brgb.is_os_block) { if (jcp.os_block == 0) return status::unimplemented; jcp.M = jcp.os_block; jcp.M_tail = jcp.os % jcp.os_block; } else { if (jcp.ow_block == 0) return status::unimplemented; jcp.M = jcp.ow_block; jcp.M_tail = jcp.ow % jcp.ow_block; } jcp.K = jcp.ic >= jcp.ic_block ? jcp.ic_block : 0; jcp.N = jcp.oc >= jcp.oc_block ? jcp.oc_block : 0; jcp.N_tail = jcp.oc % jcp.oc_block; jcp.K_tail = jcp.ic % jcp.ic_block; jcp.gemm_batch_size = jcp.nb_ic_blocking; // to avoid cache concurrent access from different threads size_t sc_size = sizeof(brgemm_batch_element_t); jcp.adjusted_batch_size = div_up(rnd_up(jcp.gemm_batch_size * sc_size, 4096), sc_size); jcp.LDA = jcp.stride_w * jcp.ic_without_padding; jcp.LDC = (jcp.use_buffer) ? jcp.oc_block : jcp.oc_without_padding; jcp.LDD = jcp.oc_without_padding; CHECK(pick_tags(jcp, src_md, weights_md, dst_md, bias_md)); const auto &oscales = attr.output_scales_; jcp.is_oc_scale = oscales.mask_ == 1 << 1; // only common and per-oc-channel scales are supported const bool oscales_ok = one_of(oscales.mask_, 0, 1 << 1); if (!oscales_ok) return status::unimplemented; // no inp buffer or brgemm_vpad for 1x1 jcp.exec_type = exec_base; jcp.inp_buffer_size = 0; jcp.buffer_size = jcp.LDC * jcp.M; return status::success; } void init_scratchpad(memory_tracking::registrar_t &scratchpad, const jit_brgemm_conv_conf_t &jcp) { if (jcp.brg_type == brgemm_addr || jcp.brg_type == brgemm_offs || (jcp.brg_type == brgemm_strd && jcp.exec_type == exec_vpad)) scratchpad.book(key_brgemm_primitive_batch, (size_t)jcp.nthr * jcp.adjusted_batch_size, sizeof(brgemm_batch_element_t), 64); if (jcp.exec_type == exec_trans) { size_t inp_buffer_size = (size_t)jcp.nthr * jcp.inp_buffer_size; scratchpad.book( key_conv_brgemm_inp_buffer, inp_buffer_size, jcp.src_dsz); size_t inp_buffer_mask_size = (size_t)jcp.nthr * jcp.inp_buffer_mask_size; scratchpad.book(key_conv_brgemm_inp_buffer_mask, inp_buffer_mask_size, sizeof(uint8_t)); } if (jcp.use_buffer) { scratchpad.book(key_brgemm_primitive_buffer, jcp.nthr * jcp.buffer_size, jcp.acc_dsz); } } } // namespace brgemm_convolution_utils } // namespace x64 } // namespace cpu } // namespace impl } // namespace dnnl
; A104879: Row sums of a sum-of-powers triangle. ; 1,2,4,8,17,40,106,316,1049,3830,15208,65072,297841,1449756,7468542,40555748,231335961,1381989882,8623700812,56078446616,379233142801,2662013133296,19362917622002,145719550012300,1133023004941273,9090156910550110,75161929739797520 mov $14,$0 mov $16,$0 add $16,1 lpb $16,1 clr $0,14 mov $0,$14 sub $16,1 sub $0,$16 lpb $0,1 sub $0,1 mov $2,$0 add $6,1 pow $2,$6 add $1,$2 lpe add $1,1 add $15,$1 lpe mov $1,$15
map_header CeladonMart5F, CELADON_MART_5F, LOBBY, 0 end_map_header
//-------------------------------------------------------------------------- // Copyright 2021 Yohan Sandun // // 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 "lexer.h" Lexer::Lexer(String* code) { code_ = code; Advance(); } Lexer::~Lexer() { if (error_ != nullptr) delete error_; } void Lexer::Advance(int amount) { index_ += amount; current_column_++; if (index_ < code_->length_) { current_char_ = code_->ptr_[index_]; if (current_char_ == '\n') { current_line_++; current_column_ = 0; } return; } current_char_ = '\0'; } char Lexer::Peek(int amount) { if (index_ + amount < code_->length_) return code_->ptr_[index_ + amount];; return '\0'; } List<Token*>* Lexer::GenerateTokens() { List<Token*>* tokens = new List<Token*>(); while (current_char_ != '\0') { if (current_char_ == ' ' || current_char_ == '\t') Advance(); else if (current_char_ == '\r') { if (Peek() == '\n') { tokens->Add(new Token(Token::Type::kNewline, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kNewline, current_line_, current_column_)); Advance(); } } else if (current_char_ == '\n' || current_char_ == ';') { tokens->Add(new Token(Token::Type::kNewline, current_line_, current_column_)); Advance(); } else if (current_char_ == '+') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kPlusEq, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kPlus, current_line_, current_column_)); Advance(); } } else if (current_char_ == '-') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kMinusEq, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kMinus, current_line_, current_column_)); Advance(); } } else if (current_char_ == '*') { if (Peek() == '*') { if (Peek(2) == '=') { tokens->Add(new Token(Token::Type::kPowerEq, current_line_, current_column_)); Advance(3); } else { tokens->Add(new Token(Token::Type::kPower, current_line_, current_column_)); Advance(2); } } else if (Peek() == '=') { tokens->Add(new Token(Token::Type::kMultiplyEq, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kMultiply, current_line_, current_column_)); Advance(); } } else if (current_char_ == '/') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kDivisionEq, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kDivision, current_line_, current_column_)); Advance(); } } else if (current_char_ == '%') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kModulusEq, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kModulus, current_line_, current_column_)); Advance(); } } else if (current_char_ == '=') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kEqualsEquals, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kEquals, current_line_, current_column_)); Advance(); } } else if (current_char_ == '!') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kNotEquals, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kBooleanNot, current_line_, current_column_)); Advance(); } } else if (current_char_ == '&') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kBitwiseAndEq, current_line_, current_column_)); Advance(2); } else if (Peek() == '&') { tokens->Add(new Token(Token::Type::kBooleanAnd, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kBitwiseAnd, current_line_, current_column_)); Advance(); } } else if (current_char_ == '|') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kBitwiseOrEq, current_line_, current_column_)); Advance(2); } else if (Peek() == '|') { tokens->Add(new Token(Token::Type::kBooleanOr, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kBitwiseOr, current_line_, current_column_)); Advance(); } } else if (current_char_ == '~') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kBitwiseComplementEq, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kBitwiseComplement, current_line_, current_column_)); Advance(); } } else if (current_char_ == '^') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kBitwiseXorEquals, current_line_, current_column_)); Advance(2); } else { tokens->Add(new Token(Token::Type::kBitwiseXor, current_line_, current_column_)); Advance(); } } else if (current_char_ == '<') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kLessEquals, current_line_, current_column_)); Advance(2); } else if (Peek() == '<') { if (Peek(2) == '=') { tokens->Add(new Token(Token::Type::kBitwiseLeftShiftEq, current_line_, current_column_)); Advance(3); } else { tokens->Add(new Token(Token::Type::kBitwiseLeftShift, current_line_, current_column_)); Advance(2); } } else { tokens->Add(new Token(Token::Type::kLess, current_line_, current_column_)); Advance(); } } else if (current_char_ == '>') { if (Peek() == '=') { tokens->Add(new Token(Token::Type::kGreaterEquals, current_line_, current_column_)); Advance(2); } else if (Peek() == '>') { if (Peek(2) == '=') { tokens->Add(new Token(Token::Type::kBitwiseRightShiftEq, current_line_, current_column_)); Advance(3); } else { tokens->Add(new Token(Token::Type::kBitwiseRightShift, current_line_, current_column_)); Advance(2); } } else { tokens->Add(new Token(Token::Type::kGreater, current_line_, current_column_)); Advance(); } } else if (current_char_ == ',') { tokens->Add(new Token(Token::Type::kComma, current_line_, current_column_)); Advance(); } else if (current_char_ == '.') { tokens->Add(new Token(Token::Type::kDot, current_line_, current_column_)); Advance(); } else if (current_char_ == ':') { tokens->Add(new Token(Token::Type::kColon, current_line_, current_column_)); Advance(); } else if (current_char_ == '(') { tokens->Add(new Token(Token::Type::kLeftParen, current_line_, current_column_)); Advance(); } else if (current_char_ == ')') { tokens->Add(new Token(Token::Type::kRightParen, current_line_, current_column_)); Advance(); } else if (current_char_ == '[') { tokens->Add(new Token(Token::Type::kLeftSquare, current_line_, current_column_)); Advance(); } else if (current_char_ == ']') { tokens->Add(new Token(Token::Type::kRightSquare, current_line_, current_column_)); Advance(); } else if (current_char_ == '{') { tokens->Add(new Token(Token::Type::kLeftBrace, current_line_, current_column_)); Advance(); } else if (current_char_ == '}') { tokens->Add(new Token(Token::Type::kRightBrace, current_line_, current_column_)); Advance(); } else if (current_char_ >= '0' && current_char_ <= '9') tokens->Add(CreateNumber()); else if ((current_char_ >= 'A' && current_char_ <= 'Z') || (current_char_ >= 'a' && current_char_ <= 'z') || current_char_ == '_') tokens->Add(CreateIdentifier()); else if (current_char_ == '"') tokens->Add(CreateString()); else if (current_char_ == '\'') tokens->Add(CreateString('\'')); } tokens->Add(new Token(Token::Type::kEof, current_line_, current_column_)); return tokens; } Token* Lexer::CreateNumber() { int dot_count = 0; String* number = new String(5); U_INT32 start_column = current_column_; while (current_char_ != '\0' && ((current_char_ >= '0' && current_char_ <= '9') || current_char_ == '.')) { if (current_char_ == '.') dot_count++; number->Append(current_char_); Advance(); } if (dot_count != 0) return new Token(number, Token::Type::kFloat, current_line_, start_column, current_column_); return new Token(number, Token::Type::kInteger, current_line_, start_column, current_column_); //TODO : Throw an error when dot_count > 1 } Token* Lexer::CreateString(char string_char) { U_INT32 start_column = current_column_; Advance(); String* string = new String(10); while (current_char_ != '\0') { if (current_char_ == '\\') { Advance(); if (current_char_ == 'n') string->Append('\n'); else if (current_char_ == 't') string->Append('\t'); else if (current_char_ == 'b') string->Append('\b'); else string->Append(current_char_); Advance(); continue; } if (current_char_ == string_char) { Advance(); break; } string->Append(current_char_); Advance(); } return new Token(string, Token::Type::kString, current_line_, start_column, current_column_); } Token* Lexer::CreateIdentifier() { U_INT32 start_column = current_column_; String* id = new String(5); while (current_char_ != '\0' && ((current_char_ >= 'A' && current_char_ <= 'Z') || (current_char_ >= 'a' && current_char_ <= 'z') || ((current_char_ >= '0' && current_char_ <= '9') || current_char_ == '_'))) { id->Append(current_char_); Advance(); } if (id->Compare(UTF_8 "float")) { delete id; return new Token(Token::Type::kKwFloat, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "if")) { delete id; return new Token(Token::Type::kKwIf, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "elif")) { delete id; return new Token(Token::Type::kKwElif, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "else")) { delete id; return new Token(Token::Type::kKwElse, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "for")) { delete id; return new Token(Token::Type::kKwFor, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "to")) { delete id; return new Token(Token::Type::kKwTo, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "step")) { delete id; return new Token(Token::Type::kKwStep, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "method")) { delete id; return new Token(Token::Type::kKwMethod, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "return")) { delete id; return new Token(Token::Type::kKwReturn, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "while")) { delete id; return new Token(Token::Type::kKwWhile, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "int")) { delete id; return new Token(Token::Type::kKwInt, current_line_, start_column, current_column_); } else if (id->Compare(UTF_8 "string")) { delete id; return new Token(Token::Type::kKwString, current_line_, start_column, current_column_); } return new Token(id, Token::Type::kIdentifier, current_line_, start_column, current_column_); }
///////////////////////////////////////////////////////////////////////////////// // // Thor C++ Library // Copyright (c) 2011-2021 Jan Haller // // This software is provided 'as-is', without any express or implied // warranty. In no event will the authors be held liable for any damages // arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it // freely, subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; you must not // claim that you wrote the original software. If you use this software // in a product, an acknowledgment in the product documentation would be // appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, and must not be // misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // ///////////////////////////////////////////////////////////////////////////////// /// @file /// @brief Class template thor::ActionContext #ifndef THOR_ACTIONCONTEXT_HPP #define THOR_ACTIONCONTEXT_HPP namespace sf { class Window; class Event; } // namespace sf namespace thor { /// @addtogroup Input /// @{ /// @brief Structure containing information about the context in which an action has occurred /// @details This structure aggregates the events and the realtime input that were used to activate a specific action. Its objects /// are passed to the EventSystem class, which makes it possible for listener functions to get information about the action's trigger /// (e.g. the sf::Event::KeyPressed event for key presses). /// @see ActionMap::invokeCallbacks() template <typename ActionId> struct ActionContext { // Constructor ActionContext(sf::Window* window, const sf::Event* event, const ActionId& actionId) : window(window) , event(event) , actionId(actionId) { } /// @brief Pointer to sf::Window passed to the ActionMap::invokeCallbacks(). /// @details Use this variable to access the window inside a callback function. This pointer can be @a nullptr if you /// didn't specify a window when calling ActionMap::invokeCallbacks(). sf::Window* window; /// @brief Pointer to a sf::Event that contributed to this action's activation. /// @details Do not store the pointer. It is a null pointer if the action is not an event action (triggered by a sf::Event), but a realtime action (triggered /// by sf::Mouse, sf::Keyboard or sf::Joystick). The event type behind the pointer depends on the action: /// <table> /// <tr><th>How was the thor::%Action constructed?</th> <th>Possible values for @a event->type</th> </tr> /// <tr><td>Keyboard/mouse/joystick actions constructed with @a PressOnce</td> <td>KeyPressed, MouseButtonPressed or JoystickButtonPressed</td> </tr> /// <tr><td>Keyboard/mouse/joystick actions constructed with @a ReleaseOnce</td> <td>KeyReleased, MouseButtonReleased or JoystickButtonReleased</td> </tr> /// <tr><td>Keyboard/mouse/joystick actions constructed with @a Hold</td> <td>The pointer is @a nullptr and thus cannot be dereferenced</td> </tr> /// <tr><td>Miscellaneous SFML event actions</td> <td>The sf::Event::EventType specified in the Action constructor</td> </tr> /// <tr><td>Actions combined with ||, && and ! operators</td> <td>The one event type in the operands, unless the pointer is @a nullptr</td> </tr> /// </table> /// If this context is created for an Action that involves logical operators, then this @ref event member will represent zero or one involved event actions. /// Note that meaningful combinations of logical operators involve at most one %event action and possibly multiple realtime actions that can be active at the same time /// (see operator documentation). Example actions are <i>event && realtime</i> or <i>event || event</i>. Thus, only one context will be built for logical combinations, /// and at most one event will be stored in it. const sf::Event* event; /// @brief Identifier of the action. /// @details This is the ID referring to this action, used as argument for ActionMap::operator[] and EventSystem::connect(). ActionId actionId; }; /// @} // Extracts the ID of an ActionContext object (needed by EventSystem) template <typename ActionId> ActionId getEventId(const ActionContext<ActionId>& event) { return event.actionId; } } // namespace thor #endif // THOR_ACTIONCONTEXT_HPP
; ; Grundy Newbrain Specific libraries ; ; Stefano Bodrato - 19/05/2007 ; ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; put char to stream ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; void nb_putc( int stream, char byte ); ; ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ; ; ; $Id: nb_putc.asm,v 1.2 2015/01/19 01:33:00 pauloscustodio Exp $ ; PUBLIC nb_putc EXTERN ZCALL .nb_putc ld ix,2 add ix,sp ld a,(ix+0) ; byte ld e,(ix+2) ; stream call ZCALL defb $30 ; zoutput ret
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE194_Unexpected_Sign_Extension__fgets_malloc_82_bad.cpp Label Definition File: CWE194_Unexpected_Sign_Extension.label.xml Template File: sources-sink-82_bad.tmpl.cpp */ /* * @description * CWE: 194 Unexpected Sign Extension * BadSource: fgets Read data from the console using fgets() * GoodSource: Positive integer * Sinks: malloc * BadSink : Allocate memory using malloc() with the size of data * Flow Variant: 82 Data flow: data passed in a parameter to an virtual method called via a pointer * * */ #ifndef OMITBAD #include "std_testcase.h" #include "CWE194_Unexpected_Sign_Extension__fgets_malloc_82.h" namespace CWE194_Unexpected_Sign_Extension__fgets_malloc_82 { void CWE194_Unexpected_Sign_Extension__fgets_malloc_82_bad::action(short data) { /* Assume we want to allocate a relatively small buffer */ if (data < 100) { /* POTENTIAL FLAW: malloc() takes a size_t (unsigned int) as input and therefore if it is negative, * the conversion will cause malloc() to allocate a very large amount of data or fail */ char * dataBuffer = (char *)malloc(data); if (dataBuffer == NULL) {exit(-1);} /* Do something with dataBuffer */ memset(dataBuffer, 'A', data-1); dataBuffer[data-1] = '\0'; printLine(dataBuffer); free(dataBuffer); } } } #endif /* OMITBAD */
; A194029: Natural fractal sequence of the Fibonacci sequence (1,2,3,5,8,...). ; 1,1,1,2,1,2,3,1,2,3,4,5,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,9,10,11,12,13,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28 add $0,1 mov $2,1 mov $3,1 lpb $0 sub $0,$2 add $4,$2 mov $2,$3 mov $3,$4 lpe add $0,1
; A137410: a(n) = (5^n - 3) / 2. ; -1,1,11,61,311,1561,7811,39061,195311,976561,4882811,24414061,122070311,610351561,3051757811,15258789061,76293945311,381469726561,1907348632811,9536743164061,47683715820311,238418579101561,1192092895507811,5960464477539061,29802322387695311,149011611938476561,745058059692382811,3725290298461914061,18626451492309570311,93132257461547851561,465661287307739257811,2328306436538696289061,11641532182693481445311,58207660913467407226561,291038304567337036132811,1455191522836685180664061 mov $1,5 pow $1,$0 sub $1,3 div $1,2 mov $0,$1
// Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <vector> #include "prevector.h" #include "random.h" #include "serialize.h" #include "streams.h" #include "test/test_desire.h" #include <boost/test/unit_test.hpp> BOOST_FIXTURE_TEST_SUITE(PrevectorTests, TestingSetup) template<unsigned int N, typename T> class prevector_tester { typedef std::vector<T> realtype; realtype real_vector; realtype real_vector_alt; typedef prevector<N, T> pretype; pretype pre_vector; pretype pre_vector_alt; typedef typename pretype::size_type Size; bool passed = true; uint32_t insecure_rand_Rz_cache; uint32_t insecure_rand_Rw_cache; template <typename A, typename B> void local_check_equal(A a, B b) { local_check(a == b); } void local_check(bool b) { passed &= b; } void test() { const pretype& const_pre_vector = pre_vector; local_check_equal(real_vector.size(), pre_vector.size()); local_check_equal(real_vector.empty(), pre_vector.empty()); for (Size s = 0; s < real_vector.size(); s++) { local_check(real_vector[s] == pre_vector[s]); local_check(&(pre_vector[s]) == &(pre_vector.begin()[s])); local_check(&(pre_vector[s]) == &*(pre_vector.begin() + s)); local_check(&(pre_vector[s]) == &*((pre_vector.end() + s) - real_vector.size())); } // local_check(realtype(pre_vector) == real_vector); local_check(pretype(real_vector.begin(), real_vector.end()) == pre_vector); local_check(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector); size_t pos = 0; BOOST_FOREACH(const T& v, pre_vector) { local_check(v == real_vector[pos++]); } BOOST_REVERSE_FOREACH(const T& v, pre_vector) { local_check(v == real_vector[--pos]); } BOOST_FOREACH(const T& v, const_pre_vector) { local_check(v == real_vector[pos++]); } BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) { local_check(v == real_vector[--pos]); } CDataStream ss1(SER_DISK, 0); CDataStream ss2(SER_DISK, 0); ss1 << real_vector; ss2 << pre_vector; local_check_equal(ss1.size(), ss2.size()); for (Size s = 0; s < ss1.size(); s++) { local_check_equal(ss1[s], ss2[s]); } } public: void resize(Size s) { real_vector.resize(s); local_check_equal(real_vector.size(), s); pre_vector.resize(s); local_check_equal(pre_vector.size(), s); test(); } void reserve(Size s) { real_vector.reserve(s); local_check(real_vector.capacity() >= s); pre_vector.reserve(s); local_check(pre_vector.capacity() >= s); test(); } void insert(Size position, const T& value) { real_vector.insert(real_vector.begin() + position, value); pre_vector.insert(pre_vector.begin() + position, value); test(); } void insert(Size position, Size count, const T& value) { real_vector.insert(real_vector.begin() + position, count, value); pre_vector.insert(pre_vector.begin() + position, count, value); test(); } template<typename I> void insert_range(Size position, I first, I last) { real_vector.insert(real_vector.begin() + position, first, last); pre_vector.insert(pre_vector.begin() + position, first, last); test(); } void erase(Size position) { real_vector.erase(real_vector.begin() + position); pre_vector.erase(pre_vector.begin() + position); test(); } void erase(Size first, Size last) { real_vector.erase(real_vector.begin() + first, real_vector.begin() + last); pre_vector.erase(pre_vector.begin() + first, pre_vector.begin() + last); test(); } void update(Size pos, const T& value) { real_vector[pos] = value; pre_vector[pos] = value; test(); } void push_back(const T& value) { real_vector.push_back(value); pre_vector.push_back(value); test(); } void pop_back() { real_vector.pop_back(); pre_vector.pop_back(); test(); } void clear() { real_vector.clear(); pre_vector.clear(); } void assign(Size n, const T& value) { real_vector.assign(n, value); pre_vector.assign(n, value); } Size size() { return real_vector.size(); } Size capacity() { return pre_vector.capacity(); } void shrink_to_fit() { pre_vector.shrink_to_fit(); test(); } void swap() { real_vector.swap(real_vector_alt); pre_vector.swap(pre_vector_alt); test(); } ~prevector_tester() { BOOST_CHECK_MESSAGE(passed, "insecure_rand_Rz: " << insecure_rand_Rz_cache << ", insecure_rand_Rw: " << insecure_rand_Rw_cache); } prevector_tester() { seed_insecure_rand(); insecure_rand_Rz_cache = insecure_rand_Rz; insecure_rand_Rw_cache = insecure_rand_Rw; } }; BOOST_AUTO_TEST_CASE(PrevectorTestInt) { for (int j = 0; j < 64; j++) { BOOST_TEST_MESSAGE("PrevectorTestInt " << j); prevector_tester<8, int> test; for (int i = 0; i < 2048; i++) { int r = insecure_rand(); if ((r % 4) == 0) { test.insert(insecure_rand() % (test.size() + 1), insecure_rand()); } if (test.size() > 0 && ((r >> 2) % 4) == 1) { test.erase(insecure_rand() % test.size()); } if (((r >> 4) % 8) == 2) { int new_size = std::max<int>(0, std::min<int>(30, test.size() + (insecure_rand() % 5) - 2)); test.resize(new_size); } if (((r >> 7) % 8) == 3) { test.insert(insecure_rand() % (test.size() + 1), 1 + (insecure_rand() % 2), insecure_rand()); } if (((r >> 10) % 8) == 4) { int del = std::min<int>(test.size(), 1 + (insecure_rand() % 2)); int beg = insecure_rand() % (test.size() + 1 - del); test.erase(beg, beg + del); } if (((r >> 13) % 16) == 5) { test.push_back(insecure_rand()); } if (test.size() > 0 && ((r >> 17) % 16) == 6) { test.pop_back(); } if (((r >> 21) % 32) == 7) { int values[4]; int num = 1 + (insecure_rand() % 4); for (int i = 0; i < num; i++) { values[i] = insecure_rand(); } test.insert_range(insecure_rand() % (test.size() + 1), values, values + num); } if (((r >> 26) % 32) == 8) { int del = std::min<int>(test.size(), 1 + (insecure_rand() % 4)); int beg = insecure_rand() % (test.size() + 1 - del); test.erase(beg, beg + del); } r = insecure_rand(); if (r % 32 == 9) { test.reserve(insecure_rand() % 32); } if ((r >> 5) % 64 == 10) { test.shrink_to_fit(); } if (test.size() > 0) { test.update(insecure_rand() % test.size(), insecure_rand()); } if (((r >> 11) % 1024) == 11) { test.clear(); } if (((r >> 21) % 512) == 12) { test.assign(insecure_rand() % 32, insecure_rand()); } if (((r >> 15) % 64) == 3) { test.swap(); } } } } BOOST_AUTO_TEST_SUITE_END()
// // HUDErrorRenderer.hpp // G3M // // Created by Diego Gomez Deck on 9/28/13. // // #ifndef __G3M__HUDErrorRenderer__ #define __G3M__HUDErrorRenderer__ #include "ErrorRenderer.hpp" class HUDImageRenderer; class ErrorMessagesCustomizer { public: #ifdef C_CODE virtual ~ErrorMessagesCustomizer() {} #endif virtual std::vector<std::string> customize(const std::vector<std::string>& errors) = 0; }; class HUDErrorRenderer : public ErrorRenderer { private: HUDImageRenderer* _hudImageRenderer; ErrorMessagesCustomizer* _errorMessageCustomizer; public: HUDErrorRenderer(ErrorMessagesCustomizer* errorMessageCustomizer=NULL); ~HUDErrorRenderer() { } void setErrors(const std::vector<std::string>& errors); void initialize(const G3MContext* context); void render(const G3MRenderContext* rc, GLState* glState); void onResizeViewportEvent(const G3MEventContext* ec, int width, int height); void start(const G3MRenderContext* rc); void stop(const G3MRenderContext* rc); void onResume(const G3MContext* context); void onPause(const G3MContext* context); void onDestroy(const G3MContext* context); }; #endif
; ; jccolor.asm - colorspace conversion (AVX2) ; ; Copyright (C) 2009, 2016, D. R. Commander. ; Copyright (C) 2015, Intel Corporation. ; ; Based on the x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; [TAB8] %include "jsimdext.inc" ; -------------------------------------------------------------------------- %define SCALEBITS 16 F_0_081 equ 5329 ; FIX(0.08131) F_0_114 equ 7471 ; FIX(0.11400) F_0_168 equ 11059 ; FIX(0.16874) F_0_250 equ 16384 ; FIX(0.25000) F_0_299 equ 19595 ; FIX(0.29900) F_0_331 equ 21709 ; FIX(0.33126) F_0_418 equ 27439 ; FIX(0.41869) F_0_587 equ 38470 ; FIX(0.58700) F_0_337 equ (F_0_587 - F_0_250) ; FIX(0.58700) - FIX(0.25000) ; -------------------------------------------------------------------------- SECTION SEG_CONST alignz 32 GLOBAL_DATA(jconst_rgb_ycc_convert_avx2) EXTN(jconst_rgb_ycc_convert_avx2): PW_F0299_F0337 times 8 dw F_0_299, F_0_337 PW_F0114_F0250 times 8 dw F_0_114, F_0_250 PW_MF016_MF033 times 8 dw -F_0_168, -F_0_331 PW_MF008_MF041 times 8 dw -F_0_081, -F_0_418 PD_ONEHALFM1_CJ times 8 dd (1 << (SCALEBITS - 1)) - 1 + \ (CENTERJSAMPLE << SCALEBITS) PD_ONEHALF times 8 dd (1 << (SCALEBITS - 1)) alignz 32 ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 32 %include "jccolext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_RGB_RED %define RGB_GREEN EXT_RGB_GREEN %define RGB_BLUE EXT_RGB_BLUE %define RGB_PIXELSIZE EXT_RGB_PIXELSIZE %define jsimd_rgb_ycc_convert_avx2 jsimd_extrgb_ycc_convert_avx2 %include "jccolext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_RGBX_RED %define RGB_GREEN EXT_RGBX_GREEN %define RGB_BLUE EXT_RGBX_BLUE %define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE %define jsimd_rgb_ycc_convert_avx2 jsimd_extrgbx_ycc_convert_avx2 %include "jccolext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_BGR_RED %define RGB_GREEN EXT_BGR_GREEN %define RGB_BLUE EXT_BGR_BLUE %define RGB_PIXELSIZE EXT_BGR_PIXELSIZE %define jsimd_rgb_ycc_convert_avx2 jsimd_extbgr_ycc_convert_avx2 %include "jccolext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_BGRX_RED %define RGB_GREEN EXT_BGRX_GREEN %define RGB_BLUE EXT_BGRX_BLUE %define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE %define jsimd_rgb_ycc_convert_avx2 jsimd_extbgrx_ycc_convert_avx2 %include "jccolext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_XBGR_RED %define RGB_GREEN EXT_XBGR_GREEN %define RGB_BLUE EXT_XBGR_BLUE %define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE %define jsimd_rgb_ycc_convert_avx2 jsimd_extxbgr_ycc_convert_avx2 %include "jccolext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_XRGB_RED %define RGB_GREEN EXT_XRGB_GREEN %define RGB_BLUE EXT_XRGB_BLUE %define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE %define jsimd_rgb_ycc_convert_avx2 jsimd_extxrgb_ycc_convert_avx2 %include "jccolext-avx2.asm"
; A172472: a(n) = floor(sqrt(2*n^3)). ; 0,1,4,7,11,15,20,26,32,38,44,51,58,66,74,82,90,99,108,117,126,136,145,155,166,176,187,198,209,220,232,244,256,268,280,292,305,318,331,344,357,371,384,398,412,426,441,455,470,485,500,515,530,545,561,576,592,608,624,640,657,673,690,707,724,741,758,775,793,810,828,846,864,882,900,918,936,955,974,993,1011,1030,1050,1069,1088,1108,1127,1147,1167,1187,1207,1227,1247,1268,1288,1309,1330,1351,1372,1393,1414,1435,1456,1478,1499,1521,1543,1565,1587,1609,1631,1653,1676,1698,1721,1744,1766,1789,1812,1835,1859,1882,1905,1929,1952,1976,2000,2024,2048,2072,2096,2120,2144,2169,2193,2218,2242,2267,2292,2317,2342,2367,2393,2418,2443,2469,2494,2520,2546,2572,2598,2624,2650,2676,2702,2729,2755,2782,2808,2835,2862,2889,2916,2943,2970,2997,3024,3052,3079,3107,3134,3162,3190,3217,3245,3273,3302,3330,3358,3386,3415,3443,3472,3500,3529,3558,3587,3616,3645,3674,3703,3733,3762,3791,3821,3850,3880,3910,3940,3970,4000,4030,4060,4090,4120,4150,4181,4211,4242,4273,4303,4334,4365,4396,4427,4458,4489,4520,4551,4583,4614,4646,4677,4709,4741,4772,4804,4836,4868,4900,4932,4965,4997,5029,5062,5094,5127,5159,5192,5225,5258,5291,5324,5357,5390,5423,5456,5489,5523,5556 pow $0,3 mul $0,4 mov $2,1 lpb $0,1 sub $0,1 add $2,4 trn $0,$2 lpe add $3,$2 add $0,$3 mov $1,$0 div $1,4
ORG $100 C1 EQU $20D C2 EQU $20E N1L EQU $201 N1H EQU $200 N2L EQU $203 N2H EQU $202 D1 EQU $205 D2 EQU $206 D3 EQU $207 D4 EQU $208 D5 EQU $209 D6 EQU $20A D7 EQU $20B D8 EQU $20C RH1 EQU $210 RH2 EQU $211 RL1 EQU $212 RL2 EQU $213 CLR C1 CLR C2 LDAA N1L LDAB N2L MUL STD D1 LDAA N1H LDAB N2L MUL STD D3 LDAA N1L LDAB N2H MUL STD D5 LDAA N1H LDAB N2H MUL STD D7 LDAA D2 STAA RL2 LDAA D1 LDAB D4 ABA BCC NC1 INC C1 NC1 LDAB D6 ABA BCC NC2 INC C1 NC2 STAA RL1 LDAA D3 LDAB D5 ABA BCC NC3 INC C2 NC3 LDAB D8 ABA BCC NC4 INC C2 NC4 LDAB C1 ABA BCC NC5 INC C2 NC5 STAA RH2 LDAA D7 LDAB C2 ABA STAA RH1 FIN BRA FIN 
; ; 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" section .text globalsym(vpx_clear_system_state) sym(vpx_clear_system_state): emms ret
#include <torch/csrc/utils/disable_torch_function.h> #include <torch/csrc/utils/pybind.h> #include <torch/csrc/Exceptions.h> #include <torch/csrc/utils/python_strings.h> namespace torch { static thread_local bool enable_torch_function = true; PyObject* disabled_torch_function = nullptr; PyObject* disabled_torch_dispatch = nullptr; bool torch_function_enabled() { return enable_torch_function; } PyObject* disabled_torch_function_impl() { return disabled_torch_function; } void set_disabled_torch_function_impl(PyObject* value) { disabled_torch_function = value; } PyObject* disabled_torch_dispatch_impl() { return disabled_torch_dispatch; } void set_disabled_torch_dispatch_impl(PyObject* value) { disabled_torch_dispatch = value; } } typedef struct { PyObject_HEAD /* Type-specific fields go here. */ bool old_state; } DisableTorchFunction; PyObject* DisableTorchFunction__enter(PyObject* self, PyObject *unused) { ((DisableTorchFunction*)self)->old_state = torch::enable_torch_function; torch::enable_torch_function = false; Py_RETURN_NONE; } PyObject* DisableTorchFunction__exit(PyObject* self, PyObject *unused) { torch::enable_torch_function = ((DisableTorchFunction*)self)->old_state; Py_RETURN_NONE; } PyObject* THPModule_isEnabledTorchFunction(PyObject* self, PyObject *unused) { if (torch::enable_torch_function) { Py_RETURN_TRUE; } else { Py_RETURN_FALSE; } } static PyMethodDef DisableTorchFunction_methods[] = { // NOLINT {"__enter__", DisableTorchFunction__enter, METH_NOARGS, nullptr}, {"__exit__", DisableTorchFunction__exit, METH_VARARGS, nullptr}, {nullptr, nullptr, 0, nullptr} }; PyTypeObject DisableTorchFunctionType = { PyVarObject_HEAD_INIT(nullptr, 0) "torch._C.DisableTorchFunction", /* tp_name */ sizeof(DisableTorchFunction), /* tp_basicsize */ 0, /* tp_itemsize */ nullptr, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ nullptr, /* tp_getattr */ nullptr, /* tp_setattr */ nullptr, /* tp_reserved */ nullptr, /* tp_repr */ nullptr, /* tp_as_number */ nullptr, /* tp_as_sequence */ nullptr, /* tp_as_mapping */ nullptr, /* tp_hash */ nullptr, /* tp_call */ nullptr, /* tp_str */ nullptr, /* tp_getattro */ nullptr, /* tp_setattro */ nullptr, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ nullptr, /* tp_doc */ nullptr, /* tp_traverse */ nullptr, /* tp_clear */ nullptr, /* tp_richcompare */ 0, /* tp_weaklistoffset */ nullptr, /* tp_iter */ nullptr, /* tp_iternext */ DisableTorchFunction_methods, /* tp_methods */ nullptr, /* tp_members */ nullptr, /* tp_getset */ nullptr, /* tp_base */ nullptr, /* tp_dict */ nullptr, /* tp_descr_get */ nullptr, /* tp_descr_set */ 0, /* tp_dictoffset */ nullptr, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ PyType_GenericNew, /* tp_new */ }; PyObject* THPModule_DisableTorchFunctionType() { if (PyType_Ready(&DisableTorchFunctionType) < 0) { return nullptr; } return (PyObject *)(&DisableTorchFunctionType); } PyObject* THPModule_disable_torch_function(PyObject *self, PyObject *a) { HANDLE_TH_ERRORS PyObject *func=nullptr, *types=nullptr, *args=nullptr, *kwargs=nullptr; if (!PyArg_ParseTuple(a, "OO|OO", &func, &types, &args, &kwargs)) { return nullptr; } py::tuple py_args; if (args == nullptr) { py_args = py::make_tuple(); } else if (PyList_CheckExact(args)) { py_args = py::reinterpret_steal<py::tuple>(PyList_AsTuple(args)); } else { py_args = py::reinterpret_borrow<py::tuple>(args); } // These are all C-API calls so no exceptions will be raised // and therefore no need for RAII approach to storing // the old value. bool old_value = torch::enable_torch_function; torch::enable_torch_function = false; // kwargs can safely be nullptr here. PyObject *result = PyObject_Call(func, py_args.ptr(), kwargs); torch::enable_torch_function = old_value; return result; END_HANDLE_TH_ERRORS } PyObject* THPModule_disable_torch_dispatch(PyObject *self, PyObject *a) { HANDLE_TH_ERRORS PyObject *func=nullptr, *types=nullptr, *args=nullptr, *kwargs=nullptr; if (!PyArg_ParseTuple(a, "OO|OO", &func, &types, &args, &kwargs)) { return nullptr; } py::tuple py_args; if (args == nullptr) { py_args = py::make_tuple(); } else if (PyList_CheckExact(args)) { py_args = py::reinterpret_steal<py::tuple>(PyList_AsTuple(args)); } else { py_args = py::reinterpret_borrow<py::tuple>(args); } // This implementation is not completely correct. The moral // meaning of this function is that we should do a redispatch // "after" PythonKey, aka a redispatch() call. But we don't have a // dispatcher call here; we have an opaque Python object. // // What we have here is a close approximation: instead of redispatch(), we // just exclude Python and all the keys before it, so that we will go // to the next key after Python. The difference, however, is we are // now PERMANENTLY after Python. We don't think there are any legitimate // cases where we want to go for another round on the entire dispatcher key // set, but if there are, then we will have to do something else here. c10::impl::ExcludeDispatchKeyGuard guard_( // TODO: add constructor for this specifically c10::DispatchKeySet(c10::DispatchKeySet::FULL) - c10::DispatchKeySet(c10::DispatchKeySet::FULL_AFTER, c10::DispatchKey::Python) // NB: off by one hazard here, but it works out: python key is not // included in AFTER, so it is included in the negation (and that's // correct: we want to exclude Python key and everything BEFORE it.) ); auto r = PyObject_Call(func, py_args.ptr(), kwargs); if (r == nullptr) throw python_error(); return r; END_HANDLE_TH_ERRORS } // Makes sure that we don't check for __torch_function__ on basic Python types static bool is_basic_python_type(PyTypeObject *tp) { return ( /* Basic number types */ tp == &PyBool_Type || tp == &PyLong_Type || tp == &PyFloat_Type || tp == &PyComplex_Type || /* Basic sequence types */ tp == &PyList_Type || tp == &PyTuple_Type || tp == &PyDict_Type || tp == &PySet_Type || tp == &PyFrozenSet_Type || tp == &PyUnicode_Type || tp == &PyBytes_Type || /* other builtins */ tp == &PySlice_Type || tp == Py_TYPE(Py_None) || tp == Py_TYPE(Py_Ellipsis) || tp == Py_TYPE(Py_NotImplemented) || PyModule_Check(tp) || /* sentinel to swallow trailing || */ false ); } inline bool has_torch_function_attr(PyObject* obj) { // NOLINTNEXTLINE(clang-diagnostic-writable-strings) auto attr = PyObject_FastGetAttrString(obj, "__torch_function__"); return ( attr.ptr() != nullptr && attr.ptr() != torch::disabled_torch_function); } namespace torch { auto check_has_torch_function(PyObject* obj) -> bool { PyTypeObject *tp = Py_TYPE(obj); return ( !THPVariable_CheckTypeExact(tp) && !is_basic_python_type(tp) && torch::torch_function_enabled() && has_torch_function_attr(obj) ); } } // namespace torch inline bool sequence_has_torch_function(PyObject* args) { // NOLINTNEXTLINE(bugprone-branch-clone) Py_ssize_t nargs = PySequence_Fast_GET_SIZE(args); for (Py_ssize_t i = 0; i < nargs; i++) { PyObject* obj = PySequence_Fast_GET_ITEM(args, i); if (torch::check_has_torch_function(obj)) { return true; } } return false; } inline bool array_has_torch_function(PyObject *const *args, Py_ssize_t nargs) { for (Py_ssize_t i = 0; i < nargs; i++) { if (torch::check_has_torch_function(args[i])) { return true; } } return false; } PyObject* THPModule_has_torch_function(PyObject*, PyObject *arg) { bool result; // NOLINT(cppcoreguidelines-init-variables) if (PyTuple_CheckExact(arg) || PyList_CheckExact(arg)) { // Fast path: // If we know that we have a tuple or list, we can skip an INCREF and // DECREF from PySequence_Fast. Core functions will always follow this // convention (almost always tuples), and it shaves ~3.5% off the cost of // the check. result = sequence_has_torch_function(arg); } else { auto args = py::reinterpret_steal<py::object>( PySequence_Fast(arg, "expected a sequence")); result = sequence_has_torch_function(args.ptr()); } if (result) { Py_RETURN_TRUE; } Py_RETURN_FALSE; } PyObject* THPModule_has_torch_function_unary(PyObject*, PyObject *obj) { // Special case `THPModule_has_torch_function` for the single arg case. if (torch::check_has_torch_function(obj)) { Py_RETURN_TRUE; } Py_RETURN_FALSE; } PyObject* THPModule_has_torch_function_variadic(PyObject*, PyObject *const *args, Py_ssize_t nargs) { if (array_has_torch_function(args, nargs)) { Py_RETURN_TRUE; } Py_RETURN_FALSE; }
SFX_Poisoned_1_Ch5: duty_cycle 0 pitch_sweep 1, 4 square_note 4, 15, 2, 1536 sound_loop 4, SFX_Poisoned_1_Ch5 square_note 15, 15, 3, 1536 pitch_sweep 0, 8 sound_ret
db "FAIRY@" ; species name dw 200, 170 ; height, weight db "In truth, it is a" next "cowardly #MON." next "It growls eagerly" page "in order to hide" next "its fear from its" next "opponent.@"
;modified version of the code in example 4.6 global _start extern ExitProcess %INCLUDE "lib.h" section .data nwln db 10, 0 space db 32, 0 str_prompt db "Please input a string (len<100): ",0 out_msg1 db "The ASCII code of ",0 out_msg2 db " in binary is ",0 query_msg db "Do you want to quit (Y/N): ",0 section .bss buffer resb 105 buffer2 resb 10 section .code _start: read_char: puts str_prompt ; request a string input fgets buffer, 105 puts out_msg1 puts buffer puts out_msg2 mov ESI, 0 char_loop: mov AL, [buffer+ESI] cmp AL, 0 je finish_printing mov [buffer2], AL mov [buffer2+1], BYTE 0 mov AH,80H ; mask byte = 80H mov ECX,8 ; loop count to print 8 bits print_bit: test AL,AH ; test does not modify AL jz print_0 ; if tested bit is 0, print it mov [buffer2], BYTE 49 mov [buffer2+1], BYTE 0 puts buffer2 jmp skip1 print_0: mov [buffer2], BYTE 48 mov [buffer2+1], BYTE 0 puts buffer2 skip1: shr AH,1 ; right-shift mask bit to test ; next bit of the ASCII code loop print_bit puts space inc ESI jmp char_loop finish_printing: puts nwln query: puts query_msg ; query user whether to terminate fgets buffer, 10 cmp [buffer], BYTE 'Y' je is_yes cmp [buffer], BYTE 'y' je is_yes cmp [buffer], BYTE 'N' je is_no cmp [buffer], BYTE 'n' je is_no jmp query is_yes: cmp [buffer+1], BYTE 0 je done jmp query is_no: cmp [buffer+1], BYTE 0 je read_char jmp query done: ; otherwise, terminate program push 0 call ExitProcess
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Microsoft Research Singularity ;;; ;;; Copyright (c) Microsoft Corporation. All rights reserved. ;;; ;;; This file contains ARM-specific assembly code. ;;; ; __dtou double precision floating point to unsigned integer convert ; ; Input: r1 - Most significant word of the double to be converted ; r0 - Least significant word of the double to be converted ; ; Output: r0 - converted float in unsigned integer format ; ; Local storage size and offsets LOC_SIZE EQU 0x18 OrgOp1h EQU 0x14 OrgOp1l EQU 0x10 ExDResl EQU 0x08 NewResl EQU 0x10 GET fpe.asm GET kxarm.inc AREA |.text|, CODE, READONLY Export __dtou IMPORT FPE_Raise NESTED_ENTRY __dtou EnterWithLR_16 STMFD sp!, {lr} ; Save return address SUB sp, sp, #LOC_SIZE ; Allocate stack space PROLOG_END STR r1, [sp, #OrgOp1h] ; Save off original args in case of exception ORRS r12, r0, r1, LSL #1 ; Check for zero STR r0, [sp, #OrgOp1l] ; Save off original args in case of exception ADDEQ sp, sp, #LOC_SIZE ; Restore stack and return IF Interworking :LOR: Thumbing LDMEQFD sp!, {lr} ; if zero (r0 already zero) BXEQ lr ELSE LDMEQFD sp!, {pc} ; if zero (r0 already zero) ENDIF MOVS r2, r1, LSL #1 ; Right justify exponent, save sign bit in C MOV r1, r1, LSL #11 ; Left justify mantissa ORR r1, r1, r0, LSR #21 ; .. ; .. MOV r0, r0, LSL #11 ; .. ORR r1, r1, #1 << 31 ; Insert hidden one (even for denorms) BCS _ffix_negative ; If negative input, separate case MOV r3, #DExp_bias+1 ; r3 = 31 + DExp_bias ADD r3, r3, #30 ; .. SUBS r2, r3, r2, LSR #21 ; Determine shift amount BLT shift_left ; Negative shift is a shift left, NaN, ; or INF CMP r2, #32 ; See if shifting all bits out BGE shift_right_32 ; If shifting all bits out, return zero shift_right RSB r3, r2, #32 ; Check for inexact ORRS r12, r0, r1, LSL r3 ; .. MOV r0, r1, LSR r2 ; Shift the result MOVNE r3, #INX_bit ; Set inexact if inexact MOVEQ r3, #0 ; Otherwise set to no exceptions B __dtou_return ; Return shift_left RSB r2, r2, #0 ; Get left shift amount CMP r2, #32 ; If >= 32, shift by moving words, and MOVGE r1, r0 ; adjusting shift amount MOVGE r0, #0 ; .. SUBGE r2, r2, #32 ; .. MOV r1, r1, LSL r2 ; Perform rest of shift RSB r2, r2, #32 ; .. ORR r0, r1, r0, LSR r2 ; .. MOV r3, #IVO_bit ; Overflow so set invalid operation B __dtou_return ; Return shift_right_32 ; 0.0 < abs(Arg) < 1.0, so losing all bits BIC r3, r3, #IVO_bit ; Ensure invalid is clear MOV r3, #INX_bit ; Set inexact MOV r0, #0 ; Return zero B __dtou_return ; Return _ffix_negative MOV r3, #DExp_bias+1 ; r3 = 31 + DExp_bias ADD r3, r3, #30 ; .. SUBS r2, r3, r2, LSR #21 ; Determine shift amount BLT shift_left_neg ; Negative shift is a shift left, NaN, ; or INF CMP r2, #32 ; See if shifting all bits out BGE shift_right_32 ; If shifting all bits out, return zero shift_right_neg MOV r0, r1, LSR r2 ; Shift the result RSB r0, r0, #0 ; Negate result MOV r3, #IVO_bit ; Have a negative so invalid B __dtou_return ; Return shift_left_neg RSB r2, r2, #0 ; Get left shift amount CMP r2, #32 ; If >= 32, shift by moving words, and MOVGE r1, r0 ; adjusting shift amount MOVGE r0, #0 ; .. SUBGE r2, r2, #32 ; .. MOV r1, r1, LSL r2 ; Perform rest of shift RSB r2, r2, #32 ; .. ORR r0, r1, r0, LSR r2 ; .. RSB r0, r0, #0 ; Negate result MOV r3, #IVO_bit ; Have a negative so invalid __dtou_return TST r3, #FPECause_mask ; Any exceptions? ADDEQ sp, sp, #LOC_SIZE ; If not, pop off saved arg and IF Interworking :LOR: Thumbing LDMEQFD sp!, {lr} ; return BXEQ lr ELSE LDMEQFD sp!, {pc} ; return ENDIF ORR r1, r3, #_FpDToU ; Exception information LDR r3, [sp, #OrgOp1h] ; Original operand 1 LDR r2, [sp, #OrgOp1l] ; .. STR r0, [sp, #ExDResl] ; Store default result ADD r0, sp, #NewResl ; Pointer to new result CALL FPE_Raise ; Handle exception information IF Thumbing :LAND: :LNOT: Interworking CODE16 bx pc ; switch back to ARM mode nop CODE32 ENDIF LDR r0, [sp, #NewResl] ; Load new result ADD sp, sp, #LOC_SIZE ; Pop off exception record and result IF Interworking :LOR: Thumbing LDMFD sp!, {lr} ; Return BX lr ELSE LDMFD sp!, {pc} ; Return ENDIF ENTRY_END __dtou END
; A304723: a(n) = 5^(n-1)*(3^n - 1)/2. ; Submitted by Jon Maiga ; 0,1,20,325,5000,75625,1137500,17078125,256250000,3844140625,57664062500,864970703125,12974609375000,194619384765625,2919291992187500,43789385986328125,656840820312500000,9852612457275390625,147789187622070312500,2216837818145751953125,33252567291259765625000 mov $1,5 pow $1,$0 mov $2,15 pow $2,$0 sub $2,$1 mov $0,$2 div $0,10
SECTION "Stack", WRAM0[$C080] ds $80 - 1 wStack:: SECTION "Init", ROM0 Init: di cp $11 ld a, 1 jr z, .cgb xor a .cgb ld [hGBC], a xor a ldx [rIF], [rIE] ldx [rRP] ldx [rSCX], [rSCY] ldx [rSB], [rSC] ldx [rWX], [rWY] ldx [rBGP], [rOBP0], [rOBP1] ldx [rTMA], [rTAC] put [rTAC], rTAC_4096Hz .wait ld a, [rLY] cp 144 jr c, .wait xor a ld [rLCDC], a ld sp, wStack fill $C000, $2000, 0 ld a, [hGBC] and a jr z, .cleared_wram ld a, 7 .wram_bank push af ld [rSVBK], a fill $D000, $1000, 0 pop af dec a cp 1 jr nc, .wram_bank .cleared_wram ld a, [hGBC] push af fill $FF80, $7F, 0 pop af ld [hGBC], a fill $8000, $2000, 0 fill $FE00, $A0, 0 put [rJOYP], 0 put [rSTAT], 8 ; hblank enable put [rWY], $90 put [rWX], 7 put [rLCDC], %11100011 IF def(NormalSpeed) ; not implemented yet ld a, [hGBC] and a call nz, NormalSpeed ENDC put [rIF], 0 put [rIE], %1111 ei halt call WriteDMATransferToHRAM call Main ; if Main returns, restart the program jp Init
copyright zengfr site:http://github.com/zengfr/romhack 00042A move.l D1, (A0)+ 00042C dbra D0, $42a 001880 add.l D1, ($8,A6) 001884 moveq #$0, D1 [enemy+ 8, enemy+ A] 0018AE add.l D0, ($8,A6) 0018B2 moveq #$0, D0 [123p+ 8, 123p+ A, base+744, enemy+ 8, enemy+ A, etc+ 8, etc+ A, item+ 8, item+ A] 004912 move.l D0, (A4)+ 004914 move.l D0, (A4)+ 004D3C move.l D0, (A4)+ 004D3E move.l D0, (A4)+ 035E2E add.l D0, ($8,A6) 035E32 moveq #$1, D1 [enemy+ 8, enemy+ A] 035FD8 add.l D0, ($8,A6) [enemy+B0, enemy+B2] 035FDC moveq #$1, D1 [enemy+ 8, enemy+ A] 03E73E add.l D0, ($8,A6) 03E742 moveq #$1, D1 [enemy+ 8, enemy+ A] 03E7FC add.l D0, ($8,A6) [enemy+B0, enemy+B2] 03E800 moveq #$1, D1 [enemy+ 8, enemy+ A] 03FE94 move.l ($8,A6), D0 [enemy+CC, enemy+CE] 03FE98 move.l D0, ($c8,A6) [enemy+ 8, enemy+ A] 03FEB8 cmp.l ($8,A6), D0 [enemy+ 8] 03FEBC blt $3fec8 [enemy+ 8, enemy+ A] 03FEC0 sub.l ($8,A6), D0 03FEC4 bra $3fed0 [enemy+ 8, enemy+ A] 03FF14 cmp.l ($8,A6), D2 03FF18 bge $3ff20 [enemy+ 8, enemy+ A] 040A54 add.l D0, ($8,A6) [enemy+B0, enemy+B2] 040A58 moveq #$1, D1 [enemy+ 8, enemy+ A] 040B06 add.l D0, ($8,A6) [enemy+B0, enemy+B2] 040B0A moveq #$1, D1 [enemy+ 8, enemy+ A] 041FD8 add.l D0, ($8,A6) [enemy+A0, enemy+A2] 041FDC move.l ($a4,A6), D0 [enemy+ 8, enemy+ A] 055932 add.l D0, ($8,A6) [enemy+AA, enemy+AC] 055936 jsr $49ca.l [enemy+ 8, enemy+ A] 0566EA add.l D0, ($8,A6) [enemy+B0, enemy+B2] 0566EE move.w ($aa,A6), D0 [enemy+ 8, enemy+ A] 056B1C add.l D0, ($8,A6) [enemy+8A, enemy+8C] 056B20 cmpi.l #$a000, ($8a,A6) [enemy+ 8, enemy+ A] 056B6A add.l D0, ($8,A6) [enemy+8A, enemy+8C] 056B6E cmpi.l #$8000, ($8a,A6) [enemy+ 8, enemy+ A] 056FB8 add.l D0, ($8,A6) [enemy+AA, enemy+AC] 056FBC rts [enemy+ 8, enemy+ A] 057008 add.l D0, ($8,A6) [enemy+AA, enemy+AC] 05700C rts [enemy+ 8, enemy+ A] 057034 add.l D0, ($8,A6) [enemy+AA, enemy+AC] 057038 jsr $119c.l [enemy+ 8, enemy+ A] 057044 add.l D0, ($8,A6) 057048 rts [enemy+ 8, enemy+ A] 057070 add.l D0, ($8,A6) [enemy+AA, enemy+AC] 057074 jsr $119c.l [enemy+ 8, enemy+ A] 057080 add.l D0, ($8,A6) 057084 rts [enemy+ 8, enemy+ A] 058E84 add.l D0, ($8,A6) [enemy+C0, enemy+C2] 058E88 moveq #$1, D1 [enemy+ 8, enemy+ A] 058FAA add.l D0, ($8,A6) [enemy+C0, enemy+C2] 058FAE moveq #$1, D1 [enemy+ 8, enemy+ A] 059BC4 move.l ($8,A6), D0 [enemy+76] 059BC8 sub.l ($8,A0), D0 [enemy+ 8, enemy+ A] 05A648 add.l D0, ($8,A6) 05A64C rts [enemy+ 8, enemy+ A] 05A77A add.l D0, ($8,A6) 05A77E movea.l ($a0,A6), A1 [enemy+ 8, enemy+ A] 05FFD6 sub.l D0, ($8,A6) [enemy+A0, enemy+A2] 05FFDA jmp $121e.l [enemy+ 8, enemy+ A] 0AAACA move.l (A0), D2 0AAACC move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAACE move.w D0, ($2,A0) 0AAAD2 cmp.l (A0), D0 0AAAD4 bne $aaafc 0AAAD8 move.l D2, (A0)+ 0AAADA cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAE6 move.l (A0), D2 0AAAE8 move.w D0, (A0) [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] 0AAAF4 move.l D2, (A0)+ 0AAAF6 cmpa.l A0, A1 [123p+11A, 123p+11C, 123p+11E, 123p+120, 123p+122, 123p+124, 123p+126, 123p+128, 123p+12A, enemy+BC, enemy+C0, enemy+C2, enemy+C4, enemy+CC, enemy+CE, enemy+D0, enemy+D2, enemy+D4, enemy+D6, enemy+D8, enemy+DA, enemy+DE, item+86, item+88, item+8A, item+98, item+9A, item+9C, item+9E, item+A0, item+A2, item+A4, item+A6, scr1] copyright zengfr site:http://github.com/zengfr/romhack
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/ash/file_system_provider/operations/read_directory.h" #include <memory> #include <string> #include <utility> #include <vector> #include "base/bind.h" #include "base/files/file.h" #include "base/files/file_path.h" #include "base/json/json_reader.h" #include "base/values.h" #include "chrome/browser/ash/file_system_provider/icon_set.h" #include "chrome/browser/ash/file_system_provider/operations/get_metadata.h" #include "chrome/browser/ash/file_system_provider/operations/test_util.h" #include "chrome/common/extensions/api/file_system_provider.h" #include "chrome/common/extensions/api/file_system_provider_capabilities/file_system_provider_capabilities_handler.h" #include "chrome/common/extensions/api/file_system_provider_internal.h" #include "components/services/filesystem/public/mojom/types.mojom.h" #include "extensions/browser/event_router.h" #include "storage/browser/file_system/async_file_util.h" #include "testing/gtest/include/gtest/gtest.h" namespace ash { namespace file_system_provider { namespace operations { namespace { const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; const char kFileSystemId[] = "testing-file-system"; const int kRequestId = 2; const base::FilePath::CharType kDirectoryPath[] = FILE_PATH_LITERAL("/directory"); // Callback invocation logger. Acts as a fileapi end-point. class CallbackLogger { public: class Event { public: Event(base::File::Error result, storage::AsyncFileUtil::EntryList entry_list, bool has_more) : result_(result), entry_list_(std::move(entry_list)), has_more_(has_more) {} Event(const Event&) = delete; Event& operator=(const Event&) = delete; virtual ~Event() {} base::File::Error result() { return result_; } const storage::AsyncFileUtil::EntryList& entry_list() { return entry_list_; } bool has_more() { return has_more_; } private: base::File::Error result_; storage::AsyncFileUtil::EntryList entry_list_; bool has_more_; }; CallbackLogger() {} CallbackLogger(const CallbackLogger&) = delete; CallbackLogger& operator=(const CallbackLogger&) = delete; virtual ~CallbackLogger() {} void OnReadDirectory(base::File::Error result, storage::AsyncFileUtil::EntryList entry_list, bool has_more) { events_.push_back( std::make_unique<Event>(result, std::move(entry_list), has_more)); } std::vector<std::unique_ptr<Event>>& events() { return events_; } private: std::vector<std::unique_ptr<Event>> events_; }; // Returns the request value as |result| in case of successful parse. void CreateRequestValueFromJSON(const std::string& json, std::unique_ptr<RequestValue>* result) { using extensions::api::file_system_provider_internal:: ReadDirectoryRequestedSuccess::Params; base::JSONReader::ValueWithError parsed_json = base::JSONReader::ReadAndReturnValueWithError(json); ASSERT_TRUE(parsed_json.value) << parsed_json.error_message; ASSERT_TRUE(parsed_json.value->is_list()); std::unique_ptr<Params> params(Params::Create(parsed_json.value->GetList())); ASSERT_TRUE(params.get()); *result = RequestValue::CreateForReadDirectorySuccess(std::move(params)); ASSERT_TRUE(result->get()); } } // namespace class FileSystemProviderOperationsReadDirectoryTest : public testing::Test { protected: FileSystemProviderOperationsReadDirectoryTest() {} ~FileSystemProviderOperationsReadDirectoryTest() override {} void SetUp() override { file_system_info_ = ProvidedFileSystemInfo( kExtensionId, MountOptions(kFileSystemId, "" /* display_name */), base::FilePath(), false /* configurable */, true /* watchable */, extensions::SOURCE_FILE, IconSet()); } ProvidedFileSystemInfo file_system_info_; }; TEST_F(FileSystemProviderOperationsReadDirectoryTest, Execute) { using extensions::api::file_system_provider::ReadDirectoryRequestedOptions; util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; ReadDirectory read_directory( NULL, file_system_info_, base::FilePath(kDirectoryPath), base::BindRepeating(&CallbackLogger::OnReadDirectory, base::Unretained(&callback_logger))); read_directory.SetDispatchEventImplForTesting( base::BindRepeating(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, base::Unretained(&dispatcher))); EXPECT_TRUE(read_directory.Execute(kRequestId)); ASSERT_EQ(1u, dispatcher.events().size()); extensions::Event* event = dispatcher.events()[0].get(); EXPECT_EQ(extensions::api::file_system_provider::OnReadDirectoryRequested:: kEventName, event->event_name); base::ListValue* event_args = event->event_args.get(); ASSERT_EQ(1u, event_args->GetList().size()); const base::Value* options_as_value = &event_args->GetList()[0]; ASSERT_TRUE(options_as_value->is_dict()); ReadDirectoryRequestedOptions options; ASSERT_TRUE( ReadDirectoryRequestedOptions::Populate(*options_as_value, &options)); EXPECT_EQ(kFileSystemId, options.file_system_id); EXPECT_EQ(kRequestId, options.request_id); EXPECT_EQ(kDirectoryPath, options.directory_path); } TEST_F(FileSystemProviderOperationsReadDirectoryTest, Execute_NoListener) { util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); CallbackLogger callback_logger; ReadDirectory read_directory( NULL, file_system_info_, base::FilePath(kDirectoryPath), base::BindRepeating(&CallbackLogger::OnReadDirectory, base::Unretained(&callback_logger))); read_directory.SetDispatchEventImplForTesting( base::BindRepeating(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, base::Unretained(&dispatcher))); EXPECT_FALSE(read_directory.Execute(kRequestId)); } TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnSuccess) { util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; ReadDirectory read_directory( NULL, file_system_info_, base::FilePath(kDirectoryPath), base::BindRepeating(&CallbackLogger::OnReadDirectory, base::Unretained(&callback_logger))); read_directory.SetDispatchEventImplForTesting( base::BindRepeating(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, base::Unretained(&dispatcher))); EXPECT_TRUE(read_directory.Execute(kRequestId)); // Sample input as JSON. Keep in sync with file_system_provider_api.idl. // As for now, it is impossible to create *::Params class directly, not from // base::Value. const std::string input = "[\n" " \"testing-file-system\",\n" // kFileSystemId " 2,\n" // kRequestId " [\n" " {\n" " \"isDirectory\": false,\n" " \"name\": \"blueberries.txt\"\n" " }\n" " ],\n" " false,\n" // has_more " 0\n" // execution_time "]\n"; std::unique_ptr<RequestValue> request_value; ASSERT_NO_FATAL_FAILURE(CreateRequestValueFromJSON(input, &request_value)); const bool has_more = false; read_directory.OnSuccess(kRequestId, std::move(request_value), has_more); ASSERT_EQ(1u, callback_logger.events().size()); CallbackLogger::Event* event = callback_logger.events()[0].get(); EXPECT_EQ(base::File::FILE_OK, event->result()); ASSERT_EQ(1u, event->entry_list().size()); const filesystem::mojom::DirectoryEntry entry = event->entry_list()[0]; EXPECT_EQ(entry.type, filesystem::mojom::FsFileType::REGULAR_FILE); EXPECT_EQ("blueberries.txt", entry.name.value()); } TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnSuccess_InvalidMetadata) { util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; ReadDirectory read_directory( NULL, file_system_info_, base::FilePath(kDirectoryPath), base::BindRepeating(&CallbackLogger::OnReadDirectory, base::Unretained(&callback_logger))); read_directory.SetDispatchEventImplForTesting( base::BindRepeating(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, base::Unretained(&dispatcher))); EXPECT_TRUE(read_directory.Execute(kRequestId)); // Sample input as JSON. Keep in sync with file_system_provider_api.idl. // As for now, it is impossible to create *::Params class directly, not from // base::Value. const std::string input = "[\n" " \"testing-file-system\",\n" // kFileSystemId " 2,\n" // kRequestId " [\n" " {\n" " \"isDirectory\": false,\n" " \"name\": \"blue/berries.txt\"\n" " }\n" " ],\n" " false,\n" // has_more " 0\n" // execution_time "]\n"; std::unique_ptr<RequestValue> request_value; ASSERT_NO_FATAL_FAILURE(CreateRequestValueFromJSON(input, &request_value)); const bool has_more = false; read_directory.OnSuccess(kRequestId, std::move(request_value), has_more); ASSERT_EQ(1u, callback_logger.events().size()); CallbackLogger::Event* event = callback_logger.events()[0].get(); EXPECT_EQ(base::File::FILE_ERROR_IO, event->result()); EXPECT_EQ(0u, event->entry_list().size()); } TEST_F(FileSystemProviderOperationsReadDirectoryTest, OnError) { util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); CallbackLogger callback_logger; ReadDirectory read_directory( NULL, file_system_info_, base::FilePath(kDirectoryPath), base::BindRepeating(&CallbackLogger::OnReadDirectory, base::Unretained(&callback_logger))); read_directory.SetDispatchEventImplForTesting( base::BindRepeating(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, base::Unretained(&dispatcher))); EXPECT_TRUE(read_directory.Execute(kRequestId)); read_directory.OnError(kRequestId, std::make_unique<RequestValue>(), base::File::FILE_ERROR_TOO_MANY_OPENED); ASSERT_EQ(1u, callback_logger.events().size()); CallbackLogger::Event* event = callback_logger.events()[0].get(); EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); ASSERT_EQ(0u, event->entry_list().size()); } } // namespace operations } // namespace file_system_provider } // namespace ash
// Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "config/amfeed-config.h" #endif #include <cstring> #if HAVE_DECL_STRNLEN == 0 size_t strnlen( const char *start, size_t max_len) { const char *end = (const char *)memchr(start, '\0', max_len); return end ? (size_t)(end - start) : max_len; } #endif // HAVE_DECL_STRNLEN