text
stringlengths
1
1.05M
// Copyright Takatoshi Kondo 2015 // // 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 "test_main.hpp" #include "combi_test.hpp" #include "checker.hpp" BOOST_AUTO_TEST_SUITE(test_resend) BOOST_AUTO_TEST_CASE( publish_qos1 ) { auto test = [](boost::asio::io_service& ios, auto& c, auto& s, auto& b) { using packet_id_t = typename std::remove_reference_t<decltype(*c)>::packet_id_t; c->set_client_id("cid1"); c->set_clean_session(true); std::uint16_t pid_pub; checker chk = { cont("start"), // connect cont("h_connack1"), // disconnect cont("h_close1"), // connect cont("h_connack2"), // publish topic1 QoS1 // force_disconnect cont("h_error"), // connect cont("h_connack3"), cont("h_puback"), // disconnect cont("h_close2"), }; std::vector<mqtt::v5::property_variant> ps { mqtt::v5::property::payload_format_indicator(mqtt::v5::property::payload_format_indicator::string), mqtt::v5::property::message_expiry_interval(0x12345678UL), mqtt::v5::property::topic_alias(0x1234U), mqtt::v5::property::response_topic("response topic"), mqtt::v5::property::correlation_data("correlation data"), mqtt::v5::property::user_property("key1", "val1"), mqtt::v5::property::user_property("key2", "val2"), mqtt::v5::property::subscription_identifier(123), }; std::size_t user_prop_count = 0; b.set_publish_props_handler( [&user_prop_count, size = ps.size()] (std::vector<mqtt::v5::property_variant> const& props) { BOOST_TEST(props.size() == size); for (auto const& p : props) { mqtt::visit( mqtt::make_lambda_visitor<void>( [&](mqtt::v5::property::payload_format_indicator::recv const& t) { BOOST_TEST(t.val() == mqtt::v5::property::payload_format_indicator::string); }, [&](mqtt::v5::property::message_expiry_interval::recv const& t) { BOOST_TEST(t.val() == 0x12345678UL); }, [&](mqtt::v5::property::topic_alias::recv const& t) { BOOST_TEST(t.val() == 0x1234U); }, [&](mqtt::v5::property::response_topic::recv const& t) { BOOST_TEST(t.val() == "response topic"); }, [&](mqtt::v5::property::correlation_data::recv const& t) { BOOST_TEST(t.val() == "correlation data"); }, [&](mqtt::v5::property::user_property::recv const& t) { switch (user_prop_count++) { case 0: BOOST_TEST(t.key() == "key1"); BOOST_TEST(t.val() == "val1"); break; case 1: BOOST_TEST(t.key() == "key2"); BOOST_TEST(t.val() == "val2"); break; case 2: BOOST_TEST(t.key() == "key1"); BOOST_TEST(t.val() == "val1"); break; case 3: BOOST_TEST(t.key() == "key2"); BOOST_TEST(t.val() == "val2"); break; default: BOOST_TEST(false); break; } }, [&](mqtt::v5::property::subscription_identifier const& t) { BOOST_TEST(t.val() == 123U); }, [&](auto&& ...) { BOOST_TEST(false); } ), p ); } } ); switch (c->get_protocol_version()) { case mqtt::protocol_version::v3_1_1: c->set_connack_handler( [&chk, &c, &pid_pub] (bool sp, std::uint8_t connack_return_code) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); BOOST_TEST(sp == false); pid_pub = c->publish_at_least_once("topic1", "topic1_contents"); c->force_disconnect(); }, "h_error", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_puback_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); return true; }); break; case mqtt::protocol_version::v5: c->set_v5_connack_handler( [&chk, &c, &pid_pub, ps = std::move(ps)] (bool sp, std::uint8_t connack_return_code, std::vector<mqtt::v5::property_variant> /*props*/) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&, ps = std::move(ps)] { MQTT_CHK("h_connack2"); // If clean session is not provided, than there will be a session present // if there was ever a previous connection, even if clean session was provided // on the previous connection. // This is because MQTTv5 change the semantics of the flag to "clean start" // such that it only effects the start of the session. // Post Session cleanup is handled with a timer, not with the clean session flag. BOOST_TEST(sp == true); pid_pub = c->publish_at_least_once("topic1", "topic1_contents", false, std::move(ps)); c->force_disconnect(); }, "h_error", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id, std::uint8_t, std::vector<mqtt::v5::property_variant> /*props*/) { MQTT_CHK("h_puback"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); return true; }); break; default: BOOST_CHECK(false); break; } c->set_close_handler( [&chk, &c, &s] () { auto ret = chk.match( "h_connack1", [&] { MQTT_CHK("h_close1"); c->set_clean_session(false); c->connect(); }, "h_puback", [&] { MQTT_CHK("h_close2"); s.close(); } ); BOOST_TEST(ret); }); c->set_error_handler( [&chk, &c] (boost::system::error_code const&) { MQTT_CHK("h_error"); c->connect(); }); MQTT_CHK("start"); c->connect(); ios.run(); BOOST_TEST(chk.all()); }; do_combi_test_sync(test); } BOOST_AUTO_TEST_CASE( publish_qos2 ) { auto test = [](boost::asio::io_service& ios, auto& c, auto& s, auto& /*b*/) { using packet_id_t = typename std::remove_reference_t<decltype(*c)>::packet_id_t; c->set_client_id("cid1"); c->set_clean_session(true); std::uint16_t pid_pub; checker chk = { cont("start"), // connect cont("h_connack1"), // disconnect cont("h_close1"), // connect cont("h_connack2"), // publish topic1 QoS2 // force_disconnect cont("h_error"), // connect cont("h_connack3"), cont("h_pubrec"), cont("h_pubcomp"), // disconnect cont("h_close2"), }; switch (c->get_protocol_version()) { case mqtt::protocol_version::v3_1_1: c->set_connack_handler( [&chk, &c, &pid_pub] (bool sp, std::uint8_t connack_return_code) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); BOOST_TEST(sp == false); pid_pub = c->publish_exactly_once("topic1", "topic1_contents"); c->force_disconnect(); }, "h_error", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); return true; }); break; case mqtt::protocol_version::v5: c->set_v5_connack_handler( [&chk, &c, &pid_pub] (bool sp, std::uint8_t connack_return_code, std::vector<mqtt::v5::property_variant> /*props*/) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); // If clean session is not provided, than there will be a session present // if there was ever a previous connection, even if clean session was provided // on the previous connection. // This is because MQTTv5 change the semantics of the flag to "clean start" // such that it only effects the start of the session. // Post Session cleanup is handled with a timer, not with the clean session flag. BOOST_TEST(sp == true); pid_pub = c->publish_exactly_once("topic1", "topic1_contents"); c->force_disconnect(); }, "h_error", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_v5_pubrec_handler( [&chk, &pid_pub] (packet_id_t packet_id, std::uint8_t, std::vector<mqtt::v5::property_variant> /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id, std::uint8_t, std::vector<mqtt::v5::property_variant> /*props*/) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); return true; }); break; default: BOOST_CHECK(false); break; } c->set_close_handler( [&chk, &c, &s] () { auto ret = chk.match( "h_connack1", [&] { MQTT_CHK("h_close1"); c->set_clean_session(false); c->connect(); }, "h_pubcomp", [&] { MQTT_CHK("h_close2"); s.close(); } ); BOOST_TEST(ret); }); c->set_error_handler( [&chk, &c] (boost::system::error_code const&) { MQTT_CHK("h_error"); c->connect(); }); MQTT_CHK("start"); c->connect(); ios.run(); BOOST_TEST(chk.all()); }; do_combi_test_sync(test); } BOOST_AUTO_TEST_CASE( pubrel_qos2 ) { auto test = [](boost::asio::io_service& ios, auto& c, auto& s, auto& b) { using packet_id_t = typename std::remove_reference_t<decltype(*c)>::packet_id_t; c->set_client_id("cid1"); c->set_clean_session(true); std::uint16_t pid_pub; checker chk = { cont("start"), // connect cont("h_connack1"), // disconnect cont("h_close1"), // connect cont("h_connack2"), // publish topic1 QoS2 cont("h_pubrec"), // force_disconnect cont("h_error"), // connect cont("h_connack3"), cont("h_pubcomp"), // disconnect cont("h_close2"), }; std::vector<mqtt::v5::property_variant> ps { mqtt::v5::property::reason_string("test success"), mqtt::v5::property::user_property("key1", "val1"), mqtt::v5::property::user_property("key2", "val2"), }; std::size_t user_prop_count = 0; b.set_pubrel_props_handler( [&user_prop_count, size = ps.size()] (std::vector<mqtt::v5::property_variant> const& props) { BOOST_TEST(props.size() == size); for (auto const& p : props) { mqtt::visit( mqtt::make_lambda_visitor<void>( [&](mqtt::v5::property::reason_string::recv const& t) { BOOST_TEST(t.val() == "test success"); }, [&](mqtt::v5::property::user_property::recv const& t) { switch (user_prop_count++) { case 0: BOOST_TEST(t.key() == "key1"); BOOST_TEST(t.val() == "val1"); break; case 1: BOOST_TEST(t.key() == "key2"); BOOST_TEST(t.val() == "val2"); break; case 2: BOOST_TEST(t.key() == "key1"); BOOST_TEST(t.val() == "val1"); break; case 3: BOOST_TEST(t.key() == "key2"); BOOST_TEST(t.val() == "val2"); break; default: BOOST_TEST(false); break; } }, [&](auto&& ...) { BOOST_TEST(false); } ), p ); } } ); switch (c->get_protocol_version()) { case mqtt::protocol_version::v3_1_1: c->set_connack_handler( [&chk, &c, &pid_pub] (bool sp, std::uint8_t connack_return_code) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); BOOST_TEST(sp == false); pid_pub = c->publish_exactly_once("topic1", "topic1_contents"); }, "h_error", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_pubrec_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c->force_disconnect(); return true; }); c->set_pubcomp_handler( [&chk, &c] (packet_id_t packet_id) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c->disconnect(); return true; }); break; case mqtt::protocol_version::v5: c->set_auto_pub_response(false); c->set_v5_connack_handler( [&chk, &c, &pid_pub] (bool sp, std::uint8_t connack_return_code, std::vector<mqtt::v5::property_variant> /*props*/) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); // If clean session is not provided, than there will be a session present // if there was ever a previous connection, even if clean session was provided // on the previous connection. // This is because MQTTv5 change the semantics of the flag to "clean start" // such that it only effects the start of the session. // Post Session cleanup is handled with a timer, not with the clean session flag. BOOST_TEST(sp == true); pid_pub = c->publish_exactly_once("topic1", "topic1_contents"); }, "h_error", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_v5_pubrec_handler( [&chk, &c, &pid_pub, ps = std::move(ps)] (packet_id_t packet_id, std::uint8_t, std::vector<mqtt::v5::property_variant> /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c->pubrel(packet_id, mqtt::v5::reason_code::success, std::move(ps)); c->force_disconnect(); return true; }); c->set_v5_pubcomp_handler( [&chk, &c] (packet_id_t packet_id, std::uint8_t, std::vector<mqtt::v5::property_variant> /*props*/) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == 1); c->disconnect(); return true; }); break; default: BOOST_CHECK(false); break; } c->set_close_handler( [&chk, &c, &s] () { auto ret = chk.match( "h_connack1", [&] { MQTT_CHK("h_close1"); c->set_clean_session(false); c->connect(); }, "h_pubcomp", [&] { MQTT_CHK("h_close2"); s.close(); } ); BOOST_TEST(ret); }); c->set_error_handler( [&chk, &c] (boost::system::error_code const&) { MQTT_CHK("h_error"); c->connect(); }); MQTT_CHK("start"); c->connect(); ios.run(); BOOST_TEST(chk.all()); }; do_combi_test_sync(test); } BOOST_AUTO_TEST_CASE( publish_pubrel_qos2 ) { auto test = [](boost::asio::io_service& ios, auto& c, auto& s, auto& /*b*/) { using packet_id_t = typename std::remove_reference_t<decltype(*c)>::packet_id_t; c->set_client_id("cid1"); c->set_clean_session(true); std::uint16_t pid_pub; checker chk = { cont("start"), // connect cont("h_connack1"), // disconnect cont("h_close1"), // connect cont("h_connack2"), // publish topic1 QoS2 // force_disconnect cont("h_error1"), // connect cont("h_connack3"), cont("h_pubrec"), // force_disconnect cont("h_error2"), // connect cont("h_connack4"), cont("h_pubcomp"), // disconnect cont("h_close2"), }; switch (c->get_protocol_version()) { case mqtt::protocol_version::v3_1_1: c->set_connack_handler( [&chk, &c, & pid_pub] (bool sp, std::uint8_t connack_return_code) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); BOOST_TEST(sp == false); pid_pub = c->publish_exactly_once("topic1", "topic1_contents"); c->force_disconnect(); }, "h_error1", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); }, "h_error2", [&] { MQTT_CHK("h_connack4"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_pubrec_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c->force_disconnect(); return true; }); c->set_pubcomp_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); return true; }); break; case mqtt::protocol_version::v5: c->set_v5_connack_handler( [&chk, &c, & pid_pub] (bool sp, std::uint8_t connack_return_code, std::vector<mqtt::v5::property_variant> /*props*/) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); // If clean session is not provided, than there will be a session present // if there was ever a previous connection, even if clean session was provided // on the previous connection. // This is because MQTTv5 change the semantics of the flag to "clean start" // such that it only effects the start of the session. // Post Session cleanup is handled with a timer, not with the clean session flag. BOOST_TEST(sp == true); pid_pub = c->publish_exactly_once("topic1", "topic1_contents"); c->force_disconnect(); }, "h_error1", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); }, "h_error2", [&] { MQTT_CHK("h_connack4"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_v5_pubrec_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id, std::uint8_t, std::vector<mqtt::v5::property_variant> /*props*/) { MQTT_CHK("h_pubrec"); BOOST_TEST(packet_id == pid_pub); c->force_disconnect(); return true; }); c->set_v5_pubcomp_handler( [&chk, &c, &pid_pub] (packet_id_t packet_id, std::uint8_t, std::vector<mqtt::v5::property_variant> /*props*/) { MQTT_CHK("h_pubcomp"); BOOST_TEST(packet_id == pid_pub); c->disconnect(); return true; }); break; default: BOOST_CHECK(false); break; } c->set_close_handler( [&chk, &c, &s] () { auto ret = chk.match( "h_connack1", [&] { MQTT_CHK("h_close1"); c->set_clean_session(false); c->connect(); }, "h_pubcomp", [&] { MQTT_CHK("h_close2"); s.close(); } ); BOOST_TEST(ret); }); c->set_error_handler( [&chk, &c] (boost::system::error_code const&) { auto ret = chk.match( "h_connack2", [&] { MQTT_CHK("h_error1"); c->connect(); }, "h_pubrec", [&] { MQTT_CHK("h_error2"); c->connect(); } ); BOOST_TEST(ret); }); MQTT_CHK("start"); c->connect(); ios.run(); BOOST_TEST(chk.all()); }; do_combi_test_sync(test); } BOOST_AUTO_TEST_CASE( multi_publish_qos1 ) { auto test = [](boost::asio::io_service& ios, auto& c, auto& s, auto& /*b*/) { using packet_id_t = typename std::remove_reference_t<decltype(*c)>::packet_id_t; c->set_client_id("cid1"); c->set_clean_session(true); std::uint16_t pid_pub1; std::uint16_t pid_pub2; checker chk = { cont("start"), // connect cont("h_connack1"), // disconnect cont("h_close1"), // connect cont("h_connack2"), // publish topic1 QoS1 // publish topic1 QoS1 // force_disconnect cont("h_error1"), // connect cont("h_connack3"), cont("h_puback1"), cont("h_puback2"), // disconnect cont("h_close2"), }; switch (c->get_protocol_version()) { case mqtt::protocol_version::v3_1_1: c->set_connack_handler( [&chk, &c, &pid_pub1, &pid_pub2] (bool sp, std::uint8_t connack_return_code) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); BOOST_TEST(sp == false); pid_pub1 = c->publish_at_least_once("topic1", "topic1_contents1"); pid_pub2 = c->publish_at_least_once("topic1", "topic1_contents2"); c->force_disconnect(); }, "h_error1", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_puback_handler( [&chk, &c, &pid_pub1, &pid_pub2] (packet_id_t packet_id) { auto ret = chk.match( "h_connack3", [&] { MQTT_CHK("h_puback1"); BOOST_TEST(packet_id == pid_pub1); }, "h_puback1", [&] { MQTT_CHK("h_puback2"); BOOST_TEST(packet_id == pid_pub2); c->disconnect(); } ); BOOST_TEST(ret); return true; }); break; case mqtt::protocol_version::v5: c->set_v5_connack_handler( [&chk, &c, &pid_pub1, &pid_pub2] (bool sp, std::uint8_t connack_return_code, std::vector<mqtt::v5::property_variant> /*props*/) { BOOST_TEST(connack_return_code == mqtt::connect_return_code::accepted); auto ret = chk.match( "start", [&] { MQTT_CHK("h_connack1"); BOOST_TEST(sp == false); c->disconnect(); }, "h_close1", [&] { MQTT_CHK("h_connack2"); // If clean session is not provided, than there will be a session present // if there was ever a previous connection, even if clean session was provided // on the previous connection. // This is because MQTTv5 change the semantics of the flag to "clean start" // such that it only effects the start of the session. // Post Session cleanup is handled with a timer, not with the clean session flag. BOOST_TEST(sp == true); pid_pub1 = c->publish_at_least_once("topic1", "topic1_contents1"); pid_pub2 = c->publish_at_least_once("topic1", "topic1_contents2"); c->force_disconnect(); }, "h_error1", [&] { MQTT_CHK("h_connack3"); BOOST_TEST(sp == true); } ); BOOST_TEST(ret); return true; }); c->set_v5_puback_handler( [&chk, &c, &pid_pub1, &pid_pub2] (packet_id_t packet_id, std::uint8_t, std::vector<mqtt::v5::property_variant> /*props*/) { auto ret = chk.match( "h_connack3", [&] { MQTT_CHK("h_puback1"); BOOST_TEST(packet_id == pid_pub1); }, "h_puback1", [&] { MQTT_CHK("h_puback2"); BOOST_TEST(packet_id == pid_pub2); c->disconnect(); } ); BOOST_TEST(ret); return true; }); break; default: BOOST_CHECK(false); break; } c->set_close_handler( [&chk, &c, &s] () { auto ret = chk.match( "h_connack1", [&] { MQTT_CHK("h_close1"); c->set_clean_session(false); c->connect(); }, "h_puback2", [&] { MQTT_CHK("h_close2"); s.close(); } ); BOOST_TEST(ret); }); c->set_error_handler( [&chk, &c] (boost::system::error_code const&) { MQTT_CHK("h_error1"); c->connect(); }); MQTT_CHK("start"); c->connect(); ios.run(); BOOST_TEST(chk.all()); }; do_combi_test_sync(test); } BOOST_AUTO_TEST_SUITE_END()
; ; Colour Genie EG2000 graphics routines ; Fast background restore ; ; ; $Id: bkrestore.asm,v 1.2 2016/06/20 21:47:41 dom Exp $ ; SECTION code_clib PUBLIC bkrestore PUBLIC _bkrestore EXTERN pixeladdress .bkrestore ._bkrestore ; __FASTCALL__ : sprite ptr in HL push ix ;save callers push hl pop ix ld h,(ix+2) ; restore sprite position ld l,(ix+3) ld a,(ix+0) ld b,(ix+1) cp 9 jr nc,bkrestore ._sloop push bc push hl ld a,(ix+4) and @10101010 ld (hl),a inc hl ld a,(ix+4) and @01010101 rla ld (hl),a inc hl ld a,(ix+5) and @10101010 ld (hl),a inc hl ld a,(ix+5) and @01010101 rla ld (hl),a inc hl inc ix inc ix pop hl ld bc,40 ;Go to next line add hl,bc pop bc djnz _sloop pop ix ret .bkrestorew push bc ld a,(ix+4) and @10101010 ld (hl),a inc hl ld a,(ix+4) and @01010101 rla ld (hl),a inc hl ld a,(ix+5) and @10101010 ld (hl),a inc hl ld a,(ix+5) and @01010101 rla ld (hl),a inc hl ld a,(ix+6) and @10101010 ld (hl),a inc hl ld a,(ix+6) and @01010101 rla ld (hl),a inc ix inc ix inc ix pop hl ld bc,40 ;Go to next line add hl,bc pop bc djnz bkrestorew pop ix ret
; A298030: Partial sums of A298029. ; 1,4,10,22,40,73,112,163,220,289,364,451,544,649,760,883,1012,1153,1300,1459,1624,1801,1984,2179,2380,2593,2812,3043,3280,3529,3784,4051,4324,4609,4900,5203,5512,5833,6160,6499,6844,7201,7564,7939,8320,8713,9112,9523,9940,10369,10804,11251,11704,12169,12640,13123,13612,14113,14620,15139,15664,16201,16744,17299,17860,18433,19012,19603,20200,20809,21424,22051,22684,23329,23980,24643,25312,25993,26680,27379,28084,28801,29524,30259,31000,31753,32512,33283,34060,34849,35644,36451,37264,38089,38920,39763,40612,41473,42340,43219,44104,45001,45904,46819,47740,48673,49612,50563,51520,52489,53464,54451,55444,56449,57460,58483,59512,60553,61600,62659,63724,64801,65884,66979,68080,69193,70312,71443,72580,73729,74884,76051,77224,78409,79600,80803,82012,83233,84460,85699,86944,88201,89464,90739,92020,93313,94612,95923,97240,98569,99904,101251,102604,103969,105340,106723,108112,109513,110920,112339,113764,115201,116644,118099,119560,121033,122512,124003,125500,127009,128524,130051,131584,133129,134680,136243,137812,139393,140980,142579,144184,145801,147424,149059,150700,152353,154012,155683,157360,159049,160744,162451,164164,165889,167620,169363,171112,172873,174640,176419,178204,180001,181804,183619,185440,187273,189112,190963,192820,194689,196564,198451,200344,202249,204160,206083,208012,209953,211900,213859,215824,217801,219784,221779,223780,225793,227812,229843,231880,233929,235984,238051,240124,242209,244300,246403,248512,250633,252760,254899,257044,259201,261364,263539,265720,267913,270112,272323,274540,276769 mov $1,$0 mov $3,$0 mov $0,1 mul $0,$3 trn $1,1 pow $1,2 add $1,1 mov $2,1 add $3,1 lpb $0,1 mov $0,3 mul $2,2 mov $3,2 mov $4,$1 mul $1,2 div $4,$2 lpe sub $1,$4 sub $1,$2 div $3,$2 add $1,$3 sub $1,1 mul $1,3 add $1,1
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The OFIChain developers // Copyright (c) 2011-2017 The OFIChain developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "OFIChain-config.h" #endif #include "txdb.h" #include "addrman.h" #include "rpcserver.h" #include "checkpoints.h" #include "net.h" #include "init.h" #include "util.h" #include "ui_interface.h" #include "checkpointsync.h" #include <boost/filesystem.hpp> #include <boost/filesystem/fstream.hpp> #include <boost/filesystem/convenience.hpp> #include <boost/interprocess/sync/file_lock.hpp> #include <boost/algorithm/string/predicate.hpp> #include <openssl/crypto.h> #ifndef WIN32 #include <signal.h> #endif using namespace std; using namespace boost; CWallet* pwalletMain; #ifdef WIN32 // Win32 LevelDB doesn't use filedescriptors, and the ones used for // accessing block files, don't count towards to fd_set size limit // anyway. #define MIN_CORE_FILEDESCRIPTORS 0 #else #define MIN_CORE_FILEDESCRIPTORS 150 #endif // Used to pass flags to the Bind() function enum BindFlags { BF_NONE = 0, BF_EXPLICIT = (1U << 0), BF_REPORT_ERROR = (1U << 1) }; ////////////////////////////////////////////////////////////////////////////// // // Shutdown // // // Thread management and startup/shutdown: // // The network-processing threads are all part of a thread group // created by AppInit() or the Qt main() function. // // A clean exit happens when StartShutdown() or the SIGTERM // signal handler sets fRequestShutdown, which triggers // the DetectShutdownThread(), which interrupts the main thread group. // DetectShutdownThread() then exits, which causes AppInit() to // continue (it .joins the shutdown thread). // Shutdown() is then // called to clean up database connections, and stop other // threads that should only be stopped after the main network-processing // threads have exited. // // Note that if running -daemon the parent process returns from AppInit2 // before adding any threads to the threadGroup, so .join_all() returns // immediately and the parent exits from main(). // // Shutdown for Qt is very similar, only it uses a QTimer to detect // fRequestShutdown getting set, and then does the normal Qt // shutdown thing. // volatile bool fRequestShutdown = false; void StartShutdown() { fRequestShutdown = true; } bool ShutdownRequested() { return fRequestShutdown; } static CCoinsViewDB *pcoinsdbview; void Shutdown() { printf("Shutdown : In progress...\n"); static CCriticalSection cs_Shutdown; TRY_LOCK(cs_Shutdown, lockShutdown); if (!lockShutdown) return; RenameThread("OFIChain-shutoff"); nTransactionsUpdated++; StopRPCThreads(); bitdb.Flush(false); StopNode(); { LOCK(cs_main); if (pwalletMain) pwalletMain->SetBestChain(CBlockLocator(pindexBest)); if (pblocktree) pblocktree->Flush(); if (pcoinsTip) pcoinsTip->Flush(); delete pcoinsTip; pcoinsTip = NULL; delete pcoinsdbview; pcoinsdbview = NULL; delete pblocktree; pblocktree = NULL; } bitdb.Flush(true); boost::filesystem::remove(GetPidFile()); UnregisterWallet(pwalletMain); delete pwalletMain; printf("Shutdown : done\n"); } // // Signal handlers are very limited in what they are allowed to do, so: // void HandleSIGTERM(int) { fRequestShutdown = true; } void HandleSIGHUP(int) { fReopenDebugLog = true; } bool static InitError(const std::string &str) { uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_ERROR); return false; } bool static InitWarning(const std::string &str) { uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING); return true; } bool static Bind(const CService &addr, unsigned int flags) { if (!(flags & BF_EXPLICIT) && IsLimited(addr)) return false; std::string strError; if (!BindListenPort(addr, strError)) { if (flags & BF_REPORT_ERROR) return InitError(strError); return false; } return true; } // Core-specific options shared between UI and daemon std::string HelpMessage(HelpMessageMode hmm) { string strUsage = _("Options:") + "\n" + " -? " + _("This help message") + "\n" + " -conf=<file> " + _("Specify configuration file (default: OFIChain.conf)") + "\n" + " -pid=<file> " + _("Specify pid file (default: OFIChaind.pid)") + "\n" + " -gen " + _("Generate coins (default: 0)") + "\n" + " -nominting " + _("Disable minting of POS blocks") + "\n" + " -datadir=<dir> " + _("Specify data directory") + "\n" + " -dbcache=<n> " + _("Set database cache size in megabytes (default: 25)") + "\n" + " -maxorphanblocks=<n> " + _("Keep at most <n> unconnectable blocks in memory (default: 750)") + "\n" + " -maxorphantx=<n> " + _("Keep at most <n> unconnectable transactions in memory (default: 100)") + "\n" + " -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" + " -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" + " -socks=<n> " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" + " -tor=<ip:port> " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n" " -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" + " -port=<port> " + _("Listen for connections on <port> (default: 9901 or testnet: 9903)") + "\n" + " -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n" + " -addnode=<ip> " + _("Add a node to connect to and attempt to keep the connection open") + "\n" + " -connect=<ip> " + _("Connect only to the specified node(s)") + "\n" + " -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" + " -externalip=<ip> " + _("Specify your own public address") + "\n" + " -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6 or Tor)") + "\n" + " -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n" + " -checkpoints " + _("Only accept block chain matching built-in checkpoints (default: 1)") + "\n" + " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" + " -bind=<addr> " + _("Bind to given address and always listen on it. Use [host]:port notation for IPv6") + "\n" + " -dnsseed " + _("Find peers using DNS lookup (default: 1 unless -connect)") + "\n" + " -banscore=<n> " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" + " -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" + " -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n" + " -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") + "\n" + #ifdef USE_UPNP #if USE_UPNP " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n" + #else " -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n" + #endif #endif " -paytxfee=<amt> " + _("Fee per KB to add to transactions you send") + "\n" + " -debug=<category> " + _("Output debugging information (default: 0, supplying <category> is optional)") + "\n" + _("If <category> is not supplied, output all debugging information.") + "\n" + _("<category> can be:") + " addrman, alert, coindb, db, lock, rand, rpc, selectcoins, mempool, net"; // Don't translate these and qt below if (hmm == HMM_BITCOIN_QT) { strUsage += ", qt.\n"; } else { strUsage += ".\n"; } strUsage += " -logtimestamps " + _("Prepend debug output with timestamp (default: 1)") + "\n" + " -shrinkdebugfile " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n" + " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n" + " -regtest " + _("Enter regression test mode, which uses a special chain in which blocks can be " "solved instantly. This is intended for regression testing tools and app development.") + "\n"; #ifdef WIN32 strUsage += " -printtodebugger " + _("Send trace/debug info to debugger") + "\n"; #endif if (hmm == HMM_BITCOIN_QT) { strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n"; } if (hmm == HMM_BITCOIND) { #if !defined(WIN32) strUsage += " -daemon " + _("Run in the background as a daemon and accept commands") + "\n"; #endif } strUsage += " -rpcthreads=<n> " + _("Set the number of threads to service RPC calls (default: 4)") + "\n" + " -blocknotify=<cmd> " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" + " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n" + " -alertnotify=<cmd> " + _("Execute command when a relevant alert is received (%s in cmd is replaced by message)") + "\n" + " -upgradewallet " + _("Upgrade wallet to latest format") + "\n" + " -keypool=<n> " + _("Set key pool size to <n> (default: 100)") + "\n" + " -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n" + " -zapwallettxes " + _("Clear list of wallet transactions (diagnostic tool; implies -rescan)") + "\n" + " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n" + " -checkblocks=<n> " + _("How many blocks to check at startup (default: 288, 0 = all)") + "\n" + " -checklevel=<n> " + _("How thorough the block verification is (0-4, default: 3)") + "\n" + " -txindex " + _("Maintain a full transaction index (default: 0)") + "\n" + " -loadblock=<file> " + _("Imports blocks from external blk000??.dat file") + "\n" + " -reindex " + _("Rebuild block chain index from current blk000??.dat files") + "\n" + " -par=<n> " + _("Set the number of script verification threads (up to 16, 0 = auto, <0 = leave that many cores free, default: 0)") + "\n" + "\n" + _("Block creation options:") + "\n" + " -blockminsize=<n> " + _("Set minimum block size in bytes (default: 0)") + "\n" + " -blockmaxsize=<n> " + _("Set maximum block size in bytes (default: 250000)") + "\n" + " -blockprioritysize=<n> " + _("Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)") + "\n" + "\n" + _("SSL options: (see the OFIChain Wiki for SSL setup instructions)") + "\n" + " -rpcssl " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n" + " -rpcsslcertificatechainfile=<file.cert> " + _("Server certificate file (default: server.cert)") + "\n" + " -rpcsslprivatekeyfile=<file.pem> " + _("Server private key (default: server.pem)") + "\n" + " -rpcsslciphers=<ciphers> " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)") + "\n"; return strUsage; } struct CImportingNow { CImportingNow() { assert(fImporting == false); fImporting = true; } ~CImportingNow() { assert(fImporting == true); fImporting = false; } }; void ThreadImport(std::vector<boost::filesystem::path> vImportFiles) { RenameThread("OFIChain-loadblk"); // -reindex if (fReindex) { CImportingNow imp; int nFile = 0; while (true) { CDiskBlockPos pos(nFile, 0); FILE *file = OpenBlockFile(pos, true); if (!file) break; printf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile); LoadExternalBlockFile(file, &pos); nFile++; } pblocktree->WriteReindexing(false); fReindex = false; printf("Reindexing finished\n"); // To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked): InitBlockIndex(); } // hardcoded $DATADIR/bootstrap.dat filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat"; if (filesystem::exists(pathBootstrap)) { FILE *file = fopen(pathBootstrap.string().c_str(), "rb"); if (file) { CImportingNow imp; filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old"; printf("Importing bootstrap.dat...\n"); LoadExternalBlockFile(file); RenameOver(pathBootstrap, pathBootstrapOld); } } // -loadblock= BOOST_FOREACH(boost::filesystem::path &path, vImportFiles) { FILE *file = fopen(path.string().c_str(), "rb"); if (file) { CImportingNow imp; printf("Importing %s...\n", path.string().c_str()); LoadExternalBlockFile(file); } } } /** Initialize OFIChain. * @pre Parameters should be parsed and config file should be read. */ bool AppInit2(boost::thread_group& threadGroup) { // ********************************************************* Step 1: setup #ifdef _MSC_VER // Turn off Microsoft heap dump noise _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0)); #endif #if _MSC_VER >= 1400 // Disable confusing "helpful" text message on abort, Ctrl-C _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); #endif #ifdef WIN32 // Enable Data Execution Prevention (DEP) // Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008 // A failure is non-critical and needs no further attention! #ifndef PROCESS_DEP_ENABLE // We define this here, because GCCs winbase.h limits this to _WIN32_WINNT >= 0x0601 (Windows 7), // which is not correct. Can be removed, when GCCs winbase.h is fixed! #define PROCESS_DEP_ENABLE 0x00000001 #endif typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD); PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy"); if (setProcDEPPol != NULL) setProcDEPPol(PROCESS_DEP_ENABLE); // Initialize Windows Sockets WSADATA wsadata; int ret = WSAStartup(MAKEWORD(2,2), &wsadata); if (ret != NO_ERROR || LOBYTE(wsadata.wVersion ) != 2 || HIBYTE(wsadata.wVersion) != 2) { return InitError(strprintf("Error: Winsock library failed to start (WSAStartup returned error %d)", ret)); } #endif #ifndef WIN32 umask(077); // Clean shutdown on SIGTERM struct sigaction sa; sa.sa_handler = HandleSIGTERM; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGTERM, &sa, NULL); sigaction(SIGINT, &sa, NULL); // Reopen debug.log on SIGHUP struct sigaction sa_hup; sa_hup.sa_handler = HandleSIGHUP; sigemptyset(&sa_hup.sa_mask); sa_hup.sa_flags = 0; sigaction(SIGHUP, &sa_hup, NULL); #endif // ********************************************************* Step 2: parameter interactions fTestNet = GetBoolArg("-testnet"); if (mapArgs.count("-bind")) { // when specifying an explicit binding address, you want to listen on it // even when -connect or -proxy is specified SoftSetBoolArg("-listen", true); } if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { // when only connecting to trusted nodes, do not seed via DNS, or listen by default SoftSetBoolArg("-dnsseed", false); SoftSetBoolArg("-listen", false); } if (mapArgs.count("-proxy")) { // to protect privacy, do not listen by default if a proxy server is specified SoftSetBoolArg("-listen", false); } if (!GetBoolArg("-listen", true)) { // do not map ports or try to retrieve public IP when not listening (pointless) SoftSetBoolArg("-upnp", false); // network discovery still needed to identify network (e.g. IPv4) } if (mapArgs.count("-externalip")) { // if an explicit public IP is specified, do not try to find others SoftSetBoolArg("-discover", false); } if (GetBoolArg("-salvagewallet")) { // Rewrite just private keys: rescan to find transactions SoftSetBoolArg("-rescan", true); } // -zapwallettx implies a rescan if (GetBoolArg("-zapwallettxes", false)) { if (SoftSetBoolArg("-rescan", true)) printf("AppInit2 : parameter interaction: -zapwallettxes=1 -> setting -rescan=1\n"); } // Make sure enough file descriptors are available int nBind = std::max((int)mapArgs.count("-bind"), 1); nMaxConnections = GetArg("-maxconnections", 125); nMaxConnections = std::max(std::min(nMaxConnections, (int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS)), 0); int nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS); if (nFD < MIN_CORE_FILEDESCRIPTORS) return InitError(_("Not enough file descriptors available.")); if (nFD - MIN_CORE_FILEDESCRIPTORS < nMaxConnections) nMaxConnections = nFD - MIN_CORE_FILEDESCRIPTORS; // ********************************************************* Step 3: parameter-to-internal-flags fDebug = GetBoolArg("-debug"); fBenchmark = GetBoolArg("-benchmark"); // -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency nScriptCheckThreads = GetArg("-par", 0); if (nScriptCheckThreads <= 0) nScriptCheckThreads += boost::thread::hardware_concurrency(); if (nScriptCheckThreads <= 1) nScriptCheckThreads = 0; else if (nScriptCheckThreads > MAX_SCRIPTCHECK_THREADS) nScriptCheckThreads = MAX_SCRIPTCHECK_THREADS; // -debug implies fDebug* if (fDebug) fDebugNet = true; else fDebugNet = GetBoolArg("-debugnet"); if (fDaemon) fServer = true; else fServer = GetBoolArg("-server"); /* force fServer when running without GUI */ #if !defined(QT_GUI) fServer = true; #endif fPrintToConsole = GetBoolArg("-printtoconsole"); fPrintToDebugger = GetBoolArg("-printtodebugger"); fLogTimestamps = GetBoolArg("-logtimestamps", true); if (mapArgs.count("-timeout")) { int nNewTimeout = GetArg("-timeout", 5000); if (nNewTimeout > 0 && nNewTimeout < 600000) nConnectTimeout = nNewTimeout; } // Continue to put "/P2SH/" in the coinbase to monitor // BIP16 support. // This can be removed eventually... const char* pszP2SH = "/P2SH/"; COINBASE_FLAGS << std::vector<unsigned char>(pszP2SH, pszP2SH+strlen(pszP2SH)); // Fee-per-kilobyte amount considered the same as "free" // If you are mining, be careful setting this: // if you set it to zero then // a transaction spammer can cheaply fill blocks using // 1-satoshi-fee transactions. It should be set above the real // cost to you of processing a transaction. // // ppcoin: -mintxfee and -minrelaytxfee options of OFIChain disabled // fixed min fees defined in MIN_TX_FEE and MIN_RELAY_TX_FEE if (mapArgs.count("-paytxfee")) { if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee) || nTransactionFee < MIN_TX_FEE) return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s'"), mapArgs["-paytxfee"].c_str())); if (nTransactionFee > 0.25 * COIN) InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction.")); } if (mapArgs.count("-checkpointkey")) // ppcoin: checkpoint master priv key { if (!SetCheckpointPrivKey(GetArg("-checkpointkey", ""))) return InitError(_("Unable to sign checkpoint, wrong checkpointkey?")); } // ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log std::string strDataDir = GetDataDir().string(); // Make sure only a single OFIChain process is using the data directory. boost::filesystem::path pathLockFile = GetDataDir() / ".lock"; FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist. if (file) fclose(file); static boost::interprocess::file_lock lock(pathLockFile.string().c_str()); if (!lock.try_lock()) return InitError(strprintf(_("Cannot obtain a lock on data directory %s. OFIChain is probably already running."), strDataDir.c_str())); if (GetBoolArg("-shrinkdebugfile", !fDebug)) ShrinkDebugFile(); printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); printf("OFIChain version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str()); printf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION)); if (!fLogTimestamps) printf("Startup time: %s\n", DateTimeStrFormat("%Y-%m-%d %H:%M:%S", GetTime()).c_str()); printf("Default data directory %s\n", GetDefaultDataDir().string().c_str()); printf("Using data directory %s\n", strDataDir.c_str()); printf("Using at most %i connections (%i file descriptors available)\n", nMaxConnections, nFD); std::ostringstream strErrors; if (fDaemon) fprintf(stdout, "OFIChain server starting\n"); if (nScriptCheckThreads) { printf("Using %u threads for script verification\n", nScriptCheckThreads); for (int i=0; i<nScriptCheckThreads-1; i++) threadGroup.create_thread(&ThreadScriptCheck); } int64 nStart; // ********************************************************* Step 5: verify wallet database integrity uiInterface.InitMessage(_("Verifying wallet...")); if (!bitdb.Open(GetDataDir())) { // try moving the database env out of the way boost::filesystem::path pathDatabase = GetDataDir() / "database"; boost::filesystem::path pathDatabaseBak = GetDataDir() / strprintf("database.%" PRI64d".bak", GetTime()); try { boost::filesystem::rename(pathDatabase, pathDatabaseBak); printf("Moved old %s to %s. Retrying.\n", pathDatabase.string().c_str(), pathDatabaseBak.string().c_str()); } catch(boost::filesystem::filesystem_error &error) { // failure is ok (well, not really, but it's not worse than what we started with) } // try again if (!bitdb.Open(GetDataDir())) { // if it still fails, it probably means we can't even create the database env string msg = strprintf(_("Error initializing wallet database environment %s!"), strDataDir.c_str()); return InitError(msg); } } if (GetBoolArg("-salvagewallet")) { // Recover readable keypairs: if (!CWalletDB::Recover(bitdb, "wallet.dat", true)) return false; } if (filesystem::exists(GetDataDir() / "wallet.dat")) { CDBEnv::VerifyResult r = bitdb.Verify("wallet.dat", CWalletDB::Recover); if (r == CDBEnv::RECOVER_OK) { string msg = strprintf(_("Warning: wallet.dat corrupt, data salvaged!" " Original wallet.dat saved as wallet.{timestamp}.bak in %s; if" " your balance or transactions are incorrect you should" " restore from a backup."), strDataDir.c_str()); InitWarning(msg); } if (r == CDBEnv::RECOVER_FAIL) return InitError(_("wallet.dat corrupt, salvage failed")); } // ********************************************************* Step 6: network initialization int nSocksVersion = GetArg("-socks", 5); if (nSocksVersion != 4 && nSocksVersion != 5) return InitError(strprintf(_("Unknown -socks proxy version requested: %i"), nSocksVersion)); if (mapArgs.count("-onlynet")) { std::set<enum Network> nets; BOOST_FOREACH(std::string snet, mapMultiArgs["-onlynet"]) { enum Network net = ParseNetwork(snet); if (net == NET_UNROUTABLE) return InitError(strprintf(_("Unknown network specified in -onlynet: '%s'"), snet.c_str())); nets.insert(net); } for (int n = 0; n < NET_MAX; n++) { enum Network net = (enum Network)n; if (!nets.count(net)) SetLimited(net); } } #if defined(USE_IPV6) #if ! USE_IPV6 else SetLimited(NET_IPV6); #endif #endif CService addrProxy; bool fProxy = false; if (mapArgs.count("-proxy")) { addrProxy = CService(mapArgs["-proxy"], 9050); if (!addrProxy.IsValid()) return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str())); if (!IsLimited(NET_IPV4)) SetProxy(NET_IPV4, addrProxy, nSocksVersion); if (nSocksVersion > 4) { #ifdef USE_IPV6 if (!IsLimited(NET_IPV6)) SetProxy(NET_IPV6, addrProxy, nSocksVersion); #endif SetNameProxy(addrProxy, nSocksVersion); } fProxy = true; } // -tor can override normal proxy, -notor disables tor entirely if (!(mapArgs.count("-tor") && mapArgs["-tor"] == "0") && (fProxy || mapArgs.count("-tor"))) { CService addrOnion; if (!mapArgs.count("-tor")) addrOnion = addrProxy; else addrOnion = CService(mapArgs["-tor"], 9050); if (!addrOnion.IsValid()) return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"].c_str())); SetProxy(NET_TOR, addrOnion, 5); SetReachable(NET_TOR); } // see Step 2: parameter interactions for more information about these fNoListen = !GetBoolArg("-listen", true); fDiscover = GetBoolArg("-discover", true); fNameLookup = GetBoolArg("-dns", true); bool fBound = false; if (!fNoListen) { if (mapArgs.count("-bind")) { BOOST_FOREACH(std::string strBind, mapMultiArgs["-bind"]) { CService addrBind; if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false)) return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind.c_str())); fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR)); } } else { struct in_addr inaddr_any; inaddr_any.s_addr = INADDR_ANY; #ifdef USE_IPV6 fBound |= Bind(CService(in6addr_any, GetListenPort()), BF_NONE); #endif fBound |= Bind(CService(inaddr_any, GetListenPort()), !fBound ? BF_REPORT_ERROR : BF_NONE); } if (!fBound) return InitError(_("Failed to listen on any port. Use -listen=0 if you want this.")); } if (mapArgs.count("-externalip")) { BOOST_FOREACH(string strAddr, mapMultiArgs["-externalip"]) { CService addrLocal(strAddr, GetListenPort(), fNameLookup); if (!addrLocal.IsValid()) return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr.c_str())); AddLocal(CService(strAddr, GetListenPort(), fNameLookup), LOCAL_MANUAL); } } BOOST_FOREACH(string strDest, mapMultiArgs["-seednode"]) AddOneShot(strDest); // ********************************************************* Step 7: load block chain fReindex = GetBoolArg("-reindex"); // Upgrading to 0.8; hard-link the old blknnnn.dat files into /blocks/ filesystem::path blocksDir = GetDataDir() / "blocks"; if (!filesystem::exists(blocksDir)) { filesystem::create_directories(blocksDir); bool linked = false; for (unsigned int i = 1; i < 10000; i++) { filesystem::path source = GetDataDir() / strprintf("blk%04u.dat", i); if (!filesystem::exists(source)) break; filesystem::path dest = blocksDir / strprintf("blk%05u.dat", i-1); try { filesystem::create_hard_link(source, dest); printf("Hardlinked %s -> %s\n", source.string().c_str(), dest.string().c_str()); linked = true; } catch (filesystem::filesystem_error & e) { // Note: hardlink creation failing is not a disaster, it just means // blocks will get re-downloaded from peers. printf("Error hardlinking blk%04u.dat : %s\n", i, e.what()); break; } } if (linked) { fReindex = true; } } // cache size calculations size_t nTotalCache = GetArg("-dbcache", 25) << 20; if (nTotalCache < (1 << 22)) nTotalCache = (1 << 22); // total cache cannot be less than 4 MiB size_t nBlockTreeDBCache = nTotalCache / 8; if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false)) nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB nTotalCache -= nBlockTreeDBCache; size_t nCoinDBCache = nTotalCache / 2; // use half of the remaining cache for coindb cache nTotalCache -= nCoinDBCache; nCoinCacheSize = nTotalCache / 300; // coins in memory require around 300 bytes bool fLoaded = false; while (!fLoaded) { bool fReset = fReindex; std::string strLoadError; uiInterface.InitMessage(_("Loading block index...")); nStart = GetTimeMillis(); do { try { UnloadBlockIndex(); delete pcoinsTip; delete pcoinsdbview; delete pblocktree; pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex); pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex); pcoinsTip = new CCoinsViewCache(*pcoinsdbview); if (fReindex) pblocktree->WriteReindexing(true); if (!LoadBlockIndex()) { strLoadError = _("Error loading block database"); break; } // Initialize the block index (no-op if non-empty database was already loaded) if (!InitBlockIndex()) { strLoadError = _("Error initializing block database"); break; } uiInterface.InitMessage(_("Verifying blocks...")); if (!VerifyDB()) { strLoadError = _("Corrupted block database detected"); break; } } catch(std::exception &e) { strLoadError = _("Error opening block database"); break; } fLoaded = true; } while(false); if (!fLoaded) { // first suggest a reindex if (!fReset) { bool fRet = uiInterface.ThreadSafeMessageBox( strLoadError + ".\n" + _("Do you want to rebuild the block database now?"), "", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT); if (fRet) { fReindex = true; fRequestShutdown = false; } else { return false; } } else { return InitError(strLoadError); } } } if (mapArgs.count("-txindex") && fTxIndex != GetBoolArg("-txindex", false)) return InitError(_("You need to rebuild the databases using -reindex to change -txindex")); // as LoadBlockIndex can take several minutes, it's possible the user // requested to kill OFIChain-qt during the last operation. If so, exit. // As the program has not fully started yet, Shutdown() is possibly overkill. if (fRequestShutdown) { printf("Shutdown requested. Exiting.\n"); return false; } printf(" block index %15" PRI64d"ms\n", GetTimeMillis() - nStart); if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree")) { PrintBlockTree(); return false; } if (mapArgs.count("-printblock")) { string strMatch = mapArgs["-printblock"]; int nFound = 0; for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi) { uint256 hash = (*mi).first; if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0) { CBlockIndex* pindex = (*mi).second; CBlock block; block.ReadFromDisk(pindex); block.BuildMerkleTree(); block.print(); printf("\n"); nFound++; } } if (nFound == 0) printf("No blocks matching %s were found\n", strMatch.c_str()); return false; } // ********************************************************* Step 8: load wallet if (GetBoolArg("-zapwallettxes", false)) { uiInterface.InitMessage(_("Zapping all transactions from wallet...")); pwalletMain = new CWallet("wallet.dat"); DBErrors nZapWalletRet = pwalletMain->ZapWalletTx(); if (nZapWalletRet != DB_LOAD_OK) { uiInterface.InitMessage(_("Error loading wallet.dat: Wallet corrupted")); return false; } delete pwalletMain; pwalletMain = NULL; } uiInterface.InitMessage(_("Loading wallet...")); nStart = GetTimeMillis(); bool fFirstRun = true; pwalletMain = new CWallet("wallet.dat"); DBErrors nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun); if (nLoadWalletRet != DB_LOAD_OK) { if (nLoadWalletRet == DB_CORRUPT) strErrors << _("Error loading wallet.dat: Wallet corrupted") << "\n"; else if (nLoadWalletRet == DB_NONCRITICAL_ERROR) { string msg(_("Warning: error reading wallet.dat! All keys read correctly, but transaction data" " or address book entries might be missing or incorrect.")); InitWarning(msg); } else if (nLoadWalletRet == DB_TOO_NEW) strErrors << _("Error loading wallet.dat: Wallet requires newer version of OFIChain") << "\n"; else if (nLoadWalletRet == DB_NEED_REWRITE) { strErrors << _("Wallet needed to be rewritten: restart OFIChain to complete") << "\n"; printf("%s", strErrors.str().c_str()); return InitError(strErrors.str()); } else strErrors << _("Error loading wallet.dat") << "\n"; } if (GetBoolArg("-upgradewallet", fFirstRun)) { int nMaxVersion = GetArg("-upgradewallet", 0); if (nMaxVersion == 0) // the -upgradewallet without argument case { printf("Performing wallet upgrade to %i\n", FEATURE_LATEST); nMaxVersion = CLIENT_VERSION; pwalletMain->SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately } else printf("Allowing wallet upgrade up to %i\n", nMaxVersion); if (nMaxVersion < pwalletMain->GetVersion()) strErrors << _("Cannot downgrade wallet") << "\n"; pwalletMain->SetMaxVersion(nMaxVersion); } if (fFirstRun) { // Create new keyUser and set as default key RandAddSeedPerfmon(); CPubKey newDefaultKey; if (pwalletMain->GetKeyFromPool(newDefaultKey, false)) { pwalletMain->SetDefaultKey(newDefaultKey); if (!pwalletMain->SetAddressBookName(pwalletMain->vchDefaultKey.GetID(), "")) strErrors << _("Cannot write default address") << "\n"; } pwalletMain->SetBestChain(CBlockLocator(pindexBest)); } printf("%s", strErrors.str().c_str()); printf(" wallet %15" PRI64d"ms\n", GetTimeMillis() - nStart); RegisterWallet(pwalletMain); CBlockIndex *pindexRescan = pindexBest; if (GetBoolArg("-rescan")) pindexRescan = pindexGenesisBlock; else { CWalletDB walletdb("wallet.dat"); CBlockLocator locator; if (walletdb.ReadBestBlock(locator)) pindexRescan = locator.GetBlockIndex(); else pindexRescan = pindexGenesisBlock; } if (pindexBest && pindexBest != pindexRescan && pindexRescan && pindexBest->nHeight > pindexRescan->nHeight) { uiInterface.InitMessage(_("Rescanning...")); printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight); nStart = GetTimeMillis(); pwalletMain->ScanForWalletTransactions(pindexRescan, true); printf(" rescan %15" PRI64d"ms\n", GetTimeMillis() - nStart); pwalletMain->SetBestChain(CBlockLocator(pindexBest)); nWalletDBUpdated++; } // ********************************************************* Step 9: import blocks // scan for better chains in the block chain database, that are not yet connected in the active best chain CValidationState state; if (!ConnectBestBlock(state)) strErrors << "Failed to connect best block"; std::vector<boost::filesystem::path> vImportFiles; if (mapArgs.count("-loadblock")) { BOOST_FOREACH(string strFile, mapMultiArgs["-loadblock"]) vImportFiles.push_back(strFile); } threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); // ********************************************************* Step 10: load peers uiInterface.InitMessage(_("Loading addresses...")); nStart = GetTimeMillis(); { CAddrDB adb; if (!adb.Read(addrman)) printf("Invalid or missing peers.dat; recreating\n"); } printf("Loaded %i addresses from peers.dat %" PRI64d"ms\n", addrman.size(), GetTimeMillis() - nStart); // ********************************************************* Step 11: start node if (!CheckDiskSpace()) return false; if (!strErrors.str().empty()) return InitError(strErrors.str()); RandAddSeedPerfmon(); //// debug print printf("mapBlockIndex.size() = %" PRIszu"\n", mapBlockIndex.size()); printf("nBestHeight = %d\n", nBestHeight); printf("setKeyPool.size() = %" PRIszu"\n", pwalletMain->setKeyPool.size()); printf("mapWallet.size() = %" PRIszu"\n", pwalletMain->mapWallet.size()); printf("mapAddressBook.size() = %" PRIszu"\n", pwalletMain->mapAddressBook.size()); #ifdef TESTING if (mapArgs.count("-timetravel")) nTimeShift = GetArg("-timetravel", 0); #endif StartNode(threadGroup); if (fServer) StartRPCThreads(); // Generate coins in the background GenerateOFIChains(GetBoolArg("-gen", false), pwalletMain); // ppcoin: mint proof-of-stake blocks in the background #ifdef TESTING if (GetBoolArg("-stakegen", true)) #endif MintStake(threadGroup, pwalletMain); // ********************************************************* Step 12: finished uiInterface.InitMessage(_("Done loading")); // Add wallet transactions that aren't already in a block to mapTransactions pwalletMain->ReacceptWalletTransactions(); // Run a thread to flush wallet periodically threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile))); return !fRequestShutdown; }
org 0x7c00 bits 16 %define Buffer_Seg 0x0700 %macro debug 0 pusha mov dx, 0x8A00 mov ax, dx out dx, ax mov ax, 0x8aE0 mov dx, 0x8a00 out dx, ax popa %endmacro jmp short main nop ;BPB - Bios Parameter Block BPB_OEM: Times 8 db 0x20 BPB_BytesPerSector: dw 512 BPB_SectorsPerCluster: db 1 BPB_ReservedSectors: dw 1 BPB_NumberOfFATs: db 2 BPB_RootEntires: dw 224 BPB_TotalSectors: dw 2880 BPB_Descriptor: db 0xF0 BPB_SectorsPerFAT: dw 9 BPB_SectorsPerTrack: dw 18 BPB_NumberOfHeads: dw 2 BPB_HiddenSectors: dd 0 BPB_TotalSecotrs32: dd 0 ;Extended BPB_DriveNumber: db 0 BPB_NTFlags: db 0 BPB_Signature: db 0x29 BPB_VolumeID: dd 0xAABBCCDD BPB_LabelString: times 11 db 0x20 BPB_SystemString: times 8 db 0x20 %define Buffer_Seg 0x1000 %include "FAT.inc" main: xor eax, eax mov ds, ax mov es, ax mov ss, ax ; mov sp, 0x1000 mov [BPB_DriveNumber], dl int 13h ; reset drive mov ax, 3 ; Set text-mode 3. int 10h ; text-mode 3 set. the screen is cleared ;Lookup Root Direcotry xor eax, eax mov al, [BPB_NumberOfFATs] mov dx, [BPB_SectorsPerFAT] mul dx add ax, [BPB_ReservedSectors] push ax xor di, di mov si, LoaderFile mov bx, Buffer_Seg mov es, bx xor dx, dx .NextDirectorySector: mov cx, 1 xor bx, bx push ax push di add ax, di call ReadSector jc boot_fail mov cx, 0x10 .NextFilePtr: mov al, [es:bx] test al, al jz .NoFile cmp al, 0xE5 je .NoFile mov al, [es:bx + 0xB] cmp al, 0x0F je .NoFile mov di, bx call strcmp jc FileFound .NoFile: add bx, 0x20 dec cx jnz .NextFilePtr pop di pop ax inc di mov bx, di cmp di, [BPB_RootEntires] jb .NextDirectorySector jmp boot_fail boot_fail: mov si,msg_boot_fail call print mov ax,0 int 0x16 int 0x19 jmp $ FileFound: add sp, 4 pop di mov ax, [BPB_RootEntires] shr ax, 4 add di, ax mov si, [es:bx + FAT_FileEntry.LowCluster] mov bx, Buffer_Seg mov es, bx mov gs, bx xor bx, bx xor dx, dx mov ax, 1 mov cx, [BPB_SectorsPerFAT] call ReadSector jc boot_fail mov bx, 0x0200 mov es, bx xor bx, bx .NextCluster: cmp si, 0x0FF8 je .NoMoreClusters call ReadCluster; jmp .NextCluster .NoMoreClusters: ;debug mov sp, 0x1000 jmp 0x0000:0x2000 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Reads a FAT12 cluster ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Inout: ES:BX -> buffer ;; ;; SI = cluster no ;; ;; GS:BP -> Loaded fat;; ;; Output: SI = next cluster ;; ;; ES:BX -> next addr ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ReadCluster: mov bp, sp mov ax, si add ax, di sub ax, 2 xor ch, ch mov cl, [BPB_SectorsPerCluster] ; cx = sector count mul cx xor dx,dx ; add ax, [ss:bp+1*2] ; adc dx, [ss:bp+2*2] ; dx:ax = LBA call ReadSector mov ax, [BPB_BytesPerSector] shr ax, 4 ; ax = paragraphs per sector mul cx ; ax = paragraphs read mov cx, es add cx, ax mov es, cx ; es:bx updated mov ax, 3 mul si mov cx, ax shr ax, 1 mov si, ax ; si = cluster * 3 / 2 mov ax, [gs:si] ; si = next cluster test cx, 1 jz .NoClusterShift shr ax, 4 .NoClusterShift: and ax, 0x0FFF mov si, ax ReadClusterDone: ret %define sectors_per_track BPB_SectorsPerTrack %define number_of_heads BPB_NumberOfHeads %define Drive_Number BPB_DriveNumber %define bytes_per_sector BPB_BytesPerSector %include "ReadSector.asm" print: ; ds:si - text push ax push bx push cx push si mov ah,0x0e mov cx,1 xor bx,bx print_1: mov al,[si] test al, al jz print_end inc si int 0x10 jmp print_1 print_end: pop si pop cx pop bx pop ax ret ;INPUT: ds:si - text1 ; es:di - text2 ;OUTPUT: if texts are equal carry flag is set ;this function changes only carry flag ;this function are not case sensitive strcmp: push si push di push ax .strcmp_loop: mov al, [ds:si] mov ah, [es:di] test ax, ax jz .equal cmp ah, al jne .not_equal inc di inc si jmp .strcmp_loop .equal: stc jmp .end .not_equal: clc .end: pop ax pop di pop si ret LoaderFile db 'SNLOADERBIN',0 msg_boot_fail db 'ERROR!',0x0A,0x0D,0 ;load_kernel db 'Booting Supernova...',10,13,0 TIMES 510-($-$$) DB 0 DW 0AA55H
; nasmfunc.asm ; TAB=4 section .text GLOBAL io_hlt, io_cli, io_sti, io_stihlt GLOBAL io_in8, io_in16, io_in32 GLOBAL io_out8, io_out16, io_out32 GLOBAL io_load_eflags, io_store_eflags io_hlt: ; void io_hlt(void) HLT RET io_cli: ; void io_cli(void) CLI RET io_sti: ; void io_sti(void) STI RET io_stihlt: ; void io_stihlt(void) STI HLT RET io_in8: ; int io_in8(int port) MOV EDX, [ESP+4] MOV EAX, 0 IN AL, DX RET io_in16: ; int io_in16(int port) MOV EDX, [ESP+4] MOV EAX, 0 IN AX, DX RET io_in32: ; int io_in32(int port) MOV EDX, [ESP+4] IN EAX, DX RET io_out8 ; void io_out8(int port, int data) MOV EDX, [ESP+4] MOV EAX, [ESP+8] OUT DX, AL RET io_out16 ; void io_out16(int port, int data) MOV EDX, [ESP+4] MOV EAX, [ESP+8] OUT DX, AX RET io_out32 ; void io_out32(int port, int data) MOV EDX, [ESP+4] MOV EAX, [ESP+8] OUT DX, EAX RET io_load_eflags: ; int io_load_eflags(void) PUSHFD ; push eflags POP EAX RET io_store_eflags: MOV EAX, [ESP+4] PUSH EAX POPFD ; pop eflags RET
; A058764: Smallest number x such that cototient(x) = 2^n. ; 2,4,6,12,24,48,96,192,384,768,1536,3072,6144,12288,24576,49152,98304,196608,393216,786432,1572864,3145728,6291456,12582912,25165824,50331648,100663296,201326592,402653184,805306368,1610612736,3221225472,6442450944,12884901888,25769803776,51539607552,103079215104,206158430208,412316860416,824633720832,1649267441664,3298534883328,6597069766656,13194139533312,26388279066624,52776558133248,105553116266496 mov $1,2 pow $1,$0 mul $1,3 add $1,3 div $1,4 mul $1,2 mov $0,$1
/************************************************************************\ Copyright 1997 The University of North Carolina at Chapel Hill. All Rights Reserved. Permission to use, copy, modify and distribute this software and its documentation for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and the following three paragraphs appear in all copies. IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF NORTH CAROLINA HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Permission to use, copy, modify and distribute this software and its documentation for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and the following three paragraphs appear in all copies. THE UNIVERSITY OF NORTH CAROLINA SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF NORTH CAROLINA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. --------------------------------- |Please send all BUG REPORTS to: | | | | geom@cs.unc.edu | | | --------------------------------- The authors may be contacted via: US Mail: A. Pattekar/J. Cohen/T. Hudson/S. Gottschalk/M. Lin/D. Manocha Department of Computer Science Sitterson Hall, CB #3175 University of N. Carolina Chapel Hill, NC 27599-3175 Phone: (919)962-1749 EMail: geom@cs.unc.edu \************************************************************************/ #include <iostream> #include <stdlib.h> #include "VCollide.H" using namespace std; int main(int argc, char *argv[]) { /* if (argc != 1) { cerr<<argv[0]<<": USAGE: "<<argv[0]<<"\n"; exit(1); }*/ VCollide vc; int id[2]; int i; for (i=0; i<2; i++) //create both the objects. { vc.NewObject(&id[i]); //the geometry is a unit cube with one vertex at the origin. double v1[3], v2[3], v3[3]; v1[0] = 0.0; v1[1] = 0.0; v1[2] = 0.0; v2[0] = 1.0; v2[1] = 0.0; v2[2] = 0.0; v3[0] = 1.0; v3[1] = 0.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 0); v1[0] = 0.0; v1[1] = 0.0; v1[2] = 0.0; v2[0] = 0.0; v2[1] = 0.0; v2[2] = 1.0; v3[0] = 1.0; v3[1] = 0.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 1); v1[0] = 0.0; v1[1] = 1.0; v1[2] = 0.0; v2[0] = 1.0; v2[1] = 1.0; v2[2] = 0.0; v3[0] = 1.0; v3[1] = 1.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 2); v1[0] = 0.0; v1[1] = 1.0; v1[2] = 0.0; v2[0] = 0.0; v2[1] = 1.0; v2[2] = 1.0; v3[0] = 1.0; v3[1] = 1.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 3); v1[0] = 1.0; v1[1] = 0.0; v1[2] = 0.0; v2[0] = 1.0; v2[1] = 1.0; v2[2] = 0.0; v3[0] = 1.0; v3[1] = 1.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 4); v1[0] = 1.0; v1[1] = 0.0; v1[2] = 0.0; v2[0] = 1.0; v2[1] = 0.0; v2[2] = 1.0; v3[0] = 1.0; v3[1] = 1.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 5); v1[0] = 0.0; v1[1] = 0.0; v1[2] = 0.0; v2[0] = 0.0; v2[1] = 1.0; v2[2] = 0.0; v3[0] = 0.0; v3[1] = 1.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 6); v1[0] = 0.0; v1[1] = 0.0; v1[2] = 0.0; v2[0] = 0.0; v2[1] = 0.0; v2[2] = 1.0; v3[0] = 0.0; v3[1] = 1.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 7); v1[0] = 1.0; v1[1] = 0.0; v1[2] = 1.0; v2[0] = 1.0; v2[1] = 1.0; v2[2] = 1.0; v3[0] = 0.0; v3[1] = 1.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 8); v1[0] = 1.0; v1[1] = 0.0; v1[2] = 1.0; v2[0] = 0.0; v2[1] = 0.0; v2[2] = 1.0; v3[0] = 0.0; v3[1] = 1.0; v3[2] = 1.0; vc.AddTri(v1, v2, v3, 9); v1[0] = 1.0; v1[1] = 0.0; v1[2] = 0.0; v2[0] = 1.0; v2[1] = 1.0; v2[2] = 0.0; v3[0] = 0.0; v3[1] = 1.0; v3[2] = 0.0; vc.AddTri(v1, v2, v3, 10); v1[0] = 1.0; v1[1] = 0.0; v1[2] = 0.0; v2[0] = 0.0; v2[1] = 0.0; v2[2] = 0.0; v3[0] = 0.0; v3[1] = 1.0; v3[2] = 0.0; vc.AddTri(v1, v2, v3, 11); vc.EndObject(); } double trans0[4][4], trans1[4][4]; //transformation matrices. //initialize the transformation matrices to identity. for (i=0; i<4; i++) { int j; for (j=0; j<4; j++) trans0[i][j] = trans1[i][j] = ( (i==j) ? 1.0 : 0.0 ); } int simulation_step=1; for (i=-25; i<=25; i++) //perform 51 frames of the simulation { cout<<"Simulation step: "<<simulation_step++<<"\n"; //in successive frames of the simulation, the two objects //approach each other from far and finally collide and cross //each other. trans0[0][3] = 0.25*i; //we translate both the objects trans1[0][3] = -0.25*i; //along the X-axis only. vc.UpdateTrans(id[0], trans0); vc.UpdateTrans(id[1], trans1); VCReport report; vc.Collide( &report ); //perform collision test. //default is VC_FIRST_CONTACT int j; for (j = 0; j < report.numObjPairs(); j++) cout<<"Detected collision between objects " <<report.obj1ID(j) <<" and "<< report.obj2ID(j) <<"\n"; vc.Collide( &report ); //perform collision test. //default is VC_FIRST_CONTACT for (int j = 0; j < report.numObjPairs(); j++) cout<<"Detected collision between objects " <<report.obj1ID(j) <<" and "<< report.obj2ID(j) <<"\n"; } return 0; }
// // GLUtilities.cpp // LearnGLFW // // Created by billthaslu on 2021/4/10. // #include "GLUtilities.hpp" #include <OpenGL/OpenGL.h> #include <OpenGL/gl.h> #include <OpenGL/glext.h> #include <iostream> #include "GLUtilities.hpp" GLuint compileShaders(void) { GLuint vertexShader = -1; GLuint fragmentShader = -1; GLuint program = -1; static const GLchar *vertexShaderSource[] = { "#version 330 core \n" "layout (location = 0) in vec3 Position; \n" "void main(void) \n" "{ \n" "gl_Position = vec4(Position.x, Position.y, Position.z, 1.0); \n" "} \n" }; static const GLchar *fragmentShaderSource = " \ #version 330 core \ out vec4 FragColor; \ void main(void) \ { \ FragColor = vec4(0.0, 0.8, 1.0, 1.0); \ } \ "; vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, vertexShaderSource, NULL); glCompileShader(vertexShader); GLint status = -1; glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { GLint logLength; glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &logLength); if (logLength > 0) { GLchar *log = (GLchar *)malloc(logLength); glGetShaderInfoLog(vertexShader, logLength, &logLength, log); std::cout << "ERROR\n" << log << std::endl; free(log); } } fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); glCompileShader(fragmentShader); status = -1; glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { GLint logLength; glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &logLength); if (logLength > 0) { GLchar *log = (GLchar *)malloc(logLength); glGetShaderInfoLog(fragmentShader, logLength, &logLength, log); std::cout << "ERROR\n" << log << std::endl; free(log); } } program = glCreateProgram(); glAttachShader(program, vertexShader); glAttachShader(program, fragmentShader); glLinkProgram(program); status = -1; glGetProgramiv(program, GL_LINK_STATUS, &status); if (status == GL_FALSE) { GLint logLength; glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength); if (logLength > 0) { GLchar *log = (GLchar *)malloc(logLength); glGetProgramInfoLog(program, logLength, &logLength, log); std::cout << "ERROR\n" << log << std::endl; free(log); } return false; } glDeleteShader(vertexShader); glDeleteShader(fragmentShader); return program; } GLuint compileShadersWithSources(const GLchar *vertexShaderSource, const GLchar *fragmentShaderSource) { GLuint vertexShader = -1; GLuint fragmentShader = -1; GLuint program = -1; vertexShader = glCreateShader(GL_VERTEX_SHADER); glShaderSource(vertexShader, 1, &vertexShaderSource, NULL); glCompileShader(vertexShader); GLint status = -1; glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { GLint logLength; glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &logLength); if (logLength > 0) { GLchar *log = (GLchar *)malloc(logLength); glGetShaderInfoLog(vertexShader, logLength, &logLength, log); std::cout << "ERROR\n" << log << std::endl; free(log); } } fragmentShader = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(fragmentShader, 1, &fragmentShaderSource, NULL); glCompileShader(fragmentShader); status = -1; glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &status); if (status == GL_FALSE) { GLint logLength; glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &logLength); if (logLength > 0) { GLchar *log = (GLchar *)malloc(logLength); glGetShaderInfoLog(fragmentShader, logLength, &logLength, log); std::cout << "ERROR\n" << log << std::endl; free(log); } } program = glCreateProgram(); glAttachShader(program, vertexShader); glAttachShader(program, fragmentShader); glLinkProgram(program); status = -1; glGetProgramiv(program, GL_LINK_STATUS, &status); if (status == GL_FALSE) { GLint logLength; glGetProgramiv(program, GL_INFO_LOG_LENGTH, &logLength); if (logLength > 0) { GLchar *log = (GLchar *)malloc(logLength); glGetProgramInfoLog(program, logLength, &logLength, log); std::cout << "ERROR\n" << log << std::endl; free(log); } return false; } glDeleteShader(vertexShader); glDeleteShader(fragmentShader); return program; }
; A189050: a(n) = if n even then P((n-2)/2)+P(n/2) otherwise 3*P((n+1)/2)+P((n-1)/2) where P(i) are the Pell numbers (A000129). ; Submitted by Jamie Morken(s3) ; 3,1,7,3,17,7,41,17,99,41,239,99,577,239,1393,577,3363,1393,8119,3363,19601,8119,47321,19601,114243,47321,275807,114243,665857,275807,1607521,665857,3880899,1607521,9369319,3880899,22619537,9369319,54608393,22619537,131836323,54608393,318281039,131836323,768398401,318281039,1855077841,768398401,4478554083,1855077841,10812186007,4478554083,26102926097,10812186007,63018038201,26102926097,152139002499,63018038201,367296043199,152139002499,886731088897,367296043199,2140758220993,886731088897 seq $0,165754 ; a(n) = nimsum(n+(n+1)+(n+2)). seq $0,152113 ; A001333 with terms repeated. div $0,2 mul $0,2 add $0,1
Name: ys_w17.asm Type: file Size: 13158 Last-Modified: '2016-05-13T04:51:15Z' SHA-1: 740A54D60C11977CB5B98DA1873644429CFD3F5C Description: null
//////////////////////////////////////////////////////////////////////////////// // $Workfile: ZipPathComponent.cpp $ // $Archive: /ZipArchive/ZipPathComponent.cpp $ // $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ //////////////////////////////////////////////////////////////////////////////// // This source file is part of the ZipArchive library source distribution and // is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // For the licensing details see the file License.txt //////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "ZipPathComponent.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// CZipPathComponent::~CZipPathComponent() { } void CZipPathComponent::SetFullPath(LPCTSTR lpszFullPath) { TCHAR szDrive[_MAX_DRIVE]; TCHAR szDir[_MAX_DIR]; TCHAR szFname[_MAX_FNAME]; TCHAR szExt[_MAX_EXT]; CZipString szTempPath(lpszFullPath); const CZipString szPrefix = _T("\\\\?\\unc\\"); int i = -1, iLen = szPrefix.GetLength(); if (iLen > szTempPath.GetLength()) iLen = szTempPath.GetLength(); CZipString szPossiblePrefix = szTempPath.Left(iLen); szPossiblePrefix.MakeLower(); // must perform case insensitive comparison while (++i < iLen && szPossiblePrefix[i] == szPrefix[i]); if (i == 2 || i == 4 || i == 8) // unc path, unicode path or unc path meeting windows file name conventions { m_szPrefix = szTempPath.Left(i); szTempPath = szTempPath.Mid(i); } else m_szPrefix.Empty(); _tsplitpath(szTempPath, szDrive , szDir, szFname, szExt); m_szDrive = szDrive; m_szDirectory = szDir; m_szDirectory.TrimLeft(m_cSeparator); m_szDirectory.TrimRight(m_cSeparator); SetExtension(szExt); m_szFileTitle = szFname; } CZipString CZipPathComponent::GetNoDrive() const { CZipString szPath = m_szDirectory; CZipString szFileName = GetFileName(); if (!szFileName.IsEmpty() && !szPath.IsEmpty()) szPath += m_cSeparator; szPath += szFileName; return szPath; }
; A215502: a(n) = (1+sqrt(3))^n + (-2)^n + (1-sqrt(3))^n + 1. ; Submitted by Christian Krause ; 4,1,13,13,73,121,481,1009,3361,7969,24193,61249,177025,464257,1307137,3493633,9699841,26190337,72173569,195941377,537802753,1464342529,4010582017,10937266177,29920862209,81665925121,223274237953,609678999553,1666309128193,4551170949121,12436570767361,33972262207489,92824108400641,253579856314369,692833699233793,1892775571488769,5171321620660225,14127988225867777,38599032009916417,105453215837847553,288106144962969601,787115423066750977,2150449733129207809,5875117118252384257 mov $1,-2 pow $1,$0 seq $0,80040 ; a(n) = 2*a(n-1) + 2*a(n-2) for n > 1; a(0)=2, a(1)=2. add $1,$0 mov $0,$1 add $0,1
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r15 push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0xa204, %r13 nop nop nop nop nop cmp %r12, %r12 movb $0x61, (%r13) nop nop nop and $14380, %rcx lea addresses_D_ht+0x3084, %rsi lea addresses_normal_ht+0x509c, %rdi nop xor $13985, %rdx mov $87, %rcx rep movsq nop nop nop sub $16162, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %r15 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r15 push %r8 push %rbp push %rbx push %rdx // Store lea addresses_UC+0x12af4, %r15 nop nop add %r14, %r14 mov $0x5152535455565758, %r8 movq %r8, %xmm6 vmovups %ymm6, (%r15) nop nop inc %rbp // Store lea addresses_US+0xdb30, %r8 sub $50889, %r14 mov $0x5152535455565758, %rdx movq %rdx, %xmm0 movups %xmm0, (%r8) nop nop add %r15, %r15 // Store lea addresses_UC+0x2784, %rbp nop nop nop nop xor %r12, %r12 movw $0x5152, (%rbp) nop nop add $58149, %rdx // Faulty Load lea addresses_WC+0x5784, %r14 clflush (%r14) nop nop nop and $13360, %r12 mov (%r14), %r8 lea oracles, %r15 and $0xff, %r8 shlq $12, %r8 mov (%r15,%r8,1), %r8 pop %rdx pop %rbx pop %rbp pop %r8 pop %r15 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_US', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}} {'00': 1380, '52': 689} 00 00 00 52 52 00 00 00 00 52 52 00 00 52 52 52 00 00 00 00 00 00 00 00 00 00 00 52 00 52 52 00 00 00 00 00 52 00 00 00 52 00 00 00 00 00 52 52 00 00 00 00 52 00 00 00 00 00 52 00 00 00 52 00 00 00 00 00 52 00 52 00 52 52 00 52 52 00 00 52 00 00 00 00 52 00 00 00 52 52 00 52 52 00 00 00 00 52 52 52 00 00 52 00 00 52 52 00 00 00 52 00 00 52 00 00 52 52 52 52 52 00 52 00 52 52 00 52 00 00 00 00 52 00 00 00 00 52 52 00 00 00 52 00 00 00 00 52 00 00 00 00 52 00 00 00 00 00 52 52 00 00 00 52 52 00 00 00 00 52 00 52 00 00 00 00 00 00 00 00 00 52 00 52 00 52 00 00 52 00 00 00 00 00 52 00 00 52 00 00 52 52 00 00 00 52 52 00 00 52 00 00 00 00 52 00 52 52 00 52 00 00 00 52 00 52 00 00 00 00 00 00 00 00 00 00 00 52 00 00 52 00 52 00 00 52 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 52 00 52 00 52 00 00 00 52 00 00 52 00 00 00 00 00 00 52 00 00 52 00 00 52 52 00 00 52 52 00 00 00 52 00 52 00 52 00 00 00 52 00 00 00 52 00 00 00 52 00 00 52 00 52 00 00 52 00 52 52 00 00 00 00 00 00 52 00 00 00 00 52 00 00 00 52 52 00 00 52 00 00 52 00 00 00 00 00 52 52 52 52 52 52 00 00 00 00 00 00 52 00 00 52 00 52 52 00 52 00 00 00 00 00 52 52 52 52 00 00 52 52 00 00 00 52 52 00 52 00 52 00 52 00 00 52 00 52 00 00 00 00 00 00 52 00 00 00 00 52 00 00 00 52 00 00 52 52 00 00 00 00 00 52 52 00 00 52 00 52 52 00 00 00 52 00 00 00 52 00 00 00 00 00 00 00 00 00 52 00 00 00 52 00 52 00 52 00 00 00 52 52 00 52 52 00 52 52 00 52 00 00 00 52 00 00 00 52 00 52 00 00 52 52 00 52 00 52 00 52 00 00 00 00 00 00 00 00 00 52 52 00 00 00 00 00 00 00 52 52 52 00 00 00 00 00 00 00 00 00 52 00 00 00 52 00 00 52 52 00 52 00 00 52 00 52 52 00 00 52 00 00 00 00 00 00 00 52 00 00 52 00 00 52 00 00 00 00 52 00 52 00 00 52 00 52 00 00 00 00 00 00 00 00 00 52 00 00 52 52 00 00 00 00 00 00 00 00 00 00 00 00 00 00 52 52 00 52 52 00 00 00 00 00 00 52 00 52 52 00 00 00 52 00 52 00 00 52 00 00 00 00 00 52 52 52 00 00 52 00 52 52 00 00 52 00 00 52 52 00 52 00 00 00 52 00 52 00 00 00 00 52 00 00 00 00 00 00 00 52 52 00 52 00 52 00 00 00 00 00 00 00 00 00 52 00 00 00 00 00 00 52 00 00 52 52 00 52 52 00 00 00 52 00 00 52 00 52 52 52 52 52 00 52 52 52 00 00 52 00 00 00 52 00 52 52 00 00 00 52 00 00 52 00 00 00 00 00 52 52 52 52 00 00 00 00 00 00 00 00 00 00 00 00 52 00 00 00 52 52 00 00 52 00 52 00 00 00 52 52 52 00 52 00 00 00 00 00 00 52 52 52 00 00 52 00 52 00 52 00 52 52 52 52 52 00 00 00 52 00 00 52 00 00 00 00 52 00 00 52 00 52 00 00 00 52 00 00 52 52 00 00 00 52 52 00 00 00 00 00 00 00 52 00 52 00 52 52 00 00 52 00 52 00 00 00 00 00 52 00 00 00 00 00 52 00 00 00 00 52 52 52 00 52 00 52 52 52 52 52 52 00 52 00 52 00 00 52 00 52 00 00 00 00 00 00 00 00 52 00 00 00 00 52 00 00 52 00 52 00 00 00 00 00 52 00 00 00 52 52 00 52 52 00 00 00 52 52 00 00 00 52 00 00 00 52 52 52 52 00 00 00 00 00 52 52 00 00 00 52 00 52 00 00 00 00 52 00 52 00 00 00 00 00 52 52 00 52 00 52 52 00 52 52 52 52 00 00 52 52 00 00 00 00 52 52 00 00 00 00 00 00 00 00 52 52 00 00 00 52 52 00 00 00 00 00 52 52 00 52 00 00 52 00 00 00 00 */
; Options: ; startup=1 --> RAM mode ; startup=2 --> ROM mode (position code at location 0 and provide minimal interrupt services) ; ; CRT_ORG_CODE = start address ; CRT_ORG_BSS = address for bss variables ; CRT_MODEL = 0 (RAM), 1 = (ROM, code copied), 2 = (ROM, code compressed) ; ; djm 18/5/99 ; ; $Id: spec_crt0.asm,v 1.53 2016-07-16 07:06:27 dom Exp $ ; MODULE zx82_crt0 ;-------- ; Include zcc_opt.def to find out some info ;-------- defc crt0 = 1 INCLUDE "zcc_opt.def" ;-------- ; Some scope definitions ;-------- EXTERN _main ; main() is always external to crt0 code PUBLIC cleanup ; jp'd to by exit() PUBLIC l_dcal ; jp(hl) PUBLIC call_rom3 ; Interposer PUBLIC _FRAMES defc _FRAMES = 23672 ; Timer IF DEFINED_ZXVGS IF !DEFINED_CRT_ORG_CODE DEFC CRT_ORG_CODE = $5CCB ; repleaces BASIC program defc DEFINED_CRT_ORG_CODE = 1 ENDIF IF !STACKPTR DEFC STACKPTR = $FF57 ; below UDG, keep eye when using banks ENDIF ENDIF IF !DEFINED_CRT_ORG_CODE IF (startup=2) ; ROM ? defc CRT_ORG_CODE = 0 defc STACKPTR = 32767 ELSE defc CRT_ORG_CODE = 32768 ENDIF ENDIF org CRT_ORG_CODE start: ; --- startup=2 ---> build a ROM IF (startup=2) di ; put hardware in a stable state ld a,$3F ld i,a jr init ; go over rst 8, bypass shadow ROM defs $0008-ASMPC if (ASMPC<>$0008) defs CODE_ALIGNMENT_ERROR endif ; --- rst 8 --- ld hl,($5c5d) ; It was the address reached by CH-ADD. nop ; one byte still, to jump over the ; Opus Discovery and similar shadowing traps ; --- nothing more ? init: im 1 ld sp,STACKPTR-64 ld a,@111000 ; White PAPER, black INK call zx_internal_cls ld (hl),0 ld bc,42239 ldir ei ELSE ; --- startup=[default] --- ld iy,23610 ; restore the right iy value, ; fixing the self-relocating trick, if any IF !DEFINED_ZXVGS ld (start1+1),sp ; Save entry stack ENDIF IF STACKPTR ld sp,STACKPTR ENDIF ld hl,-64 add hl,sp ld sp,hl call crt0_init_bss ld (exitsp),sp ; Optional definition for auto MALLOC init; it takes ; all the space between the end of the program and UDG IF DEFINED_USING_amalloc ld hl,_heap ld c,(hl) inc hl ld b,(hl) inc bc ; compact way to do "mallinit()" xor a ld (hl),a dec hl ld (hl),a ; Stack is somewhere else, no need to reduce the size for malloc ld hl,65535-168 ; Preserve UDG sbc hl,bc ; hl = total free memory push bc ; main address for malloc area push hl ; area size EXTERN sbrk_callee call sbrk_callee ENDIF IF DEFINED_ZXVGS ;setting variables needed for proper keyboard reading LD (IY+1),$CD ; FLAGS #5C3B LD (IY+48),1 ; FLAGS2 #5C6A EI ; ZXVGS starts with disabled interrupts ENDIF ld a,2 ; open the upper display (uneeded?) call 5633 ENDIF IF DEFINED_NEEDresidos call residos_detect jp c,cleanup_exit ENDIF call _main ; Call user program cleanup: ; ; Deallocate memory which has been allocated here! ; push hl IF !DEFINED_nostreams EXTERN closeall call closeall ENDIF IF (startup=2) ; ROM ? cleanup_exit: rst 0 defs 56-cleanup_exit-1 if (ASMPC<>$0038) defs CODE_ALIGNMENT_ERROR endif ; ######## IM 1 MODE INTERRUPT ENTRY ######## INCLUDE "spec_crt0_rom_isr.as1" ; ######## END OF ROM INTERRUPT HANDLER ######## PUBLIC zx_internal_cls zx_internal_cls: ld hl,$4000 ; cls ld d,h ld e,l inc de ld (hl),0 ld bc,$1800 ldir ld (hl),a ld bc,768 ldir rrca rrca rrca out (254),a ret ELSE IF DEFINED_ZXVGS POP BC ;let's say exit code goes to BC RST 8 DEFB $FD ;Program finished ELSE cleanup_exit: ld hl,10072 ;Restore hl' to what basic wants exx pop bc start1: ld sp,0 ;Restore stack to entry value ret ENDIF ENDIF l_dcal: jp (hl) ;Used for function pointer calls ; Runtime selection INCLUDE "crt0_runtime_selection.asm" ;--------------------------------------------- ; Some +3 stuff - this needs to be below 49152 ;--------------------------------------------- IF DEFINED_NEEDresidos INCLUDE "idedos.def" defc ERR_NR=$5c3a ; BASIC system variables defc ERR_SP=$5c3d PUBLIC dodos ; ; This is support for residos, we use the normal ; +3 -lplus3 library and rewrite the values so ; that they suit us somewhat dodos: exx push iy pop hl ld b,PKG_IDEDOS rst RST_HOOK defb HOOK_PACKAGE ld iy,23610 ret ; Detect an installed version of ResiDOS. ; ; This should be done before you attempt to call any other ResiDOS/+3DOS/IDEDOS ; routines, and ensures that the Spectrum is running with ResiDOS installed. ; Since +3DOS and IDEDOS are present only from v1.40, this version must ; be checked for before making any further calls. ; ; If you need to use calls that were only provided from a certain version of ; ResiDOS, you can check that here as well. ; ; The ResiDOS version call is made with a special hook-code after a RST 8, ; which will cause an error on Speccies without ResiDOS v1.20+ installed, ; or error 0 (OK) if ResiDOS v1.20+ is present. Therefore, we need ; to trap any errors here. residos_detect: ld hl,(ERR_SP) push hl ; save the existing ERR_SP ld hl,detect_error push hl ; stack error-handler return address ld hl,0 add hl,sp ld (ERR_SP),hl ; set the error-handler SP rst RST_HOOK ; invoke the version info hook code defb HOOK_VERSION pop hl ; ResiDOS doesn't return, so if we get jr noresidos ; here, some other hardware is present detect_error: pop hl ld (ERR_SP),hl ; restore the old ERR_SP ld a,(ERR_NR) inc a ; is the error code now "OK"? jr nz,noresidos ; if not, ResiDOS was not detected ex de,hl ; get HL=ResiDOS version push hl ; save the version ld de,$0140 ; DE=minimum version to run with and a sbc hl,de pop bc ; restore the version to BC ret nc ; and return with it if at least v1.40 noresidos: ld bc,0 ; no ResiDOS ld a,$ff ld (ERR_NR),a ; clear error ret ENDIF ;--------------------------------------------- ; Some +3 stuff - this needs to be below 49152 ;--------------------------------------------- IF DEFINED_NEEDplus3dodos ; Routine to call +3DOS Routines. Located in startup ; code to ensure we don't get paged out ; (These routines have to be below 49152) ; djm 17/3/2000 (after the manual!) PUBLIC dodos dodos: call dodos2 ;dummy routine to restore iy afterwards ld iy,23610 ret dodos2: push af push bc ld a,7 ld bc,32765 di ld (23388),a out (c),a ei pop bc pop af call cjumpiy push af push bc ld a,16 ld bc,32765 di ld (23388),a out (c),a ei pop bc pop af ret cjumpiy: jp (iy) ENDIF ; Call a routine in the spectrum ROM ; The routine to call is stored in the two bytes following call_rom3: exx ; Use alternate registers IF DEFINED_NEED_ZXMMC push af xor a ; standard ROM out ($7F),a ; ZXMMC FASTPAGE pop af ENDIF ex (sp),hl ; get return address ld c,(hl) inc hl ld b,(hl) ; BC=BASIC address inc hl ex (sp),hl ; restore return address push bc exx ; Back to the regular set ret defm "Small C+ ZX" ;Unnecessary file signature defb 0 IF (startup=2) ;ROM IF !DEFINED_CRT_ORG_BSS defc CRT_ORG_BSS = 24576 defc DEFINED_CRT_ORG_BSS = 1 ENDIF ; If we were given a model then use it IF DEFINED_CRT_MODEL defc __crt_model = CRT_MODEL ELSE defc __crt_model = 1 ENDIF ENDIF ; If we were given an address for the BSS then use it IF DEFINED_CRT_ORG_BSS defc __crt_org_bss = CRT_ORG_BSS ENDIF INCLUDE "crt0_section.asm" SECTION code_crt_init ld a,@111000 ; White PAPER, black INK ld ($5c48),a ; BORDCR ld ($5c8d),a ; ATTR_P ld ($5c8f),a ; ATTR_T SECTION bss_crt IF startup=2 PUBLIC romsvc romsvc: defs 10 ; Pointer to the end of the sysdefvars ; used by the ROM version of some library ENDIF SECTION rodata_clib ; Default block size for "gendos.lib" ; every single block (up to 36) is written in a separate file ; the bigger RND_BLOCKSIZE, bigger can be the output file size ; but this comes at cost of the malloc'd space for the internal buffer ; Current block size is kept in a control block (just a structure saved ; in a separate file, so changing this value ; at runtime before creating a file is perfectly legal. _RND_BLOCKSIZE: defw 1000 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Define Memory Banks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IFNDEF CRT_ORG_BANK_00 defc CRT_ORG_BANK_00 = 0xc000 ENDIF IFNDEF CRT_ORG_BANK_01 defc CRT_ORG_BANK_01 = 0xc000 ENDIF IFNDEF CRT_ORG_BANK_02 defc CRT_ORG_BANK_02 = 0xc000 ENDIF IFNDEF CRT_ORG_BANK_03 defc CRT_ORG_BANK_03 = 0xc000 ENDIF IFNDEF CRT_ORG_BANK_04 defc CRT_ORG_BANK_04 = 0xc000 ENDIF IFNDEF CRT_ORG_BANK_05 defc CRT_ORG_BANK_05 = 0xc000 ENDIF IFNDEF CRT_ORG_BANK_06 defc CRT_ORG_BANK_06 = 0xc000 ENDIF IFNDEF CRT_ORG_BANK_07 defc CRT_ORG_BANK_07 = 0xc000 ENDIF SECTION BANK_00 org CRT_ORG_BANK_00 SECTION BANK_01 org CRT_ORG_BANK_01 SECTION BANK_02 org CRT_ORG_BANK_02 SECTION BANK_03 org CRT_ORG_BANK_03 SECTION BANK_04 org CRT_ORG_BANK_04 SECTION BANK_05 org CRT_ORG_BANK_05 SECTION BANK_06 org CRT_ORG_BANK_06 SECTION BANK_07 org CRT_ORG_BANK_07
; Copyright © 2021, VideoLAN and dav1d authors ; Copyright © 2021, Two Orioles, LLC ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, this ; list of conditions and the following disclaimer. ; ; 2. Redistributions in binary form must reproduce the above copyright notice, ; this list of conditions and the following disclaimer in the documentation ; and/or other materials provided with the distribution. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %include "config.asm" %include "ext/x86/x86inc.asm" %if ARCH_X86_64 SECTION_RODATA 32 ; dav1d_obmc_masks[] * -512 obmc_masks: dw 0, 0, -9728, 0, -12800, -7168, -2560, 0 dw -14336, -11264, -8192, -5632, -3584, -1536, 0, 0 dw -15360, -13824, -12288, -10752, -9216, -7680, -6144, -5120 dw -4096, -3072, -2048, -1536, 0, 0, 0, 0 dw -15872, -14848, -14336, -13312, -12288, -11776, -10752, -10240 dw -9728, -8704, -8192, -7168, -6656, -6144, -5632, -4608 dw -4096, -3584, -3072, -2560, -2048, -2048, -1536, -1024 blend_shuf: db 0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 2, 3 deint_shuf: dd 0, 4, 1, 5, 2, 6, 3, 7 subpel_h_shufA: db 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9 subpel_h_shufB: db 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 13 subpel_h_shuf2: db 0, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 8, 9 put_bilin_h_rnd: dw 8, 8, 10, 10 prep_mul: dw 16, 16, 4, 4 put_8tap_h_rnd: dd 34, 40 prep_8tap_1d_rnd: dd 8 - (8192 << 4) prep_8tap_2d_rnd: dd 32 - (8192 << 5) warp8x8t_rnd: dd 16384 - (8192 << 15) warp8x8_shift: dd 5, 3 warp8x8_rnd: dw 4096, 4096, 16384, 16384 bidir_rnd: dw -16400, -16400, -16388, -16388 bidir_mul: dw 2048, 2048, 8192, 8192 %define pw_16 prep_mul pw_2: times 2 dw 2 pw_64: times 2 dw 64 pw_2048: times 2 dw 2048 pw_8192: times 2 dw 8192 pw_27615: times 2 dw 27615 pw_32766: times 2 dw 32766 pw_m512: times 2 dw -512 pd_32: dd 32 pd_512: dd 512 pd_32768: dd 32768 pd_65538: dd 65538 %macro BIDIR_JMP_TABLE 2-* %xdefine %1_%2_table (%%table - 2*%3) %xdefine %%base %1_%2_table %xdefine %%prefix mangle(private_prefix %+ _%1_16bpc_%2) %%table: %rep %0 - 2 dd %%prefix %+ .w%3 - %%base %rotate 1 %endrep %endmacro BIDIR_JMP_TABLE avg, avx2, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE w_avg, avx2, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE mask, avx2, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE w_mask_420, avx2, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE w_mask_422, avx2, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE w_mask_444, avx2, 4, 8, 16, 32, 64, 128 BIDIR_JMP_TABLE blend, avx2, 4, 8, 16, 32 BIDIR_JMP_TABLE blend_v, avx2, 2, 4, 8, 16, 32 BIDIR_JMP_TABLE blend_h, avx2, 2, 4, 8, 16, 32, 64, 128 %macro BASE_JMP_TABLE 3-* %xdefine %1_%2_table (%%table - %3) %xdefine %%base %1_%2 %%table: %rep %0 - 2 dw %%base %+ _w%3 - %%base %rotate 1 %endrep %endmacro %xdefine put_avx2 mangle(private_prefix %+ _put_bilin_16bpc_avx2.put) %xdefine prep_avx2 mangle(private_prefix %+ _prep_bilin_16bpc_avx2.prep) BASE_JMP_TABLE put, avx2, 2, 4, 8, 16, 32, 64, 128 BASE_JMP_TABLE prep, avx2, 4, 8, 16, 32, 64, 128 %macro HV_JMP_TABLE 5-* %xdefine %%prefix mangle(private_prefix %+ _%1_%2_16bpc_%3) %xdefine %%base %1_%3 %assign %%types %4 %if %%types & 1 %xdefine %1_%2_h_%3_table (%%h - %5) %%h: %rep %0 - 4 dw %%prefix %+ .h_w%5 - %%base %rotate 1 %endrep %rotate 4 %endif %if %%types & 2 %xdefine %1_%2_v_%3_table (%%v - %5) %%v: %rep %0 - 4 dw %%prefix %+ .v_w%5 - %%base %rotate 1 %endrep %rotate 4 %endif %if %%types & 4 %xdefine %1_%2_hv_%3_table (%%hv - %5) %%hv: %rep %0 - 4 dw %%prefix %+ .hv_w%5 - %%base %rotate 1 %endrep %endif %endmacro HV_JMP_TABLE put, bilin, avx2, 7, 2, 4, 8, 16, 32, 64, 128 HV_JMP_TABLE prep, bilin, avx2, 7, 4, 8, 16, 32, 64, 128 %define table_offset(type, fn) type %+ fn %+ SUFFIX %+ _table - type %+ SUFFIX cextern mc_subpel_filters %define subpel_filters (mangle(private_prefix %+ _mc_subpel_filters)-8) cextern mc_warp_filter SECTION .text INIT_XMM avx2 cglobal put_bilin_16bpc, 4, 8, 0, dst, ds, src, ss, w, h, mxy mov mxyd, r6m ; mx lea r7, [put_avx2] %if UNIX64 DECLARE_REG_TMP 8 %define org_w r8d mov r8d, wd %else DECLARE_REG_TMP 7 %define org_w wm %endif tzcnt wd, wm movifnidn hd, hm test mxyd, mxyd jnz .h mov mxyd, r7m ; my test mxyd, mxyd jnz .v .put: movzx wd, word [r7+wq*2+table_offset(put,)] add wq, r7 jmp wq .put_w2: mov r6d, [srcq+ssq*0] mov r7d, [srcq+ssq*1] lea srcq, [srcq+ssq*2] mov [dstq+dsq*0], r6d mov [dstq+dsq*1], r7d lea dstq, [dstq+dsq*2] sub hd, 2 jg .put_w2 RET .put_w4: mov r6, [srcq+ssq*0] mov r7, [srcq+ssq*1] lea srcq, [srcq+ssq*2] mov [dstq+dsq*0], r6 mov [dstq+dsq*1], r7 lea dstq, [dstq+dsq*2] sub hd, 2 jg .put_w4 RET .put_w8: movu m0, [srcq+ssq*0] movu m1, [srcq+ssq*1] lea srcq, [srcq+ssq*2] mova [dstq+dsq*0], m0 mova [dstq+dsq*1], m1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .put_w8 RET INIT_YMM avx2 .put_w16: movu m0, [srcq+ssq*0] movu m1, [srcq+ssq*1] lea srcq, [srcq+ssq*2] mova [dstq+dsq*0], m0 mova [dstq+dsq*1], m1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .put_w16 RET .put_w32: movu m0, [srcq+ssq*0+32*0] movu m1, [srcq+ssq*0+32*1] movu m2, [srcq+ssq*1+32*0] movu m3, [srcq+ssq*1+32*1] lea srcq, [srcq+ssq*2] mova [dstq+dsq*0+32*0], m0 mova [dstq+dsq*0+32*1], m1 mova [dstq+dsq*1+32*0], m2 mova [dstq+dsq*1+32*1], m3 lea dstq, [dstq+dsq*2] sub hd, 2 jg .put_w32 RET .put_w64: movu m0, [srcq+32*0] movu m1, [srcq+32*1] movu m2, [srcq+32*2] movu m3, [srcq+32*3] add srcq, ssq mova [dstq+32*0], m0 mova [dstq+32*1], m1 mova [dstq+32*2], m2 mova [dstq+32*3], m3 add dstq, dsq dec hd jg .put_w64 RET .put_w128: movu m0, [srcq+32*0] movu m1, [srcq+32*1] movu m2, [srcq+32*2] movu m3, [srcq+32*3] mova [dstq+32*0], m0 mova [dstq+32*1], m1 mova [dstq+32*2], m2 mova [dstq+32*3], m3 movu m0, [srcq+32*4] movu m1, [srcq+32*5] movu m2, [srcq+32*6] movu m3, [srcq+32*7] add srcq, ssq mova [dstq+32*4], m0 mova [dstq+32*5], m1 mova [dstq+32*6], m2 mova [dstq+32*7], m3 add dstq, dsq dec hd jg .put_w128 RET .h: movd xm5, mxyd mov mxyd, r7m ; my vpbroadcastd m4, [pw_16] vpbroadcastw m5, xm5 psubw m4, m5 test mxyd, mxyd jnz .hv ; 12-bit is rounded twice so we can't use the same pmulhrsw approach as .v movzx wd, word [r7+wq*2+table_offset(put, _bilin_h)] mov r6d, r8m ; bitdepth_max add wq, r7 shr r6d, 11 vpbroadcastd m3, [r7-put_avx2+put_bilin_h_rnd+r6*4] jmp wq .h_w2: movq xm1, [srcq+ssq*0] movhps xm1, [srcq+ssq*1] lea srcq, [srcq+ssq*2] pmullw xm0, xm4, xm1 psrlq xm1, 16 pmullw xm1, xm5 paddw xm0, xm3 paddw xm0, xm1 psrlw xm0, 4 movd [dstq+dsq*0], xm0 pextrd [dstq+dsq*1], xm0, 2 lea dstq, [dstq+dsq*2] sub hd, 2 jg .h_w2 RET .h_w4: movq xm0, [srcq+ssq*0] movhps xm0, [srcq+ssq*1] movq xm1, [srcq+ssq*0+2] movhps xm1, [srcq+ssq*1+2] lea srcq, [srcq+ssq*2] pmullw xm0, xm4 pmullw xm1, xm5 paddw xm0, xm3 paddw xm0, xm1 psrlw xm0, 4 movq [dstq+dsq*0], xm0 movhps [dstq+dsq*1], xm0 lea dstq, [dstq+dsq*2] sub hd, 2 jg .h_w4 RET .h_w8: movu xm0, [srcq+ssq*0] vinserti128 m0, [srcq+ssq*1], 1 movu xm1, [srcq+ssq*0+2] vinserti128 m1, [srcq+ssq*1+2], 1 lea srcq, [srcq+ssq*2] pmullw m0, m4 pmullw m1, m5 paddw m0, m3 paddw m0, m1 psrlw m0, 4 mova [dstq+dsq*0], xm0 vextracti128 [dstq+dsq*1], m0, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .h_w8 RET .h_w16: pmullw m0, m4, [srcq+ssq*0] pmullw m1, m5, [srcq+ssq*0+2] paddw m0, m3 paddw m0, m1 pmullw m1, m4, [srcq+ssq*1] pmullw m2, m5, [srcq+ssq*1+2] lea srcq, [srcq+ssq*2] paddw m1, m3 paddw m1, m2 psrlw m0, 4 psrlw m1, 4 mova [dstq+dsq*0], m0 mova [dstq+dsq*1], m1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .h_w16 RET .h_w32: pmullw m0, m4, [srcq+32*0] pmullw m1, m5, [srcq+32*0+2] paddw m0, m3 paddw m0, m1 pmullw m1, m4, [srcq+32*1] pmullw m2, m5, [srcq+32*1+2] add srcq, ssq paddw m1, m3 paddw m1, m2 psrlw m0, 4 psrlw m1, 4 mova [dstq+32*0], m0 mova [dstq+32*1], m1 add dstq, dsq dec hd jg .h_w32 RET .h_w64: .h_w128: movifnidn t0d, org_w .h_w64_loop0: mov r6d, t0d .h_w64_loop: pmullw m0, m4, [srcq+r6*2-32*1] pmullw m1, m5, [srcq+r6*2-32*1+2] paddw m0, m3 paddw m0, m1 pmullw m1, m4, [srcq+r6*2-32*2] pmullw m2, m5, [srcq+r6*2-32*2+2] paddw m1, m3 paddw m1, m2 psrlw m0, 4 psrlw m1, 4 mova [dstq+r6*2-32*1], m0 mova [dstq+r6*2-32*2], m1 sub r6d, 32 jg .h_w64_loop add srcq, ssq add dstq, dsq dec hd jg .h_w64_loop0 RET .v: movzx wd, word [r7+wq*2+table_offset(put, _bilin_v)] shl mxyd, 11 movd xm5, mxyd add wq, r7 vpbroadcastw m5, xm5 jmp wq .v_w2: movd xm0, [srcq+ssq*0] .v_w2_loop: movd xm1, [srcq+ssq*1] lea srcq, [srcq+ssq*2] punpckldq xm2, xm0, xm1 movd xm0, [srcq+ssq*0] punpckldq xm1, xm0 psubw xm1, xm2 pmulhrsw xm1, xm5 paddw xm1, xm2 movd [dstq+dsq*0], xm1 pextrd [dstq+dsq*1], xm1, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .v_w2_loop RET .v_w4: movq xm0, [srcq+ssq*0] .v_w4_loop: movq xm1, [srcq+ssq*1] lea srcq, [srcq+ssq*2] punpcklqdq xm2, xm0, xm1 movq xm0, [srcq+ssq*0] punpcklqdq xm1, xm0 psubw xm1, xm2 pmulhrsw xm1, xm5 paddw xm1, xm2 movq [dstq+dsq*0], xm1 movhps [dstq+dsq*1], xm1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .v_w4_loop RET .v_w8: movu xm0, [srcq+ssq*0] .v_w8_loop: vbroadcasti128 m1, [srcq+ssq*1] lea srcq, [srcq+ssq*2] vpblendd m2, m0, m1, 0xf0 vbroadcasti128 m0, [srcq+ssq*0] vpblendd m1, m0, 0xf0 psubw m1, m2 pmulhrsw m1, m5 paddw m1, m2 mova [dstq+dsq*0], xm1 vextracti128 [dstq+dsq*1], m1, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .v_w8_loop RET .v_w32: movu m0, [srcq+ssq*0+32*0] movu m1, [srcq+ssq*0+32*1] .v_w32_loop: movu m2, [srcq+ssq*1+32*0] movu m3, [srcq+ssq*1+32*1] lea srcq, [srcq+ssq*2] psubw m4, m2, m0 pmulhrsw m4, m5 paddw m4, m0 movu m0, [srcq+ssq*0+32*0] mova [dstq+dsq*0+32*0], m4 psubw m4, m3, m1 pmulhrsw m4, m5 paddw m4, m1 movu m1, [srcq+ssq*0+32*1] mova [dstq+dsq*0+32*1], m4 psubw m4, m0, m2 pmulhrsw m4, m5 paddw m4, m2 mova [dstq+dsq*1+32*0], m4 psubw m4, m1, m3 pmulhrsw m4, m5 paddw m4, m3 mova [dstq+dsq*1+32*1], m4 lea dstq, [dstq+dsq*2] sub hd, 2 jg .v_w32_loop RET .v_w16: .v_w64: .v_w128: movifnidn t0d, org_w add t0d, t0d mov r4, srcq lea r6d, [hq+t0*8-256] mov r7, dstq .v_w16_loop0: movu m0, [srcq+ssq*0] .v_w16_loop: movu m3, [srcq+ssq*1] lea srcq, [srcq+ssq*2] psubw m1, m3, m0 pmulhrsw m1, m5 paddw m1, m0 movu m0, [srcq+ssq*0] psubw m2, m0, m3 pmulhrsw m2, m5 paddw m2, m3 mova [dstq+dsq*0], m1 mova [dstq+dsq*1], m2 lea dstq, [dstq+dsq*2] sub hd, 2 jg .v_w16_loop add r4, 32 add r7, 32 movzx hd, r6b mov srcq, r4 mov dstq, r7 sub r6d, 1<<8 jg .v_w16_loop0 RET .hv: movzx wd, word [r7+wq*2+table_offset(put, _bilin_hv)] WIN64_SPILL_XMM 8 shl mxyd, 11 vpbroadcastd m3, [pw_2] movd xm6, mxyd vpbroadcastd m7, [pw_8192] add wq, r7 vpbroadcastw m6, xm6 test dword r8m, 0x800 jnz .hv_12bpc psllw m4, 2 psllw m5, 2 vpbroadcastd m7, [pw_2048] .hv_12bpc: jmp wq .hv_w2: vpbroadcastq xm1, [srcq+ssq*0] pmullw xm0, xm4, xm1 psrlq xm1, 16 pmullw xm1, xm5 paddw xm0, xm3 paddw xm0, xm1 psrlw xm0, 2 .hv_w2_loop: movq xm2, [srcq+ssq*1] lea srcq, [srcq+ssq*2] movhps xm2, [srcq+ssq*0] pmullw xm1, xm4, xm2 psrlq xm2, 16 pmullw xm2, xm5 paddw xm1, xm3 paddw xm1, xm2 psrlw xm1, 2 ; 1 _ 2 _ shufpd xm2, xm0, xm1, 0x01 ; 0 _ 1 _ mova xm0, xm1 psubw xm1, xm2 paddw xm1, xm1 pmulhw xm1, xm6 paddw xm1, xm2 pmulhrsw xm1, xm7 movd [dstq+dsq*0], xm1 pextrd [dstq+dsq*1], xm1, 2 lea dstq, [dstq+dsq*2] sub hd, 2 jg .hv_w2_loop RET .hv_w4: pmullw xm0, xm4, [srcq+ssq*0-8] pmullw xm1, xm5, [srcq+ssq*0-6] paddw xm0, xm3 paddw xm0, xm1 psrlw xm0, 2 .hv_w4_loop: movq xm1, [srcq+ssq*1] movq xm2, [srcq+ssq*1+2] lea srcq, [srcq+ssq*2] movhps xm1, [srcq+ssq*0] movhps xm2, [srcq+ssq*0+2] pmullw xm1, xm4 pmullw xm2, xm5 paddw xm1, xm3 paddw xm1, xm2 psrlw xm1, 2 ; 1 2 shufpd xm2, xm0, xm1, 0x01 ; 0 1 mova xm0, xm1 psubw xm1, xm2 paddw xm1, xm1 pmulhw xm1, xm6 paddw xm1, xm2 pmulhrsw xm1, xm7 movq [dstq+dsq*0], xm1 movhps [dstq+dsq*1], xm1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .hv_w4_loop RET .hv_w8: pmullw xm0, xm4, [srcq+ssq*0] pmullw xm1, xm5, [srcq+ssq*0+2] paddw xm0, xm3 paddw xm0, xm1 psrlw xm0, 2 vinserti128 m0, xm0, 1 .hv_w8_loop: movu xm1, [srcq+ssq*1] movu xm2, [srcq+ssq*1+2] lea srcq, [srcq+ssq*2] vinserti128 m1, [srcq+ssq*0], 1 vinserti128 m2, [srcq+ssq*0+2], 1 pmullw m1, m4 pmullw m2, m5 paddw m1, m3 paddw m1, m2 psrlw m1, 2 ; 1 2 vperm2i128 m2, m0, m1, 0x21 ; 0 1 mova m0, m1 psubw m1, m2 paddw m1, m1 pmulhw m1, m6 paddw m1, m2 pmulhrsw m1, m7 mova [dstq+dsq*0], xm1 vextracti128 [dstq+dsq*1], m1, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .hv_w8_loop RET .hv_w16: .hv_w32: .hv_w64: .hv_w128: %if UNIX64 lea r6d, [r8*2-32] %else mov r6d, wm lea r6d, [r6*2-32] %endif mov r4, srcq lea r6d, [hq+r6*8] mov r7, dstq .hv_w16_loop0: pmullw m0, m4, [srcq+ssq*0] pmullw m1, m5, [srcq+ssq*0+2] paddw m0, m3 paddw m0, m1 psrlw m0, 2 .hv_w16_loop: pmullw m1, m4, [srcq+ssq*1] pmullw m2, m5, [srcq+ssq*1+2] lea srcq, [srcq+ssq*2] paddw m1, m3 paddw m1, m2 psrlw m1, 2 psubw m2, m1, m0 paddw m2, m2 pmulhw m2, m6 paddw m2, m0 pmulhrsw m2, m7 mova [dstq+dsq*0], m2 pmullw m0, m4, [srcq+ssq*0] pmullw m2, m5, [srcq+ssq*0+2] paddw m0, m3 paddw m0, m2 psrlw m0, 2 psubw m2, m0, m1 paddw m2, m2 pmulhw m2, m6 paddw m2, m1 pmulhrsw m2, m7 mova [dstq+dsq*1], m2 lea dstq, [dstq+dsq*2] sub hd, 2 jg .hv_w16_loop add r4, 32 add r7, 32 movzx hd, r6b mov srcq, r4 mov dstq, r7 sub r6d, 1<<8 jg .hv_w16_loop0 RET cglobal prep_bilin_16bpc, 3, 7, 0, tmp, src, stride, w, h, mxy, stride3 movifnidn mxyd, r5m ; mx lea r6, [prep_avx2] %if UNIX64 DECLARE_REG_TMP 7 %define org_w r7d %else DECLARE_REG_TMP 6 %define org_w r5m %endif mov org_w, wd tzcnt wd, wm movifnidn hd, hm test mxyd, mxyd jnz .h mov mxyd, r6m ; my test mxyd, mxyd jnz .v .prep: movzx wd, word [r6+wq*2+table_offset(prep,)] mov r5d, r7m ; bitdepth_max vpbroadcastd m5, [r6-prep_avx2+pw_8192] add wq, r6 shr r5d, 11 vpbroadcastd m4, [r6-prep_avx2+prep_mul+r5*4] lea stride3q, [strideq*3] jmp wq .prep_w4: movq xm0, [srcq+strideq*0] movhps xm0, [srcq+strideq*1] vpbroadcastq m1, [srcq+strideq*2] vpbroadcastq m2, [srcq+stride3q ] lea srcq, [srcq+strideq*4] vpblendd m0, m1, 0x30 vpblendd m0, m2, 0xc0 pmullw m0, m4 psubw m0, m5 mova [tmpq], m0 add tmpq, 32 sub hd, 4 jg .prep_w4 RET .prep_w8: movu xm0, [srcq+strideq*0] vinserti128 m0, [srcq+strideq*1], 1 movu xm1, [srcq+strideq*2] vinserti128 m1, [srcq+stride3q ], 1 lea srcq, [srcq+strideq*4] pmullw m0, m4 pmullw m1, m4 psubw m0, m5 psubw m1, m5 mova [tmpq+32*0], m0 mova [tmpq+32*1], m1 add tmpq, 32*2 sub hd, 4 jg .prep_w8 RET .prep_w16: pmullw m0, m4, [srcq+strideq*0] pmullw m1, m4, [srcq+strideq*1] pmullw m2, m4, [srcq+strideq*2] pmullw m3, m4, [srcq+stride3q ] lea srcq, [srcq+strideq*4] psubw m0, m5 psubw m1, m5 psubw m2, m5 psubw m3, m5 mova [tmpq+32*0], m0 mova [tmpq+32*1], m1 mova [tmpq+32*2], m2 mova [tmpq+32*3], m3 add tmpq, 32*4 sub hd, 4 jg .prep_w16 RET .prep_w32: pmullw m0, m4, [srcq+strideq*0+32*0] pmullw m1, m4, [srcq+strideq*0+32*1] pmullw m2, m4, [srcq+strideq*1+32*0] pmullw m3, m4, [srcq+strideq*1+32*1] lea srcq, [srcq+strideq*2] psubw m0, m5 psubw m1, m5 psubw m2, m5 psubw m3, m5 mova [tmpq+32*0], m0 mova [tmpq+32*1], m1 mova [tmpq+32*2], m2 mova [tmpq+32*3], m3 add tmpq, 32*4 sub hd, 2 jg .prep_w32 RET .prep_w64: pmullw m0, m4, [srcq+32*0] pmullw m1, m4, [srcq+32*1] pmullw m2, m4, [srcq+32*2] pmullw m3, m4, [srcq+32*3] add srcq, strideq psubw m0, m5 psubw m1, m5 psubw m2, m5 psubw m3, m5 mova [tmpq+32*0], m0 mova [tmpq+32*1], m1 mova [tmpq+32*2], m2 mova [tmpq+32*3], m3 add tmpq, 32*4 dec hd jg .prep_w64 RET .prep_w128: pmullw m0, m4, [srcq+32*0] pmullw m1, m4, [srcq+32*1] pmullw m2, m4, [srcq+32*2] pmullw m3, m4, [srcq+32*3] psubw m0, m5 psubw m1, m5 psubw m2, m5 psubw m3, m5 mova [tmpq+32*0], m0 mova [tmpq+32*1], m1 mova [tmpq+32*2], m2 mova [tmpq+32*3], m3 pmullw m0, m4, [srcq+32*4] pmullw m1, m4, [srcq+32*5] pmullw m2, m4, [srcq+32*6] pmullw m3, m4, [srcq+32*7] add tmpq, 32*8 add srcq, strideq psubw m0, m5 psubw m1, m5 psubw m2, m5 psubw m3, m5 mova [tmpq-32*4], m0 mova [tmpq-32*3], m1 mova [tmpq-32*2], m2 mova [tmpq-32*1], m3 dec hd jg .prep_w128 RET .h: movd xm5, mxyd mov mxyd, r6m ; my vpbroadcastd m4, [pw_16] vpbroadcastw m5, xm5 vpbroadcastd m3, [pw_32766] psubw m4, m5 test dword r7m, 0x800 jnz .h_12bpc psllw m4, 2 psllw m5, 2 .h_12bpc: test mxyd, mxyd jnz .hv movzx wd, word [r6+wq*2+table_offset(prep, _bilin_h)] add wq, r6 lea stride3q, [strideq*3] jmp wq .h_w4: movu xm1, [srcq+strideq*0] vinserti128 m1, [srcq+strideq*2], 1 movu xm2, [srcq+strideq*1] vinserti128 m2, [srcq+stride3q ], 1 lea srcq, [srcq+strideq*4] punpcklqdq m0, m1, m2 psrldq m1, 2 pslldq m2, 6 pmullw m0, m4 vpblendd m1, m2, 0xcc pmullw m1, m5 psubw m0, m3 paddw m0, m1 psraw m0, 2 mova [tmpq], m0 add tmpq, 32 sub hd, 4 jg .h_w4 RET .h_w8: movu xm0, [srcq+strideq*0] vinserti128 m0, [srcq+strideq*1], 1 movu xm1, [srcq+strideq*0+2] vinserti128 m1, [srcq+strideq*1+2], 1 lea srcq, [srcq+strideq*2] pmullw m0, m4 pmullw m1, m5 psubw m0, m3 paddw m0, m1 psraw m0, 2 mova [tmpq], m0 add tmpq, 32 sub hd, 2 jg .h_w8 RET .h_w16: pmullw m0, m4, [srcq+strideq*0] pmullw m1, m5, [srcq+strideq*0+2] psubw m0, m3 paddw m0, m1 pmullw m1, m4, [srcq+strideq*1] pmullw m2, m5, [srcq+strideq*1+2] lea srcq, [srcq+strideq*2] psubw m1, m3 paddw m1, m2 psraw m0, 2 psraw m1, 2 mova [tmpq+32*0], m0 mova [tmpq+32*1], m1 add tmpq, 32*2 sub hd, 2 jg .h_w16 RET .h_w32: .h_w64: .h_w128: movifnidn t0d, org_w .h_w32_loop0: mov r3d, t0d .h_w32_loop: pmullw m0, m4, [srcq+r3*2-32*1] pmullw m1, m5, [srcq+r3*2-32*1+2] psubw m0, m3 paddw m0, m1 pmullw m1, m4, [srcq+r3*2-32*2] pmullw m2, m5, [srcq+r3*2-32*2+2] psubw m1, m3 paddw m1, m2 psraw m0, 2 psraw m1, 2 mova [tmpq+r3*2-32*1], m0 mova [tmpq+r3*2-32*2], m1 sub r3d, 32 jg .h_w32_loop add srcq, strideq lea tmpq, [tmpq+t0*2] dec hd jg .h_w32_loop0 RET .v: movzx wd, word [r6+wq*2+table_offset(prep, _bilin_v)] movd xm5, mxyd vpbroadcastd m4, [pw_16] vpbroadcastw m5, xm5 vpbroadcastd m3, [pw_32766] add wq, r6 lea stride3q, [strideq*3] psubw m4, m5 test dword r7m, 0x800 jnz .v_12bpc psllw m4, 2 psllw m5, 2 .v_12bpc: jmp wq .v_w4: movq xm0, [srcq+strideq*0] .v_w4_loop: vpbroadcastq m2, [srcq+strideq*2] vpbroadcastq xm1, [srcq+strideq*1] vpblendd m2, m0, 0x03 ; 0 2 2 2 vpbroadcastq m0, [srcq+stride3q ] lea srcq, [srcq+strideq*4] vpblendd m1, m0, 0xf0 ; 1 1 3 3 vpbroadcastq m0, [srcq+strideq*0] vpblendd m1, m2, 0x33 ; 0 1 2 3 vpblendd m0, m2, 0x0c ; 4 2 4 4 punpckhqdq m2, m1, m0 ; 1 2 3 4 pmullw m1, m4 pmullw m2, m5 psubw m1, m3 paddw m1, m2 psraw m1, 2 mova [tmpq], m1 add tmpq, 32 sub hd, 4 jg .v_w4_loop RET .v_w8: movu xm0, [srcq+strideq*0] .v_w8_loop: vbroadcasti128 m2, [srcq+strideq*1] lea srcq, [srcq+strideq*2] vpblendd m1, m0, m2, 0xf0 ; 0 1 vbroadcasti128 m0, [srcq+strideq*0] vpblendd m2, m0, 0xf0 ; 1 2 pmullw m1, m4 pmullw m2, m5 psubw m1, m3 paddw m1, m2 psraw m1, 2 mova [tmpq], m1 add tmpq, 32 sub hd, 2 jg .v_w8_loop RET .v_w16: movu m0, [srcq+strideq*0] .v_w16_loop: movu m2, [srcq+strideq*1] lea srcq, [srcq+strideq*2] pmullw m0, m4 pmullw m1, m5, m2 psubw m0, m3 paddw m1, m0 movu m0, [srcq+strideq*0] psraw m1, 2 pmullw m2, m4 mova [tmpq+32*0], m1 pmullw m1, m5, m0 psubw m2, m3 paddw m1, m2 psraw m1, 2 mova [tmpq+32*1], m1 add tmpq, 32*2 sub hd, 2 jg .v_w16_loop RET .v_w32: .v_w64: .v_w128: %if WIN64 PUSH r7 %endif movifnidn r7d, org_w add r7d, r7d mov r3, srcq lea r6d, [hq+r7*8-256] mov r5, tmpq .v_w32_loop0: movu m0, [srcq+strideq*0] .v_w32_loop: movu m2, [srcq+strideq*1] lea srcq, [srcq+strideq*2] pmullw m0, m4 pmullw m1, m5, m2 psubw m0, m3 paddw m1, m0 movu m0, [srcq+strideq*0] psraw m1, 2 pmullw m2, m4 mova [tmpq+r7*0], m1 pmullw m1, m5, m0 psubw m2, m3 paddw m1, m2 psraw m1, 2 mova [tmpq+r7*1], m1 lea tmpq, [tmpq+r7*2] sub hd, 2 jg .v_w32_loop add r3, 32 add r5, 32 movzx hd, r6b mov srcq, r3 mov tmpq, r5 sub r6d, 1<<8 jg .v_w32_loop0 %if WIN64 POP r7 %endif RET .hv: WIN64_SPILL_XMM 7 movzx wd, word [r6+wq*2+table_offset(prep, _bilin_hv)] shl mxyd, 11 movd xm6, mxyd add wq, r6 lea stride3q, [strideq*3] vpbroadcastw m6, xm6 jmp wq .hv_w4: movu xm1, [srcq+strideq*0] %if WIN64 movaps [rsp+24], xmm7 %endif pmullw xm0, xm4, xm1 psrldq xm1, 2 pmullw xm1, xm5 psubw xm0, xm3 paddw xm0, xm1 psraw xm0, 2 vpbroadcastq m0, xm0 .hv_w4_loop: movu xm1, [srcq+strideq*1] vinserti128 m1, [srcq+stride3q ], 1 movu xm2, [srcq+strideq*2] lea srcq, [srcq+strideq*4] vinserti128 m2, [srcq+strideq*0], 1 punpcklqdq m7, m1, m2 psrldq m1, 2 pslldq m2, 6 pmullw m7, m4 vpblendd m1, m2, 0xcc pmullw m1, m5 psubw m7, m3 paddw m1, m7 psraw m1, 2 ; 1 2 3 4 vpblendd m0, m1, 0x3f vpermq m2, m0, q2103 ; 0 1 2 3 mova m0, m1 psubw m1, m2 pmulhrsw m1, m6 paddw m1, m2 mova [tmpq], m1 add tmpq, 32 sub hd, 4 jg .hv_w4_loop %if WIN64 movaps xmm7, [rsp+24] %endif RET .hv_w8: pmullw xm0, xm4, [srcq+strideq*0] pmullw xm1, xm5, [srcq+strideq*0+2] psubw xm0, xm3 paddw xm0, xm1 psraw xm0, 2 vinserti128 m0, xm0, 1 .hv_w8_loop: movu xm1, [srcq+strideq*1] movu xm2, [srcq+strideq*1+2] lea srcq, [srcq+strideq*2] vinserti128 m1, [srcq+strideq*0], 1 vinserti128 m2, [srcq+strideq*0+2], 1 pmullw m1, m4 pmullw m2, m5 psubw m1, m3 paddw m1, m2 psraw m1, 2 ; 1 2 vperm2i128 m2, m0, m1, 0x21 ; 0 1 mova m0, m1 psubw m1, m2 pmulhrsw m1, m6 paddw m1, m2 mova [tmpq], m1 add tmpq, 32 sub hd, 2 jg .hv_w8_loop RET .hv_w16: .hv_w32: .hv_w64: .hv_w128: %if WIN64 PUSH r7 %endif movifnidn r7d, org_w add r7d, r7d mov r3, srcq lea r6d, [hq+r7*8-256] mov r5, tmpq .hv_w16_loop0: pmullw m0, m4, [srcq] pmullw m1, m5, [srcq+2] psubw m0, m3 paddw m0, m1 psraw m0, 2 .hv_w16_loop: pmullw m1, m4, [srcq+strideq*1] pmullw m2, m5, [srcq+strideq*1+2] lea srcq, [srcq+strideq*2] psubw m1, m3 paddw m1, m2 psraw m1, 2 psubw m2, m1, m0 pmulhrsw m2, m6 paddw m2, m0 mova [tmpq+r7*0], m2 pmullw m0, m4, [srcq+strideq*0] pmullw m2, m5, [srcq+strideq*0+2] psubw m0, m3 paddw m0, m2 psraw m0, 2 psubw m2, m0, m1 pmulhrsw m2, m6 paddw m2, m1 mova [tmpq+r7*1], m2 lea tmpq, [tmpq+r7*2] sub hd, 2 jg .hv_w16_loop add r3, 32 add r5, 32 movzx hd, r6b mov srcq, r3 mov tmpq, r5 sub r6d, 1<<8 jg .hv_w16_loop0 %if WIN64 POP r7 %endif RET ; int8_t subpel_filters[5][15][8] %assign FILTER_REGULAR (0*15 << 16) | 3*15 %assign FILTER_SMOOTH (1*15 << 16) | 4*15 %assign FILTER_SHARP (2*15 << 16) | 3*15 %macro MC_8TAP_FN 4 ; prefix, type, type_h, type_v cglobal %1_8tap_%2_16bpc mov t0d, FILTER_%3 %ifidn %3, %4 mov t1d, t0d %else mov t1d, FILTER_%4 %endif %ifnidn %2, regular ; skip the jump in the last filter jmp mangle(private_prefix %+ _%1_8tap_16bpc %+ SUFFIX) %endif %endmacro %if WIN64 DECLARE_REG_TMP 4, 5 %else DECLARE_REG_TMP 7, 8 %endif MC_8TAP_FN put, sharp, SHARP, SHARP MC_8TAP_FN put, sharp_smooth, SHARP, SMOOTH MC_8TAP_FN put, smooth_sharp, SMOOTH, SHARP MC_8TAP_FN put, smooth, SMOOTH, SMOOTH MC_8TAP_FN put, sharp_regular, SHARP, REGULAR MC_8TAP_FN put, regular_sharp, REGULAR, SHARP MC_8TAP_FN put, smooth_regular, SMOOTH, REGULAR MC_8TAP_FN put, regular_smooth, REGULAR, SMOOTH MC_8TAP_FN put, regular, REGULAR, REGULAR cglobal put_8tap_16bpc, 4, 9, 0, dst, ds, src, ss, w, h, mx, my %define base r8-put_avx2 imul mxd, mxm, 0x010101 add mxd, t0d ; 8tap_h, mx, 4tap_h imul myd, mym, 0x010101 add myd, t1d ; 8tap_v, my, 4tap_v lea r8, [put_avx2] movifnidn wd, wm movifnidn hd, hm test mxd, 0xf00 jnz .h test myd, 0xf00 jnz .v tzcnt wd, wd movzx wd, word [r8+wq*2+table_offset(put,)] add wq, r8 %if WIN64 pop r8 %endif jmp wq .h_w2: movzx mxd, mxb sub srcq, 2 mova xm2, [subpel_h_shuf2] vpbroadcastd xm3, [base+subpel_filters+mxq*8+2] pmovsxbw xm3, xm3 .h_w2_loop: movu xm0, [srcq+ssq*0] movu xm1, [srcq+ssq*1] lea srcq, [srcq+ssq*2] pshufb xm0, xm2 pshufb xm1, xm2 pmaddwd xm0, xm3 pmaddwd xm1, xm3 phaddd xm0, xm1 paddd xm0, xm4 psrad xm0, 6 packusdw xm0, xm0 pminsw xm0, xm5 movd [dstq+dsq*0], xm0 pextrd [dstq+dsq*1], xm0, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .h_w2_loop RET .h_w4: movzx mxd, mxb sub srcq, 2 pmovsxbw xm3, [base+subpel_filters+mxq*8] WIN64_SPILL_XMM 8 vbroadcasti128 m6, [subpel_h_shufA] vbroadcasti128 m7, [subpel_h_shufB] pshufd xm3, xm3, q2211 vpbroadcastq m2, xm3 vpermq m3, m3, q1111 .h_w4_loop: movu xm1, [srcq+ssq*0] vinserti128 m1, [srcq+ssq*1], 1 lea srcq, [srcq+ssq*2] pshufb m0, m1, m6 ; 0 1 1 2 2 3 3 4 pshufb m1, m7 ; 2 3 3 4 4 5 5 6 pmaddwd m0, m2 pmaddwd m1, m3 paddd m0, m4 paddd m0, m1 psrad m0, 6 vextracti128 xm1, m0, 1 packusdw xm0, xm1 pminsw xm0, xm5 movq [dstq+dsq*0], xm0 movhps [dstq+dsq*1], xm0 lea dstq, [dstq+dsq*2] sub hd, 2 jg .h_w4_loop RET .h: test myd, 0xf00 jnz .hv mov r7d, r8m vpbroadcastw m5, r8m shr r7d, 11 vpbroadcastd m4, [base+put_8tap_h_rnd+r7*4] cmp wd, 4 je .h_w4 jl .h_w2 %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 13 shr mxd, 16 sub srcq, 6 vpbroadcastq m0, [base+subpel_filters+mxq*8] vbroadcasti128 m6, [subpel_h_shufA] vbroadcasti128 m7, [subpel_h_shufB] punpcklbw m0, m0 psraw m0, 8 ; sign-extend pshufd m8, m0, q0000 pshufd m9, m0, q1111 pshufd m10, m0, q2222 pshufd m11, m0, q3333 cmp wd, 8 jg .h_w16 .h_w8: %macro PUT_8TAP_H 5 ; dst/src+0, src+8, src+16, tmp[1-2] pshufb m%4, m%1, m7 ; 2 3 3 4 4 5 5 6 pshufb m%1, m6 ; 0 1 1 2 2 3 3 4 pmaddwd m%5, m9, m%4 ; abcd1 pmaddwd m%1, m8 ; abcd0 pshufb m%2, m7 ; 6 7 7 8 8 9 9 a shufpd m%4, m%2, 0x05 ; 4 5 5 6 6 7 7 8 paddd m%5, m4 paddd m%1, m%5 pmaddwd m%5, m11, m%2 ; abcd3 paddd m%1, m%5 pmaddwd m%5, m10, m%4 ; abcd2 pshufb m%3, m7 ; a b b c c d d e pmaddwd m%4, m8 ; efgh0 paddd m%1, m%5 pmaddwd m%5, m9, m%2 ; efgh1 shufpd m%2, m%3, 0x05 ; 8 9 9 a a b b c pmaddwd m%3, m11 ; efgh3 pmaddwd m%2, m10 ; efgh2 paddd m%4, m4 paddd m%4, m%5 paddd m%3, m%4 paddd m%2, m%3 psrad m%1, 6 psrad m%2, 6 packusdw m%1, m%2 pminsw m%1, m5 %endmacro movu xm0, [srcq+ssq*0+ 0] vinserti128 m0, [srcq+ssq*1+ 0], 1 movu xm2, [srcq+ssq*0+16] vinserti128 m2, [srcq+ssq*1+16], 1 lea srcq, [srcq+ssq*2] shufpd m1, m0, m2, 0x05 PUT_8TAP_H 0, 1, 2, 3, 12 mova [dstq+dsq*0], xm0 vextracti128 [dstq+dsq*1], m0, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .h_w8 RET .h_w16: mov r6d, wd .h_w16_loop: movu m0, [srcq+r6*2-32] movu m1, [srcq+r6*2-24] movu m2, [srcq+r6*2-16] PUT_8TAP_H 0, 1, 2, 3, 12 mova [dstq+r6*2-32], m0 sub r6d, 16 jg .h_w16_loop add srcq, ssq add dstq, dsq dec hd jg .h_w16 RET .v: movzx mxd, myb shr myd, 16 cmp hd, 4 cmovle myd, mxd vpbroadcastq m0, [base+subpel_filters+myq*8] %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 15 vpbroadcastd m6, [pd_32] vpbroadcastw m7, r8m lea r6, [ssq*3] sub srcq, r6 punpcklbw m0, m0 psraw m0, 8 ; sign-extend pshufd m8, m0, q0000 pshufd m9, m0, q1111 pshufd m10, m0, q2222 pshufd m11, m0, q3333 cmp wd, 4 jg .v_w8 je .v_w4 .v_w2: movd xm2, [srcq+ssq*0] pinsrd xm2, [srcq+ssq*1], 1 pinsrd xm2, [srcq+ssq*2], 2 pinsrd xm2, [srcq+r6 ], 3 ; 0 1 2 3 lea srcq, [srcq+ssq*4] movd xm3, [srcq+ssq*0] vpbroadcastd xm1, [srcq+ssq*1] vpbroadcastd xm0, [srcq+ssq*2] add srcq, r6 vpblendd xm3, xm1, 0x02 ; 4 5 vpblendd xm1, xm0, 0x02 ; 5 6 palignr xm4, xm3, xm2, 4 ; 1 2 3 4 punpcklwd xm3, xm1 ; 45 56 punpcklwd xm1, xm2, xm4 ; 01 12 punpckhwd xm2, xm4 ; 23 34 .v_w2_loop: vpbroadcastd xm4, [srcq+ssq*0] pmaddwd xm5, xm8, xm1 ; a0 b0 mova xm1, xm2 pmaddwd xm2, xm9 ; a1 b1 paddd xm5, xm6 paddd xm5, xm2 mova xm2, xm3 pmaddwd xm3, xm10 ; a2 b2 paddd xm5, xm3 vpblendd xm3, xm0, xm4, 0x02 ; 6 7 vpbroadcastd xm0, [srcq+ssq*1] lea srcq, [srcq+ssq*2] vpblendd xm4, xm0, 0x02 ; 7 8 punpcklwd xm3, xm4 ; 67 78 pmaddwd xm4, xm11, xm3 ; a3 b3 paddd xm5, xm4 psrad xm5, 6 packusdw xm5, xm5 pminsw xm5, xm7 movd [dstq+dsq*0], xm5 pextrd [dstq+dsq*1], xm5, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .v_w2_loop RET .v_w4: movq xm1, [srcq+ssq*0] vpbroadcastq m0, [srcq+ssq*1] vpbroadcastq m2, [srcq+ssq*2] vpbroadcastq m4, [srcq+r6 ] lea srcq, [srcq+ssq*4] vpbroadcastq m3, [srcq+ssq*0] vpbroadcastq m5, [srcq+ssq*1] vpblendd m1, m0, 0x30 vpblendd m0, m2, 0x30 punpcklwd m1, m0 ; 01 12 vpbroadcastq m0, [srcq+ssq*2] add srcq, r6 vpblendd m2, m4, 0x30 vpblendd m4, m3, 0x30 punpcklwd m2, m4 ; 23 34 vpblendd m3, m5, 0x30 vpblendd m5, m0, 0x30 punpcklwd m3, m5 ; 45 56 .v_w4_loop: vpbroadcastq m4, [srcq+ssq*0] pmaddwd m5, m8, m1 ; a0 b0 mova m1, m2 pmaddwd m2, m9 ; a1 b1 paddd m5, m6 paddd m5, m2 mova m2, m3 pmaddwd m3, m10 ; a2 b2 paddd m5, m3 vpblendd m3, m0, m4, 0x30 vpbroadcastq m0, [srcq+ssq*1] lea srcq, [srcq+ssq*2] vpblendd m4, m0, 0x30 punpcklwd m3, m4 ; 67 78 pmaddwd m4, m11, m3 ; a3 b3 paddd m5, m4 psrad m5, 6 vextracti128 xm4, m5, 1 packusdw xm5, xm4 pminsw xm5, xm7 movq [dstq+dsq*0], xm5 movhps [dstq+dsq*1], xm5 lea dstq, [dstq+dsq*2] sub hd, 2 jg .v_w4_loop RET .v_w8: shl wd, 5 mov r7, srcq mov r8, dstq lea wd, [hq+wq-256] .v_w8_loop0: vbroadcasti128 m4, [srcq+ssq*0] vbroadcasti128 m5, [srcq+ssq*1] vbroadcasti128 m0, [srcq+r6 ] vbroadcasti128 m6, [srcq+ssq*2] lea srcq, [srcq+ssq*4] vbroadcasti128 m1, [srcq+ssq*0] vbroadcasti128 m2, [srcq+ssq*1] vbroadcasti128 m3, [srcq+ssq*2] add srcq, r6 shufpd m4, m0, 0x0c shufpd m5, m1, 0x0c punpcklwd m1, m4, m5 ; 01 punpckhwd m4, m5 ; 34 shufpd m6, m2, 0x0c punpcklwd m2, m5, m6 ; 12 punpckhwd m5, m6 ; 45 shufpd m0, m3, 0x0c punpcklwd m3, m6, m0 ; 23 punpckhwd m6, m0 ; 56 .v_w8_loop: vbroadcasti128 m14, [srcq+ssq*0] pmaddwd m12, m8, m1 ; a0 pmaddwd m13, m8, m2 ; b0 mova m1, m3 mova m2, m4 pmaddwd m3, m9 ; a1 pmaddwd m4, m9 ; b1 paddd m12, m3 paddd m13, m4 mova m3, m5 mova m4, m6 pmaddwd m5, m10 ; a2 pmaddwd m6, m10 ; b2 paddd m12, m5 vbroadcasti128 m5, [srcq+ssq*1] lea srcq, [srcq+ssq*2] paddd m13, m6 shufpd m6, m0, m14, 0x0d shufpd m0, m14, m5, 0x0c punpcklwd m5, m6, m0 ; 67 punpckhwd m6, m0 ; 78 pmaddwd m14, m11, m5 ; a3 paddd m12, m14 pmaddwd m14, m11, m6 ; b3 paddd m13, m14 psrad m12, 5 psrad m13, 5 packusdw m12, m13 pxor m13, m13 pavgw m12, m13 pminsw m12, m7 vpermq m12, m12, q3120 mova [dstq+dsq*0], xm12 vextracti128 [dstq+dsq*1], m12, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .v_w8_loop add r7, 16 add r8, 16 movzx hd, wb mov srcq, r7 mov dstq, r8 sub wd, 1<<8 jg .v_w8_loop0 RET .hv: %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 16 vpbroadcastw m15, r8m cmp wd, 4 jg .hv_w8 movzx mxd, mxb vpbroadcastd m0, [base+subpel_filters+mxq*8+2] movzx mxd, myb shr myd, 16 cmp hd, 4 cmovle myd, mxd vpbroadcastq m1, [base+subpel_filters+myq*8] vpbroadcastd m6, [pd_512] lea r6, [ssq*3] sub srcq, 2 sub srcq, r6 pxor m7, m7 punpcklbw m7, m0 punpcklbw m1, m1 psraw m1, 8 ; sign-extend test dword r8m, 0x800 jz .hv_10bit psraw m7, 2 psllw m1, 2 .hv_10bit: pshufd m11, m1, q0000 pshufd m12, m1, q1111 pshufd m13, m1, q2222 pshufd m14, m1, q3333 cmp wd, 4 je .hv_w4 vbroadcasti128 m9, [subpel_h_shuf2] vbroadcasti128 m1, [srcq+r6 ] ; 3 3 movu xm3, [srcq+ssq*2] movu xm0, [srcq+ssq*0] movu xm2, [srcq+ssq*1] lea srcq, [srcq+ssq*4] vinserti128 m3, [srcq+ssq*0], 1 ; 2 4 vinserti128 m0, [srcq+ssq*1], 1 ; 0 5 vinserti128 m2, [srcq+ssq*2], 1 ; 1 6 add srcq, r6 pshufb m1, m9 pshufb m3, m9 pshufb m0, m9 pshufb m2, m9 pmaddwd m1, m7 pmaddwd m3, m7 pmaddwd m0, m7 pmaddwd m2, m7 phaddd m1, m3 phaddd m0, m2 paddd m1, m6 paddd m0, m6 psrad m1, 10 psrad m0, 10 packssdw m1, m0 ; 3 2 0 1 vextracti128 xm0, m1, 1 ; 3 4 5 6 pshufd xm2, xm1, q1301 ; 2 3 1 2 pshufd xm3, xm0, q2121 ; 4 5 4 5 punpckhwd xm1, xm2 ; 01 12 punpcklwd xm2, xm0 ; 23 34 punpckhwd xm3, xm0 ; 45 56 .hv_w2_loop: movu xm4, [srcq+ssq*0] movu xm5, [srcq+ssq*1] lea srcq, [srcq+ssq*2] pshufb xm4, xm9 pshufb xm5, xm9 pmaddwd xm4, xm7 pmaddwd xm5, xm7 phaddd xm4, xm5 pmaddwd xm5, xm11, xm1 ; a0 b0 mova xm1, xm2 pmaddwd xm2, xm12 ; a1 b1 paddd xm5, xm2 mova xm2, xm3 pmaddwd xm3, xm13 ; a2 b2 paddd xm5, xm3 paddd xm4, xm6 psrad xm4, 10 packssdw xm4, xm4 palignr xm3, xm4, xm0, 12 mova xm0, xm4 punpcklwd xm3, xm0 ; 67 78 pmaddwd xm4, xm14, xm3 ; a3 b3 paddd xm5, xm6 paddd xm5, xm4 psrad xm5, 10 packusdw xm5, xm5 pminsw xm5, xm15 movd [dstq+dsq*0], xm5 pextrd [dstq+dsq*1], xm5, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .hv_w2_loop RET .hv_w4: vbroadcasti128 m9, [subpel_h_shufA] vbroadcasti128 m10, [subpel_h_shufB] pshufd m8, m7, q1111 pshufd m7, m7, q0000 movu xm1, [srcq+ssq*0] vinserti128 m1, [srcq+ssq*1], 1 ; 0 1 vbroadcasti128 m0, [srcq+r6 ] vinserti128 m2, m0, [srcq+ssq*2], 0 ; 2 3 lea srcq, [srcq+ssq*4] vinserti128 m0, [srcq+ssq*0], 1 ; 3 4 movu xm3, [srcq+ssq*1] vinserti128 m3, [srcq+ssq*2], 1 ; 5 6 add srcq, r6 pshufb m4, m1, m9 pshufb m1, m10 pmaddwd m4, m7 pmaddwd m1, m8 pshufb m5, m2, m9 pshufb m2, m10 pmaddwd m5, m7 pmaddwd m2, m8 paddd m4, m6 paddd m1, m4 pshufb m4, m0, m9 pshufb m0, m10 pmaddwd m4, m7 pmaddwd m0, m8 paddd m5, m6 paddd m2, m5 pshufb m5, m3, m9 pshufb m3, m10 pmaddwd m5, m7 pmaddwd m3, m8 paddd m4, m6 paddd m4, m0 paddd m5, m6 paddd m5, m3 vperm2i128 m0, m1, m2, 0x21 psrld m1, 10 psrld m2, 10 vperm2i128 m3, m4, m5, 0x21 pslld m4, 6 pslld m5, 6 pblendw m2, m4, 0xaa ; 23 34 pslld m0, 6 pblendw m1, m0, 0xaa ; 01 12 psrld m3, 10 pblendw m3, m5, 0xaa ; 45 56 psrad m0, m5, 16 .hv_w4_loop: movu xm4, [srcq+ssq*0] vinserti128 m4, [srcq+ssq*1], 1 lea srcq, [srcq+ssq*2] pmaddwd m5, m11, m1 ; a0 b0 mova m1, m2 pmaddwd m2, m12 ; a1 b1 paddd m5, m6 paddd m5, m2 mova m2, m3 pmaddwd m3, m13 ; a2 b2 paddd m5, m3 pshufb m3, m4, m9 pshufb m4, m10 pmaddwd m3, m7 pmaddwd m4, m8 paddd m3, m6 paddd m4, m3 psrad m4, 10 packssdw m0, m4 ; _ 7 6 8 vpermq m3, m0, q1122 ; _ 6 _ 7 punpckhwd m3, m0 ; 67 78 mova m0, m4 pmaddwd m4, m14, m3 ; a3 b3 paddd m4, m5 psrad m4, 10 vextracti128 xm5, m4, 1 packusdw xm4, xm5 pminsw xm4, xm15 movq [dstq+dsq*0], xm4 movhps [dstq+dsq*1], xm4 lea dstq, [dstq+dsq*2] sub hd, 2 jg .hv_w4_loop RET .hv_w8: shr mxd, 16 vpbroadcastq m2, [base+subpel_filters+mxq*8] movzx mxd, myb shr myd, 16 cmp hd, 4 cmovle myd, mxd pmovsxbw xm1, [base+subpel_filters+myq*8] shl wd, 5 lea r6, [ssq*3] sub srcq, 6 sub srcq, r6 pxor m0, m0 punpcklbw m0, m2 mov r7, srcq mov r8, dstq lea wd, [hq+wq-256] test dword r8m, 0x800 jz .hv_w8_10bit psraw m0, 2 psllw xm1, 2 .hv_w8_10bit: pshufd m11, m0, q0000 pshufd m12, m0, q1111 pshufd m13, m0, q2222 pshufd m14, m0, q3333 %if WIN64 %define v_mul (rsp+stack_offset+40) ; r4m %else %define v_mul (rsp-24) ; red zone %endif mova [v_mul], xm1 .hv_w8_loop0: %macro PUT_8TAP_HV_H 3 ; dst/src+0, src+8, src+16 pshufb m2, m%1, m9 ; 2 3 3 4 4 5 5 6 pshufb m%1, m8 ; 0 1 1 2 2 3 3 4 pmaddwd m3, m12, m2 pmaddwd m%1, m11 pshufb m%2, m9 ; 6 7 7 8 8 9 9 a shufpd m2, m%2, 0x05 ; 4 5 5 6 6 7 7 8 paddd m3, m10 paddd m%1, m3 pmaddwd m3, m14, m%2 paddd m%1, m3 pmaddwd m3, m13, m2 pshufb m%3, m9 ; a b b c c d d e pmaddwd m2, m11 paddd m%1, m3 pmaddwd m3, m12, m%2 shufpd m%2, m%3, 0x05 ; 8 9 9 a a b b c pmaddwd m%3, m14 pmaddwd m%2, m13 paddd m2, m10 paddd m2, m3 paddd m%3, m2 paddd m%2, m%3 psrad m%1, 10 psrad m%2, 10 packssdw m%1, m%2 %endmacro movu xm4, [srcq+r6 *1+ 0] vbroadcasti128 m8, [subpel_h_shufA] movu xm6, [srcq+r6 *1+ 8] vbroadcasti128 m9, [subpel_h_shufB] movu xm0, [srcq+r6 *1+16] vpbroadcastd m10, [pd_512] movu xm5, [srcq+ssq*0+ 0] vinserti128 m5, [srcq+ssq*4+ 0], 1 movu xm1, [srcq+ssq*0+16] vinserti128 m1, [srcq+ssq*4+16], 1 shufpd m7, m5, m1, 0x05 INIT_XMM avx2 PUT_8TAP_HV_H 4, 6, 0 ; 3 INIT_YMM avx2 PUT_8TAP_HV_H 5, 7, 1 ; 0 4 movu xm0, [srcq+ssq*2+ 0] vinserti128 m0, [srcq+r6 *2+ 0], 1 movu xm1, [srcq+ssq*2+16] vinserti128 m1, [srcq+r6 *2+16], 1 shufpd m7, m0, m1, 0x05 PUT_8TAP_HV_H 0, 7, 1 ; 2 6 movu xm6, [srcq+ssq*1+ 0] movu xm1, [srcq+ssq*1+16] lea srcq, [srcq+ssq*4] vinserti128 m6, [srcq+ssq*1+ 0], 1 vinserti128 m1, [srcq+ssq*1+16], 1 add srcq, r6 shufpd m7, m6, m1, 0x05 PUT_8TAP_HV_H 6, 7, 1 ; 1 5 vpermq m4, m4, q1100 vpermq m5, m5, q3120 vpermq m6, m6, q3120 vpermq m7, m0, q3120 punpcklwd m3, m7, m4 ; 23 punpckhwd m4, m5 ; 34 punpcklwd m1, m5, m6 ; 01 punpckhwd m5, m6 ; 45 punpcklwd m2, m6, m7 ; 12 punpckhwd m6, m7 ; 56 .hv_w8_loop: vpbroadcastd m9, [v_mul+4*0] vpbroadcastd m7, [v_mul+4*1] vpbroadcastd m10, [v_mul+4*2] pmaddwd m8, m9, m1 ; a0 pmaddwd m9, m2 ; b0 mova m1, m3 mova m2, m4 pmaddwd m3, m7 ; a1 pmaddwd m4, m7 ; b1 paddd m8, m3 paddd m9, m4 mova m3, m5 mova m4, m6 pmaddwd m5, m10 ; a2 pmaddwd m6, m10 ; b2 paddd m8, m5 paddd m9, m6 movu xm5, [srcq+ssq*0] vinserti128 m5, [srcq+ssq*1], 1 vbroadcasti128 m7, [subpel_h_shufA] vbroadcasti128 m10, [subpel_h_shufB] movu xm6, [srcq+ssq*0+16] vinserti128 m6, [srcq+ssq*1+16], 1 vextracti128 [dstq], m0, 1 pshufb m0, m5, m7 ; 01 pshufb m5, m10 ; 23 pmaddwd m0, m11 pmaddwd m5, m12 paddd m0, m5 pshufb m5, m6, m7 ; 89 pshufb m6, m10 ; ab pmaddwd m5, m13 pmaddwd m6, m14 paddd m6, m5 movu xm5, [srcq+ssq*0+8] vinserti128 m5, [srcq+ssq*1+8], 1 lea srcq, [srcq+ssq*2] pshufb m7, m5, m7 pshufb m5, m10 pmaddwd m10, m13, m7 pmaddwd m7, m11 paddd m0, m10 vpbroadcastd m10, [pd_512] paddd m6, m7 pmaddwd m7, m14, m5 pmaddwd m5, m12 paddd m0, m7 paddd m5, m6 vbroadcasti128 m6, [dstq] paddd m8, m10 paddd m9, m10 paddd m0, m10 paddd m5, m10 vpbroadcastd m10, [v_mul+4*3] psrad m0, 10 psrad m5, 10 packssdw m0, m5 vpermq m7, m0, q3120 ; 7 8 shufpd m6, m7, 0x04 ; 6 7 punpcklwd m5, m6, m7 ; 67 punpckhwd m6, m7 ; 78 pmaddwd m7, m10, m5 ; a3 pmaddwd m10, m6 ; b3 paddd m7, m8 paddd m9, m10 psrad m7, 10 psrad m9, 10 packusdw m7, m9 pminsw m7, m15 vpermq m7, m7, q3120 mova [dstq+dsq*0], xm7 vextracti128 [dstq+dsq*1], m7, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .hv_w8_loop add r7, 16 add r8, 16 movzx hd, wb mov srcq, r7 mov dstq, r8 sub wd, 1<<8 jg .hv_w8_loop0 RET %if WIN64 DECLARE_REG_TMP 6, 4 %else DECLARE_REG_TMP 6, 7 %endif MC_8TAP_FN prep, sharp, SHARP, SHARP MC_8TAP_FN prep, sharp_smooth, SHARP, SMOOTH MC_8TAP_FN prep, smooth_sharp, SMOOTH, SHARP MC_8TAP_FN prep, smooth, SMOOTH, SMOOTH MC_8TAP_FN prep, sharp_regular, SHARP, REGULAR MC_8TAP_FN prep, regular_sharp, REGULAR, SHARP MC_8TAP_FN prep, smooth_regular, SMOOTH, REGULAR MC_8TAP_FN prep, regular_smooth, REGULAR, SMOOTH MC_8TAP_FN prep, regular, REGULAR, REGULAR cglobal prep_8tap_16bpc, 4, 8, 0, tmp, src, stride, w, h, mx, my %define base r7-prep_avx2 imul mxd, mxm, 0x010101 add mxd, t0d ; 8tap_h, mx, 4tap_h imul myd, mym, 0x010101 add myd, t1d ; 8tap_v, my, 4tap_v lea r7, [prep_avx2] movifnidn hd, hm test mxd, 0xf00 jnz .h test myd, 0xf00 jnz .v tzcnt wd, wd mov r6d, r7m ; bitdepth_max movzx wd, word [r7+wq*2+table_offset(prep,)] vpbroadcastd m5, [r7-prep_avx2+pw_8192] shr r6d, 11 add wq, r7 vpbroadcastd m4, [base+prep_mul+r6*4] lea r6, [strideq*3] %if WIN64 pop r7 %endif jmp wq .h_w4: movzx mxd, mxb sub srcq, 2 pmovsxbw xm0, [base+subpel_filters+mxq*8] vbroadcasti128 m3, [subpel_h_shufA] vbroadcasti128 m4, [subpel_h_shufB] WIN64_SPILL_XMM 8 pshufd xm0, xm0, q2211 test dword r7m, 0x800 jnz .h_w4_12bpc psllw xm0, 2 .h_w4_12bpc: vpbroadcastq m6, xm0 vpermq m7, m0, q1111 .h_w4_loop: movu xm1, [srcq+strideq*0] vinserti128 m1, [srcq+strideq*2], 1 movu xm2, [srcq+strideq*1] vinserti128 m2, [srcq+r6 ], 1 lea srcq, [srcq+strideq*4] pshufb m0, m1, m3 ; 0 1 1 2 2 3 3 4 pshufb m1, m4 ; 2 3 3 4 4 5 5 6 pmaddwd m0, m6 pmaddwd m1, m7 paddd m0, m5 paddd m0, m1 pshufb m1, m2, m3 pshufb m2, m4 pmaddwd m1, m6 pmaddwd m2, m7 paddd m1, m5 paddd m1, m2 psrad m0, 4 psrad m1, 4 packssdw m0, m1 mova [tmpq], m0 add tmpq, 32 sub hd, 4 jg .h_w4_loop RET .h: test myd, 0xf00 jnz .hv vpbroadcastd m5, [prep_8tap_1d_rnd] ; 8 - (8192 << 4) lea r6, [strideq*3] cmp wd, 4 je .h_w4 shr mxd, 16 sub srcq, 6 vpbroadcastq m0, [base+subpel_filters+mxq*8] %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 12 vbroadcasti128 m6, [subpel_h_shufA] vbroadcasti128 m7, [subpel_h_shufB] punpcklbw m0, m0 psraw m0, 8 ; sign-extend test dword r7m, 0x800 jnz .h_12bpc psllw m0, 2 .h_12bpc: pshufd m8, m0, q0000 pshufd m9, m0, q1111 pshufd m10, m0, q2222 pshufd m11, m0, q3333 cmp wd, 8 jg .h_w16 .h_w8: %macro PREP_8TAP_H 5 ; dst/src+0, src+8, src+16, tmp[1-2] pshufb m%4, m%1, m7 ; 2 3 3 4 4 5 5 6 pshufb m%1, m6 ; 0 1 1 2 2 3 3 4 pmaddwd m%5, m9, m%4 ; abcd1 pmaddwd m%1, m8 ; abcd0 pshufb m%2, m7 ; 6 7 7 8 8 9 9 a shufpd m%4, m%2, 0x05 ; 4 5 5 6 6 7 7 8 paddd m%5, m5 paddd m%1, m%5 pmaddwd m%5, m11, m%2 ; abcd3 paddd m%1, m%5 pmaddwd m%5, m10, m%4 ; abcd2 pshufb m%3, m7 ; a b b c c d d e pmaddwd m%4, m8 ; efgh0 paddd m%1, m%5 pmaddwd m%5, m9, m%2 ; efgh1 shufpd m%2, m%3, 0x05 ; 8 9 9 a a b b c pmaddwd m%3, m11 ; efgh3 pmaddwd m%2, m10 ; efgh2 paddd m%4, m5 paddd m%4, m%5 paddd m%3, m%4 paddd m%2, m%3 psrad m%1, 4 psrad m%2, 4 packssdw m%1, m%2 %endmacro movu xm0, [srcq+strideq*0+ 0] vinserti128 m0, [srcq+strideq*1+ 0], 1 movu xm2, [srcq+strideq*0+16] vinserti128 m2, [srcq+strideq*1+16], 1 lea srcq, [srcq+strideq*2] shufpd m1, m0, m2, 0x05 PREP_8TAP_H 0, 1, 2, 3, 4 mova [tmpq], m0 add tmpq, 32 sub hd, 2 jg .h_w8 RET .h_w16: add wd, wd .h_w16_loop0: mov r6d, wd .h_w16_loop: movu m0, [srcq+r6-32] movu m1, [srcq+r6-24] movu m2, [srcq+r6-16] PREP_8TAP_H 0, 1, 2, 3, 4 mova [tmpq+r6-32], m0 sub r6d, 32 jg .h_w16_loop add srcq, strideq add tmpq, wq dec hd jg .h_w16_loop0 RET .v: movzx mxd, myb shr myd, 16 cmp hd, 4 cmovle myd, mxd vpbroadcastq m0, [base+subpel_filters+myq*8] %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 15 vpbroadcastd m7, [prep_8tap_1d_rnd] lea r6, [strideq*3] sub srcq, r6 punpcklbw m0, m0 psraw m0, 8 ; sign-extend test dword r7m, 0x800 jnz .v_12bpc psllw m0, 2 .v_12bpc: pshufd m8, m0, q0000 pshufd m9, m0, q1111 pshufd m10, m0, q2222 pshufd m11, m0, q3333 cmp wd, 4 jg .v_w8 .v_w4: movq xm1, [srcq+strideq*0] vpbroadcastq m0, [srcq+strideq*1] vpbroadcastq m2, [srcq+strideq*2] vpbroadcastq m4, [srcq+r6 ] lea srcq, [srcq+strideq*4] vpbroadcastq m3, [srcq+strideq*0] vpbroadcastq m5, [srcq+strideq*1] vpblendd m1, m0, 0x30 vpblendd m0, m2, 0x30 punpcklwd m1, m0 ; 01 12 vpbroadcastq m0, [srcq+strideq*2] add srcq, r6 vpblendd m2, m4, 0x30 vpblendd m4, m3, 0x30 punpcklwd m2, m4 ; 23 34 vpblendd m3, m5, 0x30 vpblendd m5, m0, 0x30 punpcklwd m3, m5 ; 45 56 .v_w4_loop: vpbroadcastq m4, [srcq+strideq*0] pmaddwd m5, m8, m1 ; a0 b0 mova m1, m2 pmaddwd m2, m9 ; a1 b1 paddd m5, m7 paddd m5, m2 mova m2, m3 pmaddwd m3, m10 ; a2 b2 paddd m5, m3 vpblendd m3, m0, m4, 0x30 vpbroadcastq m0, [srcq+strideq*1] lea srcq, [srcq+strideq*2] vpblendd m4, m0, 0x30 punpcklwd m3, m4 ; 67 78 pmaddwd m4, m11, m3 ; a3 b3 paddd m5, m4 psrad m5, 4 vextracti128 xm4, m5, 1 packssdw xm5, xm4 mova [tmpq], xm5 add tmpq, 16 sub hd, 2 jg .v_w4_loop RET .v_w8: %if WIN64 push r8 %endif mov r8d, wd shl wd, 5 mov r5, srcq mov r7, tmpq lea wd, [hq+wq-256] .v_w8_loop0: vbroadcasti128 m4, [srcq+strideq*0] vbroadcasti128 m5, [srcq+strideq*1] vbroadcasti128 m0, [srcq+r6 ] vbroadcasti128 m6, [srcq+strideq*2] lea srcq, [srcq+strideq*4] vbroadcasti128 m1, [srcq+strideq*0] vbroadcasti128 m2, [srcq+strideq*1] vbroadcasti128 m3, [srcq+strideq*2] add srcq, r6 shufpd m4, m0, 0x0c shufpd m5, m1, 0x0c punpcklwd m1, m4, m5 ; 01 punpckhwd m4, m5 ; 34 shufpd m6, m2, 0x0c punpcklwd m2, m5, m6 ; 12 punpckhwd m5, m6 ; 45 shufpd m0, m3, 0x0c punpcklwd m3, m6, m0 ; 23 punpckhwd m6, m0 ; 56 .v_w8_loop: vbroadcasti128 m14, [srcq+strideq*0] pmaddwd m12, m8, m1 ; a0 pmaddwd m13, m8, m2 ; b0 mova m1, m3 mova m2, m4 pmaddwd m3, m9 ; a1 pmaddwd m4, m9 ; b1 paddd m12, m7 paddd m13, m7 paddd m12, m3 paddd m13, m4 mova m3, m5 mova m4, m6 pmaddwd m5, m10 ; a2 pmaddwd m6, m10 ; b2 paddd m12, m5 vbroadcasti128 m5, [srcq+strideq*1] lea srcq, [srcq+strideq*2] paddd m13, m6 shufpd m6, m0, m14, 0x0d shufpd m0, m14, m5, 0x0c punpcklwd m5, m6, m0 ; 67 punpckhwd m6, m0 ; 78 pmaddwd m14, m11, m5 ; a3 paddd m12, m14 pmaddwd m14, m11, m6 ; b3 paddd m13, m14 psrad m12, 4 psrad m13, 4 packssdw m12, m13 vpermq m12, m12, q3120 mova [tmpq+r8*0], xm12 vextracti128 [tmpq+r8*2], m12, 1 lea tmpq, [tmpq+r8*4] sub hd, 2 jg .v_w8_loop add r5, 16 add r7, 16 movzx hd, wb mov srcq, r5 mov tmpq, r7 sub wd, 1<<8 jg .v_w8_loop0 %if WIN64 pop r8 %endif RET .hv: %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 16 vpbroadcastd m15, [prep_8tap_2d_rnd] cmp wd, 4 jg .hv_w8 movzx mxd, mxb vpbroadcastd m0, [base+subpel_filters+mxq*8+2] movzx mxd, myb shr myd, 16 cmp hd, 4 cmovle myd, mxd vpbroadcastq m1, [base+subpel_filters+myq*8] lea r6, [strideq*3] sub srcq, 2 sub srcq, r6 pxor m7, m7 punpcklbw m7, m0 punpcklbw m1, m1 psraw m7, 4 psraw m1, 8 test dword r7m, 0x800 jz .hv_w4_10bit psraw m7, 2 .hv_w4_10bit: pshufd m11, m1, q0000 pshufd m12, m1, q1111 pshufd m13, m1, q2222 pshufd m14, m1, q3333 .hv_w4: vbroadcasti128 m9, [subpel_h_shufA] vbroadcasti128 m10, [subpel_h_shufB] pshufd m8, m7, q1111 pshufd m7, m7, q0000 movu xm1, [srcq+strideq*0] vinserti128 m1, [srcq+strideq*1], 1 ; 0 1 vbroadcasti128 m0, [srcq+r6 ] vinserti128 m2, m0, [srcq+strideq*2], 0 ; 2 3 lea srcq, [srcq+strideq*4] vinserti128 m0, [srcq+strideq*0], 1 ; 3 4 movu xm3, [srcq+strideq*1] vinserti128 m3, [srcq+strideq*2], 1 ; 5 6 add srcq, r6 pshufb m4, m1, m9 pshufb m1, m10 pmaddwd m4, m7 pmaddwd m1, m8 pshufb m5, m2, m9 pshufb m2, m10 pmaddwd m5, m7 pmaddwd m2, m8 paddd m4, m15 paddd m1, m4 pshufb m4, m0, m9 pshufb m0, m10 pmaddwd m4, m7 pmaddwd m0, m8 paddd m5, m15 paddd m2, m5 pshufb m5, m3, m9 pshufb m3, m10 pmaddwd m5, m7 pmaddwd m3, m8 paddd m4, m15 paddd m4, m0 paddd m5, m15 paddd m5, m3 vperm2i128 m0, m1, m2, 0x21 psrld m1, 6 psrld m2, 6 vperm2i128 m3, m4, m5, 0x21 pslld m4, 10 pslld m5, 10 pblendw m2, m4, 0xaa ; 23 34 pslld m0, 10 pblendw m1, m0, 0xaa ; 01 12 psrld m3, 6 pblendw m3, m5, 0xaa ; 45 56 psrad m0, m5, 16 .hv_w4_loop: movu xm4, [srcq+strideq*0] vinserti128 m4, [srcq+strideq*1], 1 lea srcq, [srcq+strideq*2] pmaddwd m5, m11, m1 ; a0 b0 mova m1, m2 pmaddwd m2, m12 ; a1 b1 paddd m5, m15 paddd m5, m2 mova m2, m3 pmaddwd m3, m13 ; a2 b2 paddd m5, m3 pshufb m3, m4, m9 pshufb m4, m10 pmaddwd m3, m7 pmaddwd m4, m8 paddd m3, m15 paddd m4, m3 psrad m4, 6 packssdw m0, m4 ; _ 7 6 8 vpermq m3, m0, q1122 ; _ 6 _ 7 punpckhwd m3, m0 ; 67 78 mova m0, m4 pmaddwd m4, m14, m3 ; a3 b3 paddd m4, m5 psrad m4, 6 vextracti128 xm5, m4, 1 packssdw xm4, xm5 mova [tmpq], xm4 add tmpq, 16 sub hd, 2 jg .hv_w4_loop RET .hv_w8: shr mxd, 16 vpbroadcastq m2, [base+subpel_filters+mxq*8] movzx mxd, myb shr myd, 16 cmp hd, 4 cmovle myd, mxd pmovsxbw xm1, [base+subpel_filters+myq*8] %if WIN64 PUSH r8 %endif mov r8d, wd shl wd, 5 lea r6, [strideq*3] sub srcq, 6 sub srcq, r6 mov r5, srcq mov r7, tmpq lea wd, [hq+wq-256] pxor m0, m0 punpcklbw m0, m2 mova [v_mul], xm1 psraw m0, 4 test dword r7m, 0x800 jz .hv_w8_10bit psraw m0, 2 .hv_w8_10bit: pshufd m11, m0, q0000 pshufd m12, m0, q1111 pshufd m13, m0, q2222 pshufd m14, m0, q3333 .hv_w8_loop0: %macro PREP_8TAP_HV_H 3 ; dst/src+0, src+8, src+16 pshufb m2, m%1, m9 ; 2 3 3 4 4 5 5 6 pshufb m%1, m8 ; 0 1 1 2 2 3 3 4 pmaddwd m3, m12, m2 pmaddwd m%1, m11 pshufb m%2, m9 ; 6 7 7 8 8 9 9 a shufpd m2, m%2, 0x05 ; 4 5 5 6 6 7 7 8 paddd m3, m15 paddd m%1, m3 pmaddwd m3, m14, m%2 paddd m%1, m3 pmaddwd m3, m13, m2 pshufb m%3, m9 ; a b b c c d d e pmaddwd m2, m11 paddd m%1, m3 pmaddwd m3, m12, m%2 shufpd m%2, m%3, 0x05 ; 8 9 9 a a b b c pmaddwd m%3, m14 pmaddwd m%2, m13 paddd m2, m15 paddd m2, m3 paddd m2, m%3 paddd m2, m%2 psrad m%1, 6 psrad m2, 6 packssdw m%1, m2 %endmacro movu xm4, [srcq+r6 + 0] vbroadcasti128 m8, [subpel_h_shufA] movu xm6, [srcq+r6 + 8] vbroadcasti128 m9, [subpel_h_shufB] movu xm0, [srcq+r6 +16] movu xm5, [srcq+strideq*0+ 0] vinserti128 m5, [srcq+strideq*4+ 0], 1 movu xm1, [srcq+strideq*0+16] vinserti128 m1, [srcq+strideq*4+16], 1 shufpd m7, m5, m1, 0x05 INIT_XMM avx2 PREP_8TAP_HV_H 4, 6, 0 ; 3 INIT_YMM avx2 PREP_8TAP_HV_H 5, 7, 1 ; 0 4 movu xm0, [srcq+strideq*2+ 0] vinserti128 m0, [srcq+r6 *2+ 0], 1 movu xm1, [srcq+strideq*2+16] vinserti128 m1, [srcq+r6 *2+16], 1 shufpd m7, m0, m1, 0x05 PREP_8TAP_HV_H 0, 7, 1 ; 2 6 movu xm6, [srcq+strideq*1+ 0] movu xm1, [srcq+strideq*1+16] lea srcq, [srcq+strideq*4] vinserti128 m6, [srcq+strideq*1+ 0], 1 vinserti128 m1, [srcq+strideq*1+16], 1 add srcq, r6 shufpd m7, m6, m1, 0x05 PREP_8TAP_HV_H 6, 7, 1 ; 1 5 vpermq m4, m4, q1100 vpermq m5, m5, q3120 vpermq m6, m6, q3120 vpermq m7, m0, q3120 punpcklwd m3, m7, m4 ; 23 punpckhwd m4, m5 ; 34 punpcklwd m1, m5, m6 ; 01 punpckhwd m5, m6 ; 45 punpcklwd m2, m6, m7 ; 12 punpckhwd m6, m7 ; 56 .hv_w8_loop: vpbroadcastd m9, [v_mul+4*0] vpbroadcastd m7, [v_mul+4*1] vpbroadcastd m10, [v_mul+4*2] pmaddwd m8, m9, m1 ; a0 pmaddwd m9, m2 ; b0 mova m1, m3 mova m2, m4 pmaddwd m3, m7 ; a1 pmaddwd m4, m7 ; b1 paddd m8, m15 paddd m9, m15 paddd m8, m3 paddd m9, m4 mova m3, m5 mova m4, m6 pmaddwd m5, m10 ; a2 pmaddwd m6, m10 ; b2 paddd m8, m5 paddd m9, m6 movu xm5, [srcq+strideq*0] vinserti128 m5, [srcq+strideq*1], 1 vbroadcasti128 m7, [subpel_h_shufA] vbroadcasti128 m10, [subpel_h_shufB] movu xm6, [srcq+strideq*0+16] vinserti128 m6, [srcq+strideq*1+16], 1 vextracti128 [tmpq], m0, 1 pshufb m0, m5, m7 ; 01 pshufb m5, m10 ; 23 pmaddwd m0, m11 pmaddwd m5, m12 paddd m0, m15 paddd m0, m5 pshufb m5, m6, m7 ; 89 pshufb m6, m10 ; ab pmaddwd m5, m13 pmaddwd m6, m14 paddd m5, m15 paddd m6, m5 movu xm5, [srcq+strideq*0+8] vinserti128 m5, [srcq+strideq*1+8], 1 lea srcq, [srcq+strideq*2] pshufb m7, m5, m7 pshufb m5, m10 pmaddwd m10, m13, m7 pmaddwd m7, m11 paddd m0, m10 paddd m6, m7 pmaddwd m7, m14, m5 pmaddwd m5, m12 paddd m0, m7 paddd m5, m6 vbroadcasti128 m6, [tmpq] vpbroadcastd m10, [v_mul+4*3] psrad m0, 6 psrad m5, 6 packssdw m0, m5 vpermq m7, m0, q3120 ; 7 8 shufpd m6, m7, 0x04 ; 6 7 punpcklwd m5, m6, m7 ; 67 punpckhwd m6, m7 ; 78 pmaddwd m7, m10, m5 ; a3 pmaddwd m10, m6 ; b3 paddd m7, m8 paddd m9, m10 psrad m7, 6 psrad m9, 6 packssdw m7, m9 vpermq m7, m7, q3120 mova [tmpq+r8*0], xm7 vextracti128 [tmpq+r8*2], m7, 1 lea tmpq, [tmpq+r8*4] sub hd, 2 jg .hv_w8_loop add r5, 16 add r7, 16 movzx hd, wb mov srcq, r5 mov tmpq, r7 sub wd, 1<<8 jg .hv_w8_loop0 %if WIN64 POP r8 %endif RET %macro WARP_V 5 ; dst, 01, 23, 45, 67 lea tmp1d, [myq+deltaq*4] lea tmp2d, [myq+deltaq*1] shr myd, 10 shr tmp1d, 10 movq xm8, [filterq+myq *8] vinserti128 m8, [filterq+tmp1q*8], 1 ; a e lea tmp1d, [tmp2q+deltaq*4] lea myd, [tmp2q+deltaq*1] shr tmp2d, 10 shr tmp1d, 10 movq xm0, [filterq+tmp2q*8] vinserti128 m0, [filterq+tmp1q*8], 1 ; b f lea tmp1d, [myq+deltaq*4] lea tmp2d, [myq+deltaq*1] shr myd, 10 shr tmp1d, 10 movq xm9, [filterq+myq *8] vinserti128 m9, [filterq+tmp1q*8], 1 ; c g lea tmp1d, [tmp2q+deltaq*4] lea myd, [tmp2q+gammaq] ; my += gamma punpcklwd m8, m0 shr tmp2d, 10 shr tmp1d, 10 movq xm0, [filterq+tmp2q*8] vinserti128 m0, [filterq+tmp1q*8], 1 ; d h punpcklwd m0, m9, m0 punpckldq m9, m8, m0 punpckhdq m0, m8, m0 punpcklbw m8, m11, m9 ; a0 a1 b0 b1 c0 c1 d0 d1 << 8 punpckhbw m9, m11, m9 ; a2 a3 b2 b3 c2 c3 d2 d3 << 8 pmaddwd m%2, m8 pmaddwd m9, m%3 punpcklbw m8, m11, m0 ; a4 a5 b4 b5 c4 c5 d4 d5 << 8 punpckhbw m0, m11, m0 ; a6 a7 b6 b7 c6 c7 d6 d7 << 8 pmaddwd m8, m%4 pmaddwd m0, m%5 paddd m9, m%2 mova m%2, m%3 paddd m0, m8 mova m%3, m%4 mova m%4, m%5 paddd m%1, m0, m9 %endmacro cglobal warp_affine_8x8t_16bpc, 4, 14, 16, tmp, ts mov r6d, r7m lea r9, [$$] shr r6d, 11 vpbroadcastd m13, [r9-$$+warp8x8_shift+r6*4] vpbroadcastd m14, [warp8x8t_rnd] call mangle(private_prefix %+ _warp_affine_8x8_16bpc_avx2).main jmp .start .loop: call mangle(private_prefix %+ _warp_affine_8x8_16bpc_avx2).main2 lea tmpq, [tmpq+tsq*4] .start: paddd m7, m14 paddd m0, m14 psrad m7, 15 psrad m0, 15 packssdw m7, m0 vpermq m7, m7, q3120 mova [tmpq+tsq*0], xm7 vextracti128 [tmpq+tsq*2], m7, 1 dec r4d jg .loop .end: RET cglobal warp_affine_8x8_16bpc, 4, 14, 16, dst, ds, src, ss, abcd, mx, tmp2, \ alpha, beta, filter, tmp1, delta, \ my, gamma mov r6d, r7m lea filterq, [$$] shr r6d, 11 vpbroadcastd m13, [filterq-$$+warp8x8_shift+r6*4] vpbroadcastd m14, [filterq-$$+warp8x8_rnd +r6*4] vpbroadcastw m15, r7m ; pixel_max call .main jmp .start .loop: call .main2 lea dstq, [dstq+dsq*2] .start: psrad m7, 16 psrad m0, 16 packusdw m7, m0 pmulhrsw m7, m14 pminsw m7, m15 vpermq m7, m7, q3120 mova [dstq+dsq*0], xm7 vextracti128 [dstq+dsq*1], m7, 1 dec r4d jg .loop .end: RET ALIGN function_align .main: ; Stack args offset by one (r4m -> r5m etc.) due to call %if WIN64 mov abcdq, r5m mov mxd, r6m %endif movsx alphad, word [abcdq+2*0] movsx betad, word [abcdq+2*1] vpbroadcastd m12, [pd_32768] pxor m11, m11 add filterq, mc_warp_filter-$$ lea tmp1q, [ssq*3] add mxd, 512+(64<<10) lea tmp2d, [alphaq*3] sub srcq, tmp1q ; src -= src_stride*3 sub betad, tmp2d ; beta -= alpha*3 mov myd, r7m call .h psrld m1, m0, 16 call .h pblendw m1, m0, 0xaa ; 01 psrld m2, m0, 16 call .h pblendw m2, m0, 0xaa ; 12 psrld m3, m0, 16 call .h pblendw m3, m0, 0xaa ; 23 psrld m4, m0, 16 call .h pblendw m4, m0, 0xaa ; 34 psrld m5, m0, 16 call .h pblendw m5, m0, 0xaa ; 45 psrld m6, m0, 16 call .h pblendw m6, m0, 0xaa ; 56 movsx deltad, word [abcdq+2*2] movsx gammad, word [abcdq+2*3] add myd, 512+(64<<10) mov r4d, 4 lea tmp1d, [deltaq*3] sub gammad, tmp1d ; gamma -= delta*3 .main2: call .h psrld m7, m6, 16 pblendw m7, m0, 0xaa ; 67 WARP_V 7, 1, 3, 5, 7 call .h psrld m10, m5, 16 pblendw m10, m0, 0xaa ; 78 WARP_V 0, 2, 4, 6, 10 ret ALIGN function_align .h: lea tmp1d, [mxq+alphaq*4] lea tmp2d, [mxq+alphaq*1] movu xm10, [srcq-6] vinserti128 m10, [srcq+2], 1 shr mxd, 10 ; 0 shr tmp1d, 10 ; 4 movq xm0, [filterq+mxq *8] vinserti128 m0, [filterq+tmp1q*8], 1 lea tmp1d, [tmp2q+alphaq*4] lea mxd, [tmp2q+alphaq*1] movu xm8, [srcq-4] vinserti128 m8, [srcq+4], 1 shr tmp2d, 10 ; 1 shr tmp1d, 10 ; 5 movq xm9, [filterq+tmp2q*8] vinserti128 m9, [filterq+tmp1q*8], 1 lea tmp1d, [mxq+alphaq*4] lea tmp2d, [mxq+alphaq*1] shr mxd, 10 ; 2 shr tmp1d, 10 ; 6 punpcklbw m0, m11, m0 pmaddwd m0, m10 movu xm10, [srcq-2] vinserti128 m10, [srcq+6], 1 punpcklbw m9, m11, m9 pmaddwd m9, m8 movq xm8, [filterq+mxq *8] vinserti128 m8, [filterq+tmp1q*8], 1 lea tmp1d, [tmp2q+alphaq*4] lea mxd, [tmp2q+betaq] ; mx += beta phaddd m0, m9 ; 0 1 4 5 movu xm9, [srcq+0] vinserti128 m9, [srcq+8], 1 shr tmp2d, 10 ; 3 shr tmp1d, 10 ; 7 punpcklbw m8, m11, m8 pmaddwd m8, m10 movq xm10, [filterq+tmp2q*8] vinserti128 m10, [filterq+tmp1q*8], 1 punpcklbw m10, m11, m10 pmaddwd m9, m10 add srcq, ssq phaddd m8, m9 ; 2 3 6 7 phaddd m0, m8 ; 0 1 2 3 4 5 6 7 vpsllvd m0, m13 paddd m0, m12 ; rounded 14-bit result in upper 16 bits of dword ret %macro BIDIR_FN 0 call .main lea stride3q, [strideq*3] jmp wq .w4: movq [dstq ], xm0 movhps [dstq+strideq*1], xm0 vextracti128 xm0, m0, 1 movq [dstq+strideq*2], xm0 movhps [dstq+stride3q ], xm0 cmp hd, 4 je .ret lea dstq, [dstq+strideq*4] movq [dstq ], xm1 movhps [dstq+strideq*1], xm1 vextracti128 xm1, m1, 1 movq [dstq+strideq*2], xm1 movhps [dstq+stride3q ], xm1 cmp hd, 8 je .ret lea dstq, [dstq+strideq*4] movq [dstq ], xm2 movhps [dstq+strideq*1], xm2 vextracti128 xm2, m2, 1 movq [dstq+strideq*2], xm2 movhps [dstq+stride3q ], xm2 lea dstq, [dstq+strideq*4] movq [dstq ], xm3 movhps [dstq+strideq*1], xm3 vextracti128 xm3, m3, 1 movq [dstq+strideq*2], xm3 movhps [dstq+stride3q ], xm3 .ret: RET .w8: mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 mova [dstq+strideq*2], xm1 vextracti128 [dstq+stride3q ], m1, 1 cmp hd, 4 jne .w8_loop_start RET .w8_loop: call .main lea dstq, [dstq+strideq*4] mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 mova [dstq+strideq*2], xm1 vextracti128 [dstq+stride3q ], m1, 1 .w8_loop_start: lea dstq, [dstq+strideq*4] mova [dstq+strideq*0], xm2 vextracti128 [dstq+strideq*1], m2, 1 mova [dstq+strideq*2], xm3 vextracti128 [dstq+stride3q ], m3, 1 sub hd, 8 jg .w8_loop RET .w16_loop: call .main lea dstq, [dstq+strideq*4] .w16: mova [dstq+strideq*0], m0 mova [dstq+strideq*1], m1 mova [dstq+strideq*2], m2 mova [dstq+stride3q ], m3 sub hd, 4 jg .w16_loop RET .w32_loop: call .main lea dstq, [dstq+strideq*2] .w32: mova [dstq+strideq*0+32*0], m0 mova [dstq+strideq*0+32*1], m1 mova [dstq+strideq*1+32*0], m2 mova [dstq+strideq*1+32*1], m3 sub hd, 2 jg .w32_loop RET .w64_loop: call .main add dstq, strideq .w64: mova [dstq+32*0], m0 mova [dstq+32*1], m1 mova [dstq+32*2], m2 mova [dstq+32*3], m3 dec hd jg .w64_loop RET .w128_loop: call .main add dstq, strideq .w128: mova [dstq+32*0], m0 mova [dstq+32*1], m1 mova [dstq+32*2], m2 mova [dstq+32*3], m3 call .main mova [dstq+32*4], m0 mova [dstq+32*5], m1 mova [dstq+32*6], m2 mova [dstq+32*7], m3 dec hd jg .w128_loop RET %endmacro %if WIN64 DECLARE_REG_TMP 5 %else DECLARE_REG_TMP 7 %endif cglobal avg_16bpc, 4, 7, 6, dst, stride, tmp1, tmp2, w, h, stride3 %define base r6-avg_avx2_table lea r6, [avg_avx2_table] tzcnt wd, wm mov t0d, r6m ; pixel_max movsxd wq, [r6+wq*4] shr t0d, 11 vpbroadcastd m4, [base+bidir_rnd+t0*4] vpbroadcastd m5, [base+bidir_mul+t0*4] movifnidn hd, hm add wq, r6 BIDIR_FN ALIGN function_align .main: mova m0, [tmp1q+32*0] paddsw m0, [tmp2q+32*0] mova m1, [tmp1q+32*1] paddsw m1, [tmp2q+32*1] mova m2, [tmp1q+32*2] paddsw m2, [tmp2q+32*2] mova m3, [tmp1q+32*3] paddsw m3, [tmp2q+32*3] add tmp1q, 32*4 add tmp2q, 32*4 pmaxsw m0, m4 pmaxsw m1, m4 pmaxsw m2, m4 pmaxsw m3, m4 psubsw m0, m4 psubsw m1, m4 psubsw m2, m4 psubsw m3, m4 pmulhw m0, m5 pmulhw m1, m5 pmulhw m2, m5 pmulhw m3, m5 ret cglobal w_avg_16bpc, 4, 7, 9, dst, stride, tmp1, tmp2, w, h, stride3 lea r6, [w_avg_avx2_table] tzcnt wd, wm mov t0d, r6m ; weight vpbroadcastw m8, r7m ; pixel_max vpbroadcastd m7, [r6-w_avg_avx2_table+pd_65538] movsxd wq, [r6+wq*4] paddw m7, m8 add wq, r6 lea r6d, [t0-16] shl t0d, 16 sub t0d, r6d ; 16-weight, weight pslld m7, 7 rorx r6d, t0d, 30 ; << 2 test dword r7m, 0x800 cmovz r6d, t0d movifnidn hd, hm movd xm6, r6d vpbroadcastd m6, xm6 BIDIR_FN ALIGN function_align .main: mova m4, [tmp1q+32*0] mova m0, [tmp2q+32*0] punpckhwd m5, m0, m4 punpcklwd m0, m4 mova m4, [tmp1q+32*1] mova m1, [tmp2q+32*1] pmaddwd m5, m6 pmaddwd m0, m6 paddd m5, m7 paddd m0, m7 psrad m5, 8 psrad m0, 8 packusdw m0, m5 punpckhwd m5, m1, m4 punpcklwd m1, m4 mova m4, [tmp1q+32*2] mova m2, [tmp2q+32*2] pmaddwd m5, m6 pmaddwd m1, m6 paddd m5, m7 paddd m1, m7 psrad m5, 8 psrad m1, 8 packusdw m1, m5 punpckhwd m5, m2, m4 punpcklwd m2, m4 mova m4, [tmp1q+32*3] mova m3, [tmp2q+32*3] add tmp1q, 32*4 add tmp2q, 32*4 pmaddwd m5, m6 pmaddwd m2, m6 paddd m5, m7 paddd m2, m7 psrad m5, 8 psrad m2, 8 packusdw m2, m5 punpckhwd m5, m3, m4 punpcklwd m3, m4 pmaddwd m5, m6 pmaddwd m3, m6 paddd m5, m7 paddd m3, m7 psrad m5, 8 psrad m3, 8 packusdw m3, m5 pminsw m0, m8 pminsw m1, m8 pminsw m2, m8 pminsw m3, m8 ret cglobal mask_16bpc, 4, 8, 11, dst, stride, tmp1, tmp2, w, h, mask, stride3 %define base r7-mask_avx2_table lea r7, [mask_avx2_table] tzcnt wd, wm mov r6d, r7m ; pixel_max movifnidn hd, hm shr r6d, 11 movsxd wq, [r7+wq*4] vpbroadcastd m8, [base+pw_64] vpbroadcastd m9, [base+bidir_rnd+r6*4] vpbroadcastd m10, [base+bidir_mul+r6*4] mov maskq, maskmp add wq, r7 BIDIR_FN ALIGN function_align .main: %macro MASK 1 pmovzxbw m5, [maskq+16*%1] mova m%1, [tmp1q+32*%1] mova m6, [tmp2q+32*%1] punpckhwd m4, m%1, m6 punpcklwd m%1, m6 psubw m7, m8, m5 punpckhwd m6, m5, m7 ; m, 64-m punpcklwd m5, m7 pmaddwd m4, m6 ; tmp1 * m + tmp2 * (64-m) pmaddwd m%1, m5 psrad m4, 5 psrad m%1, 5 packssdw m%1, m4 pmaxsw m%1, m9 psubsw m%1, m9 pmulhw m%1, m10 %endmacro MASK 0 MASK 1 MASK 2 MASK 3 add maskq, 16*4 add tmp1q, 32*4 add tmp2q, 32*4 ret cglobal w_mask_420_16bpc, 4, 8, 16, dst, stride, tmp1, tmp2, w, h, mask, stride3 %define base r7-w_mask_420_avx2_table lea r7, [w_mask_420_avx2_table] tzcnt wd, wm mov r6d, r8m ; pixel_max movd xm0, r7m ; sign movifnidn hd, hm shr r6d, 11 movsxd wq, [r7+wq*4] vpbroadcastd m10, [base+pw_27615] ; ((64 - 38) << 10) + 1023 - 32 vpbroadcastd m11, [base+pw_64] vpbroadcastd m12, [base+bidir_rnd+r6*4] vpbroadcastd m13, [base+bidir_mul+r6*4] movd xm14, [base+pw_2] mov maskq, maskmp psubw xm14, xm0 vpbroadcastw m14, xm14 add wq, r7 call .main lea stride3q, [strideq*3] jmp wq .w4: phaddd m4, m5 paddw m4, m14 psrlw m4, 2 packuswb m4, m4 vextracti128 xm5, m4, 1 punpcklwd xm4, xm5 movq [dstq+strideq*0], xm0 movhps [dstq+strideq*1], xm0 vextracti128 xm0, m0, 1 movq [dstq+strideq*2], xm0 movhps [dstq+stride3q ], xm0 mova [maskq], xm4 cmp hd, 8 jl .w4_end lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm1 movhps [dstq+strideq*1], xm1 vextracti128 xm1, m1, 1 movq [dstq+strideq*2], xm1 movhps [dstq+stride3q ], xm1 je .w4_end lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm2 movhps [dstq+strideq*1], xm2 vextracti128 xm2, m2, 1 movq [dstq+strideq*2], xm2 movhps [dstq+stride3q ], xm2 lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm3 movhps [dstq+strideq*1], xm3 vextracti128 xm3, m3, 1 movq [dstq+strideq*2], xm3 movhps [dstq+stride3q ], xm3 .w4_end: RET .w8_loop: call .main lea dstq, [dstq+strideq*4] add maskq, 16 .w8: vperm2i128 m6, m4, m5, 0x21 vpblendd m4, m5, 0xf0 paddw m4, m14 paddw m4, m6 psrlw m4, 2 vextracti128 xm5, m4, 1 packuswb xm4, xm5 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 mova [dstq+strideq*2], xm1 vextracti128 [dstq+stride3q ], m1, 1 mova [maskq], xm4 sub hd, 8 jl .w8_end lea dstq, [dstq+strideq*4] mova [dstq+strideq*0], xm2 vextracti128 [dstq+strideq*1], m2, 1 mova [dstq+strideq*2], xm3 vextracti128 [dstq+stride3q ], m3, 1 jg .w8_loop .w8_end: RET .w16_loop: call .main lea dstq, [dstq+strideq*4] add maskq, 16 .w16: punpcklqdq m6, m4, m5 punpckhqdq m4, m5 paddw m6, m14 paddw m4, m6 psrlw m4, 2 vextracti128 xm5, m4, 1 packuswb xm4, xm5 pshufd xm4, xm4, q3120 mova [dstq+strideq*0], m0 mova [dstq+strideq*1], m1 mova [dstq+strideq*2], m2 mova [dstq+stride3q ], m3 mova [maskq], xm4 sub hd, 4 jg .w16_loop RET .w32_loop: call .main lea dstq, [dstq+strideq*4] add maskq, 32 .w32: paddw m4, m14 paddw m4, m5 psrlw m15, m4, 2 mova [dstq+strideq*0+32*0], m0 mova [dstq+strideq*0+32*1], m1 mova [dstq+strideq*1+32*0], m2 mova [dstq+strideq*1+32*1], m3 call .main mova m6, [deint_shuf] paddw m4, m14 paddw m4, m5 psrlw m4, 2 packuswb m15, m4 vpermd m4, m6, m15 mova [dstq+strideq*2+32*0], m0 mova [dstq+strideq*2+32*1], m1 mova [dstq+stride3q +32*0], m2 mova [dstq+stride3q +32*1], m3 mova [maskq], m4 sub hd, 4 jg .w32_loop RET .w64_loop: call .main lea dstq, [dstq+strideq*2] add maskq, 32 .w64: paddw m4, m14 paddw m15, m14, m5 mova [dstq+strideq*0+32*0], m0 mova [dstq+strideq*0+32*1], m1 mova [dstq+strideq*0+32*2], m2 mova [dstq+strideq*0+32*3], m3 mova [maskq], m4 ; no available registers call .main paddw m4, [maskq] mova m6, [deint_shuf] paddw m5, m15 psrlw m4, 2 psrlw m5, 2 packuswb m4, m5 ; 0 2 4 6 1 3 5 7 vpermd m4, m6, m4 mova [dstq+strideq*1+32*0], m0 mova [dstq+strideq*1+32*1], m1 mova [dstq+strideq*1+32*2], m2 mova [dstq+strideq*1+32*3], m3 mova [maskq], m4 sub hd, 2 jg .w64_loop RET .w128_loop: call .main lea dstq, [dstq+strideq*2] add maskq, 64 .w128: paddw m4, m14 paddw m5, m14 mova [dstq+strideq*0+32*0], m0 mova [dstq+strideq*0+32*1], m1 mova [dstq+strideq*0+32*2], m2 mova [dstq+strideq*0+32*3], m3 mova [maskq+32*0], m4 mova [dstq+strideq], m5 call .main paddw m4, m14 paddw m15, m14, m5 mova [dstq+strideq*0+32*4], m0 mova [dstq+strideq*0+32*5], m1 mova [dstq+strideq*0+32*6], m2 mova [dstq+strideq*0+32*7], m3 mova [maskq+32*1], m4 call .main paddw m4, [maskq+32*0] paddw m5, [dstq+strideq] mova m6, [deint_shuf] psrlw m4, 2 psrlw m5, 2 packuswb m4, m5 vpermd m4, m6, m4 mova [dstq+strideq*1+32*0], m0 mova [dstq+strideq*1+32*1], m1 mova [dstq+strideq*1+32*2], m2 mova [dstq+strideq*1+32*3], m3 mova [maskq+32*0], m4 call .main paddw m4, [maskq+32*1] mova m6, [deint_shuf] paddw m5, m15 psrlw m4, 2 psrlw m5, 2 packuswb m4, m5 vpermd m4, m6, m4 mova [dstq+strideq*1+32*4], m0 mova [dstq+strideq*1+32*5], m1 mova [dstq+strideq*1+32*6], m2 mova [dstq+strideq*1+32*7], m3 mova [maskq+32*1], m4 sub hd, 2 jg .w128_loop RET ALIGN function_align .main: %macro W_MASK 2-6 11, 12, 13 ; dst/src1, mask/src2, pw_64, rnd, mul mova m%1, [tmp1q+32*%1] mova m%2, [tmp2q+32*%1] punpcklwd m8, m%2, m%1 punpckhwd m9, m%2, m%1 psubsw m%1, m%2 pabsw m%1, m%1 psubusw m7, m10, m%1 psrlw m7, 10 ; 64-m psubw m%2, m%3, m7 ; m punpcklwd m%1, m7, m%2 punpckhwd m7, m%2 pmaddwd m%1, m8 pmaddwd m7, m9 psrad m%1, 5 psrad m7, 5 packssdw m%1, m7 pmaxsw m%1, m%4 psubsw m%1, m%4 pmulhw m%1, m%5 %endmacro W_MASK 0, 4 W_MASK 1, 5 phaddw m4, m5 W_MASK 2, 5 W_MASK 3, 6 phaddw m5, m6 add tmp1q, 32*4 add tmp2q, 32*4 ret cglobal w_mask_422_16bpc, 4, 8, 16, dst, stride, tmp1, tmp2, w, h, mask, stride3 %define base r7-w_mask_422_avx2_table lea r7, [w_mask_422_avx2_table] tzcnt wd, wm mov r6d, r8m ; pixel_max vpbroadcastb m14, r7m ; sign movifnidn hd, hm shr r6d, 11 movsxd wq, [r7+wq*4] vpbroadcastd m10, [base+pw_27615] vpbroadcastd m11, [base+pw_64] vpbroadcastd m12, [base+bidir_rnd+r6*4] vpbroadcastd m13, [base+bidir_mul+r6*4] mova m15, [base+deint_shuf] mov maskq, maskmp add wq, r7 call .main lea stride3q, [strideq*3] jmp wq .w4: movq [dstq+strideq*0], xm0 movhps [dstq+strideq*1], xm0 vextracti128 xm0, m0, 1 movq [dstq+strideq*2], xm0 movhps [dstq+stride3q ], xm0 cmp hd, 8 jl .w4_end lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm1 movhps [dstq+strideq*1], xm1 vextracti128 xm1, m1, 1 movq [dstq+strideq*2], xm1 movhps [dstq+stride3q ], xm1 je .w4_end lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm2 movhps [dstq+strideq*1], xm2 vextracti128 xm2, m2, 1 movq [dstq+strideq*2], xm2 movhps [dstq+stride3q ], xm2 lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm3 movhps [dstq+strideq*1], xm3 vextracti128 xm3, m3, 1 movq [dstq+strideq*2], xm3 movhps [dstq+stride3q ], xm3 .w4_end: RET .w8_loop: call .main lea dstq, [dstq+strideq*4] .w8: mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 mova [dstq+strideq*2], xm1 vextracti128 [dstq+stride3q ], m1, 1 sub hd, 8 jl .w8_end lea dstq, [dstq+strideq*4] mova [dstq+strideq*0], xm2 vextracti128 [dstq+strideq*1], m2, 1 mova [dstq+strideq*2], xm3 vextracti128 [dstq+stride3q ], m3, 1 jg .w8_loop .w8_end: RET .w16_loop: call .main lea dstq, [dstq+strideq*4] .w16: mova [dstq+strideq*0], m0 mova [dstq+strideq*1], m1 mova [dstq+strideq*2], m2 mova [dstq+stride3q ], m3 sub hd, 4 jg .w16_loop RET .w32_loop: call .main lea dstq, [dstq+strideq*2] .w32: mova [dstq+strideq*0+32*0], m0 mova [dstq+strideq*0+32*1], m1 mova [dstq+strideq*1+32*0], m2 mova [dstq+strideq*1+32*1], m3 sub hd, 2 jg .w32_loop RET .w64_loop: call .main add dstq, strideq .w64: mova [dstq+32*0], m0 mova [dstq+32*1], m1 mova [dstq+32*2], m2 mova [dstq+32*3], m3 dec hd jg .w64_loop RET .w128_loop: call .main add dstq, strideq .w128: mova [dstq+32*0], m0 mova [dstq+32*1], m1 mova [dstq+32*2], m2 mova [dstq+32*3], m3 call .main mova [dstq+32*4], m0 mova [dstq+32*5], m1 mova [dstq+32*6], m2 mova [dstq+32*7], m3 dec hd jg .w128_loop RET ALIGN function_align .main: W_MASK 0, 4 W_MASK 1, 5 phaddw m4, m5 W_MASK 2, 5 W_MASK 3, 6 phaddw m5, m6 add tmp1q, 32*4 add tmp2q, 32*4 packuswb m4, m5 pxor m5, m5 psubb m4, m14 pavgb m4, m5 vpermd m4, m15, m4 mova [maskq], m4 add maskq, 32 ret cglobal w_mask_444_16bpc, 4, 8, 11, dst, stride, tmp1, tmp2, w, h, mask, stride3 %define base r7-w_mask_444_avx2_table lea r7, [w_mask_444_avx2_table] tzcnt wd, wm mov r6d, r8m ; pixel_max movifnidn hd, hm shr r6d, 11 movsxd wq, [r7+wq*4] vpbroadcastd m10, [base+pw_27615] vpbroadcastd m4, [base+pw_64] vpbroadcastd m5, [base+bidir_rnd+r6*4] vpbroadcastd m6, [base+bidir_mul+r6*4] mov maskq, maskmp add wq, r7 call .main lea stride3q, [strideq*3] jmp wq .w4: movq [dstq+strideq*0], xm0 movhps [dstq+strideq*1], xm0 vextracti128 xm0, m0, 1 movq [dstq+strideq*2], xm0 movhps [dstq+stride3q ], xm0 cmp hd, 8 jl .w4_end lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm1 movhps [dstq+strideq*1], xm1 vextracti128 xm1, m1, 1 movq [dstq+strideq*2], xm1 movhps [dstq+stride3q ], xm1 je .w4_end call .main lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm0 movhps [dstq+strideq*1], xm0 vextracti128 xm0, m0, 1 movq [dstq+strideq*2], xm0 movhps [dstq+stride3q ], xm0 lea dstq, [dstq+strideq*4] movq [dstq+strideq*0], xm1 movhps [dstq+strideq*1], xm1 vextracti128 xm1, m1, 1 movq [dstq+strideq*2], xm1 movhps [dstq+stride3q ], xm1 .w4_end: RET .w8_loop: call .main lea dstq, [dstq+strideq*4] .w8: mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 mova [dstq+strideq*2], xm1 vextracti128 [dstq+stride3q ], m1, 1 sub hd, 4 jg .w8_loop .w8_end: RET .w16_loop: call .main lea dstq, [dstq+strideq*2] .w16: mova [dstq+strideq*0], m0 mova [dstq+strideq*1], m1 sub hd, 2 jg .w16_loop RET .w32_loop: call .main add dstq, strideq .w32: mova [dstq+32*0], m0 mova [dstq+32*1], m1 dec hd jg .w32_loop RET .w64_loop: call .main add dstq, strideq .w64: mova [dstq+32*0], m0 mova [dstq+32*1], m1 call .main mova [dstq+32*2], m0 mova [dstq+32*3], m1 dec hd jg .w64_loop RET .w128_loop: call .main add dstq, strideq .w128: mova [dstq+32*0], m0 mova [dstq+32*1], m1 call .main mova [dstq+32*2], m0 mova [dstq+32*3], m1 call .main mova [dstq+32*4], m0 mova [dstq+32*5], m1 call .main mova [dstq+32*6], m0 mova [dstq+32*7], m1 dec hd jg .w128_loop RET ALIGN function_align .main: W_MASK 0, 2, 4, 5, 6 W_MASK 1, 3, 4, 5, 6 packuswb m2, m3 vpermq m2, m2, q3120 add tmp1q, 32*2 add tmp2q, 32*2 mova [maskq], m2 add maskq, 32 ret ; (a * (64 - m) + b * m + 32) >> 6 ; = (((b - a) * m + 32) >> 6) + a ; = (((b - a) * (m << 9) + 16384) >> 15) + a ; except m << 9 overflows int16_t when m == 64 (which is possible), ; but if we negate m it works out (-64 << 9 == -32768). ; = (((a - b) * (m * -512) + 16384) >> 15) + a cglobal blend_16bpc, 3, 7, 7, dst, ds, tmp, w, h, mask %define base r6-blend_avx2_table lea r6, [blend_avx2_table] tzcnt wd, wm movifnidn hd, hm movsxd wq, [r6+wq*4] movifnidn maskq, maskmp vpbroadcastd m6, [base+pw_m512] add wq, r6 lea r6, [dsq*3] jmp wq .w4: pmovzxbw m3, [maskq] movq xm0, [dstq+dsq*0] movhps xm0, [dstq+dsq*1] vpbroadcastq m1, [dstq+dsq*2] vpbroadcastq m2, [dstq+r6 ] vpblendd m0, m1, 0x30 vpblendd m0, m2, 0xc0 psubw m1, m0, [tmpq] add maskq, 16 add tmpq, 32 pmullw m3, m6 pmulhrsw m1, m3 paddw m0, m1 vextracti128 xm1, m0, 1 movq [dstq+dsq*0], xm0 movhps [dstq+dsq*1], xm0 movq [dstq+dsq*2], xm1 movhps [dstq+r6 ], xm1 lea dstq, [dstq+dsq*4] sub hd, 4 jg .w4 RET .w8: pmovzxbw m4, [maskq+16*0] pmovzxbw m5, [maskq+16*1] mova xm0, [dstq+dsq*0] vinserti128 m0, [dstq+dsq*1], 1 mova xm1, [dstq+dsq*2] vinserti128 m1, [dstq+r6 ], 1 psubw m2, m0, [tmpq+32*0] psubw m3, m1, [tmpq+32*1] add maskq, 16*2 add tmpq, 32*2 pmullw m4, m6 pmullw m5, m6 pmulhrsw m2, m4 pmulhrsw m3, m5 paddw m0, m2 paddw m1, m3 mova [dstq+dsq*0], xm0 vextracti128 [dstq+dsq*1], m0, 1 mova [dstq+dsq*2], xm1 vextracti128 [dstq+r6 ], m1, 1 lea dstq, [dstq+dsq*4] sub hd, 4 jg .w8 RET .w16: pmovzxbw m4, [maskq+16*0] pmovzxbw m5, [maskq+16*1] mova m0, [dstq+dsq*0] psubw m2, m0, [tmpq+ 32*0] mova m1, [dstq+dsq*1] psubw m3, m1, [tmpq+ 32*1] add maskq, 16*2 add tmpq, 32*2 pmullw m4, m6 pmullw m5, m6 pmulhrsw m2, m4 pmulhrsw m3, m5 paddw m0, m2 paddw m1, m3 mova [dstq+dsq*0], m0 mova [dstq+dsq*1], m1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .w16 RET .w32: pmovzxbw m4, [maskq+16*0] pmovzxbw m5, [maskq+16*1] mova m0, [dstq+32*0] psubw m2, m0, [tmpq+32*0] mova m1, [dstq+32*1] psubw m3, m1, [tmpq+32*1] add maskq, 16*2 add tmpq, 32*2 pmullw m4, m6 pmullw m5, m6 pmulhrsw m2, m4 pmulhrsw m3, m5 paddw m0, m2 paddw m1, m3 mova [dstq+32*0], m0 mova [dstq+32*1], m1 add dstq, dsq dec hd jg .w32 RET INIT_XMM avx2 cglobal blend_v_16bpc, 3, 6, 6, dst, ds, tmp, w, h %define base r5-blend_v_avx2_table lea r5, [blend_v_avx2_table] tzcnt wd, wm movifnidn hd, hm movsxd wq, [r5+wq*4] add wq, r5 jmp wq .w2: vpbroadcastd m2, [base+obmc_masks+2*2] .w2_loop: movd m0, [dstq+dsq*0] pinsrd m0, [dstq+dsq*1], 1 movq m1, [tmpq] add tmpq, 4*2 psubw m1, m0, m1 pmulhrsw m1, m2 paddw m0, m1 movd [dstq+dsq*0], m0 pextrd [dstq+dsq*1], m0, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .w2_loop RET .w4: vpbroadcastq m2, [base+obmc_masks+4*2] .w4_loop: movq m0, [dstq+dsq*0] movhps m0, [dstq+dsq*1] psubw m1, m0, [tmpq] add tmpq, 8*2 pmulhrsw m1, m2 paddw m0, m1 movq [dstq+dsq*0], m0 movhps [dstq+dsq*1], m0 lea dstq, [dstq+dsq*2] sub hd, 2 jg .w4_loop RET INIT_YMM avx2 .w8: vbroadcasti128 m2, [base+obmc_masks+8*2] .w8_loop: mova xm0, [dstq+dsq*0] vinserti128 m0, [dstq+dsq*1], 1 psubw m1, m0, [tmpq] add tmpq, 16*2 pmulhrsw m1, m2 paddw m0, m1 mova [dstq+dsq*0], xm0 vextracti128 [dstq+dsq*1], m0, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .w8_loop RET .w16: mova m4, [base+obmc_masks+16*2] .w16_loop: mova m0, [dstq+dsq*0] psubw m2, m0, [tmpq+ 32*0] mova m1, [dstq+dsq*1] psubw m3, m1, [tmpq+ 32*1] add tmpq, 32*2 pmulhrsw m2, m4 pmulhrsw m3, m4 paddw m0, m2 paddw m1, m3 mova [dstq+dsq*0], m0 mova [dstq+dsq*1], m1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .w16_loop RET .w32: %if WIN64 movaps [rsp+ 8], xmm6 movaps [rsp+24], xmm7 %endif mova m6, [base+obmc_masks+32*2] vbroadcasti128 m7, [base+obmc_masks+32*3] .w32_loop: mova m0, [dstq+dsq*0+32*0] psubw m3, m0, [tmpq +32*0] mova xm2, [dstq+dsq*0+32*1] mova xm5, [tmpq +32*1] mova m1, [dstq+dsq*1+32*0] psubw m4, m1, [tmpq +32*2] vinserti128 m2, [dstq+dsq*1+32*1], 1 vinserti128 m5, [tmpq +32*3], 1 add tmpq, 32*4 psubw m5, m2, m5 pmulhrsw m3, m6 pmulhrsw m4, m6 pmulhrsw m5, m7 paddw m0, m3 paddw m1, m4 paddw m2, m5 mova [dstq+dsq*0+32*0], m0 mova [dstq+dsq*1+32*0], m1 mova [dstq+dsq*0+32*1], xm2 vextracti128 [dstq+dsq*1+32*1], m2, 1 lea dstq, [dstq+dsq*2] sub hd, 2 jg .w32_loop %if WIN64 movaps xmm6, [rsp+ 8] movaps xmm7, [rsp+24] %endif RET %macro BLEND_H_ROW 2-3 0; dst_off, tmp_off, inc_tmp mova m0, [dstq+32*(%1+0)] psubw m2, m0, [tmpq+32*(%2+0)] mova m1, [dstq+32*(%1+1)] psubw m3, m1, [tmpq+32*(%2+1)] %if %3 add tmpq, 32*%3 %endif pmulhrsw m2, m4 pmulhrsw m3, m4 paddw m0, m2 paddw m1, m3 mova [dstq+32*(%1+0)], m0 mova [dstq+32*(%1+1)], m1 %endmacro INIT_XMM avx2 cglobal blend_h_16bpc, 3, 6, 6, dst, ds, tmp, w, h, mask %define base r5-blend_h_avx2_table lea r5, [blend_h_avx2_table] tzcnt wd, wm mov hd, hm movsxd wq, [r5+wq*4] add wq, r5 lea maskq, [base+obmc_masks+hq*2] lea hd, [hq*3] shr hd, 2 ; h * 3/4 lea maskq, [maskq+hq*2] neg hq jmp wq .w2: movd m0, [dstq+dsq*0] pinsrd m0, [dstq+dsq*1], 1 movd m2, [maskq+hq*2] movq m1, [tmpq] add tmpq, 4*2 punpcklwd m2, m2 psubw m1, m0, m1 pmulhrsw m1, m2 paddw m0, m1 movd [dstq+dsq*0], m0 pextrd [dstq+dsq*1], m0, 1 lea dstq, [dstq+dsq*2] add hq, 2 jl .w2 RET .w4: mova m3, [blend_shuf] .w4_loop: movq m0, [dstq+dsq*0] movhps m0, [dstq+dsq*1] movd m2, [maskq+hq*2] psubw m1, m0, [tmpq] add tmpq, 8*2 pshufb m2, m3 pmulhrsw m1, m2 paddw m0, m1 movq [dstq+dsq*0], m0 movhps [dstq+dsq*1], m0 lea dstq, [dstq+dsq*2] add hq, 2 jl .w4_loop RET INIT_YMM avx2 .w8: vbroadcasti128 m3, [blend_shuf] shufpd m3, m3, 0x0c .w8_loop: mova xm0, [dstq+dsq*0] vinserti128 m0, [dstq+dsq*1], 1 vpbroadcastd m2, [maskq+hq*2] psubw m1, m0, [tmpq] add tmpq, 16*2 pshufb m2, m3 pmulhrsw m1, m2 paddw m0, m1 mova [dstq+dsq*0], xm0 vextracti128 [dstq+dsq*1], m0, 1 lea dstq, [dstq+dsq*2] add hq, 2 jl .w8_loop RET .w16: vpbroadcastw m4, [maskq+hq*2] vpbroadcastw m5, [maskq+hq*2+2] mova m0, [dstq+dsq*0] psubw m2, m0, [tmpq+ 32*0] mova m1, [dstq+dsq*1] psubw m3, m1, [tmpq+ 32*1] add tmpq, 32*2 pmulhrsw m2, m4 pmulhrsw m3, m5 paddw m0, m2 paddw m1, m3 mova [dstq+dsq*0], m0 mova [dstq+dsq*1], m1 lea dstq, [dstq+dsq*2] add hq, 2 jl .w16 RET .w32: vpbroadcastw m4, [maskq+hq*2] BLEND_H_ROW 0, 0, 2 add dstq, dsq inc hq jl .w32 RET .w64: vpbroadcastw m4, [maskq+hq*2] BLEND_H_ROW 0, 0 BLEND_H_ROW 2, 2, 4 add dstq, dsq inc hq jl .w64 RET .w128: vpbroadcastw m4, [maskq+hq*2] BLEND_H_ROW 0, 0 BLEND_H_ROW 2, 2, 8 BLEND_H_ROW 4, -4 BLEND_H_ROW 6, -2 add dstq, dsq inc hq jl .w128 RET %endif ; ARCH_X86_64
; A137584: a(n) = 3*a(n-1) - 2*a(n-2) + a(n-3), n > 3. ; 0,3,6,13,30,70,163,379,881,2048,4761,11068,25730,59815,139053,323259,751486,1746993,4061266,9441298,21948355,51023735,118615793,275748264,641036941,1490230088,3464364646,8053670703,18722512905,43524561955,101182330758,235220381269 mov $3,2 mov $5,$0 lpb $3 mov $0,$5 sub $3,1 add $0,$3 trn $0,1 seq $0,137531 ; a(n) = 3*a(n-1) - 2*a(n-2) + a(n-3). sub $0,1 mov $2,$3 mul $2,$0 add $1,$2 mov $4,$0 lpe min $5,1 mul $5,$4 sub $1,$5 mov $0,$1
; A326725: a(n) = (1/2)*n*(5*n - 7); row 5 of A326728. ; 0,-1,3,12,26,45,69,98,132,171,215,264,318,377,441,510,584,663,747,836,930,1029,1133,1242,1356,1475,1599,1728,1862,2001,2145,2294,2448,2607,2771,2940,3114,3293,3477,3666,3860,4059,4263,4472,4686,4905,5129,5358,5592,5831,6075,6324,6578,6837,7101,7370,7644,7923,8207,8496,8790,9089,9393,9702,10016,10335,10659,10988,11322,11661,12005,12354,12708,13067,13431,13800,14174,14553,14937,15326,15720,16119,16523,16932,17346,17765,18189,18618,19052,19491,19935,20384,20838,21297,21761,22230,22704,23183,23667,24156 mov $1,$0 mul $1,5 sub $1,7 mul $0,$1 div $0,2
; A027656: Expansion of 1/(1-x^2)^2 (included only for completeness - the policy is always to omit the zeros from such sequences). ; 1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,16,0,17,0,18,0,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,31,0,32,0,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0 add $0,2 mov $1,$0 dif $1,2 sub $0,$1
// Time: O(n) on average // Space: O(n) // reference: https://en.wikipedia.org/wiki/Smallest-circle_problem class Solution { public: vector<double> outerTrees(vector<vector<int>>& trees) { random_shuffle(begin(trees), end(trees)); vector<vector<double>> boundaries; const auto& result = Welzl(trees, &boundaries, 0); return {result.first[0], result.first[1], result.second}; } private: pair<vector<double>, double> Welzl( const vector<vector<int>>& points, vector<vector<double>> *boundaries, int curr) { if (curr == size(points) || size(*boundaries) == 3) { return trivial(*boundaries); } vector<double> p = {double(points[curr][0]), double(points[curr][1])}; const auto& result = Welzl(points, boundaries, curr + 1); if (!empty(result.first) && inside(result, p)) { return result; } boundaries->emplace_back(move(p)); const auto& result2 = Welzl(points, boundaries, curr + 1); boundaries->pop_back(); return result2; } pair<vector<double>, double> trivial(const vector<vector<double>>& boundaries) { // circumscribed circle if (empty(boundaries)) { return {{}, 0.0}; } if (size(boundaries) == 1) { return {boundaries[0], 0.0}; } if (size(boundaries) == 2) { return circle_from_2_points(boundaries[0], boundaries[1]); } return circle_from_3_points(boundaries[0], boundaries[1], boundaries[2]); } double dist(const vector<double>& a, const vector<double>& b) { return sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1])); } bool inside(const pair<vector<double>, double>& c, const vector<double>& p) { static const double EPS = 1e-5; return dist(c.first, p) < c.second + EPS; } vector<double> circle_center(int bx, int by, int cx, int cy) { double B = bx * bx + by * by; double C = cx * cx + cy * cy; double D = bx * cy - by * cx; return {(cy * B - by * C) / (2 * D), (bx * C - cx * B) / (2 * D)}; } pair<vector<double>, double> circle_from_2_points( const vector<double>& A, const vector<double>& B) { vector<double> C = {(A[0] + B[0]) / 2.0, (A[1] + B[1]) / 2.0}; return {C, dist(A, B) / 2.0}; } pair<vector<double>, double> circle_from_3_points( const vector<double>& A, const vector<double>& B, const vector<double>& C) { vector<double> I = circle_center(B[0] - A[0], B[1] - A[1], C[0] - A[0], C[1] - A[1]); I[0] += A[0]; I[1] += A[1]; return {I, dist(I, A)}; } };
.MODEL SMALL .STACK 100H .DATA PROMPT1 DB 10, 13, "Enter a string: $" PROMPT2 DB 10, 13, "Length: $" STR1 DB 10 DUP('$') .CODE MAIN PROC MOV AX, @DATA MOV DS, AX ;DATA SEGMENT INITIALIZATION MOV ES, AX ;EXTRA SEGMENT INITIALIZATION SO STRING INTRUCTIONS CAN USE ES:DI LEA DX, PROMPT1 MOV AH, 09H INT 21H ;DISPLAY PROMPT1 CLD ;CLEAR DIRECTION FLAG SO ES:DI CAN MOVE FORWARDS LEA DI, STR1 ;ES:DI => DI IS POINTING TO STARTING ADDRESS OF STR1 MOV CX, 9 ;MAX INPUT SIZE INPUT: MOV AH, 01H INT 21H ;SINGLE CHARACTER INPUT CMP AL, 13D JE END_INPUT ;JUMP IF RETURN IS ENTERED STOSB ;MOV CONTENT OF AL TO ES:DI => WHERE DI IS POINTING AND INCREMENTING DI LOOP INPUT ;CHECK WHETHER CX IS ZERO TO STOP INPUT END_INPUT: LEA DX, PROMPT2 MOV AH, 09H INT 21H ;DISPLAY PROMPT2 LEA DI, STR1 ;ES:DI IS POINTING TO STARTING ADDRESS OF STR1 MOV AL, '$' ;MOVING $ TO AL SO SCANSB CAN COMPARE CONTENT OF ES:DI TO AL MOV CX, 10 ;COUNTER TO REPEAT SCASB REPNE SCASB ;REPEATING COMPARING CONTENT POINTED BY ES:DI TO AL UNTIL $ IS FOUND AUR CX IS ZERO MOV BX, CX ;MOVING (9 - NUMBER OF CHARACTERS IN STR1) MOV CX, 9 SUB CX, BX ; 9 - (NUMBER OF EMPTY PLACES IN STR1) MOV DL, CL ;MOVING LENGTH OF STR1 TO DL SO IT CAN BE DISPLAYED ADD DL, 30H ;CONVERTING IT TO A CHARACTER MOV AH, 02H INT 21H ;DISPLAY LENGTH OF STR1 ;EXIT DOS MOV AH, 4CH INT 21H MAIN ENDP END MAIN
#include "stdafx.h" using namespace std; const int N = 45; void fill(int* a,int n) { for(int i=0;i<n;i++) { a[i] = rand()%10000; } } void sort(int* a, int n) { int i,j,k; int t; for(k = n/2; k > 0; k /=2) for(i = k; i < n; i++) { t = a[i]; for(j = i; j>=k; j-=k) { if(t < a[j-k]) a[j] = a[j-k]; else break; } a[j] = t; } } void print(int* a,int n,int p) { for(int i=0;i<n;i++) { cout << p << ":" << a[i] << " "; } cout << endl; } int main(int argc, char *argv[]) { if(argc != 2) { return 1; } int pn = atoi(argv[1]); int* a = new int[N+5]; fill(a,N); sort(a,N); print(a,N,pn); return 0; }
// // Created by JJJai on 12/19/2021. // #include <main.h> #include "material.h" scratch::Material::Material(unsigned int id, std::vector<std::shared_ptr<Texture>> textures) : _id(id), _index(-1), _textures(std::move( textures)) { } scratch::Material::Material(std::vector<std::shared_ptr<Texture>> textures) : _id(0), _index(-1), _textures(std::move(textures)) { } scratch::Material::Material() : _id(0), _index(-1), _textures(std::vector<std::shared_ptr<Texture>>()) {} void scratch::Material::activate() { _shader->use(); setupTextures(); setupStateParameters(); } void scratch::Material::setShader(std::shared_ptr<scratch::Shader> shader) { _shader = shader; } std::shared_ptr<scratch::Shader> scratch::Material::getShader() { return _shader; } unsigned int scratch::Material::getId() const { return _id; } void scratch::Material::setId(unsigned int id) { _id = id; } const std::map<std::string, scratch::Parameter> &scratch::Material::getParameters() const { return _parameters; } void scratch::Material::setParameters(const std::map<std::string, scratch::Parameter> &parameters) { _parameters = parameters; } void scratch::Material::setBool(const std::string &name, bool value) { scratch::Parameter param; param.type = scratch::ParameterType::BOOL; param.value = value; _parameters[name] = param; } void scratch::Material::setInt(const std::string &name, int value) { scratch::Parameter param; param.type = scratch::ParameterType::INT; param.value = value; _parameters[name] = param; } void scratch::Material::setFloat(const std::string &name, float value) { scratch::Parameter param; param.type = scratch::ParameterType::FLOAT; param.value = value; _parameters[name] = param; } void scratch::Material::setMat4(const std::string &name, glm::mat4 value) { scratch::Parameter param; param.type = scratch::ParameterType::MATRIX4; param.value = value; _parameters[name] = param; } void scratch::Material::setVec3(const std::string &name, glm::vec3 value) { scratch::Parameter param; param.type = scratch::ParameterType::VECTOR3; param.value = value; _parameters[name] = param; } void scratch::Material::removeParameter(const std::string &name) { _parameters.erase(name); } void scratch::Material::renameParameter(const std::string &oldName, const std::string &newName) { auto nodeHandler = _parameters.extract(oldName); nodeHandler.key() = newName; _parameters.insert(std::move(nodeHandler)); } void scratch::Material::setupTextures() { // bind appropriate textures unsigned int diffuseNr = 1; unsigned int specularNr = 1; unsigned int normalNr = 1; unsigned int heightNr = 1; for (auto i = 0; i < _textures.size(); i++) { glActiveTexture(GL_TEXTURE0 + i); // active proper texture unit before binding // retrieve texture number (the N in diffuse_textureN) std::shared_ptr<scratch::Texture> texture = _textures[i]; std::string number; std::string name = _textures[i]->type; if (name == "texture_diffuse") number = std::to_string(diffuseNr++); else if (name == "texture_specular") number = std::to_string(specularNr++); // transfer unsigned int to stream else if (name == "texture_normal") number = std::to_string(normalNr++); // transfer unsigned int to stream else if (name == "texture_height") number = std::to_string(heightNr++); // transfer unsigned int to stream std::string uniformName = "material."; uniformName.append(name).append(number); // now set the sampler to the correct texture unit glUniform1i(glGetUniformLocation(_shader->getShaderId(), uniformName.c_str()), i); // and finally bind the texture glBindTexture(GL_TEXTURE_2D, _textures[i]->id); } } void scratch::Material::setupStateParameters() { for (auto const &[key, val] : _parameters) { switch (val.type) { case BOOL: _shader->setBool(key, std::get<bool>(val.value)); break; case INT: _shader->setInt(key, std::get<int>(val.value)); break; case FLOAT: _shader->setFloat(key, std::get<float>(val.value)); break; case VECTOR3: _shader->setVec3(key, std::get<glm::vec3>(val.value)); break; case MATRIX4: _shader->setMat4(key, std::get<glm::mat4>(val.value)); break; default: SCRATCH_ASSERT_NEVER("Unknown Param Type"); break; } } } void scratch::Material::clearParameters() { for (auto const &[key, val] : _parameters) { switch (val.type) { case BOOL: _shader->setBool(key, false); break; case INT: _shader->setInt(key, 0); break; case FLOAT: _shader->setFloat(key, 0); break; case VECTOR3: _shader->setVec3(key, glm::vec3(0)); break; case MATRIX4: _shader->setMat4(key, glm::mat4(1)); break; default: SCRATCH_ASSERT_NEVER("Unknown Param Type"); break; } } } void scratch::Material::serialize(rapidjson::PrettyWriter<rapidjson::StringBuffer> &writer) { writer.StartObject(); writer.String("id"); writer.Uint(_id); writer.String("shaderName"); writer.String(_shader->getName().c_str(), static_cast<rapidjson::SizeType>(_shader->getName().length())); writer.String("textures"); writer.StartArray(); for (auto texture: _textures) { writer.StartObject(); writer.String("path"); writer.String(texture->path.c_str(), static_cast<rapidjson::SizeType>(texture->path.length())); writer.String("type"); writer.String(texture->type.c_str(), static_cast<rapidjson::SizeType>(texture->type.length())); writer.EndObject(); } writer.EndArray(); writer.String("parameters"); writer.StartArray(); for (auto &param : _parameters) { writer.StartObject(); writer.String("key"); writer.String(param.first.c_str(), static_cast<rapidjson::SizeType>(param.first.length())); writer.String("type"); std::string type = PARAM_TYPE_TO_STRING.find(param.second.type)->second; writer.String(type.c_str(), static_cast<rapidjson::SizeType>(type.length())); writer.String("value"); std::string serializedValue = ""; switch (param.second.type) { case BOOL: serializedValue = scratch::StringConverter::toString(std::get<bool>(param.second.value)); break; case INT: serializedValue = scratch::StringConverter::toString(std::get<int>(param.second.value)); break; case FLOAT: serializedValue = scratch::StringConverter::toString(std::get<float>(param.second.value)); break; case VECTOR3: serializedValue = scratch::StringConverter::toString(std::get<glm::vec3>(param.second.value)); break; case MATRIX4: serializedValue = scratch::StringConverter::toString(std::get<glm::mat4>(param.second.value)); break; default: SCRATCH_ASSERT_NEVER("Unknown Param Type"); break; } writer.String(serializedValue.c_str(), static_cast<rapidjson::SizeType>(serializedValue.length())); writer.EndObject(); } writer.EndArray(); writer.EndObject(); } void scratch::Material::deserialize(const rapidjson::Value &object) { _id = object["id"].GetUint(); std::string shaderName = object["shaderName"].GetString(); _shader = ScratchManagers->shaderLibrary->findShader(shaderName); auto texturesArray = object["textures"].GetArray(); for (rapidjson::Value::ConstValueIterator itr = texturesArray.Begin(); itr != texturesArray.End(); ++itr) { std::string textureType = (*itr)["type"].GetString(); std::string texturePath = (*itr)["path"].GetString(); this->addTexture(texturePath, textureType); } auto parametersArray = object["parameters"].GetArray(); for (auto itr = parametersArray.Begin(); itr != parametersArray.End(); ++itr) { std::string key = (*itr)["key"].GetString(); std::string typeString = (*itr)["type"].GetString(); scratch::Parameter param; param.type = STRING_TO_PARAM_TYPE.find(typeString)->second; std::string rawValue = (*itr)["value"].GetString(); switch (param.type) { case BOOL: param.value = scratch::StringConverter::parsebool(rawValue); break; case INT: param.value = scratch::StringConverter::parseint(rawValue); break; case FLOAT: param.value = scratch::StringConverter::parsefloat(rawValue); break; case VECTOR3: param.value = scratch::StringConverter::parsevec3(rawValue); break; case MATRIX4: param.value = scratch::StringConverter::parsemat4(rawValue); break; default: SCRATCH_ASSERT_NEVER("Unknown Param Type"); break; } _parameters[key] = param; } } void scratch::Material::addTexture(const std::string &path, const std::string &typeName) { _textures.push_back(ScratchManagers->resourceManager->loadTexture(path, typeName)); } const std::string &scratch::Material::getPath() const { return _path; } void scratch::Material::setPath(const std::string &path) { _path = path; } int scratch::Material::getIndex() const { return _index; } void scratch::Material::setIndex(int index) { _index = index; } const std::string &scratch::Material::getName() const { return _name; } void scratch::Material::setName(const std::string &name) { _name = name; }
ctarget: file format elf64-x86-64 Disassembly of section .init: 0000000000400c48 <_init>: 400c48: 48 83 ec 08 sub $0x8,%rsp 400c4c: e8 6b 02 00 00 callq 400ebc <call_gmon_start> 400c51: 48 83 c4 08 add $0x8,%rsp 400c55: c3 retq Disassembly of section .plt: 0000000000400c60 <strcasecmp@plt-0x10>: 400c60: ff 35 8a 33 20 00 pushq 0x20338a(%rip) # 603ff0 <_GLOBAL_OFFSET_TABLE_+0x8> 400c66: ff 25 8c 33 20 00 jmpq *0x20338c(%rip) # 603ff8 <_GLOBAL_OFFSET_TABLE_+0x10> 400c6c: 0f 1f 40 00 nopl 0x0(%rax) 0000000000400c70 <strcasecmp@plt>: 400c70: ff 25 8a 33 20 00 jmpq *0x20338a(%rip) # 604000 <_GLOBAL_OFFSET_TABLE_+0x18> 400c76: 68 00 00 00 00 pushq $0x0 400c7b: e9 e0 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400c80 <__errno_location@plt>: 400c80: ff 25 82 33 20 00 jmpq *0x203382(%rip) # 604008 <_GLOBAL_OFFSET_TABLE_+0x20> 400c86: 68 01 00 00 00 pushq $0x1 400c8b: e9 d0 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400c90 <srandom@plt>: 400c90: ff 25 7a 33 20 00 jmpq *0x20337a(%rip) # 604010 <_GLOBAL_OFFSET_TABLE_+0x28> 400c96: 68 02 00 00 00 pushq $0x2 400c9b: e9 c0 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400ca0 <strncmp@plt>: 400ca0: ff 25 72 33 20 00 jmpq *0x203372(%rip) # 604018 <_GLOBAL_OFFSET_TABLE_+0x30> 400ca6: 68 03 00 00 00 pushq $0x3 400cab: e9 b0 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400cb0 <strcpy@plt>: 400cb0: ff 25 6a 33 20 00 jmpq *0x20336a(%rip) # 604020 <_GLOBAL_OFFSET_TABLE_+0x38> 400cb6: 68 04 00 00 00 pushq $0x4 400cbb: e9 a0 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400cc0 <puts@plt>: 400cc0: ff 25 62 33 20 00 jmpq *0x203362(%rip) # 604028 <_GLOBAL_OFFSET_TABLE_+0x40> 400cc6: 68 05 00 00 00 pushq $0x5 400ccb: e9 90 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400cd0 <write@plt>: 400cd0: ff 25 5a 33 20 00 jmpq *0x20335a(%rip) # 604030 <_GLOBAL_OFFSET_TABLE_+0x48> 400cd6: 68 06 00 00 00 pushq $0x6 400cdb: e9 80 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400ce0 <__stack_chk_fail@plt>: 400ce0: ff 25 52 33 20 00 jmpq *0x203352(%rip) # 604038 <_GLOBAL_OFFSET_TABLE_+0x50> 400ce6: 68 07 00 00 00 pushq $0x7 400ceb: e9 70 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400cf0 <mmap@plt>: 400cf0: ff 25 4a 33 20 00 jmpq *0x20334a(%rip) # 604040 <_GLOBAL_OFFSET_TABLE_+0x58> 400cf6: 68 08 00 00 00 pushq $0x8 400cfb: e9 60 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400d00 <memset@plt>: 400d00: ff 25 42 33 20 00 jmpq *0x203342(%rip) # 604048 <_GLOBAL_OFFSET_TABLE_+0x60> 400d06: 68 09 00 00 00 pushq $0x9 400d0b: e9 50 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400d10 <alarm@plt>: 400d10: ff 25 3a 33 20 00 jmpq *0x20333a(%rip) # 604050 <_GLOBAL_OFFSET_TABLE_+0x68> 400d16: 68 0a 00 00 00 pushq $0xa 400d1b: e9 40 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400d20 <close@plt>: 400d20: ff 25 32 33 20 00 jmpq *0x203332(%rip) # 604058 <_GLOBAL_OFFSET_TABLE_+0x70> 400d26: 68 0b 00 00 00 pushq $0xb 400d2b: e9 30 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400d30 <read@plt>: 400d30: ff 25 2a 33 20 00 jmpq *0x20332a(%rip) # 604060 <_GLOBAL_OFFSET_TABLE_+0x78> 400d36: 68 0c 00 00 00 pushq $0xc 400d3b: e9 20 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400d40 <__libc_start_main@plt>: 400d40: ff 25 22 33 20 00 jmpq *0x203322(%rip) # 604068 <_GLOBAL_OFFSET_TABLE_+0x80> 400d46: 68 0d 00 00 00 pushq $0xd 400d4b: e9 10 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400d50 <signal@plt>: 400d50: ff 25 1a 33 20 00 jmpq *0x20331a(%rip) # 604070 <_GLOBAL_OFFSET_TABLE_+0x88> 400d56: 68 0e 00 00 00 pushq $0xe 400d5b: e9 00 ff ff ff jmpq 400c60 <_init+0x18> 0000000000400d60 <gethostbyname@plt>: 400d60: ff 25 12 33 20 00 jmpq *0x203312(%rip) # 604078 <_GLOBAL_OFFSET_TABLE_+0x90> 400d66: 68 0f 00 00 00 pushq $0xf 400d6b: e9 f0 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400d70 <__memmove_chk@plt>: 400d70: ff 25 0a 33 20 00 jmpq *0x20330a(%rip) # 604080 <_GLOBAL_OFFSET_TABLE_+0x98> 400d76: 68 10 00 00 00 pushq $0x10 400d7b: e9 e0 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400d80 <strtol@plt>: 400d80: ff 25 02 33 20 00 jmpq *0x203302(%rip) # 604088 <_GLOBAL_OFFSET_TABLE_+0xa0> 400d86: 68 11 00 00 00 pushq $0x11 400d8b: e9 d0 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400d90 <memcpy@plt>: 400d90: ff 25 fa 32 20 00 jmpq *0x2032fa(%rip) # 604090 <_GLOBAL_OFFSET_TABLE_+0xa8> 400d96: 68 12 00 00 00 pushq $0x12 400d9b: e9 c0 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400da0 <time@plt>: 400da0: ff 25 f2 32 20 00 jmpq *0x2032f2(%rip) # 604098 <_GLOBAL_OFFSET_TABLE_+0xb0> 400da6: 68 13 00 00 00 pushq $0x13 400dab: e9 b0 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400db0 <random@plt>: 400db0: ff 25 ea 32 20 00 jmpq *0x2032ea(%rip) # 6040a0 <_GLOBAL_OFFSET_TABLE_+0xb8> 400db6: 68 14 00 00 00 pushq $0x14 400dbb: e9 a0 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400dc0 <_IO_getc@plt>: 400dc0: ff 25 e2 32 20 00 jmpq *0x2032e2(%rip) # 6040a8 <_GLOBAL_OFFSET_TABLE_+0xc0> 400dc6: 68 15 00 00 00 pushq $0x15 400dcb: e9 90 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400dd0 <__isoc99_sscanf@plt>: 400dd0: ff 25 da 32 20 00 jmpq *0x2032da(%rip) # 6040b0 <_GLOBAL_OFFSET_TABLE_+0xc8> 400dd6: 68 16 00 00 00 pushq $0x16 400ddb: e9 80 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400de0 <munmap@plt>: 400de0: ff 25 d2 32 20 00 jmpq *0x2032d2(%rip) # 6040b8 <_GLOBAL_OFFSET_TABLE_+0xd0> 400de6: 68 17 00 00 00 pushq $0x17 400deb: e9 70 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400df0 <__printf_chk@plt>: 400df0: ff 25 ca 32 20 00 jmpq *0x2032ca(%rip) # 6040c0 <_GLOBAL_OFFSET_TABLE_+0xd8> 400df6: 68 18 00 00 00 pushq $0x18 400dfb: e9 60 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400e00 <fopen@plt>: 400e00: ff 25 c2 32 20 00 jmpq *0x2032c2(%rip) # 6040c8 <_GLOBAL_OFFSET_TABLE_+0xe0> 400e06: 68 19 00 00 00 pushq $0x19 400e0b: e9 50 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400e10 <getopt@plt>: 400e10: ff 25 ba 32 20 00 jmpq *0x2032ba(%rip) # 6040d0 <_GLOBAL_OFFSET_TABLE_+0xe8> 400e16: 68 1a 00 00 00 pushq $0x1a 400e1b: e9 40 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400e20 <strtoul@plt>: 400e20: ff 25 b2 32 20 00 jmpq *0x2032b2(%rip) # 6040d8 <_GLOBAL_OFFSET_TABLE_+0xf0> 400e26: 68 1b 00 00 00 pushq $0x1b 400e2b: e9 30 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400e30 <gethostname@plt>: 400e30: ff 25 aa 32 20 00 jmpq *0x2032aa(%rip) # 6040e0 <_GLOBAL_OFFSET_TABLE_+0xf8> 400e36: 68 1c 00 00 00 pushq $0x1c 400e3b: e9 20 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400e40 <exit@plt>: 400e40: ff 25 a2 32 20 00 jmpq *0x2032a2(%rip) # 6040e8 <_GLOBAL_OFFSET_TABLE_+0x100> 400e46: 68 1d 00 00 00 pushq $0x1d 400e4b: e9 10 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400e50 <connect@plt>: 400e50: ff 25 9a 32 20 00 jmpq *0x20329a(%rip) # 6040f0 <_GLOBAL_OFFSET_TABLE_+0x108> 400e56: 68 1e 00 00 00 pushq $0x1e 400e5b: e9 00 fe ff ff jmpq 400c60 <_init+0x18> 0000000000400e60 <__fprintf_chk@plt>: 400e60: ff 25 92 32 20 00 jmpq *0x203292(%rip) # 6040f8 <_GLOBAL_OFFSET_TABLE_+0x110> 400e66: 68 1f 00 00 00 pushq $0x1f 400e6b: e9 f0 fd ff ff jmpq 400c60 <_init+0x18> 0000000000400e70 <__sprintf_chk@plt>: 400e70: ff 25 8a 32 20 00 jmpq *0x20328a(%rip) # 604100 <_GLOBAL_OFFSET_TABLE_+0x118> 400e76: 68 20 00 00 00 pushq $0x20 400e7b: e9 e0 fd ff ff jmpq 400c60 <_init+0x18> 0000000000400e80 <socket@plt>: 400e80: ff 25 82 32 20 00 jmpq *0x203282(%rip) # 604108 <_GLOBAL_OFFSET_TABLE_+0x120> 400e86: 68 21 00 00 00 pushq $0x21 400e8b: e9 d0 fd ff ff jmpq 400c60 <_init+0x18> Disassembly of section .text: 0000000000400e90 <_start>: 400e90: 31 ed xor %ebp,%ebp 400e92: 49 89 d1 mov %rdx,%r9 400e95: 5e pop %rsi 400e96: 48 89 e2 mov %rsp,%rdx 400e99: 48 83 e4 f0 and $0xfffffffffffffff0,%rsp 400e9d: 50 push %rax 400e9e: 54 push %rsp 400e9f: 49 c7 c0 70 2d 40 00 mov $0x402d70,%r8 400ea6: 48 c7 c1 e0 2c 40 00 mov $0x402ce0,%rcx 400ead: 48 c7 c7 ad 11 40 00 mov $0x4011ad,%rdi 400eb4: e8 87 fe ff ff callq 400d40 <__libc_start_main@plt> 400eb9: f4 hlt 400eba: 90 nop 400ebb: 90 nop 0000000000400ebc <call_gmon_start>: 400ebc: 48 83 ec 08 sub $0x8,%rsp 400ec0: 48 8b 05 19 31 20 00 mov 0x203119(%rip),%rax # 603fe0 <_DYNAMIC+0x1d0> 400ec7: 48 85 c0 test %rax,%rax 400eca: 74 02 je 400ece <call_gmon_start+0x12> 400ecc: ff d0 callq *%rax 400ece: 48 83 c4 08 add $0x8,%rsp 400ed2: c3 retq 400ed3: 90 nop 400ed4: 90 nop 400ed5: 90 nop 400ed6: 90 nop 400ed7: 90 nop 400ed8: 90 nop 400ed9: 90 nop 400eda: 90 nop 400edb: 90 nop 400edc: 90 nop 400edd: 90 nop 400ede: 90 nop 400edf: 90 nop 0000000000400ee0 <deregister_tm_clones>: 400ee0: b8 97 44 60 00 mov $0x604497,%eax 400ee5: 55 push %rbp 400ee6: 48 2d 90 44 60 00 sub $0x604490,%rax 400eec: 48 83 f8 0e cmp $0xe,%rax 400ef0: 48 89 e5 mov %rsp,%rbp 400ef3: 77 02 ja 400ef7 <deregister_tm_clones+0x17> 400ef5: 5d pop %rbp 400ef6: c3 retq 400ef7: b8 00 00 00 00 mov $0x0,%eax 400efc: 48 85 c0 test %rax,%rax 400eff: 74 f4 je 400ef5 <deregister_tm_clones+0x15> 400f01: 5d pop %rbp 400f02: bf 90 44 60 00 mov $0x604490,%edi 400f07: ff e0 jmpq *%rax 400f09: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 0000000000400f10 <register_tm_clones>: 400f10: b8 90 44 60 00 mov $0x604490,%eax 400f15: 55 push %rbp 400f16: 48 2d 90 44 60 00 sub $0x604490,%rax 400f1c: 48 c1 f8 03 sar $0x3,%rax 400f20: 48 89 e5 mov %rsp,%rbp 400f23: 48 89 c2 mov %rax,%rdx 400f26: 48 c1 ea 3f shr $0x3f,%rdx 400f2a: 48 01 d0 add %rdx,%rax 400f2d: 48 d1 f8 sar %rax 400f30: 75 02 jne 400f34 <register_tm_clones+0x24> 400f32: 5d pop %rbp 400f33: c3 retq 400f34: ba 00 00 00 00 mov $0x0,%edx 400f39: 48 85 d2 test %rdx,%rdx 400f3c: 74 f4 je 400f32 <register_tm_clones+0x22> 400f3e: 5d pop %rbp 400f3f: 48 89 c6 mov %rax,%rsi 400f42: bf 90 44 60 00 mov $0x604490,%edi 400f47: ff e2 jmpq *%rdx 400f49: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 0000000000400f50 <__do_global_dtors_aux>: 400f50: 80 3d 61 35 20 00 00 cmpb $0x0,0x203561(%rip) # 6044b8 <completed.6976> 400f57: 75 11 jne 400f6a <__do_global_dtors_aux+0x1a> 400f59: 55 push %rbp 400f5a: 48 89 e5 mov %rsp,%rbp 400f5d: e8 7e ff ff ff callq 400ee0 <deregister_tm_clones> 400f62: 5d pop %rbp 400f63: c6 05 4e 35 20 00 01 movb $0x1,0x20354e(%rip) # 6044b8 <completed.6976> 400f6a: f3 c3 repz retq 400f6c: 0f 1f 40 00 nopl 0x0(%rax) 0000000000400f70 <frame_dummy>: 400f70: 48 83 3d 90 2e 20 00 cmpq $0x0,0x202e90(%rip) # 603e08 <__JCR_END__> 400f77: 00 400f78: 74 1e je 400f98 <frame_dummy+0x28> 400f7a: b8 00 00 00 00 mov $0x0,%eax 400f7f: 48 85 c0 test %rax,%rax 400f82: 74 14 je 400f98 <frame_dummy+0x28> 400f84: 55 push %rbp 400f85: bf 08 3e 60 00 mov $0x603e08,%edi 400f8a: 48 89 e5 mov %rsp,%rbp 400f8d: ff d0 callq *%rax 400f8f: 5d pop %rbp 400f90: e9 7b ff ff ff jmpq 400f10 <register_tm_clones> 400f95: 0f 1f 00 nopl (%rax) 400f98: e9 73 ff ff ff jmpq 400f10 <register_tm_clones> 400f9d: 90 nop 400f9e: 90 nop 400f9f: 90 nop 0000000000400fa0 <usage>: 400fa0: 48 83 ec 08 sub $0x8,%rsp 400fa4: 48 89 fa mov %rdi,%rdx 400fa7: 83 3d 3a 35 20 00 00 cmpl $0x0,0x20353a(%rip) # 6044e8 <is_checker> 400fae: 74 3e je 400fee <usage+0x4e> 400fb0: be 88 2d 40 00 mov $0x402d88,%esi 400fb5: bf 01 00 00 00 mov $0x1,%edi 400fba: b8 00 00 00 00 mov $0x0,%eax 400fbf: e8 2c fe ff ff callq 400df0 <__printf_chk@plt> 400fc4: bf c0 2d 40 00 mov $0x402dc0,%edi 400fc9: e8 f2 fc ff ff callq 400cc0 <puts@plt> 400fce: bf 38 2f 40 00 mov $0x402f38,%edi 400fd3: e8 e8 fc ff ff callq 400cc0 <puts@plt> 400fd8: bf e8 2d 40 00 mov $0x402de8,%edi 400fdd: e8 de fc ff ff callq 400cc0 <puts@plt> 400fe2: bf 52 2f 40 00 mov $0x402f52,%edi 400fe7: e8 d4 fc ff ff callq 400cc0 <puts@plt> 400fec: eb 32 jmp 401020 <usage+0x80> 400fee: be 6e 2f 40 00 mov $0x402f6e,%esi 400ff3: bf 01 00 00 00 mov $0x1,%edi 400ff8: b8 00 00 00 00 mov $0x0,%eax 400ffd: e8 ee fd ff ff callq 400df0 <__printf_chk@plt> 401002: bf 10 2e 40 00 mov $0x402e10,%edi 401007: e8 b4 fc ff ff callq 400cc0 <puts@plt> 40100c: bf 38 2e 40 00 mov $0x402e38,%edi 401011: e8 aa fc ff ff callq 400cc0 <puts@plt> 401016: bf 8c 2f 40 00 mov $0x402f8c,%edi 40101b: e8 a0 fc ff ff callq 400cc0 <puts@plt> 401020: bf 00 00 00 00 mov $0x0,%edi 401025: e8 16 fe ff ff callq 400e40 <exit@plt> 000000000040102a <initialize_target>: 40102a: 55 push %rbp 40102b: 53 push %rbx 40102c: 48 81 ec 18 21 00 00 sub $0x2118,%rsp 401033: 89 f5 mov %esi,%ebp 401035: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 40103c: 00 00 40103e: 48 89 84 24 08 21 00 mov %rax,0x2108(%rsp) 401045: 00 401046: 31 c0 xor %eax,%eax 401048: 89 3d 8a 34 20 00 mov %edi,0x20348a(%rip) # 6044d8 <check_level> 40104e: 8b 3d f4 30 20 00 mov 0x2030f4(%rip),%edi # 604148 <target_id> 401054: e8 65 1c 00 00 callq 402cbe <gencookie> 401059: 89 05 85 34 20 00 mov %eax,0x203485(%rip) # 6044e4 <cookie> 40105f: 89 c7 mov %eax,%edi 401061: e8 58 1c 00 00 callq 402cbe <gencookie> 401066: 89 05 74 34 20 00 mov %eax,0x203474(%rip) # 6044e0 <authkey> 40106c: 8b 05 d6 30 20 00 mov 0x2030d6(%rip),%eax # 604148 <target_id> 401072: 8d 78 01 lea 0x1(%rax),%edi 401075: e8 16 fc ff ff callq 400c90 <srandom@plt> 40107a: e8 31 fd ff ff callq 400db0 <random@plt> 40107f: 89 c7 mov %eax,%edi 401081: e8 02 03 00 00 callq 401388 <scramble> 401086: 89 c3 mov %eax,%ebx 401088: ba 00 00 00 00 mov $0x0,%edx 40108d: 85 ed test %ebp,%ebp 40108f: 74 18 je 4010a9 <initialize_target+0x7f> 401091: bf 00 00 00 00 mov $0x0,%edi 401096: e8 05 fd ff ff callq 400da0 <time@plt> 40109b: 89 c7 mov %eax,%edi 40109d: e8 ee fb ff ff callq 400c90 <srandom@plt> 4010a2: e8 09 fd ff ff callq 400db0 <random@plt> 4010a7: 89 c2 mov %eax,%edx 4010a9: 01 da add %ebx,%edx 4010ab: 0f b7 d2 movzwl %dx,%edx 4010ae: 8d 04 d5 00 01 00 00 lea 0x100(,%rdx,8),%eax 4010b5: 89 c0 mov %eax,%eax 4010b7: 48 89 05 c2 33 20 00 mov %rax,0x2033c2(%rip) # 604480 <buf_offset> 4010be: c6 05 43 40 20 00 63 movb $0x63,0x204043(%rip) # 605108 <target_prefix> 4010c5: 83 3d bc 33 20 00 00 cmpl $0x0,0x2033bc(%rip) # 604488 <notify> 4010cc: 0f 84 b9 00 00 00 je 40118b <initialize_target+0x161> 4010d2: 83 3d 0f 34 20 00 00 cmpl $0x0,0x20340f(%rip) # 6044e8 <is_checker> 4010d9: 0f 85 ac 00 00 00 jne 40118b <initialize_target+0x161> 4010df: be 00 01 00 00 mov $0x100,%esi 4010e4: 48 89 e7 mov %rsp,%rdi 4010e7: e8 44 fd ff ff callq 400e30 <gethostname@plt> 4010ec: bb 00 00 00 00 mov $0x0,%ebx 4010f1: 85 c0 test %eax,%eax 4010f3: 74 23 je 401118 <initialize_target+0xee> 4010f5: bf 68 2e 40 00 mov $0x402e68,%edi 4010fa: e8 c1 fb ff ff callq 400cc0 <puts@plt> 4010ff: bf 08 00 00 00 mov $0x8,%edi 401104: e8 37 fd ff ff callq 400e40 <exit@plt> 401109: 48 89 e6 mov %rsp,%rsi 40110c: e8 5f fb ff ff callq 400c70 <strcasecmp@plt> 401111: 85 c0 test %eax,%eax 401113: 74 1a je 40112f <initialize_target+0x105> 401115: 83 c3 01 add $0x1,%ebx 401118: 48 63 c3 movslq %ebx,%rax 40111b: 48 8b 3c c5 60 41 60 mov 0x604160(,%rax,8),%rdi 401122: 00 401123: 48 85 ff test %rdi,%rdi 401126: 75 e1 jne 401109 <initialize_target+0xdf> 401128: b8 00 00 00 00 mov $0x0,%eax 40112d: eb 05 jmp 401134 <initialize_target+0x10a> 40112f: b8 01 00 00 00 mov $0x1,%eax 401134: 85 c0 test %eax,%eax 401136: 75 1c jne 401154 <initialize_target+0x12a> 401138: 48 89 e2 mov %rsp,%rdx 40113b: be a0 2e 40 00 mov $0x402ea0,%esi 401140: bf 01 00 00 00 mov $0x1,%edi 401145: e8 a6 fc ff ff callq 400df0 <__printf_chk@plt> 40114a: bf 08 00 00 00 mov $0x8,%edi 40114f: e8 ec fc ff ff callq 400e40 <exit@plt> 401154: 48 8d bc 24 00 01 00 lea 0x100(%rsp),%rdi 40115b: 00 40115c: e8 c3 18 00 00 callq 402a24 <init_driver> 401161: 85 c0 test %eax,%eax 401163: 79 26 jns 40118b <initialize_target+0x161> 401165: 48 8d 94 24 00 01 00 lea 0x100(%rsp),%rdx 40116c: 00 40116d: be e0 2e 40 00 mov $0x402ee0,%esi 401172: bf 01 00 00 00 mov $0x1,%edi 401177: b8 00 00 00 00 mov $0x0,%eax 40117c: e8 6f fc ff ff callq 400df0 <__printf_chk@plt> 401181: bf 08 00 00 00 mov $0x8,%edi 401186: e8 b5 fc ff ff callq 400e40 <exit@plt> 40118b: 48 8b 84 24 08 21 00 mov 0x2108(%rsp),%rax 401192: 00 401193: 64 48 33 04 25 28 00 xor %fs:0x28,%rax 40119a: 00 00 40119c: 74 05 je 4011a3 <initialize_target+0x179> 40119e: e8 3d fb ff ff callq 400ce0 <__stack_chk_fail@plt> 4011a3: 48 81 c4 18 21 00 00 add $0x2118,%rsp 4011aa: 5b pop %rbx 4011ab: 5d pop %rbp 4011ac: c3 retq 00000000004011ad <main>: 4011ad: 41 56 push %r14 4011af: 41 55 push %r13 4011b1: 41 54 push %r12 4011b3: 55 push %rbp 4011b4: 53 push %rbx 4011b5: 41 89 fc mov %edi,%r12d 4011b8: 48 89 f3 mov %rsi,%rbx 4011bb: be c5 1d 40 00 mov $0x401dc5,%esi 4011c0: bf 0b 00 00 00 mov $0xb,%edi 4011c5: e8 86 fb ff ff callq 400d50 <signal@plt> 4011ca: be 77 1d 40 00 mov $0x401d77,%esi 4011cf: bf 07 00 00 00 mov $0x7,%edi 4011d4: e8 77 fb ff ff callq 400d50 <signal@plt> 4011d9: be 13 1e 40 00 mov $0x401e13,%esi 4011de: bf 04 00 00 00 mov $0x4,%edi 4011e3: e8 68 fb ff ff callq 400d50 <signal@plt> 4011e8: bd a5 2f 40 00 mov $0x402fa5,%ebp 4011ed: 83 3d f4 32 20 00 00 cmpl $0x0,0x2032f4(%rip) # 6044e8 <is_checker> 4011f4: 74 1e je 401214 <main+0x67> 4011f6: be 61 1e 40 00 mov $0x401e61,%esi 4011fb: bf 0e 00 00 00 mov $0xe,%edi 401200: e8 4b fb ff ff callq 400d50 <signal@plt> 401205: bf 05 00 00 00 mov $0x5,%edi 40120a: e8 01 fb ff ff callq 400d10 <alarm@plt> 40120f: bd aa 2f 40 00 mov $0x402faa,%ebp 401214: 48 8b 05 85 32 20 00 mov 0x203285(%rip),%rax # 6044a0 <stdin@@GLIBC_2.2.5> 40121b: 48 89 05 ae 32 20 00 mov %rax,0x2032ae(%rip) # 6044d0 <infile> 401222: 41 bd 00 00 00 00 mov $0x0,%r13d 401228: 41 be 00 00 00 00 mov $0x0,%r14d 40122e: e9 c6 00 00 00 jmpq 4012f9 <main+0x14c> 401233: 83 e8 61 sub $0x61,%eax 401236: 3c 10 cmp $0x10,%al 401238: 0f 87 9c 00 00 00 ja 4012da <main+0x12d> 40123e: 0f b6 c0 movzbl %al,%eax 401241: ff 24 c5 f0 2f 40 00 jmpq *0x402ff0(,%rax,8) 401248: 48 8b 3b mov (%rbx),%rdi 40124b: e8 50 fd ff ff callq 400fa0 <usage> 401250: be 6d 32 40 00 mov $0x40326d,%esi 401255: 48 8b 3d 4c 32 20 00 mov 0x20324c(%rip),%rdi # 6044a8 <optarg@@GLIBC_2.2.5> 40125c: e8 9f fb ff ff callq 400e00 <fopen@plt> 401261: 48 89 05 68 32 20 00 mov %rax,0x203268(%rip) # 6044d0 <infile> 401268: 48 85 c0 test %rax,%rax 40126b: 0f 85 88 00 00 00 jne 4012f9 <main+0x14c> 401271: 48 8b 0d 30 32 20 00 mov 0x203230(%rip),%rcx # 6044a8 <optarg@@GLIBC_2.2.5> 401278: ba b2 2f 40 00 mov $0x402fb2,%edx 40127d: be 01 00 00 00 mov $0x1,%esi 401282: 48 8b 3d 27 32 20 00 mov 0x203227(%rip),%rdi # 6044b0 <stderr@@GLIBC_2.2.5> 401289: e8 d2 fb ff ff callq 400e60 <__fprintf_chk@plt> 40128e: b8 01 00 00 00 mov $0x1,%eax 401293: e9 e4 00 00 00 jmpq 40137c <main+0x1cf> 401298: ba 10 00 00 00 mov $0x10,%edx 40129d: be 00 00 00 00 mov $0x0,%esi 4012a2: 48 8b 3d ff 31 20 00 mov 0x2031ff(%rip),%rdi # 6044a8 <optarg@@GLIBC_2.2.5> 4012a9: e8 72 fb ff ff callq 400e20 <strtoul@plt> 4012ae: 41 89 c6 mov %eax,%r14d 4012b1: eb 46 jmp 4012f9 <main+0x14c> 4012b3: ba 0a 00 00 00 mov $0xa,%edx 4012b8: be 00 00 00 00 mov $0x0,%esi 4012bd: 48 8b 3d e4 31 20 00 mov 0x2031e4(%rip),%rdi # 6044a8 <optarg@@GLIBC_2.2.5> 4012c4: e8 b7 fa ff ff callq 400d80 <strtol@plt> 4012c9: 41 89 c5 mov %eax,%r13d 4012cc: eb 2b jmp 4012f9 <main+0x14c> 4012ce: c7 05 b0 31 20 00 00 movl $0x0,0x2031b0(%rip) # 604488 <notify> 4012d5: 00 00 00 4012d8: eb 1f jmp 4012f9 <main+0x14c> 4012da: 0f be d2 movsbl %dl,%edx 4012dd: be cf 2f 40 00 mov $0x402fcf,%esi 4012e2: bf 01 00 00 00 mov $0x1,%edi 4012e7: b8 00 00 00 00 mov $0x0,%eax 4012ec: e8 ff fa ff ff callq 400df0 <__printf_chk@plt> 4012f1: 48 8b 3b mov (%rbx),%rdi 4012f4: e8 a7 fc ff ff callq 400fa0 <usage> 4012f9: 48 89 ea mov %rbp,%rdx 4012fc: 48 89 de mov %rbx,%rsi 4012ff: 44 89 e7 mov %r12d,%edi 401302: e8 09 fb ff ff callq 400e10 <getopt@plt> 401307: 89 c2 mov %eax,%edx 401309: 3c ff cmp $0xff,%al 40130b: 0f 85 22 ff ff ff jne 401233 <main+0x86> 401311: be 00 00 00 00 mov $0x0,%esi 401316: 44 89 ef mov %r13d,%edi 401319: e8 0c fd ff ff callq 40102a <initialize_target> 40131e: 83 3d c3 31 20 00 00 cmpl $0x0,0x2031c3(%rip) # 6044e8 <is_checker> 401325: 74 2a je 401351 <main+0x1a4> 401327: 44 3b 35 b2 31 20 00 cmp 0x2031b2(%rip),%r14d # 6044e0 <authkey> 40132e: 74 21 je 401351 <main+0x1a4> 401330: 44 89 f2 mov %r14d,%edx 401333: be 08 2f 40 00 mov $0x402f08,%esi 401338: bf 01 00 00 00 mov $0x1,%edi 40133d: b8 00 00 00 00 mov $0x0,%eax 401342: e8 a9 fa ff ff callq 400df0 <__printf_chk@plt> 401347: b8 00 00 00 00 mov $0x0,%eax 40134c: e8 ba 06 00 00 callq 401a0b <check_fail> 401351: 8b 15 8d 31 20 00 mov 0x20318d(%rip),%edx # 6044e4 <cookie> 401357: be e2 2f 40 00 mov $0x402fe2,%esi 40135c: bf 01 00 00 00 mov $0x1,%edi 401361: b8 00 00 00 00 mov $0x0,%eax 401366: e8 85 fa ff ff callq 400df0 <__printf_chk@plt> 40136b: 48 8b 3d 0e 31 20 00 mov 0x20310e(%rip),%rdi # 604480 <buf_offset> 401372: e8 ea 0b 00 00 callq 401f61 <stable_launch> 401377: b8 00 00 00 00 mov $0x0,%eax 40137c: 5b pop %rbx 40137d: 5d pop %rbp 40137e: 41 5c pop %r12 401380: 41 5d pop %r13 401382: 41 5e pop %r14 401384: c3 retq 401385: 90 nop 401386: 90 nop 401387: 90 nop 0000000000401388 <scramble>: 401388: b8 00 00 00 00 mov $0x0,%eax 40138d: eb 11 jmp 4013a0 <scramble+0x18> 40138f: 69 c8 7f 79 00 00 imul $0x797f,%eax,%ecx 401395: 01 f9 add %edi,%ecx 401397: 89 c2 mov %eax,%edx 401399: 89 4c 94 c8 mov %ecx,-0x38(%rsp,%rdx,4) 40139d: 83 c0 01 add $0x1,%eax 4013a0: 83 f8 09 cmp $0x9,%eax 4013a3: 76 ea jbe 40138f <scramble+0x7> 4013a5: 8b 44 24 dc mov -0x24(%rsp),%eax 4013a9: 69 c0 44 a6 00 00 imul $0xa644,%eax,%eax 4013af: 89 44 24 dc mov %eax,-0x24(%rsp) 4013b3: 8b 44 24 e8 mov -0x18(%rsp),%eax 4013b7: 69 c0 d5 50 00 00 imul $0x50d5,%eax,%eax 4013bd: 89 44 24 e8 mov %eax,-0x18(%rsp) 4013c1: 8b 44 24 e4 mov -0x1c(%rsp),%eax 4013c5: 69 c0 00 3a 00 00 imul $0x3a00,%eax,%eax 4013cb: 89 44 24 e4 mov %eax,-0x1c(%rsp) 4013cf: 8b 44 24 e4 mov -0x1c(%rsp),%eax 4013d3: 69 c0 29 9f 00 00 imul $0x9f29,%eax,%eax 4013d9: 89 44 24 e4 mov %eax,-0x1c(%rsp) 4013dd: 8b 44 24 ec mov -0x14(%rsp),%eax 4013e1: 69 c0 96 16 00 00 imul $0x1696,%eax,%eax 4013e7: 89 44 24 ec mov %eax,-0x14(%rsp) 4013eb: 8b 44 24 d4 mov -0x2c(%rsp),%eax 4013ef: 69 c0 4d 29 00 00 imul $0x294d,%eax,%eax 4013f5: 89 44 24 d4 mov %eax,-0x2c(%rsp) 4013f9: 8b 44 24 ec mov -0x14(%rsp),%eax 4013fd: 69 c0 7d c8 00 00 imul $0xc87d,%eax,%eax 401403: 89 44 24 ec mov %eax,-0x14(%rsp) 401407: 8b 44 24 d4 mov -0x2c(%rsp),%eax 40140b: 69 c0 7e 90 00 00 imul $0x907e,%eax,%eax 401411: 89 44 24 d4 mov %eax,-0x2c(%rsp) 401415: 8b 44 24 c8 mov -0x38(%rsp),%eax 401419: 69 c0 5f c3 00 00 imul $0xc35f,%eax,%eax 40141f: 89 44 24 c8 mov %eax,-0x38(%rsp) 401423: 8b 44 24 d0 mov -0x30(%rsp),%eax 401427: 69 c0 32 43 00 00 imul $0x4332,%eax,%eax 40142d: 89 44 24 d0 mov %eax,-0x30(%rsp) 401431: 8b 44 24 dc mov -0x24(%rsp),%eax 401435: 69 c0 d9 3f 00 00 imul $0x3fd9,%eax,%eax 40143b: 89 44 24 dc mov %eax,-0x24(%rsp) 40143f: 8b 44 24 cc mov -0x34(%rsp),%eax 401443: 69 c0 d7 49 00 00 imul $0x49d7,%eax,%eax 401449: 89 44 24 cc mov %eax,-0x34(%rsp) 40144d: 8b 44 24 c8 mov -0x38(%rsp),%eax 401451: 69 c0 7a 8c 00 00 imul $0x8c7a,%eax,%eax 401457: 89 44 24 c8 mov %eax,-0x38(%rsp) 40145b: 8b 44 24 d4 mov -0x2c(%rsp),%eax 40145f: 69 c0 f8 0e 00 00 imul $0xef8,%eax,%eax 401465: 89 44 24 d4 mov %eax,-0x2c(%rsp) 401469: 8b 44 24 e0 mov -0x20(%rsp),%eax 40146d: 69 c0 2d 12 00 00 imul $0x122d,%eax,%eax 401473: 89 44 24 e0 mov %eax,-0x20(%rsp) 401477: 8b 44 24 d0 mov -0x30(%rsp),%eax 40147b: 69 c0 16 c6 00 00 imul $0xc616,%eax,%eax 401481: 89 44 24 d0 mov %eax,-0x30(%rsp) 401485: 8b 44 24 e0 mov -0x20(%rsp),%eax 401489: 69 c0 41 48 00 00 imul $0x4841,%eax,%eax 40148f: 89 44 24 e0 mov %eax,-0x20(%rsp) 401493: 8b 44 24 e4 mov -0x1c(%rsp),%eax 401497: 69 c0 44 92 00 00 imul $0x9244,%eax,%eax 40149d: 89 44 24 e4 mov %eax,-0x1c(%rsp) 4014a1: 8b 44 24 e4 mov -0x1c(%rsp),%eax 4014a5: 69 c0 19 5f 00 00 imul $0x5f19,%eax,%eax 4014ab: 89 44 24 e4 mov %eax,-0x1c(%rsp) 4014af: 8b 44 24 e4 mov -0x1c(%rsp),%eax 4014b3: 69 c0 8d 3a 00 00 imul $0x3a8d,%eax,%eax 4014b9: 89 44 24 e4 mov %eax,-0x1c(%rsp) 4014bd: 8b 44 24 e0 mov -0x20(%rsp),%eax 4014c1: 69 c0 30 4a 00 00 imul $0x4a30,%eax,%eax 4014c7: 89 44 24 e0 mov %eax,-0x20(%rsp) 4014cb: 8b 44 24 dc mov -0x24(%rsp),%eax 4014cf: 69 c0 74 f2 00 00 imul $0xf274,%eax,%eax 4014d5: 89 44 24 dc mov %eax,-0x24(%rsp) 4014d9: 8b 44 24 d8 mov -0x28(%rsp),%eax 4014dd: 69 c0 04 82 00 00 imul $0x8204,%eax,%eax 4014e3: 89 44 24 d8 mov %eax,-0x28(%rsp) 4014e7: 8b 44 24 dc mov -0x24(%rsp),%eax 4014eb: 69 c0 82 d5 00 00 imul $0xd582,%eax,%eax 4014f1: 89 44 24 dc mov %eax,-0x24(%rsp) 4014f5: 8b 44 24 dc mov -0x24(%rsp),%eax 4014f9: 69 c0 cc 01 00 00 imul $0x1cc,%eax,%eax 4014ff: 89 44 24 dc mov %eax,-0x24(%rsp) 401503: 8b 44 24 e0 mov -0x20(%rsp),%eax 401507: 69 c0 77 0d 00 00 imul $0xd77,%eax,%eax 40150d: 89 44 24 e0 mov %eax,-0x20(%rsp) 401511: 8b 44 24 e0 mov -0x20(%rsp),%eax 401515: 69 c0 50 d8 00 00 imul $0xd850,%eax,%eax 40151b: 89 44 24 e0 mov %eax,-0x20(%rsp) 40151f: 8b 44 24 d4 mov -0x2c(%rsp),%eax 401523: 69 c0 45 02 00 00 imul $0x245,%eax,%eax 401529: 89 44 24 d4 mov %eax,-0x2c(%rsp) 40152d: 8b 44 24 dc mov -0x24(%rsp),%eax 401531: 69 c0 5c b6 00 00 imul $0xb65c,%eax,%eax 401537: 89 44 24 dc mov %eax,-0x24(%rsp) 40153b: 8b 44 24 d0 mov -0x30(%rsp),%eax 40153f: 69 c0 62 b1 00 00 imul $0xb162,%eax,%eax 401545: 89 44 24 d0 mov %eax,-0x30(%rsp) 401549: 8b 44 24 cc mov -0x34(%rsp),%eax 40154d: 69 c0 2f b8 00 00 imul $0xb82f,%eax,%eax 401553: 89 44 24 cc mov %eax,-0x34(%rsp) 401557: 8b 44 24 e0 mov -0x20(%rsp),%eax 40155b: 69 c0 fc 80 00 00 imul $0x80fc,%eax,%eax 401561: 89 44 24 e0 mov %eax,-0x20(%rsp) 401565: 8b 44 24 e8 mov -0x18(%rsp),%eax 401569: 69 c0 65 8e 00 00 imul $0x8e65,%eax,%eax 40156f: 89 44 24 e8 mov %eax,-0x18(%rsp) 401573: 8b 44 24 c8 mov -0x38(%rsp),%eax 401577: 69 c0 b2 82 00 00 imul $0x82b2,%eax,%eax 40157d: 89 44 24 c8 mov %eax,-0x38(%rsp) 401581: 8b 44 24 d4 mov -0x2c(%rsp),%eax 401585: 69 c0 ad 44 00 00 imul $0x44ad,%eax,%eax 40158b: 89 44 24 d4 mov %eax,-0x2c(%rsp) 40158f: 8b 44 24 dc mov -0x24(%rsp),%eax 401593: 69 c0 2e 63 00 00 imul $0x632e,%eax,%eax 401599: 89 44 24 dc mov %eax,-0x24(%rsp) 40159d: 8b 44 24 c8 mov -0x38(%rsp),%eax 4015a1: 69 c0 19 21 00 00 imul $0x2119,%eax,%eax 4015a7: 89 44 24 c8 mov %eax,-0x38(%rsp) 4015ab: 8b 44 24 e4 mov -0x1c(%rsp),%eax 4015af: 69 c0 8a a1 00 00 imul $0xa18a,%eax,%eax 4015b5: 89 44 24 e4 mov %eax,-0x1c(%rsp) 4015b9: 8b 44 24 d8 mov -0x28(%rsp),%eax 4015bd: 69 c0 95 d8 00 00 imul $0xd895,%eax,%eax 4015c3: 89 44 24 d8 mov %eax,-0x28(%rsp) 4015c7: 8b 44 24 d4 mov -0x2c(%rsp),%eax 4015cb: 69 c0 81 e8 00 00 imul $0xe881,%eax,%eax 4015d1: 89 44 24 d4 mov %eax,-0x2c(%rsp) 4015d5: 8b 44 24 d8 mov -0x28(%rsp),%eax 4015d9: 69 c0 c1 8f 00 00 imul $0x8fc1,%eax,%eax 4015df: 89 44 24 d8 mov %eax,-0x28(%rsp) 4015e3: 8b 44 24 d0 mov -0x30(%rsp),%eax 4015e7: 69 c0 07 1c 00 00 imul $0x1c07,%eax,%eax 4015ed: 89 44 24 d0 mov %eax,-0x30(%rsp) 4015f1: 8b 44 24 c8 mov -0x38(%rsp),%eax 4015f5: 69 c0 47 4d 00 00 imul $0x4d47,%eax,%eax 4015fb: 89 44 24 c8 mov %eax,-0x38(%rsp) 4015ff: 8b 44 24 cc mov -0x34(%rsp),%eax 401603: 69 c0 dd cc 00 00 imul $0xccdd,%eax,%eax 401609: 89 44 24 cc mov %eax,-0x34(%rsp) 40160d: 8b 44 24 d4 mov -0x2c(%rsp),%eax 401611: 69 c0 89 2f 00 00 imul $0x2f89,%eax,%eax 401617: 89 44 24 d4 mov %eax,-0x2c(%rsp) 40161b: 8b 44 24 c8 mov -0x38(%rsp),%eax 40161f: 69 c0 2d cc 00 00 imul $0xcc2d,%eax,%eax 401625: 89 44 24 c8 mov %eax,-0x38(%rsp) 401629: 8b 44 24 cc mov -0x34(%rsp),%eax 40162d: 69 c0 b8 f5 00 00 imul $0xf5b8,%eax,%eax 401633: 89 44 24 cc mov %eax,-0x34(%rsp) 401637: 8b 44 24 dc mov -0x24(%rsp),%eax 40163b: 69 c0 29 e8 00 00 imul $0xe829,%eax,%eax 401641: 89 44 24 dc mov %eax,-0x24(%rsp) 401645: 8b 44 24 dc mov -0x24(%rsp),%eax 401649: 69 c0 69 60 00 00 imul $0x6069,%eax,%eax 40164f: 89 44 24 dc mov %eax,-0x24(%rsp) 401653: 8b 44 24 e8 mov -0x18(%rsp),%eax 401657: 69 c0 9c 71 00 00 imul $0x719c,%eax,%eax 40165d: 89 44 24 e8 mov %eax,-0x18(%rsp) 401661: 8b 44 24 e8 mov -0x18(%rsp),%eax 401665: 69 c0 1a 28 00 00 imul $0x281a,%eax,%eax 40166b: 89 44 24 e8 mov %eax,-0x18(%rsp) 40166f: 8b 44 24 ec mov -0x14(%rsp),%eax 401673: 69 c0 f3 33 00 00 imul $0x33f3,%eax,%eax 401679: 89 44 24 ec mov %eax,-0x14(%rsp) 40167d: 8b 44 24 e4 mov -0x1c(%rsp),%eax 401681: 69 c0 6c 2a 00 00 imul $0x2a6c,%eax,%eax 401687: 89 44 24 e4 mov %eax,-0x1c(%rsp) 40168b: 8b 44 24 e4 mov -0x1c(%rsp),%eax 40168f: 69 c0 51 ec 00 00 imul $0xec51,%eax,%eax 401695: 89 44 24 e4 mov %eax,-0x1c(%rsp) 401699: 8b 44 24 e0 mov -0x20(%rsp),%eax 40169d: 69 c0 8a 4c 00 00 imul $0x4c8a,%eax,%eax 4016a3: 89 44 24 e0 mov %eax,-0x20(%rsp) 4016a7: 8b 44 24 d4 mov -0x2c(%rsp),%eax 4016ab: 69 c0 63 dd 00 00 imul $0xdd63,%eax,%eax 4016b1: 89 44 24 d4 mov %eax,-0x2c(%rsp) 4016b5: 8b 44 24 d0 mov -0x30(%rsp),%eax 4016b9: 69 c0 ca ca 00 00 imul $0xcaca,%eax,%eax 4016bf: 89 44 24 d0 mov %eax,-0x30(%rsp) 4016c3: 8b 44 24 dc mov -0x24(%rsp),%eax 4016c7: 69 c0 5d 44 00 00 imul $0x445d,%eax,%eax 4016cd: 89 44 24 dc mov %eax,-0x24(%rsp) 4016d1: 8b 44 24 d8 mov -0x28(%rsp),%eax 4016d5: 69 c0 b7 17 00 00 imul $0x17b7,%eax,%eax 4016db: 89 44 24 d8 mov %eax,-0x28(%rsp) 4016df: 8b 44 24 d0 mov -0x30(%rsp),%eax 4016e3: 69 c0 b5 1b 00 00 imul $0x1bb5,%eax,%eax 4016e9: 89 44 24 d0 mov %eax,-0x30(%rsp) 4016ed: 8b 44 24 d8 mov -0x28(%rsp),%eax 4016f1: 69 c0 7a 8f 00 00 imul $0x8f7a,%eax,%eax 4016f7: 89 44 24 d8 mov %eax,-0x28(%rsp) 4016fb: 8b 44 24 e0 mov -0x20(%rsp),%eax 4016ff: 69 c0 f9 2e 00 00 imul $0x2ef9,%eax,%eax 401705: 89 44 24 e0 mov %eax,-0x20(%rsp) 401709: 8b 44 24 d8 mov -0x28(%rsp),%eax 40170d: 69 c0 0c 35 00 00 imul $0x350c,%eax,%eax 401713: 89 44 24 d8 mov %eax,-0x28(%rsp) 401717: 8b 44 24 cc mov -0x34(%rsp),%eax 40171b: 69 c0 50 09 00 00 imul $0x950,%eax,%eax 401721: 89 44 24 cc mov %eax,-0x34(%rsp) 401725: 8b 44 24 d0 mov -0x30(%rsp),%eax 401729: 69 c0 fd 81 00 00 imul $0x81fd,%eax,%eax 40172f: 89 44 24 d0 mov %eax,-0x30(%rsp) 401733: 8b 44 24 cc mov -0x34(%rsp),%eax 401737: 69 c0 8c 3a 00 00 imul $0x3a8c,%eax,%eax 40173d: 89 44 24 cc mov %eax,-0x34(%rsp) 401741: 8b 44 24 dc mov -0x24(%rsp),%eax 401745: 69 c0 b6 4f 00 00 imul $0x4fb6,%eax,%eax 40174b: 89 44 24 dc mov %eax,-0x24(%rsp) 40174f: 8b 44 24 c8 mov -0x38(%rsp),%eax 401753: 69 c0 4a f3 00 00 imul $0xf34a,%eax,%eax 401759: 89 44 24 c8 mov %eax,-0x38(%rsp) 40175d: 8b 44 24 cc mov -0x34(%rsp),%eax 401761: 69 c0 fd 43 00 00 imul $0x43fd,%eax,%eax 401767: 89 44 24 cc mov %eax,-0x34(%rsp) 40176b: 8b 44 24 e4 mov -0x1c(%rsp),%eax 40176f: 69 c0 24 7d 00 00 imul $0x7d24,%eax,%eax 401775: 89 44 24 e4 mov %eax,-0x1c(%rsp) 401779: 8b 44 24 ec mov -0x14(%rsp),%eax 40177d: 69 c0 6d b4 00 00 imul $0xb46d,%eax,%eax 401783: 89 44 24 ec mov %eax,-0x14(%rsp) 401787: ba 00 00 00 00 mov $0x0,%edx 40178c: b8 00 00 00 00 mov $0x0,%eax 401791: eb 0b jmp 40179e <scramble+0x416> 401793: 89 d1 mov %edx,%ecx 401795: 8b 4c 8c c8 mov -0x38(%rsp,%rcx,4),%ecx 401799: 01 c8 add %ecx,%eax 40179b: 83 c2 01 add $0x1,%edx 40179e: 83 fa 09 cmp $0x9,%edx 4017a1: 76 f0 jbe 401793 <scramble+0x40b> 4017a3: f3 c3 repz retq 4017a5: 90 nop 4017a6: 90 nop 4017a7: 90 nop 00000000004017a8 <getbuf>: 4017a8: 48 83 ec 28 sub $0x28,%rsp 4017ac: 48 89 e7 mov %rsp,%rdi 4017af: e8 8c 02 00 00 callq 401a40 <Gets> 4017b4: b8 01 00 00 00 mov $0x1,%eax 4017b9: 48 83 c4 28 add $0x28,%rsp 4017bd: c3 retq 4017be: 90 nop 4017bf: 90 nop 00000000004017c0 <touch1>: 4017c0: 48 83 ec 08 sub $0x8,%rsp 4017c4: c7 05 0e 2d 20 00 01 movl $0x1,0x202d0e(%rip) # 6044dc <vlevel> 4017cb: 00 00 00 4017ce: bf c5 30 40 00 mov $0x4030c5,%edi 4017d3: e8 e8 f4 ff ff callq 400cc0 <puts@plt> 4017d8: bf 01 00 00 00 mov $0x1,%edi 4017dd: e8 ab 04 00 00 callq 401c8d <validate> 4017e2: bf 00 00 00 00 mov $0x0,%edi 4017e7: e8 54 f6 ff ff callq 400e40 <exit@plt> 00000000004017ec <touch2>: 4017ec: 48 83 ec 08 sub $0x8,%rsp 4017f0: 89 fa mov %edi,%edx 4017f2: c7 05 e0 2c 20 00 02 movl $0x2,0x202ce0(%rip) # 6044dc <vlevel> 4017f9: 00 00 00 4017fc: 3b 3d e2 2c 20 00 cmp 0x202ce2(%rip),%edi # 6044e4 <cookie> 401802: 75 20 jne 401824 <touch2+0x38> 401804: be e8 30 40 00 mov $0x4030e8,%esi 401809: bf 01 00 00 00 mov $0x1,%edi 40180e: b8 00 00 00 00 mov $0x0,%eax 401813: e8 d8 f5 ff ff callq 400df0 <__printf_chk@plt> 401818: bf 02 00 00 00 mov $0x2,%edi 40181d: e8 6b 04 00 00 callq 401c8d <validate> 401822: eb 1e jmp 401842 <touch2+0x56> 401824: be 10 31 40 00 mov $0x403110,%esi 401829: bf 01 00 00 00 mov $0x1,%edi 40182e: b8 00 00 00 00 mov $0x0,%eax 401833: e8 b8 f5 ff ff callq 400df0 <__printf_chk@plt> 401838: bf 02 00 00 00 mov $0x2,%edi 40183d: e8 0d 05 00 00 callq 401d4f <fail> 401842: bf 00 00 00 00 mov $0x0,%edi 401847: e8 f4 f5 ff ff callq 400e40 <exit@plt> 000000000040184c <hexmatch>: 40184c: 41 54 push %r12 40184e: 55 push %rbp 40184f: 53 push %rbx 401850: 48 83 c4 80 add $0xffffffffffffff80,%rsp 401854: 41 89 fc mov %edi,%r12d 401857: 48 89 f5 mov %rsi,%rbp 40185a: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 401861: 00 00 401863: 48 89 44 24 78 mov %rax,0x78(%rsp) 401868: 31 c0 xor %eax,%eax 40186a: e8 41 f5 ff ff callq 400db0 <random@plt> 40186f: 48 89 c1 mov %rax,%rcx 401872: 48 ba 0b d7 a3 70 3d movabs $0xa3d70a3d70a3d70b,%rdx 401879: 0a d7 a3 40187c: 48 f7 ea imul %rdx 40187f: 48 01 ca add %rcx,%rdx 401882: 48 c1 fa 06 sar $0x6,%rdx 401886: 48 89 c8 mov %rcx,%rax 401889: 48 c1 f8 3f sar $0x3f,%rax 40188d: 48 29 c2 sub %rax,%rdx 401890: 48 8d 04 92 lea (%rdx,%rdx,4),%rax 401894: 48 8d 04 80 lea (%rax,%rax,4),%rax 401898: 48 c1 e0 02 shl $0x2,%rax 40189c: 48 29 c1 sub %rax,%rcx 40189f: 48 8d 1c 0c lea (%rsp,%rcx,1),%rbx 4018a3: 45 89 e0 mov %r12d,%r8d 4018a6: b9 e2 30 40 00 mov $0x4030e2,%ecx 4018ab: 48 c7 c2 ff ff ff ff mov $0xffffffffffffffff,%rdx 4018b2: be 01 00 00 00 mov $0x1,%esi 4018b7: 48 89 df mov %rbx,%rdi 4018ba: b8 00 00 00 00 mov $0x0,%eax 4018bf: e8 ac f5 ff ff callq 400e70 <__sprintf_chk@plt> 4018c4: ba 09 00 00 00 mov $0x9,%edx 4018c9: 48 89 de mov %rbx,%rsi 4018cc: 48 89 ef mov %rbp,%rdi 4018cf: e8 cc f3 ff ff callq 400ca0 <strncmp@plt> 4018d4: 85 c0 test %eax,%eax 4018d6: 0f 94 c0 sete %al 4018d9: 0f b6 c0 movzbl %al,%eax 4018dc: 48 8b 74 24 78 mov 0x78(%rsp),%rsi 4018e1: 64 48 33 34 25 28 00 xor %fs:0x28,%rsi 4018e8: 00 00 4018ea: 74 05 je 4018f1 <hexmatch+0xa5> 4018ec: e8 ef f3 ff ff callq 400ce0 <__stack_chk_fail@plt> 4018f1: 48 83 ec 80 sub $0xffffffffffffff80,%rsp 4018f5: 5b pop %rbx 4018f6: 5d pop %rbp 4018f7: 41 5c pop %r12 4018f9: c3 retq 00000000004018fa <touch3>: 4018fa: 53 push %rbx 4018fb: 48 89 fb mov %rdi,%rbx 4018fe: c7 05 d4 2b 20 00 03 movl $0x3,0x202bd4(%rip) # 6044dc <vlevel> 401905: 00 00 00 401908: 48 89 fe mov %rdi,%rsi 40190b: 8b 3d d3 2b 20 00 mov 0x202bd3(%rip),%edi # 6044e4 <cookie> 401911: e8 36 ff ff ff callq 40184c <hexmatch> 401916: 85 c0 test %eax,%eax 401918: 74 23 je 40193d <touch3+0x43> 40191a: 48 89 da mov %rbx,%rdx 40191d: be 38 31 40 00 mov $0x403138,%esi 401922: bf 01 00 00 00 mov $0x1,%edi 401927: b8 00 00 00 00 mov $0x0,%eax 40192c: e8 bf f4 ff ff callq 400df0 <__printf_chk@plt> 401931: bf 03 00 00 00 mov $0x3,%edi 401936: e8 52 03 00 00 callq 401c8d <validate> 40193b: eb 21 jmp 40195e <touch3+0x64> 40193d: 48 89 da mov %rbx,%rdx 401940: be 60 31 40 00 mov $0x403160,%esi 401945: bf 01 00 00 00 mov $0x1,%edi 40194a: b8 00 00 00 00 mov $0x0,%eax 40194f: e8 9c f4 ff ff callq 400df0 <__printf_chk@plt> 401954: bf 03 00 00 00 mov $0x3,%edi 401959: e8 f1 03 00 00 callq 401d4f <fail> 40195e: bf 00 00 00 00 mov $0x0,%edi 401963: e8 d8 f4 ff ff callq 400e40 <exit@plt> 0000000000401968 <test>: 401968: 48 83 ec 08 sub $0x8,%rsp 40196c: b8 00 00 00 00 mov $0x0,%eax 401971: e8 32 fe ff ff callq 4017a8 <getbuf> 401976: 89 c2 mov %eax,%edx 401978: be 88 31 40 00 mov $0x403188,%esi 40197d: bf 01 00 00 00 mov $0x1,%edi 401982: b8 00 00 00 00 mov $0x0,%eax 401987: e8 64 f4 ff ff callq 400df0 <__printf_chk@plt> 40198c: 48 83 c4 08 add $0x8,%rsp 401990: c3 retq 401991: 90 nop 401992: 90 nop 401993: 90 nop 401994: 90 nop 401995: 90 nop 401996: 90 nop 401997: 90 nop 401998: 90 nop 401999: 90 nop 40199a: 90 nop 40199b: 90 nop 40199c: 90 nop 40199d: 90 nop 40199e: 90 nop 40199f: 90 nop 00000000004019a0 <save_char>: 4019a0: 8b 05 5e 37 20 00 mov 0x20375e(%rip),%eax # 605104 <gets_cnt> 4019a6: 3d ff 03 00 00 cmp $0x3ff,%eax 4019ab: 7f 49 jg 4019f6 <save_char+0x56> 4019ad: 8d 14 40 lea (%rax,%rax,2),%edx 4019b0: 89 f9 mov %edi,%ecx 4019b2: c1 e9 04 shr $0x4,%ecx 4019b5: 48 63 c9 movslq %ecx,%rcx 4019b8: 0f b6 b1 b0 34 40 00 movzbl 0x4034b0(%rcx),%esi 4019bf: 48 63 ca movslq %edx,%rcx 4019c2: 40 88 b1 00 45 60 00 mov %sil,0x604500(%rcx) 4019c9: 8d 4a 01 lea 0x1(%rdx),%ecx 4019cc: 83 e7 0f and $0xf,%edi 4019cf: 0f b6 b7 b0 34 40 00 movzbl 0x4034b0(%rdi),%esi 4019d6: 48 63 c9 movslq %ecx,%rcx 4019d9: 40 88 b1 00 45 60 00 mov %sil,0x604500(%rcx) 4019e0: 83 c2 02 add $0x2,%edx 4019e3: 48 63 d2 movslq %edx,%rdx 4019e6: c6 82 00 45 60 00 20 movb $0x20,0x604500(%rdx) 4019ed: 83 c0 01 add $0x1,%eax 4019f0: 89 05 0e 37 20 00 mov %eax,0x20370e(%rip) # 605104 <gets_cnt> 4019f6: f3 c3 repz retq 00000000004019f8 <save_term>: 4019f8: 8b 05 06 37 20 00 mov 0x203706(%rip),%eax # 605104 <gets_cnt> 4019fe: 8d 04 40 lea (%rax,%rax,2),%eax 401a01: 48 98 cltq 401a03: c6 80 00 45 60 00 00 movb $0x0,0x604500(%rax) 401a0a: c3 retq 0000000000401a0b <check_fail>: 401a0b: 48 83 ec 08 sub $0x8,%rsp 401a0f: 0f be 15 f2 36 20 00 movsbl 0x2036f2(%rip),%edx # 605108 <target_prefix> 401a16: 41 b8 00 45 60 00 mov $0x604500,%r8d 401a1c: 8b 0d b6 2a 20 00 mov 0x202ab6(%rip),%ecx # 6044d8 <check_level> 401a22: be ab 31 40 00 mov $0x4031ab,%esi 401a27: bf 01 00 00 00 mov $0x1,%edi 401a2c: b8 00 00 00 00 mov $0x0,%eax 401a31: e8 ba f3 ff ff callq 400df0 <__printf_chk@plt> 401a36: bf 01 00 00 00 mov $0x1,%edi 401a3b: e8 00 f4 ff ff callq 400e40 <exit@plt> 0000000000401a40 <Gets>: 401a40: 41 54 push %r12 401a42: 55 push %rbp 401a43: 53 push %rbx 401a44: 49 89 fc mov %rdi,%r12 401a47: c7 05 b3 36 20 00 00 movl $0x0,0x2036b3(%rip) # 605104 <gets_cnt> 401a4e: 00 00 00 401a51: 48 89 fb mov %rdi,%rbx 401a54: eb 11 jmp 401a67 <Gets+0x27> 401a56: 48 8d 6b 01 lea 0x1(%rbx),%rbp 401a5a: 88 03 mov %al,(%rbx) 401a5c: 0f b6 f8 movzbl %al,%edi 401a5f: e8 3c ff ff ff callq 4019a0 <save_char> 401a64: 48 89 eb mov %rbp,%rbx 401a67: 48 8b 3d 62 2a 20 00 mov 0x202a62(%rip),%rdi # 6044d0 <infile> 401a6e: e8 4d f3 ff ff callq 400dc0 <_IO_getc@plt> 401a73: 83 f8 ff cmp $0xffffffff,%eax 401a76: 74 05 je 401a7d <Gets+0x3d> 401a78: 83 f8 0a cmp $0xa,%eax 401a7b: 75 d9 jne 401a56 <Gets+0x16> 401a7d: c6 03 00 movb $0x0,(%rbx) 401a80: b8 00 00 00 00 mov $0x0,%eax 401a85: e8 6e ff ff ff callq 4019f8 <save_term> 401a8a: 4c 89 e0 mov %r12,%rax 401a8d: 5b pop %rbx 401a8e: 5d pop %rbp 401a8f: 41 5c pop %r12 401a91: c3 retq 0000000000401a92 <notify_server>: 401a92: 53 push %rbx 401a93: 48 81 ec 30 40 00 00 sub $0x4030,%rsp 401a9a: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 401aa1: 00 00 401aa3: 48 89 84 24 28 40 00 mov %rax,0x4028(%rsp) 401aaa: 00 401aab: 31 c0 xor %eax,%eax 401aad: 83 3d 34 2a 20 00 00 cmpl $0x0,0x202a34(%rip) # 6044e8 <is_checker> 401ab4: 0f 85 b2 01 00 00 jne 401c6c <notify_server+0x1da> 401aba: 8b 05 44 36 20 00 mov 0x203644(%rip),%eax # 605104 <gets_cnt> 401ac0: 83 c0 64 add $0x64,%eax 401ac3: 3d 00 20 00 00 cmp $0x2000,%eax 401ac8: 7e 1e jle 401ae8 <notify_server+0x56> 401aca: be e0 32 40 00 mov $0x4032e0,%esi 401acf: bf 01 00 00 00 mov $0x1,%edi 401ad4: b8 00 00 00 00 mov $0x0,%eax 401ad9: e8 12 f3 ff ff callq 400df0 <__printf_chk@plt> 401ade: bf 01 00 00 00 mov $0x1,%edi 401ae3: e8 58 f3 ff ff callq 400e40 <exit@plt> 401ae8: 89 fb mov %edi,%ebx 401aea: 0f be 15 17 36 20 00 movsbl 0x203617(%rip),%edx # 605108 <target_prefix> 401af1: 83 3d 90 29 20 00 00 cmpl $0x0,0x202990(%rip) # 604488 <notify> 401af8: b8 ff ff ff ff mov $0xffffffff,%eax 401afd: 0f 45 05 dc 29 20 00 cmovne 0x2029dc(%rip),%eax # 6044e0 <authkey> 401b04: 85 ff test %edi,%edi 401b06: b9 c6 31 40 00 mov $0x4031c6,%ecx 401b0b: 41 b9 c1 31 40 00 mov $0x4031c1,%r9d 401b11: 4c 0f 44 c9 cmove %rcx,%r9 401b15: 48 c7 44 24 18 00 45 movq $0x604500,0x18(%rsp) 401b1c: 60 00 401b1e: 89 74 24 10 mov %esi,0x10(%rsp) 401b22: 89 54 24 08 mov %edx,0x8(%rsp) 401b26: 89 04 24 mov %eax,(%rsp) 401b29: 44 8b 05 18 26 20 00 mov 0x202618(%rip),%r8d # 604148 <target_id> 401b30: b9 cb 31 40 00 mov $0x4031cb,%ecx 401b35: ba 00 20 00 00 mov $0x2000,%edx 401b3a: be 01 00 00 00 mov $0x1,%esi 401b3f: 48 8d 7c 24 20 lea 0x20(%rsp),%rdi 401b44: b8 00 00 00 00 mov $0x0,%eax 401b49: e8 22 f3 ff ff callq 400e70 <__sprintf_chk@plt> 401b4e: 83 3d 33 29 20 00 00 cmpl $0x0,0x202933(%rip) # 604488 <notify> 401b55: 0f 84 83 00 00 00 je 401bde <notify_server+0x14c> 401b5b: 85 db test %ebx,%ebx 401b5d: 74 70 je 401bcf <notify_server+0x13d> 401b5f: 4c 8d 8c 24 20 20 00 lea 0x2020(%rsp),%r9 401b66: 00 401b67: 41 b8 00 00 00 00 mov $0x0,%r8d 401b6d: 48 8d 4c 24 20 lea 0x20(%rsp),%rcx 401b72: 48 8b 15 d7 25 20 00 mov 0x2025d7(%rip),%rdx # 604150 <lab> 401b79: 48 8b 35 d8 25 20 00 mov 0x2025d8(%rip),%rsi # 604158 <course> 401b80: 48 8b 3d b9 25 20 00 mov 0x2025b9(%rip),%rdi # 604140 <user_id> 401b87: e8 8b 10 00 00 callq 402c17 <driver_post> 401b8c: 85 c0 test %eax,%eax 401b8e: 79 26 jns 401bb6 <notify_server+0x124> 401b90: 48 8d 94 24 20 20 00 lea 0x2020(%rsp),%rdx 401b97: 00 401b98: be e7 31 40 00 mov $0x4031e7,%esi 401b9d: bf 01 00 00 00 mov $0x1,%edi 401ba2: b8 00 00 00 00 mov $0x0,%eax 401ba7: e8 44 f2 ff ff callq 400df0 <__printf_chk@plt> 401bac: bf 01 00 00 00 mov $0x1,%edi 401bb1: e8 8a f2 ff ff callq 400e40 <exit@plt> 401bb6: bf 10 33 40 00 mov $0x403310,%edi 401bbb: e8 00 f1 ff ff callq 400cc0 <puts@plt> 401bc0: bf f3 31 40 00 mov $0x4031f3,%edi 401bc5: e8 f6 f0 ff ff callq 400cc0 <puts@plt> 401bca: e9 9d 00 00 00 jmpq 401c6c <notify_server+0x1da> 401bcf: bf fd 31 40 00 mov $0x4031fd,%edi 401bd4: e8 e7 f0 ff ff callq 400cc0 <puts@plt> 401bd9: e9 8e 00 00 00 jmpq 401c6c <notify_server+0x1da> 401bde: 85 db test %ebx,%ebx 401be0: b8 c6 31 40 00 mov $0x4031c6,%eax 401be5: ba c1 31 40 00 mov $0x4031c1,%edx 401bea: 48 0f 44 d0 cmove %rax,%rdx 401bee: be 48 33 40 00 mov $0x403348,%esi 401bf3: bf 01 00 00 00 mov $0x1,%edi 401bf8: b8 00 00 00 00 mov $0x0,%eax 401bfd: e8 ee f1 ff ff callq 400df0 <__printf_chk@plt> 401c02: 48 8b 15 37 25 20 00 mov 0x202537(%rip),%rdx # 604140 <user_id> 401c09: be 04 32 40 00 mov $0x403204,%esi 401c0e: bf 01 00 00 00 mov $0x1,%edi 401c13: b8 00 00 00 00 mov $0x0,%eax 401c18: e8 d3 f1 ff ff callq 400df0 <__printf_chk@plt> 401c1d: 48 8b 15 34 25 20 00 mov 0x202534(%rip),%rdx # 604158 <course> 401c24: be 11 32 40 00 mov $0x403211,%esi 401c29: bf 01 00 00 00 mov $0x1,%edi 401c2e: b8 00 00 00 00 mov $0x0,%eax 401c33: e8 b8 f1 ff ff callq 400df0 <__printf_chk@plt> 401c38: 48 8b 15 11 25 20 00 mov 0x202511(%rip),%rdx # 604150 <lab> 401c3f: be 1d 32 40 00 mov $0x40321d,%esi 401c44: bf 01 00 00 00 mov $0x1,%edi 401c49: b8 00 00 00 00 mov $0x0,%eax 401c4e: e8 9d f1 ff ff callq 400df0 <__printf_chk@plt> 401c53: 48 8d 54 24 20 lea 0x20(%rsp),%rdx 401c58: be 26 32 40 00 mov $0x403226,%esi 401c5d: bf 01 00 00 00 mov $0x1,%edi 401c62: b8 00 00 00 00 mov $0x0,%eax 401c67: e8 84 f1 ff ff callq 400df0 <__printf_chk@plt> 401c6c: 48 8b 84 24 28 40 00 mov 0x4028(%rsp),%rax 401c73: 00 401c74: 64 48 33 04 25 28 00 xor %fs:0x28,%rax 401c7b: 00 00 401c7d: 74 05 je 401c84 <notify_server+0x1f2> 401c7f: e8 5c f0 ff ff callq 400ce0 <__stack_chk_fail@plt> 401c84: 48 81 c4 30 40 00 00 add $0x4030,%rsp 401c8b: 5b pop %rbx 401c8c: c3 retq 0000000000401c8d <validate>: 401c8d: 53 push %rbx 401c8e: 89 fb mov %edi,%ebx 401c90: 83 3d 51 28 20 00 00 cmpl $0x0,0x202851(%rip) # 6044e8 <is_checker> 401c97: 74 6b je 401d04 <validate+0x77> 401c99: 39 3d 3d 28 20 00 cmp %edi,0x20283d(%rip) # 6044dc <vlevel> 401c9f: 74 14 je 401cb5 <validate+0x28> 401ca1: bf 32 32 40 00 mov $0x403232,%edi 401ca6: e8 15 f0 ff ff callq 400cc0 <puts@plt> 401cab: b8 00 00 00 00 mov $0x0,%eax 401cb0: e8 56 fd ff ff callq 401a0b <check_fail> 401cb5: 8b 15 1d 28 20 00 mov 0x20281d(%rip),%edx # 6044d8 <check_level> 401cbb: 39 fa cmp %edi,%edx 401cbd: 74 20 je 401cdf <validate+0x52> 401cbf: 89 f9 mov %edi,%ecx 401cc1: be 70 33 40 00 mov $0x403370,%esi 401cc6: bf 01 00 00 00 mov $0x1,%edi 401ccb: b8 00 00 00 00 mov $0x0,%eax 401cd0: e8 1b f1 ff ff callq 400df0 <__printf_chk@plt> 401cd5: b8 00 00 00 00 mov $0x0,%eax 401cda: e8 2c fd ff ff callq 401a0b <check_fail> 401cdf: 0f be 15 22 34 20 00 movsbl 0x203422(%rip),%edx # 605108 <target_prefix> 401ce6: 41 b8 00 45 60 00 mov $0x604500,%r8d 401cec: 89 f9 mov %edi,%ecx 401cee: be 50 32 40 00 mov $0x403250,%esi 401cf3: bf 01 00 00 00 mov $0x1,%edi 401cf8: b8 00 00 00 00 mov $0x0,%eax 401cfd: e8 ee f0 ff ff callq 400df0 <__printf_chk@plt> 401d02: eb 49 jmp 401d4d <validate+0xc0> 401d04: 39 3d d2 27 20 00 cmp %edi,0x2027d2(%rip) # 6044dc <vlevel> 401d0a: 74 18 je 401d24 <validate+0x97> 401d0c: bf 32 32 40 00 mov $0x403232,%edi 401d11: e8 aa ef ff ff callq 400cc0 <puts@plt> 401d16: 89 de mov %ebx,%esi 401d18: bf 00 00 00 00 mov $0x0,%edi 401d1d: e8 70 fd ff ff callq 401a92 <notify_server> 401d22: eb 29 jmp 401d4d <validate+0xc0> 401d24: 0f be 0d dd 33 20 00 movsbl 0x2033dd(%rip),%ecx # 605108 <target_prefix> 401d2b: 89 fa mov %edi,%edx 401d2d: be 98 33 40 00 mov $0x403398,%esi 401d32: bf 01 00 00 00 mov $0x1,%edi 401d37: b8 00 00 00 00 mov $0x0,%eax 401d3c: e8 af f0 ff ff callq 400df0 <__printf_chk@plt> 401d41: 89 de mov %ebx,%esi 401d43: bf 01 00 00 00 mov $0x1,%edi 401d48: e8 45 fd ff ff callq 401a92 <notify_server> 401d4d: 5b pop %rbx 401d4e: c3 retq 0000000000401d4f <fail>: 401d4f: 48 83 ec 08 sub $0x8,%rsp 401d53: 83 3d 8e 27 20 00 00 cmpl $0x0,0x20278e(%rip) # 6044e8 <is_checker> 401d5a: 74 0a je 401d66 <fail+0x17> 401d5c: b8 00 00 00 00 mov $0x0,%eax 401d61: e8 a5 fc ff ff callq 401a0b <check_fail> 401d66: 89 fe mov %edi,%esi 401d68: bf 00 00 00 00 mov $0x0,%edi 401d6d: e8 20 fd ff ff callq 401a92 <notify_server> 401d72: 48 83 c4 08 add $0x8,%rsp 401d76: c3 retq 0000000000401d77 <bushandler>: 401d77: 48 83 ec 08 sub $0x8,%rsp 401d7b: 83 3d 66 27 20 00 00 cmpl $0x0,0x202766(%rip) # 6044e8 <is_checker> 401d82: 74 14 je 401d98 <bushandler+0x21> 401d84: bf 65 32 40 00 mov $0x403265,%edi 401d89: e8 32 ef ff ff callq 400cc0 <puts@plt> 401d8e: b8 00 00 00 00 mov $0x0,%eax 401d93: e8 73 fc ff ff callq 401a0b <check_fail> 401d98: bf d0 33 40 00 mov $0x4033d0,%edi 401d9d: e8 1e ef ff ff callq 400cc0 <puts@plt> 401da2: bf 6f 32 40 00 mov $0x40326f,%edi 401da7: e8 14 ef ff ff callq 400cc0 <puts@plt> 401dac: be 00 00 00 00 mov $0x0,%esi 401db1: bf 00 00 00 00 mov $0x0,%edi 401db6: e8 d7 fc ff ff callq 401a92 <notify_server> 401dbb: bf 01 00 00 00 mov $0x1,%edi 401dc0: e8 7b f0 ff ff callq 400e40 <exit@plt> 0000000000401dc5 <seghandler>: 401dc5: 48 83 ec 08 sub $0x8,%rsp 401dc9: 83 3d 18 27 20 00 00 cmpl $0x0,0x202718(%rip) # 6044e8 <is_checker> 401dd0: 74 14 je 401de6 <seghandler+0x21> 401dd2: bf 85 32 40 00 mov $0x403285,%edi 401dd7: e8 e4 ee ff ff callq 400cc0 <puts@plt> 401ddc: b8 00 00 00 00 mov $0x0,%eax 401de1: e8 25 fc ff ff callq 401a0b <check_fail> 401de6: bf f0 33 40 00 mov $0x4033f0,%edi 401deb: e8 d0 ee ff ff callq 400cc0 <puts@plt> 401df0: bf 6f 32 40 00 mov $0x40326f,%edi 401df5: e8 c6 ee ff ff callq 400cc0 <puts@plt> 401dfa: be 00 00 00 00 mov $0x0,%esi 401dff: bf 00 00 00 00 mov $0x0,%edi 401e04: e8 89 fc ff ff callq 401a92 <notify_server> 401e09: bf 01 00 00 00 mov $0x1,%edi 401e0e: e8 2d f0 ff ff callq 400e40 <exit@plt> 0000000000401e13 <illegalhandler>: 401e13: 48 83 ec 08 sub $0x8,%rsp 401e17: 83 3d ca 26 20 00 00 cmpl $0x0,0x2026ca(%rip) # 6044e8 <is_checker> 401e1e: 74 14 je 401e34 <illegalhandler+0x21> 401e20: bf 98 32 40 00 mov $0x403298,%edi 401e25: e8 96 ee ff ff callq 400cc0 <puts@plt> 401e2a: b8 00 00 00 00 mov $0x0,%eax 401e2f: e8 d7 fb ff ff callq 401a0b <check_fail> 401e34: bf 18 34 40 00 mov $0x403418,%edi 401e39: e8 82 ee ff ff callq 400cc0 <puts@plt> 401e3e: bf 6f 32 40 00 mov $0x40326f,%edi 401e43: e8 78 ee ff ff callq 400cc0 <puts@plt> 401e48: be 00 00 00 00 mov $0x0,%esi 401e4d: bf 00 00 00 00 mov $0x0,%edi 401e52: e8 3b fc ff ff callq 401a92 <notify_server> 401e57: bf 01 00 00 00 mov $0x1,%edi 401e5c: e8 df ef ff ff callq 400e40 <exit@plt> 0000000000401e61 <sigalrmhandler>: 401e61: 48 83 ec 08 sub $0x8,%rsp 401e65: 83 3d 7c 26 20 00 00 cmpl $0x0,0x20267c(%rip) # 6044e8 <is_checker> 401e6c: 74 14 je 401e82 <sigalrmhandler+0x21> 401e6e: bf ac 32 40 00 mov $0x4032ac,%edi 401e73: e8 48 ee ff ff callq 400cc0 <puts@plt> 401e78: b8 00 00 00 00 mov $0x0,%eax 401e7d: e8 89 fb ff ff callq 401a0b <check_fail> 401e82: ba 05 00 00 00 mov $0x5,%edx 401e87: be 48 34 40 00 mov $0x403448,%esi 401e8c: bf 01 00 00 00 mov $0x1,%edi 401e91: b8 00 00 00 00 mov $0x0,%eax 401e96: e8 55 ef ff ff callq 400df0 <__printf_chk@plt> 401e9b: be 00 00 00 00 mov $0x0,%esi 401ea0: bf 00 00 00 00 mov $0x0,%edi 401ea5: e8 e8 fb ff ff callq 401a92 <notify_server> 401eaa: bf 01 00 00 00 mov $0x1,%edi 401eaf: e8 8c ef ff ff callq 400e40 <exit@plt> 0000000000401eb4 <launch>: 401eb4: 55 push %rbp 401eb5: 48 89 e5 mov %rsp,%rbp 401eb8: 48 83 ec 10 sub $0x10,%rsp 401ebc: 48 89 fa mov %rdi,%rdx 401ebf: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 401ec6: 00 00 401ec8: 48 89 45 f8 mov %rax,-0x8(%rbp) 401ecc: 31 c0 xor %eax,%eax 401ece: 48 8d 47 1e lea 0x1e(%rdi),%rax 401ed2: 48 83 e0 f0 and $0xfffffffffffffff0,%rax 401ed6: 48 29 c4 sub %rax,%rsp 401ed9: 48 8d 7c 24 0f lea 0xf(%rsp),%rdi 401ede: 48 83 e7 f0 and $0xfffffffffffffff0,%rdi 401ee2: be f4 00 00 00 mov $0xf4,%esi 401ee7: e8 14 ee ff ff callq 400d00 <memset@plt> 401eec: 48 8b 05 ad 25 20 00 mov 0x2025ad(%rip),%rax # 6044a0 <stdin@@GLIBC_2.2.5> 401ef3: 48 39 05 d6 25 20 00 cmp %rax,0x2025d6(%rip) # 6044d0 <infile> 401efa: 75 14 jne 401f10 <launch+0x5c> 401efc: be b4 32 40 00 mov $0x4032b4,%esi 401f01: bf 01 00 00 00 mov $0x1,%edi 401f06: b8 00 00 00 00 mov $0x0,%eax 401f0b: e8 e0 ee ff ff callq 400df0 <__printf_chk@plt> 401f10: c7 05 c2 25 20 00 00 movl $0x0,0x2025c2(%rip) # 6044dc <vlevel> 401f17: 00 00 00 401f1a: b8 00 00 00 00 mov $0x0,%eax 401f1f: e8 44 fa ff ff callq 401968 <test> 401f24: 83 3d bd 25 20 00 00 cmpl $0x0,0x2025bd(%rip) # 6044e8 <is_checker> 401f2b: 74 14 je 401f41 <launch+0x8d> 401f2d: bf c1 32 40 00 mov $0x4032c1,%edi 401f32: e8 89 ed ff ff callq 400cc0 <puts@plt> 401f37: b8 00 00 00 00 mov $0x0,%eax 401f3c: e8 ca fa ff ff callq 401a0b <check_fail> 401f41: bf cc 32 40 00 mov $0x4032cc,%edi 401f46: e8 75 ed ff ff callq 400cc0 <puts@plt> 401f4b: 48 8b 45 f8 mov -0x8(%rbp),%rax 401f4f: 64 48 33 04 25 28 00 xor %fs:0x28,%rax 401f56: 00 00 401f58: 74 05 je 401f5f <launch+0xab> 401f5a: e8 81 ed ff ff callq 400ce0 <__stack_chk_fail@plt> 401f5f: c9 leaveq 401f60: c3 retq 0000000000401f61 <stable_launch>: 401f61: 53 push %rbx 401f62: 48 89 3d 5f 25 20 00 mov %rdi,0x20255f(%rip) # 6044c8 <global_offset> 401f69: 41 b9 00 00 00 00 mov $0x0,%r9d 401f6f: 41 b8 00 00 00 00 mov $0x0,%r8d 401f75: b9 32 01 00 00 mov $0x132,%ecx 401f7a: ba 07 00 00 00 mov $0x7,%edx 401f7f: be 00 00 10 00 mov $0x100000,%esi 401f84: bf 00 60 58 55 mov $0x55586000,%edi 401f89: e8 62 ed ff ff callq 400cf0 <mmap@plt> 401f8e: 48 89 c3 mov %rax,%rbx 401f91: 48 3d 00 60 58 55 cmp $0x55586000,%rax 401f97: 74 37 je 401fd0 <stable_launch+0x6f> 401f99: be 00 00 10 00 mov $0x100000,%esi 401f9e: 48 89 c7 mov %rax,%rdi 401fa1: e8 3a ee ff ff callq 400de0 <munmap@plt> 401fa6: b9 00 60 58 55 mov $0x55586000,%ecx 401fab: ba 80 34 40 00 mov $0x403480,%edx 401fb0: be 01 00 00 00 mov $0x1,%esi 401fb5: 48 8b 3d f4 24 20 00 mov 0x2024f4(%rip),%rdi # 6044b0 <stderr@@GLIBC_2.2.5> 401fbc: b8 00 00 00 00 mov $0x0,%eax 401fc1: e8 9a ee ff ff callq 400e60 <__fprintf_chk@plt> 401fc6: bf 01 00 00 00 mov $0x1,%edi 401fcb: e8 70 ee ff ff callq 400e40 <exit@plt> 401fd0: 48 8d 90 f8 ff 0f 00 lea 0xffff8(%rax),%rdx 401fd7: 48 89 15 32 31 20 00 mov %rdx,0x203132(%rip) # 605110 <stack_top> 401fde: 48 89 e0 mov %rsp,%rax 401fe1: 48 89 d4 mov %rdx,%rsp 401fe4: 48 89 c2 mov %rax,%rdx 401fe7: 48 89 15 d2 24 20 00 mov %rdx,0x2024d2(%rip) # 6044c0 <global_save_stack> 401fee: 48 8b 3d d3 24 20 00 mov 0x2024d3(%rip),%rdi # 6044c8 <global_offset> 401ff5: e8 ba fe ff ff callq 401eb4 <launch> 401ffa: 48 8b 05 bf 24 20 00 mov 0x2024bf(%rip),%rax # 6044c0 <global_save_stack> 402001: 48 89 c4 mov %rax,%rsp 402004: be 00 00 10 00 mov $0x100000,%esi 402009: 48 89 df mov %rbx,%rdi 40200c: e8 cf ed ff ff callq 400de0 <munmap@plt> 402011: 5b pop %rbx 402012: c3 retq 402013: 90 nop 402014: 90 nop 402015: 90 nop 402016: 90 nop 402017: 90 nop 402018: 90 nop 402019: 90 nop 40201a: 90 nop 40201b: 90 nop 40201c: 90 nop 40201d: 90 nop 40201e: 90 nop 40201f: 90 nop 0000000000402020 <rio_readinitb>: 402020: 89 37 mov %esi,(%rdi) 402022: c7 47 04 00 00 00 00 movl $0x0,0x4(%rdi) 402029: 48 8d 47 10 lea 0x10(%rdi),%rax 40202d: 48 89 47 08 mov %rax,0x8(%rdi) 402031: c3 retq 0000000000402032 <sigalrm_handler>: 402032: 48 83 ec 08 sub $0x8,%rsp 402036: b9 00 00 00 00 mov $0x0,%ecx 40203b: ba c0 34 40 00 mov $0x4034c0,%edx 402040: be 01 00 00 00 mov $0x1,%esi 402045: 48 8b 3d 64 24 20 00 mov 0x202464(%rip),%rdi # 6044b0 <stderr@@GLIBC_2.2.5> 40204c: b8 00 00 00 00 mov $0x0,%eax 402051: e8 0a ee ff ff callq 400e60 <__fprintf_chk@plt> 402056: bf 01 00 00 00 mov $0x1,%edi 40205b: e8 e0 ed ff ff callq 400e40 <exit@plt> 0000000000402060 <rio_writen>: 402060: 41 55 push %r13 402062: 41 54 push %r12 402064: 55 push %rbp 402065: 53 push %rbx 402066: 48 83 ec 08 sub $0x8,%rsp 40206a: 41 89 fc mov %edi,%r12d 40206d: 48 89 f5 mov %rsi,%rbp 402070: 49 89 d5 mov %rdx,%r13 402073: 48 89 d3 mov %rdx,%rbx 402076: eb 28 jmp 4020a0 <rio_writen+0x40> 402078: 48 89 da mov %rbx,%rdx 40207b: 48 89 ee mov %rbp,%rsi 40207e: 44 89 e7 mov %r12d,%edi 402081: e8 4a ec ff ff callq 400cd0 <write@plt> 402086: 48 85 c0 test %rax,%rax 402089: 7f 0f jg 40209a <rio_writen+0x3a> 40208b: e8 f0 eb ff ff callq 400c80 <__errno_location@plt> 402090: 83 38 04 cmpl $0x4,(%rax) 402093: 75 15 jne 4020aa <rio_writen+0x4a> 402095: b8 00 00 00 00 mov $0x0,%eax 40209a: 48 29 c3 sub %rax,%rbx 40209d: 48 01 c5 add %rax,%rbp 4020a0: 48 85 db test %rbx,%rbx 4020a3: 75 d3 jne 402078 <rio_writen+0x18> 4020a5: 4c 89 e8 mov %r13,%rax 4020a8: eb 07 jmp 4020b1 <rio_writen+0x51> 4020aa: 48 c7 c0 ff ff ff ff mov $0xffffffffffffffff,%rax 4020b1: 48 83 c4 08 add $0x8,%rsp 4020b5: 5b pop %rbx 4020b6: 5d pop %rbp 4020b7: 41 5c pop %r12 4020b9: 41 5d pop %r13 4020bb: c3 retq 00000000004020bc <rio_read>: 4020bc: 41 55 push %r13 4020be: 41 54 push %r12 4020c0: 55 push %rbp 4020c1: 53 push %rbx 4020c2: 48 83 ec 08 sub $0x8,%rsp 4020c6: 48 89 fb mov %rdi,%rbx 4020c9: 49 89 f5 mov %rsi,%r13 4020cc: 49 89 d4 mov %rdx,%r12 4020cf: 48 8d 6f 10 lea 0x10(%rdi),%rbp 4020d3: eb 2a jmp 4020ff <rio_read+0x43> 4020d5: 8b 3b mov (%rbx),%edi 4020d7: ba 00 20 00 00 mov $0x2000,%edx 4020dc: 48 89 ee mov %rbp,%rsi 4020df: e8 4c ec ff ff callq 400d30 <read@plt> 4020e4: 89 43 04 mov %eax,0x4(%rbx) 4020e7: 85 c0 test %eax,%eax 4020e9: 79 0c jns 4020f7 <rio_read+0x3b> 4020eb: e8 90 eb ff ff callq 400c80 <__errno_location@plt> 4020f0: 83 38 04 cmpl $0x4,(%rax) 4020f3: 74 0a je 4020ff <rio_read+0x43> 4020f5: eb 37 jmp 40212e <rio_read+0x72> 4020f7: 85 c0 test %eax,%eax 4020f9: 74 3c je 402137 <rio_read+0x7b> 4020fb: 48 89 6b 08 mov %rbp,0x8(%rbx) 4020ff: 8b 43 04 mov 0x4(%rbx),%eax 402102: 85 c0 test %eax,%eax 402104: 7e cf jle 4020d5 <rio_read+0x19> 402106: 89 c2 mov %eax,%edx 402108: 4c 39 e2 cmp %r12,%rdx 40210b: 44 0f 42 e0 cmovb %eax,%r12d 40210f: 49 63 ec movslq %r12d,%rbp 402112: 48 8b 73 08 mov 0x8(%rbx),%rsi 402116: 48 89 ea mov %rbp,%rdx 402119: 4c 89 ef mov %r13,%rdi 40211c: e8 6f ec ff ff callq 400d90 <memcpy@plt> 402121: 48 01 6b 08 add %rbp,0x8(%rbx) 402125: 44 29 63 04 sub %r12d,0x4(%rbx) 402129: 48 89 e8 mov %rbp,%rax 40212c: eb 0e jmp 40213c <rio_read+0x80> 40212e: 48 c7 c0 ff ff ff ff mov $0xffffffffffffffff,%rax 402135: eb 05 jmp 40213c <rio_read+0x80> 402137: b8 00 00 00 00 mov $0x0,%eax 40213c: 48 83 c4 08 add $0x8,%rsp 402140: 5b pop %rbx 402141: 5d pop %rbp 402142: 41 5c pop %r12 402144: 41 5d pop %r13 402146: c3 retq 0000000000402147 <rio_readlineb>: 402147: 41 55 push %r13 402149: 41 54 push %r12 40214b: 55 push %rbp 40214c: 53 push %rbx 40214d: 48 83 ec 18 sub $0x18,%rsp 402151: 49 89 fd mov %rdi,%r13 402154: 48 89 f5 mov %rsi,%rbp 402157: 49 89 d4 mov %rdx,%r12 40215a: bb 01 00 00 00 mov $0x1,%ebx 40215f: eb 3c jmp 40219d <rio_readlineb+0x56> 402161: ba 01 00 00 00 mov $0x1,%edx 402166: 48 8d 74 24 0f lea 0xf(%rsp),%rsi 40216b: 4c 89 ef mov %r13,%rdi 40216e: e8 49 ff ff ff callq 4020bc <rio_read> 402173: 83 f8 01 cmp $0x1,%eax 402176: 75 12 jne 40218a <rio_readlineb+0x43> 402178: 48 8d 55 01 lea 0x1(%rbp),%rdx 40217c: 0f b6 44 24 0f movzbl 0xf(%rsp),%eax 402181: 88 45 00 mov %al,0x0(%rbp) 402184: 3c 0a cmp $0xa,%al 402186: 75 0e jne 402196 <rio_readlineb+0x4f> 402188: eb 1a jmp 4021a4 <rio_readlineb+0x5d> 40218a: 85 c0 test %eax,%eax 40218c: 75 22 jne 4021b0 <rio_readlineb+0x69> 40218e: 48 83 fb 01 cmp $0x1,%rbx 402192: 75 13 jne 4021a7 <rio_readlineb+0x60> 402194: eb 23 jmp 4021b9 <rio_readlineb+0x72> 402196: 48 83 c3 01 add $0x1,%rbx 40219a: 48 89 d5 mov %rdx,%rbp 40219d: 4c 39 e3 cmp %r12,%rbx 4021a0: 72 bf jb 402161 <rio_readlineb+0x1a> 4021a2: eb 03 jmp 4021a7 <rio_readlineb+0x60> 4021a4: 48 89 d5 mov %rdx,%rbp 4021a7: c6 45 00 00 movb $0x0,0x0(%rbp) 4021ab: 48 89 d8 mov %rbx,%rax 4021ae: eb 0e jmp 4021be <rio_readlineb+0x77> 4021b0: 48 c7 c0 ff ff ff ff mov $0xffffffffffffffff,%rax 4021b7: eb 05 jmp 4021be <rio_readlineb+0x77> 4021b9: b8 00 00 00 00 mov $0x0,%eax 4021be: 48 83 c4 18 add $0x18,%rsp 4021c2: 5b pop %rbx 4021c3: 5d pop %rbp 4021c4: 41 5c pop %r12 4021c6: 41 5d pop %r13 4021c8: c3 retq 00000000004021c9 <urlencode>: 4021c9: 41 54 push %r12 4021cb: 55 push %rbp 4021cc: 53 push %rbx 4021cd: 48 83 ec 10 sub $0x10,%rsp 4021d1: 48 89 fb mov %rdi,%rbx 4021d4: 48 89 f5 mov %rsi,%rbp 4021d7: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 4021de: 00 00 4021e0: 48 89 44 24 08 mov %rax,0x8(%rsp) 4021e5: 31 c0 xor %eax,%eax 4021e7: 48 c7 c1 ff ff ff ff mov $0xffffffffffffffff,%rcx 4021ee: f2 ae repnz scas %es:(%rdi),%al 4021f0: 48 f7 d1 not %rcx 4021f3: 8d 41 ff lea -0x1(%rcx),%eax 4021f6: e9 aa 00 00 00 jmpq 4022a5 <urlencode+0xdc> 4021fb: 44 0f b6 03 movzbl (%rbx),%r8d 4021ff: 41 80 f8 2a cmp $0x2a,%r8b 402203: 0f 94 c2 sete %dl 402206: 41 80 f8 2d cmp $0x2d,%r8b 40220a: 0f 94 c0 sete %al 40220d: 08 c2 or %al,%dl 40220f: 75 24 jne 402235 <urlencode+0x6c> 402211: 41 80 f8 2e cmp $0x2e,%r8b 402215: 74 1e je 402235 <urlencode+0x6c> 402217: 41 80 f8 5f cmp $0x5f,%r8b 40221b: 74 18 je 402235 <urlencode+0x6c> 40221d: 41 8d 40 d0 lea -0x30(%r8),%eax 402221: 3c 09 cmp $0x9,%al 402223: 76 10 jbe 402235 <urlencode+0x6c> 402225: 41 8d 40 bf lea -0x41(%r8),%eax 402229: 3c 19 cmp $0x19,%al 40222b: 76 08 jbe 402235 <urlencode+0x6c> 40222d: 41 8d 40 9f lea -0x61(%r8),%eax 402231: 3c 19 cmp $0x19,%al 402233: 77 0a ja 40223f <urlencode+0x76> 402235: 44 88 45 00 mov %r8b,0x0(%rbp) 402239: 48 8d 6d 01 lea 0x1(%rbp),%rbp 40223d: eb 5f jmp 40229e <urlencode+0xd5> 40223f: 41 80 f8 20 cmp $0x20,%r8b 402243: 75 0a jne 40224f <urlencode+0x86> 402245: c6 45 00 2b movb $0x2b,0x0(%rbp) 402249: 48 8d 6d 01 lea 0x1(%rbp),%rbp 40224d: eb 4f jmp 40229e <urlencode+0xd5> 40224f: 41 8d 40 e0 lea -0x20(%r8),%eax 402253: 3c 5f cmp $0x5f,%al 402255: 0f 96 c2 setbe %dl 402258: 41 80 f8 09 cmp $0x9,%r8b 40225c: 0f 94 c0 sete %al 40225f: 08 c2 or %al,%dl 402261: 74 50 je 4022b3 <urlencode+0xea> 402263: 45 0f b6 c0 movzbl %r8b,%r8d 402267: b9 58 35 40 00 mov $0x403558,%ecx 40226c: ba 08 00 00 00 mov $0x8,%edx 402271: be 01 00 00 00 mov $0x1,%esi 402276: 48 89 e7 mov %rsp,%rdi 402279: b8 00 00 00 00 mov $0x0,%eax 40227e: e8 ed eb ff ff callq 400e70 <__sprintf_chk@plt> 402283: 0f b6 04 24 movzbl (%rsp),%eax 402287: 88 45 00 mov %al,0x0(%rbp) 40228a: 0f b6 44 24 01 movzbl 0x1(%rsp),%eax 40228f: 88 45 01 mov %al,0x1(%rbp) 402292: 0f b6 44 24 02 movzbl 0x2(%rsp),%eax 402297: 88 45 02 mov %al,0x2(%rbp) 40229a: 48 8d 6d 03 lea 0x3(%rbp),%rbp 40229e: 48 83 c3 01 add $0x1,%rbx 4022a2: 44 89 e0 mov %r12d,%eax 4022a5: 44 8d 60 ff lea -0x1(%rax),%r12d 4022a9: 85 c0 test %eax,%eax 4022ab: 0f 85 4a ff ff ff jne 4021fb <urlencode+0x32> 4022b1: eb 05 jmp 4022b8 <urlencode+0xef> 4022b3: b8 ff ff ff ff mov $0xffffffff,%eax 4022b8: 48 8b 74 24 08 mov 0x8(%rsp),%rsi 4022bd: 64 48 33 34 25 28 00 xor %fs:0x28,%rsi 4022c4: 00 00 4022c6: 74 05 je 4022cd <urlencode+0x104> 4022c8: e8 13 ea ff ff callq 400ce0 <__stack_chk_fail@plt> 4022cd: 48 83 c4 10 add $0x10,%rsp 4022d1: 5b pop %rbx 4022d2: 5d pop %rbp 4022d3: 41 5c pop %r12 4022d5: c3 retq 00000000004022d6 <submitr>: 4022d6: 41 57 push %r15 4022d8: 41 56 push %r14 4022da: 41 55 push %r13 4022dc: 41 54 push %r12 4022de: 55 push %rbp 4022df: 53 push %rbx 4022e0: 48 81 ec 68 a0 00 00 sub $0xa068,%rsp 4022e7: 49 89 fc mov %rdi,%r12 4022ea: 89 74 24 14 mov %esi,0x14(%rsp) 4022ee: 49 89 d7 mov %rdx,%r15 4022f1: 49 89 ce mov %rcx,%r14 4022f4: 4c 89 44 24 18 mov %r8,0x18(%rsp) 4022f9: 4d 89 cd mov %r9,%r13 4022fc: 48 8b 9c 24 a0 a0 00 mov 0xa0a0(%rsp),%rbx 402303: 00 402304: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 40230b: 00 00 40230d: 48 89 84 24 58 a0 00 mov %rax,0xa058(%rsp) 402314: 00 402315: 31 c0 xor %eax,%eax 402317: c7 44 24 2c 00 00 00 movl $0x0,0x2c(%rsp) 40231e: 00 40231f: ba 00 00 00 00 mov $0x0,%edx 402324: be 01 00 00 00 mov $0x1,%esi 402329: bf 02 00 00 00 mov $0x2,%edi 40232e: e8 4d eb ff ff callq 400e80 <socket@plt> 402333: 89 c5 mov %eax,%ebp 402335: 85 c0 test %eax,%eax 402337: 79 4e jns 402387 <submitr+0xb1> 402339: 48 b8 45 72 72 6f 72 movabs $0x43203a726f727245,%rax 402340: 3a 20 43 402343: 48 89 03 mov %rax,(%rbx) 402346: 48 b8 6c 69 65 6e 74 movabs $0x6e7520746e65696c,%rax 40234d: 20 75 6e 402350: 48 89 43 08 mov %rax,0x8(%rbx) 402354: 48 b8 61 62 6c 65 20 movabs $0x206f7420656c6261,%rax 40235b: 74 6f 20 40235e: 48 89 43 10 mov %rax,0x10(%rbx) 402362: 48 b8 63 72 65 61 74 movabs $0x7320657461657263,%rax 402369: 65 20 73 40236c: 48 89 43 18 mov %rax,0x18(%rbx) 402370: c7 43 20 6f 63 6b 65 movl $0x656b636f,0x20(%rbx) 402377: 66 c7 43 24 74 00 movw $0x74,0x24(%rbx) 40237d: b8 ff ff ff ff mov $0xffffffff,%eax 402382: e9 4a 06 00 00 jmpq 4029d1 <submitr+0x6fb> 402387: 4c 89 e7 mov %r12,%rdi 40238a: e8 d1 e9 ff ff callq 400d60 <gethostbyname@plt> 40238f: 48 85 c0 test %rax,%rax 402392: 75 67 jne 4023fb <submitr+0x125> 402394: 48 b8 45 72 72 6f 72 movabs $0x44203a726f727245,%rax 40239b: 3a 20 44 40239e: 48 89 03 mov %rax,(%rbx) 4023a1: 48 b8 4e 53 20 69 73 movabs $0x6e7520736920534e,%rax 4023a8: 20 75 6e 4023ab: 48 89 43 08 mov %rax,0x8(%rbx) 4023af: 48 b8 61 62 6c 65 20 movabs $0x206f7420656c6261,%rax 4023b6: 74 6f 20 4023b9: 48 89 43 10 mov %rax,0x10(%rbx) 4023bd: 48 b8 72 65 73 6f 6c movabs $0x2065766c6f736572,%rax 4023c4: 76 65 20 4023c7: 48 89 43 18 mov %rax,0x18(%rbx) 4023cb: 48 b8 73 65 72 76 65 movabs $0x6120726576726573,%rax 4023d2: 72 20 61 4023d5: 48 89 43 20 mov %rax,0x20(%rbx) 4023d9: c7 43 28 64 64 72 65 movl $0x65726464,0x28(%rbx) 4023e0: 66 c7 43 2c 73 73 movw $0x7373,0x2c(%rbx) 4023e6: c6 43 2e 00 movb $0x0,0x2e(%rbx) 4023ea: 89 ef mov %ebp,%edi 4023ec: e8 2f e9 ff ff callq 400d20 <close@plt> 4023f1: b8 ff ff ff ff mov $0xffffffff,%eax 4023f6: e9 d6 05 00 00 jmpq 4029d1 <submitr+0x6fb> 4023fb: 48 c7 44 24 30 00 00 movq $0x0,0x30(%rsp) 402402: 00 00 402404: 48 c7 44 24 38 00 00 movq $0x0,0x38(%rsp) 40240b: 00 00 40240d: 66 c7 44 24 30 02 00 movw $0x2,0x30(%rsp) 402414: 48 63 50 14 movslq 0x14(%rax),%rdx 402418: 48 8b 40 18 mov 0x18(%rax),%rax 40241c: 48 8b 30 mov (%rax),%rsi 40241f: b9 0c 00 00 00 mov $0xc,%ecx 402424: 48 8d 7c 24 34 lea 0x34(%rsp),%rdi 402429: e8 42 e9 ff ff callq 400d70 <__memmove_chk@plt> 40242e: 0f b7 44 24 14 movzwl 0x14(%rsp),%eax 402433: 66 c1 c8 08 ror $0x8,%ax 402437: 66 89 44 24 32 mov %ax,0x32(%rsp) 40243c: ba 10 00 00 00 mov $0x10,%edx 402441: 48 8d 74 24 30 lea 0x30(%rsp),%rsi 402446: 89 ef mov %ebp,%edi 402448: e8 03 ea ff ff callq 400e50 <connect@plt> 40244d: 85 c0 test %eax,%eax 40244f: 79 59 jns 4024aa <submitr+0x1d4> 402451: 48 b8 45 72 72 6f 72 movabs $0x55203a726f727245,%rax 402458: 3a 20 55 40245b: 48 89 03 mov %rax,(%rbx) 40245e: 48 b8 6e 61 62 6c 65 movabs $0x6f7420656c62616e,%rax 402465: 20 74 6f 402468: 48 89 43 08 mov %rax,0x8(%rbx) 40246c: 48 b8 20 63 6f 6e 6e movabs $0x7463656e6e6f6320,%rax 402473: 65 63 74 402476: 48 89 43 10 mov %rax,0x10(%rbx) 40247a: 48 b8 20 74 6f 20 74 movabs $0x20656874206f7420,%rax 402481: 68 65 20 402484: 48 89 43 18 mov %rax,0x18(%rbx) 402488: c7 43 20 73 65 72 76 movl $0x76726573,0x20(%rbx) 40248f: 66 c7 43 24 65 72 movw $0x7265,0x24(%rbx) 402495: c6 43 26 00 movb $0x0,0x26(%rbx) 402499: 89 ef mov %ebp,%edi 40249b: e8 80 e8 ff ff callq 400d20 <close@plt> 4024a0: b8 ff ff ff ff mov $0xffffffff,%eax 4024a5: e9 27 05 00 00 jmpq 4029d1 <submitr+0x6fb> 4024aa: 48 c7 c2 ff ff ff ff mov $0xffffffffffffffff,%rdx 4024b1: 4c 89 ef mov %r13,%rdi 4024b4: b8 00 00 00 00 mov $0x0,%eax 4024b9: 48 89 d1 mov %rdx,%rcx 4024bc: f2 ae repnz scas %es:(%rdi),%al 4024be: 48 f7 d1 not %rcx 4024c1: 48 89 ce mov %rcx,%rsi 4024c4: 4c 89 ff mov %r15,%rdi 4024c7: 48 89 d1 mov %rdx,%rcx 4024ca: f2 ae repnz scas %es:(%rdi),%al 4024cc: 48 f7 d1 not %rcx 4024cf: 49 89 c8 mov %rcx,%r8 4024d2: 4c 89 f7 mov %r14,%rdi 4024d5: 48 89 d1 mov %rdx,%rcx 4024d8: f2 ae repnz scas %es:(%rdi),%al 4024da: 49 29 c8 sub %rcx,%r8 4024dd: 48 8b 7c 24 18 mov 0x18(%rsp),%rdi 4024e2: 48 89 d1 mov %rdx,%rcx 4024e5: f2 ae repnz scas %es:(%rdi),%al 4024e7: 49 29 c8 sub %rcx,%r8 4024ea: 48 8d 44 76 fd lea -0x3(%rsi,%rsi,2),%rax 4024ef: 49 8d 44 00 7b lea 0x7b(%r8,%rax,1),%rax 4024f4: 48 3d 00 20 00 00 cmp $0x2000,%rax 4024fa: 76 72 jbe 40256e <submitr+0x298> 4024fc: 48 b8 45 72 72 6f 72 movabs $0x52203a726f727245,%rax 402503: 3a 20 52 402506: 48 89 03 mov %rax,(%rbx) 402509: 48 b8 65 73 75 6c 74 movabs $0x747320746c757365,%rax 402510: 20 73 74 402513: 48 89 43 08 mov %rax,0x8(%rbx) 402517: 48 b8 72 69 6e 67 20 movabs $0x6f6f7420676e6972,%rax 40251e: 74 6f 6f 402521: 48 89 43 10 mov %rax,0x10(%rbx) 402525: 48 b8 20 6c 61 72 67 movabs $0x202e656772616c20,%rax 40252c: 65 2e 20 40252f: 48 89 43 18 mov %rax,0x18(%rbx) 402533: 48 b8 49 6e 63 72 65 movabs $0x6573616572636e49,%rax 40253a: 61 73 65 40253d: 48 89 43 20 mov %rax,0x20(%rbx) 402541: 48 b8 20 53 55 42 4d movabs $0x5254494d42555320,%rax 402548: 49 54 52 40254b: 48 89 43 28 mov %rax,0x28(%rbx) 40254f: 48 b8 5f 4d 41 58 42 movabs $0x46554258414d5f,%rax 402556: 55 46 00 402559: 48 89 43 30 mov %rax,0x30(%rbx) 40255d: 89 ef mov %ebp,%edi 40255f: e8 bc e7 ff ff callq 400d20 <close@plt> 402564: b8 ff ff ff ff mov $0xffffffff,%eax 402569: e9 63 04 00 00 jmpq 4029d1 <submitr+0x6fb> 40256e: 48 8d b4 24 40 20 00 lea 0x2040(%rsp),%rsi 402575: 00 402576: b9 00 04 00 00 mov $0x400,%ecx 40257b: b8 00 00 00 00 mov $0x0,%eax 402580: 48 89 f7 mov %rsi,%rdi 402583: f3 48 ab rep stos %rax,%es:(%rdi) 402586: 4c 89 ef mov %r13,%rdi 402589: e8 3b fc ff ff callq 4021c9 <urlencode> 40258e: 85 c0 test %eax,%eax 402590: 0f 89 8a 00 00 00 jns 402620 <submitr+0x34a> 402596: 48 b8 45 72 72 6f 72 movabs $0x52203a726f727245,%rax 40259d: 3a 20 52 4025a0: 48 89 03 mov %rax,(%rbx) 4025a3: 48 b8 65 73 75 6c 74 movabs $0x747320746c757365,%rax 4025aa: 20 73 74 4025ad: 48 89 43 08 mov %rax,0x8(%rbx) 4025b1: 48 b8 72 69 6e 67 20 movabs $0x6e6f6320676e6972,%rax 4025b8: 63 6f 6e 4025bb: 48 89 43 10 mov %rax,0x10(%rbx) 4025bf: 48 b8 74 61 69 6e 73 movabs $0x6e6120736e696174,%rax 4025c6: 20 61 6e 4025c9: 48 89 43 18 mov %rax,0x18(%rbx) 4025cd: 48 b8 20 69 6c 6c 65 movabs $0x6c6167656c6c6920,%rax 4025d4: 67 61 6c 4025d7: 48 89 43 20 mov %rax,0x20(%rbx) 4025db: 48 b8 20 6f 72 20 75 movabs $0x72706e7520726f20,%rax 4025e2: 6e 70 72 4025e5: 48 89 43 28 mov %rax,0x28(%rbx) 4025e9: 48 b8 69 6e 74 61 62 movabs $0x20656c6261746e69,%rax 4025f0: 6c 65 20 4025f3: 48 89 43 30 mov %rax,0x30(%rbx) 4025f7: 48 b8 63 68 61 72 61 movabs $0x6574636172616863,%rax 4025fe: 63 74 65 402601: 48 89 43 38 mov %rax,0x38(%rbx) 402605: 66 c7 43 40 72 2e movw $0x2e72,0x40(%rbx) 40260b: c6 43 42 00 movb $0x0,0x42(%rbx) 40260f: 89 ef mov %ebp,%edi 402611: e8 0a e7 ff ff callq 400d20 <close@plt> 402616: b8 ff ff ff ff mov $0xffffffff,%eax 40261b: e9 b1 03 00 00 jmpq 4029d1 <submitr+0x6fb> 402620: 4c 89 64 24 08 mov %r12,0x8(%rsp) 402625: 48 8d 84 24 40 20 00 lea 0x2040(%rsp),%rax 40262c: 00 40262d: 48 89 04 24 mov %rax,(%rsp) 402631: 4d 89 f9 mov %r15,%r9 402634: 4d 89 f0 mov %r14,%r8 402637: b9 e8 34 40 00 mov $0x4034e8,%ecx 40263c: ba 00 20 00 00 mov $0x2000,%edx 402641: be 01 00 00 00 mov $0x1,%esi 402646: 48 8d 7c 24 40 lea 0x40(%rsp),%rdi 40264b: b8 00 00 00 00 mov $0x0,%eax 402650: e8 1b e8 ff ff callq 400e70 <__sprintf_chk@plt> 402655: 48 8d 7c 24 40 lea 0x40(%rsp),%rdi 40265a: b8 00 00 00 00 mov $0x0,%eax 40265f: 48 c7 c1 ff ff ff ff mov $0xffffffffffffffff,%rcx 402666: f2 ae repnz scas %es:(%rdi),%al 402668: 48 f7 d1 not %rcx 40266b: 48 8d 51 ff lea -0x1(%rcx),%rdx 40266f: 48 8d 74 24 40 lea 0x40(%rsp),%rsi 402674: 89 ef mov %ebp,%edi 402676: e8 e5 f9 ff ff callq 402060 <rio_writen> 40267b: 48 85 c0 test %rax,%rax 40267e: 79 6e jns 4026ee <submitr+0x418> 402680: 48 b8 45 72 72 6f 72 movabs $0x43203a726f727245,%rax 402687: 3a 20 43 40268a: 48 89 03 mov %rax,(%rbx) 40268d: 48 b8 6c 69 65 6e 74 movabs $0x6e7520746e65696c,%rax 402694: 20 75 6e 402697: 48 89 43 08 mov %rax,0x8(%rbx) 40269b: 48 b8 61 62 6c 65 20 movabs $0x206f7420656c6261,%rax 4026a2: 74 6f 20 4026a5: 48 89 43 10 mov %rax,0x10(%rbx) 4026a9: 48 b8 77 72 69 74 65 movabs $0x6f74206574697277,%rax 4026b0: 20 74 6f 4026b3: 48 89 43 18 mov %rax,0x18(%rbx) 4026b7: 48 b8 20 74 68 65 20 movabs $0x7365722065687420,%rax 4026be: 72 65 73 4026c1: 48 89 43 20 mov %rax,0x20(%rbx) 4026c5: 48 b8 75 6c 74 20 73 movabs $0x7672657320746c75,%rax 4026cc: 65 72 76 4026cf: 48 89 43 28 mov %rax,0x28(%rbx) 4026d3: 66 c7 43 30 65 72 movw $0x7265,0x30(%rbx) 4026d9: c6 43 32 00 movb $0x0,0x32(%rbx) 4026dd: 89 ef mov %ebp,%edi 4026df: e8 3c e6 ff ff callq 400d20 <close@plt> 4026e4: b8 ff ff ff ff mov $0xffffffff,%eax 4026e9: e9 e3 02 00 00 jmpq 4029d1 <submitr+0x6fb> 4026ee: 89 ee mov %ebp,%esi 4026f0: 48 8d bc 24 40 80 00 lea 0x8040(%rsp),%rdi 4026f7: 00 4026f8: e8 23 f9 ff ff callq 402020 <rio_readinitb> 4026fd: ba 00 20 00 00 mov $0x2000,%edx 402702: 48 8d 74 24 40 lea 0x40(%rsp),%rsi 402707: 48 8d bc 24 40 80 00 lea 0x8040(%rsp),%rdi 40270e: 00 40270f: e8 33 fa ff ff callq 402147 <rio_readlineb> 402714: 48 85 c0 test %rax,%rax 402717: 7f 7d jg 402796 <submitr+0x4c0> 402719: 48 b8 45 72 72 6f 72 movabs $0x43203a726f727245,%rax 402720: 3a 20 43 402723: 48 89 03 mov %rax,(%rbx) 402726: 48 b8 6c 69 65 6e 74 movabs $0x6e7520746e65696c,%rax 40272d: 20 75 6e 402730: 48 89 43 08 mov %rax,0x8(%rbx) 402734: 48 b8 61 62 6c 65 20 movabs $0x206f7420656c6261,%rax 40273b: 74 6f 20 40273e: 48 89 43 10 mov %rax,0x10(%rbx) 402742: 48 b8 72 65 61 64 20 movabs $0x7269662064616572,%rax 402749: 66 69 72 40274c: 48 89 43 18 mov %rax,0x18(%rbx) 402750: 48 b8 73 74 20 68 65 movabs $0x6564616568207473,%rax 402757: 61 64 65 40275a: 48 89 43 20 mov %rax,0x20(%rbx) 40275e: 48 b8 72 20 66 72 6f movabs $0x72206d6f72662072,%rax 402765: 6d 20 72 402768: 48 89 43 28 mov %rax,0x28(%rbx) 40276c: 48 b8 65 73 75 6c 74 movabs $0x657320746c757365,%rax 402773: 20 73 65 402776: 48 89 43 30 mov %rax,0x30(%rbx) 40277a: c7 43 38 72 76 65 72 movl $0x72657672,0x38(%rbx) 402781: c6 43 3c 00 movb $0x0,0x3c(%rbx) 402785: 89 ef mov %ebp,%edi 402787: e8 94 e5 ff ff callq 400d20 <close@plt> 40278c: b8 ff ff ff ff mov $0xffffffff,%eax 402791: e9 3b 02 00 00 jmpq 4029d1 <submitr+0x6fb> 402796: 4c 8d 84 24 40 60 00 lea 0x6040(%rsp),%r8 40279d: 00 40279e: 48 8d 4c 24 2c lea 0x2c(%rsp),%rcx 4027a3: 48 8d 94 24 40 40 00 lea 0x4040(%rsp),%rdx 4027aa: 00 4027ab: be 5f 35 40 00 mov $0x40355f,%esi 4027b0: 48 8d 7c 24 40 lea 0x40(%rsp),%rdi 4027b5: b8 00 00 00 00 mov $0x0,%eax 4027ba: e8 11 e6 ff ff callq 400dd0 <__isoc99_sscanf@plt> 4027bf: e9 95 00 00 00 jmpq 402859 <submitr+0x583> 4027c4: ba 00 20 00 00 mov $0x2000,%edx 4027c9: 48 8d 74 24 40 lea 0x40(%rsp),%rsi 4027ce: 48 8d bc 24 40 80 00 lea 0x8040(%rsp),%rdi 4027d5: 00 4027d6: e8 6c f9 ff ff callq 402147 <rio_readlineb> 4027db: 48 85 c0 test %rax,%rax 4027de: 7f 79 jg 402859 <submitr+0x583> 4027e0: 48 b8 45 72 72 6f 72 movabs $0x43203a726f727245,%rax 4027e7: 3a 20 43 4027ea: 48 89 03 mov %rax,(%rbx) 4027ed: 48 b8 6c 69 65 6e 74 movabs $0x6e7520746e65696c,%rax 4027f4: 20 75 6e 4027f7: 48 89 43 08 mov %rax,0x8(%rbx) 4027fb: 48 b8 61 62 6c 65 20 movabs $0x206f7420656c6261,%rax 402802: 74 6f 20 402805: 48 89 43 10 mov %rax,0x10(%rbx) 402809: 48 b8 72 65 61 64 20 movabs $0x6165682064616572,%rax 402810: 68 65 61 402813: 48 89 43 18 mov %rax,0x18(%rbx) 402817: 48 b8 64 65 72 73 20 movabs $0x6f72662073726564,%rax 40281e: 66 72 6f 402821: 48 89 43 20 mov %rax,0x20(%rbx) 402825: 48 b8 6d 20 74 68 65 movabs $0x657220656874206d,%rax 40282c: 20 72 65 40282f: 48 89 43 28 mov %rax,0x28(%rbx) 402833: 48 b8 73 75 6c 74 20 movabs $0x72657320746c7573,%rax 40283a: 73 65 72 40283d: 48 89 43 30 mov %rax,0x30(%rbx) 402841: c7 43 38 76 65 72 00 movl $0x726576,0x38(%rbx) 402848: 89 ef mov %ebp,%edi 40284a: e8 d1 e4 ff ff callq 400d20 <close@plt> 40284f: b8 ff ff ff ff mov $0xffffffff,%eax 402854: e9 78 01 00 00 jmpq 4029d1 <submitr+0x6fb> 402859: 0f b6 44 24 40 movzbl 0x40(%rsp),%eax 40285e: 83 e8 0d sub $0xd,%eax 402861: 75 0f jne 402872 <submitr+0x59c> 402863: 0f b6 44 24 41 movzbl 0x41(%rsp),%eax 402868: 83 e8 0a sub $0xa,%eax 40286b: 75 05 jne 402872 <submitr+0x59c> 40286d: 0f b6 44 24 42 movzbl 0x42(%rsp),%eax 402872: 85 c0 test %eax,%eax 402874: 0f 85 4a ff ff ff jne 4027c4 <submitr+0x4ee> 40287a: ba 00 20 00 00 mov $0x2000,%edx 40287f: 48 8d 74 24 40 lea 0x40(%rsp),%rsi 402884: 48 8d bc 24 40 80 00 lea 0x8040(%rsp),%rdi 40288b: 00 40288c: e8 b6 f8 ff ff callq 402147 <rio_readlineb> 402891: 48 85 c0 test %rax,%rax 402894: 0f 8f 83 00 00 00 jg 40291d <submitr+0x647> 40289a: 48 b8 45 72 72 6f 72 movabs $0x43203a726f727245,%rax 4028a1: 3a 20 43 4028a4: 48 89 03 mov %rax,(%rbx) 4028a7: 48 b8 6c 69 65 6e 74 movabs $0x6e7520746e65696c,%rax 4028ae: 20 75 6e 4028b1: 48 89 43 08 mov %rax,0x8(%rbx) 4028b5: 48 b8 61 62 6c 65 20 movabs $0x206f7420656c6261,%rax 4028bc: 74 6f 20 4028bf: 48 89 43 10 mov %rax,0x10(%rbx) 4028c3: 48 b8 72 65 61 64 20 movabs $0x6174732064616572,%rax 4028ca: 73 74 61 4028cd: 48 89 43 18 mov %rax,0x18(%rbx) 4028d1: 48 b8 74 75 73 20 6d movabs $0x7373656d20737574,%rax 4028d8: 65 73 73 4028db: 48 89 43 20 mov %rax,0x20(%rbx) 4028df: 48 b8 61 67 65 20 66 movabs $0x6d6f726620656761,%rax 4028e6: 72 6f 6d 4028e9: 48 89 43 28 mov %rax,0x28(%rbx) 4028ed: 48 b8 20 72 65 73 75 movabs $0x20746c7573657220,%rax 4028f4: 6c 74 20 4028f7: 48 89 43 30 mov %rax,0x30(%rbx) 4028fb: c7 43 38 73 65 72 76 movl $0x76726573,0x38(%rbx) 402902: 66 c7 43 3c 65 72 movw $0x7265,0x3c(%rbx) 402908: c6 43 3e 00 movb $0x0,0x3e(%rbx) 40290c: 89 ef mov %ebp,%edi 40290e: e8 0d e4 ff ff callq 400d20 <close@plt> 402913: b8 ff ff ff ff mov $0xffffffff,%eax 402918: e9 b4 00 00 00 jmpq 4029d1 <submitr+0x6fb> 40291d: 44 8b 44 24 2c mov 0x2c(%rsp),%r8d 402922: 41 81 f8 c8 00 00 00 cmp $0xc8,%r8d 402929: 74 34 je 40295f <submitr+0x689> 40292b: 4c 8d 8c 24 40 60 00 lea 0x6040(%rsp),%r9 402932: 00 402933: b9 28 35 40 00 mov $0x403528,%ecx 402938: 48 c7 c2 ff ff ff ff mov $0xffffffffffffffff,%rdx 40293f: be 01 00 00 00 mov $0x1,%esi 402944: 48 89 df mov %rbx,%rdi 402947: b8 00 00 00 00 mov $0x0,%eax 40294c: e8 1f e5 ff ff callq 400e70 <__sprintf_chk@plt> 402951: 89 ef mov %ebp,%edi 402953: e8 c8 e3 ff ff callq 400d20 <close@plt> 402958: b8 ff ff ff ff mov $0xffffffff,%eax 40295d: eb 72 jmp 4029d1 <submitr+0x6fb> 40295f: 48 8d 74 24 40 lea 0x40(%rsp),%rsi 402964: 48 89 df mov %rbx,%rdi 402967: e8 44 e3 ff ff callq 400cb0 <strcpy@plt> 40296c: 89 ef mov %ebp,%edi 40296e: e8 ad e3 ff ff callq 400d20 <close@plt> 402973: 0f b6 13 movzbl (%rbx),%edx 402976: 83 ea 4f sub $0x4f,%edx 402979: 89 d1 mov %edx,%ecx 40297b: 85 d2 test %edx,%edx 40297d: 75 16 jne 402995 <submitr+0x6bf> 40297f: 0f b6 4b 01 movzbl 0x1(%rbx),%ecx 402983: 83 e9 4b sub $0x4b,%ecx 402986: 75 0d jne 402995 <submitr+0x6bf> 402988: 0f b6 4b 02 movzbl 0x2(%rbx),%ecx 40298c: 83 e9 0a sub $0xa,%ecx 40298f: 75 04 jne 402995 <submitr+0x6bf> 402991: 0f b6 4b 03 movzbl 0x3(%rbx),%ecx 402995: b8 00 00 00 00 mov $0x0,%eax 40299a: 85 c9 test %ecx,%ecx 40299c: 74 33 je 4029d1 <submitr+0x6fb> 40299e: bf 70 35 40 00 mov $0x403570,%edi 4029a3: b9 05 00 00 00 mov $0x5,%ecx 4029a8: 48 89 de mov %rbx,%rsi 4029ab: f3 a6 repz cmpsb %es:(%rdi),%ds:(%rsi) 4029ad: 40 0f 97 c6 seta %sil 4029b1: 0f 92 c1 setb %cl 4029b4: 40 38 ce cmp %cl,%sil 4029b7: 74 18 je 4029d1 <submitr+0x6fb> 4029b9: 85 d2 test %edx,%edx 4029bb: 75 0d jne 4029ca <submitr+0x6f4> 4029bd: 0f b6 53 01 movzbl 0x1(%rbx),%edx 4029c1: 83 ea 4b sub $0x4b,%edx 4029c4: 75 04 jne 4029ca <submitr+0x6f4> 4029c6: 0f b6 53 02 movzbl 0x2(%rbx),%edx 4029ca: 83 fa 01 cmp $0x1,%edx 4029cd: 19 c0 sbb %eax,%eax 4029cf: f7 d0 not %eax 4029d1: 48 8b 9c 24 58 a0 00 mov 0xa058(%rsp),%rbx 4029d8: 00 4029d9: 64 48 33 1c 25 28 00 xor %fs:0x28,%rbx 4029e0: 00 00 4029e2: 74 05 je 4029e9 <submitr+0x713> 4029e4: e8 f7 e2 ff ff callq 400ce0 <__stack_chk_fail@plt> 4029e9: 48 81 c4 68 a0 00 00 add $0xa068,%rsp 4029f0: 5b pop %rbx 4029f1: 5d pop %rbp 4029f2: 41 5c pop %r12 4029f4: 41 5d pop %r13 4029f6: 41 5e pop %r14 4029f8: 41 5f pop %r15 4029fa: c3 retq 00000000004029fb <init_timeout>: 4029fb: 53 push %rbx 4029fc: 89 fb mov %edi,%ebx 4029fe: 85 ff test %edi,%edi 402a00: 74 20 je 402a22 <init_timeout+0x27> 402a02: 85 ff test %edi,%edi 402a04: b8 00 00 00 00 mov $0x0,%eax 402a09: 0f 48 d8 cmovs %eax,%ebx 402a0c: be 32 20 40 00 mov $0x402032,%esi 402a11: bf 0e 00 00 00 mov $0xe,%edi 402a16: e8 35 e3 ff ff callq 400d50 <signal@plt> 402a1b: 89 df mov %ebx,%edi 402a1d: e8 ee e2 ff ff callq 400d10 <alarm@plt> 402a22: 5b pop %rbx 402a23: c3 retq 0000000000402a24 <init_driver>: 402a24: 55 push %rbp 402a25: 53 push %rbx 402a26: 48 83 ec 28 sub $0x28,%rsp 402a2a: 48 89 fd mov %rdi,%rbp 402a2d: 64 48 8b 04 25 28 00 mov %fs:0x28,%rax 402a34: 00 00 402a36: 48 89 44 24 18 mov %rax,0x18(%rsp) 402a3b: 31 c0 xor %eax,%eax 402a3d: be 01 00 00 00 mov $0x1,%esi 402a42: bf 0d 00 00 00 mov $0xd,%edi 402a47: e8 04 e3 ff ff callq 400d50 <signal@plt> 402a4c: be 01 00 00 00 mov $0x1,%esi 402a51: bf 1d 00 00 00 mov $0x1d,%edi 402a56: e8 f5 e2 ff ff callq 400d50 <signal@plt> 402a5b: be 01 00 00 00 mov $0x1,%esi 402a60: bf 1d 00 00 00 mov $0x1d,%edi 402a65: e8 e6 e2 ff ff callq 400d50 <signal@plt> 402a6a: ba 00 00 00 00 mov $0x0,%edx 402a6f: be 01 00 00 00 mov $0x1,%esi 402a74: bf 02 00 00 00 mov $0x2,%edi 402a79: e8 02 e4 ff ff callq 400e80 <socket@plt> 402a7e: 89 c3 mov %eax,%ebx 402a80: 85 c0 test %eax,%eax 402a82: 79 4f jns 402ad3 <init_driver+0xaf> 402a84: 48 b8 45 72 72 6f 72 movabs $0x43203a726f727245,%rax 402a8b: 3a 20 43 402a8e: 48 89 45 00 mov %rax,0x0(%rbp) 402a92: 48 b8 6c 69 65 6e 74 movabs $0x6e7520746e65696c,%rax 402a99: 20 75 6e 402a9c: 48 89 45 08 mov %rax,0x8(%rbp) 402aa0: 48 b8 61 62 6c 65 20 movabs $0x206f7420656c6261,%rax 402aa7: 74 6f 20 402aaa: 48 89 45 10 mov %rax,0x10(%rbp) 402aae: 48 b8 63 72 65 61 74 movabs $0x7320657461657263,%rax 402ab5: 65 20 73 402ab8: 48 89 45 18 mov %rax,0x18(%rbp) 402abc: c7 45 20 6f 63 6b 65 movl $0x656b636f,0x20(%rbp) 402ac3: 66 c7 45 24 74 00 movw $0x74,0x24(%rbp) 402ac9: b8 ff ff ff ff mov $0xffffffff,%eax 402ace: e9 28 01 00 00 jmpq 402bfb <init_driver+0x1d7> 402ad3: bf 75 35 40 00 mov $0x403575,%edi 402ad8: e8 83 e2 ff ff callq 400d60 <gethostbyname@plt> 402add: 48 85 c0 test %rax,%rax 402ae0: 75 68 jne 402b4a <init_driver+0x126> 402ae2: 48 b8 45 72 72 6f 72 movabs $0x44203a726f727245,%rax 402ae9: 3a 20 44 402aec: 48 89 45 00 mov %rax,0x0(%rbp) 402af0: 48 b8 4e 53 20 69 73 movabs $0x6e7520736920534e,%rax 402af7: 20 75 6e 402afa: 48 89 45 08 mov %rax,0x8(%rbp) 402afe: 48 b8 61 62 6c 65 20 movabs $0x206f7420656c6261,%rax 402b05: 74 6f 20 402b08: 48 89 45 10 mov %rax,0x10(%rbp) 402b0c: 48 b8 72 65 73 6f 6c movabs $0x2065766c6f736572,%rax 402b13: 76 65 20 402b16: 48 89 45 18 mov %rax,0x18(%rbp) 402b1a: 48 b8 73 65 72 76 65 movabs $0x6120726576726573,%rax 402b21: 72 20 61 402b24: 48 89 45 20 mov %rax,0x20(%rbp) 402b28: c7 45 28 64 64 72 65 movl $0x65726464,0x28(%rbp) 402b2f: 66 c7 45 2c 73 73 movw $0x7373,0x2c(%rbp) 402b35: c6 45 2e 00 movb $0x0,0x2e(%rbp) 402b39: 89 df mov %ebx,%edi 402b3b: e8 e0 e1 ff ff callq 400d20 <close@plt> 402b40: b8 ff ff ff ff mov $0xffffffff,%eax 402b45: e9 b1 00 00 00 jmpq 402bfb <init_driver+0x1d7> 402b4a: 48 c7 04 24 00 00 00 movq $0x0,(%rsp) 402b51: 00 402b52: 48 c7 44 24 08 00 00 movq $0x0,0x8(%rsp) 402b59: 00 00 402b5b: 66 c7 04 24 02 00 movw $0x2,(%rsp) 402b61: 48 63 50 14 movslq 0x14(%rax),%rdx 402b65: 48 8b 40 18 mov 0x18(%rax),%rax 402b69: 48 8b 30 mov (%rax),%rsi 402b6c: 48 8d 7c 24 04 lea 0x4(%rsp),%rdi 402b71: b9 0c 00 00 00 mov $0xc,%ecx 402b76: e8 f5 e1 ff ff callq 400d70 <__memmove_chk@plt> 402b7b: 66 c7 44 24 02 3c 9a movw $0x9a3c,0x2(%rsp) 402b82: ba 10 00 00 00 mov $0x10,%edx 402b87: 48 89 e6 mov %rsp,%rsi 402b8a: 89 df mov %ebx,%edi 402b8c: e8 bf e2 ff ff callq 400e50 <connect@plt> 402b91: 85 c0 test %eax,%eax 402b93: 79 50 jns 402be5 <init_driver+0x1c1> 402b95: 48 b8 45 72 72 6f 72 movabs $0x55203a726f727245,%rax 402b9c: 3a 20 55 402b9f: 48 89 45 00 mov %rax,0x0(%rbp) 402ba3: 48 b8 6e 61 62 6c 65 movabs $0x6f7420656c62616e,%rax 402baa: 20 74 6f 402bad: 48 89 45 08 mov %rax,0x8(%rbp) 402bb1: 48 b8 20 63 6f 6e 6e movabs $0x7463656e6e6f6320,%rax 402bb8: 65 63 74 402bbb: 48 89 45 10 mov %rax,0x10(%rbp) 402bbf: 48 b8 20 74 6f 20 73 movabs $0x76726573206f7420,%rax 402bc6: 65 72 76 402bc9: 48 89 45 18 mov %rax,0x18(%rbp) 402bcd: 66 c7 45 20 65 72 movw $0x7265,0x20(%rbp) 402bd3: c6 45 22 00 movb $0x0,0x22(%rbp) 402bd7: 89 df mov %ebx,%edi 402bd9: e8 42 e1 ff ff callq 400d20 <close@plt> 402bde: b8 ff ff ff ff mov $0xffffffff,%eax 402be3: eb 16 jmp 402bfb <init_driver+0x1d7> 402be5: 89 df mov %ebx,%edi 402be7: e8 34 e1 ff ff callq 400d20 <close@plt> 402bec: 66 c7 45 00 4f 4b movw $0x4b4f,0x0(%rbp) 402bf2: c6 45 02 00 movb $0x0,0x2(%rbp) 402bf6: b8 00 00 00 00 mov $0x0,%eax 402bfb: 48 8b 4c 24 18 mov 0x18(%rsp),%rcx 402c00: 64 48 33 0c 25 28 00 xor %fs:0x28,%rcx 402c07: 00 00 402c09: 74 05 je 402c10 <init_driver+0x1ec> 402c0b: e8 d0 e0 ff ff callq 400ce0 <__stack_chk_fail@plt> 402c10: 48 83 c4 28 add $0x28,%rsp 402c14: 5b pop %rbx 402c15: 5d pop %rbp 402c16: c3 retq 0000000000402c17 <driver_post>: 402c17: 53 push %rbx 402c18: 48 83 ec 10 sub $0x10,%rsp 402c1c: 4c 89 cb mov %r9,%rbx 402c1f: 45 85 c0 test %r8d,%r8d 402c22: 74 27 je 402c4b <driver_post+0x34> 402c24: 48 89 ca mov %rcx,%rdx 402c27: be 8d 35 40 00 mov $0x40358d,%esi 402c2c: bf 01 00 00 00 mov $0x1,%edi 402c31: b8 00 00 00 00 mov $0x0,%eax 402c36: e8 b5 e1 ff ff callq 400df0 <__printf_chk@plt> 402c3b: 66 c7 03 4f 4b movw $0x4b4f,(%rbx) 402c40: c6 43 02 00 movb $0x0,0x2(%rbx) 402c44: b8 00 00 00 00 mov $0x0,%eax 402c49: eb 39 jmp 402c84 <driver_post+0x6d> 402c4b: 48 85 ff test %rdi,%rdi 402c4e: 74 26 je 402c76 <driver_post+0x5f> 402c50: 80 3f 00 cmpb $0x0,(%rdi) 402c53: 74 21 je 402c76 <driver_post+0x5f> 402c55: 4c 89 0c 24 mov %r9,(%rsp) 402c59: 49 89 c9 mov %rcx,%r9 402c5c: 49 89 d0 mov %rdx,%r8 402c5f: 48 89 f9 mov %rdi,%rcx 402c62: 48 89 f2 mov %rsi,%rdx 402c65: be 9a 3c 00 00 mov $0x3c9a,%esi 402c6a: bf 75 35 40 00 mov $0x403575,%edi 402c6f: e8 62 f6 ff ff callq 4022d6 <submitr> 402c74: eb 0e jmp 402c84 <driver_post+0x6d> 402c76: 66 c7 03 4f 4b movw $0x4b4f,(%rbx) 402c7b: c6 43 02 00 movb $0x0,0x2(%rbx) 402c7f: b8 00 00 00 00 mov $0x0,%eax 402c84: 48 83 c4 10 add $0x10,%rsp 402c88: 5b pop %rbx 402c89: c3 retq 402c8a: 90 nop 402c8b: 90 nop 0000000000402c8c <check>: 402c8c: 89 fa mov %edi,%edx 402c8e: c1 ea 1c shr $0x1c,%edx 402c91: b8 00 00 00 00 mov $0x0,%eax 402c96: b9 00 00 00 00 mov $0x0,%ecx 402c9b: 85 d2 test %edx,%edx 402c9d: 75 0d jne 402cac <check+0x20> 402c9f: eb 1b jmp 402cbc <check+0x30> 402ca1: 89 f8 mov %edi,%eax 402ca3: d3 e8 shr %cl,%eax 402ca5: 3c 0a cmp $0xa,%al 402ca7: 74 0e je 402cb7 <check+0x2b> 402ca9: 83 c1 08 add $0x8,%ecx 402cac: 83 f9 1f cmp $0x1f,%ecx 402caf: 7e f0 jle 402ca1 <check+0x15> 402cb1: b8 01 00 00 00 mov $0x1,%eax 402cb6: c3 retq 402cb7: b8 00 00 00 00 mov $0x0,%eax 402cbc: f3 c3 repz retq 0000000000402cbe <gencookie>: 402cbe: 53 push %rbx 402cbf: 83 c7 01 add $0x1,%edi 402cc2: e8 c9 df ff ff callq 400c90 <srandom@plt> 402cc7: e8 e4 e0 ff ff callq 400db0 <random@plt> 402ccc: 89 c3 mov %eax,%ebx 402cce: 89 c7 mov %eax,%edi 402cd0: e8 b7 ff ff ff callq 402c8c <check> 402cd5: 85 c0 test %eax,%eax 402cd7: 74 ee je 402cc7 <gencookie+0x9> 402cd9: 89 d8 mov %ebx,%eax 402cdb: 5b pop %rbx 402cdc: c3 retq 402cdd: 90 nop 402cde: 90 nop 402cdf: 90 nop 0000000000402ce0 <__libc_csu_init>: 402ce0: 48 89 6c 24 d8 mov %rbp,-0x28(%rsp) 402ce5: 4c 89 64 24 e0 mov %r12,-0x20(%rsp) 402cea: 48 8d 2d 0f 11 20 00 lea 0x20110f(%rip),%rbp # 603e00 <__init_array_end> 402cf1: 4c 8d 25 00 11 20 00 lea 0x201100(%rip),%r12 # 603df8 <__frame_dummy_init_array_entry> 402cf8: 4c 89 6c 24 e8 mov %r13,-0x18(%rsp) 402cfd: 4c 89 74 24 f0 mov %r14,-0x10(%rsp) 402d02: 4c 89 7c 24 f8 mov %r15,-0x8(%rsp) 402d07: 48 89 5c 24 d0 mov %rbx,-0x30(%rsp) 402d0c: 48 83 ec 38 sub $0x38,%rsp 402d10: 4c 29 e5 sub %r12,%rbp 402d13: 41 89 fd mov %edi,%r13d 402d16: 49 89 f6 mov %rsi,%r14 402d19: 48 c1 fd 03 sar $0x3,%rbp 402d1d: 49 89 d7 mov %rdx,%r15 402d20: e8 23 df ff ff callq 400c48 <_init> 402d25: 48 85 ed test %rbp,%rbp 402d28: 74 1c je 402d46 <__libc_csu_init+0x66> 402d2a: 31 db xor %ebx,%ebx 402d2c: 0f 1f 40 00 nopl 0x0(%rax) 402d30: 4c 89 fa mov %r15,%rdx 402d33: 4c 89 f6 mov %r14,%rsi 402d36: 44 89 ef mov %r13d,%edi 402d39: 41 ff 14 dc callq *(%r12,%rbx,8) 402d3d: 48 83 c3 01 add $0x1,%rbx 402d41: 48 39 eb cmp %rbp,%rbx 402d44: 75 ea jne 402d30 <__libc_csu_init+0x50> 402d46: 48 8b 5c 24 08 mov 0x8(%rsp),%rbx 402d4b: 48 8b 6c 24 10 mov 0x10(%rsp),%rbp 402d50: 4c 8b 64 24 18 mov 0x18(%rsp),%r12 402d55: 4c 8b 6c 24 20 mov 0x20(%rsp),%r13 402d5a: 4c 8b 74 24 28 mov 0x28(%rsp),%r14 402d5f: 4c 8b 7c 24 30 mov 0x30(%rsp),%r15 402d64: 48 83 c4 38 add $0x38,%rsp 402d68: c3 retq 402d69: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 0000000000402d70 <__libc_csu_fini>: 402d70: f3 c3 repz retq 402d72: 90 nop 402d73: 90 nop Disassembly of section .fini: 0000000000402d74 <_fini>: 402d74: 48 83 ec 08 sub $0x8,%rsp 402d78: 48 83 c4 08 add $0x8,%rsp 402d7c: c3 retq
.686 .model flat .xmm .code _test proc push ebp mov ebp,esp sub esp,104 push edi push esi ; start of inline function test1 mov eax,256 imul eax,512 sub eax,131072 ; end of inline function test1 cmp eax,0 je label0000 mov eax,1 pop esi pop edi add esp,104 pop ebp ret label0000: ; start of inline function test2 mov eax,555 add eax,666 sub eax,1221 ; end of inline function test2 cmp eax,0 je label0001 mov eax,2 pop esi pop edi add esp,104 pop ebp ret label0001: ; start of inline function test3 mov edi,444 mov esi,222 mov eax,esi cmp edi,0 jle label0007 mov esi,111 jmp label0008 label0007: mov eax,edi label0008: add eax,esi add eax,111 sub eax,edi ; end of inline function test3 cmp eax,0 je label0002 mov eax,3 pop esi pop edi add esp,104 pop ebp ret label0002: ; start of inline function test4 mov edi,5 inc edi add edi,4 sub edi,10 ; end of inline function test4 cmp edi,0 je label0003 mov eax,4 pop esi pop edi add esp,104 pop ebp ret label0003: ; start of inline function test5 mov edi,888 cmp edi,0 jle label000b mov esi,444 jmp label000c label000b: mov esi,222 label000c: add esi,444 sub esi,edi ; end of inline function test5 cmp esi,0 je label0004 mov eax,3 pop esi pop edi add esp,104 pop ebp ret label0004: mov eax,0 pop esi pop edi add esp,104 pop ebp ret _test endp end
extern setAttr public _printChar public print public printAttr public printChar public font section CODE_4 #include "defs.inc" ; ; Display a char at the specified location. ; Callable from 'C', parameters are passed on ; the stack. ; defvars 0 ; Define the stack variables used { yPos ds.b 2 xPos ds.b 2 char ds.b 2 } _printChar: entry ld b, (ix+yPos) ld c, (ix+xPos) ld a, (ix+char) call printChar exit ret ; ; Display a string with attributes. ; ; Entry: ; hl - Pointer to string ; b - Y screen start position ; c - X screen start position ; a - Screen attributes ; ; Exit: ; hl - Points to the memory location following the strings ; null terminator. ; c - Screen X position following the string ; printAttr: push af push de ld e, a L1b: ld a, (hl) inc hl or a jr z, L1f call printChar ld a, e call setAttr inc c jr L1b L1f: pop de pop af ret ; ; Display a string. ; ; Entry: ; hl - Pointer to string ; b - Y screen start position ; c - X screen start position ; ; Exit: ; hl - Points to the memory location following the strings ; null terminator. ; c - Screen X position following the string ; print: push af L2b: ld a, (hl) inc hl or a jr z, L2f call printChar inc c jr L2b L2f: pop af ret ; ; Display a character at the specified position. ; ; Input: ; b - Y character position ; c - X character position ; a - Character to display ; printChar: push af push bc push hl IF _ZXN extern displayTile ; Clear the tile over the character ld l, a ld a, ID_BLANK call displayTile ld a, l ENDIF sub ' ' ; Font data starts at <SPACE> ld l, a ; Get char to display ld h, 0 hlx 8 outChar font pop hl pop bc pop af ret section RODATA_4 font: binary "Torment.ch8" ; Sad face ASCII 0x80 (128) defb 60 defb 66 defb 165 defb 129 defb 153 defb 165 defb 66 defb 60
<% from pwnlib.shellcraft.i386.linux import syscall %> <%page args="timerid, value"/> <%docstring> Invokes the syscall timer_gettime. See 'man 2 timer_gettime' for more information. Arguments: timerid(timer_t): timerid value(itimerspec): value </%docstring> ${syscall('SYS_timer_gettime', timerid, value)}
; EFM8UB1 SFRs WDTCN = 0x97 CKCON0 = 0x8E SFRPAGE = 0xA7 CLKSEL = 0xA9 P3 = 0xB0 ; page 0x20 REG1CN = 0xC6 P3MDOUT = 0x9C ; Interrupt vector .area INTV (ABS) .org 0x0000 _int_reset: ljmp _start .org 0x0003 _int_ex0: reti .org 0x000b _int_t0: ljmp T0_ISR .ds 5 .area CSEG (ABS,CON) .org 0x00A0 ; code starts after the interrupt vector _start: clr EA ; disable global interrupts mov WDTCN,#0xDE ; disable watchdog mov WDTCN,#0xAD mov SFRPAGE,#0x20 orl REG1CN,#0x84 ; Disable the internal voltage regulator. VREGIN ; and VDD are tied together and we use an external ; LDO. (RM 7.8) mov CLKSEL,#0x43 ; SYSCLK is HFOSC1/16 (3 MHz) orl CKCON0,#0x02 ; Timer 0 uses SYSCLK/48 (62.5 KHz) mov P3MDOUT,#0x02 ; P3.1 is a push-pull output (LED) mov SFRPAGE,#0x00 setb EA ; re-enable global interrupts main: mov TMOD,#0x01 ; Timer 0 is a 16-bit timer setb ET0 ; enable Timer 0 interrupts setb TR0 ; run Timer 0 idle: mov PCON,#0x01 ; idle mode, wait for interrupt mov PCON,PCON ; dummy 3 cycle instruction sjmp idle T0_ISR: cpl P3.1 mov TH0,#0xE7 mov TL0,#0x96 clr TF0 ; reset Timer 0 interrupt reti
/* * Copyright 2015 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "GrDrawPathBatch.h" #include "GrRenderTargetPriv.h" static void pre_translate_transform_values(const float* xforms, GrPathRendering::PathTransformType type, int count, SkScalar x, SkScalar y, float* dst); void GrDrawPathBatchBase::onPrepare(GrBatchFlushState*) { const GrRenderTargetPriv& rtPriv = this->pipeline()->getRenderTarget()->renderTargetPriv(); fStencilPassSettings.reset(GrPathRendering::GetStencilPassSettings(fFillType), this->pipeline()->hasStencilClip(), rtPriv.numStencilBits()); } SkString GrDrawPathBatch::dumpInfo() const { SkString string; string.printf("PATH: 0x%p", fPath.get()); string.append(INHERITED::dumpInfo()); return string; } void GrDrawPathBatch::onDraw(GrBatchFlushState* state) { GrProgramDesc desc; SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color(), this->overrides(), this->viewMatrix())); state->gpu()->pathRendering()->drawPath(*this->pipeline(), *pathProc, this->stencilPassSettings(), fPath.get()); } SkString GrDrawPathRangeBatch::dumpInfo() const { SkString string; string.printf("RANGE: 0x%p COUNTS: [", fPathRange.get()); for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { string.appendf("%d, ", iter.get()->fInstanceData->count()); } string.remove(string.size() - 2, 2); string.append("]"); string.append(INHERITED::dumpInfo()); return string; } GrDrawPathRangeBatch::GrDrawPathRangeBatch(const SkMatrix& viewMatrix, SkScalar scale, SkScalar x, SkScalar y, GrColor color, GrPathRendering::FillType fill, GrPathRange* range, const InstanceData* instanceData, const SkRect& bounds) : INHERITED(ClassID(), viewMatrix, color, fill) , fPathRange(range) , fTotalPathCount(instanceData->count()) , fScale(scale) { fDraws.addToHead()->set(instanceData, x, y); this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); } bool GrDrawPathRangeBatch::onCombineIfPossible(GrBatch* t, const GrCaps& caps) { GrDrawPathRangeBatch* that = t->cast<GrDrawPathRangeBatch>(); if (this->fPathRange.get() != that->fPathRange.get() || this->transformType() != that->transformType() || this->fScale != that->fScale || this->color() != that->color() || !this->viewMatrix().cheapEqualTo(that->viewMatrix())) { return false; } if (!GrPipeline::AreEqual(*this->pipeline(), *that->pipeline(), false)) { return false; } switch (fDraws.head()->fInstanceData->transformType()) { case GrPathRendering::kNone_PathTransformType: if (this->fDraws.head()->fX != that->fDraws.head()->fX || this->fDraws.head()->fY != that->fDraws.head()->fY) { return false; } break; case GrPathRendering::kTranslateX_PathTransformType: if (this->fDraws.head()->fY != that->fDraws.head()->fY) { return false; } break; case GrPathRendering::kTranslateY_PathTransformType: if (this->fDraws.head()->fX != that->fDraws.head()->fX) { return false; } break; default: break; } // TODO: Check some other things here. (winding, opaque, pathProc color, vm, ...) // Try to combine this call with the previous DrawPaths. We do this by stenciling all the // paths together and then covering them in a single pass. This is not equivalent to two // separate draw calls, so we can only do it if there is no blending (no overlap would also // work). Note that it's also possible for overlapping paths to cancel each other's winding // numbers, and we only partially account for this by not allowing even/odd paths to be // combined. (Glyphs in the same font tend to wind the same direction so it works out OK.) if (GrPathRendering::kWinding_FillType != this->fillType() || GrPathRendering::kWinding_FillType != that->fillType() || this->overrides().willColorBlendWithDst()) { return false; } SkASSERT(!that->overrides().willColorBlendWithDst()); fTotalPathCount += that->fTotalPathCount; while (Draw* head = that->fDraws.head()) { Draw* draw = fDraws.addToTail(); draw->fInstanceData.reset(head->fInstanceData.release()); draw->fX = head->fX; draw->fY = head->fY; that->fDraws.popHead(); } this->joinBounds(*that); return true; } void GrDrawPathRangeBatch::onDraw(GrBatchFlushState* state) { const Draw& head = *fDraws.head(); SkMatrix drawMatrix(this->viewMatrix()); drawMatrix.preScale(fScale, fScale); drawMatrix.preTranslate(head.fX, head.fY); SkMatrix localMatrix; localMatrix.setScale(fScale, fScale); localMatrix.preTranslate(head.fX, head.fY); SkAutoTUnref<GrPathProcessor> pathProc(GrPathProcessor::Create(this->color(), this->overrides(), drawMatrix, localMatrix)); if (fDraws.count() == 1) { const InstanceData& instances = *head.fInstanceData; state->gpu()->pathRendering()->drawPaths(*this->pipeline(), *pathProc, this->stencilPassSettings(), fPathRange.get(), instances.indices(), GrPathRange::kU16_PathIndexType, instances.transformValues(), instances.transformType(), instances.count()); } else { int floatsPerTransform = GrPathRendering::PathTransformSize(this->transformType()); SkAutoSTMalloc<4096, float> transformStorage(floatsPerTransform * fTotalPathCount); SkAutoSTMalloc<2048, uint16_t> indexStorage(fTotalPathCount); int idx = 0; for (DrawList::Iter iter(fDraws); iter.get(); iter.next()) { const Draw& draw = *iter.get(); const InstanceData& instances = *draw.fInstanceData; memcpy(&indexStorage[idx], instances.indices(), instances.count() * sizeof(uint16_t)); pre_translate_transform_values(instances.transformValues(), this->transformType(), instances.count(), draw.fX - head.fX, draw.fY - head.fY, &transformStorage[floatsPerTransform * idx]); idx += instances.count(); // TODO: Support mismatched transform types if we start using more types other than 2D. SkASSERT(instances.transformType() == this->transformType()); } SkASSERT(idx == fTotalPathCount); state->gpu()->pathRendering()->drawPaths(*this->pipeline(), *pathProc, this->stencilPassSettings(), fPathRange.get(), indexStorage, GrPathRange::kU16_PathIndexType, transformStorage, this->transformType(), fTotalPathCount); } } inline void pre_translate_transform_values(const float* xforms, GrPathRendering::PathTransformType type, int count, SkScalar x, SkScalar y, float* dst) { if (0 == x && 0 == y) { memcpy(dst, xforms, count * GrPathRendering::PathTransformSize(type) * sizeof(float)); return; } switch (type) { case GrPathRendering::kNone_PathTransformType: SkFAIL("Cannot pre-translate kNone_PathTransformType."); break; case GrPathRendering::kTranslateX_PathTransformType: SkASSERT(0 == y); for (int i = 0; i < count; i++) { dst[i] = xforms[i] + x; } break; case GrPathRendering::kTranslateY_PathTransformType: SkASSERT(0 == x); for (int i = 0; i < count; i++) { dst[i] = xforms[i] + y; } break; case GrPathRendering::kTranslate_PathTransformType: for (int i = 0; i < 2 * count; i += 2) { dst[i] = xforms[i] + x; dst[i + 1] = xforms[i + 1] + y; } break; case GrPathRendering::kAffine_PathTransformType: for (int i = 0; i < 6 * count; i += 6) { dst[i] = xforms[i]; dst[i + 1] = xforms[i + 1]; dst[i + 2] = xforms[i] * x + xforms[i + 1] * y + xforms[i + 2]; dst[i + 3] = xforms[i + 3]; dst[i + 4] = xforms[i + 4]; dst[i + 5] = xforms[i + 3] * x + xforms[i + 4] * y + xforms[i + 5]; } break; default: SkFAIL("Unknown transform type."); break; } }
;****************************************************************************** ;* x86 optimized Format Conversion Utils ;* Copyright (c) 2008 Loren Merritt ;* ;* This file is part of FFmpeg. ;* ;* FFmpeg is free software; you can redistribute it and/or ;* modify it under the terms of the GNU Lesser General Public ;* License as published by the Free Software Foundation; either ;* version 2.1 of the License, or (at your option) any later version. ;* ;* FFmpeg is distributed in the hope that it will be useful, ;* but WITHOUT ANY WARRANTY; without even the implied warranty of ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;* Lesser General Public License for more details. ;* ;* You should have received a copy of the GNU Lesser General Public ;* License along with FFmpeg; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** %include "libavutil/x86/x86util.asm" SECTION_TEXT %macro CVTPS2PI 2 %if cpuflag(sse) cvtps2pi %1, %2 %elif cpuflag(3dnow) pf2id %1, %2 %endif %endmacro ;--------------------------------------------------------------------------------- ; void int32_to_float_fmul_scalar(float *dst, const int *src, float mul, int len); ;--------------------------------------------------------------------------------- %macro INT32_TO_FLOAT_FMUL_SCALAR 1 %if UNIX64 cglobal int32_to_float_fmul_scalar, 3, 3, %1, dst, src, len %else cglobal int32_to_float_fmul_scalar, 4, 4, %1, dst, src, mul, len %endif %if WIN64 SWAP 0, 2 %elif ARCH_X86_32 movss m0, mulm %endif SPLATD m0 shl lenq, 2 add srcq, lenq add dstq, lenq neg lenq .loop: %if cpuflag(sse2) cvtdq2ps m1, [srcq+lenq ] cvtdq2ps m2, [srcq+lenq+16] %else cvtpi2ps m1, [srcq+lenq ] cvtpi2ps m3, [srcq+lenq+ 8] cvtpi2ps m2, [srcq+lenq+16] cvtpi2ps m4, [srcq+lenq+24] movlhps m1, m3 movlhps m2, m4 %endif mulps m1, m0 mulps m2, m0 mova [dstq+lenq ], m1 mova [dstq+lenq+16], m2 add lenq, 32 jl .loop REP_RET %endmacro INIT_XMM sse INT32_TO_FLOAT_FMUL_SCALAR 5 INIT_XMM sse2 INT32_TO_FLOAT_FMUL_SCALAR 3 ;------------------------------------------------------------------------------ ; void ff_float_to_int16(int16_t *dst, const float *src, long len); ;------------------------------------------------------------------------------ %macro FLOAT_TO_INT16 1 cglobal float_to_int16, 3, 3, %1, dst, src, len add lenq, lenq lea srcq, [srcq+2*lenq] add dstq, lenq neg lenq .loop: %if cpuflag(sse2) cvtps2dq m0, [srcq+2*lenq ] cvtps2dq m1, [srcq+2*lenq+16] packssdw m0, m1 mova [dstq+lenq], m0 %else CVTPS2PI m0, [srcq+2*lenq ] CVTPS2PI m1, [srcq+2*lenq+ 8] CVTPS2PI m2, [srcq+2*lenq+16] CVTPS2PI m3, [srcq+2*lenq+24] packssdw m0, m1 packssdw m2, m3 mova [dstq+lenq ], m0 mova [dstq+lenq+8], m2 %endif add lenq, 16 js .loop %if mmsize == 8 emms %endif REP_RET %endmacro INIT_XMM sse2 FLOAT_TO_INT16 2 INIT_MMX sse FLOAT_TO_INT16 0 INIT_MMX 3dnow FLOAT_TO_INT16 0 ;------------------------------------------------------------------------------ ; void ff_float_to_int16_step(int16_t *dst, const float *src, long len, long step); ;------------------------------------------------------------------------------ %macro FLOAT_TO_INT16_STEP 1 cglobal float_to_int16_step, 4, 7, %1, dst, src, len, step, step3, v1, v2 add lenq, lenq lea srcq, [srcq+2*lenq] lea step3q, [stepq*3] neg lenq .loop: %if cpuflag(sse2) cvtps2dq m0, [srcq+2*lenq ] cvtps2dq m1, [srcq+2*lenq+16] packssdw m0, m1 movd v1d, m0 psrldq m0, 4 movd v2d, m0 psrldq m0, 4 mov [dstq], v1w mov [dstq+stepq*4], v2w shr v1d, 16 shr v2d, 16 mov [dstq+stepq*2], v1w mov [dstq+step3q*2], v2w lea dstq, [dstq+stepq*8] movd v1d, m0 psrldq m0, 4 movd v2d, m0 mov [dstq], v1w mov [dstq+stepq*4], v2w shr v1d, 16 shr v2d, 16 mov [dstq+stepq*2], v1w mov [dstq+step3q*2], v2w lea dstq, [dstq+stepq*8] %else CVTPS2PI m0, [srcq+2*lenq ] CVTPS2PI m1, [srcq+2*lenq+ 8] CVTPS2PI m2, [srcq+2*lenq+16] CVTPS2PI m3, [srcq+2*lenq+24] packssdw m0, m1 packssdw m2, m3 movd v1d, m0 psrlq m0, 32 movd v2d, m0 mov [dstq], v1w mov [dstq+stepq*4], v2w shr v1d, 16 shr v2d, 16 mov [dstq+stepq*2], v1w mov [dstq+step3q*2], v2w lea dstq, [dstq+stepq*8] movd v1d, m2 psrlq m2, 32 movd v2d, m2 mov [dstq], v1w mov [dstq+stepq*4], v2w shr v1d, 16 shr v2d, 16 mov [dstq+stepq*2], v1w mov [dstq+step3q*2], v2w lea dstq, [dstq+stepq*8] %endif add lenq, 16 js .loop %if mmsize == 8 emms %endif REP_RET %endmacro INIT_XMM sse2 FLOAT_TO_INT16_STEP 2 INIT_MMX sse FLOAT_TO_INT16_STEP 0 INIT_MMX 3dnow FLOAT_TO_INT16_STEP 0 ;------------------------------------------------------------------------------- ; void ff_float_to_int16_interleave2(int16_t *dst, const float **src, long len); ;------------------------------------------------------------------------------- %macro FLOAT_TO_INT16_INTERLEAVE2 0 cglobal float_to_int16_interleave2, 3, 4, 2, dst, src0, src1, len lea lenq, [4*r2q] mov src1q, [src0q+gprsize] mov src0q, [src0q] add dstq, lenq add src0q, lenq add src1q, lenq neg lenq .loop: %if cpuflag(sse2) cvtps2dq m0, [src0q+lenq] cvtps2dq m1, [src1q+lenq] packssdw m0, m1 movhlps m1, m0 punpcklwd m0, m1 mova [dstq+lenq], m0 %else CVTPS2PI m0, [src0q+lenq ] CVTPS2PI m1, [src0q+lenq+8] CVTPS2PI m2, [src1q+lenq ] CVTPS2PI m3, [src1q+lenq+8] packssdw m0, m1 packssdw m2, m3 mova m1, m0 punpcklwd m0, m2 punpckhwd m1, m2 mova [dstq+lenq ], m0 mova [dstq+lenq+8], m1 %endif add lenq, 16 js .loop %if mmsize == 8 emms %endif REP_RET %endmacro INIT_MMX 3dnow FLOAT_TO_INT16_INTERLEAVE2 INIT_MMX sse FLOAT_TO_INT16_INTERLEAVE2 INIT_XMM sse2 FLOAT_TO_INT16_INTERLEAVE2 %macro FLOAT_TO_INT16_INTERLEAVE6 0 ; void float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len) cglobal float_to_int16_interleave6, 2, 8, 0, dst, src, src1, src2, src3, src4, src5, len %if ARCH_X86_64 mov lend, r2d %else %define lend dword r2m %endif mov src1q, [srcq+1*gprsize] mov src2q, [srcq+2*gprsize] mov src3q, [srcq+3*gprsize] mov src4q, [srcq+4*gprsize] mov src5q, [srcq+5*gprsize] mov srcq, [srcq] sub src1q, srcq sub src2q, srcq sub src3q, srcq sub src4q, srcq sub src5q, srcq .loop: CVTPS2PI mm0, [srcq] CVTPS2PI mm1, [srcq+src1q] CVTPS2PI mm2, [srcq+src2q] CVTPS2PI mm3, [srcq+src3q] CVTPS2PI mm4, [srcq+src4q] CVTPS2PI mm5, [srcq+src5q] packssdw mm0, mm3 packssdw mm1, mm4 packssdw mm2, mm5 PSWAPD mm3, mm0 punpcklwd mm0, mm1 punpckhwd mm1, mm2 punpcklwd mm2, mm3 PSWAPD mm3, mm0 punpckldq mm0, mm2 punpckhdq mm2, mm1 punpckldq mm1, mm3 movq [dstq ], mm0 movq [dstq+16], mm2 movq [dstq+ 8], mm1 add srcq, 8 add dstq, 24 sub lend, 2 jg .loop emms RET %endmacro ; FLOAT_TO_INT16_INTERLEAVE6 INIT_MMX sse FLOAT_TO_INT16_INTERLEAVE6 INIT_MMX 3dnow FLOAT_TO_INT16_INTERLEAVE6 INIT_MMX 3dnowext FLOAT_TO_INT16_INTERLEAVE6 ;----------------------------------------------------------------------------- ; void ff_float_interleave6(float *dst, const float **src, unsigned int len); ;----------------------------------------------------------------------------- %macro FLOAT_INTERLEAVE6 1 cglobal float_interleave6, 2, 8, %1, dst, src, src1, src2, src3, src4, src5, len %if ARCH_X86_64 mov lend, r2d %else %define lend dword r2m %endif mov src1q, [srcq+1*gprsize] mov src2q, [srcq+2*gprsize] mov src3q, [srcq+3*gprsize] mov src4q, [srcq+4*gprsize] mov src5q, [srcq+5*gprsize] mov srcq, [srcq] sub src1q, srcq sub src2q, srcq sub src3q, srcq sub src4q, srcq sub src5q, srcq .loop: %if cpuflag(sse) movaps m0, [srcq] movaps m1, [srcq+src1q] movaps m2, [srcq+src2q] movaps m3, [srcq+src3q] movaps m4, [srcq+src4q] movaps m5, [srcq+src5q] SBUTTERFLYPS 0, 1, 6 SBUTTERFLYPS 2, 3, 6 SBUTTERFLYPS 4, 5, 6 movaps m6, m4 shufps m4, m0, 0xe4 movlhps m0, m2 movhlps m6, m2 movaps [dstq ], m0 movaps [dstq+16], m4 movaps [dstq+32], m6 movaps m6, m5 shufps m5, m1, 0xe4 movlhps m1, m3 movhlps m6, m3 movaps [dstq+48], m1 movaps [dstq+64], m5 movaps [dstq+80], m6 %else ; mmx movq m0, [srcq] movq m1, [srcq+src1q] movq m2, [srcq+src2q] movq m3, [srcq+src3q] movq m4, [srcq+src4q] movq m5, [srcq+src5q] SBUTTERFLY dq, 0, 1, 6 SBUTTERFLY dq, 2, 3, 6 SBUTTERFLY dq, 4, 5, 6 movq [dstq ], m0 movq [dstq+ 8], m2 movq [dstq+16], m4 movq [dstq+24], m1 movq [dstq+32], m3 movq [dstq+40], m5 %endif add srcq, mmsize add dstq, mmsize*6 sub lend, mmsize/4 jg .loop %if mmsize == 8 emms %endif REP_RET %endmacro INIT_MMX mmx FLOAT_INTERLEAVE6 0 INIT_XMM sse FLOAT_INTERLEAVE6 7 ;----------------------------------------------------------------------------- ; void ff_float_interleave2(float *dst, const float **src, unsigned int len); ;----------------------------------------------------------------------------- %macro FLOAT_INTERLEAVE2 1 cglobal float_interleave2, 3, 4, %1, dst, src, len, src1 mov src1q, [srcq+gprsize] mov srcq, [srcq ] sub src1q, srcq .loop: mova m0, [srcq ] mova m1, [srcq+src1q ] mova m3, [srcq +mmsize] mova m4, [srcq+src1q+mmsize] mova m2, m0 PUNPCKLDQ m0, m1 PUNPCKHDQ m2, m1 mova m1, m3 PUNPCKLDQ m3, m4 PUNPCKHDQ m1, m4 mova [dstq ], m0 mova [dstq+1*mmsize], m2 mova [dstq+2*mmsize], m3 mova [dstq+3*mmsize], m1 add srcq, mmsize*2 add dstq, mmsize*4 sub lend, mmsize/2 jg .loop %if mmsize == 8 emms %endif REP_RET %endmacro INIT_MMX mmx %define PUNPCKLDQ punpckldq %define PUNPCKHDQ punpckhdq FLOAT_INTERLEAVE2 0 INIT_XMM sse %define PUNPCKLDQ unpcklps %define PUNPCKHDQ unpckhps FLOAT_INTERLEAVE2 5
//#include "apue.h" #include <stdio.h> #include <syslog.h> #include <fcntl.h> #include <unistd.h> #include <stdlib.h> #include <sys/resource.h> /** * 注释1:因为我们从shell创建的daemon子进程,所以daemon子进程会继承shell的umask,如果不清除的话,会导致daemon进程创建文件时屏蔽某些权限。 * 注释2:fork后让父进程退出,子进程获得新的pid,肯定不为进程组组长,这是setsid前提。 * 注释3:调用setsid来创建新的进程会话。这使得daemon进程成为会话首进程,脱离和terminal的关联。 * 注释4:最好在这里再次fork。这样使得daemon进程不再是会话首进程,那么永远没有机会获得控制终端。如果这里不fork的话,会话首进程依然可能打开控制终端。 * 注释5:将当前工作目录切换到根目录。父进程继承过来的当前目录可能mount在一个文件系统上,如果不切换到根目录,那么这个文件系统不允许unmount。 * 注释6:在子进程中关闭从父进程中继承过来的那些不需要的文件描述符。可以通过_SC_OPEN_MAX来判断最高文件描述符(不是很必须). * 注释7:打开/dev/null复制到0,1,2,因为dameon进程已经和terminal脱离了,所以需要重新定向标准输入,标准输出和标准错误(不是很必须). */ void daemonize(const char *cmd){ int i, fd0, fd1, fd2; pid_t pid; //struct rlimit rl; //struct sigaction sa; /* * Clear file creation mask. */ //umask(0);//注释1 /* * Get maximum number of file descriptors. */ //if (getrlimit(RLIMIT_NOFILE, &rl) < 0) // err_quit("%s: can't get file limit", cmd); /* * Become a session leader to lose controlling TTY. */ if ((pid = fork()) < 0) {//注释2 printf("%s: can't fork", cmd); exit(-1); } else if (pid != 0) /* parent */ exit(0); setsid();//注释3 /* * Ensure future opens won't allocate controlling TTYs. */ /* sa.sa_handler = SIG_IGN; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGHUP, &sa, NULL) < 0) err_quit("%s: can't ignore SIGHUP", cmd); if ((pid = fork()) < 0)//注释4 err_quit("%s: can't fork", cmd); */ /*else if (pid != 0) *//* parent */ /* exit(0); */ /* * Change the current working directory to the root so * we won't prevent file systems from being unmounted. */ if (chdir("/") < 0) {//注释5 printf("%s: can't change directory to /", cmd); exit(-1); } /* * Close all open file descriptors. */ /* if (rl.rlim_max == RLIM_INFINITY) rl.rlim_max = 1024; for (i = 0; i < rl.rlim_max; i++) close(i);//注释6 */ /* * Attach file descriptors 0, 1, and 2 to /dev/null. */ fd0 = open("/dev/null", O_RDWR);//注释7 //fd1 = dup(0);//注释7 //fd2 = dup(0);//注释7 dup2(fd0, STDIN_FILENO); dup2(fd0, STDOUT_FILENO); dup2(fd0, STDERR_FILENO); /* * Initialize the log file. */ /* openlog(cmd, LOG_CONS, LOG_DAEMON); if (fd0 != 0 || fd1 != 1 || fd2 != 2) { syslog(LOG_ERR, "unexpected file descriptors %d %d %d",fd0, fd1, fd2); exit(1); } */ } int main(int argc, char* argv[]) { daemonize("test"); while(1) { sleep(60); } }
/****************************************************************************** * Copyright (c) 2010-2011, Duane Merrill. All rights reserved. * Copyright (c) 2011-2018, NVIDIA CORPORATION. All rights reserved. * Modifications Copyright (c) 2017-2020, Advanced Micro Devices, Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the NVIDIA 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 NVIDIA CORPORATION 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 HIPCUB_ROCPRIM_ITERATOR_TRANSFORM_INPUT_ITERATOR_HPP_ #define HIPCUB_ROCPRIM_ITERATOR_TRANSFORM_INPUT_ITERATOR_HPP_ #include <iterator> #include <iostream> #include "../../../config.hpp" #include <rocprim/iterator/transform_iterator.hpp> #if (THRUST_VERSION >= 100700) // This iterator is compatible with Thrust API 1.7 and newer #include <thrust/iterator/iterator_facade.h> #include <thrust/iterator/iterator_traits.h> #endif // THRUST_VERSION BEGIN_HIPCUB_NAMESPACE #ifndef DOXYGEN_SHOULD_SKIP_THIS // Do not document template< typename ValueType, typename ConversionOp, typename InputIteratorT, typename OffsetT = std::ptrdiff_t // ignored > using TransformInputIterator = ::rocprim::transform_iterator<InputIteratorT, ConversionOp, ValueType>; #endif END_HIPCUB_NAMESPACE #endif // HIPCUB_ROCPRIM_ITERATOR_TRANSFORM_INPUT_ITERATOR_HPP_
%include "../UltimaPatcher.asm" %include "include/uw1.asm" %include "include/uw1-eop.asm" [bits 16] startPatch EXE_LENGTH, \ expanded overlay procedure: mapControl startBlockAt addr_eop_mapControl push bp mov bp, sp ; bp-based stack frame: %assign arg_mapControl 0x04 %assign ____callerIp 0x02 %assign ____callerBp 0x00 push si push di cmp word [bp+arg_mapControl], MapControl_LEVEL_UP jz levelUp cmp word [bp+arg_mapControl], MapControl_LEVEL_DOWN jz levelDown cmp word [bp+arg_mapControl], MapControl_AVATAR_LEVEL jz avatarLevel jmp endProc levelUp: test word [dseg_mapDungeonLevel], 7 jz endProc mov ax, [dseg_mapDungeonLevel] inc ax jmp changeMapLevel levelDown: mov ax, [dseg_mapDungeonLevel] and ax, 7 cmp ax, 1 jz endProc mov ax, [dseg_mapDungeonLevel] dec ax jmp changeMapLevel avatarLevel: mov ax, [dseg_avatarDungeonLevel] cmp ax, [dseg_mapDungeonLevel] jz endProc jmp changeMapLevel changeMapLevel: push ax callFromOverlay changeMapLevel add sp, 2 endProc: pop di pop si mov sp, bp pop bp retn endBlockAt off_eop_mapControl_end endPatch
scope VI: { Init: addi sp, 8 sw ra, -8(sp) // Clear screen before enabling VI la t0, framebuffer0 ls_gp(sw t0, active_framebuffer) jal FillScreen lli a0, 0x0001 lui t0, VI_BASE la t1, framebuffer0 sw t1, VI_ORIGIN(t0) // Setup VI // 16-bit color (0), no AA, resampling only (8) lli t1, (%10 << 0)|(%10 << 8) sw t1, VI_STATUS(t0) // width (pixels) lli t1, width sw t1, VI_WIDTH(t0) // interrupt at start of vblank //lli t1, 121 //0x200 lli t1, 0x200 sw t1, VI_V_INTR(t0) // hsync width (pixels)(0), color burst width (pixels)(8), vsync height (lines)(16), color burst start (pixels from hsync)(20) la t1, (50<<0)|(34<<8)|(5<<16)|(58<<20) sw t1, VI_TIMING(t0) // v sync, lines per frame lli t1, 525 sw t1, VI_V_SYNC(t0) // h sync, 1/4 pixels per line lli t1, 0xc15 sw t1, VI_H_SYNC(t0) // h sync leap, same as h sync la t1, 0x0c15'0c15 sw t1, VI_H_SYNC_LEAP(t0) // start of active video (pixels)(16), end of active video (pixels)(0) la t1, (98<<16)|(738<<0) sw t1, VI_H_VIDEO(t0) // start of active video (lines)(16), end of active video (lines)(0) la t1, (32<<16)|(512<<0) sw t1, VI_V_VIDEO(t0) // color burst start (lines?)(16), color burst end (lines?)(0) la t1, (14<<16)|(516<<0) sw t1, VI_V_BURST(t0) // h scale, 0 subpixel lli t1, hscale_width * 0x400 / 640 sw t1, VI_X_SCALE(t0) // v scale, 0 subpixel lli t1, vscale_height * 0x400 / 240 sw t1, VI_Y_SCALE(t0) la t1, framebuffer1 ls_gp(sw t1, active_framebuffer) ls_gp(sw r0, finished_framebuffer) jal FillScreen lli a0, 0x0001 // Init dlist buffers la_gp(t0, dlists) lli t1, num_dlists - sw r0, 0(t0) sw r0, 4(t0) addi t1, -1 bnez t1,- addi t0, 8 lli t1, -1 ls_gp(sb t1, running_dlist_idx) // Clear pending interrupts sw r0, VI_V_CURRENT_LINE(t0) lui t0, MI_BASE lli t1, MI_CLEAR_DP_INT sw t1, MI_INIT_MODE(t0) // Reset RDP lui t2, DPC_BASE sw r0, DPC_START (t2) sw r0, DPC_END (t2) lli t1, CLR_XBS|CLR_FRZ|CLR_FLS sw t1, DPC_STATUS (t2) // Enable interrupts lli t1, MI_MASK_SET_VI|MI_MASK_SET_DP sw t1, MI_INTR_MASK(t0) lw ra, -8(sp) jr ra addi ra, -8 VI_Interrupt: ls_gp(sd t0, exception_regs + t0*8) ls_gp(lw t0, finished_framebuffer) beqz t0,+ ls_gp(sw r0, finished_framebuffer) ls_gp(sd t1, exception_regs + t1*8) ls_gp(sd t2, exception_regs + t2*8) lui t1, VI_BASE lw t2, VI_ORIGIN(t1) sw t0, VI_ORIGIN(t1) lui t0, 0xa000 or t2, t0 ls_gp(sw t2, active_framebuffer) ls_gp(ld t1, exception_regs + t1*8) ls_gp(ld t2, exception_regs + t2*8) + jr k1 ls_gp(ld t0, exception_regs + t0*8) // Spinning on DPC_STATUS (from the CPU, at least) seems to reliably hang // the RDP, or something, so keep we'll track of whether something is // running ourselves, via the DP interrupt. // a2: idx WaitForDlist: sll t0, a2, 3 add t0, gp - lw t1, dlists + 0 - gp_base (t0) bnez t1,- nop jr ra nop // syscall QUEUE_DLIST_SYSCALL // a0: start // a1: end // a2: idx // returns 1 in v1 if successful scope QueueDlist: { ls_gp(lb v1, running_dlist_idx) bgez v1,+ nop // Nothing running yet, start this one immediately. // TODO does this need to check for busy/valid? lui k0, DPC_BASE //lli v1, SET_FRZ //sw v1, DPC_STATUS (k0) sw a0, DPC_START (k0) sw a1, DPC_END (k0) ls_gp(sb a2, running_dlist_idx) //lli v1, CLR_FRZ //sw v1, DPC_STATUS (k0) //lw r0, DPC_STATUS (k0) //sw a0, DPC_START (k0) //sw a1, DPC_END (k0) j done lli v1, 1 + // Already running a dlist, queue this one if the slot is open sll k0, a2, 3 add k0, gp lw v1, dlists + 0 - gp_base (k0) bnez v1, done lli v1, 0 sw a0, dlists + 0 - gp_base (k0) sw a1, dlists + 4 - gp_base (k0) lli v1, 1 done: jr k1 nop } scope DP_Interrupt: { ls_gp(sd t0, exception_regs + t0*8) ls_gp(sd t1, exception_regs + t1*8) ls_gp(sd t2, exception_regs + t2*8) ls_gp(lbu t0, running_dlist_idx) subi t1, t0, frame_dlist_idx bnez t1,+ // Expose the framebuffer if this was the frame dlist finishing ls_gp(lw k0, active_framebuffer) ls_gp(sw r0, active_framebuffer) ls_gp(sw k0, finished_framebuffer) + // Mark it free sll k0, t0, 3 add k0, gp sw r0, dlists + 0 - gp_base (k0) // Look for the next one to run lli t1, -1 ls_gp(sb t1, running_dlist_idx) move t1, t0 - addi t1, 1 lli t2, num_dlists beq t1, t2,+ addi k0, 8 lw t2, dlists + 0 - gp_base (k0) beqz t2,- nop j found nop + lli t1, 0 move k0, gp - lw t2, dlists + 0 - gp_base (k0) beqz t2,+ nop found: ls_gp(sb t1, running_dlist_idx) // Run it lui t1, DPC_BASE //lli t0, SET_FRZ //sw t0, DPC_STATUS (t1) lw t0, dlists + 4 - gp_base (k0) sw t2, DPC_START (t1) sw t0, DPC_END (t1) //lli k0, CLR_FRZ //sw k0, DPC_STATUS (t1) //lw r0, DPC_STATUS (t1) //sw t2, DPC_START (t1) //sw t0, DPC_END (t1) j done nop + addi k0, 8 bne t1, t0,- addi t1, 1 done: ls_gp(ld t0, exception_regs + t0*8) ls_gp(ld t1, exception_regs + t1*8) ls_gp(ld t2, exception_regs + t2*8) if {defined PROFILE_RDP} { lui k0, DPC_BASE lw k0, DPC_CLOCK (k0) ls_gp(sw k0, frame_rdp_cycles) } jr k1 nop } // Returns framebuffer in a0, blocks until available GetFramebuffer: - ls_gp(lw a0, active_framebuffer) beqz a0,- nop jr ra nop StopDP: // TODO, just set frozen? jr ra nop // a0 = color FillScreen: ls_gp(lw t0, active_framebuffer) dsll t2, a0, 16 or t2, a0 dsll32 t3, t2, 0 or t2, t3 li t3, width*height*2 -;sd t2, 0(t0) addi t0,8 bgtz t3,- addi t3,-8 jr ra nop // a0 = framebuffer pos // a1 = max chars scope PrintDebugToScreen: { move t9, a1 move t4, t9 la a1, debug_buffer la a2, debug_buffer_cursor lw a2, 0 (a2) move a3, a0 lli t8, 0xffff bne a1, a2, char_loop nop jr ra nop char_loop: lbu t0, 0 (a1) lli t1, 0xff // invert video bne t0, t1,+ lli t1, 0xa // newline j char_loop_continue xori t8, 0xfffe + bnez t4,+ addi t4, -1 lli t0, 0xa addi a1, -1 + // line wrap bne t0, t1,+ sll t0, 3 addi a3, (width*2)*8 // move down a line move t4, t9 j char_loop_continue move a0, a3 + la t1, font add t0, t1 ld t0, 0(t0) li t2, 7 // rows to do -;li t3, 7 // pixels to do -;bltz t0,+ move t1, t8 xori t1, 0xfffe +;sh t1, 0(a0) addi a0, 2 dsll t0, 1 bnez t3,- addi t3, -1 addi a0, (width*2)-(8*2) // move down a line bnez t2,-- addi t2, -1 addi a0, (8*2)-(8*width*2) // move forward a char char_loop_continue: addi a1, 1 bne a1, a2, char_loop nop jr ra nop } // This does not perform the final render, it only assembles the dlist // a0, a1: X, Y pixel coordinates scope PrintDebugToScreenRDP: { Start: addi sp, 8 sw ra, -8(sp) lli a2, text_dlist_idx jal VI.WaitForDlist nop lw ra, -8(sp) addi sp, -8 la a3, text_dlist // copy setup // TODO this only needs to be done once la t0, TextStaticDlist lli t1, (TextStaticDlist.End-TextStaticDlist)/16 - ld t2, 0(t0) ld t3, 8(t0) sd t2, 0(a3) sd t3, 8(a3) addi a3, 16 addi t1, -1 bnez t1,- addi t0, 16 ls_gp(sw a3, text_dlist_ptr) Continue: move s8, a0 ls_gp(lw a3, text_dlist_ptr) // write characters lli t3, 0 // normal (not inverse) mode la t9, debug_buffer ls_gp(lw t8, debug_buffer_cursor) beq t9, t8, char_loop_end nop char_loop: lbu t2, 0 (t9) lli t1, 0xff // invert video bne t2, t1, no_invert lli t1, 0xa // newline // Change palettes for inverse video // FIXME this isn't accounted for in the size of text_dlist la t0, TextStaticDlist.SetNormal lli t1, (TextStaticDlist.SetNormalEnd-TextStaticDlist.SetNormal)/8 bnez t3,+ xori t3, 1 la t0, TextStaticDlist.SetInverse + - ld t2, 0(t0) sd t2, 0(a3) addi a3, 8 addi t1, -1 bnez t1,- addi t0, 8 j char_loop_continue nop no_invert: subi t4, a0, width - 32 - 8 bltz t4,+ nop lli t2, 0xa addi t9, -1 + // line wrap bne t2, t1,+ nop move a0, s8 j char_loop_continue addi a1, 8 + // write rects ls_gp(ld t0, TextStaticDlist.TextureRectangleTemplate) dsll t1, a0, 2+12 // XH=x<<2 or t0, t1 dsll t1, a1, 2+0 // YH=y<<2 or t0, t1 addi t1, a0, 7 dsll32 t1, 2+44 // XL=(x+7)<<2 or t0, t1 addi t1, a1, 7 dsll32 t1, 2+32-32 // YL=(x+7)<<2 or t0, t1 andi t1, t2, 0b11 addi t1, TextStaticDlist.render_font_b0_tile dsll t1, 24 // Tile = render_font_b0_tile + char&0b11 or t0, t1 sd t0, 0(a3) ls_gp(ld t0, TextStaticDlist.TextureRectangleTemplate+8) srl t1, t2, 2 dsll32 t1, 3+5+48-32 // S=(char>>2)*8<<5 or t0, t1 sd t0, 8(a3) addi a3, 16 addi a0, 8 char_loop_continue: addi t9, 1 bne t9, t8, char_loop nop char_loop_end: jr ra ls_gp(sw a3, text_dlist_ptr) Render: ls_gp(lw a3, text_dlist_ptr) // write NOP sd r0, 0(a3) addi a3, 8 // write sync ls_gp(ld t0, TextStaticDlist.SyncFull) addi a3, 8 sd t0, -8(a3) // write another NOP sd r0, 0(a3) addi a3, 8 // run RDP la a0, text_dlist ls_gp(sw a0, text_dlist_ptr) move a1, a3 lli a2, text_dlist_idx - syscall QUEUE_DLIST_SYSCALL nop beqz v1,- nop jr ra nop } } begin_bss() align(4) finished_framebuffer:; dw 0 active_framebuffer:; dw 0 text_dlist_ptr:; dw 0 constant frame_dlist_idx(0) constant prof_dlist_idx(1) constant text_dlist_idx(2) constant num_dlists(3) dlists: fill num_dlists*8 running_dlist_idx:; db 0 align(4) end_bss()
; A070385: a(n) = 5^n mod 38. ; 1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1,5,25,11,17,9,7,35,23,1 mov $1,1 mov $2,$0 lpb $2 mul $1,5 mod $1,38 sub $2,1 lpe mov $0,$1
; some flags here for build configuration i guess ;;; actual code to do with the file starts here ;;; .include "defines.inc" .include "global.inc" .import NMI_HANDLER, RESET_HANDLER, IRQ_HANDLER .segment "HEADER" ; comments regarding header format taken from ; https://wiki.nesdev.org/w/index.php?title=INES#iNES_file_format ; Flag 0-3 .byte "NES", $1A ; Flag 4 .byte $01 ; n * 16KB PRG ROM ; Flag 5 .byte $01 ; n * 8KB CHR ROM ; Flag 6 .byte %00000000 ; |||||||| ; |||||||+- Mirroring: 0: horizontal (vertical arrangement) (CIRAM A10 = PPU A11) ; ||||||| 1: vertical (horizontal arrangement) (CIRAM A10 = PPU A10) ; ||||||+-- 1: Cartridge contains battery-backed PRG RAM ($6000-7FFF) or other persistent memory ; |||||+--- 1: 512-byte trainer at $7000-$71FF (stored before PRG data) ; ||||+---- 1: Ignore mirroring control or above mirroring bit; instead provide four-screen VRAM ; ++++----- Lower nybble of mapper number ; Flag 7 .byte %00000000 ; |||||||| ; |||||||+- VS Unisystem ; ||||||+-- PlayChoice-10 (8KB of Hint Screen data stored after CHR data) ; ||||++--- If equal to 2, flags 8-15 are in NES 2.0 format ; ++++----- Upper nybble of mapper number ; Flag 8 .byte $00 ; Flag 9 .byte %00000000 ; |||||||| ; |||||||+- TV system (0: NTSC; 1: PAL) ; +++++++-- Reserved, set to zero ; Flag 10 .byte $00 ; ??? ; Flag 11-15; iNES 2.0 stuff i guess .byte $00, $00, $00, $00, $00 .segment "ZEROPAGE" ; $0000-$00FF, place cycle crucial variables here ; $0000-$000F framecounter: .res 1 system_state: .res 1 ; controller buffers controller_1: .res 1 controller_2: .res 1 ; 4 byte-size variables temp_8_0: .res 1 temp_8_1: .res 1 temp_8_2: .res 1 temp_8_3: .res 1 ; buttons pressed for both controllers controller_press_1: .res 1 controller_press_2: .res 1 ; 4 word-size variables temp_16_0: .res 2 temp_16_1: .res 2 temp_16_2: .res 2 temp_16_3: .res 2 ; $0010-$001F... .segment "INTERNALRAM" ; internal RAM .segment "VECTORS" .addr NMI_HANDLER, RESET_HANDLER, IRQ_HANDLER .segment "CHR" .incbin "../gfx/textchar.chr"
//================================================================================================= /*! // \file src/mathtest/dmatdmatmult/MDbLDb.cpp // \brief Source file for the MDbLDb dense matrix/dense matrix multiplication math test // // Copyright (C) 2012-2018 Klaus Iglberger - All Rights Reserved // // This file is part of the Blaze library. You can redistribute it and/or modify it under // the terms of the New (Revised) BSD License. Redistribution and use in source and binary // forms, with or without modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of // conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright notice, this list // of conditions and the following disclaimer in the documentation and/or other materials // provided with the distribution. // 3. Neither the names of the Blaze development group nor the names of its contributors // may be used to endorse or promote products derived from this software without specific // prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT // SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH // DAMAGE. */ //================================================================================================= //************************************************************************************************* // Includes //************************************************************************************************* #include <cstdlib> #include <iostream> #include <blaze/math/DynamicMatrix.h> #include <blaze/math/LowerMatrix.h> #include <blazetest/mathtest/Creator.h> #include <blazetest/mathtest/dmatdmatmult/OperationTest.h> #include <blazetest/system/MathTest.h> //================================================================================================= // // MAIN FUNCTION // //================================================================================================= //************************************************************************************************* int main() { std::cout << " Running 'MDbLDb'..." << std::endl; using blazetest::mathtest::TypeB; try { // Matrix type definitions using MDb = blaze::DynamicMatrix<TypeB>; using LDb = blaze::LowerMatrix< blaze::DynamicMatrix<TypeB> >; // Creator type definitions using CMDb = blazetest::Creator<MDb>; using CLDb = blazetest::Creator<LDb>; // Running tests with small matrices for( size_t i=0UL; i<=6UL; ++i ) { for( size_t j=0UL; j<=6UL; ++j ) { RUN_DMATDMATMULT_OPERATION_TEST( CMDb( i, j ), CLDb( j ) ); } } // Running tests with large matrices RUN_DMATDMATMULT_OPERATION_TEST( CMDb( 37UL, 15UL ), CLDb( 15UL ) ); RUN_DMATDMATMULT_OPERATION_TEST( CMDb( 37UL, 37UL ), CLDb( 37UL ) ); RUN_DMATDMATMULT_OPERATION_TEST( CMDb( 37UL, 63UL ), CLDb( 63UL ) ); RUN_DMATDMATMULT_OPERATION_TEST( CMDb( 32UL, 16UL ), CLDb( 16UL ) ); RUN_DMATDMATMULT_OPERATION_TEST( CMDb( 32UL, 32UL ), CLDb( 32UL ) ); RUN_DMATDMATMULT_OPERATION_TEST( CMDb( 32UL, 64UL ), CLDb( 64UL ) ); } catch( std::exception& ex ) { std::cerr << "\n\n ERROR DETECTED during dense matrix/dense matrix multiplication:\n" << ex.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; } //*************************************************************************************************
; Z88 Small C+ Run time Library ; Moved functions over to proper libdefs ; To make startup code smaller and neater! ; ; 6/9/98 djm SECTION code_l_sccz80 PUBLIC l_pint EXTERN l_pint_pop_pint defc l_pint = l_pint_pop_pint
; A079273: Octo numbers (a polygonal sequence): a(n) = 5*n^2 - 6*n + 2 = (n-1)^2 + (2*n-1)^2. ; 1,10,29,58,97,146,205,274,353,442,541,650,769,898,1037,1186,1345,1514,1693,1882,2081,2290,2509,2738,2977,3226,3485,3754,4033,4322,4621,4930,5249,5578,5917,6266,6625,6994,7373,7762,8161,8570,8989,9418,9857,10306,10765,11234,11713,12202,12701,13210,13729,14258,14797,15346,15905,16474,17053,17642,18241,18850,19469,20098,20737,21386,22045,22714,23393,24082,24781,25490,26209,26938,27677,28426,29185,29954,30733,31522,32321,33130,33949,34778,35617,36466,37325,38194,39073,39962,40861,41770,42689,43618,44557,45506,46465,47434,48413,49402,50401,51410,52429,53458,54497,55546,56605,57674,58753,59842,60941,62050,63169,64298,65437,66586,67745,68914,70093,71282,72481,73690,74909,76138,77377,78626,79885,81154,82433,83722,85021,86330,87649,88978,90317,91666,93025,94394,95773,97162,98561,99970,101389,102818,104257,105706,107165,108634,110113,111602,113101,114610,116129,117658,119197,120746,122305,123874,125453,127042,128641,130250,131869,133498,135137,136786,138445,140114,141793,143482,145181,146890,148609,150338,152077,153826,155585,157354,159133,160922,162721,164530,166349,168178,170017,171866,173725,175594,177473,179362,181261,183170,185089,187018,188957,190906,192865,194834,196813,198802,200801,202810,204829,206858,208897,210946,213005,215074,217153,219242,221341,223450,225569,227698,229837,231986,234145,236314,238493,240682,242881,245090,247309,249538,251777,254026,256285,258554,260833,263122,265421,267730,270049,272378,274717,277066,279425,281794,284173,286562,288961,291370,293789,296218,298657,301106,303565,306034,308513,311002 mov $1,5 mul $1,$0 add $1,4 mul $1,$0 add $1,1
; ; MSX specific routines ; ; Improved functions by Rafael de Oliveira Jannone ; Originally released in 2004 for GFX - a small graphics library ; ; int msx_vpeek(int address); ; ; Read the MSX video memory ; ; $Id: msx_vpeek.asm,v 1.9 2015/01/19 01:32:57 pauloscustodio Exp $ ; PUBLIC msx_vpeek INCLUDE "msx/vdp.inc" msx_vpeek: ; (FASTCALL) -> HL = address ;ld ix,RDVRM ;call msxbios ; enter vdp address pointer ld a,l di out (VDP_CMD), a ld a,h and @00111111 ei out (VDP_CMD), a ; read data in a,(VDP_DATAIN) ld h,0 ld l,a ret
; int printf(const char *fmt, ...) ; 05.2008 aralbrec PUBLIC printf EXTERN vfprintf_callee, stdio_varg EXTERN ASMDISP_VFPRINTF_CALLEE EXTERN _stdout .printf call stdio_varg ; de = char *fmt ld c,l ld b,h ; bc = top of parameter list ld ix,(_stdout) jp vfprintf_callee + ASMDISP_VFPRINTF_CALLEE
global utils_number_to_decimal_ascii global utils_get_decimal_length global utils_are_three_equals extern console_print extern console_print_nl segment .data base_10: dd 10 segment .bss segment .text ; Convert a 32 bit unsigned dezimal number to its ascii representation and store it in given ; adress parameter ; The highest value is 4294967295 so the string has a max length of 10 ; Parameters: value to convert, length of number, adress where to store result utils_number_to_decimal_ascii: enter 0,0 pusha ; We create the string backwards. So we first add the last char of the number to the string ; and finally the first one. ; E.g. when we have the number 638 we first add the 8. So we have the string: __8 ; Then _38 and finally 638 with ascii codes mov eax, [ebp+8] ; Store number which we want to convert in eax mov ecx, [ebp+12] ; Move numbers length in ecx register ; We loop as long ecx is not zero, so we execute the code as long as we have covered all ; indexes of the number .pos_to_string: mov edx, 0 div dword [base_10] ; Divide number in eax with 10 (Base of dezimal numbers) ; In eax is the result of the division and in edx the rest add edx, 48 ; Add 48 to make number to its ascii equivalent mov ebx, [ebp+16] ; Store Adress of string in ebx mov byte [ebx+ecx-1], dl ; Add the ascii number to the string (String Adress + index - 1) ; We only need one byte so we use dl insted of edx. ; Edx stores the rest of the division which is our number and ; because the number is between 0 and 9 and we add 48 to get the ; ascii representation one byte is enough to store the rest. loop .pos_to_string popa leave ret ; Returns the length of the given decimal number ; Parameters: number ; Returns length in eax register utils_get_decimal_length: enter 4,0 pusha ;mov dword [ebp-4], 638 mov eax, [ebp+8] ; Move given parameter (decimal number) to eax to work with it mov dword [ebp-4], 0 ; The length counter .count: inc dword [ebp-4] ; Increment length mov edx, 0 ; Reset edx before dividing div dword [base_10] ; Divide number in eax with 10 (Base of dezimal numbers) cmp dword eax, 0 ; If divided number is zero we have completed counting jnz .count ; If number was not zero after dividing loop again ; !count popa mov eax, [ebp-4] ; Return the length (return in eax register) leave ret ; Check if the three given 32Bit values are equals ; Returns 1 in eax when there are equals, else return 0 ; Parameters: value1, value2, value3 utils_are_three_equals: enter 4, 0 pusha mov eax, [ebp+8] mov ebx, [ebp+12] cmp eax, ebx jnz .not_equals mov eax, [ebp+16] cmp eax, ebx jnz .not_equals ; Equals mov dword [ebp-4], 1 jmp .ret .not_equals: mov dword [ebp-4], 0 jmp .ret .ret: popa mov eax, [ebp-4] leave ret
; ; jdmerge.asm - merged upsampling/color conversion (AVX2) ; ; Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB ; Copyright (C) 2009, 2016, D. R. Commander. ; Copyright (C) 2015, Intel Corporation. ; ; Based on the x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; [TAB8] %include "jsimdext.inc" ; -------------------------------------------------------------------------- %define SCALEBITS 16 F_0_344 equ 22554 ; FIX(0.34414) F_0_714 equ 46802 ; FIX(0.71414) F_1_402 equ 91881 ; FIX(1.40200) F_1_772 equ 116130 ; FIX(1.77200) F_0_402 equ (F_1_402 - 65536) ; FIX(1.40200) - FIX(1) F_0_285 equ ( 65536 - F_0_714) ; FIX(1) - FIX(0.71414) F_0_228 equ (131072 - F_1_772) ; FIX(2) - FIX(1.77200) ; -------------------------------------------------------------------------- SECTION SEG_CONST alignz 32 global EXTN(jconst_merged_upsample_avx2) EXTN(jconst_merged_upsample_avx2): PW_F0402 times 16 dw F_0_402 PW_MF0228 times 16 dw -F_0_228 PW_MF0344_F0285 times 8 dw -F_0_344, F_0_285 PW_ONE times 16 dw 1 PD_ONEHALF times 8 dd 1 << (SCALEBITS-1) alignz 32 ; -------------------------------------------------------------------------- SECTION SEG_TEXT BITS 32 %include "jdmrgext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_RGB_RED %define RGB_GREEN EXT_RGB_GREEN %define RGB_BLUE EXT_RGB_BLUE %define RGB_PIXELSIZE EXT_RGB_PIXELSIZE %define jsimd_h2v1_merged_upsample_avx2 jsimd_h2v1_extrgb_merged_upsample_avx2 %define jsimd_h2v2_merged_upsample_avx2 jsimd_h2v2_extrgb_merged_upsample_avx2 %include "jdmrgext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_RGBX_RED %define RGB_GREEN EXT_RGBX_GREEN %define RGB_BLUE EXT_RGBX_BLUE %define RGB_PIXELSIZE EXT_RGBX_PIXELSIZE %define jsimd_h2v1_merged_upsample_avx2 jsimd_h2v1_extrgbx_merged_upsample_avx2 %define jsimd_h2v2_merged_upsample_avx2 jsimd_h2v2_extrgbx_merged_upsample_avx2 %include "jdmrgext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_BGR_RED %define RGB_GREEN EXT_BGR_GREEN %define RGB_BLUE EXT_BGR_BLUE %define RGB_PIXELSIZE EXT_BGR_PIXELSIZE %define jsimd_h2v1_merged_upsample_avx2 jsimd_h2v1_extbgr_merged_upsample_avx2 %define jsimd_h2v2_merged_upsample_avx2 jsimd_h2v2_extbgr_merged_upsample_avx2 %include "jdmrgext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_BGRX_RED %define RGB_GREEN EXT_BGRX_GREEN %define RGB_BLUE EXT_BGRX_BLUE %define RGB_PIXELSIZE EXT_BGRX_PIXELSIZE %define jsimd_h2v1_merged_upsample_avx2 jsimd_h2v1_extbgrx_merged_upsample_avx2 %define jsimd_h2v2_merged_upsample_avx2 jsimd_h2v2_extbgrx_merged_upsample_avx2 %include "jdmrgext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_XBGR_RED %define RGB_GREEN EXT_XBGR_GREEN %define RGB_BLUE EXT_XBGR_BLUE %define RGB_PIXELSIZE EXT_XBGR_PIXELSIZE %define jsimd_h2v1_merged_upsample_avx2 jsimd_h2v1_extxbgr_merged_upsample_avx2 %define jsimd_h2v2_merged_upsample_avx2 jsimd_h2v2_extxbgr_merged_upsample_avx2 %include "jdmrgext-avx2.asm" %undef RGB_RED %undef RGB_GREEN %undef RGB_BLUE %undef RGB_PIXELSIZE %define RGB_RED EXT_XRGB_RED %define RGB_GREEN EXT_XRGB_GREEN %define RGB_BLUE EXT_XRGB_BLUE %define RGB_PIXELSIZE EXT_XRGB_PIXELSIZE %define jsimd_h2v1_merged_upsample_avx2 jsimd_h2v1_extxrgb_merged_upsample_avx2 %define jsimd_h2v2_merged_upsample_avx2 jsimd_h2v2_extxrgb_merged_upsample_avx2 %include "jdmrgext-avx2.asm"
; Copyright 2005-2014 Intel Corporation. All Rights Reserved. ; ; This file is part of Threading Building Blocks. Threading Building Blocks is free software; ; you can redistribute it and/or modify it under the terms of the GNU General Public License ; version 2 as published by the Free Software Foundation. Threading Building Blocks is ; distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the ; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ; See the GNU General Public License for more details. You should have received a copy of ; the GNU General Public License along with Threading Building Blocks; if not, write to the ; Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ; ; As a special exception, you may use this file as part of a free software library without ; restriction. Specifically, if other files instantiate templates or use macros or inline ; functions from this file, or you compile this file and link it with other files to produce ; an executable, this file does not by itself cause the resulting executable to be covered ; by the GNU General Public License. This exception does not however invalidate any other ; reasons why the executable file might be covered by the GNU General Public License. .686 .model flat,c .code ALIGN 4 PUBLIC c __TBB_machine_fetchadd1 __TBB_machine_fetchadd1: mov edx,4[esp] mov eax,8[esp] lock xadd [edx],al ret .code ALIGN 4 PUBLIC c __TBB_machine_fetchstore1 __TBB_machine_fetchstore1: mov edx,4[esp] mov eax,8[esp] lock xchg [edx],al ret .code ALIGN 4 PUBLIC c __TBB_machine_cmpswp1 __TBB_machine_cmpswp1: mov edx,4[esp] mov ecx,8[esp] mov eax,12[esp] lock cmpxchg [edx],cl ret .code ALIGN 4 PUBLIC c __TBB_machine_fetchadd2 __TBB_machine_fetchadd2: mov edx,4[esp] mov eax,8[esp] lock xadd [edx],ax ret .code ALIGN 4 PUBLIC c __TBB_machine_fetchstore2 __TBB_machine_fetchstore2: mov edx,4[esp] mov eax,8[esp] lock xchg [edx],ax ret .code ALIGN 4 PUBLIC c __TBB_machine_cmpswp2 __TBB_machine_cmpswp2: mov edx,4[esp] mov ecx,8[esp] mov eax,12[esp] lock cmpxchg [edx],cx ret .code ALIGN 4 PUBLIC c __TBB_machine_fetchadd4 __TBB_machine_fetchadd4: mov edx,4[esp] mov eax,8[esp] lock xadd [edx],eax ret .code ALIGN 4 PUBLIC c __TBB_machine_fetchstore4 __TBB_machine_fetchstore4: mov edx,4[esp] mov eax,8[esp] lock xchg [edx],eax ret .code ALIGN 4 PUBLIC c __TBB_machine_cmpswp4 __TBB_machine_cmpswp4: mov edx,4[esp] mov ecx,8[esp] mov eax,12[esp] lock cmpxchg [edx],ecx ret .code ALIGN 4 PUBLIC c __TBB_machine_fetchadd8 __TBB_machine_fetchadd8: push ebx push edi mov edi,12[esp] mov eax,[edi] mov edx,4[edi] __TBB_machine_fetchadd8_loop: mov ebx,16[esp] mov ecx,20[esp] add ebx,eax adc ecx,edx lock cmpxchg8b qword ptr [edi] jnz __TBB_machine_fetchadd8_loop pop edi pop ebx ret .code ALIGN 4 PUBLIC c __TBB_machine_fetchstore8 __TBB_machine_fetchstore8: push ebx push edi mov edi,12[esp] mov ebx,16[esp] mov ecx,20[esp] mov eax,[edi] mov edx,4[edi] __TBB_machine_fetchstore8_loop: lock cmpxchg8b qword ptr [edi] jnz __TBB_machine_fetchstore8_loop pop edi pop ebx ret .code ALIGN 4 PUBLIC c __TBB_machine_cmpswp8 __TBB_machine_cmpswp8: push ebx push edi mov edi,12[esp] mov ebx,16[esp] mov ecx,20[esp] mov eax,24[esp] mov edx,28[esp] lock cmpxchg8b qword ptr [edi] pop edi pop ebx ret .code ALIGN 4 PUBLIC c __TBB_machine_load8 __TBB_machine_Load8: ; If location is on stack, compiler may have failed to align it correctly, so we do dynamic check. mov ecx,4[esp] test ecx,7 jne load_slow ; Load within a cache line sub esp,12 fild qword ptr [ecx] fistp qword ptr [esp] mov eax,[esp] mov edx,4[esp] add esp,12 ret load_slow: ; Load is misaligned. Use cmpxchg8b. push ebx push edi mov edi,ecx xor eax,eax xor ebx,ebx xor ecx,ecx xor edx,edx lock cmpxchg8b qword ptr [edi] pop edi pop ebx ret EXTRN __TBB_machine_store8_slow:PROC .code ALIGN 4 PUBLIC c __TBB_machine_store8 __TBB_machine_Store8: ; If location is on stack, compiler may have failed to align it correctly, so we do dynamic check. mov ecx,4[esp] test ecx,7 jne __TBB_machine_store8_slow ;; tail call to tbb_misc.cpp fild qword ptr 8[esp] fistp qword ptr [ecx] ret end
; Z88 Small C+ Run Time Library ; Long functions ; ; feilipu 10/2021 SECTION code_clib SECTION code_l_sccz80 PUBLIC l_long_cpl_mde ;primary = 1s complement primary ;enter with primary in (de) .l_long_cpl_mde ld a,(de) cpl ld (de),a inc de ld a,(de) cpl ld (de),a inc de ld a,(de) cpl ld (de),a inc de ld a,(de) cpl ld (de),a ret
// Copyright 2016 The Fuchsia 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 "devfs.h" #include <fcntl.h> #include <fidl/fuchsia.io/cpp/wire.h> #include <lib/async/cpp/wait.h> #include <lib/ddk/driver.h> #include <lib/fdio/directory.h> #include <lib/fidl/coding.h> #include <lib/fidl/cpp/message_part.h> #include <lib/fidl/txn_header.h> #include <lib/zx/channel.h> #include <stdio.h> #include <string.h> #include <zircon/types.h> #include <memory> #include <fbl/ref_ptr.h> #include <fbl/string_buffer.h> #include "coordinator.h" #include "src/devices/bin/driver_manager/builtin_devices.h" #include "src/devices/lib/log/log.h" namespace { namespace fio = fuchsia_io; async_dispatcher_t* g_dispatcher = nullptr; uint64_t next_ino = 2; std::unique_ptr<Devnode> class_devnode; std::unique_ptr<Devnode> devfs_mkdir(Devnode* parent, std::string_view name); // Dummy node to represent dev/diagnostics directory. std::unique_ptr<Devnode> diagnostics_devnode; // Dummy node to represent dev/null directory. std::unique_ptr<Devnode> null_devnode; // Dummy node to represent dev/zero directory. std::unique_ptr<Devnode> zero_devnode; // Connection to diagnostics VFS server. Channel is owned by inspect manager. std::optional<fidl::UnownedClientEnd<fuchsia_io::Directory>> diagnostics_channel; const char kDiagnosticsDirName[] = "diagnostics"; const size_t kDiagnosticsDirLen = strlen(kDiagnosticsDirName); zx::channel g_devfs_root; } // namespace struct Watcher : fbl::DoublyLinkedListable<std::unique_ptr<Watcher>, fbl::NodeOptions::AllowRemoveFromContainer> { Watcher(Devnode* dn, fidl::ServerEnd<fuchsia_io::DirectoryWatcher> server_end, fio::wire::WatchMask mask) : devnode(dn), server_end(std::move(server_end)), mask(mask) {} Watcher(const Watcher&) = delete; Watcher& operator=(const Watcher&) = delete; Watcher(Watcher&&) = delete; Watcher& operator=(Watcher&&) = delete; void HandleChannelClose(async_dispatcher_t* dispatcher, async::WaitBase* wait, zx_status_t status, const zx_packet_signal_t* signal); Devnode* devnode = nullptr; fidl::ServerEnd<fuchsia_io::DirectoryWatcher> server_end; fio::wire::WatchMask mask; async::WaitMethod<Watcher, &Watcher::HandleChannelClose> channel_close_wait{this}; }; void Watcher::HandleChannelClose(async_dispatcher_t* dispatcher, async::WaitBase* wait, zx_status_t status, const zx_packet_signal_t* signal) { if (status == ZX_OK) { if (signal->observed & ZX_CHANNEL_PEER_CLOSED) { RemoveFromContainer(); } } } class DcIostate : public fbl::DoublyLinkedListable<DcIostate*>, public fidl::WireServer<fuchsia_io::Directory> { public: explicit DcIostate(Devnode* dn, async_dispatcher_t* dispatcher); ~DcIostate() override; static void Bind(std::unique_ptr<DcIostate> ios, fidl::ServerEnd<fio::Node> request); // Remove this DcIostate from its devnode void DetachFromDevnode(); void AdvisoryLock(AdvisoryLockRequestView request, AdvisoryLockCompleter::Sync& completer) override { completer.ReplyError(ZX_ERR_NOT_SUPPORTED); } void Clone(CloneRequestView request, CloneCompleter::Sync& completer) override; void CloseDeprecated(CloseDeprecatedRequestView request, CloseDeprecatedCompleter::Sync& completer) override; void Close(CloseRequestView request, CloseCompleter::Sync& completer) override; void Describe(DescribeRequestView request, DescribeCompleter::Sync& completer) override; void Describe2(Describe2RequestView request, Describe2Completer::Sync& completer) override; void SyncDeprecated(SyncDeprecatedRequestView request, SyncDeprecatedCompleter::Sync& completer) override { completer.Reply(ZX_ERR_NOT_SUPPORTED); } void Sync(SyncRequestView request, SyncCompleter::Sync& completer) override { completer.ReplyError(ZX_ERR_NOT_SUPPORTED); } void GetAttr(GetAttrRequestView request, GetAttrCompleter::Sync& completer) override; void SetAttr(SetAttrRequestView request, SetAttrCompleter::Sync& completer) override { completer.Reply(ZX_ERR_NOT_SUPPORTED); } void Open(OpenRequestView request, OpenCompleter::Sync& completer) override; void AddInotifyFilter(AddInotifyFilterRequestView request, AddInotifyFilterCompleter::Sync& completer) override {} void Unlink(UnlinkRequestView request, UnlinkCompleter::Sync& completer) override { zx_status_t status = ZX_ERR_NOT_SUPPORTED; completer.Reply(::fuchsia_io::wire::Directory2UnlinkResult::WithErr(status)); } void ReadDirents(ReadDirentsRequestView request, ReadDirentsCompleter::Sync& completer) override; void Rewind(RewindRequestView request, RewindCompleter::Sync& completer) override; void GetToken(GetTokenRequestView request, GetTokenCompleter::Sync& completer) override { completer.Reply(ZX_ERR_NOT_SUPPORTED, zx::handle()); } void Rename(RenameRequestView request, RenameCompleter::Sync& completer) override { zx_status_t status = ZX_ERR_NOT_SUPPORTED; completer.Reply(::fuchsia_io::wire::Directory2RenameResult::WithErr(status)); } void Link(LinkRequestView request, LinkCompleter::Sync& completer) override { completer.Reply(ZX_ERR_NOT_SUPPORTED); } void Watch(WatchRequestView request, WatchCompleter::Sync& completer) override; void GetFlags(GetFlagsRequestView request, GetFlagsCompleter::Sync& completer) override { completer.Reply(ZX_ERR_NOT_SUPPORTED, {}); } void SetFlags(SetFlagsRequestView request, SetFlagsCompleter::Sync& completer) override { completer.Reply(ZX_ERR_NOT_SUPPORTED); } void QueryFilesystem(QueryFilesystemRequestView request, QueryFilesystemCompleter::Sync& completer) override; private: // pointer to our devnode, nullptr if it has been removed Devnode* devnode_; std::optional<fidl::ServerBindingRef<fuchsia_io::Directory>> binding_; async_dispatcher_t* dispatcher_; uint64_t readdir_ino_ = 0; }; namespace { struct ProtocolInfo { const char* name; std::unique_ptr<Devnode> devnode; uint32_t id; uint32_t flags; }; ProtocolInfo proto_infos[] = { #define DDK_PROTOCOL_DEF(tag, val, name, flags) {name, nullptr, val, flags}, #include <lib/ddk/protodefs.h> }; // A devnode is a directory (from stat's perspective) if // it has children, or if it doesn't have a device, or if // its device has no rpc handle bool devnode_is_dir(const Devnode* dn) { if (dn->children.is_empty()) { return (dn->device == nullptr) || (!dn->device->device_controller().is_valid()) || (!dn->device->coordinator_binding().has_value()); } return true; } // Local devnodes are ones that we should not hand off OPEN // RPCs to the underlying driver_host bool devnode_is_local(Devnode* dn) { if (dn->service_dir) { return false; } if (dn->device == nullptr) { return true; } if (!dn->device->device_controller().is_valid()) { return true; } if (dn->device->flags & DEV_CTX_MUST_ISOLATE) { return true; } return false; } // Notify a single watcher about the given operation and path. On failure, // frees the watcher. This can only be called on a watcher that has not yet // been added to a Devnode's watchers list. void devfs_notify_single(std::unique_ptr<Watcher>* watcher, const fbl::String& name, fio::wire::WatchEvent op) { size_t len = name.length(); if (!*watcher || len > fio::wire::kMaxFilename) { return; } ZX_ASSERT(!(*watcher)->InContainer()); uint8_t msg[fio::wire::kMaxFilename + 2]; const uint32_t msg_len = static_cast<uint32_t>(len + 2); msg[0] = static_cast<uint8_t>(op); msg[1] = static_cast<uint8_t>(len); memcpy(msg + 2, name.c_str(), len); // convert to mask fio::wire::WatchMask mask = static_cast<fio::wire::WatchMask>(1u << static_cast<uint8_t>(op)); if (!((*watcher)->mask & mask)) { return; } if ((*watcher)->server_end.channel().write(0, msg, msg_len, nullptr, 0) != ZX_OK) { watcher->reset(); } } void devfs_notify(Devnode* dn, std::string_view name, fio::wire::WatchEvent op) { if (dn->watchers.is_empty()) { return; } size_t len = name.length(); if (len > fio::wire::kMaxFilename) { return; } uint8_t msg[fio::wire::kMaxFilename + 2]; const uint32_t msg_len = static_cast<uint32_t>(len + 2); msg[0] = static_cast<uint8_t>(op); msg[1] = static_cast<uint8_t>(len); memcpy(msg + 2, name.data(), len); // convert to mask fio::wire::WatchMask mask = static_cast<fio::wire::WatchMask>(1u << static_cast<uint8_t>(op)); for (auto itr = dn->watchers.begin(); itr != dn->watchers.end();) { auto& cur = *itr; // Advance the iterator now instead of at the end of the loop because we // may erase the current element from the list. ++itr; if (!(cur.mask & mask)) { continue; } if (cur.server_end.channel().write(0, msg, msg_len, nullptr, 0) != ZX_OK) { dn->watchers.erase(cur); // The Watcher is free'd here } } } } // namespace void devfs_prepopulate_class(Devnode* dn) { for (auto& info : proto_infos) { if (!(info.flags & PF_NOPUB)) { info.devnode = devfs_mkdir(dn, info.name); } } } Devnode* devfs_proto_node(uint32_t protocol_id) { for (const auto& info : proto_infos) { if (info.id == protocol_id) { return info.devnode.get(); } } return nullptr; } zx_status_t devfs_watch(Devnode* dn, fidl::ServerEnd<fio::DirectoryWatcher> server_end, fio::wire::WatchMask mask) { auto watcher = std::make_unique<Watcher>(dn, std::move(server_end), mask); if (watcher == nullptr) { return ZX_ERR_NO_MEMORY; } // If the watcher has asked for all existing entries, send it all of them // followed by the end-of-existing marker (IDLE). if (mask & fio::wire::WatchMask::kExisting) { for (const auto& child : dn->children) { if (child.device && (child.device->flags & DEV_CTX_INVISIBLE)) { continue; } // TODO: send multiple per write devfs_notify_single(&watcher, child.name, fio::wire::WatchEvent::kExisting); } devfs_notify_single(&watcher, "", fio::wire::WatchEvent::kIdle); } // Watcher may have been freed by devfs_notify_single, so check before // adding. if (watcher) { dn->watchers.push_front(std::move(watcher)); Watcher& watcher_ref = dn->watchers.front(); watcher_ref.channel_close_wait.set_object(watcher_ref.server_end.channel().get()); watcher_ref.channel_close_wait.set_trigger(ZX_CHANNEL_PEER_CLOSED); watcher_ref.channel_close_wait.Begin(g_dispatcher); } return ZX_OK; } bool devfs_has_watchers(Devnode* dn) { return !dn->watchers.is_empty(); } namespace { std::unique_ptr<Devnode> devfs_mknode(const fbl::RefPtr<Device>& dev, std::string_view name) { auto dn = std::make_unique<Devnode>(name); if (!dn) { return nullptr; } dn->ino = next_ino++; // TODO(teisenbe): This should probably be refcounted dn->device = dev.get(); return dn; } std::unique_ptr<Devnode> devfs_mkdir(Devnode* parent, std::string_view name) { std::unique_ptr<Devnode> dn = devfs_mknode(nullptr, name); if (dn == nullptr) { return nullptr; } dn->parent = parent; parent->children.push_back(dn.get()); return dn; } Devnode* devfs_lookup(Devnode* parent, std::string_view name) { for (auto& child : parent->children) { if (name == static_cast<std::string_view>(child.name)) { return &child; } } return nullptr; } zx_status_t fill_dirent(vdirent_t* de, size_t delen, uint64_t ino, const fbl::String& name, uint8_t type) { size_t len = name.length(); size_t sz = sizeof(vdirent_t) + len; if (sz > delen || len > NAME_MAX) { return ZX_ERR_INVALID_ARGS; } de->ino = ino; de->size = static_cast<uint8_t>(len); de->type = type; memcpy(de->name, name.c_str(), len); return static_cast<zx_status_t>(sz); } zx_status_t devfs_readdir(Devnode* dn, uint64_t* ino_inout, void* data, size_t len) { char* ptr = static_cast<char*>(data); uint64_t ino = *ino_inout; for (const auto& child : dn->children) { if (child.ino <= ino) { continue; } if (child.device == nullptr) { // "pure" directories (like /dev/class/$NAME) do not show up // if they have no children, to avoid clutter and confusion. // They remain openable, so they can be watched. // // An exception being /dev/diagnostics which is served by different VFS // and should be listed even though it has no devnode children. // // Another exception is when the devnode is for a remote service. if (child.children.is_empty() && child.ino != diagnostics_devnode->ino && child.ino != null_devnode->ino && child.ino != zero_devnode->ino && !child.service_dir) { continue; } } else { // invisible devices also do not show up if (child.device->flags & DEV_CTX_INVISIBLE) { continue; } } ino = child.ino; auto vdirent = reinterpret_cast<vdirent_t*>(ptr); zx_status_t r = fill_dirent(vdirent, len, ino, child.name, VTYPE_TO_DTYPE(V_TYPE_DIR)); if (r < 0) { break; } ptr += r; len -= r; } *ino_inout = ino; return static_cast<zx_status_t>(ptr - static_cast<char*>(data)); } zx_status_t devfs_walk(Devnode** dn_inout, char* path) { Devnode* dn = *dn_inout; again: if ((path == nullptr) || (path[0] == 0)) { *dn_inout = dn; return ZX_OK; } char* name = path; if ((path = strchr(path, '/')) != nullptr) { *path++ = 0; } if (name[0] == 0) { return ZX_ERR_BAD_PATH; } for (auto& child : dn->children) { if (!strcmp(child.name.c_str(), name)) { if (child.device && (child.device->flags & DEV_CTX_INVISIBLE)) { continue; } dn = &child; goto again; } } // The path only partially matched. return ZX_ERR_NOT_FOUND; } void devfs_open(Devnode* dirdn, async_dispatcher_t* dispatcher, fidl::ServerEnd<fio::Node> ipc, char* path, fio::OpenFlags flags) { std::string_view path_view(path); // Filter requests for diagnostics path and pass it on to diagnostics vfs server. if (!strncmp(path, kDiagnosticsDirName, kDiagnosticsDirLen) && (path[kDiagnosticsDirLen] == '\0' || path[kDiagnosticsDirLen] == '/')) { char* dir_path = path + kDiagnosticsDirLen; char current_dir[] = "."; if (dir_path[0] == '/') { dir_path++; } else { dir_path = current_dir; } fidl::WireCall(*diagnostics_channel) ->Open(flags, 0, fidl::StringView::FromExternal(dir_path), std::move(ipc)); } else if (path_view == kNullDevName || path_view == kZeroDevName) { BuiltinDevices::Get(dispatcher)->HandleOpen(flags, std::move(ipc), path_view); } else { if (!strcmp(path, ".")) { path = nullptr; } auto describe = [&ipc, describe = flags & fio::wire::OpenFlags::kDescribe]( zx::status<fio::wire::NodeInfo> node_info) { if (describe) { __UNUSED auto result = fidl::WireSendEvent(ipc)->OnOpen( node_info.status_value(), node_info.is_ok() ? std::move(node_info.value()) : fio::wire::NodeInfo()); } }; Devnode* dn = dirdn; if (zx_status_t status = devfs_walk(&dn, path); status != ZX_OK) { describe(zx::error(status)); return; } // If we are a local-only node, or we are asked to not go remote, or we are asked to // open-as-a-directory, open locally: if (devnode_is_local(dn) || flags & (fio::wire::OpenFlags::kNoRemote | fio::wire::OpenFlags::kDirectory)) { auto ios = std::make_unique<DcIostate>(dn, dispatcher); if (ios == nullptr) { describe(zx::error(ZX_ERR_NO_MEMORY)); return; } fio::wire::DirectoryObject directory; describe(zx::ok(fio::wire::NodeInfo::WithDirectory(directory))); DcIostate::Bind(std::move(ios), std::move(ipc)); } else if (dn->service_dir) { fidl::WireCall(dn->service_dir) ->Open(flags, 0, fidl::StringView::FromExternal(dn->service_path), std::move(ipc)); } else { __UNUSED auto result = dn->device->device_controller()->Open(flags, 0, ".", std::move(ipc)); } } } void devfs_remove(Devnode* dn) { if (dn->InContainer()) { dn->parent->children.erase(*dn); } // detach all connected iostates while (!dn->iostate.is_empty()) { dn->iostate.front().DetachFromDevnode(); } // notify own file watcher if ((dn->device == nullptr) || !(dn->device->flags & DEV_CTX_INVISIBLE)) { devfs_notify(dn, "", fio::wire::WatchEvent::kDeleted); } // disconnect from device and notify parent/link directory watchers if (dn->device != nullptr) { if (dn->device->self == dn) { dn->device->self = nullptr; if ((dn->device->parent() != nullptr) && (dn->device->parent()->self != nullptr) && !(dn->device->flags & DEV_CTX_INVISIBLE)) { devfs_notify(dn->device->parent()->self, dn->name, fio::wire::WatchEvent::kRemoved); } } if (dn->device->link == dn) { dn->device->link = nullptr; if (!(dn->device->flags & DEV_CTX_INVISIBLE)) { Devnode* dir = devfs_proto_node(dn->device->protocol_id()); devfs_notify(dir, dn->name, fio::wire::WatchEvent::kRemoved); } } dn->device = nullptr; } // destroy all watchers dn->watchers.clear(); // detach children // They will be unpublished when the devices they're associated with are // eventually destroyed. dn->children.clear(); } } // namespace Devnode::Devnode(fbl::String name) : name(std::move(name)) {} Devnode::~Devnode() { devfs_remove(this); } DcIostate::DcIostate(Devnode* dn, async_dispatcher_t* dispatcher) : devnode_(dn), dispatcher_(dispatcher) { devnode_->iostate.push_back(this); } DcIostate::~DcIostate() { DetachFromDevnode(); } void DcIostate::Bind(std::unique_ptr<DcIostate> ios, fidl::ServerEnd<fio::Node> request) { std::optional<fidl::ServerBindingRef<fuchsia_io::Directory>>* binding = &ios->binding_; *binding = fidl::BindServer(ios->dispatcher_, fidl::ServerEnd<fuchsia_io::Directory>(request.TakeChannel()), std::move(ios)); } void DcIostate::DetachFromDevnode() { if (devnode_ != nullptr) { devnode_->iostate.erase(*this); devnode_ = nullptr; } if (std::optional binding = std::exchange(binding_, std::nullopt); binding.has_value()) { binding.value().Unbind(); } } void devfs_advertise(const fbl::RefPtr<Device>& dev) { if (dev->link) { Devnode* dir = devfs_proto_node(dev->protocol_id()); devfs_notify(dir, dev->link->name, fio::wire::WatchEvent::kAdded); } if (dev->self->parent) { devfs_notify(dev->self->parent, dev->self->name, fio::wire::WatchEvent::kAdded); } } // TODO: generate a MODIFIED event rather than back to back REMOVED and ADDED void devfs_advertise_modified(const fbl::RefPtr<Device>& dev) { if (dev->link) { Devnode* dir = devfs_proto_node(dev->protocol_id()); devfs_notify(dir, dev->link->name, fio::wire::WatchEvent::kRemoved); devfs_notify(dir, dev->link->name, fio::wire::WatchEvent::kAdded); } if (dev->self->parent) { devfs_notify(dev->self->parent, dev->self->name, fio::wire::WatchEvent::kRemoved); devfs_notify(dev->self->parent, dev->self->name, fio::wire::WatchEvent::kAdded); } } zx_status_t devfs_seq_name(Devnode* dir, char* data, size_t size) { for (unsigned n = 0; n < 1000; n++) { snprintf(data, size, "%03u", (dir->seqcount++) % 1000); if (devfs_lookup(dir, data) == nullptr) { return ZX_OK; } } return ZX_ERR_ALREADY_EXISTS; } zx_status_t devfs_publish(const fbl::RefPtr<Device>& parent, const fbl::RefPtr<Device>& dev) { if ((parent->self == nullptr) || (dev->self != nullptr) || (dev->link != nullptr)) { return ZX_ERR_INTERNAL; } std::unique_ptr<Devnode> dnself = devfs_mknode(dev, dev->name()); if (dnself == nullptr) { return ZX_ERR_NO_MEMORY; } if ((dev->protocol_id() == ZX_PROTOCOL_TEST_PARENT) || (dev->protocol_id() == ZX_PROTOCOL_MISC)) { // misc devices are singletons, not a class // in the sense of other device classes. // They do not get aliases in /dev/class/misc/... // instead they exist only under their parent // device. goto done; } // Create link in /dev/class/... if this id has a published class if (auto dir = devfs_proto_node(dev->protocol_id()); dir != nullptr) { char buf[4] = {}; auto name = dev->name(); if (dev->protocol_id() != ZX_PROTOCOL_CONSOLE) { zx_status_t status = devfs_seq_name(dir, buf, sizeof(buf)); if (status != ZX_OK) { return status; } name = buf; } std::unique_ptr<Devnode> dnlink = devfs_mknode(dev, name); if (dnlink == nullptr) { return ZX_ERR_NO_MEMORY; } // add link node to class directory dnlink->parent = dir; dir->children.push_back(dnlink.get()); dev->link = dnlink.release(); } done: // add self node to parent directory dnself->parent = parent->self; parent->self->children.push_back(dnself.get()); dev->self = dnself.release(); if (!(dev->flags & DEV_CTX_INVISIBLE)) { devfs_advertise(dev); } return ZX_OK; } // TODO(teisenbe): Ideally this would take a RefPtr, but currently this is // invoked in the dtor for Device. void devfs_unpublish(Device* dev) { if (dev->self != nullptr) { delete dev->self; dev->self = nullptr; } if (dev->link != nullptr) { delete dev->link; dev->link = nullptr; } } zx_status_t devfs_connect(const Device* dev, fidl::ServerEnd<fio::Node> client_remote) { if (!client_remote.is_valid()) { return ZX_ERR_BAD_HANDLE; } __UNUSED auto result = dev->device_controller()->Open({}, 0, ".", std::move(client_remote)); return ZX_OK; } void devfs_connect_diagnostics(fidl::UnownedClientEnd<fio::Directory> h) { diagnostics_channel = std::make_optional<fidl::UnownedClientEnd<fio::Directory>>(h); } void DcIostate::Open(OpenRequestView request, OpenCompleter::Sync& completer) { if (request->path.size() <= fio::wire::kMaxPath) { fbl::StringBuffer<fio::wire::kMaxPath + 1> terminated_path; terminated_path.Append(request->path.data(), request->path.size()); devfs_open(devnode_, dispatcher_, std::move(request->object), terminated_path.data(), request->flags); } } void DcIostate::Clone(CloneRequestView request, CloneCompleter::Sync& completer) { if (request->flags & fio::wire::OpenFlags::kCloneSameRights) { request->flags |= fio::wire::OpenFlags::kRightReadable | fio::wire::OpenFlags::kRightWritable; } char path[] = "."; devfs_open(devnode_, dispatcher_, std::move(request->object), path, request->flags | fio::wire::OpenFlags::kNoRemote); } void DcIostate::QueryFilesystem(QueryFilesystemRequestView request, QueryFilesystemCompleter::Sync& completer) { fuchsia_io::wire::FilesystemInfo info; strlcpy(reinterpret_cast<char*>(info.name.data()), "devfs", fuchsia_io::wire::kMaxFsNameBuffer); completer.Reply(ZX_OK, fidl::ObjectView<fuchsia_io::wire::FilesystemInfo>::FromExternal(&info)); } void DcIostate::Watch(WatchRequestView request, WatchCompleter::Sync& completer) { zx_status_t status; if (!request->mask || request->options != 0) { status = ZX_ERR_INVALID_ARGS; } else { status = devfs_watch(devnode_, std::move(request->watcher), request->mask); } completer.Reply(status); } void DcIostate::Rewind(RewindRequestView request, RewindCompleter::Sync& completer) { readdir_ino_ = 0; completer.Reply(ZX_OK); } void DcIostate::ReadDirents(ReadDirentsRequestView request, ReadDirentsCompleter::Sync& completer) { if (request->max_bytes > fio::wire::kMaxBuf) { completer.Reply(ZX_ERR_INVALID_ARGS, fidl::VectorView<uint8_t>()); return; } uint8_t data[fio::wire::kMaxBuf]; size_t actual = 0; zx_status_t status = devfs_readdir(devnode_, &readdir_ino_, data, request->max_bytes); if (status >= 0) { actual = status; status = ZX_OK; } completer.Reply(status, fidl::VectorView<uint8_t>::FromExternal(data, actual)); } void DcIostate::GetAttr(GetAttrRequestView request, GetAttrCompleter::Sync& completer) { uint32_t mode; if (devnode_is_dir(devnode_)) { mode = V_TYPE_DIR | V_IRUSR | V_IWUSR; } else { mode = V_TYPE_CDEV | V_IRUSR | V_IWUSR; } fio::wire::NodeAttributes attributes; attributes.mode = mode; attributes.content_size = 0; attributes.link_count = 1; attributes.id = devnode_->ino; completer.Reply(ZX_OK, attributes); } void DcIostate::Describe(DescribeRequestView request, DescribeCompleter::Sync& completer) { fio::wire::DirectoryObject directory; completer.Reply(fio::wire::NodeInfo::WithDirectory(directory)); } void DcIostate::Describe2(Describe2RequestView request, Describe2Completer::Sync& completer) { fio::wire::DirectoryInfo directory_info; fio::wire::Representation representation = fio::wire::Representation::WithDirectory( fidl::ObjectView<decltype(directory_info)>::FromExternal(&directory_info)); fio::wire::ConnectionInfo connection_info; connection_info.set_representation( fidl::ObjectView<decltype(representation)>::FromExternal(&representation)); completer.Reply(connection_info); } void DcIostate::CloseDeprecated(CloseDeprecatedRequestView request, CloseDeprecatedCompleter::Sync& completer) { completer.Reply(ZX_OK); completer.Close(ZX_OK); } void DcIostate::Close(CloseRequestView request, CloseCompleter::Sync& completer) { completer.ReplySuccess(); completer.Close(ZX_OK); } zx::unowned_channel devfs_root_borrow() { return zx::unowned_channel(g_devfs_root); } zx::channel devfs_root_clone() { return zx::channel(fdio_service_clone(g_devfs_root.get())); } void devfs_init(const fbl::RefPtr<Device>& device, async_dispatcher_t* dispatcher) { g_dispatcher = dispatcher; auto root_devnode = std::make_unique<Devnode>(""); if (!root_devnode) { return; } root_devnode->ino = 1; class_devnode = devfs_mkdir(root_devnode.get(), "class"); if (!class_devnode) { return; } devfs_prepopulate_class(class_devnode.get()); // Create dummy diagnostics devnode, so that the directory is listed. diagnostics_devnode = devfs_mkdir(root_devnode.get(), "diagnostics"); // Create dummy null devnode, so that the directory is listed. null_devnode = devfs_mkdir(root_devnode.get(), "null"); // Create dummy zero devnode, so that the directory is listed. zero_devnode = devfs_mkdir(root_devnode.get(), "zero"); // TODO(teisenbe): Should this take a reference? root_devnode->device = device.get(); root_devnode->device->self = root_devnode.get(); auto endpoints = fidl::CreateEndpoints<fio::Node>(); if (endpoints.is_error()) { return; } auto ios = std::make_unique<DcIostate>(root_devnode.get(), dispatcher); if (ios == nullptr) { return; } DcIostate::Bind(std::move(ios), std::move(endpoints->server)); g_devfs_root = endpoints->client.TakeChannel(); // This is actually owned by |device| and will be freed in unpublish __UNUSED auto ptr = root_devnode.release(); } zx_status_t devfs_walk(Devnode* dn, const char* path, fbl::RefPtr<Device>* dev) { Devnode* inout = dn; char path_copy[PATH_MAX]; if (strlen(path) + 1 > sizeof(path_copy)) { return ZX_ERR_BUFFER_TOO_SMALL; } strcpy(path_copy, path); zx_status_t status = devfs_walk(&inout, path_copy); if (status != ZX_OK) { return status; } *dev = fbl::RefPtr(inout->device); return ZX_OK; } zx_status_t devfs_export(Devnode* dn, fidl::ClientEnd<fuchsia_io::Directory> service_dir, std::string_view service_path, std::string_view devfs_path, uint32_t protocol_id, std::vector<std::unique_ptr<Devnode>>& out) { // Check if the `devfs_path` provided is valid. const auto is_valid_path = [](std::string_view path) { return !path.empty() && path.front() != '/' && path.back() != '/'; }; if (!is_valid_path(service_path) || !is_valid_path(devfs_path)) { return ZX_ERR_INVALID_ARGS; } // Walk the `devfs_path` and call `process` on each part of the path. // // e.g. If devfs_path is "platform/acpi/acpi-pwrbtn", then process will be // called with "platform", then "acpi", then "acpi-pwrbtn". std::string_view::size_type begin = 0, end = 0; const auto walk = [&devfs_path, &begin, &end](auto process) { do { // Consume excess separators. while (devfs_path[begin] == '/') { ++begin; } end = devfs_path.find('/', begin); auto size = end == std::string_view::npos ? end : end - begin; if (!process(devfs_path.substr(begin, size))) { break; } begin = end + 1; } while (end != std::string_view::npos); }; // Walk `devfs_path` and find the last Devnode that exists, so we can create // the rest of the path underneath it. Devnode* prev_dn = nullptr; walk([&dn, &prev_dn](std::string_view name) { prev_dn = dn; dn = devfs_lookup(dn, name); return dn != nullptr; }); // The full path described by `devfs_path` already exists. if (dn != nullptr) { return ZX_ERR_ALREADY_EXISTS; } // Create Devnodes for the remainder of the path, and set `service_dir` and // `service_path` on the leaf Devnode. dn = prev_dn; walk([&out, &dn](std::string_view name) { out.push_back(devfs_mkdir(dn, name)); devfs_notify(dn, name, fio::wire::WatchEvent::kAdded); dn = out.back().get(); return true; }); dn->service_dir = std::move(service_dir); dn->service_path = service_path; // If a protocol directory exists for `protocol_id`, then create a Devnode // under the protocol directory too. if (auto dir = devfs_proto_node(protocol_id); dir != nullptr) { char name[4] = {}; zx_status_t status = devfs_seq_name(dir, name, sizeof(name)); if (status != ZX_OK) { return status; } out.push_back(devfs_mkdir(dir, name)); devfs_notify(dir, name, fio::wire::WatchEvent::kAdded); // Clone the service node for the entry in the protocol directory. auto endpoints = fidl::CreateEndpoints<fio::Node>(); if (endpoints.is_error()) { return endpoints.status_value(); } auto result = fidl::WireCall(dn->service_dir) ->Clone(fio::wire::OpenFlags::kCloneSameRights, std::move(endpoints->server)); if (!result.ok()) { return result.status(); } Devnode* class_dn = out.back().get(); class_dn->service_dir.channel().swap(endpoints->client.channel()); class_dn->service_path = service_path; } return ZX_OK; }
; A175228: Remaining sequence of step 3 of sieve from A175227. ; 1,4,8,10,14,16,20,22,25,27,30,33,35,38,40,44,46,49,51,54,56,58,62,64,66,69,72,75,77,80,82,85,87,90,92,94,96,99,102 mul $0,2 cal $0,65090 ; Natural numbers which are not odd primes: composites plus 1 and 2. mov $1,$0
; A265024: a(n) = n! * Sum_{d in D(n+1)} (-1)^(d+1)*(n+1)/d, D(n) the divisors of n. ; Submitted by Christian Krause ; 1,1,8,6,144,480,5760,5040,524160,2177280,43545600,159667200,6706022400,49816166400,2092278988800,1307674368000,376610217984000,4623936565248000,128047474114560000,729870602452992000,77852864261652480000,613091306060513280000 mov $2,$0 seq $0,318876 ; Sum of divisors d of n for which 2*phi(d) > d. lpb $2 mul $0,$2 sub $2,1 lpe
//////////////////////////////////////////////////////////////////////////////// // Copyright (c) 2012 Bryce Adelstein-Lelbach // // SPDX-License-Identifier: BSL-1.0 // 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 <hpx/config.hpp> #if !defined(HPX_COMPUTE_DEVICE_CODE) #include <hpx/hpx_main.hpp> #include <hpx/iostream.hpp> #include <hpx/include/actions.hpp> #include <hpx/include/components.hpp> #include <hpx/modules/testing.hpp> #include <string> bool a_ctor = false; bool a_dtor = false; bool b_ctor = false; bool b_dtor = false; /////////////////////////////////////////////////////////////////////////////// // Abstract struct A : hpx::components::abstract_managed_component_base<A> { A() { a_ctor = true; } virtual ~A() { a_dtor = true; } virtual std::string test0() const = 0; std::string test0_nonvirt() const { return test0(); } HPX_DEFINE_COMPONENT_ACTION(A, test0_nonvirt, test0_action); }; HPX_REGISTER_COMPONENT_HEAP(hpx::components::managed_component<A>); HPX_DEFINE_GET_COMPONENT_TYPE(A); typedef A::test0_action test0_action; HPX_REGISTER_ACTION_DECLARATION(test0_action); HPX_REGISTER_ACTION(test0_action); /////////////////////////////////////////////////////////////////////////////// // Concrete struct B : A, hpx::components::managed_component_base<B> { typedef hpx::components::managed_component_base<B>::wrapping_type wrapping_type; typedef B type_holder; typedef A base_type_holder; B() { b_ctor = true; } ~B() { b_dtor = true; } std::string test0() const override { return "B"; } std::string test1() const { return "B"; } HPX_DEFINE_COMPONENT_ACTION(B, test1, test1_action); }; typedef hpx::components::managed_component<B> serverB_type; HPX_REGISTER_DERIVED_COMPONENT_FACTORY(serverB_type, B, "A"); typedef B::test1_action test1_action; HPX_REGISTER_ACTION_DECLARATION(test1_action); HPX_REGISTER_ACTION(test1_action); /////////////////////////////////////////////////////////////////////////////// struct clientA : hpx::components::client_base<clientA, A> { typedef hpx::components::client_base<clientA, A> base_type; clientA(hpx::shared_future<hpx::id_type> const& gid) : base_type(gid) {} std::string test0() { test0_action act; return act(base_type::get_id()); } }; /////////////////////////////////////////////////////////////////////////////// struct clientB : hpx::components::client_base<clientB, B> { typedef hpx::components::client_base<clientB, B> base_type; clientB(hpx::shared_future<hpx::id_type> const& gid) : base_type(gid) {} std::string test0() { test0_action act; return act(base_type::get_id()); } std::string test1() { test1_action act; return act(base_type::get_id()); } }; /////////////////////////////////////////////////////////////////////////////// void reset_globals() { a_ctor = false; a_dtor = false; b_ctor = false; b_dtor = false; } int main() { /////////////////////////////////////////////////////////////////////////// { // Client to A, instance of B clientA obj(hpx::components::new_<B>(hpx::find_here())); HPX_TEST_EQ(obj.test0(), "B"); } // Make sure AGAS kicked in... hpx::agas::garbage_collect(); hpx::this_thread::yield(); HPX_TEST(a_ctor); HPX_TEST(a_dtor); HPX_TEST(b_ctor); HPX_TEST(b_dtor); reset_globals(); /////////////////////////////////////////////////////////////////////////// { // Client to B, instance of B clientB obj(hpx::components::new_<B>(hpx::find_here())); HPX_TEST_EQ(obj.test0(), "B"); HPX_TEST_EQ(obj.test1(), "B"); } // Make sure AGAS kicked in... hpx::agas::garbage_collect(); hpx::this_thread::yield(); HPX_TEST(a_ctor); HPX_TEST(a_dtor); HPX_TEST(b_ctor); HPX_TEST(b_dtor); reset_globals(); return 0; } #endif
; A256539: Number of partitions of 4n into at most 5 parts. ; Submitted by Jamie Morken(s2) ; 1,5,18,47,101,192,333,540,831,1226,1747,2418,3266,4319,5608,7166,9027,11229,13811,16814,20282,24260,28796,33940,39744,46262,53550,61667,70673,80631,91606,103664,116875,131310,147042,164147,182702,202787,224484,247877,273052,300097,329103,360162,393369,428821,466616,506856,549644,595085,643287,694359,748413,805563,865925,929617,996759,1067474,1141886,1220122,1302311,1388583,1479072,1573913,1673243,1777202,1885931,1999574,2118277,2242188,2371457,2506236,2646680,2792945,2945190,3103576,3268265 mov $2,$0 mov $4,$0 lpb $2 mov $0,$4 sub $2,1 sub $0,$2 mov $5,$0 mov $6,0 mov $7,$0 add $7,1 lpb $7 mov $0,$5 sub $7,1 sub $0,$7 mov $3,$0 mul $3,7 add $0,$3 seq $0,25770 ; Expansion of 1/((1-x)(1-x^3)(1-x^10)). add $6,$0 lpe add $1,$6 lpe mov $0,$1 add $0,1
; A003984: Table of max(x,y), where (x,y) = (0,0),(0,1),(1,0),(0,2),(1,1),(2,0),... ; 0,1,1,2,1,2,3,2,2,3,4,3,2,3,4,5,4,3,3,4,5,6,5,4,3,4,5,6,7,6,5,4,4,5,6,7,8,7,6,5,4,5,6,7,8,9,8,7,6,5,5,6,7,8,9,10,9,8,7,6,5,6,7,8,9,10,11,10,9,8,7,6,6,7,8,9,10,11,12,11,10,9,8,7,6,7,8,9,10,11,12,13,12,11,10,9,8,7,7,8 lpb $0 sub $0,1 add $1,1 mov $2,$0 trn $0,$1 lpe add $3,$2 sub $1,$3 trn $1,$3 add $1,$3 mov $0,$1
FX_PLAYER_SHOOT equ SONIDO5 ;No destaca FX_ZOMBIE_BYE equ SONIDO6 FX_ZOMBIE_EXPLODE equ SONIDO8 FX_TAKE equ SONIDO7 FX_PLAYER_BIG_SHOOT equ SONIDO10 INIT_MUSIC DI CALL PLAYER_OFF LD HL, MWORK.BUFF_CANAL_A LD [CANAL_A],HL LD HL, MWORK.BUFF_CANAL_B LD [CANAL_B],HL LD HL,MWORK.BUFF_CANAL_C LD [CANAL_C],HL LD HL,MWORK.BUFF_CANAL_P LD [CANAL_P],HL XOR A LD [INTERR],A CALL INICIO LD HL,INICIO LD [HOOK+1],HL LD A,$C3 LD [HOOK],A EI RET K_SONG_1 EQU 0 K_SONG_2 equ 1 K_SONG_3 equ 2 K_SONG_RUN equ 3 K_SONG_GAME_OVER equ 4 K_SONG_INTRO EQU 5 TABLA_SONG DW SONG_1_LEVEL DW MDATA.SONG_2_LEVEL DW MDATA.SONG_3_LEVEL DW SONG_RUN DW MDATA.SONG_GAME_OVER DW MDATA.SONG_INTRO SONG_1_LEVEL incbin "rescue1N1v2.mus" ;incbin "game_overN1.mus" ;SONG_2_LEVEL ;incbin "level1_rescue.mus" SONG_RUN incbin "virus_huida.mus" ;include "virus_LEVEL1_fx.mus.asm" include "sonidosfxN1.mus.asm" ;incbin "level1_getout.mus" ;include "level1_getout.mus.asm" include "WYZPROPLAY47cMSX.ASM"
INCLUDE "graphics/grafix.inc" SECTION code_clib PUBLIC setxy PUBLIC _setxy EXTERN l_cmp EXTERN __gfx_coords ; ; $Id: w_setxy.asm,v 1.5 2016-07-02 09:01:35 dom Exp $ ; ; ****************************************************************** ; ; Move current pixel coordinate to (x0,y0). Only legal coordinates ; are accepted. ; ; Wide resolution (WORD based parameters) version by Stefano Bodrato ; ; Design & programming by Gunther Strube, Copyright (C) InterLogic 1995 ; ; X-range is always legal (0-255). Y-range must be 0 - 63. ; ; in: hl,de = (x,y) coordinate ; ; registers changed after return: ; ..bcdehl/ixiy same ; af....../.... different ; .setxy ._setxy pop bc pop de pop hl push hl push de push bc push hl ld hl,maxy call l_cmp pop hl ret nc ; Return if Y overflows push de ld de,maxx call l_cmp pop de ret c ; Return if X overflows ld (__gfx_coords),hl ; store X ld (__gfx_coords+2),de ; store Y: COORDS must be 2 bytes wider ret
.size 8000 .text@48 jp lstatint .text@100 jp lbegin .data@143 80 .text@150 lbegin: ld c, 41 ld b, 02 ld d, 03 lbegin_waitm2: ldff a, (c) and a, d cmp a, b jrnz lbegin_waitm2 ld a, 08 ldff(c), a xor a, a ldff(0f), a ld a, 02 ldff(ff), a ei ld c, 0f .text@1000 lstatint: ld a, 48 ldff(41), a ldff a, (44) inc a ldff(45), a ld a, 02 ldff(43), a .text@1058 xor a, a ldff(c), a nop nop nop nop nop nop ld a, ff ldff(45), a nop nop nop nop nop nop nop nop nop nop nop nop 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
; A210000: Number of unimodular 2 X 2 matrices having all terms in {0,1,...,n}. ; 0,6,14,30,46,78,94,142,174,222,254,334,366,462,510,574,638,766,814,958,1022,1118,1198,1374,1438,1598,1694,1838,1934,2158,2222,2462,2590,2750,2878,3070,3166,3454,3598,3790,3918,4238,4334,4670,4830 mov $2,$0 add $2,1 mov $4,$0 lpb $2 mov $0,$4 sub $2,1 sub $0,$2 trn $0,1 mov $3,1 lpb $0 mov $3,$0 cal $3,10 ; Euler totient function phi(n): count numbers <= n and prime to n. mov $0,1 lpe mul $3,4 add $3,$0 sub $3,1 mul $3,4 add $1,$3 lpe sub $1,4 div $1,4 mul $1,2 sub $1,4 div $1,2 mul $1,2
; nrv2x decoder in pure 68k asm for Rygar AGA ; On entry: ; a0 buffer start ; d0 offset inside buffer for packed data ; On exit: ; buffer filled with unpacked data ; all registers preserved nrv2x_decoder: movem.l d0-d5/a0-a4,-(sp) move.l d0,d3 lea (a0),a1 adda.l d0,a0 ; common setup moveq #-$80,d0 moveq #-1,d2 moveq #2,d4 moveq #-2,d5 ; select between s/r algorithms tst.l d3 beq.w nrv2r_unpack ; nrv2s decompression in pure 68k asm ; by ross ; ; On entry: ; a0 src packed data pointer ; a1 dest pointer ; (decompress from a0 to a1) ; ; On exit: ; a0 = dest start ; a1 = dest end ; ; Register usage: ; a2 m_pos ; a3 constant: -$d00 ; a4 2nd src pointer (in stack) ; ; d0 bit buffer ; d1 m_off ; d2 m_len or -1 ; ; d3 last_m_off ; d4 constant: 2 ; d5 reserved space on stack (max 256) ; ; ; Notes: ; we have max_offset = 2^23, so we can use some word arithmetics on d1 ; we have max_match = 65535, so we can use word arithmetics on d2 ; nrv2s_unpack ; movem.l d0-d5/a1-a4,-(sp) move.b (a0)+,d1 ; ~stack usage ; moveq #-2,d5 and.b d1,d5 lea (sp),a4 adda.l d5,sp ; reserve space ._stk move.b (a0)+,-(a4) addq.b #1,d1 bne.b ._stk ; ------------- setup constants ----------- ; moveq #-$80,d0 ; d0.b = $80 (byte refill flag) ; moveq #-1,d2 moveq #-1,d3 ; last_off = -1 ; moveq #2,d4 movea.w #-$d00,a3 ; ------------- DECOMPRESSION ------------- .decompr_literal move.b (a0)+,(a1)+ .decompr_loop add.b d0,d0 bcc.b .decompr_match bne.b .decompr_literal move.b (a0)+,d0 addx.b d0,d0 bcs.b .decompr_literal .decompr_match moveq #-2,d1 .decompr_gamma_1 add.b d0,d0 bne.b ._g_1 move.b (a0)+,d0 addx.b d0,d0 ._g_1 addx.w d1,d1 ; max 2^23! add.b d0,d0 bcc.b .decompr_gamma_1 bne.b .decompr_select move.b (a0)+,d0 addx.b d0,d0 bcc.b .decompr_gamma_1 .decompr_select addq.w #3,d1 beq.b .decompr_get_mlen ; last m_off bpl.b .decompr_exit_token lsl.l #8,d1 move.b (a0)+,d1 move.l d1,d3 ; last_m_off = m_off .decompr_get_mlen ; implicit d2 = -1 add.b d0,d0 bne.b ._e_1 move.b (a0)+,d0 addx.b d0,d0 ._e_1 addx.w d2,d2 add.b d0,d0 bne.b ._e_2 move.b (a0)+,d0 addx.b d0,d0 ._e_2 addx.w d2,d2 lea (a1,d3.l),a2 addq.w #2,d2 bgt.b .decompr_gamma_2 .decompr_tiny_mlen move.l d3,d1 sub.l a3,d1 addx.w d4,d2 .L_copy2 move.b (a2)+,(a1)+ .L_copy1 move.b (a2)+,(a1)+ dbra d2,.L_copy1 .L_rep bra.b .decompr_loop .decompr_gamma_2 ; implicit d2 = 1 add.b d0,d0 bne.b ._g_2 move.b (a0)+,d0 addx.b d0,d0 ._g_2 addx.w d2,d2 add.b d0,d0 bcc.b .decompr_gamma_2 bne.b .decompr_large_mlen move.b (a0)+,d0 addx.b d0,d0 bcc.b .decompr_gamma_2 .decompr_large_mlen move.b (a2)+,(a1)+ move.b (a2)+,(a1)+ cmp.l a3,d3 bcs.b .L_copy2 move.b (a2)+,(a1)+ dbra d2,.L_copy1 .decompr_exit_token lea (a4),a0 bclr d2,d2 ; ;) bne.b .L_rep bra.w _common_exit ; suba.l d5,sp ; movem.l (sp)+,d0-d5/a0-a4 ; rts ; nrv2r decompression in 68000 assembly ; by ross ; ; On entry: ; a0 src pointer ; [a1 dest pointer] ; (decompress also to a1=a0) ; ; On exit: ; all preserved but ; a1 = dest start ; ; Register usage: ; a2 m_pos ; a3 constant: $cff ; a4 2nd src pointer (in stack) ; ; d0 bit buffer ; d1 m_off ; d2 m_len or -1 ; ; d3 last_m_off ; d4 constant: 2 ; d5 reserved space on stack ; ; ; Notes: ; we have max_offset = 2^23, so we can use some word arithmetics on d1 ; we have max_match = 65535, so we can use word arithmetics on d2 ; nrv2r_unpack ; movem.l d0-d5/a0/a2-a4,-(sp) ; lea (a0),a1 ; if (a1) lea (a0),a4 adda.l (a0),a0 ; end of packed data move.l -(a0),(a1) ; if (a1) move.l -(a0),(a4) adda.l -(a0),a1 ; end of buffer move.b -(a0),d1 ; ~stack usage ; moveq #-2,d5 and.b d1,d5 adda.l d5,sp ; reserve space lea (sp),a4 ._stk move.b -(a0),(a4)+ addq.b #1,d1 bne.b ._stk ; ------------- setup constants ----------- ; moveq #-$80,d0 ; d0.b = $80 (byte refill flag) ; moveq #-1,d2 ; moveq #0,d3 ; last_off = 0(1) ; moveq #2,d4 movea.w #$cff,a3 ; ------------- DECOMPRESSION ------------- .decompr_literal move.b -(a0),-(a1) .decompr_loop add.b d0,d0 bcc.b .decompr_match bne.b .decompr_literal move.b -(a0),d0 addx.b d0,d0 bcs.b .decompr_literal .decompr_match moveq #1,d1 .decompr_gamma_1 add.b d0,d0 bne.b ._g_1 move.b -(a0),d0 addx.b d0,d0 ._g_1 addx.w d1,d1 ; max 2^23! add.b d0,d0 bcc.b .decompr_gamma_1 bne.b .decompr_select move.b -(a0),d0 addx.b d0,d0 bcc.b .decompr_gamma_1 .decompr_select subq.w #3,d1 bcs.b .decompr_get_mlen ; last m_off bmi.b .decompr_exit_token lsl.l #8,d1 move.b -(a0),d1 move.l d1,d3 ; last_m_off = m_off .decompr_get_mlen ; implicit d2 = -1 add.b d0,d0 bne.b ._e_1 move.b -(a0),d0 addx.b d0,d0 ._e_1 addx.w d2,d2 add.b d0,d0 bne.b ._e_2 move.b -(a0),d0 addx.b d0,d0 ._e_2 addx.w d2,d2 lea 1(a1,d3.l),a2 addq.w #2,d2 bgt.b .decompr_gamma_2 .decompr_tiny_mlen move.l a3,d1 sub.l d3,d1 addx.w d4,d2 .L_copy2 move.b -(a2),-(a1) .L_copy1 move.b -(a2),-(a1) dbra d2,.L_copy1 .L_rep bra.b .decompr_loop .decompr_gamma_2 ; implicit d2 = 1 add.b d0,d0 bne.b ._g_2 move.b -(a0),d0 addx.b d0,d0 ._g_2 addx.w d2,d2 add.b d0,d0 bcc.b .decompr_gamma_2 bne.b .decompr_large_mlen move.b -(a0),d0 addx.b d0,d0 bcc.b .decompr_gamma_2 .decompr_large_mlen move.b -(a2),-(a1) move.b -(a2),-(a1) cmpa.l d3,a3 bcs.b .L_copy2 move.b -(a2),-(a1) dbra d2,.L_copy1 .decompr_exit_token lea (a4),a0 bclr d2,d2 ; ;) bne.b .L_rep _common_exit suba.l d5,sp movem.l (sp)+,d0-d5/a0-a4 rts
; A032793: Numbers that are congruent to {1, 2, 4} mod 5. ; 1,2,4,6,7,9,11,12,14,16,17,19,21,22,24,26,27,29,31,32,34,36,37,39,41,42,44,46,47,49,51,52,54,56,57,59,61,62,64,66,67,69,71,72,74,76,77,79,81,82,84,86,87,89,91,92,94,96,97,99,101,102,104,106,107,109 mul $0,5 mov $1,$0 div $1,3 add $1,1
; A145289: Duplicate of A016777. ; 1,4,7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58,61,64,67,70,73,76,79,82,85,88,91,94,97,100,103 mov $1,$0 mul $1,3 add $1,1
; A177881: Partial sums of round(3^n/10). ; 0,0,1,4,12,36,109,328,984,2952,8857,26572,79716,239148,717445,2152336,6457008,19371024,58113073,174339220,523017660,1569052980,4707158941,14121476824,42364430472,127093291416,381279874249,1143839622748,3431518868244,10294556604732,30883669814197,92651009442592,277953028327776,833859084983328,2501577254949985,7504731764849956 mov $1,3 lpb $0,1 sub $0,1 mul $1,3 lpe div $1,20
; A005728: Number of fractions in Farey series of order n. ; 1,2,3,5,7,11,13,19,23,29,33,43,47,59,65,73,81,97,103,121,129,141,151,173,181,201,213,231,243,271,279,309,325,345,361,385,397,433,451,475,491,531,543,585,605,629,651,697,713,755,775,807,831,883,901,941,965,1001,1029,1087,1103,1163,1193,1229,1261,1309,1329,1395,1427,1471,1495,1565,1589,1661,1697,1737,1773,1833,1857,1935,1967,2021,2061,2143,2167,2231,2273,2329,2369,2457,2481,2553,2597,2657,2703,2775,2807,2903,2945,3005,3045,3145,3177,3279,3327,3375,3427,3533,3569,3677,3717,3789,3837,3949,3985,4073,4129,4201,4259,4355,4387,4497,4557,4637,4697,4797,4833,4959,5023,5107,5155,5285,5325,5433,5499,5571,5635,5771,5815,5953,6001,6093,6163,6283,6331,6443,6515,6599,6671,6819,6859,7009,7081,7177,7237,7357,7405,7561,7639,7743,7807,7939,7993,8155,8235,8315,8397,8563,8611,8767,8831,8939,9023,9195,9251,9371,9451,9567,9655,9833,9881,10061,10133,10253,10341,10485,10545,10705,10797,10905,10977,11167,11231,11423,11519,11615,11699,11895,11955,12153,12233,12365,12465,12633,12697,12857,12959,13091,13187,13367,13415,13625,13729,13869,13975,14143,14215,14395,14503,14647,14727,14919,14991,15213,15309,15429,15541,15767,15839,16067,16155,16275,16387,16619,16691,16875,16991,17147,17243,17481,17545,17785,17895,18057,18177,18345,18425,18641,18761,18925 cal $0,210000 ; Number of unimodular 2 X 2 matrices having all terms in {0,1,...,n}. add $0,2 div $0,4 mov $1,$0 div $1,2 add $1,1
addi $1, $0, 1 addi $2, $0, 2 add $3, $2, $1 sub $1, $3, $2 addi $10, $11, -23 add $11, $3, $10 sub $1, $10, $11 mult $8, $3, $2 mult $9, $1, $1 and $7, $1, $2 and $7, $2, $2 or $7, $1, $2 or $7, $2, $2 nor $7, $1, $2 nor $7, $2, $2 slt $0, $2, $7 slt $2, $0, $7 beq $0, $0, 1 j 8 addi $5, $0, 5 beq $0, $2, 10 bne $0, $0, 10 bne $0, $2, 2 j 8 j 8 j 30 j 8 j 8 j 8 # label nop add $5, $5, $5 jal 34 j 100 # label nop jr $ra #beq $12, $7, 4 ##sb $21, 5($5) #mult $9, $11, $21 ##lb $11, -5($23) #bne $20, $19, 7 #jr 5 #jal 6
// Autogenerated from CppHeaderCreator // Created by Sc2ad // ========================================================================= #pragma once // Begin includes #include "beatsaber-hook/shared/utils/typedefs.h" #include "beatsaber-hook/shared/utils/byref.hpp" // Including type: OVR.OpenVR.IVROverlay #include "OVR/OpenVR/IVROverlay.hpp" // Including type: System.MulticastDelegate #include "System/MulticastDelegate.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-properties.hpp" #include "beatsaber-hook/shared/utils/il2cpp-utils-fields.hpp" #include "beatsaber-hook/shared/utils/utils.h" // Completed includes // Begin forward declares // Forward declaring namespace: System namespace System { // Forward declaring type: IAsyncResult class IAsyncResult; // Forward declaring type: AsyncCallback class AsyncCallback; } // Completed forward declares #include "beatsaber-hook/shared/utils/il2cpp-type-check.hpp" NEED_NO_BOX(::OVR::OpenVR::IVROverlay::_CloseMessageOverlay); DEFINE_IL2CPP_ARG_TYPE(::OVR::OpenVR::IVROverlay::_CloseMessageOverlay*, "OVR.OpenVR", "IVROverlay/_CloseMessageOverlay"); // Type namespace: OVR.OpenVR namespace OVR::OpenVR { // Size: 0x70 #pragma pack(push, 1) // Autogenerated type: OVR.OpenVR.IVROverlay/OVR.OpenVR._CloseMessageOverlay // [TokenAttribute] Offset: FFFFFFFF // [UnmanagedFunctionPointerAttribute] Offset: 696020 class IVROverlay::_CloseMessageOverlay : public ::System::MulticastDelegate { public: // public System.Void .ctor(System.Object object, System.IntPtr method) // Offset: 0x821F4C template<::il2cpp_utils::CreationType creationType = ::il2cpp_utils::CreationType::Temporary> static IVROverlay::_CloseMessageOverlay* New_ctor(::Il2CppObject* object, ::System::IntPtr method) { static auto ___internal__logger = ::Logger::get().WithContext("::OVR::OpenVR::IVROverlay::_CloseMessageOverlay::.ctor"); return THROW_UNLESS((::il2cpp_utils::New<IVROverlay::_CloseMessageOverlay*, creationType>(object, method))); } // public System.Void Invoke() // Offset: 0x821F5C void Invoke(); // public System.IAsyncResult BeginInvoke(System.AsyncCallback callback, System.Object object) // Offset: 0x822168 ::System::IAsyncResult* BeginInvoke(::System::AsyncCallback* callback, ::Il2CppObject* object); // public System.Void EndInvoke(System.IAsyncResult result) // Offset: 0x822194 void EndInvoke(::System::IAsyncResult* result); }; // OVR.OpenVR.IVROverlay/OVR.OpenVR._CloseMessageOverlay #pragma pack(pop) } #include "beatsaber-hook/shared/utils/il2cpp-utils-methods.hpp" // Writing MetadataGetter for method: OVR::OpenVR::IVROverlay::_CloseMessageOverlay::New_ctor // Il2CppName: .ctor // Cannot get method pointer of value based method overload from template for constructor! // Try using FindMethod instead! // Writing MetadataGetter for method: OVR::OpenVR::IVROverlay::_CloseMessageOverlay::Invoke // Il2CppName: Invoke template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::IVROverlay::_CloseMessageOverlay::*)()>(&OVR::OpenVR::IVROverlay::_CloseMessageOverlay::Invoke)> { static const MethodInfo* get() { return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::IVROverlay::_CloseMessageOverlay*), "Invoke", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{}); } }; // Writing MetadataGetter for method: OVR::OpenVR::IVROverlay::_CloseMessageOverlay::BeginInvoke // Il2CppName: BeginInvoke template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<::System::IAsyncResult* (OVR::OpenVR::IVROverlay::_CloseMessageOverlay::*)(::System::AsyncCallback*, ::Il2CppObject*)>(&OVR::OpenVR::IVROverlay::_CloseMessageOverlay::BeginInvoke)> { static const MethodInfo* get() { static auto* callback = &::il2cpp_utils::GetClassFromName("System", "AsyncCallback")->byval_arg; static auto* object = &::il2cpp_utils::GetClassFromName("System", "Object")->byval_arg; return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::IVROverlay::_CloseMessageOverlay*), "BeginInvoke", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{callback, object}); } }; // Writing MetadataGetter for method: OVR::OpenVR::IVROverlay::_CloseMessageOverlay::EndInvoke // Il2CppName: EndInvoke template<> struct ::il2cpp_utils::il2cpp_type_check::MetadataGetter<static_cast<void (OVR::OpenVR::IVROverlay::_CloseMessageOverlay::*)(::System::IAsyncResult*)>(&OVR::OpenVR::IVROverlay::_CloseMessageOverlay::EndInvoke)> { static const MethodInfo* get() { static auto* result = &::il2cpp_utils::GetClassFromName("System", "IAsyncResult")->byval_arg; return ::il2cpp_utils::FindMethod(classof(OVR::OpenVR::IVROverlay::_CloseMessageOverlay*), "EndInvoke", std::vector<Il2CppClass*>(), ::std::vector<const Il2CppType*>{result}); } };
; A168669: Numbers n such that sqrt(36*n+49) is prime. ; Submitted by Simon Strandgaard ; 0,2,22,50,60,102,172,190,260,282,520,632,830,1012,1380,1430,1612,1920,2130,2192,2720,2790,3042,3382,3460,3740,4202,4922,5352,5450,5800,5902,6372,8310,8992,9570,10032,10642,11412,12062,12580,12730,13262,13962,14680,18722,19552,20210,20400,22850,23052,23972,24910,26840,27610,28842,29640,30682,31742,32820,33062,34162,35030,37570,38742,40870,41140,42092,43332,46152,47160,47450,48472,51452,56722,57040,58160,58482,61090,61420,64430,67512,71912,72270,73530,76820,77190,80182,82272,85360,88902,91102 seq $0,129807 ; Primes congruent to +-7 mod 18. pow $0,2 sub $0,49 div $0,36
//StaticTest @111 D=A @SP A=M M=D @SP M=M+1 @333 D=A @SP A=M M=D @SP M=M+1 @888 D=A @SP A=M M=D @SP M=M+1 @StaticTest.8 D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @StaticTest.3 D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @StaticTest.1 D=A @R15 M=D @SP M=M-1 @SP A=M D=M @R15 A=M M=D @StaticTest.3 D=M @SP A=M M=D @SP M=M+1 @StaticTest.1 D=M @SP A=M M=D @SP M=M+1 @SP M=M-1 @SP A=M D=M @SP M=M-1 @SP A=M D=M-D @SP A=M M=D @SP M=M+1 @StaticTest.8 D=M @SP A=M M=D @SP M=M+1 @SP M=M-1 @SP A=M D=M @SP M=M-1 @SP A=M D=M+D @SP A=M M=D @SP M=M+1
/* * Load_dtm.cpp * ------------ * Purpose: Digital Tracker / Digital Home Studio module Loader (DTM) * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. */ #include "stdafx.h" #include "Loaders.h" OPENMPT_NAMESPACE_BEGIN enum PatternFormats : uint32 { DTM_PT_PATTERN_FORMAT = 0, DTM_204_PATTERN_FORMAT = MagicBE("2.04"), DTM_206_PATTERN_FORMAT = MagicBE("2.06"), }; struct DTMFileHeader { char magic[4]; uint32be headerSize; uint16be type; // 0 = module uint8be stereoMode; // FF = panoramic stereo, 00 = old stereo uint8be bitDepth; // Typically 8, sometimes 16, but is not actually used anywhere? uint16be reserved; // Usually 0, but not in unknown title 1.dtm and unknown title 2.dtm uint16be speed; uint16be tempo; uint32be forcedSampleRate; // Seems to be ignored in newer files }; MPT_BINARY_STRUCT(DTMFileHeader, 22) // IFF-style Chunk struct DTMChunk { // 32-Bit chunk identifiers enum ChunkIdentifiers { idS_Q_ = MagicBE("S.Q."), idPATT = MagicBE("PATT"), idINST = MagicBE("INST"), idIENV = MagicBE("IENV"), idDAPT = MagicBE("DAPT"), idDAIT = MagicBE("DAIT"), idTEXT = MagicBE("TEXT"), idPATN = MagicBE("PATN"), idTRKN = MagicBE("TRKN"), idVERS = MagicBE("VERS"), idSV19 = MagicBE("SV19"), }; uint32be id; uint32be length; size_t GetLength() const { return length; } ChunkIdentifiers GetID() const { return static_cast<ChunkIdentifiers>(id.get()); } }; MPT_BINARY_STRUCT(DTMChunk, 8) struct DTMSample { uint32be reserved; // 0x204 for first sample, 0x208 for second, etc... uint32be length; // in bytes uint8be finetune; // -8....7 uint8be volume; // 0...64 uint32be loopStart; // in bytes uint32be loopLength; // ditto char name[22]; uint8be stereo; uint8be bitDepth; uint16be transpose; uint16be unknown; uint32be sampleRate; void ConvertToMPT(ModSample &mptSmp, uint32 forcedSampleRate, uint32 formatVersion) const { mptSmp.Initialize(MOD_TYPE_IT); mptSmp.nLength = length; mptSmp.nLoopStart = loopStart; mptSmp.nLoopEnd = mptSmp.nLoopStart + loopLength; // In revolution to come.dtm, the file header says samples rate is 24512 Hz, but samples say it's 50000 Hz // Digital Home Studio ignores the header setting in 2.04-/2.06-style modules mptSmp.nC5Speed = (formatVersion == DTM_PT_PATTERN_FORMAT && forcedSampleRate > 0) ? forcedSampleRate : sampleRate; int32 transposeAmount = MOD2XMFineTune(finetune); if(formatVersion == DTM_206_PATTERN_FORMAT && transpose > 0 && transpose != 48) { // Digital Home Studio applies this unconditionally, but some old songs sound wrong then (delirium.dtm). // Digital Tracker 2.03 ignores the setting. // Maybe this should not be applied for "real" Digital Tracker modules? transposeAmount += (48 - transpose) * 128; } mptSmp.Transpose(transposeAmount * (1.0 / (12.0 * 128.0))); mptSmp.nVolume = std::min(volume.get(), uint8(64)) * 4u; if(stereo & 1) { mptSmp.uFlags.set(CHN_STEREO); mptSmp.nLength /= 2u; mptSmp.nLoopStart /= 2u; mptSmp.nLoopEnd /= 2u; } if(bitDepth > 8) { mptSmp.uFlags.set(CHN_16BIT); mptSmp.nLength /= 2u; mptSmp.nLoopStart /= 2u; mptSmp.nLoopEnd /= 2u; } if(mptSmp.nLoopEnd > mptSmp.nLoopStart + 1) { mptSmp.uFlags.set(CHN_LOOP); } else { mptSmp.nLoopStart = mptSmp.nLoopEnd = 0; } } }; MPT_BINARY_STRUCT(DTMSample, 50) struct DTMInstrument { uint16be insNum; uint8be unknown1; uint8be envelope; // 0xFF = none uint8be sustain; // 0xFF = no sustain point uint16be fadeout; uint8be vibRate; uint8be vibDepth; uint8be modulationRate; uint8be modulationDepth; uint8be breathRate; uint8be breathDepth; uint8be volumeRate; uint8be volumeDepth; }; MPT_BINARY_STRUCT(DTMInstrument, 15) struct DTMEnvelope { struct DTMEnvPoint { uint8be value; uint8be tick; }; uint16be numPoints; DTMEnvPoint points[16]; }; MPT_BINARY_STRUCT(DTMEnvelope::DTMEnvPoint, 2) MPT_BINARY_STRUCT(DTMEnvelope, 34) struct DTMText { uint16be textType; // 0 = pattern, 1 = free, 2 = song uint32be textLength; uint16be tabWidth; uint16be reserved; uint16be oddLength; }; MPT_BINARY_STRUCT(DTMText, 12) static bool ValidateHeader(const DTMFileHeader &fileHeader) { if(std::memcmp(fileHeader.magic, "D.T.", 4) || fileHeader.headerSize < sizeof(fileHeader) - 8u || fileHeader.headerSize > 256 // Excessively long song title? || fileHeader.type != 0) { return false; } return true; } CSoundFile::ProbeResult CSoundFile::ProbeFileHeaderDTM(MemoryFileReader file, const uint64 *pfilesize) { DTMFileHeader fileHeader; if(!file.ReadStruct(fileHeader)) { return ProbeWantMoreData; } if(!ValidateHeader(fileHeader)) { return ProbeFailure; } MPT_UNREFERENCED_PARAMETER(pfilesize); return ProbeSuccess; } bool CSoundFile::ReadDTM(FileReader &file, ModLoadingFlags loadFlags) { file.Rewind(); DTMFileHeader fileHeader; if(!file.ReadStruct(fileHeader)) { return false; } if(!ValidateHeader(fileHeader)) { return false; } if(loadFlags == onlyVerifyHeader) { return true; } InitializeGlobals(MOD_TYPE_DTM); InitializeChannels(); m_SongFlags.set(SONG_ITCOMPATGXX | SONG_ITOLDEFFECTS); m_playBehaviour.reset(kITVibratoTremoloPanbrello); // Various files have a default speed or tempo of 0 if(fileHeader.tempo) m_nDefaultTempo.Set(fileHeader.tempo); if(fileHeader.speed) m_nDefaultSpeed = fileHeader.speed; if(fileHeader.stereoMode == 0) SetupMODPanning(true); file.ReadString<mpt::String::maybeNullTerminated>(m_songName, fileHeader.headerSize - (sizeof(fileHeader) - 8u)); auto chunks = ChunkReader(file).ReadChunks<DTMChunk>(1); // Read order list if(FileReader chunk = chunks.GetChunk(DTMChunk::idS_Q_)) { uint16 ordLen = chunk.ReadUint16BE(); uint16 restartPos = chunk.ReadUint16BE(); chunk.Skip(4); // Reserved ReadOrderFromFile<uint8>(Order(), chunk, ordLen); Order().SetRestartPos(restartPos); } else { return false; } // Read pattern properties uint32 patternFormat; if(FileReader chunk = chunks.GetChunk(DTMChunk::idPATT)) { m_nChannels = chunk.ReadUint16BE(); if(m_nChannels < 1 || m_nChannels > 32) { return false; } Patterns.ResizeArray(chunk.ReadUint16BE()); // Number of stored patterns, may be lower than highest pattern number patternFormat = chunk.ReadUint32BE(); if(patternFormat != DTM_PT_PATTERN_FORMAT && patternFormat != DTM_204_PATTERN_FORMAT && patternFormat != DTM_206_PATTERN_FORMAT) { return false; } } else { return false; } // Read global info if(FileReader chunk = chunks.GetChunk(DTMChunk::idSV19)) { chunk.Skip(2); // Ticks per quarter note, typically 24 uint32 fractionalTempo = chunk.ReadUint32BE(); m_nDefaultTempo = TEMPO(m_nDefaultTempo.GetInt() + fractionalTempo / 4294967296.0); uint16be panning[32]; chunk.ReadArray(panning); for(CHANNELINDEX chn = 0; chn < 32 && chn < GetNumChannels(); chn++) { // Panning is in range 0...180, 90 = center ChnSettings[chn].nPan = static_cast<uint16>(128 + Util::muldivr(std::min(static_cast<int>(panning[chn]), int(180)) - 90, 128, 90)); } chunk.Skip(16); // Chunk ends here for old DTM modules if(chunk.CanRead(2)) { m_nDefaultGlobalVolume = std::min(chunk.ReadUint16BE(), static_cast<uint16>(MAX_GLOBAL_VOLUME)); } chunk.Skip(128); uint16be volume[32]; if(chunk.ReadArray(volume)) { for(CHANNELINDEX chn = 0; chn < 32 && chn < GetNumChannels(); chn++) { // Volume is in range 0...128, 64 = normal ChnSettings[chn].nVolume = static_cast<uint8>(std::min(static_cast<int>(volume[chn]), int(128)) / 2); } m_nSamplePreAmp *= 2; // Compensate for channel volume range } } // Read song message if(FileReader chunk = chunks.GetChunk(DTMChunk::idTEXT)) { DTMText text; chunk.ReadStruct(text); if(text.oddLength == 0xFFFF) { chunk.Skip(1); } m_songMessage.Read(chunk, chunk.BytesLeft(), SongMessage::leCRLF); } // Read sample headers if(FileReader chunk = chunks.GetChunk(DTMChunk::idINST)) { uint16 numSamples = chunk.ReadUint16BE(); bool newSamples = (numSamples >= 0x8000); numSamples &= 0x7FFF; if(numSamples >= MAX_SAMPLES || !chunk.CanRead(numSamples * (sizeof(DTMSample) + (newSamples ? 2u : 0u)))) { return false; } m_nSamples = numSamples; for(SAMPLEINDEX smp = 1; smp <= numSamples; smp++) { SAMPLEINDEX realSample = newSamples ? (chunk.ReadUint16BE() + 1u) : smp; DTMSample dtmSample; chunk.ReadStruct(dtmSample); if(realSample < 1 || realSample >= MAX_SAMPLES) { continue; } m_nSamples = std::max(m_nSamples, realSample); ModSample &mptSmp = Samples[realSample]; dtmSample.ConvertToMPT(mptSmp, fileHeader.forcedSampleRate, patternFormat); m_szNames[realSample] = mpt::String::ReadBuf(mpt::String::maybeNullTerminated, dtmSample.name); } if(chunk.ReadUint16BE() == 0x0004) { // Digital Home Studio instruments m_nInstruments = std::min(static_cast<INSTRUMENTINDEX>(m_nSamples), static_cast<INSTRUMENTINDEX>(MAX_INSTRUMENTS - 1)); FileReader envChunk = chunks.GetChunk(DTMChunk::idIENV); while(chunk.CanRead(sizeof(DTMInstrument))) { DTMInstrument instr; chunk.ReadStruct(instr); if(instr.insNum < GetNumInstruments()) { ModSample &sample = Samples[instr.insNum + 1]; sample.nVibDepth = instr.vibDepth; sample.nVibRate = instr.vibRate; sample.nVibSweep = 255; ModInstrument *mptIns = AllocateInstrument(instr.insNum + 1, instr.insNum + 1); if(mptIns != nullptr) { InstrumentEnvelope &mptEnv = mptIns->VolEnv; mptIns->nFadeOut = std::min(static_cast<uint16>(instr.fadeout), uint16(0xFFF)); if(instr.envelope != 0xFF && envChunk.Seek(2 + sizeof(DTMEnvelope) * instr.envelope)) { DTMEnvelope env; envChunk.ReadStruct(env); mptEnv.dwFlags.set(ENV_ENABLED); mptEnv.resize(std::min({ static_cast<std::size_t>(env.numPoints), std::size(env.points), static_cast<std::size_t>(MAX_ENVPOINTS) })); for(size_t i = 0; i < mptEnv.size(); i++) { mptEnv[i].value = std::min(uint8(64), static_cast<uint8>(env.points[i].value)); mptEnv[i].tick = env.points[i].tick; } if(instr.sustain != 0xFF) { mptEnv.dwFlags.set(ENV_SUSTAIN); mptEnv.nSustainStart = mptEnv.nSustainEnd = instr.sustain; } if(!mptEnv.empty()) { mptEnv.dwFlags.set(ENV_LOOP); mptEnv.nLoopStart = mptEnv.nLoopEnd = static_cast<uint8>(mptEnv.size() - 1); } } } } } } } // Read pattern data for(auto &chunk : chunks.GetAllChunks(DTMChunk::idDAPT)) { chunk.Skip(4); // FF FF FF FF PATTERNINDEX patNum = chunk.ReadUint16BE(); ROWINDEX numRows = chunk.ReadUint16BE(); if(patternFormat == DTM_206_PATTERN_FORMAT) { // The stored data is actually not row-based, but tick-based. numRows /= m_nDefaultSpeed; } if(!(loadFlags & loadPatternData) || patNum > 255 || !Patterns.Insert(patNum, numRows)) { continue; } if(patternFormat == DTM_206_PATTERN_FORMAT) { chunk.Skip(4); for(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++) { uint16 length = chunk.ReadUint16BE(); if(length % 2u) length++; FileReader rowChunk = chunk.ReadChunk(length); int tick = 0; std::div_t position = { 0, 0 }; while(rowChunk.CanRead(6) && static_cast<ROWINDEX>(position.quot) < numRows) { ModCommand *m = Patterns[patNum].GetpModCommand(position.quot, chn); const auto [note, volume, instr, command, param, delay] = rowChunk.ReadArray<uint8, 6>(); if(note > 0 && note <= 96) { m->note = note + NOTE_MIN + 12; if(position.rem) { m->command = CMD_MODCMDEX; m->param = 0xD0 | static_cast<ModCommand::PARAM>(std::min(position.rem, 15)); } } else if(note & 0x80) { // Lower 7 bits contain note, probably intended for MIDI-like note-on/note-off events if(position.rem) { m->command = CMD_MODCMDEX; m->param = 0xC0 | static_cast<ModCommand::PARAM>(std::min(position.rem, 15)); } else { m->note = NOTE_NOTECUT; } } if(volume) { m->volcmd = VOLCMD_VOLUME; m->vol = std::min(volume, uint8(64)); // Volume can go up to 255, but we do not support over-amplification at the moment. } if(instr) { m->instr = instr; } if(command || param) { m->command = command; m->param = param; ConvertModCommand(*m); #ifdef MODPLUG_TRACKER m->Convert(MOD_TYPE_MOD, MOD_TYPE_IT, *this); #endif // G is 8-bit volume // P is tremor (need to disable oldfx) } if(delay & 0x80) tick += (delay & 0x7F) * 0x100 + rowChunk.ReadUint8(); else tick += delay; position = std::div(tick, m_nDefaultSpeed); } } } else { ModCommand *m = Patterns[patNum].GetpModCommand(0, 0); for(ROWINDEX row = 0; row < numRows; row++) { for(CHANNELINDEX chn = 0; chn < GetNumChannels(); chn++, m++) { const auto data = chunk.ReadArray<uint8, 4>(); if(patternFormat == DTM_204_PATTERN_FORMAT) { const auto [note, instrVol, instrCmd, param] = data; if(note > 0 && note < 0x80) { m->note = (note >> 4) * 12 + (note & 0x0F) + NOTE_MIN + 11; } uint8 vol = instrVol >> 2; if(vol) { m->volcmd = VOLCMD_VOLUME; m->vol = vol - 1u; } m->instr = ((instrVol & 0x03) << 4) | (instrCmd >> 4); m->command = instrCmd & 0x0F; m->param = param; } else { ReadMODPatternEntry(data, *m); m->instr |= data[0] & 0x30; // Allow more than 31 instruments } ConvertModCommand(*m); // Fix commands without memory and slide nibble precedence switch(m->command) { case CMD_PORTAMENTOUP: case CMD_PORTAMENTODOWN: if(!m->param) { m->command = CMD_NONE; } break; case CMD_VOLUMESLIDE: case CMD_TONEPORTAVOL: case CMD_VIBRATOVOL: if(m->param & 0xF0) { m->param &= 0xF0; } else if(!m->param) { m->command = CMD_NONE; } break; default: break; } #ifdef MODPLUG_TRACKER m->Convert(MOD_TYPE_MOD, MOD_TYPE_IT, *this); #endif } } } } // Read pattern names if(FileReader chunk = chunks.GetChunk(DTMChunk::idPATN)) { PATTERNINDEX pat = 0; std::string name; while(chunk.CanRead(1) && pat < Patterns.Size()) { chunk.ReadNullString(name, 32); Patterns[pat].SetName(name); pat++; } } // Read channel names if(FileReader chunk = chunks.GetChunk(DTMChunk::idTRKN)) { CHANNELINDEX chn = 0; std::string name; while(chunk.CanRead(1) && chn < GetNumChannels()) { chunk.ReadNullString(name, 32); ChnSettings[chn].szName = name; chn++; } } // Read sample data for(auto &chunk : chunks.GetAllChunks(DTMChunk::idDAIT)) { SAMPLEINDEX smp = chunk.ReadUint16BE(); if(smp >= GetNumSamples() || !(loadFlags & loadSampleData)) { continue; } ModSample &mptSmp = Samples[smp + 1]; SampleIO( mptSmp.uFlags[CHN_16BIT] ? SampleIO::_16bit : SampleIO::_8bit, mptSmp.uFlags[CHN_STEREO] ? SampleIO::stereoInterleaved: SampleIO::mono, SampleIO::bigEndian, SampleIO::signedPCM).ReadSample(mptSmp, chunk); } // Is this accurate? mpt::ustring tracker; if(patternFormat == DTM_206_PATTERN_FORMAT) { tracker = U_("Digital Home Studio"); } else if(FileReader chunk = chunks.GetChunk(DTMChunk::idVERS)) { uint32 version = chunk.ReadUint32BE(); tracker = MPT_UFORMAT("Digital Tracker {}.{}")(version >> 4, version & 0x0F); } else { tracker = U_("Digital Tracker"); } m_modFormat.formatName = U_("Digital Tracker"); m_modFormat.type = U_("dtm"); m_modFormat.madeWithTracker = std::move(tracker); m_modFormat.charset = mpt::Charset::ISO8859_1; return true; } OPENMPT_NAMESPACE_END
; /***************************************************************************** ; * ugBASIC - an isomorphic BASIC language compiler for retrocomputers * ; ***************************************************************************** ; * Copyright 2021-2022 Marco Spedaletti (asimov@mclink.it) ; * ; * 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. ; *---------------------------------------------------------------------------- ; * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0 ; * (la "Licenza"); è proibito usare questo file se non in conformità alla ; * Licenza. Una copia della Licenza è disponibile all'indirizzo: ; * ; * http://www.apache.org/licenses/LICENSE-2.0 ; * ; * Se non richiesto dalla legislazione vigente o concordato per iscritto, ; * il software distribuito nei termini della Licenza è distribuito ; * "COSì COM'è", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o ; * implicite. Consultare la Licenza per il testo specifico che regola le ; * autorizzazioni e le limitazioni previste dalla medesima. ; ****************************************************************************/ ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ;* * ;* IMAGES ROUTINE FOR VIC-I * ;* * ;* by Marco Spedaletti * ;* * ;* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ; ---------------------------------------------------------------------------- ; - Put image on bitmap ; ---------------------------------------------------------------------------- PUTIMAGE: ; LDA CURRENTMODE ; ; BITMAP_MODE_STANDARD ; CMP #2 ; BNE PUTIMAGE2X ; JMP PUTIMAGE2 ; PUTIMAGE2X: ; ; BITMAP_MODE_MULTICOLOR ; CMP #3 ; BNE PUTIMAGE3X ; JMP PUTIMAGE3 ; PUTIMAGE3X: ; ; TILEMAP_MODE_STANDARD ; CMP #0 ; BNE PUTIMAGE0X ; JMP PUTIMAGE0 ; PUTIMAGE0X: ; ; TILEMAP_MODE_MULTICOLOR ; CMP #1 ; BNE PUTIMAGE1X ; JMP PUTIMAGE1 ; PUTIMAGE1X: ; ; TILEMAP_MODE_EXTENDED ; CMP #4 ; BNE PUTIMAGE4X ; JMP PUTIMAGE4 ; PUTIMAGE4X: ; RTS PUTIMAGE0: LDY #2 LDA (TMPPTR),Y STA MATHPTR2 PUTIMAGE02C: LDY #0 LDA (TMPPTR),Y STA IMAGEW LSR LSR LSR STA IMAGEW LDY #1 LDA (TMPPTR),Y LSR LSR LSR STA IMAGEH STA IMAGEH2 CLC LDA TMPPTR ADC #3 STA TMPPTR LDA TMPPTR+1 ADC #0 STA TMPPTR+1 ;------------------------- ;calc Y-cell, divide by 8 ;y/8 is y-cell table index ;------------------------- LDA IMAGEY LSR ;/ 2 LSR ;/ 4 LSR ;/ 8 TAY ;tbl_8,y index CLC ;------------------------ ;calc X-cell, divide by 8 ;divide 2-byte PLOTX / 8 ;------------------------ LDA IMAGEX ROR IMAGEX+1 ;rotate the high byte into carry flag ROR ;lo byte / 2 (rotate C into low byte) LSR ;lo byte / 4 LSR ;lo byte / 8 STA MATHPTR0 ;tbl_8,x index ;---------------------------------- ;add x & y to calc cell point is in ;---------------------------------- CLC LDA PLOTCVBASELO,Y ;table of $A000 row base addresses ADC MATHPTR0 ;+ (8 * Xcell) STA PLOTDEST ;= cell address LDA PLOTCVBASEHI,Y ;do the high byte ADC #0 STA PLOTDEST+1 CLC LDA PLOTC2VBASELO,Y ;table of $A000 row base addresses ADC MATHPTR0 ;+ (8 * Xcell) STA PLOTCDEST ;= cell address LDA PLOTC2VBASEHI,Y ;do the high byte ADC #0 STA PLOTCDEST+1 TYA ADC IMAGEH LDA IMAGEW TAY DEY PUTIMAGE0L1: LDA (TMPPTR),Y STA (PLOTDEST),Y DEY CPY #255 BNE PUTIMAGE0L1 CLC LDA TMPPTR ADC IMAGEW STA TMPPTR LDA TMPPTR+1 ADC #0 STA TMPPTR+1 CLC LDA PLOTDEST ADC #22 STA PLOTDEST LDA PLOTDEST+1 ADC #$0 STA PLOTDEST+1 DEC IMAGEH BEQ PUTIMAGE0C LDA IMAGEW TAY DEY JMP PUTIMAGE0L1 PUTIMAGE0C: LDA MATHPTR2 BEQ PUTIMAGE0C2 JMP PUTIMAGE0C16 PUTIMAGE0C2: LDY #0 LDA (TMPPTR),Y STA MATHPTR1 LDA IMAGEH2 STA IMAGEH LDA IMAGEW TAY DEY LDA MATHPTR1 PUTIMAGE02L2: STA (PLOTCDEST),Y DEY CPY #255 BNE PUTIMAGE02L2 DEC IMAGEH BEQ PUTIMAGE0E CLC LDA TMPPTR ADC IMAGEW STA TMPPTR LDA TMPPTR+1 ADC #0 STA TMPPTR+1 CLC LDA PLOTCDEST ADC #22 STA PLOTCDEST LDA PLOTCDEST+1 ADC #0 STA PLOTCDEST+1 LDA IMAGEW TAY DEY LDA MATHPTR1 JMP PUTIMAGE02L2 PUTIMAGE0C16: LDA IMAGEH2 STA IMAGEH LDA IMAGEW TAY DEY LDA MATHPTR1 PUTIMAGE016L2: LDA (TMPPTR),Y STA (PLOTCDEST),Y DEY CPY #255 BNE PUTIMAGE016L2 DEC IMAGEH BEQ PUTIMAGE0E CLC LDA TMPPTR ADC IMAGEW STA TMPPTR LDA TMPPTR+1 ADC #0 STA TMPPTR+1 CLC LDA PLOTCDEST ADC #22 STA PLOTCDEST LDA PLOTCDEST+1 ADC #0 STA PLOTCDEST+1 LDA IMAGEW TAY DEY JMP PUTIMAGE016L2 PUTIMAGE0E: RTS ; PUTIMAGE0: ; PUTIMAGE1: ; PUTIMAGE4: ; RTS ; PUTIMAGE2: ; LDY #0 ; LDA (TMPPTR),Y ; STA IMAGEW ; LDY #1 ; LDA (TMPPTR),Y ; LSR ; LSR ; LSR ; STA IMAGEH ; STA IMAGEH2 ; CLC ; LDA TMPPTR ; ADC #2 ; STA TMPPTR ; LDA TMPPTR+1 ; ADC #0 ; STA TMPPTR+1 ; ;------------------------- ; ;calc Y-cell, divide by 8 ; ;y/8 is y-cell table index ; ;------------------------- ; LDA IMAGEY ; LSR ;/ 2 ; LSR ;/ 4 ; LSR ;/ 8 ; TAY ;tbl_8,y index ; CLC ; ;------------------------ ; ;calc X-cell, divide by 8 ; ;divide 2-byte PLOTX / 8 ; ;------------------------ ; LDA IMAGEX ; ROR IMAGEX+1 ;rotate the high byte into carry flag ; ROR ;lo byte / 2 (rotate C into low byte) ; LSR ;lo byte / 4 ; LSR ;lo byte / 8 ; TAX ;tbl_8,x index ; ;---------------------------------- ; ;add x & y to calc cell point is in ; ;---------------------------------- ; CLC ; LDA PLOTVBASELO,Y ;table of $A000 row base addresses ; ADC PLOT8LO,X ;+ (8 * Xcell) ; STA PLOTDEST ;= cell address ; LDA PLOTVBASEHI,Y ;do the high byte ; ADC PLOT8HI,X ; STA PLOTDEST+1 ; TXA ; ADC PLOTCVBASELO,Y ;table of $8400 row base addresses ; STA PLOTCDEST ;= cell address ; LDA #0 ; ADC PLOTCVBASEHI,Y ;do the high byte ; STA PLOTCDEST+1 ; TYA ; ADC IMAGEH ; JSR PUTIMAGEWAITLINE ; LDA IMAGEW ; TAY ; DEY ; PUTIMAGE2L1: ; LDA (TMPPTR),Y ; STA (PLOTDEST),Y ; DEY ; CPY #255 ; BNE PUTIMAGE2L1 ; CLC ; LDA TMPPTR ; ADC IMAGEW ; STA TMPPTR ; LDA TMPPTR+1 ; ADC #0 ; STA TMPPTR+1 ; CLC ; LDA PLOTDEST ; ADC #$40 ; STA PLOTDEST ; LDA PLOTDEST+1 ; ADC #$1 ; STA PLOTDEST+1 ; DEC IMAGEH ; BEQ PUTIMAGE2C ; LDA IMAGEW ; TAY ; DEY ; JMP PUTIMAGE2L1 ; PUTIMAGE2C: ; LDA IMAGEH2 ; STA IMAGEH ; LDA IMAGEW ; LSR A ; LSR A ; LSR A ; STA IMAGEW ; TAY ; DEY ; PUTIMAGE2L2: ; LDA (TMPPTR),Y ; STA (PLOTCDEST),Y ; DEY ; CPY #255 ; BNE PUTIMAGE2L2 ; DEC IMAGEH ; BEQ PUTIMAGE2E ; CLC ; LDA TMPPTR ; ADC IMAGEW ; STA TMPPTR ; LDA TMPPTR+1 ; ADC #0 ; STA TMPPTR+1 ; CLC ; LDA PLOTCDEST ; ADC #40 ; STA PLOTCDEST ; LDA PLOTCDEST+1 ; ADC #0 ; STA PLOTCDEST+1 ; LDA IMAGEW ; TAY ; DEY ; JMP PUTIMAGE2L2 ; PUTIMAGE2E: ; RTS ; ;;;;;;;;;;;;;;;;; ; PUTIMAGE3: ; LDY #0 ; LDA (TMPPTR),Y ; STA IMAGEW ; LDY #1 ; LDA (TMPPTR),Y ; LSR ; LSR ; LSR ; STA IMAGEH ; STA IMAGEH2 ; CLC ; LDA TMPPTR ; ADC #2 ; STA TMPPTR ; LDA TMPPTR+1 ; ADC #0 ; STA TMPPTR+1 ; ;------------------------- ; ;calc Y-cell, divide by 8 ; ;y/8 is y-cell table index ; ;------------------------- ; LDA IMAGEY ; LSR ;/ 2 ; LSR ;/ 4 ; LSR ;/ 8 ; TAY ;tbl_8,y index ; CLC ; ;------------------------ ; ;calc X-cell, divide by 8 ; ;divide 2-byte PLOTX / 8 ; ;------------------------ ; LDA IMAGEX ; ROR IMAGEX+1 ;rotate the high byte into carry flag ; ROR ;lo byte / 2 (rotate C into low byte) ; LSR ;lo byte / 4 ; TAX ;tbl_8,x index ; ;---------------------------------- ; ;add x & y to calc cell point is in ; ;---------------------------------- ; CLC ; LDA PLOTVBASELO,Y ;table of $A000 row base addresses ; ADC PLOT8LO,X ;+ (8 * Xcell) ; STA PLOTDEST ;= cell address ; LDA PLOTVBASEHI,Y ;do the high byte ; ADC PLOT8HI,X ; STA PLOTDEST+1 ; CLC ; TXA ; ADC PLOTCVBASELO,Y ;table of $8400 row base addresses ; STA PLOTCDEST ;= cell address ; LDA #0 ; ADC PLOTCVBASEHI,Y ;do the high byte ; STA PLOTCDEST+1 ; CLC ; TXA ; ADC PLOTC2VBASELO,Y ;table of $8400 row base addresses ; STA PLOTC2DEST ;= cell address ; LDA #0 ; ADC PLOTC2VBASEHI,Y ;do the high byte ; STA PLOTC2DEST+1 ; LDA IMAGEW ; ASL ; TAY ; DEY ; PUTIMAGE3L1: ; LDA (TMPPTR),Y ; STA (PLOTDEST),Y ; DEY ; CPY #255 ; BNE PUTIMAGE3L1 ; CLC ; LDA TMPPTR ; ADC IMAGEW ; STA TMPPTR ; LDA TMPPTR+1 ; ADC #0 ; STA TMPPTR+1 ; CLC ; LDA TMPPTR ; ADC IMAGEW ; STA TMPPTR ; LDA TMPPTR+1 ; ADC #0 ; STA TMPPTR+1 ; CLC ; LDA PLOTDEST ; ADC #$40 ; STA PLOTDEST ; LDA PLOTDEST+1 ; ADC #$1 ; STA PLOTDEST+1 ; DEC IMAGEH ; BEQ PUTIMAGE3C ; LDA IMAGEW ; ASL ; TAY ; DEY ; JMP PUTIMAGE3L1 ; PUTIMAGE3C: ; LDA IMAGEH2 ; STA IMAGEH ; LDA IMAGEW ; LSR A ; LSR A ; STA IMAGEW ; TAY ; DEY ; PUTIMAGE3L2: ; LDA (TMPPTR),Y ; STA (PLOTCDEST),Y ; DEY ; CPY #255 ; BNE PUTIMAGE3L2 ; DEC IMAGEH ; BEQ PUTIMAGE3C2 ; CLC ; LDA TMPPTR ; ADC IMAGEW ; STA TMPPTR ; LDA TMPPTR+1 ; ADC #0 ; STA TMPPTR+1 ; CLC ; LDA PLOTCDEST ; ADC #40 ; STA PLOTCDEST ; LDA PLOTCDEST+1 ; ADC #0 ; STA PLOTCDEST+1 ; LDA IMAGEW ; TAY ; DEY ; JMP PUTIMAGE3L2 ; PUTIMAGE3C2: ; LDA IMAGEH2 ; STA IMAGEH ; LDA IMAGEW ; TAY ; PUTIMAGE3C2L2: ; LDA (TMPPTR),Y ; STA (PLOTC2DEST),Y ; DEY ; CPY #255 ; BNE PUTIMAGE3C2L2 ; DEC IMAGEH ; BEQ PUTIMAGE3E ; CLC ; LDA TMPPTR ; ADC IMAGEW ; STA TMPPTR ; LDA TMPPTR+1 ; ADC #0 ; STA TMPPTR+1 ; CLC ; LDA PLOTC2DEST ; ADC #40 ; STA PLOTC2DEST ; LDA PLOTC2DEST+1 ; ADC #0 ; STA PLOTC2DEST+1 ; LDA IMAGEW ; TAY ; DEY ; JMP PUTIMAGE3C2L2 ; PUTIMAGE3E: ; LDY #0 ; LDA (TMPPTR),Y ; STA $D021 ; RTS ; PUTIMAGEWAITLINE: ; CMP $D012 ; BCS PUTIMAGEWAITLINE RTS
// Copyright (c) 2012-2015 The Bitcoinold Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "compat/sanity.h" #include "key.h" #include "test/test_bitcoinold.h" #include <boost/test/unit_test.hpp> BOOST_FIXTURE_TEST_SUITE(sanity_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(basic_sanity) { BOOST_CHECK_MESSAGE(glibc_sanity_test() == true, "libc sanity test"); BOOST_CHECK_MESSAGE(glibcxx_sanity_test() == true, "stdlib sanity test"); BOOST_CHECK_MESSAGE(ECC_InitSanityCheck() == true, "openssl ECC test"); } BOOST_AUTO_TEST_SUITE_END()
; A067082: If n = abc...def in decimal notation then the right digit sum function = abc...def + bc...def + c...def + ... + def + ef + f. ; 0,1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,22,24,26,28,20,22,24,26,28,30,32,34,36,38,30,32,34,36,38,40,42,44,46,48,40,42,44,46,48,50,52,54,56,58,50,52,54,56,58,60,62,64,66,68,60,62,64,66,68,70,72,74,76,78,70,72 mov $2,$0 trn $0,10 mod $0,10 add $0,$2
; A127984: a(n) = (n/3 + 7/9)*2^(n - 1) + (-1)^n/9. ; 1,3,7,17,39,89,199,441,967,2105,4551,9785,20935,44601,94663,200249,422343,888377,1864135,3903033,8155591,17010233,35418567,73633337,152859079,316902969,656175559,1357090361,2803659207,5786275385,11930464711,24576757305,50585170375,104033652281,213793927623,439041101369,900988694983,1847790374457,3787206717895,7757665373753,15881834623431,32496676998713,66459369501127,135850770009657,277565602034119,566859328097849,1157174904254919,2361262304628281,4816349601493447 mov $2,$0 add $0,12 lpb $2 add $0,$2 mul $0,2 sub $2,1 lpe mov $1,$0 div $1,18 mul $1,2 add $1,1
; $Id: ASMWrMsrEx.asm 69111 2017-10-17 14:26:02Z vboxsync $ ;; @file ; IPRT - ASMWrMsrEx(). ; ; ; Copyright (C) 2013-2017 Oracle Corporation ; ; This file is part of VirtualBox Open Source Edition (OSE), as ; available from http://www.virtualbox.org. This file is free software; ; you can redistribute it and/or modify it under the terms of the GNU ; General Public License (GPL) as published by the Free Software ; Foundation, in version 2 as it comes in the "COPYING" file of the ; VirtualBox OSE distribution. VirtualBox OSE is distributed in the ; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. ; ; The contents of this file may alternatively be used under the terms ; of the Common Development and Distribution License Version 1.0 ; (CDDL) only, as it comes in the "COPYING.CDDL" file of the ; VirtualBox OSE distribution, in which case the provisions of the ; CDDL are applicable instead of those of the GPL. ; ; You may elect to license modified versions of this file under the ; terms and conditions of either the GPL or the CDDL or both. ; ;******************************************************************************* ;* Header Files * ;******************************************************************************* %include "iprt/asmdefs.mac" BEGINCODE ;; ; Special version of ASMRdMsr that allow specifying the rdi value. ; ; @param uMsr msc=rcx, gcc=rdi, x86=[ebp+8] The MSR to read. ; @param uXDI msc=rdx, gcc=rsi, x86=[ebp+12] The EDI/RDI value. ; @param uValue msc=r8, gcc=rdx, x86=[ebp+16] The 64-bit value to write. ; BEGINPROC_EXPORTED ASMWrMsrEx %ifdef ASM_CALL64_MSC proc_frame ASMWrMsrEx_DupWarningHack push rdi [pushreg rdi] [endprolog] and ecx, ecx ; serious paranoia mov rdi, rdx mov eax, r8d mov rdx, r8 shr rdx, 32 wrmsr pop rdi ret endproc_frame %elifdef ASM_CALL64_GCC mov ecx, edi mov rdi, rsi mov eax, edx shr edx, 32 wrmsr ret %elifdef RT_ARCH_X86 push ebp mov ebp, esp push edi mov ecx, [ebp + 8] mov edi, [esp + 12] mov eax, [esp + 16] mov edx, [esp + 20] wrmsr pop edi leave ret %else %error "Undefined arch?" %endif ENDPROC ASMWrMsrEx
SECTION code_clib SECTION code_fp_math48 PUBLIC _atanh_fastcall EXTERN cm48_sdcciy_atanh_fastcall defc _atanh_fastcall = cm48_sdcciy_atanh_fastcall
; A262450: Number of (n+3) X (1+3) 0..1 arrays with each row and column divisible by 15, read as a binary number with top and left being the most significant bits. ; 2,3,5,9,18,35,69,137,274,547,1093,2185,4370,8739,17477,34953,69906,139811,279621,559241,1118482,2236963,4473925,8947849,17895698,35791395,71582789,143165577,286331154,572662307,1145324613,2290649225,4581298450,9162596899,18325193797,36650387593,73300775186,146601550371,293203100741,586406201481,1172812402962,2345624805923,4691249611845,9382499223689,18764998447378,37529996894755,75059993789509,150119987579017,300239975158034,600479950316067,1200959900632133,2401919801264265,4803839602528530,9607679205057059,19215358410114117,38430716820228233,76861433640456466,153722867280912931,307445734561825861,614891469123651721,1229782938247303442,2459565876494606883,4919131752989213765,9838263505978427529,19676527011956855058,39353054023913710115,78706108047827420229,157412216095654840457,314824432191309680914,629648864382619361827,1259297728765238723653,2518595457530477447305,5037190915060954894610,10074381830121909789219,20148763660243819578437,40297527320487639156873,80595054640975278313746,161190109281950556627491,322380218563901113254981,644760437127802226509961,1289520874255604453019922,2579041748511208906039843,5158083497022417812079685,10316166994044835624159369,20632333988089671248318738,41264667976179342496637475,82529335952358684993274949,165058671904717369986549897,330117343809434739973099794,660234687618869479946199587,1320469375237738959892399173,2640938750475477919784798345,5281877500950955839569596690,10563755001901911679139193379,21127510003803823358278386757,42255020007607646716556773513,84510040015215293433113547026,169020080030430586866227094051,338040160060861173732454188101,676080320121722347464908376201 mov $1,2 pow $1,$0 mul $1,32 div $1,30 add $1,1 mov $0,$1
_ps: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "user.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 04 sub $0x4,%esp cps(); 11: e8 f4 02 00 00 call 30a <cps> exit(); 16: e8 47 02 00 00 call 262 <exit> 1b: 66 90 xchg %ax,%ax 1d: 66 90 xchg %ax,%ax 1f: 90 nop 00000020 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 20: 55 push %ebp 21: 89 e5 mov %esp,%ebp 23: 53 push %ebx 24: 8b 45 08 mov 0x8(%ebp),%eax 27: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 2a: 89 c2 mov %eax,%edx 2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 30: 83 c1 01 add $0x1,%ecx 33: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 37: 83 c2 01 add $0x1,%edx 3a: 84 db test %bl,%bl 3c: 88 5a ff mov %bl,-0x1(%edx) 3f: 75 ef jne 30 <strcpy+0x10> ; return os; } 41: 5b pop %ebx 42: 5d pop %ebp 43: c3 ret 44: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 4a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000050 <strcmp>: int strcmp(const char *p, const char *q) { 50: 55 push %ebp 51: 89 e5 mov %esp,%ebp 53: 56 push %esi 54: 53 push %ebx 55: 8b 55 08 mov 0x8(%ebp),%edx 58: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 5b: 0f b6 02 movzbl (%edx),%eax 5e: 0f b6 19 movzbl (%ecx),%ebx 61: 84 c0 test %al,%al 63: 75 1e jne 83 <strcmp+0x33> 65: eb 29 jmp 90 <strcmp+0x40> 67: 89 f6 mov %esi,%esi 69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 70: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 73: 0f b6 02 movzbl (%edx),%eax p++, q++; 76: 8d 71 01 lea 0x1(%ecx),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 79: 0f b6 59 01 movzbl 0x1(%ecx),%ebx 7d: 84 c0 test %al,%al 7f: 74 0f je 90 <strcmp+0x40> 81: 89 f1 mov %esi,%ecx 83: 38 d8 cmp %bl,%al 85: 74 e9 je 70 <strcmp+0x20> p++, q++; return (uchar)*p - (uchar)*q; 87: 29 d8 sub %ebx,%eax } 89: 5b pop %ebx 8a: 5e pop %esi 8b: 5d pop %ebp 8c: c3 ret 8d: 8d 76 00 lea 0x0(%esi),%esi } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 90: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; 92: 29 d8 sub %ebx,%eax } 94: 5b pop %ebx 95: 5e pop %esi 96: 5d pop %ebp 97: c3 ret 98: 90 nop 99: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000000a0 <strlen>: uint strlen(const char *s) { a0: 55 push %ebp a1: 89 e5 mov %esp,%ebp a3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) a6: 80 39 00 cmpb $0x0,(%ecx) a9: 74 12 je bd <strlen+0x1d> ab: 31 d2 xor %edx,%edx ad: 8d 76 00 lea 0x0(%esi),%esi b0: 83 c2 01 add $0x1,%edx b3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) b7: 89 d0 mov %edx,%eax b9: 75 f5 jne b0 <strlen+0x10> ; return n; } bb: 5d pop %ebp bc: c3 ret uint strlen(const char *s) { int n; for(n = 0; s[n]; n++) bd: 31 c0 xor %eax,%eax ; return n; } bf: 5d pop %ebp c0: c3 ret c1: eb 0d jmp d0 <memset> c3: 90 nop c4: 90 nop c5: 90 nop c6: 90 nop c7: 90 nop c8: 90 nop c9: 90 nop ca: 90 nop cb: 90 nop cc: 90 nop cd: 90 nop ce: 90 nop cf: 90 nop 000000d0 <memset>: void* memset(void *dst, int c, uint n) { d0: 55 push %ebp d1: 89 e5 mov %esp,%ebp d3: 57 push %edi d4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : d7: 8b 4d 10 mov 0x10(%ebp),%ecx da: 8b 45 0c mov 0xc(%ebp),%eax dd: 89 d7 mov %edx,%edi df: fc cld e0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } e2: 89 d0 mov %edx,%eax e4: 5f pop %edi e5: 5d pop %ebp e6: c3 ret e7: 89 f6 mov %esi,%esi e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000000f0 <strchr>: char* strchr(const char *s, char c) { f0: 55 push %ebp f1: 89 e5 mov %esp,%ebp f3: 53 push %ebx f4: 8b 45 08 mov 0x8(%ebp),%eax f7: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) fa: 0f b6 10 movzbl (%eax),%edx fd: 84 d2 test %dl,%dl ff: 74 1d je 11e <strchr+0x2e> if(*s == c) 101: 38 d3 cmp %dl,%bl 103: 89 d9 mov %ebx,%ecx 105: 75 0d jne 114 <strchr+0x24> 107: eb 17 jmp 120 <strchr+0x30> 109: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 110: 38 ca cmp %cl,%dl 112: 74 0c je 120 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 114: 83 c0 01 add $0x1,%eax 117: 0f b6 10 movzbl (%eax),%edx 11a: 84 d2 test %dl,%dl 11c: 75 f2 jne 110 <strchr+0x20> if(*s == c) return (char*)s; return 0; 11e: 31 c0 xor %eax,%eax } 120: 5b pop %ebx 121: 5d pop %ebp 122: c3 ret 123: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 129: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000130 <gets>: char* gets(char *buf, int max) { 130: 55 push %ebp 131: 89 e5 mov %esp,%ebp 133: 57 push %edi 134: 56 push %esi 135: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 136: 31 f6 xor %esi,%esi cc = read(0, &c, 1); 138: 8d 7d e7 lea -0x19(%ebp),%edi return 0; } char* gets(char *buf, int max) { 13b: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ 13e: eb 29 jmp 169 <gets+0x39> cc = read(0, &c, 1); 140: 83 ec 04 sub $0x4,%esp 143: 6a 01 push $0x1 145: 57 push %edi 146: 6a 00 push $0x0 148: e8 2d 01 00 00 call 27a <read> if(cc < 1) 14d: 83 c4 10 add $0x10,%esp 150: 85 c0 test %eax,%eax 152: 7e 1d jle 171 <gets+0x41> break; buf[i++] = c; 154: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 158: 8b 55 08 mov 0x8(%ebp),%edx 15b: 89 de mov %ebx,%esi if(c == '\n' || c == '\r') 15d: 3c 0a cmp $0xa,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 15f: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 163: 74 1b je 180 <gets+0x50> 165: 3c 0d cmp $0xd,%al 167: 74 17 je 180 <gets+0x50> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 169: 8d 5e 01 lea 0x1(%esi),%ebx 16c: 3b 5d 0c cmp 0xc(%ebp),%ebx 16f: 7c cf jl 140 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 171: 8b 45 08 mov 0x8(%ebp),%eax 174: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 178: 8d 65 f4 lea -0xc(%ebp),%esp 17b: 5b pop %ebx 17c: 5e pop %esi 17d: 5f pop %edi 17e: 5d pop %ebp 17f: c3 ret break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 180: 8b 45 08 mov 0x8(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 183: 89 de mov %ebx,%esi break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 185: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 189: 8d 65 f4 lea -0xc(%ebp),%esp 18c: 5b pop %ebx 18d: 5e pop %esi 18e: 5f pop %edi 18f: 5d pop %ebp 190: c3 ret 191: eb 0d jmp 1a0 <stat> 193: 90 nop 194: 90 nop 195: 90 nop 196: 90 nop 197: 90 nop 198: 90 nop 199: 90 nop 19a: 90 nop 19b: 90 nop 19c: 90 nop 19d: 90 nop 19e: 90 nop 19f: 90 nop 000001a0 <stat>: int stat(const char *n, struct stat *st) { 1a0: 55 push %ebp 1a1: 89 e5 mov %esp,%ebp 1a3: 56 push %esi 1a4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 1a5: 83 ec 08 sub $0x8,%esp 1a8: 6a 00 push $0x0 1aa: ff 75 08 pushl 0x8(%ebp) 1ad: e8 f0 00 00 00 call 2a2 <open> if(fd < 0) 1b2: 83 c4 10 add $0x10,%esp 1b5: 85 c0 test %eax,%eax 1b7: 78 27 js 1e0 <stat+0x40> return -1; r = fstat(fd, st); 1b9: 83 ec 08 sub $0x8,%esp 1bc: ff 75 0c pushl 0xc(%ebp) 1bf: 89 c3 mov %eax,%ebx 1c1: 50 push %eax 1c2: e8 f3 00 00 00 call 2ba <fstat> 1c7: 89 c6 mov %eax,%esi close(fd); 1c9: 89 1c 24 mov %ebx,(%esp) 1cc: e8 b9 00 00 00 call 28a <close> return r; 1d1: 83 c4 10 add $0x10,%esp 1d4: 89 f0 mov %esi,%eax } 1d6: 8d 65 f8 lea -0x8(%ebp),%esp 1d9: 5b pop %ebx 1da: 5e pop %esi 1db: 5d pop %ebp 1dc: c3 ret 1dd: 8d 76 00 lea 0x0(%esi),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 1e0: b8 ff ff ff ff mov $0xffffffff,%eax 1e5: eb ef jmp 1d6 <stat+0x36> 1e7: 89 f6 mov %esi,%esi 1e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001f0 <atoi>: return r; } int atoi(const char *s) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 53 push %ebx 1f4: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 1f7: 0f be 11 movsbl (%ecx),%edx 1fa: 8d 42 d0 lea -0x30(%edx),%eax 1fd: 3c 09 cmp $0x9,%al 1ff: b8 00 00 00 00 mov $0x0,%eax 204: 77 1f ja 225 <atoi+0x35> 206: 8d 76 00 lea 0x0(%esi),%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 210: 8d 04 80 lea (%eax,%eax,4),%eax 213: 83 c1 01 add $0x1,%ecx 216: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 21a: 0f be 11 movsbl (%ecx),%edx 21d: 8d 5a d0 lea -0x30(%edx),%ebx 220: 80 fb 09 cmp $0x9,%bl 223: 76 eb jbe 210 <atoi+0x20> n = n*10 + *s++ - '0'; return n; } 225: 5b pop %ebx 226: 5d pop %ebp 227: c3 ret 228: 90 nop 229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000230 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 56 push %esi 234: 53 push %ebx 235: 8b 5d 10 mov 0x10(%ebp),%ebx 238: 8b 45 08 mov 0x8(%ebp),%eax 23b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 23e: 85 db test %ebx,%ebx 240: 7e 14 jle 256 <memmove+0x26> 242: 31 d2 xor %edx,%edx 244: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 248: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 24c: 88 0c 10 mov %cl,(%eax,%edx,1) 24f: 83 c2 01 add $0x1,%edx char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 252: 39 da cmp %ebx,%edx 254: 75 f2 jne 248 <memmove+0x18> *dst++ = *src++; return vdst; } 256: 5b pop %ebx 257: 5e pop %esi 258: 5d pop %ebp 259: c3 ret 0000025a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 25a: b8 01 00 00 00 mov $0x1,%eax 25f: cd 40 int $0x40 261: c3 ret 00000262 <exit>: SYSCALL(exit) 262: b8 02 00 00 00 mov $0x2,%eax 267: cd 40 int $0x40 269: c3 ret 0000026a <wait>: SYSCALL(wait) 26a: b8 03 00 00 00 mov $0x3,%eax 26f: cd 40 int $0x40 271: c3 ret 00000272 <pipe>: SYSCALL(pipe) 272: b8 04 00 00 00 mov $0x4,%eax 277: cd 40 int $0x40 279: c3 ret 0000027a <read>: SYSCALL(read) 27a: b8 05 00 00 00 mov $0x5,%eax 27f: cd 40 int $0x40 281: c3 ret 00000282 <write>: SYSCALL(write) 282: b8 10 00 00 00 mov $0x10,%eax 287: cd 40 int $0x40 289: c3 ret 0000028a <close>: SYSCALL(close) 28a: b8 15 00 00 00 mov $0x15,%eax 28f: cd 40 int $0x40 291: c3 ret 00000292 <kill>: SYSCALL(kill) 292: b8 06 00 00 00 mov $0x6,%eax 297: cd 40 int $0x40 299: c3 ret 0000029a <exec>: SYSCALL(exec) 29a: b8 07 00 00 00 mov $0x7,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <open>: SYSCALL(open) 2a2: b8 0f 00 00 00 mov $0xf,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <mknod>: SYSCALL(mknod) 2aa: b8 11 00 00 00 mov $0x11,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <unlink>: SYSCALL(unlink) 2b2: b8 12 00 00 00 mov $0x12,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <fstat>: SYSCALL(fstat) 2ba: b8 08 00 00 00 mov $0x8,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <link>: SYSCALL(link) 2c2: b8 13 00 00 00 mov $0x13,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <mkdir>: SYSCALL(mkdir) 2ca: b8 14 00 00 00 mov $0x14,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <chdir>: SYSCALL(chdir) 2d2: b8 09 00 00 00 mov $0x9,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <dup>: SYSCALL(dup) 2da: b8 0a 00 00 00 mov $0xa,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <getpid>: SYSCALL(getpid) 2e2: b8 0b 00 00 00 mov $0xb,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <sbrk>: SYSCALL(sbrk) 2ea: b8 0c 00 00 00 mov $0xc,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <sleep>: SYSCALL(sleep) 2f2: b8 0d 00 00 00 mov $0xd,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <waitx>: SYSCALL(waitx) 2fa: b8 16 00 00 00 mov $0x16,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <getpinfo>: SYSCALL(getpinfo) 302: b8 17 00 00 00 mov $0x17,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <cps>: SYSCALL(cps) 30a: b8 18 00 00 00 mov $0x18,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <set_priority>: 312: b8 19 00 00 00 mov $0x19,%eax 317: cd 40 int $0x40 319: c3 ret 31a: 66 90 xchg %ax,%ax 31c: 66 90 xchg %ax,%ax 31e: 66 90 xchg %ax,%ax 00000320 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 320: 55 push %ebp 321: 89 e5 mov %esp,%ebp 323: 57 push %edi 324: 56 push %esi 325: 53 push %ebx 326: 89 c6 mov %eax,%esi 328: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 32b: 8b 5d 08 mov 0x8(%ebp),%ebx 32e: 85 db test %ebx,%ebx 330: 74 7e je 3b0 <printint+0x90> 332: 89 d0 mov %edx,%eax 334: c1 e8 1f shr $0x1f,%eax 337: 84 c0 test %al,%al 339: 74 75 je 3b0 <printint+0x90> neg = 1; x = -xx; 33b: 89 d0 mov %edx,%eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 33d: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) x = -xx; 344: f7 d8 neg %eax 346: 89 75 c0 mov %esi,-0x40(%ebp) } else { x = xx; } i = 0; 349: 31 ff xor %edi,%edi 34b: 8d 5d d7 lea -0x29(%ebp),%ebx 34e: 89 ce mov %ecx,%esi 350: eb 08 jmp 35a <printint+0x3a> 352: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ buf[i++] = digits[x % base]; 358: 89 cf mov %ecx,%edi 35a: 31 d2 xor %edx,%edx 35c: 8d 4f 01 lea 0x1(%edi),%ecx 35f: f7 f6 div %esi 361: 0f b6 92 e8 06 00 00 movzbl 0x6e8(%edx),%edx }while((x /= base) != 0); 368: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 36a: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 36d: 75 e9 jne 358 <printint+0x38> if(neg) 36f: 8b 45 c4 mov -0x3c(%ebp),%eax 372: 8b 75 c0 mov -0x40(%ebp),%esi 375: 85 c0 test %eax,%eax 377: 74 08 je 381 <printint+0x61> buf[i++] = '-'; 379: c6 44 0d d8 2d movb $0x2d,-0x28(%ebp,%ecx,1) 37e: 8d 4f 02 lea 0x2(%edi),%ecx 381: 8d 7c 0d d7 lea -0x29(%ebp,%ecx,1),%edi 385: 8d 76 00 lea 0x0(%esi),%esi 388: 0f b6 07 movzbl (%edi),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 38b: 83 ec 04 sub $0x4,%esp 38e: 83 ef 01 sub $0x1,%edi 391: 6a 01 push $0x1 393: 53 push %ebx 394: 56 push %esi 395: 88 45 d7 mov %al,-0x29(%ebp) 398: e8 e5 fe ff ff call 282 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 39d: 83 c4 10 add $0x10,%esp 3a0: 39 df cmp %ebx,%edi 3a2: 75 e4 jne 388 <printint+0x68> putc(fd, buf[i]); } 3a4: 8d 65 f4 lea -0xc(%ebp),%esp 3a7: 5b pop %ebx 3a8: 5e pop %esi 3a9: 5f pop %edi 3aa: 5d pop %ebp 3ab: c3 ret 3ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; } else { x = xx; 3b0: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 3b2: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 3b9: eb 8b jmp 346 <printint+0x26> 3bb: 90 nop 3bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 000003c0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3c0: 55 push %ebp 3c1: 89 e5 mov %esp,%ebp 3c3: 57 push %edi 3c4: 56 push %esi 3c5: 53 push %ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3c6: 8d 45 10 lea 0x10(%ebp),%eax } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3c9: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3cc: 8b 75 0c mov 0xc(%ebp),%esi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3cf: 8b 7d 08 mov 0x8(%ebp),%edi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3d2: 89 45 d0 mov %eax,-0x30(%ebp) 3d5: 0f b6 1e movzbl (%esi),%ebx 3d8: 83 c6 01 add $0x1,%esi 3db: 84 db test %bl,%bl 3dd: 0f 84 b0 00 00 00 je 493 <printf+0xd3> 3e3: 31 d2 xor %edx,%edx 3e5: eb 39 jmp 420 <printf+0x60> 3e7: 89 f6 mov %esi,%esi 3e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 3f0: 83 f8 25 cmp $0x25,%eax 3f3: 89 55 d4 mov %edx,-0x2c(%ebp) state = '%'; 3f6: ba 25 00 00 00 mov $0x25,%edx state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 3fb: 74 18 je 415 <printf+0x55> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 3fd: 8d 45 e2 lea -0x1e(%ebp),%eax 400: 83 ec 04 sub $0x4,%esp 403: 88 5d e2 mov %bl,-0x1e(%ebp) 406: 6a 01 push $0x1 408: 50 push %eax 409: 57 push %edi 40a: e8 73 fe ff ff call 282 <write> 40f: 8b 55 d4 mov -0x2c(%ebp),%edx 412: 83 c4 10 add $0x10,%esp 415: 83 c6 01 add $0x1,%esi int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 418: 0f b6 5e ff movzbl -0x1(%esi),%ebx 41c: 84 db test %bl,%bl 41e: 74 73 je 493 <printf+0xd3> c = fmt[i] & 0xff; if(state == 0){ 420: 85 d2 test %edx,%edx uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 422: 0f be cb movsbl %bl,%ecx 425: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 428: 74 c6 je 3f0 <printf+0x30> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 42a: 83 fa 25 cmp $0x25,%edx 42d: 75 e6 jne 415 <printf+0x55> if(c == 'd'){ 42f: 83 f8 64 cmp $0x64,%eax 432: 0f 84 f8 00 00 00 je 530 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 438: 81 e1 f7 00 00 00 and $0xf7,%ecx 43e: 83 f9 70 cmp $0x70,%ecx 441: 74 5d je 4a0 <printf+0xe0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 443: 83 f8 73 cmp $0x73,%eax 446: 0f 84 84 00 00 00 je 4d0 <printf+0x110> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 44c: 83 f8 63 cmp $0x63,%eax 44f: 0f 84 ea 00 00 00 je 53f <printf+0x17f> putc(fd, *ap); ap++; } else if(c == '%'){ 455: 83 f8 25 cmp $0x25,%eax 458: 0f 84 c2 00 00 00 je 520 <printf+0x160> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 45e: 8d 45 e7 lea -0x19(%ebp),%eax 461: 83 ec 04 sub $0x4,%esp 464: c6 45 e7 25 movb $0x25,-0x19(%ebp) 468: 6a 01 push $0x1 46a: 50 push %eax 46b: 57 push %edi 46c: e8 11 fe ff ff call 282 <write> 471: 83 c4 0c add $0xc,%esp 474: 8d 45 e6 lea -0x1a(%ebp),%eax 477: 88 5d e6 mov %bl,-0x1a(%ebp) 47a: 6a 01 push $0x1 47c: 50 push %eax 47d: 57 push %edi 47e: 83 c6 01 add $0x1,%esi 481: e8 fc fd ff ff call 282 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 486: 0f b6 5e ff movzbl -0x1(%esi),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 48a: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 48d: 31 d2 xor %edx,%edx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 48f: 84 db test %bl,%bl 491: 75 8d jne 420 <printf+0x60> putc(fd, c); } state = 0; } } } 493: 8d 65 f4 lea -0xc(%ebp),%esp 496: 5b pop %ebx 497: 5e pop %esi 498: 5f pop %edi 499: 5d pop %ebp 49a: c3 ret 49b: 90 nop 49c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 4a0: 83 ec 0c sub $0xc,%esp 4a3: b9 10 00 00 00 mov $0x10,%ecx 4a8: 6a 00 push $0x0 4aa: 8b 5d d0 mov -0x30(%ebp),%ebx 4ad: 89 f8 mov %edi,%eax 4af: 8b 13 mov (%ebx),%edx 4b1: e8 6a fe ff ff call 320 <printint> ap++; 4b6: 89 d8 mov %ebx,%eax 4b8: 83 c4 10 add $0x10,%esp } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4bb: 31 d2 xor %edx,%edx if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; 4bd: 83 c0 04 add $0x4,%eax 4c0: 89 45 d0 mov %eax,-0x30(%ebp) 4c3: e9 4d ff ff ff jmp 415 <printf+0x55> 4c8: 90 nop 4c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 4d0: 8b 45 d0 mov -0x30(%ebp),%eax 4d3: 8b 18 mov (%eax),%ebx ap++; 4d5: 83 c0 04 add $0x4,%eax 4d8: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) s = "(null)"; 4db: b8 e0 06 00 00 mov $0x6e0,%eax 4e0: 85 db test %ebx,%ebx 4e2: 0f 44 d8 cmove %eax,%ebx while(*s != 0){ 4e5: 0f b6 03 movzbl (%ebx),%eax 4e8: 84 c0 test %al,%al 4ea: 74 23 je 50f <printf+0x14f> 4ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 4f0: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4f3: 8d 45 e3 lea -0x1d(%ebp),%eax 4f6: 83 ec 04 sub $0x4,%esp 4f9: 6a 01 push $0x1 ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 4fb: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4fe: 50 push %eax 4ff: 57 push %edi 500: e8 7d fd ff ff call 282 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 505: 0f b6 03 movzbl (%ebx),%eax 508: 83 c4 10 add $0x10,%esp 50b: 84 c0 test %al,%al 50d: 75 e1 jne 4f0 <printf+0x130> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 50f: 31 d2 xor %edx,%edx 511: e9 ff fe ff ff jmp 415 <printf+0x55> 516: 8d 76 00 lea 0x0(%esi),%esi 519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 520: 83 ec 04 sub $0x4,%esp 523: 88 5d e5 mov %bl,-0x1b(%ebp) 526: 8d 45 e5 lea -0x1b(%ebp),%eax 529: 6a 01 push $0x1 52b: e9 4c ff ff ff jmp 47c <printf+0xbc> } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 530: 83 ec 0c sub $0xc,%esp 533: b9 0a 00 00 00 mov $0xa,%ecx 538: 6a 01 push $0x1 53a: e9 6b ff ff ff jmp 4aa <printf+0xea> 53f: 8b 5d d0 mov -0x30(%ebp),%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 542: 83 ec 04 sub $0x4,%esp 545: 8b 03 mov (%ebx),%eax 547: 6a 01 push $0x1 549: 88 45 e4 mov %al,-0x1c(%ebp) 54c: 8d 45 e4 lea -0x1c(%ebp),%eax 54f: 50 push %eax 550: 57 push %edi 551: e8 2c fd ff ff call 282 <write> 556: e9 5b ff ff ff jmp 4b6 <printf+0xf6> 55b: 66 90 xchg %ax,%ax 55d: 66 90 xchg %ax,%ax 55f: 90 nop 00000560 <free>: static Header base; static Header *freep; void free(void *ap) { 560: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 561: a1 80 09 00 00 mov 0x980,%eax static Header base; static Header *freep; void free(void *ap) { 566: 89 e5 mov %esp,%ebp 568: 57 push %edi 569: 56 push %esi 56a: 53 push %ebx 56b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 56e: 8b 10 mov (%eax),%edx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 570: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 573: 39 c8 cmp %ecx,%eax 575: 73 19 jae 590 <free+0x30> 577: 89 f6 mov %esi,%esi 579: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 580: 39 d1 cmp %edx,%ecx 582: 72 1c jb 5a0 <free+0x40> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 584: 39 d0 cmp %edx,%eax 586: 73 18 jae 5a0 <free+0x40> static Header base; static Header *freep; void free(void *ap) { 588: 89 d0 mov %edx,%eax Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 58a: 39 c8 cmp %ecx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 58c: 8b 10 mov (%eax),%edx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 58e: 72 f0 jb 580 <free+0x20> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 590: 39 d0 cmp %edx,%eax 592: 72 f4 jb 588 <free+0x28> 594: 39 d1 cmp %edx,%ecx 596: 73 f0 jae 588 <free+0x28> 598: 90 nop 599: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi break; if(bp + bp->s.size == p->s.ptr){ 5a0: 8b 73 fc mov -0x4(%ebx),%esi 5a3: 8d 3c f1 lea (%ecx,%esi,8),%edi 5a6: 39 d7 cmp %edx,%edi 5a8: 74 19 je 5c3 <free+0x63> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 5aa: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 5ad: 8b 50 04 mov 0x4(%eax),%edx 5b0: 8d 34 d0 lea (%eax,%edx,8),%esi 5b3: 39 f1 cmp %esi,%ecx 5b5: 74 23 je 5da <free+0x7a> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 5b7: 89 08 mov %ecx,(%eax) freep = p; 5b9: a3 80 09 00 00 mov %eax,0x980 } 5be: 5b pop %ebx 5bf: 5e pop %esi 5c0: 5f pop %edi 5c1: 5d pop %ebp 5c2: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 5c3: 03 72 04 add 0x4(%edx),%esi 5c6: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 5c9: 8b 10 mov (%eax),%edx 5cb: 8b 12 mov (%edx),%edx 5cd: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 5d0: 8b 50 04 mov 0x4(%eax),%edx 5d3: 8d 34 d0 lea (%eax,%edx,8),%esi 5d6: 39 f1 cmp %esi,%ecx 5d8: 75 dd jne 5b7 <free+0x57> p->s.size += bp->s.size; 5da: 03 53 fc add -0x4(%ebx),%edx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 5dd: a3 80 09 00 00 mov %eax,0x980 bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ p->s.size += bp->s.size; 5e2: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 5e5: 8b 53 f8 mov -0x8(%ebx),%edx 5e8: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 5ea: 5b pop %ebx 5eb: 5e pop %esi 5ec: 5f pop %edi 5ed: 5d pop %ebp 5ee: c3 ret 5ef: 90 nop 000005f0 <malloc>: return freep; } void* malloc(uint nbytes) { 5f0: 55 push %ebp 5f1: 89 e5 mov %esp,%ebp 5f3: 57 push %edi 5f4: 56 push %esi 5f5: 53 push %ebx 5f6: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 5f9: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 5fc: 8b 15 80 09 00 00 mov 0x980,%edx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 602: 8d 78 07 lea 0x7(%eax),%edi 605: c1 ef 03 shr $0x3,%edi 608: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 60b: 85 d2 test %edx,%edx 60d: 0f 84 a3 00 00 00 je 6b6 <malloc+0xc6> 613: 8b 02 mov (%edx),%eax 615: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 618: 39 cf cmp %ecx,%edi 61a: 76 74 jbe 690 <malloc+0xa0> 61c: 81 ff 00 10 00 00 cmp $0x1000,%edi 622: be 00 10 00 00 mov $0x1000,%esi 627: 8d 1c fd 00 00 00 00 lea 0x0(,%edi,8),%ebx 62e: 0f 43 f7 cmovae %edi,%esi 631: ba 00 80 00 00 mov $0x8000,%edx 636: 81 ff ff 0f 00 00 cmp $0xfff,%edi 63c: 0f 46 da cmovbe %edx,%ebx 63f: eb 10 jmp 651 <malloc+0x61> 641: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 648: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 64a: 8b 48 04 mov 0x4(%eax),%ecx 64d: 39 cf cmp %ecx,%edi 64f: 76 3f jbe 690 <malloc+0xa0> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 651: 39 05 80 09 00 00 cmp %eax,0x980 657: 89 c2 mov %eax,%edx 659: 75 ed jne 648 <malloc+0x58> char *p; Header *hp; if(nu < 4096) nu = 4096; p = sbrk(nu * sizeof(Header)); 65b: 83 ec 0c sub $0xc,%esp 65e: 53 push %ebx 65f: e8 86 fc ff ff call 2ea <sbrk> if(p == (char*)-1) 664: 83 c4 10 add $0x10,%esp 667: 83 f8 ff cmp $0xffffffff,%eax 66a: 74 1c je 688 <malloc+0x98> return 0; hp = (Header*)p; hp->s.size = nu; 66c: 89 70 04 mov %esi,0x4(%eax) free((void*)(hp + 1)); 66f: 83 ec 0c sub $0xc,%esp 672: 83 c0 08 add $0x8,%eax 675: 50 push %eax 676: e8 e5 fe ff ff call 560 <free> return freep; 67b: 8b 15 80 09 00 00 mov 0x980,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 681: 83 c4 10 add $0x10,%esp 684: 85 d2 test %edx,%edx 686: 75 c0 jne 648 <malloc+0x58> return 0; 688: 31 c0 xor %eax,%eax 68a: eb 1c jmp 6a8 <malloc+0xb8> 68c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) 690: 39 cf cmp %ecx,%edi 692: 74 1c je 6b0 <malloc+0xc0> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 694: 29 f9 sub %edi,%ecx 696: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 699: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 69c: 89 78 04 mov %edi,0x4(%eax) } freep = prevp; 69f: 89 15 80 09 00 00 mov %edx,0x980 return (void*)(p + 1); 6a5: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 6a8: 8d 65 f4 lea -0xc(%ebp),%esp 6ab: 5b pop %ebx 6ac: 5e pop %esi 6ad: 5f pop %edi 6ae: 5d pop %ebp 6af: c3 ret base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 6b0: 8b 08 mov (%eax),%ecx 6b2: 89 0a mov %ecx,(%edx) 6b4: eb e9 jmp 69f <malloc+0xaf> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 6b6: c7 05 80 09 00 00 84 movl $0x984,0x980 6bd: 09 00 00 6c0: c7 05 84 09 00 00 84 movl $0x984,0x984 6c7: 09 00 00 base.s.size = 0; 6ca: b8 84 09 00 00 mov $0x984,%eax 6cf: c7 05 88 09 00 00 00 movl $0x0,0x988 6d6: 00 00 00 6d9: e9 3e ff ff ff jmp 61c <malloc+0x2c>
mov a #$05 add a #$0A mov b a
#include "cpu_profiler.h" #include "cpu_profile.h" namespace nodex { using v8::CpuProfile; using v8::Local; using v8::Object; using v8::Array; using v8::String; CpuProfiler::CpuProfiler () {} CpuProfiler::~CpuProfiler () {} #if (NODE_MODULE_VERSION > 0x0039) v8::CpuProfiler* current_cpuprofiler = v8::CpuProfiler::New(v8::Isolate::GetCurrent()); #endif void CpuProfiler::Initialize (Local<Object> target) { Nan::HandleScope scope; Local<Object> cpuProfiler = Nan::New<Object>(); Local<Array> profiles = Nan::New<Array>(); Nan::SetMethod(cpuProfiler, "startProfiling", CpuProfiler::StartProfiling); Nan::SetMethod(cpuProfiler, "stopProfiling", CpuProfiler::StopProfiling); Nan::SetMethod(cpuProfiler, "setSamplingInterval", CpuProfiler::SetSamplingInterval); Nan::Set(cpuProfiler, Nan::New<String>("profiles").ToLocalChecked(), profiles); Profile::profiles.Reset(profiles); Nan::Set(target, Nan::New<String>("cpu").ToLocalChecked(), cpuProfiler); } NAN_METHOD(CpuProfiler::StartProfiling) { Local<String> title = Nan::To<String>(info[0]).ToLocalChecked(); #if (NODE_MODULE_VERSION > 0x0039) bool recsamples = Nan::To<bool>(info[1]).ToChecked(); current_cpuprofiler->StartProfiling(title, recsamples); #elif (NODE_MODULE_VERSION > 0x000B) bool recsamples = Nan::To<bool>(info[1]).ToChecked(); v8::Isolate::GetCurrent()->GetCpuProfiler()->StartProfiling(title, recsamples); #else v8::CpuProfiler::StartProfiling(title); #endif } NAN_METHOD(CpuProfiler::StopProfiling) { const CpuProfile* profile; Local<String> title = Nan::EmptyString(); if (info.Length()) { if (info[0]->IsString()) { title = Nan::To<String>(info[0]).ToLocalChecked(); } else if (!info[0]->IsUndefined()) { return Nan::ThrowTypeError("Wrong argument [0] type (wait String)"); } } #if (NODE_MODULE_VERSION > 0x0039) profile = current_cpuprofiler->StopProfiling(title); #elif (NODE_MODULE_VERSION > 0x000B) profile = v8::Isolate::GetCurrent()->GetCpuProfiler()->StopProfiling(title); #else profile = v8::CpuProfiler::StopProfiling(title); #endif info.GetReturnValue().Set(Profile::New(profile)); } NAN_METHOD(CpuProfiler::SetSamplingInterval) { #if (NODE_MODULE_VERSION > 0x0039) current_cpuprofiler->SetSamplingInterval(Nan::To<uint32_t>(info[0]).ToChecked()); #elif (NODE_MODULE_VERSION > 0x000B) v8::Isolate::GetCurrent()->GetCpuProfiler()->SetSamplingInterval(Nan::To<uint32_t>(info[0]).ToChecked()); #endif } } //namespace nodex
; Copyright 2015-2021 Matt "MateoConLechuga" Waltz ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, ; this list of conditions and the following disclaimer. ; ; 2. Redistributions in binary form must reproduce the above copyright notice, ; this list of conditions and the following disclaimer in the documentation ; and/or other materials provided with the distribution. ; ; 3. Neither the name of the copyright holder nor the names of its contributors ; may be used to endorse or promote products derived from this software ; without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ; POSSIBILITY OF SUCH DAMAGE. gui_main: call lcd_init.setup call gui_draw_core call gui_information_box ld a,(current_screen) cp a,screen_programs jp z,view_vat_items cp a,screen_appvars jp z,view_vat_items cp a,screen_apps jp z,view_apps cp a,screen_usb jp z,view_usb_directory jp exit_full gui_information_box: draw_rectangle_outline 193, 24, 316, 221 draw_rectangle_outline 237, 54, 274, 91 draw_horiz 199, 36, 112 set_normal_text print string_file_information, 199, 27 ret gui_draw_core: call lcd_fill call util_show_free_mem draw_rectangle 1, 1, 319, 21 draw_rectangle_outline 1, 22, 318, 223 set_inverted_text print string_cesium, 5, 7 bit setting_show_battery,(iy + settings_flag) ret z call ti.usb_IsBusPowered ld a,$e5 jr nz,.draw_battery ld a,0 battery_status := $-1 or a,a ld a,$e8 jr z,.draw_battery ld a,$95 .draw_battery: draw_rectangle_outline_color 290, 5, 314, 15 draw_vert 289, 7, 7 draw_vert 288, 9, 3 ld (vRamBuffer + (291) + (320*6)),a ld (vRamBuffer + (291) + (320*14)),a ld (vRamBuffer + (313) + (320*6)),a ld (vRamBuffer + (313) + (320*14)),a ld a,(color_secondary) ld (vRamBuffer + (290) + (320*5)),a ld (vRamBuffer + (290) + (320*15)),a ld (vRamBuffer + (314) + (320*5)),a ld (vRamBuffer + (314) + (320*15)),a ld a,(battery_status) or a,a ret z dec a jr z,.battery_1 dec a jr z,.battery_2 dec a jr z,.battery_3 ld a,$25 draw_vert 292, 8, 5 ld a,$25 draw_rectangle_color 293, 7, 295 + 1, 13 + 1 .battery_3: ld a,$25 draw_rectangle_color 297, 7, 299 + 1, 13 + 1 ld a,$25 draw_rectangle_color 301, 7, 303 + 1, 13 + 1 .battery_2: ld a,$25 draw_rectangle_color 305, 7, 307 + 1, 13 + 1 .battery_1: ld a,$25 draw_rectangle_color 309, 7, 311 + 1, 13 + 1 ld a,$25 draw_vert 312, 8, 5 ret gui_draw_cesium_info: call gui_draw_core call gui_clear_status_bar set_inverted_text print string_cesium_version, 4, 228 set_normal_text ret gui_show_description: push bc push hl call gui_clear_status_bar pop hl save_cursor set_inverted_text ld bc,4 ld a,228 call util_string_xy set_normal_text restore_cursor pop bc ret gui_draw_static_options: print string_settings, 199, 206 ld de,270 ld (lcd_x),de inc hl call lcd_string ld a,(current_screen) cp a,screen_programs ret z print string_delete, 199, 195 if config_english ld de,278 else if config_french ld de,262 else ld de,278 end if ld (lcd_x),de inc hl jp lcd_string ; z flag set = option is on ; a = index gui_draw_highlightable_option: push af ld ix,current_option_selection cp a,(ix) ld ix,color_secondary ld a,(ix) ld (.color_save),a jr nz,.no_highlight ld a,(color_tertiary) ld (ix),a .no_highlight: pop af call gui_draw_option ld a,0 .color_save := $-1 ld (color_secondary),a ret ; z flag not set = fill gui_draw_option: push af ld a,(color_primary) ld (util_restore_primary.color),a jr nz,.no_fix ld a,(color_senary) call util_set_primary .no_fix: pop af push af push hl push bc push de call lcd_rectangle_outline.computed pop hl pop bc dec bc dec bc dec bc dec bc ; bc - 4 ld a,h sub a,4 ld (.recompute),a inc l ; Ty + 3 inc l ld h,ti.lcdWidth / 2 mlt hl add hl,hl pop de add hl,de ex de,hl ; recompute offset inc e inc e pop af ld a,0 .recompute := $-1 call lcd_rectangle.computed jp util_restore_primary gui_draw_color_table: call gui_clear_status_bar ld a,(color_table_active) ld hl,string_primary_color or a,a jr z,.string ld hl,string_secondary_color dec a jr z,.string ld hl,string_tertiary_color dec a jr z,.string ld hl,string_quaternary_color dec a jr z,.string ld hl,string_quinary_color dec a jr z,.string ld hl,string_senary_color .string: set_inverted_text set_cursor 4, 228 call lcd_string ld hl,string_mode_select call lcd_string set_normal_text draw_rectangle_outline 111, 71, 208, 180 ld de,(72 shl 8) or 112 xor a,a ld b,16 .loop: push bc ld b,6 .vert: push bc ld l,ti.lcdWidth / 2 ld h,d mlt hl add hl,hl push de ld d,0 add hl,de ld de,vRamBuffer add hl,de pop de ld b,16 .horiz: ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl ld (hl),a inc hl inc a djnz .horiz sub a,16 ld e,112 inc d pop bc djnz .vert pop bc add a,16 djnz .loop call gui_color_box.compute call gui_color_box.draw ld hl,(color_ptr) ld b,$ff ld a,b ld (lcd_text_fg),a ld a,(hl) ld (lcd_text_bg),a cp a,b jr nz,.nochange push af xor a,a ld (lcd_text_fg),a pop af .nochange: push af draw_rectangle_color 113, 169, 207, 179 ; code to show color pop af or a,a sbc hl,hl ld l,a set_cursor 114, 170 jp lcd_num_3 gui_color_box: .compute: ld bc,6 ; width ld a,(color_selection_y) ld e,a ld d,c mlt de ld a,e add a,72 ld e,a ; y ld a,(color_selection_x) ld l,a ld h,c mlt hl ld bc,112 add hl,bc ; x ld c,6 ld d,c push hl, de, bc call lcd_compute ld de,ti.lcdWidth * 2 + 3 add hl,de ld a,(hl) ; get the new color ld hl,(color_ptr) ld (hl),a pop bc, de, hl ret .draw: ld a,(color_secondary) push af ld a,0 ld (color_secondary),a call lcd_rectangle_outline.computed pop af ld (color_secondary),a ret color_ptr := $ dl 0 gui_clear_status_bar: draw_rectangle 1, 225, 319, 239 ret gui_draw_item_options: bit prgm_archived,(iy + prgm_flag) draw_option 300, 118, 308, 126 ld a,(current_screen) cp a,screen_appvars ret z bit prgm_locked,(iy + prgm_flag) draw_option 300, 129, 308, 137 bit prgm_hidden,(iy + prgm_flag) draw_option 300, 140, 308, 148 ret gui_draw_usb_item_options: ld hl,(item_ptr) ld bc,13 add hl,bc bit 1,(hl) push hl draw_option 300, 118, 308, 126 pop hl bit 0,(hl) push hl draw_option 300, 129, 308, 137 pop hl bit 2,(hl) draw_option 300, 140, 308, 148 ret gui_show_item_count: ld hl,(number_of_items) bit setting_list_count,(iy + settings_adv_flag) ret z .show: push hl set_cursor item_count_x, item_count_y set_inverted_text call lcd_num_4 pop hl ret gui_fixup_sprites: ld a,(color_senary) ld hl,sprite_directory_mask ld de,sprite_directory + 2 call .fix ld hl,sprite_usb_mask ld de,sprite_usb + 2 call .fix ld hl,sprite_file_mask ld de,sprite_file_ice + 2 call .fix ld de,sprite_file_c + 2 call .fix ld de,sprite_file_asm + 2 call .fix ld de,sprite_file_app + 2 call .fix ld de,sprite_file_basic + 2 call .fix ld de,sprite_file_appvar + 2 call .fix ld (sprite_locked + 2),a ld de,sprite_locked + 2 + 5 ld (de),a inc de ld (de),a inc de inc de ld (de),a inc de ld (de),a ld de,sprite_locked + 2 + 11 ld (de),a inc de ld (de),a inc de inc de ld (de),a inc de ld (de),a ld (sprite_locked + 2 + 17),a ret .fix: push hl ld b,16 .loop: push bc ld c,(hl) ld b,8 .loop1: rlc c jr nc,.skip1 ld (de),a .skip1: inc de djnz .loop1 inc hl ld c,(hl) ld b,8 .loop2: rlc c jr nc,.skip2 ld (de),a .skip2: inc de djnz .loop2 inc hl pop bc djnz .loop pop hl ret gui_backup_ram_to_flash: ld a,(color_senary) call util_set_primary if config_english draw_rectangle 114, 105, 206, 121 draw_rectangle_outline 113, 104, 207, 121 set_cursor 119, 109 else draw_rectangle 89, 105, 256, 121 draw_rectangle_outline 88, 104, 257, 121 set_cursor 95, 109 end if call util_restore_primary set_normal_text ld hl,string_ram_backup call lcd_string call lcd_blit jp flash_backup_ram gui_show_cannot_hide: ld hl,ti.vRam ld (lcd_buffer),hl ld a,(color_senary) call util_set_primary if config_english draw_rectangle 38, 105, 285, 121 draw_rectangle_outline 37, 104, 286, 121 set_cursor 44, 109 else draw_rectangle 6, 105, 310, 121 draw_rectangle_outline 5, 104, 311, 121 set_cursor 12, 109 end if call util_restore_primary set_normal_text ld hl,str_cannot_hide call lcd_string di .debounce: call ti.GetCSC or a,a jr nz,.debounce .getkey: call util_handle_apd ld iy,ti.flags call ti.DisableAPD ; disable os apd and use our own call util_show_time call ti.GetCSC or a,a jr z,.getkey ld hl,vRamBuffer ld (lcd_buffer),hl ret gui_ram_error: call gui_box_information ld hl,string_ram_free call lcd_string call ti.MemChk call lcd_num_6 jq lcd_blit gui_fat_transfer: call gui_box_information ld hl,string_fat_transferring call lcd_string jq lcd_blit gui_box_information: ld a,(color_senary) call util_set_primary draw_rectangle 89, 105, 256, 121 draw_rectangle_outline 88, 104, 257, 121 set_cursor 95, 109 call util_restore_primary set_normal_text ret
LKS_BackgroundY: lda LKS_BG.EnableY cmp #0 bne + rtl +: ;BG1 ldx LKS_BG.V_vadd1 stx VMADDL ldx LKS_BG.Dadd1_1 lda LKS_BG.Address1+2 ldy #$20 stx DMA_ADDL+$00 sta DMA_BANK+$00 sty DMA_SIZEL+$00 ldx LKS_BG.Dadd2_1 stx DMA_ADDL+$10 sta DMA_BANK+$10 sty DMA_SIZEL+$10 SNES_MDMAEN $03 ;BG2 ldx LKS_BG.V_vadd2 stx VMADDL ldx LKS_BG.Dadd1_2 lda LKS_BG.Address2+2 stx DMA_ADDL+$00 sta DMA_BANK+$00 sty DMA_SIZEL+$00 ldx LKS_BG.Dadd2_2 stx DMA_ADDL+$10 sta DMA_BANK+$10 sty DMA_SIZEL+$10 SNES_MDMAEN $03 rtl LKS_BackgroundX: lda LKS_BG.EnableX cmp #0 bne + rtl +: SNES_VMAINC $81 ldx LKS_BG.H_vadd1 stx VMADDL lda #$7E ldx #LKS_BUF_BGS1&$FFFF ldy #$40 sta DMA_BANK stx DMA_ADDL sty DMA_SIZEL SNES_MDMAEN $01 ldx LKS_BG.Address2Haddsc stx VMADDL lda #$7E ldx #LKS_BUF_BGS2&$FFFF sta DMA_BANK stx DMA_ADDL sty DMA_SIZEL SNES_MDMAEN $01 SNES_VMAINC $80 rtl LKS_Background1X: lda LKS_BG.EnableX cmp #0 bne + rtl +: SNES_VMAINC $81 ldx LKS_BG.H_vadd1 stx VMADDL lda #$7E ldx #LKS_BUF_BGS1&$FFFF ldy #$40 sta DMA_BANK stx DMA_ADDL sty DMA_SIZEL SNES_MDMAEN $01 SNES_VMAINC $80 lda LKS_DMAT adc #$10 sta LKS_DMAT rtl LKS_Background1Y: lda LKS_BG.EnableY cmp #0 bne + rtl +: ldx LKS_BG.V_vadd1 stx VMADDL ldx LKS_BG.1add1 lda LKS_BG.Address1+2 ldy #$20 stx DMA_ADDL sta DMA_BANK sty DMA_SIZEL ldx LKS_BG.1add2 stx DMA_ADDL+$10 sta DMA_BANK+$10 sty DMA_SIZEL+$10 SNES_MDMAEN $03 lda LKS_DMAT adc #$10 sta LKS_DMAT rtl LKS_Background2X: lda LKS_BG.EnableX cmp #0 bne + rtl +: SNES_VMAINC $81 ldx LKS_BG.Address2Haddsc stx VMADDL lda #$7E ldx #LKS_BUF_BGS2&$FFFF ldy #$40 sta DMA_BANK stx DMA_ADDL sty DMA_SIZEL SNES_MDMAEN $01 SNES_VMAINC $80 lda LKS_DMAT adc #$10 sta LKS_DMAT rtl LKS_Background2Y: lda LKS_BG.EnableY cmp #0 bne + rtl +: ldx LKS_BG.V_vadd2 stx VMADDL ldx LKS_BG.Dadd1_2 lda LKS_BG.Address2+2 ldy #$20 stx DMA_ADDL+$0 sta DMA_BANK+$0 sty DMA_SIZEL+$0 ldx LKS_BG.Dadd2_2 stx DMA_ADDL+$10 sta DMA_BANK+$10 sty DMA_SIZEL+$10 SNES_MDMAEN $03 lda LKS_DMAT adc #$10 sta LKS_DMAT rtl
; A071724: a(n) = 3*binomial(2n,n-1)/(n+2), n > 0. a(0)=1. ; 1,1,3,9,28,90,297,1001,3432,11934,41990,149226,534888,1931540,7020405,25662825,94287120,347993910,1289624490,4796857230,17902146600,67016296620,251577050010,946844533674,3572042254128,13505406670700,51166197843852,194214400834356,738494264901008,2812744285440936 mov $5,2 mov $9,$0 lpb $5,1 mov $0,$9 sub $5,1 add $0,$5 sub $0,1 mov $7,$0 add $0,1 mov $4,$6 add $4,$0 mov $8,$0 add $8,2 mov $2,$8 add $2,$7 mov $0,$2 bin $2,$4 div $2,$0 mov $3,$5 mov $10,$2 lpb $3,1 mov $1,$10 sub $3,1 lpe lpe lpb $9,1 sub $1,$10 mov $9,0 lpe
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: FSEGTGameOverRuleController.cpp * Author: demensdeum * * Created on March 23, 2017, 11:45 PM */ #include "BRGameOverRuleController.h" #include <BadRobots/src/Const/BRConst.h> #include <FlameSteelEngineGameToolkit/Utils/FSEGTUtils.h> BRGameOverRuleController::BRGameOverRuleController() { delegate = NULL; } BRGameOverRuleController::BRGameOverRuleController(const BRGameOverRuleController& orig) { } bool BRGameOverRuleController::step(shared_ptr<FSEGTGameData> gameData) { for (int i = 0; i < gameData->getGameObjects()->size(); i++) { auto object = gameData->getGameObjects()->objectAtIndex(i); if (object->getClassIdentifier()->compare(BRObjectClassIdentifierRobot) != 0) { continue; } int x = FSEGTUtils::getObjectX(object); if (x > BRGameControllerScreenWidth) { if (delegate != NULL) { delegate->gameOverRuleControllerDidGameOverCase(this); } return true; } } return false; } BRGameOverRuleController::~BRGameOverRuleController() { }
dnl AMD64 mpn_addlsh2_n -- rp[] = up[] + (vp[] << 1) dnl AMD64 mpn_rsblsh2_n -- rp[] = (vp[] << 1) - up[] dnl Contributed to the GNU project by Torbjorn Granlund. dnl Copyright 2008, 2010-2012 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') define(LSH, 2) define(RSH, 62) ifdef(`OPERATION_addlsh2_n', ` define(ADDSUB, add) define(ADCSBB, adc) define(func_n, mpn_addlsh2_n) define(func_nc, mpn_addlsh2_nc)') ifdef(`OPERATION_rsblsh2_n', ` define(ADDSUB, sub) define(ADCSBB, sbb) define(func_n, mpn_rsblsh2_n) define(func_nc, mpn_rsblsh2_nc)') ABI_SUPPORT(DOS64) ABI_SUPPORT(STD64) C mpn_rsblsh2_nc removed below, its idea of carry-in is inconsistent with C refmpn_rsblsh2_nc MULFUNC_PROLOGUE(mpn_addlsh2_n mpn_addlsh2_nc mpn_rsblsh2_n) include_mpn(`x86_64/coreisbr/aorrlshC_n.asm')
//---------------------------------------------------------------------------- // // TSDuck - The MPEG Transport Stream Toolkit // Copyright (c) 2005-2022, Thierry Lelegard // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. // //---------------------------------------------------------------------------- #include "tsSystemMonitor.h" #include "tsGuardCondition.h" #include "tsxmlModelDocument.h" #include "tsxmlElement.h" #include "tsIntegerUtils.h" #include "tsForkPipe.h" #include "tsSysUtils.h" #include "tsTime.h" // Stack size for the monitor thread #define MONITOR_STACK_SIZE (64 * 1024) //---------------------------------------------------------------------------- // Constructors and destructors. //---------------------------------------------------------------------------- ts::SystemMonitor::SystemMonitor(Report& report, const UString& config) : Thread(ThreadAttributes().setPriority(ThreadAttributes::GetMinimumPriority()).setStackSize(MONITOR_STACK_SIZE)), _report(report), _config_file(config), _periods(), _mutex(), _wake_up(), _terminate(false) { } ts::SystemMonitor::~SystemMonitor() { stop(); waitForTermination(); } ts::SystemMonitor::Config::Config() : log_messages(false), stable_memory(false), max_cpu(0), alarm_command() { } ts::SystemMonitor::Period::Period() : Config(), duration(0), interval(0) { } //---------------------------------------------------------------------------- // Prefix strings for all monitor messages (for filtering purpose) //---------------------------------------------------------------------------- ts::UString ts::SystemMonitor::MonPrefix(const ts::Time& date) { return u"[MON] " + date.format(ts::Time::DATE | ts::Time::HOUR | ts::Time::MINUTE) + u", "; } //---------------------------------------------------------------------------- // Stop the monitor thread. //---------------------------------------------------------------------------- void ts::SystemMonitor::stop() { GuardCondition lock(_mutex, _wake_up); _terminate = true; lock.signal(); } //---------------------------------------------------------------------------- // Thread main code. Inherited from Thread //---------------------------------------------------------------------------- void ts::SystemMonitor::main() { // Load configuration file, consider as terminated on error. if (!loadConfigurationFile(_config_file)) { _report.error(u"monitoring ignored, invalid system monitoring XML file %s", {_config_file}); return; } // Start with the first period. There must be at least one if the configuration is valid. PeriodList::const_iterator period = _periods.begin(); assert(period != _periods.end()); size_t period_index = 0; // Last period. PeriodList::const_iterator last_period = _periods.end(); assert(last_period != _periods.begin()); --last_period; // Starting time of next period. const Time start_time(Time::CurrentLocalTime()); Time start_next_period(start_time + period->duration); // Get initial system metrics. ProcessMetrics start_metrics; GetProcessMetrics(start_metrics); // Time and metrics at the last interval. Time last_time(start_time); ProcessMetrics last_metrics(start_metrics); // Time and value of last virtual memory size increase. Time vsize_uptime(start_time); size_t vsize_max(start_metrics.vmem_size); _report.info(u"%sresource monitoring started", {MonPrefix(start_time)}); // Loop on monitoring intervals. for (;;) { // Compute next time profile. const Time now(Time::CurrentLocalTime()); while (period != last_period && now >= start_next_period) { period++; period_index++; start_next_period += period->duration; _report.debug(u"starting monitoring period #%d, duration: %'d ms, interval: %'d ms", {period_index, period->duration, period->interval}); } // Wait until due time or termination request { GuardCondition lock(_mutex, _wake_up); if (!_terminate) { lock.waitCondition(period->interval); } if (_terminate) { break; } } // If we no longer log monitoring messages, issue a last message. if (!period->log_messages) { _report.info(u"%sstopping monitoring messages to avoid infinitely large log files", {MonPrefix(Time::CurrentLocalTime())}); } // Get current process metrics Time current_time(Time::CurrentLocalTime()); ProcessMetrics metrics; GetProcessMetrics(metrics); // Build the monitoring message. UString message(MonPrefix(current_time)); // Format virtual memory size status. message.format(u"VM: %s", {UString::HumanSize(metrics.vmem_size)}); if (metrics.vmem_size != last_metrics.vmem_size) { // Virtual memory has changed message.format(u" (%s)", {UString::HumanSize(ptrdiff_t(metrics.vmem_size) - ptrdiff_t(last_metrics.vmem_size), u"B", true)}); } else { // VM stable since last time. Check if temporarily stable or safely stable. // If no increase during last 95% of the running time, then we are really stable. message += (current_time - vsize_uptime) > (95 * (current_time - start_time)) / 100 ? u" (stable)" : u" (stabilizing)"; } // Format CPU load. message += u", CPU:"; message += UString::Percentage(metrics.cpu_time - last_metrics.cpu_time, current_time - last_time); message += u" (average:"; message += UString::Percentage(metrics.cpu_time - start_metrics.cpu_time, current_time - start_time); message += u")"; // Display monitoring message if allowed in this period or if vmem has increased. if (period->log_messages || metrics.vmem_size > vsize_max) { _report.info(message); } // Compute CPU percentage during last period. const int cpu = current_time <= last_time ? 0 : int((100 * (metrics.cpu_time - last_metrics.cpu_time)) / (current_time - last_time)); // Raise an alarm if the CPU usage is above defined limit for this period. if (cpu > period->max_cpu) { _report.warning(u"%sALARM, CPU usage is %d%%, max defined to %d%%", {MonPrefix(current_time), cpu, period->max_cpu}); if (!period->alarm_command.empty()) { UString command; command.format(u"%s \"%s\" cpu %d", {period->alarm_command, message, cpu}); ForkPipe::Launch(command, _report, ForkPipe::STDERR_ONLY, ForkPipe::STDIN_NONE); } } // Raise an alarm if the virtual memory is not stable while it should be. if (period->stable_memory && metrics.vmem_size > last_metrics.vmem_size) { _report.warning(u"%sALARM, VM is not stable: %s in last monitoring interval", {MonPrefix(current_time), UString::HumanSize(ptrdiff_t(metrics.vmem_size) - ptrdiff_t(last_metrics.vmem_size), u"B", true)}); if (!period->alarm_command.empty()) { UString command; command.format(u"%s \"%s\" memory %d", {period->alarm_command, message, metrics.vmem_size}); ForkPipe::Launch(command, _report, ForkPipe::STDERR_ONLY, ForkPipe::STDIN_NONE); } } // Remember points when virtual memory increases. if (metrics.vmem_size > vsize_max) { vsize_max = metrics.vmem_size; vsize_uptime = current_time; } // Save current metrics for next interval. last_time = current_time; last_metrics = metrics; } _report.info(u"%sresource monitoring terminated", {MonPrefix(Time::CurrentLocalTime())}); } //---------------------------------------------------------------------------- // Laad the monitoring configuration file. //---------------------------------------------------------------------------- bool ts::SystemMonitor::loadConfigurationFile(const UString& config) { // Load the repository XML file. Search it in TSDuck directory if the default file is used. const bool use_default_config = config.empty(); xml::Document doc(_report); if (!doc.load(use_default_config ? u"tsduck.monitor.xml" : config, use_default_config)) { return false; } // Load the XML model. Search it in TSDuck directory. xml::ModelDocument model(_report); if (!model.load(u"tsduck.monitor.model.xml", true)) { _report.error(u"Model for TSDuck system monitoring XML files not found"); return false; } // Validate the input document according to the model. if (!model.validate(doc)) { return false; } // Get the root in the document. Should be ok since we validated the document. const xml::Element* root = doc.rootElement(); // Get one required <defaults> entry, one required <profile> and one or more <period> entries. xml::ElementVector defaults; xml::ElementVector profiles; xml::ElementVector periods; Config defconfig; bool ok = root->getChildren(defaults, u"defaults", 1, 1) && loadConfig(defconfig, defaults[0], nullptr) && root->getChildren(profiles, u"profile", 1, 1) && profiles[0]->getChildren(periods, u"period", 1); // Parse all <period> entries. for (auto it = periods.begin(); ok && it != periods.end(); ++it) { Period period; ok = (*it)->getIntAttribute(period.duration, u"duration", false, std::numeric_limits<MilliSecond>::max(), 1) && (*it)->getIntAttribute(period.interval, u"interval", true, 0, 1) && loadConfig(period, *it, &defconfig); // XML values are in seconds, we use milliseconds internally. period.duration *= MilliSecPerSec; period.interval *= MilliSecPerSec; _periods.push_back(period); } _report.debug(u"monitoring configuration loaded, %d periods", {_periods.size()}); return ok; } //---------------------------------------------------------------------------- // Laad one configuration entry. //---------------------------------------------------------------------------- bool ts::SystemMonitor::loadConfig(Config& config, const xml::Element* elem, const Config* defconfig) { // Without default config, all fields are required. const bool required = defconfig == nullptr; bool ok = elem->getIntAttribute(config.max_cpu, u"max_cpu", required, required ? 0 : defconfig->max_cpu, 0, 100) && elem->getBoolAttribute(config.stable_memory, u"stable_memory", required, required ? false : defconfig->stable_memory) && elem->getBoolAttribute(config.log_messages, u"log", required, required ? false : defconfig->log_messages) && elem->getTextChild(config.alarm_command, u"alarm", true, false, required ? UString() : defconfig->alarm_command); // Remove all newlines in the alarm command. config.alarm_command.remove(LINE_FEED); config.alarm_command.remove(CARRIAGE_RETURN); return ok; }
LDA 2200H MOV B,A ; place value of N in register B to use as counter LXI H,2500H ; set up HL to point to first byte MVI A,00 ; clear accumulator to store sum MVI C,00 ; clear register C to store carry LOOP: ADC M ; add the content of addess specified by HL pair to accumulator INX H ; increment HL to point to the address of next number JNC NEXT ; if carry not generated, skip to next iteration INR C ; increment the carry NEXT: DCR B ; one operation complete, decrement counter JNZ LOOP ; continue with the next iteration STA 2300H ; store lower byte of the sum MOV A,C ; transfer carry to accumulator STA 2301H ; store higher byte of the sum HLT ; stop
; A036044: BCR(n): write in binary, complement, reverse. ; 1,0,2,0,6,2,4,0,14,6,10,2,12,4,8,0,30,14,22,6,26,10,18,2,28,12,20,4,24,8,16,0,62,30,46,14,54,22,38,6,58,26,42,10,50,18,34,2,60,28,44,12,52,20,36,4,56,24,40,8,48,16,32,0,126,62,94,30,110,46,78,14,118,54,86,22,102,38,70,6,122,58,90,26,106,42,74,10,114,50,82,18,98,34,66,2,124,60,92,28 mov $1,2 mov $2,$0 lpb $2 sub $0,$1 div $2,2 sub $0,$2 mov $1,$2 sub $1,$0 lpe sub $1,1 mov $0,$1
#include <iostream> #include <fstream> #include <string> #include <new> #include <cstdio> #include <sstream> #include <cmath> using namespace std; int File_size(string name){ ifstream input( name ); int counter = 0; string str; while (std::getline(input, str)){ counter++; } return counter; } void find(int i,int q,int d,string bf,string inputtt,string que){ //d oi diastaseis pou exoume string token;string assist;string var; ostringstream oss; string delimiter = " "; int internal_counter = 0;int min_id;int id; int *use,i_dec,a; int counterQuery=0; int min=999999; float ManhSum=0.0; size_t pos = 0; size_t mpos = 0; std::ifstream input( inputtt ); std::ifstream query( que ); std::string str; std::string inp; use = new int[d]; ofstream BFfile(bf); if(BFfile.is_open()){ while (std::getline(query, str)){ internal_counter++; // cout << str << "\n"; while ((pos = str.find(delimiter)) != string::npos) { token = str.substr(0, pos); std::istringstream(token) >> i_dec; // cout << i_dec << " "; use[counterQuery]=i_dec; counterQuery++; str.erase(0, pos + delimiter.length()); } std::ifstream input( inputtt ); id = 1; while(std::getline(input,inp)){ //Tha anatrexoume kathe simeio tou input counterQuery=0; id++; while ((mpos = inp.find(delimiter)) != string::npos){ //Tha anatrexoume kathe syntetagmeni kathe simeiou assist = inp.substr(0, mpos); std::istringstream(assist) >> i_dec; if(counterQuery != 0){ ManhSum = ManhSum + std::abs(i_dec-use[counterQuery]); } //Ypologismos manhatan counterQuery++; inp.erase(0, mpos + delimiter.length()); } if(ManhSum < min){ min=ManhSum; min_id = id; } ManhSum=0.0; counterQuery=0; } cout << "The shortest for "<< internal_counter << " is : " << min << " from : " << min_id << endl ; // oss << "The shortest for "<< internal_counter << " is : " << min << " from : " << min_id << endl ; // var = oss.str(); var = to_string(internal_counter) + " " + to_string(min) + " " + to_string(min_id); BFfile<<var<< endl; var.clear(); min=999999.0; //Tha anatrexoume kathe simeio tou input metrontas tin apostasi counterQuery=0; } // BFfile<<var<< endl; BFfile.close(); }else{ cerr<<"Unable to open file"; } } int main(int argc,char *argv[]){ string ajax;int noa; string input_file;string query_file;string output_file; for (noa = 1; noa < argc; noa=noa+2) { ajax = argv[noa]; if(ajax.compare("-d") == 0){ input_file = argv[noa+1]; // cout << "Input " << input_file << endl; } else if(ajax.compare("-q") == 0){ query_file = argv[noa+1]; // cout << "Query " << query_file << endl; }else{//-o output_file = argv[noa+1]; } } int query_size = File_size(query_file); int input_size = File_size(input_file); find(query_size,input_size,128,output_file,input_file,query_file); return 0; }
; A175657: Eight bishops and one elephant on a 3 X 3 chessboard: a(n) = 3*2^n - 2*F(n+1), with F(n) = A000045(n). ; Submitted by Christian Krause ; 1,4,8,18,38,80,166,342,700,1426,2894,5856,11822,23822,47932,96330,193414,388048,778070,1559334,3123836,6256034,12525598,25073088,50181598,100420510,200933756,402017562,804277910,1608948656,3218532934,6438094326,12877852732,25758398002,51521152622,103049354400,206110114574,412238684078,824507228860,1649062773354,3298203723046,6596533938064,13193272544438,26386876249158,52774288326908,105549443642690,211100290102846,422202850012032,844409372647870,1688824687725886,3377658990505724 mov $3,1 lpb $0 sub $0,1 add $1,$3 mul $1,2 add $1,1 mov $2,$3 mov $3,$4 add $4,$2 lpe mov $0,$1 add $0,1
//============================================================================== // Copyright 2003 - 2011 LASMEA UMR 6602 CNRS/Univ. Clermont II // Copyright 2009 - 2011 LRI UMR 8623 CNRS/Univ Paris Sud XI // // Distributed under the Boost Software License, Version 1.0. // See accompanying file LICENSE.txt or copy at // http://www.boost.org/LICENSE_1_0.txt //============================================================================== #define NT2_UNIT_MODULE "boost::simd::complex properties" #include <nt2/sdk/complex/complex.hpp> #include <nt2/sdk/complex/imaginary.hpp> #include <nt2/sdk/complex/meta/as_complex.hpp> #include <nt2/sdk/complex/meta/as_imaginary.hpp> #include <nt2/sdk/complex/meta/as_real.hpp> #include <nt2/sdk/complex/meta/real_of.hpp> #include <nt2/sdk/meta/scalar_of.hpp> #include <boost/simd/sdk/simd/native.hpp> #include <nt2/sdk/unit/tests/basic.hpp> #include <nt2/sdk/unit/tests/type_expr.hpp> #include <nt2/sdk/unit/module.hpp> #include <iostream> NT2_TEST_CASE(properties) { using namespace nt2::meta; using nt2::imaginary; using std::complex; using boost::mpl::_; imaginary<double> im; NT2_TEST_EXPR_TYPE(im, scalar_of<_>, imaginary<double>); NT2_TEST_EXPR_TYPE(im, real_of<_>, double); NT2_TEST_EXPR_TYPE(im, as_real<_>, double); NT2_TEST_EXPR_TYPE(im, as_imaginary<_>, imaginary<double>); NT2_TEST_EXPR_TYPE(im, as_complex<_>, complex<double>); complex<double> c; NT2_TEST_EXPR_TYPE(c, scalar_of<_>, complex<double>); NT2_TEST_EXPR_TYPE(c, real_of<_>, double); NT2_TEST_EXPR_TYPE(c, as_real<_>, double); NT2_TEST_EXPR_TYPE(c, as_imaginary<_>, imaginary<double>); NT2_TEST_EXPR_TYPE(c, as_complex<_>, complex<double>); } NT2_TEST_CASE(properties_simd) { using namespace nt2::meta; using namespace boost::simd::meta; using nt2::imaginary; using std::complex; using boost::mpl::_; using boost::simd::native; typedef BOOST_SIMD_DEFAULT_EXTENSION ext_t; native<imaginary<double>, ext_t> im; NT2_TEST_EXPR_TYPE(im, scalar_of<_>, imaginary<double>); NT2_TEST_EXPR_TYPE(im, real_of<_>, double); NT2_TEST_EXPR_TYPE(im, as_real<_>, (native<double, ext_t>)); NT2_TEST_EXPR_TYPE(im, as_imaginary<_>, (native<imaginary<double>, ext_t>)); NT2_TEST_EXPR_TYPE(im, as_complex<_>, (native<complex<double>, ext_t>)); native<complex<double>, ext_t> c; NT2_TEST_EXPR_TYPE(c, scalar_of<_>, complex<double>); NT2_TEST_EXPR_TYPE(c, real_of<_>, double); NT2_TEST_EXPR_TYPE(c, as_real<_>, (native<double, ext_t>)); NT2_TEST_EXPR_TYPE(c, as_imaginary<_>, (native<imaginary<double>, ext_t>)); NT2_TEST_EXPR_TYPE(c, as_complex<_>, (native<complex<double>, ext_t>)); }
[BITS 32] section .text [GLOBAL gdt_flush] gdt_flush: mov eax, [esp + 4] lgdt [eax] mov ax, 0x10 mov ds, ax mov es, ax mov fs, ax mov gs, ax mov ss, ax jmp 0x08:.flush .flush: ret
data segment ;a DW 0H,1H,2H,3H,4H,5H,6H,7H,8H,9H,40 DUP(10H) ;a DW 11H,02H,15H,32H,05H,08H,07H,09H,10H,09H,12H,07H,25H,19H,99H,45H,18H,32H,16H,64H, 30 DUP(5) a DW 40 DUP(10H),9H,8H,7H,6H,5H,4H,3H,2H,1H, 0H ;a DW 9995H, 7D4FH, 0FF56H, 0AD55H, 4521H, 45 DUP(1234H) ;注,将需要排序的数视为有符号数! LT DW 0H RT DW 49 ends stack segment ST DW 1000 dup(0) TOP EQU 1000 ends code segment ASSUME DS:data, SS:stack, CS:code start: MOV AX, data MOV DS, AX MOV AX, stack MOV SS, AX MOV SP, TOP PUSH LT PUSH RT CALL quicksort MOV AX, 4C00H INT 21H quicksort proc near PUSH AX PUSH BX PUSH CX PUSH DX PUSH SI MOV SI, SP MOV BX, SS:[SI + 14] ; BX = L MOV AX, SS:[SI + 12] ; AX = R CMP AX, BX ;JBE P ; IF R - L <= 0 RETURN JLE P SHL BX, 1H ; BX = 2 * L MOV DX, DS:[BX] ; DX = S = ARR[L] SHL AX, 1H ; AX = 2 * R F0: CMP AX, BX ; AX = 2 * HIGH, BX = 2 * LOW JLE L_OUT ; IF HIGH > LOW MOV BP, AX MOV CX, DS:[BP] ; CX = ARR[HIGH] CMP CX, DX ; CMP ARR[HIGH], S ;JB F1 JL F1 SUB AX, 2 JMP F0 F1: CMP AX, BX ; CMP LOW, HIGH JLE L_OUT ; EXCHABGE ARR[LOW], ARR[HIGH] MOV DI, AX MOV CX, DS:[DI] MOV DS:[BX], CX, ADD BX, 2 F3: CMP AX, BX JLE L_OUT MOV CX, DS:[BX] ; CX = ARR[LOW] CMP CX, DX ; CMP ARR[HIGH], S ;JA F2 JG F2 ADD BX, 2 JMP F3 F2: CMP AX, BX JLE L_OUT MOV BP, BX MOV DI, AX MOV CX, DS:[BP] MOV DS:[DI], CX SUB AX, 2 JMP F0 ; IF HIGH <= LOW QUIT LOOP L_OUT: MOV DS:[BX], DX SHR AX, 1 ; AX = HIGH SHR BX, 1 ; BX = LOW PUSH SS:[SI + 14] ; PUSH L DEC BX ; BX = LOW - 1 PUSH BX CALL quicksort POP BX POP BX INC AX ; AX = HIGH + 1 PUSH AX PUSH SS:[SI + 12] CALL quicksort POP AX POP AX P: POP SI POP DX POP CX POP BX POP AX RET quicksort endp ends end start
// 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. // This shim interface to libhdfs (for runtime shared library loading) has been // adapted from the SFrame project, released under the ASF-compatible 3-clause // BSD license // // Using this required having the $JAVA_HOME and $HADOOP_HOME environment // variables set, so that libjvm and libhdfs can be located easily // Copyright (C) 2015 Dato, Inc. // All rights reserved. // // This software may be modified and distributed under the terms // of the BSD license. See the LICENSE file for details. #include "arrow/io/hdfs_internal.h" #include <cstdint> #include <cstdlib> #include <mutex> #include <sstream> // IWYU pragma: keep #include <string> #include <utility> #include <vector> #ifndef _WIN32 #include <dlfcn.h> #endif #include "arrow/result.h" #include "arrow/status.h" #include "arrow/util/io_util.h" #include "arrow/util/logging.h" namespace arrow { using internal::GetEnvVarNative; using internal::PlatformFilename; #ifdef _WIN32 using internal::WinErrorMessage; #endif namespace io { namespace internal { namespace { void* GetLibrarySymbol(LibraryHandle handle, const char* symbol) { if (handle == NULL) return NULL; #ifndef _WIN32 return dlsym(handle, symbol); #else void* ret = reinterpret_cast<void*>(GetProcAddress(handle, symbol)); if (ret == NULL) { // logstream(LOG_INFO) << "GetProcAddress error: " // << get_last_err_str(GetLastError()) << std::endl; } return ret; #endif } #define GET_SYMBOL_REQUIRED(SHIM, SYMBOL_NAME) \ do { \ if (!SHIM->SYMBOL_NAME) { \ *reinterpret_cast<void**>(&SHIM->SYMBOL_NAME) = \ GetLibrarySymbol(SHIM->handle, "" #SYMBOL_NAME); \ } \ if (!SHIM->SYMBOL_NAME) \ return Status::IOError("Getting symbol " #SYMBOL_NAME "failed"); \ } while (0) #define GET_SYMBOL(SHIM, SYMBOL_NAME) \ if (!SHIM->SYMBOL_NAME) { \ *reinterpret_cast<void**>(&SHIM->SYMBOL_NAME) = \ GetLibrarySymbol(SHIM->handle, "" #SYMBOL_NAME); \ } LibraryHandle libjvm_handle = nullptr; // Helper functions for dlopens Result<std::vector<PlatformFilename>> get_potential_libjvm_paths(); Result<std::vector<PlatformFilename>> get_potential_libhdfs_paths(); Result<std::vector<PlatformFilename>> get_potential_libhdfs3_paths(); Result<LibraryHandle> try_dlopen(const std::vector<PlatformFilename>& potential_paths, const char* name); Result<std::vector<PlatformFilename>> MakeFilenameVector( const std::vector<std::string>& names) { std::vector<PlatformFilename> filenames(names.size()); for (size_t i = 0; i < names.size(); ++i) { ARROW_ASSIGN_OR_RAISE(filenames[i], PlatformFilename::FromString(names[i])); } return filenames; } void AppendEnvVarFilename(const char* var_name, std::vector<PlatformFilename>* filenames) { auto maybe_env_var = GetEnvVarNative(var_name); if (maybe_env_var.ok()) { filenames->emplace_back(std::move(*maybe_env_var)); } } void AppendEnvVarFilename(const char* var_name, const char* suffix, std::vector<PlatformFilename>* filenames) { auto maybe_env_var = GetEnvVarNative(var_name); if (maybe_env_var.ok()) { auto maybe_env_var_with_suffix = PlatformFilename(std::move(*maybe_env_var)).Join(suffix); if (maybe_env_var_with_suffix.ok()) { filenames->emplace_back(std::move(*maybe_env_var_with_suffix)); } } } void InsertEnvVarFilename(const char* var_name, std::vector<PlatformFilename>* filenames) { auto maybe_env_var = GetEnvVarNative(var_name); if (maybe_env_var.ok()) { filenames->emplace(filenames->begin(), PlatformFilename(std::move(*maybe_env_var))); } } Result<std::vector<PlatformFilename>> get_potential_libhdfs_paths() { std::vector<PlatformFilename> potential_paths; std::string file_name; // OS-specific file name #ifdef _WIN32 file_name = "hdfs.dll"; #elif __APPLE__ file_name = "libhdfs.dylib"; #else file_name = "libhdfs.so"; #endif // Common paths ARROW_ASSIGN_OR_RAISE(auto search_paths, MakeFilenameVector({"", "."})); // Path from environment variable AppendEnvVarFilename("HADOOP_HOME", "lib/native", &search_paths); AppendEnvVarFilename("ARROW_LIBHDFS_DIR", &search_paths); // All paths with file name for (const auto& path : search_paths) { ARROW_ASSIGN_OR_RAISE(auto full_path, path.Join(file_name)); potential_paths.push_back(std::move(full_path)); } return potential_paths; } Result<std::vector<PlatformFilename>> get_potential_libhdfs3_paths() { std::vector<PlatformFilename> potential_paths; std::string file_name; // OS-specific file name #ifdef _WIN32 file_name = "hdfs3.dll"; #elif __APPLE__ file_name = "libhdfs3.dylib"; #else file_name = "libhdfs3.so"; #endif // Common paths ARROW_ASSIGN_OR_RAISE(auto search_paths, MakeFilenameVector({"", "."})); // Path from environment variable AppendEnvVarFilename("ARROW_LIBHDFS3_DIR", &search_paths); // All paths with file name for (auto& path : search_paths) { ARROW_ASSIGN_OR_RAISE(auto full_path, path.Join(file_name)); potential_paths.push_back(std::move(full_path)); } return potential_paths; } Result<std::vector<PlatformFilename>> get_potential_libjvm_paths() { std::vector<PlatformFilename> potential_paths; std::vector<PlatformFilename> search_prefixes; std::vector<PlatformFilename> search_suffixes; std::string file_name; // From heuristics #ifdef __WIN32 ARROW_ASSIGN_OR_RAISE(search_prefixes, MakeFilenameVector({""})); ARROW_ASSIGN_OR_RAISE(search_suffixes, MakeFilenameVector({"/jre/bin/server", "/bin/server"})); file_name = "jvm.dll"; #elif __APPLE__ ARROW_ASSIGN_OR_RAISE(search_prefixes, MakeFilenameVector({""})); ARROW_ASSIGN_OR_RAISE(search_suffixes, MakeFilenameVector({"/jre/lib/server", "/lib/server"})); file_name = "libjvm.dylib"; // SFrame uses /usr/libexec/java_home to find JAVA_HOME; for now we are // expecting users to set an environment variable #else ARROW_ASSIGN_OR_RAISE( search_prefixes, MakeFilenameVector({ "/usr/lib/jvm/default-java", // ubuntu / debian distros "/usr/lib/jvm/java", // rhel6 "/usr/lib/jvm", // centos6 "/usr/lib64/jvm", // opensuse 13 "/usr/local/lib/jvm/default-java", // alt ubuntu / debian distros "/usr/local/lib/jvm/java", // alt rhel6 "/usr/local/lib/jvm", // alt centos6 "/usr/local/lib64/jvm", // alt opensuse 13 "/usr/local/lib/jvm/java-8-openjdk-amd64", // alt ubuntu / debian distros "/usr/lib/jvm/java-8-openjdk-amd64", // alt ubuntu / debian distros "/usr/local/lib/jvm/java-7-openjdk-amd64", // alt ubuntu / debian distros "/usr/lib/jvm/java-7-openjdk-amd64", // alt ubuntu / debian distros "/usr/local/lib/jvm/java-6-openjdk-amd64", // alt ubuntu / debian distros "/usr/lib/jvm/java-6-openjdk-amd64", // alt ubuntu / debian distros "/usr/lib/jvm/java-7-oracle", // alt ubuntu "/usr/lib/jvm/java-8-oracle", // alt ubuntu "/usr/lib/jvm/java-6-oracle", // alt ubuntu "/usr/local/lib/jvm/java-7-oracle", // alt ubuntu "/usr/local/lib/jvm/java-8-oracle", // alt ubuntu "/usr/local/lib/jvm/java-6-oracle", // alt ubuntu "/usr/lib/jvm/default", // alt centos "/usr/java/latest", // alt centos })); ARROW_ASSIGN_OR_RAISE(search_suffixes, MakeFilenameVector({"", "/jre/lib/amd64/server", "/lib/amd64/server", "/lib/server"})); file_name = "libjvm.so"; #endif // From direct environment variable InsertEnvVarFilename("JAVA_HOME", &search_prefixes); // Generate cross product between search_prefixes, search_suffixes, and file_name for (auto& prefix : search_prefixes) { for (auto& suffix : search_suffixes) { ARROW_ASSIGN_OR_RAISE(auto path, prefix.Join(suffix).Join(file_name)); potential_paths.push_back(std::move(path)); } } return potential_paths; } #ifndef _WIN32 Result<LibraryHandle> try_dlopen(const std::vector<PlatformFilename>& potential_paths, const char* name) { std::string error_message = "unknown error"; LibraryHandle handle; for (const auto& p : potential_paths) { handle = dlopen(p.ToNative().c_str(), RTLD_NOW | RTLD_LOCAL); if (handle != NULL) { return handle; } else { const char* err_msg = dlerror(); if (err_msg != NULL) { error_message = err_msg; } } } return Status::IOError("Unable to load ", name, ": ", error_message); } #else Result<LibraryHandle> try_dlopen(const std::vector<PlatformFilename>& potential_paths, const char* name) { std::string error_message; LibraryHandle handle; for (const auto& p : potential_paths) { handle = LoadLibraryW(p.ToNative().c_str()); if (handle != NULL) { return handle; } else { error_message = WinErrorMessage(GetLastError()); } } return Status::IOError("Unable to load ", name, ": ", error_message); } #endif // _WIN32 LibHdfsShim libhdfs_shim; LibHdfsShim libhdfs3_shim; } // namespace Status LibHdfsShim::GetRequiredSymbols() { GET_SYMBOL_REQUIRED(this, hdfsNewBuilder); GET_SYMBOL_REQUIRED(this, hdfsBuilderSetNameNode); GET_SYMBOL_REQUIRED(this, hdfsBuilderSetNameNodePort); GET_SYMBOL_REQUIRED(this, hdfsBuilderSetUserName); GET_SYMBOL_REQUIRED(this, hdfsBuilderSetKerbTicketCachePath); GET_SYMBOL_REQUIRED(this, hdfsBuilderSetForceNewInstance); GET_SYMBOL_REQUIRED(this, hdfsBuilderConfSetStr); GET_SYMBOL_REQUIRED(this, hdfsBuilderConnect); GET_SYMBOL_REQUIRED(this, hdfsCreateDirectory); GET_SYMBOL_REQUIRED(this, hdfsDelete); GET_SYMBOL_REQUIRED(this, hdfsDisconnect); GET_SYMBOL_REQUIRED(this, hdfsExists); GET_SYMBOL_REQUIRED(this, hdfsFreeFileInfo); GET_SYMBOL_REQUIRED(this, hdfsGetCapacity); GET_SYMBOL_REQUIRED(this, hdfsGetUsed); GET_SYMBOL_REQUIRED(this, hdfsGetPathInfo); GET_SYMBOL_REQUIRED(this, hdfsListDirectory); GET_SYMBOL_REQUIRED(this, hdfsChown); GET_SYMBOL_REQUIRED(this, hdfsChmod); // File methods GET_SYMBOL_REQUIRED(this, hdfsCloseFile); GET_SYMBOL_REQUIRED(this, hdfsFlush); GET_SYMBOL_REQUIRED(this, hdfsOpenFile); GET_SYMBOL_REQUIRED(this, hdfsRead); GET_SYMBOL_REQUIRED(this, hdfsSeek); GET_SYMBOL_REQUIRED(this, hdfsTell); GET_SYMBOL_REQUIRED(this, hdfsWrite); return Status::OK(); } Status ConnectLibHdfs(LibHdfsShim** driver) { static std::mutex lock; std::lock_guard<std::mutex> guard(lock); LibHdfsShim* shim = &libhdfs_shim; static bool shim_attempted = false; if (!shim_attempted) { shim_attempted = true; shim->Initialize(); ARROW_ASSIGN_OR_RAISE(auto libjvm_potential_paths, get_potential_libjvm_paths()); ARROW_ASSIGN_OR_RAISE(libjvm_handle, try_dlopen(libjvm_potential_paths, "libjvm")); ARROW_ASSIGN_OR_RAISE(auto libhdfs_potential_paths, get_potential_libhdfs_paths()); ARROW_ASSIGN_OR_RAISE(shim->handle, try_dlopen(libhdfs_potential_paths, "libhdfs")); } else if (shim->handle == nullptr) { return Status::IOError("Prior attempt to load libhdfs failed"); } *driver = shim; return shim->GetRequiredSymbols(); } Status ConnectLibHdfs3(LibHdfsShim** driver) { static std::mutex lock; std::lock_guard<std::mutex> guard(lock); LibHdfsShim* shim = &libhdfs3_shim; static bool shim_attempted = false; if (!shim_attempted) { shim_attempted = true; shim->Initialize(); ARROW_ASSIGN_OR_RAISE(auto libhdfs3_potential_paths, get_potential_libhdfs3_paths()); ARROW_ASSIGN_OR_RAISE(shim->handle, try_dlopen(libhdfs3_potential_paths, "libhdfs3")); } else if (shim->handle == nullptr) { return Status::IOError("Prior attempt to load libhdfs3 failed"); } *driver = shim; return shim->GetRequiredSymbols(); } /////////////////////////////////////////////////////////////////////////// // HDFS thin wrapper methods hdfsBuilder* LibHdfsShim::NewBuilder(void) { return this->hdfsNewBuilder(); } void LibHdfsShim::BuilderSetNameNode(hdfsBuilder* bld, const char* nn) { this->hdfsBuilderSetNameNode(bld, nn); } void LibHdfsShim::BuilderSetNameNodePort(hdfsBuilder* bld, tPort port) { this->hdfsBuilderSetNameNodePort(bld, port); } void LibHdfsShim::BuilderSetUserName(hdfsBuilder* bld, const char* userName) { this->hdfsBuilderSetUserName(bld, userName); } void LibHdfsShim::BuilderSetKerbTicketCachePath(hdfsBuilder* bld, const char* kerbTicketCachePath) { this->hdfsBuilderSetKerbTicketCachePath(bld, kerbTicketCachePath); } void LibHdfsShim::BuilderSetForceNewInstance(hdfsBuilder* bld) { this->hdfsBuilderSetForceNewInstance(bld); } hdfsFS LibHdfsShim::BuilderConnect(hdfsBuilder* bld) { return this->hdfsBuilderConnect(bld); } int LibHdfsShim::BuilderConfSetStr(hdfsBuilder* bld, const char* key, const char* val) { return this->hdfsBuilderConfSetStr(bld, key, val); } int LibHdfsShim::Disconnect(hdfsFS fs) { return this->hdfsDisconnect(fs); } hdfsFile LibHdfsShim::OpenFile(hdfsFS fs, const char* path, int flags, int bufferSize, short replication, tSize blocksize) { // NOLINT return this->hdfsOpenFile(fs, path, flags, bufferSize, replication, blocksize); } int LibHdfsShim::CloseFile(hdfsFS fs, hdfsFile file) { return this->hdfsCloseFile(fs, file); } int LibHdfsShim::Exists(hdfsFS fs, const char* path) { return this->hdfsExists(fs, path); } int LibHdfsShim::Seek(hdfsFS fs, hdfsFile file, tOffset desiredPos) { return this->hdfsSeek(fs, file, desiredPos); } tOffset LibHdfsShim::Tell(hdfsFS fs, hdfsFile file) { return this->hdfsTell(fs, file); } tSize LibHdfsShim::Read(hdfsFS fs, hdfsFile file, void* buffer, tSize length) { return this->hdfsRead(fs, file, buffer, length); } bool LibHdfsShim::HasPread() { GET_SYMBOL(this, hdfsPread); return this->hdfsPread != nullptr; } tSize LibHdfsShim::Pread(hdfsFS fs, hdfsFile file, tOffset position, void* buffer, tSize length) { GET_SYMBOL(this, hdfsPread); DCHECK(this->hdfsPread); return this->hdfsPread(fs, file, position, buffer, length); } tSize LibHdfsShim::Write(hdfsFS fs, hdfsFile file, const void* buffer, tSize length) { return this->hdfsWrite(fs, file, buffer, length); } int LibHdfsShim::Flush(hdfsFS fs, hdfsFile file) { return this->hdfsFlush(fs, file); } int LibHdfsShim::Available(hdfsFS fs, hdfsFile file) { GET_SYMBOL(this, hdfsAvailable); if (this->hdfsAvailable) return this->hdfsAvailable(fs, file); else return 0; } int LibHdfsShim::Copy(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst) { GET_SYMBOL(this, hdfsCopy); if (this->hdfsCopy) return this->hdfsCopy(srcFS, src, dstFS, dst); else return 0; } int LibHdfsShim::Move(hdfsFS srcFS, const char* src, hdfsFS dstFS, const char* dst) { GET_SYMBOL(this, hdfsMove); if (this->hdfsMove) return this->hdfsMove(srcFS, src, dstFS, dst); else return 0; } int LibHdfsShim::Delete(hdfsFS fs, const char* path, int recursive) { return this->hdfsDelete(fs, path, recursive); } int LibHdfsShim::Rename(hdfsFS fs, const char* oldPath, const char* newPath) { GET_SYMBOL(this, hdfsRename); if (this->hdfsRename) return this->hdfsRename(fs, oldPath, newPath); else return 0; } char* LibHdfsShim::GetWorkingDirectory(hdfsFS fs, char* buffer, size_t bufferSize) { GET_SYMBOL(this, hdfsGetWorkingDirectory); if (this->hdfsGetWorkingDirectory) { return this->hdfsGetWorkingDirectory(fs, buffer, bufferSize); } else { return NULL; } } int LibHdfsShim::SetWorkingDirectory(hdfsFS fs, const char* path) { GET_SYMBOL(this, hdfsSetWorkingDirectory); if (this->hdfsSetWorkingDirectory) { return this->hdfsSetWorkingDirectory(fs, path); } else { return 0; } } int LibHdfsShim::MakeDirectory(hdfsFS fs, const char* path) { return this->hdfsCreateDirectory(fs, path); } int LibHdfsShim::SetReplication(hdfsFS fs, const char* path, int16_t replication) { GET_SYMBOL(this, hdfsSetReplication); if (this->hdfsSetReplication) { return this->hdfsSetReplication(fs, path, replication); } else { return 0; } } hdfsFileInfo* LibHdfsShim::ListDirectory(hdfsFS fs, const char* path, int* numEntries) { return this->hdfsListDirectory(fs, path, numEntries); } hdfsFileInfo* LibHdfsShim::GetPathInfo(hdfsFS fs, const char* path) { return this->hdfsGetPathInfo(fs, path); } void LibHdfsShim::FreeFileInfo(hdfsFileInfo* hdfsFileInfo, int numEntries) { this->hdfsFreeFileInfo(hdfsFileInfo, numEntries); } char*** LibHdfsShim::GetHosts(hdfsFS fs, const char* path, tOffset start, tOffset length) { GET_SYMBOL(this, hdfsGetHosts); if (this->hdfsGetHosts) { return this->hdfsGetHosts(fs, path, start, length); } else { return NULL; } } void LibHdfsShim::FreeHosts(char*** blockHosts) { GET_SYMBOL(this, hdfsFreeHosts); if (this->hdfsFreeHosts) { this->hdfsFreeHosts(blockHosts); } } tOffset LibHdfsShim::GetDefaultBlockSize(hdfsFS fs) { GET_SYMBOL(this, hdfsGetDefaultBlockSize); if (this->hdfsGetDefaultBlockSize) { return this->hdfsGetDefaultBlockSize(fs); } else { return 0; } } tOffset LibHdfsShim::GetCapacity(hdfsFS fs) { return this->hdfsGetCapacity(fs); } tOffset LibHdfsShim::GetUsed(hdfsFS fs) { return this->hdfsGetUsed(fs); } int LibHdfsShim::Chown(hdfsFS fs, const char* path, const char* owner, const char* group) { return this->hdfsChown(fs, path, owner, group); } int LibHdfsShim::Chmod(hdfsFS fs, const char* path, short mode) { // NOLINT return this->hdfsChmod(fs, path, mode); } int LibHdfsShim::Utime(hdfsFS fs, const char* path, tTime mtime, tTime atime) { GET_SYMBOL(this, hdfsUtime); if (this->hdfsUtime) { return this->hdfsUtime(fs, path, mtime, atime); } else { return 0; } } } // namespace internal } // namespace io } // namespace arrow
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r14 push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0x17ed0, %rsi lea addresses_UC_ht+0x1c388, %rdi nop nop nop and $29567, %r14 mov $49, %rcx rep movsl nop nop add $30214, %rbx lea addresses_normal_ht+0x12d6e, %r14 nop nop nop cmp %r12, %r12 mov (%r14), %rbx nop nop nop nop nop add %rdi, %rdi lea addresses_normal_ht+0x14a38, %rbx nop nop nop sub %r13, %r13 mov (%rbx), %rsi nop nop nop nop xor %rdi, %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %r14 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r15 push %r9 push %rcx push %rdi // Store lea addresses_UC+0x11238, %r11 nop nop nop and %r15, %r15 movw $0x5152, (%r11) nop nop nop nop cmp $30951, %r10 // Store mov $0x6f8fd200000007b8, %r10 nop nop nop nop nop inc %rdi movl $0x51525354, (%r10) sub %r10, %r10 // Load lea addresses_normal+0x14a38, %rcx clflush (%rcx) nop nop nop nop and %r13, %r13 movups (%rcx), %xmm6 vpextrq $0, %xmm6, %rdi nop nop nop nop nop add %r10, %r10 // Faulty Load lea addresses_UC+0x11238, %rcx nop sub %r11, %r11 mov (%rcx), %r10 lea oracles, %r11 and $0xff, %r10 shlq $12, %r10 mov (%r11,%r10,1), %r10 pop %rdi pop %rcx pop %r9 pop %r15 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': True, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': True, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_UC'}} {'OP': 'STOR', 'dst': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_NC'}} {'src': {'congruent': 11, 'AVXalign': False, 'same': True, 'size': 16, 'NT': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 8, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 2, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 4, 'same': False, 'type': 'addresses_UC_ht'}} {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 10, 'AVXalign': False, 'same': False, 'size': 8, 'NT': True, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'} {'52': 21829} 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 */
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2018 The Worldcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. // NOTE: This file is intended to be customised by the end user, and includes only local node policy logic #include <policy/policy.h> #include <consensus/validation.h> #include <validation.h> #include <coins.h> #include <tinyformat.h> #include <util.h> #include <utilstrencodings.h> CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFeeIn) { // "Dust" is defined in terms of dustRelayFee, // which has units satoshis-per-kilobyte. // If you'd pay more in fees than the value of the output // to spend something, then we consider it dust. // A typical spendable non-segwit txout is 34 bytes big, and will // need a CTxIn of at least 148 bytes to spend: // so dust is a spendable txout less than // 182*dustRelayFee/1000 (in satoshis). // 546 satoshis at the default rate of 3000 sat/kB. // A typical spendable segwit txout is 31 bytes big, and will // need a CTxIn of at least 67 bytes to spend: // so dust is a spendable txout less than // 98*dustRelayFee/1000 (in satoshis). // 294 satoshis at the default rate of 3000 sat/kB. if (txout.scriptPubKey.IsUnspendable()) return 0; size_t nSize = GetSerializeSize(txout, SER_DISK, 0); int witnessversion = 0; std::vector<unsigned char> witnessprogram; if (txout.scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) { // sum the sizes of the parts of a transaction input // with 75% segwit discount applied to the script size. nSize += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4); } else { nSize += (32 + 4 + 1 + 107 + 4); // the 148 mentioned above } return dustRelayFeeIn.GetFee(nSize); } bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFeeIn) { return (txout.nValue < GetDustThreshold(txout, dustRelayFeeIn)); } bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) { std::vector<std::vector<unsigned char> > vSolutions; if (!Solver(scriptPubKey, whichType, vSolutions)) return false; if (whichType == TX_MULTISIG) { unsigned char m = vSolutions.front()[0]; unsigned char n = vSolutions.back()[0]; // Support up to x-of-3 multisig txns as standard if (n < 1 || n > 3) return false; if (m < 1 || m > n) return false; } else if (whichType == TX_NULL_DATA && (!fAcceptDatacarrier || scriptPubKey.size() > nMaxDatacarrierBytes)) return false; return whichType != TX_NONSTANDARD && whichType != TX_WITNESS_UNKNOWN; } bool IsStandardTx(const CTransaction& tx, std::string& reason) { if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) { reason = "version"; return false; } // Extremely large transactions with lots of inputs can cost the network // almost as much to process as they cost the sender in fees, because // computing signature hashes is O(ninputs*txsize). Limiting transactions // to MAX_STANDARD_TX_WEIGHT mitigates CPU exhaustion attacks. unsigned int sz = GetTransactionWeight(tx); if (sz > MAX_STANDARD_TX_WEIGHT) { reason = "tx-size"; return false; } for (const CTxIn& txin : tx.vin) { // Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed // keys (remember the 520 byte limit on redeemScript size). That works // out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 // bytes of scriptSig, which we round off to 1650 bytes for some minor // future-proofing. That's also enough to spend a 20-of-20 // CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not // considered standard. if (txin.scriptSig.size() > 1650) { reason = "scriptsig-size"; return false; } if (!txin.scriptSig.IsPushOnly()) { reason = "scriptsig-not-pushonly"; return false; } } unsigned int nDataOut = 0; txnouttype whichType; for (const CTxOut& txout : tx.vout) { if (!::IsStandard(txout.scriptPubKey, whichType)) { reason = "scriptpubkey"; return false; } if (whichType == TX_NULL_DATA) nDataOut++; else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { reason = "bare-multisig"; return false; } else if (IsDust(txout, ::dustRelayFee)) { reason = "dust"; return false; } } // only one OP_RETURN txout is permitted if (nDataOut > 1) { reason = "multi-op-return"; return false; } return true; } /** * Check transaction inputs to mitigate two * potential denial-of-service attacks: * * 1. scriptSigs with extra data stuffed into them, * not consumed by scriptPubKey (or P2SH script) * 2. P2SH scripts with a crazy number of expensive * CHECKSIG/CHECKMULTISIG operations * * Why bother? To avoid denial-of-service attacks; an attacker * can submit a standard HASH... OP_EQUAL transaction, * which will get accepted into blocks. The redemption * script can be anything; an attacker could use a very * expensive-to-check-upon-redemption script like: * DUP CHECKSIG DROP ... repeated 100 times... OP_1 */ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) { if (tx.IsCoinBase()) return true; // Coinbases don't use vin normally for (unsigned int i = 0; i < tx.vin.size(); i++) { const CTxOut& prev = mapInputs.AccessCoin(tx.vin[i].prevout).out; std::vector<std::vector<unsigned char> > vSolutions; txnouttype whichType; // get the scriptPubKey corresponding to this input: const CScript& prevScript = prev.scriptPubKey; if (!Solver(prevScript, whichType, vSolutions)) return false; if (whichType == TX_SCRIPTHASH) { std::vector<std::vector<unsigned char> > stack; // convert the scriptSig into a stack, so we can inspect the redeemScript if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE)) return false; if (stack.empty()) return false; CScript subscript(stack.back().begin(), stack.back().end()); if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) { return false; } } } return true; } bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) { if (tx.IsCoinBase()) return true; // Coinbases are skipped for (unsigned int i = 0; i < tx.vin.size(); i++) { // We don't care if witness for this input is empty, since it must not be bloated. // If the script is invalid without witness, it would be caught sooner or later during validation. if (tx.vin[i].scriptWitness.IsNull()) continue; const CTxOut &prev = mapInputs.AccessCoin(tx.vin[i].prevout).out; // get the scriptPubKey corresponding to this input: CScript prevScript = prev.scriptPubKey; if (prevScript.IsPayToScriptHash()) { std::vector <std::vector<unsigned char> > stack; // If the scriptPubKey is P2SH, we try to extract the redeemScript casually by converting the scriptSig // into a stack. We do not check IsPushOnly nor compare the hash as these will be done later anyway. // If the check fails at this stage, we know that this txid must be a bad one. if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), SigVersion::BASE)) return false; if (stack.empty()) return false; prevScript = CScript(stack.back().begin(), stack.back().end()); } int witnessversion = 0; std::vector<unsigned char> witnessprogram; // Non-witness program must not be associated with any witness if (!prevScript.IsWitnessProgram(witnessversion, witnessprogram)) return false; // Check P2WSH standard limits if (witnessversion == 0 && witnessprogram.size() == WITNESS_V0_SCRIPTHASH_SIZE) { if (tx.vin[i].scriptWitness.stack.back().size() > MAX_STANDARD_P2WSH_SCRIPT_SIZE) return false; size_t sizeWitnessStack = tx.vin[i].scriptWitness.stack.size() - 1; if (sizeWitnessStack > MAX_STANDARD_P2WSH_STACK_ITEMS) return false; for (unsigned int j = 0; j < sizeWitnessStack; j++) { if (tx.vin[i].scriptWitness.stack[j].size() > MAX_STANDARD_P2WSH_STACK_ITEM_SIZE) return false; } } } return true; } CFeeRate incrementalRelayFee = CFeeRate(DEFAULT_INCREMENTAL_RELAY_FEE); CFeeRate dustRelayFee = CFeeRate(DUST_RELAY_TX_FEE); unsigned int nBytesPerSigOp = DEFAULT_BYTES_PER_SIGOP; int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost) { return (std::max(nWeight, nSigOpCost * nBytesPerSigOp) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR; } int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost) { return GetVirtualTransactionSize(GetTransactionWeight(tx), nSigOpCost); } int64_t GetVirtualTransactionInputSize(const CTxIn& txin, int64_t nSigOpCost) { return GetVirtualTransactionSize(GetTransactionInputWeight(txin), nSigOpCost); }
; A192460: Constant term of the reduction by x^2->x+1 of the polynomial p(n,x) defined below in Comments. ; Submitted by Jamie Morken(w1) ; 0,2,13,123,1487,21871,378942,7557722,170519635,4293742365,119359055585,3630473717035,119930672906880,4275825418586810,163638018718726915,6690920298998362845,291099044600505086165,13426830426820884360265 mov $1,$0 mov $2,1 lpb $0 sub $0,1 add $3,$2 mov $4,$3 mul $3,$1 add $3,$2 add $2,$4 mul $2,$1 sub $1,1 add $2,$4 lpe mov $0,$3
# $s0 -> i, $s1 -> j # $a0 -> v[], $a1 -> n sort: # Save n ($a1) and $ra with stack addi $sp, $sp, -16 sw $ra, 12($sp) sw $a1, 8($sp) sw $s0, 4($sp) sw $s1, 0($sp) add $s0, $zero, $zero # i = 0 for_i: slt $t0, $s0, $a1 # Check i < n beq $t0, $zero, for_i_exit # If i >= n addi $s1, $s0, -1 # j = i - 1 for_j: slt $t1, $s1, 0 # Check j >= 0 bne $t1, $zero, for_j_exit # If j < 0 sll $t2, $s1, 2 # j * 4 add $t2, $t2, $a0 # &v[j] lw $t3, 0($t2) # v[j] lw $t4, 4($t2) # v[j + 1] slt $t1, $t4, $t3 # Check v[j + 1] < v[j] beq $t1, $zero, for_j_exit # Call swap add $a1, $s1, $zero # Set j to argument jal swap addi $s1, $s1, -1 # j -= 1 j for_j for_j_exit: addi $s0, $s0, 1 # i += 1 j for_i for_i_exit: lw $s1, 0($sp) lw $s0, 4($sp) lw $a1, 8($sp) lw $ra, 12($sp) addi $sp, $sp, 20 jr $ra # $a0 -> v[], $a1 -> k swap: sll $t1, $a1, 2 # k * 4 add $t1, $t1, $a0 # &v[k] lw $t0, 0($t1) # v[k] lw $t2, 4($t1) # v[k + 1] sw $t2, 0($t1) sw $t0, 4($t1) jr $ra
SECTION code_fp_math48 PUBLIC asm_log2 EXTERN am48_log2 defc asm_log2 = am48_log2
<% from pwnlib.shellcraft import i386 %> <%page args="gid='egid'"/> <%docstring> Args: [gid (imm/reg) = egid] Sets the real and effective group id. </%docstring> % if gid == 'egid': /* getegid */ ${i386.linux.syscall('SYS_getegid')} ${i386.mov('ebx', 'eax')} % else: ${i386.mov('ebx', gid)} % endif /* setregid(eax, eax) */ ${i386.linux.syscall('SYS_setregid', 'ebx', 'ebx')}
; section .text ; global sum_to_n, loop, done ; sum_to_n: ; ; rdi = n ; xor rax, rax ; total = 0 ; xor rsi, rsi ; i = 0 (where do I save local vars)? ; cmp rsi, rdi ; i > n ? ; jg done ; loop: ; add rax, rsi ; total = total + i; ; inc rsi ; i++ ; cmp rsi, rdi ; i <= n ? ; jle loop ; done: ; ret section .text global sum_to_n sum_to_n: ; rdi = n mov rax, rdi inc rax imul rdi sar rax, 1 ret
; A156331: a(n)=8*A154811(n). ; 8,16,40,32,56,64,64,56,32,40,16,8,8,16,40,32,56,64,64,56,32,40,16,8,8,16,40,32,56,64,64,56,32,40,16,8,8,16,40,32,56,64,64,56,32,40,16,8,8,16,40,32,56,64,64,56,32,40,16,8,8,16,40,32,56,64,64,56,32,40,16,8,8,16,40 mov $1,1 lpb $0 sub $0,1 add $2,$1 add $1,$2 mod $1,9 lpe sub $1,1 mul $1,8 add $1,8
#ifndef _UT_CSTL_AVL_TREE_PRIVATE_H_ #define _UT_CSTL_AVL_TREE_PRIVATE_H_ UT_SUIT_DECLARATION(cstl_avl_tree_private) UT_CASE_DECLARATION(_create_avl_tree_auxiliary) void test__create_avl_tree_auxiliary__null_avl_tree(void** state); void test__create_avl_tree_auxiliary__null_typename(void** state); void test__create_avl_tree_auxiliary__unregistered(void** state); void test__create_avl_tree_auxiliary__c_builtin(void** state); void test__create_avl_tree_auxiliary__cstr(void** state); void test__create_avl_tree_auxiliary__libcstl_builtin(void** state); void test__create_avl_tree_auxiliary__user_define(void** state); UT_CASE_DECLARATION(_avl_tree_destroy_auxiliary) void test__avl_tree_destroy_auxiliary__null_avl_tree(void** state); void test__avl_tree_destroy_auxiliary__non_created(void** state); void test__avl_tree_destroy_auxiliary__non_inited(void** state); void test__avl_tree_destroy_auxiliary__empty(void** state); void test__avl_tree_destroy_auxiliary__non_empty(void** state); #define UT_CSTL_AVL_TREE_PRIVATE_CASE\ UT_SUIT_BEGIN(cstl_avl_tree_private, test__create_avl_tree_auxiliary__null_avl_tree),\ UT_CASE(test__create_avl_tree_auxiliary__null_typename),\ UT_CASE(test__create_avl_tree_auxiliary__unregistered),\ UT_CASE(test__create_avl_tree_auxiliary__c_builtin),\ UT_CASE(test__create_avl_tree_auxiliary__cstr),\ UT_CASE(test__create_avl_tree_auxiliary__libcstl_builtin),\ UT_CASE(test__create_avl_tree_auxiliary__user_define),\ UT_CASE_BEGIN(_avl_tree_destroy_auxiliary, test__avl_tree_destroy_auxiliary__null_avl_tree),\ UT_CASE(test__avl_tree_destroy_auxiliary__non_created),\ UT_CASE(test__avl_tree_destroy_auxiliary__non_inited),\ UT_CASE(test__avl_tree_destroy_auxiliary__empty),\ UT_CASE(test__avl_tree_destroy_auxiliary__non_empty) #endif
#include "python_panel.hpp" #include "core_logging/logging.hpp" #include "core_reflection/reflected_object.hpp" #include "core_reflection/i_definition_manager.hpp" #include "core_reflection/reflection_macros.hpp" #include "core_reflection/metadata/meta_types.hpp" #include "core_reflection/function_property.hpp" #include "core_reflection/utilities/reflection_function_utilities.hpp" #include "core_reflection/property_accessor_listener.hpp" #include "core_logging/logging.hpp" #include "core_ui_framework/i_ui_framework.hpp" #include "core_ui_framework/i_ui_application.hpp" #include "core_ui_framework/interfaces/i_view_creator.hpp" namespace wgt { PythonPanel::PythonPanel(ManagedObjectPtr contextObject) : contextObject_(std::move(contextObject)) { this->addPanel(); } PythonPanel::~PythonPanel() { this->removePanel(); } bool PythonPanel::addPanel() { auto viewCreator = get<IViewCreator>(); if (viewCreator == nullptr) { NGT_ERROR_MSG("Failed to find IViewCreator\n"); return false; } pythonView_ = viewCreator->createView("Python27UITest/PythonObjectTestPanel.qml", contextObject_->getHandle()); return true; } void PythonPanel::removePanel() { auto uiApplication = get<IUIApplication>(); if (uiApplication == nullptr) { NGT_ERROR_MSG("Failed to find IUIApplication\n"); return; } if (pythonView_.valid()) { auto view = pythonView_.get(); uiApplication->removeView(*view); view = nullptr; } contextObject_ = nullptr; } } // end namespace wgt
; A027689: a(n) = n^2 + n + 4. ; 4,6,10,16,24,34,46,60,76,94,114,136,160,186,214,244,276,310,346,384,424,466,510,556,604,654,706,760,816,874,934,996,1060,1126,1194,1264,1336,1410,1486,1564,1644,1726,1810,1896,1984,2074,2166,2260,2356,2454,2554,2656,2760,2866,2974,3084,3196,3310,3426,3544,3664,3786,3910,4036,4164,4294,4426,4560,4696,4834,4974,5116,5260,5406,5554,5704,5856,6010,6166,6324,6484,6646,6810,6976,7144,7314,7486,7660,7836,8014,8194,8376,8560,8746,8934,9124,9316,9510,9706,9904 mov $1,$0 pow $0,2 add $0,$1 add $0,4