text
stringlengths
1
1.05M
/** * Copyright 2020-2021 Huawei Technologies Co., Ltd * * 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 "pybind11/pybind11.h" #include "minddata/dataset/api/python/pybind_conversion.h" #include "minddata/dataset/api/python/pybind_register.h" #include "minddata/dataset/callback/py_ds_callback.h" #include "minddata/dataset/include/dataset/constants.h" #include "minddata/dataset/engine/serdes.h" #include "minddata/dataset/text/sentence_piece_vocab.h" // IR non-leaf nodes #include "minddata/dataset/engine/ir/datasetops/batch_node.h" #include "minddata/dataset/engine/ir/datasetops/concat_node.h" #include "minddata/dataset/engine/ir/datasetops/dataset_node.h" #include "minddata/dataset/engine/ir/datasetops/filter_node.h" #include "minddata/dataset/engine/ir/datasetops/map_node.h" #include "minddata/dataset/engine/ir/datasetops/project_node.h" #include "minddata/dataset/engine/ir/datasetops/rename_node.h" #include "minddata/dataset/engine/ir/datasetops/repeat_node.h" #include "minddata/dataset/engine/ir/datasetops/shuffle_node.h" #include "minddata/dataset/engine/ir/datasetops/skip_node.h" #include "minddata/dataset/engine/ir/datasetops/take_node.h" #include "minddata/dataset/engine/ir/datasetops/transfer_node.h" #include "minddata/dataset/engine/ir/datasetops/zip_node.h" // IR non-leaf nodes - for android #ifndef ENABLE_ANDROID #include "minddata/dataset/engine/ir/datasetops/bucket_batch_by_length_node.h" #include "minddata/dataset/engine/ir/datasetops/build_vocab_node.h" #include "minddata/dataset/engine/ir/datasetops/build_sentence_piece_vocab_node.h" #include "minddata/dataset/engine/ir/datasetops/sync_wait_node.h" #endif #include "minddata/dataset/core/config_manager.h" #include "minddata/dataset/core/data_type.h" #include "minddata/dataset/util/path.h" namespace mindspore { namespace dataset { PYBIND_REGISTER(DatasetNode, 1, ([](const py::module *m) { (void)py::class_<DatasetNode, std::shared_ptr<DatasetNode>>(*m, "Dataset") .def("set_num_workers", [](std::shared_ptr<DatasetNode> self, std::optional<int32_t> num_workers) { return num_workers ? self->SetNumWorkers(*num_workers) : self; }) .def("set_cache_client", [](std::shared_ptr<DatasetNode> self, std::shared_ptr<CacheClient> cc) { return self->SetDatasetCache(toDatasetCache(std::move(cc))); }) .def( "Zip", [](std::shared_ptr<DatasetNode> self, py::list datasets) { auto zip = std::make_shared<ZipNode>(std::move(toDatasetNode(self, datasets))); THROW_IF_ERROR(zip->ValidateParams()); return zip; }, py::arg("datasets")) .def("to_json", [](std::shared_ptr<DatasetNode> self, const std::string &json_filepath) { nlohmann::json args; THROW_IF_ERROR(Serdes::SaveToJSON(self, json_filepath, &args)); return args.dump(); }) .def_static("from_json_file", [](const std::string &json_filepath) { std::shared_ptr<DatasetNode> output; THROW_IF_ERROR(Serdes::Deserialize(json_filepath, &output)); return output; }) .def_static("from_json_string", [](const std::string &json_string) { std::shared_ptr<DatasetNode> output; nlohmann::json json_obj = nlohmann::json::parse(json_string); THROW_IF_ERROR(Serdes::ConstructPipeline(json_obj, &output)); return output; }); })); // PYBIND FOR NON-LEAF NODES // (In alphabetical order) PYBIND_REGISTER(BatchNode, 2, ([](const py::module *m) { (void)py::class_<BatchNode, DatasetNode, std::shared_ptr<BatchNode>>(*m, "BatchNode", "to create a BatchNode") .def(py::init([](std::shared_ptr<DatasetNode> self, int32_t batch_size, bool drop_remainder, bool pad, py::list in_col_names, py::list out_col_names, py::list col_order, py::object size_obj, py::object map_obj, py::dict pad_info) { std::map<std::string, std::pair<TensorShape, std::shared_ptr<Tensor>>> c_pad_info; if (pad) { THROW_IF_ERROR(toPadInfo(pad_info, &c_pad_info)); } py::function size_func = py::isinstance<py::function>(size_obj) ? size_obj.cast<py::function>() : py::function(); py::function map_func = py::isinstance<py::function>(map_obj) ? map_obj.cast<py::function>() : py::function(); auto batch = std::make_shared<BatchNode>( self, batch_size, drop_remainder, pad, toStringVector(in_col_names), toStringVector(out_col_names), toStringVector(col_order), size_func, map_func, c_pad_info); THROW_IF_ERROR(batch->ValidateParams()); return batch; })); })); PYBIND_REGISTER(BucketBatchByLengthNode, 2, ([](const py::module *m) { (void)py::class_<BucketBatchByLengthNode, DatasetNode, std::shared_ptr<BucketBatchByLengthNode>>( *m, "BucketBatchByLengthNode", "to create a BucketBatchByLengthNode") .def(py::init([](std::shared_ptr<DatasetNode> dataset, py::list column_names, std::vector<int32_t> bucket_boundaries, std::vector<int32_t> bucket_batch_sizes, py::object element_length_function, py::dict pad_info, bool pad_to_bucket_boundary, bool drop_remainder) { std::map<std::string, std::pair<TensorShape, std::shared_ptr<Tensor>>> c_pad_info; THROW_IF_ERROR(toPadInfo(pad_info, &c_pad_info)); auto bucket_batch = std::make_shared<BucketBatchByLengthNode>( dataset, toStringVector(column_names), bucket_boundaries, bucket_batch_sizes, toPyFuncOp(std::move(element_length_function), DataType::DE_INT32), c_pad_info, pad_to_bucket_boundary, drop_remainder); THROW_IF_ERROR(bucket_batch->ValidateParams()); return bucket_batch; }), py::arg("dataset"), py::arg("column_names"), py::arg("bucket_boundaries"), py::arg("bucket_batch_sizes"), py::arg("element_length_function") = py::none(), py::arg("pad_info"), py::arg("pad_to_bucket_boundary"), py::arg("drop_remainder")); })); PYBIND_REGISTER(BuildSentenceVocabNode, 2, ([](const py::module *m) { (void)py::class_<BuildSentenceVocabNode, DatasetNode, std::shared_ptr<BuildSentenceVocabNode>>( *m, "BuildSentenceVocabNode", "to create a BuildSentenceVocabNode") .def(py::init([](std::shared_ptr<DatasetNode> self, std::shared_ptr<SentencePieceVocab> vocab, const std::vector<std::string> &col_names, int32_t vocab_size, float character_coverage, SentencePieceModel model_type, const std::unordered_map<std::string, std::string> &params) { auto build_sentence_vocab = std::make_shared<BuildSentenceVocabNode>( self, vocab, col_names, vocab_size, character_coverage, model_type, params); THROW_IF_ERROR(build_sentence_vocab->ValidateParams()); return build_sentence_vocab; })); })); PYBIND_REGISTER(BuildVocabNode, 2, ([](const py::module *m) { (void)py::class_<BuildVocabNode, DatasetNode, std::shared_ptr<BuildVocabNode>>( *m, "BuildVocabNode", "to create a BuildVocabNode") .def(py::init([](std::shared_ptr<DatasetNode> self, std::shared_ptr<Vocab> vocab, py::list columns, py::tuple freq_range, int64_t top_k, py::list special_tokens, bool special_first) { auto build_vocab = std::make_shared<BuildVocabNode>(self, vocab, toStringVector(columns), toIntPair(freq_range), top_k, toStringVector(special_tokens), special_first); THROW_IF_ERROR(build_vocab->ValidateParams()); return build_vocab; })); })); PYBIND_REGISTER(ConcatNode, 2, ([](const py::module *m) { (void)py::class_<ConcatNode, DatasetNode, std::shared_ptr<ConcatNode>>(*m, "ConcatNode", "to create a ConcatNode") .def(py::init([](std::vector<std::shared_ptr<DatasetNode>> datasets, py::handle sampler, py::list children_flag_and_nums, py::list children_start_end_index) { auto concat = std::make_shared<ConcatNode>(datasets, toSamplerObj(sampler), toPairVector(children_flag_and_nums), toPairVector(children_start_end_index)); THROW_IF_ERROR(concat->ValidateParams()); return concat; })); })); PYBIND_REGISTER(FilterNode, 2, ([](const py::module *m) { (void)py::class_<FilterNode, DatasetNode, std::shared_ptr<FilterNode>>(*m, "FilterNode", "to create a FilterNode") .def(py::init([](std::shared_ptr<DatasetNode> self, py::object predicate, std::vector<std::string> input_columns) { auto filter = std::make_shared<FilterNode>(self, toPyFuncOp(predicate, DataType::DE_BOOL), input_columns); THROW_IF_ERROR(filter->ValidateParams()); return filter; })); })); PYBIND_REGISTER(MapNode, 2, ([](const py::module *m) { (void)py::class_<MapNode, DatasetNode, std::shared_ptr<MapNode>>(*m, "MapNode", "to create a MapNode") .def(py::init([](std::shared_ptr<DatasetNode> self, py::list operations, py::list input_columns, py::list output_columns, py::list project_columns, std::vector<std::shared_ptr<PyDSCallback>> py_callbacks, int64_t max_rowsize, const ManualOffloadMode offload) { auto map = std::make_shared<MapNode>( self, std::move(toTensorOperations(operations)), toStringVector(input_columns), toStringVector(output_columns), toStringVector(project_columns), nullptr, std::vector<std::shared_ptr<DSCallback>>(py_callbacks.begin(), py_callbacks.end()), offload); THROW_IF_ERROR(map->ValidateParams()); return map; })); })); PYBIND_REGISTER(ProjectNode, 2, ([](const py::module *m) { (void)py::class_<ProjectNode, DatasetNode, std::shared_ptr<ProjectNode>>(*m, "ProjectNode", "to create a ProjectNode") .def(py::init([](std::shared_ptr<DatasetNode> self, py::list columns) { auto project = std::make_shared<ProjectNode>(self, toStringVector(columns)); THROW_IF_ERROR(project->ValidateParams()); return project; })); })); PYBIND_REGISTER( RenameNode, 2, ([](const py::module *m) { (void)py::class_<RenameNode, DatasetNode, std::shared_ptr<RenameNode>>(*m, "RenameNode", "to create a RenameNode") .def(py::init([](std::shared_ptr<DatasetNode> self, py::list input_columns, py::list output_columns) { auto rename = std::make_shared<RenameNode>(self, toStringVector(input_columns), toStringVector(output_columns)); THROW_IF_ERROR(rename->ValidateParams()); return rename; })); })); PYBIND_REGISTER(RepeatNode, 2, ([](const py::module *m) { (void)py::class_<RepeatNode, DatasetNode, std::shared_ptr<RepeatNode>>(*m, "RepeatNode", "to create a RepeatNode") .def(py::init([](std::shared_ptr<DatasetNode> input, int32_t count) { auto repeat = std::make_shared<RepeatNode>(input, count); THROW_IF_ERROR(repeat->ValidateParams()); return repeat; })); })); PYBIND_REGISTER(ShuffleNode, 2, ([](const py::module *m) { (void)py::class_<ShuffleNode, DatasetNode, std::shared_ptr<ShuffleNode>>(*m, "ShuffleNode", "to create a ShuffleNode") .def(py::init([](std::shared_ptr<DatasetNode> self, int32_t shuffle_size, bool reset_every_epoch) { auto shuffle = std::make_shared<ShuffleNode>(self, shuffle_size, reset_every_epoch); THROW_IF_ERROR(shuffle->ValidateParams()); return shuffle; })); })); PYBIND_REGISTER(SkipNode, 2, ([](const py::module *m) { (void)py::class_<SkipNode, DatasetNode, std::shared_ptr<SkipNode>>(*m, "SkipNode", "to create a SkipNode") .def(py::init([](std::shared_ptr<DatasetNode> self, int32_t count) { auto skip = std::make_shared<SkipNode>(self, count); THROW_IF_ERROR(skip->ValidateParams()); return skip; })); })); PYBIND_REGISTER(SyncWaitNode, 2, ([](const py::module *m) { (void)py::class_<SyncWaitNode, DatasetNode, std::shared_ptr<SyncWaitNode>>(*m, "SyncWaitNode", "to create a SyncWaitNode") .def( py::init([](std::shared_ptr<DatasetNode> self, std::string condition_name, py::object callback) { py::function callback_func = py::isinstance<py::function>(callback) ? callback.cast<py::function>() : py::function(); auto sync_wait = std::make_shared<SyncWaitNode>(self, condition_name, callback); THROW_IF_ERROR(sync_wait->ValidateParams()); return sync_wait; })); })); PYBIND_REGISTER(TakeNode, 2, ([](const py::module *m) { (void)py::class_<TakeNode, DatasetNode, std::shared_ptr<TakeNode>>(*m, "TakeNode", "to create a TakeNode") .def(py::init([](std::shared_ptr<DatasetNode> self, int32_t count) { auto take = std::make_shared<TakeNode>(self, count); THROW_IF_ERROR(take->ValidateParams()); return take; })); })); PYBIND_REGISTER(TransferNode, 2, ([](const py::module *m) { (void)py::class_<TransferNode, DatasetNode, std::shared_ptr<TransferNode>>(*m, "TransferNode", "to create a TransferNode") .def(py::init([](std::shared_ptr<DatasetNode> self, std::string queue_name, std::string device_type, int32_t device_id, bool send_epoch_end, int32_t total_batch, bool create_data_info_queue) { auto transfer = std::make_shared<TransferNode>( self, queue_name, device_type, device_id, send_epoch_end, total_batch, create_data_info_queue); THROW_IF_ERROR(transfer->ValidateParams()); return transfer; })); })); PYBIND_REGISTER(ZipNode, 2, ([](const py::module *m) { (void)py::class_<ZipNode, DatasetNode, std::shared_ptr<ZipNode>>(*m, "ZipNode", "to create a ZipNode") .def(py::init([](std::vector<std::shared_ptr<DatasetNode>> datasets) { auto zip = std::make_shared<ZipNode>(datasets); THROW_IF_ERROR(zip->ValidateParams()); return zip; })); })); // OTHER PYBIND // (alphabetical order) PYBIND_REGISTER(ManualOffloadMode, 0, ([](const py::module *m) { (void)py::enum_<ManualOffloadMode>(*m, "ManualOffloadMode", py::arithmetic()) .value("UNSPECIFIED", ManualOffloadMode::kUnspecified) .value("DISABLED", ManualOffloadMode::kDisabled) .value("ENABLED", ManualOffloadMode::kEnabled) .export_values(); })); } // namespace dataset } // namespace mindspore
#include <iostream> #include "AdjacencyMapGraph.h" #include "adjacency_map_graph_factory.h" #include "kruskal_mst_compressed.h" #include "sum_weights.h" int main() noexcept { typedef size_t Label; // nodes are identified by size_t type typedef long Weight; // weights are of type long AdjacencyMapGraph<Label, Weight> adj_map_graph(adjacency_map_graph_factory<Label, Weight>()); // compute Minimum Spanning Tree with Kruskal algorithm using compressed Disjoint-Set data // structure const auto& mst = kruskal_mst_compressed(std::move(adj_map_graph)); // total weight of the mst found by Kruskal's algorithm const auto total_weight = sum_weights<Label, Weight>(mst.cbegin(), mst.cend()); // use std::fixed to avoid displaying numbers in scientific notation std::cout << std::fixed << total_weight << std::endl; }
#include "windowSys.h" #include "inputSys.h" #include "objects.h" #include "program.h" #include <filesystem> namespace fs = std::filesystem; // FONT FontSet::FontSet(const char* name) { TTF_Font* tmp = nullptr; #ifdef _WIN32 for (const fs::path& drc : {fs::path(L"."), fs::path(_wgetenv(L"SystemDrive")) / L"\\Windows\\Fonts"}) { #else for (const fs::path& drc : {fs::u8path("."), fs::u8path(getenv("HOME")) / ".fonts", fs::u8path("/usr/share/fonts")}) { #endif try { for (const fs::directory_entry& it : fs::recursive_directory_iterator(drc, fs::directory_options::follow_directory_symlink | fs::directory_options::skip_permission_denied)) if (!SDL_strcasecmp(it.path().stem().u8string().c_str(), name)) { string path = it.path().u8string(); if (tmp = TTF_OpenFont(path.c_str(), fontTestHeight); tmp) { file = path; break; } } } catch (...) {} } if (!tmp) throw std::runtime_error("Couldn't find font"); int size; heightScale = !TTF_SizeUTF8(tmp, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()_+-=[]{}'\\\"|;:,.<>/?", nullptr, &size) ? float(fontTestHeight) / float(size) : 1.f; TTF_CloseFont(tmp); } FontSet::~FontSet() { Clear(); } void FontSet::Clear() { for (auto [size, font] : fonts) TTF_CloseFont(font); fonts.clear(); } TTF_Font* FontSet::Get(int size) { size = int(float(size) * heightScale); return fonts.count(size) ? fonts.at(size) : AddSize(size); } TTF_Font* FontSet::AddSize(int size) { TTF_Font* font = TTF_OpenFont(file.c_str(), size); if (!font) throw std::runtime_error(TTF_GetError()); return fonts.insert(pair(size, font)).first->second; } SDL_Point FontSet::TextSize(const string& text, int size) { SDL_Point siz{}; if (TTF_Font* font = Get(size)) TTF_SizeUTF8(font, text.c_str(), &siz.x, &siz.y); return siz; } // WINDOW SYS WindowSys::WindowSys() = default; // needs to be here to make unique pointers happy WindowSys::~WindowSys() = default; // ^ int WindowSys::Start() { inputSys = nullptr; fonts = nullptr; window = nullptr; renderer = nullptr; int retval = EXIT_SUCCESS; try { Run(); } catch (const std::runtime_error& exc) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", exc.what(), window); retval = EXIT_FAILURE; } catch (...) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", "unknown error", window); retval = EXIT_FAILURE; } for (Object* it : objects) delete it; delete inputSys; delete fonts; SDL_DestroyRenderer(renderer); SDL_DestroyWindow(window); renderer = nullptr; window = nullptr; TTF_Quit(); SDL_Quit(); return retval; } void WindowSys::Run() { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC)) throw std::runtime_error(SDL_GetError()); if (TTF_Init()) throw std::runtime_error(TTF_GetError()); SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); SDL_EventState(SDL_FINGERMOTION, SDL_DISABLE); SDL_EventState(SDL_TEXTEDITING, SDL_DISABLE); SDL_EventState(SDL_KEYMAPCHANGED, SDL_DISABLE); SDL_EventState(SDL_JOYBALLMOTION, SDL_DISABLE); SDL_EventState(SDL_CONTROLLERDEVICEADDED, SDL_DISABLE); SDL_EventState(SDL_CONTROLLERDEVICEREMOVED, SDL_DISABLE); SDL_EventState(SDL_CONTROLLERDEVICEREMAPPED, SDL_DISABLE); SDL_EventState(SDL_DOLLARGESTURE, SDL_DISABLE); SDL_EventState(SDL_DOLLARRECORD, SDL_DISABLE); SDL_EventState(SDL_MULTIGESTURE, SDL_DISABLE); SDL_EventState(SDL_CLIPBOARDUPDATE, SDL_DISABLE); SDL_EventState(SDL_DROPFILE, SDL_DISABLE); SDL_EventState(SDL_DROPTEXT, SDL_DISABLE); SDL_EventState(SDL_DROPBEGIN, SDL_DISABLE); SDL_EventState(SDL_DROPCOMPLETE, SDL_DISABLE); SDL_EventState(SDL_AUDIODEVICEADDED, SDL_DISABLE); SDL_EventState(SDL_AUDIODEVICEREMOVED, SDL_DISABLE); SDL_EventState(SDL_RENDER_TARGETS_RESET, SDL_DISABLE); SDL_EventState(SDL_RENDER_DEVICE_RESET, SDL_DISABLE); if (window = SDL_CreateWindow("Controller Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_RESIZABLE); !window) throw std::runtime_error(SDL_GetError()); if (renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); !renderer) throw std::runtime_error(SDL_GetError()); SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); SDL_SetWindowMinimumSize(window, 200, 200); fonts = new FontSet; inputSys = new InputSys(this); run = true; inputSys->Prog()->EventControllersChanged(true); for (uint32_t oldTime = SDL_GetTicks(); run;) { uint32_t newTime = SDL_GetTicks(); uint32_t dMsec = newTime - oldTime; oldTime = newTime; SDL_SetRenderDrawColor(renderer, Object::colorBackground.r, Object::colorBackground.g, Object::colorBackground.b, Object::colorBackground.a); SDL_RenderClear(renderer); for (Object* obj : objects) obj->Draw(); SDL_RenderPresent(renderer); inputSys->Tick(dMsec); SDL_Event event; uint32_t timeout = SDL_GetTicks() + eventTimeout; do { if (!SDL_PollEvent(&event)) break; HandleEvent(event); } while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)); } } void WindowSys::HandleEvent(const SDL_Event& event) { switch (event.type) { case SDL_QUIT: Close(); break; case SDL_WINDOWEVENT: WindowEvent(event.window); break; case SDL_KEYDOWN: inputSys->KeypressEvent(event.key); break; case SDL_TEXTINPUT: inputSys->TextEvent(event.text); break; case SDL_MOUSEMOTION: inputSys->MouseMotionEvent(event.motion, objects); break; case SDL_MOUSEBUTTONDOWN: inputSys->MouseButtonDownEvent(event.button); break; case SDL_MOUSEBUTTONUP: inputSys->MouseButtonUpEvent(event.button, objects); break; case SDL_MOUSEWHEEL: inputSys->MouseWheelEvent(event.wheel); break; case SDL_JOYAXISMOTION: inputSys->Prog()->EventJoystickAxis(event.jaxis.which); break; case SDL_JOYHATMOTION: inputSys->Prog()->EventJoystickHat(event.jhat.which); break; case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: inputSys->Prog()->EventJoystickButton(event.jbutton.which); break; case SDL_JOYDEVICEADDED: inputSys->AddController(event.jdevice.which); break; case SDL_JOYDEVICEREMOVED: inputSys->DelController(event.jdevice.which); break; case SDL_CONTROLLERAXISMOTION: inputSys->Prog()->EventGamepadAxis(event.caxis.which); break; case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP: inputSys->Prog()->EventGamepadButton(event.cbutton.which); } } void WindowSys::WindowEvent(const SDL_WindowEvent& wevent) { switch (wevent.event) { case SDL_WINDOWEVENT_EXPOSED: inputSys->SimulateMouseMove(objects); break; case SDL_WINDOWEVENT_SIZE_CHANGED: for (Object* obj : objects) obj->OnResize(); } } void WindowSys::SwitchMenu(vector<Object*>&& objs) { for (Object* it : objects) delete it; objects = std::move(objs); inputSys->PostMenuSwitch(objects); } SDL_Texture* WindowSys::RenderText(const string& str, int height) { if (SDL_Surface* img = TTF_RenderUTF8_Blended(fonts->Get(height), str.c_str(), Object::colorText)) { SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, img); SDL_FreeSurface(img); return tex; } return nullptr; } SDL_Point WindowSys::Resolution() const { SDL_Point res; SDL_GetWindowSize(window, &res.x, &res.y); return res; } void WindowSys::DrawRect(const SDL_Rect& rect, SDL_Color color) { SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, color.a); SDL_RenderFillRect(renderer, &rect); } void WindowSys::DrawText(SDL_Texture* tex, SDL_Point pos, const SDL_Rect& frame) { if (!tex) return; int w, h; SDL_QueryTexture(tex, nullptr, nullptr, &w, &h); SDL_Rect dst = {pos.x, pos.y, w, h}; SDL_Rect crop = CropRect(dst, frame); SDL_Rect src = {crop.x, crop.y, w - crop.w, h - crop.h}; SDL_RenderCopy(renderer, tex, &src, &dst); } SDL_Rect WindowSys::CropRect(SDL_Rect& rect, const SDL_Rect& frame) { SDL_Rect isct; if (!SDL_IntersectRect(&rect, &frame, &isct)) return rect = {}; SDL_Point te = {rect.x + rect.w, rect.y + rect.h}, ie = {isct.x + isct.w, isct.y + isct.h}; SDL_Rect crop; crop.x = isct.x > rect.x ? isct.x - rect.x : 0; crop.y = isct.y > rect.y ? isct.y - rect.y : 0; crop.w = ie.x < te.x ? te.x - ie.x + crop.x : 0; crop.h = ie.y < te.y ? te.y - ie.y + crop.y : 0; rect = isct; return crop; } void WindowSys::Close() { run = false; } InputSys* WindowSys::Input() { return inputSys; } FontSet* WindowSys::Fonts() { return fonts; }
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r8 push %r9 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x11764, %rcx nop cmp %rdx, %rdx movw $0x6162, (%rcx) nop nop and %rdi, %rdi lea addresses_A_ht+0x1c1c4, %r8 nop nop nop cmp $25756, %r14 movw $0x6162, (%r8) nop xor $62045, %rdi lea addresses_D_ht+0x1016c, %r9 nop nop nop nop nop sub $56339, %rbx mov $0x6162636465666768, %rcx movq %rcx, %xmm0 movups %xmm0, (%r9) add %rbx, %rbx lea addresses_UC_ht+0x343c, %rsi lea addresses_UC_ht+0x15fe0, %rdi nop nop nop and %r9, %r9 mov $22, %rcx rep movsb nop nop nop and $21961, %rdi lea addresses_normal_ht+0x190c4, %r14 clflush (%r14) nop nop xor $53033, %rcx mov $0x6162636465666768, %rbx movq %rbx, %xmm7 vmovups %ymm7, (%r14) nop nop nop add $49528, %rdi lea addresses_normal_ht+0x15edc, %rcx sub %rdx, %rdx movb $0x61, (%rcx) nop nop xor %rdx, %rdx lea addresses_A_ht+0x2dc4, %rsi lea addresses_A_ht+0x13ec4, %rdi nop nop nop cmp $54949, %r9 mov $3, %rcx rep movsb nop nop and $6272, %rdx lea addresses_WC_ht+0xd3c4, %rdi nop nop add $15939, %rdx mov $0x6162636465666768, %r14 movq %r14, %xmm1 vmovups %ymm1, (%rdi) nop add %rdx, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r9 pop %r8 pop %r14 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r8 push %r9 push %rax push %rcx push %rdi // Store lea addresses_WT+0x1efc4, %r12 nop nop nop nop add $23652, %r9 mov $0x5152535455565758, %rdi movq %rdi, %xmm0 movups %xmm0, (%r12) nop nop nop nop nop add %rax, %rax // Store lea addresses_UC+0x108c4, %r13 nop nop nop nop xor $20709, %rcx movb $0x51, (%r13) xor $26906, %r12 // Store lea addresses_normal+0xecc4, %rax nop nop nop xor $6706, %rdi mov $0x5152535455565758, %rcx movq %rcx, (%rax) nop nop nop and $56543, %r13 // Load lea addresses_UC+0xcc4, %r8 nop nop nop xor %rdi, %rdi mov (%r8), %ecx nop nop cmp $23194, %r9 // Faulty Load lea addresses_A+0x140c4, %r13 nop nop nop nop xor %r12, %r12 mov (%r13), %r9 lea oracles, %rax and $0xff, %r9 shlq $12, %r9 mov (%rax,%r9,1), %r9 pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': True}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'00': 7949} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
#include <atomic> #include <mutex> #include "globals.hpp" std::vector<cerb::ListenThread> cerb_global::all_threads; thread_local cerb::msize_t cerb_global::allocated_buffer(0); thread_local cerb::Time cerb_global::poll_start; cerb::Interval cerb_global::slow_poll_elapse; static std::mutex remote_addrs_mutex; static std::set<util::Address> remote_addrs; static std::atomic_bool cluster_ok(false); void cerb_global::set_remotes(std::set<util::Address> remotes) { std::lock_guard<std::mutex> _(::remote_addrs_mutex); ::remote_addrs = std::move(remotes); } std::set<util::Address> cerb_global::get_remotes() { std::lock_guard<std::mutex> _(::remote_addrs_mutex); return ::remote_addrs; } static std::atomic_bool req_full_cov(true); void cerb_global::set_cluster_req_full_cov(bool c) { ::req_full_cov = c; } bool cerb_global::cluster_req_full_cov() { return ::req_full_cov; } void cerb_global::set_cluster_ok(bool ok) { ::cluster_ok = ok; } bool cerb_global::cluster_ok() { return ::cluster_ok; } static std::string auth_pass(""); void cerb_global::set_auth_pass(std::string const& pass) { ::auth_pass = pass; } bool cerb_global::need_auth() { return ::auth_pass != ""; } bool cerb_global::is_auth_ok(std::string const& pass) { return ::auth_pass == pass; }
COMMENT }%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1988 -- All Rights Reserved PROJECT: PC GEOS MODULE: SVGA screen driver FILE: svga.asm AUTHOR: Jim DeFrisco REVISION HISTORY: Name Date Description ---- ---- ----------- Jim 9/90 initial version DESCRIPTION: This driver is for all of the Super VGA 800x600 16-color modes. $Id: svgaManager.asm,v 1.1 97/04/18 11:42:25 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%} ;-------------------------------------- ; Include files ;-------------------------------------- _VideoDriver = 1 VIDEO_STACK_SIZE equ 512 ; set size of local stack include vidcomGeode.def ; common includes ;--------------------------------------------------------------------- ; Constants and Macros ;--------------------------------------------------------------------- include svgaConstant.def include vgacomConstant.def include vidcomConstant.def include vgacomMacro.def include vidcomMacro.def ;------------------------------------------------------------------------------ ; Variables ;------------------------------------------------------------------------------ idata segment include svgaDevInfo.asm ; device info block include vidcomTables.asm ; common tables include svgaTables.asm ; important tabular information idata ends udata segment include vidcomVariable.def include vgacomVariable.def ; local buffer space udata ends ;------------------------------------------------------------------------------ ; Extended Device Info ;------------------------------------------------------------------------------ VideoDevices segment lmem LMEM_TYPE_GENERAL include svgaStringTab.asm ; device names VideoDevices ends ;------------------------------------------------------------------------------ ; Fixed Code ;------------------------------------------------------------------------------ idata segment include vidcomEntry.asm ; entry point,jump tab include vidcomOutput.asm ; common output routines include vidcomChars.asm ; common character output routines include vgacomGenChar.asm ; routines for larger characters include vidcomFont.asm ; routines for building, rotating chars include vidcomUnder.asm ; save under routines include vidcomUtils.asm ; utility routines include vidcomRegion.asm ; region drawing routine include vidcomXOR.asm ; xor region support include vidcomInfo.asm ; device naming/setting include vidcomEscape.asm ; support for some escape codes include vidcomDither.asm ; dither patterns include vidcomPalette.asm ; support for VidGetPixel include vgacomOutput.asm ; output routines include vgacomUtils.asm ; misc utility routines include vgacomChars.asm ; character drawing routines include vgacomPointer.asm ; pointer support include vgacomPalette.asm ; color palette table include svgaEscTab.asm ; escape code jump table include svgaPalette.asm ; color escape support idata ends ;------------------------------------------------------------------------------ ; Movable Code ;------------------------------------------------------------------------------ include vidcomPolygon.asm ; polygon drawing include vidcomLine.asm ; line drawing routine include vidcomPutLine.asm ; line drawing routine include vidcomRaster.asm ; raster primitive support include vidcomExclBounds.asm ; bounds accumulation include vgacomRaster.asm ; raster primitive support include vgacomTables.asm ; common tables include svgaAdmin.asm ; misc admin routines end
#ifndef GRB_BACKEND_APSPIE_DESCRIPTOR_HPP #define GRB_BACKEND_APSPIE_DESCRIPTOR_HPP #include <vector> #include <moderngpu.cuh> namespace graphblas { namespace backend { class Descriptor { public: // Default Constructor, Standard Constructor (Replaces new in C++) // -it's imperative to call constructor using matrix or the constructed object // won't be tied to this outermost layer Descriptor() : desc_{ GrB_FIXEDROW, GrB_32, GrB_32, GrB_128 }, d_limits_(NULL), d_carryin_(NULL), d_carryout_(NULL), d_context_(mgpu::CreateCudaDevice(0)) {} // Assignment Constructor // TODO: void operator=( Descriptor& rhs ); // Destructor ~Descriptor() {}; // C API Methods // // Mutators Info set( const Desc_field field, Desc_value value ); // Accessors Info get( const Desc_field field, Desc_value& value ) const; private: // Data members that are same for all backends Desc_value desc_[4]; int* d_limits_; float* d_carryin_; float* d_carryout_; mgpu::ContextPtr d_context_; }; Info Descriptor::set( const Desc_field field, Desc_value value ) { desc_[field] = value; return GrB_SUCCESS; } Info Descriptor::get( const Desc_field field, Desc_value& value ) const { value = desc_[field]; return GrB_SUCCESS; } } // backend } // graphblas #endif // GRB_DESCRIPTOR_HPP
; A131470: a(n)=smallest number that gives a product with the sum of digits of n written in base 2 greater than n. ; 2,3,2,5,3,4,3,9,5,6,4,7,5,5,4,17,9,10,7,11,8,8,6,13,9,9,7,10,8,8,7,33,17,18,12,19,13,13,10,21,14,15,11,15,12,12,10,25,17,17,13,18,14,14,12,19,15,15,12,16,13,13,11,65,33,34,23 mov $1,$0 add $0,1 seq $1,48881 ; a(n) = A000120(n+1) - 1 = wt(n+1) - 1. add $1,1 div $0,$1 add $0,1
; A223577: Positive integers n for which there is exactly one negative integer m such that -n = floor(cot(Pi/(2*m))). ; 1,2,3,5,8,10,12,15,17,19,22,24,26,29,31,33,35,38,40,42,45,47,49,52,54,56,59,61,63,66,68,70,73,75,77,80,82,84,87,89,91,94,96,98,101,103,105,108,110,112,115,117,119,122,124,126,129,131,133,136,138 mov $6,$0 add $6,1 mov $13,$0 lpb $6 mov $0,$13 sub $6,1 sub $0,$6 mov $9,$0 mov $11,2 lpb $11 mov $0,$9 sub $11,1 add $0,$11 sub $0,1 mul $0,4 mov $3,$0 mov $4,$0 mov $5,$0 mul $0,2 mov $2,$0 add $2,$4 mov $7,13 mov $8,$3 lpb $2 lpb $4 add $2,$7 mov $4,0 mul $5,$8 div $5,$2 trn $5,1 lpe mov $2,3 lpe mov $12,$11 lpb $12 mov $10,$5 sub $12,1 lpe lpe lpb $9 mov $9,0 sub $10,$5 lpe mov $5,$10 add $5,1 add $1,$5 lpe mov $0,$1
#include "bitcoinunits.h" #include <QStringList> BitcoinUnits::BitcoinUnits(QObject *parent): QAbstractListModel(parent), unitlist(availableUnits()) { } QList<BitcoinUnits::Unit> BitcoinUnits::availableUnits() { QList<BitcoinUnits::Unit> unitlist; unitlist.append(BTC); unitlist.append(mBTC); unitlist.append(uBTC); return unitlist; } bool BitcoinUnits::valid(int unit) { switch(unit) { case BTC: case mBTC: case uBTC: return true; default: return false; } } QString BitcoinUnits::name(int unit) { switch(unit) { case BTC: return QString("BDS"); case mBTC: return QString("mBDS"); case uBTC: return QString::fromUtf8("ฮผBDS"); default: return QString("???"); } } QString BitcoinUnits::description(int unit) { switch(unit) { case BTC: return QString("Bitdrass"); case mBTC: return QString("Milli-Bitdrass (1 / 1,000)"); case uBTC: return QString("Micro-Bitdrass (1 / 1,000,000)"); default: return QString("???"); } } qint64 BitcoinUnits::factor(int unit) { switch(unit) { case BTC: return 100000000; case mBTC: return 100000; case uBTC: return 100; default: return 100000000; } } int BitcoinUnits::amountDigits(int unit) { switch(unit) { case BTC: return 8; // 21,000,000 (# digits, without commas) case mBTC: return 11; // 21,000,000,000 case uBTC: return 14; // 21,000,000,000,000 default: return 0; } } int BitcoinUnits::decimals(int unit) { switch(unit) { case BTC: return 8; case mBTC: return 5; case uBTC: return 2; default: return 0; } } QString BitcoinUnits::format(int unit, qint64 n, bool fPlus) { // Note: not using straight sprintf here because we do NOT want // localized number formatting. if(!valid(unit)) return QString(); // Refuse to format invalid unit qint64 coin = factor(unit); int num_decimals = decimals(unit); qint64 n_abs = (n > 0 ? n : -n); qint64 quotient = n_abs / coin; qint64 remainder = n_abs % coin; QString quotient_str = QString::number(quotient); QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0'); // Right-trim excess zeros after the decimal point int nTrim = 0; for (int i = remainder_str.size()-1; i>=2 && (remainder_str.at(i) == '0'); --i) ++nTrim; remainder_str.chop(nTrim); if (n < 0) quotient_str.insert(0, '-'); else if (fPlus && n > 0) quotient_str.insert(0, '+'); return quotient_str + QString(".") + remainder_str; } QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign) { return format(unit, amount, plussign) + QString(" ") + name(unit); } bool BitcoinUnits::parse(int unit, const QString &value, qint64 *val_out) { if(!valid(unit) || value.isEmpty()) return false; // Refuse to parse invalid unit or empty string int num_decimals = decimals(unit); QStringList parts = value.split("."); if(parts.size() > 2) { return false; // More than one dot } QString whole = parts[0]; QString decimals; if(parts.size() > 1) { decimals = parts[1]; } if(decimals.size() > num_decimals) { return false; // Exceeds max precision } bool ok = false; QString str = whole + decimals.leftJustified(num_decimals, '0'); if(str.size() > 18) { return false; // Longer numbers will exceed 63 bits } qint64 retvalue = str.toLongLong(&ok); if(val_out) { *val_out = retvalue; } return ok; } int BitcoinUnits::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); return unitlist.size(); } QVariant BitcoinUnits::data(const QModelIndex &index, int role) const { int row = index.row(); if(row >= 0 && row < unitlist.size()) { Unit unit = unitlist.at(row); switch(role) { case Qt::EditRole: case Qt::DisplayRole: return QVariant(name(unit)); case Qt::ToolTipRole: return QVariant(description(unit)); case UnitRole: return QVariant(static_cast<int>(unit)); } } return QVariant(); }
<% from pwnlib.shellcraft.arm.linux import syscall %> <%page args="fd, iovec, count"/> <%docstring> Invokes the syscall readv. See 'man 2 readv' for more information. Arguments: fd(int): fd iovec(iovec): iovec count(int): count </%docstring> ${syscall('SYS_readv', fd, iovec, count)}
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r15 push %rax push %rbx push %rdx // Store lea addresses_D+0x5633, %r10 nop nop nop nop add $8694, %r13 movl $0x51525354, (%r10) nop nop xor $53032, %r13 // Store mov $0x19feab0000000f51, %rax nop nop inc %r15 movb $0x51, (%rax) nop nop nop sub $63134, %r13 // Store mov $0xf88, %r13 nop nop nop nop nop add %r15, %r15 movl $0x51525354, (%r13) and %rbx, %rbx // Load mov $0x611, %r10 nop nop nop nop nop dec %r13 mov (%r10), %r15w nop nop nop xor $55277, %r15 // Faulty Load lea addresses_WT+0xf611, %r15 sub $18912, %r10 mov (%r15), %bx lea oracles, %rdx and $0xff, %rbx shlq $12, %rbx mov (%rdx,%rbx,1), %rbx pop %rdx pop %rbx pop %rax pop %r15 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_WT', 'congruent': 0}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_D', 'congruent': 0}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_NC', 'congruent': 4}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_P', 'congruent': 0}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_P', 'congruent': 11}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_WT', 'congruent': 0}} <gen_prepare_buffer> {'39': 5} 39 39 39 39 39 */
.intel_syntax noprefix MFENCE NOP NOP NOP ADD R14, 40 JMP .bb0 .bb0: AND RCX, 0b111111000000 ADD RCX, R14 CMOVZ ECX, dword ptr [RCX] LAHF {store} ADC RAX, RAX AND RDX, 0b111111000000 ADD RDX, R14 SETNZ byte ptr [RDX] MOVSX EDX, BX AND RCX, 0b111111000000 ADD RCX, R14 SUB CX, 19187 JNP .bb1 JMP .bb2 .bb1: MOVZX EDX, CX DEC AL {store} ADC RBX, RBX CMOVBE EAX, EAX {load} OR DL, DL SETB BL {disp32} JS .bb2 JMP .bb3 .bb2: AND RDX, 0b111111000000 ADD RDX, R14 ADD qword ptr [RDX], 621805592 .bb3: AND RBX, 0b111111000000 ADD RBX, R14 SUB R14, 40 MFENCE
; A183574: n+Floor[sqrt(2n+2)]. ; 3,4,5,7,8,9,11,12,13,14,15,17,18,19,20,21,23,24,25,26,27,28,29,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,49,50,51,52,53,54,55,56,57,59,60,61,62,63,64,65,66,67,68,69,71,72,73,74,75,76,77,78,79,80,81,83,84,85,86,87,88,89,90,91,92 mov $1,$0 add $1,4 add $1,$0 lpb $1 add $0,1 sub $1,1 add $2,2 trn $1,$2 lpe add $0,1
;=========================================================================== ; Util.asm ;--------------------------------------------------------------------------- ; Assembly x86 library ; ; ; Author: Ahmed Hussein ; Created: ; ; ; This file provide some Macros that help in decreasing code size ; ; Procedures included: ; * PushA ; * PopA ;=========================================================================== ;----------------------------------------------------- ; PushA ;----------------------------------------------------- ; Push all general registers ; PUSH AX, BX, DX, CX, BP, SI, DI ;----------------------------------------------------- PushA MACRO PUSH AX PUSH BX PUSH DX PUSH CX PUSH BP PUSH SI PUSH DI ENDM PushA ;----------------------------------------------------- ; PopA ;----------------------------------------------------- ; Pop all general registers ; POP DI, SI, BP, CX, DX, BX, AX ;----------------------------------------------------- PopA MACRO POP DI POP SI POP BP POP CX POP DX POP BX POP AX ENDM PopA
/* Copyright (c) 2022 Xavier Leclercq Released under the MIT License See https://github.com/ishiko-cpp/logging/blob/main/LICENSE.txt */ #include "LogLevel.hpp" using namespace Ishiko; LogLevel::LogLevel() : m_value(error) { } LogLevel::LogLevel(Value value) : m_value(value) { } LogLevel LogLevel::FromString(const std::string& level) { LogLevel result; if (level == "always") { result = always; } else if (level == "fatal") { result = fatal; } else if (level == "error") { result = error; } else if (level == "warning") { result = warning; } else if (level == "info") { result = info; } else if (level == "verbose") { result = verbose; } else if (level == "debug") { result = debug; } else if (level == "trace") { result = trace; } else { // TODO: error } return result; } bool LogLevel::operator==(LogLevel::Value level) const { return (m_value == level); } bool LogLevel::operator!=(LogLevel::Value level) const { return (m_value != level); } bool LogLevel::operator<=(LogLevel::Value level) const { return (m_value <= level); } bool LogLevel::operator>=(LogLevel::Value level) const { return (m_value >= level); } bool LogLevel::operator<(LogLevel::Value level) const { return (m_value < level); } bool LogLevel::operator>(LogLevel::Value level) const { return (m_value > level); } std::string LogLevel::toString() { std::string result; switch (m_value) { case always: result = "always"; break; case fatal: result = "fatal"; break; case error: result = "error"; break; case warning: result = "warning"; break; case info: result = "info"; break; case verbose: result = "verbose"; break; case debug: result = "debug"; break; case trace: result = "trace"; break; default: // TODO: error break; } return result; }
; Erase current save file ; by Sixtare Erase: REP #$10 LDA $010A CMP #$01 BEQ .01 BCS .02 .00 LDX #$008F JMP .delete .01 LDX #$011E JMP .delete .02 LDX #$01AD .delete LDY #$008F LDA #$00 - STA $700000,x STA $7001AD,x DEX DEY BPL - SEP #$10 RTS
;############################################################################################# ;# SHAPES AND DRAWING ;b = height ;c = width ;d = starting x ;e = starting y drawBox: dec b dec b dec b dec b ld a,(yOff) add a,e ld e,a ld a,(xOff) add a,d ld d,a and $7 ex af,af' ld a,d ld l,e ld h,0 ld d,h add hl,hl add hl,de add hl,hl add hl,de add hl,hl ;y*14 rra rra rra and %00011111 ld e,a add hl,de ;+x ld de,gbuf add hl,de ;position in gbuf ex af,af' ld de,%1111111011111111 ld (scratchSpace),de ld e,%01111111 call drawLine ld de,%1111111111111111 ld (scratchSpace),de call drawLine middleLoop: ld de,%0000000100000000 ld (scratchSpace),de ld e,%10000000 call drawLine djnz middleLoop ld de,%1111111111111111 ld (scratchSpace),de call drawLine ld de,%1111111011111111 ld (scratchSpace),de ld e,%01111111 drawLine: push bc push af ld b,a or a ld a,$FF jr z,$+9 ;check if aligned inc c srl a srl e djnz $-5 cpl and (hl) or e ld (hl),a ;store in gbuf inc hl ld a,(scratchSpace) ld e,a ;e = the pattern to draw in the middle of the line ld a,c ;width+xOff sub 16 ;-16 for the first two bytes in the line jr c,exitLine lineLoop: ld (hl),e ;draw 8 pixels at a time until we've got inc hl ; fewer than 8 pixels to draw sub 8 jr nc,lineLoop exitLine: neg cp 8 ld b,a ld a,(scratchSpace+1) jr nz,unAlined dec hl ld (hl),a inc hl jr nextRow unAlined: ;) ld e,a ld a,$FF sla a sla e djnz $-4 cpl and (hl) ;a holds the mask or e ld (hl),a nextRow: ld a,c rra rra rra and %00011111 ld e,a ld a,14 sub e ld e,a ld d,0 add hl,de ;+x pop af pop bc ret ;############################################################################################# ;# MATH ;multiplica E*H y guarda el resultado en HL multEH: ld l,0 ld d,l ld b,8 multLoop: ;hl=e*h add hl,hl jr nc,noAdd add hl,de noAdd: djnz multLoop ret
; A038572: a(n) = n rotated one binary place to the right. ; 0,1,1,3,2,6,3,7,4,12,5,13,6,14,7,15,8,24,9,25,10,26,11,27,12,28,13,29,14,30,15,31,16,48,17,49,18,50,19,51,20,52,21,53,22,54,23,55,24,56,25,57,26,58,27,59,28,60,29,61,30,62,31,63,32,96,33,97,34,98,35,99,36,100,37,101,38,102,39,103,40,104,41,105,42,106,43,107,44,108,45,109,46,110,47,111,48,112,49,113 mov $3,$0 div $0,2 mod $3,2 mov $2,$3 mov $4,$0 lpb $4 mul $2,2 div $4,2 lpe sub $0,1 add $0,$2 add $0,1
;PROGRAM PODAJฤ„CY GODZINฤ˜ PO KAลปDYM NACIลšNIฤ˜CIU KLAWISZA RETURN MINUTE: DC INTEGER(60) HOUR: DC INTEGER(3600) DAY: DC INTEGER(86400) UTC: DC INTEGER(7200) SEPARATOR: DC CHAR(':') TEN: DC INTEGER(10) MAIN: XOR 1, 1 CLOCK: HALT TIME 0 ADD 0, UTC DIV 0, DAY LD 0, 8 DIV 0, HOUR CMP 0, TEN JGE H OUT 1 H: OUT 0 LD 0, 8 DIV 0, MINUTE COUT SEPARATOR CMP 0, TEN JGE M OUT 1 M: OUT 0 COUT SEPARATOR CMP 8, TEN JGE S OUT 1 S: OUT 8 COUT TEN JMP CLOCK
; A044788: Numbers n such that string 7,5 occurs in the base 10 representation of n but not of n+1. ; Submitted by Christian Krause ; 75,175,275,375,475,575,675,759,775,875,975,1075,1175,1275,1375,1475,1575,1675,1759,1775,1875,1975,2075,2175,2275,2375,2475,2575,2675,2759,2775,2875,2975,3075,3175,3275,3375,3475,3575 add $0,10 seq $0,44397 ; Numbers n such that string 6,5 occurs in the base 10 representation of n but not of n-1. div $0,4 sub $0,241 mul $0,4 add $0,75
; A099531: Expansion of (1+x)^3/((1+x)^3+x^4). ; Submitted by Jamie Morken(w1) ; 1,0,0,0,-1,3,-6,10,-14,15,-7,-20,80,-188,351,-549,702,-622,-42,1839,-5471,11560,-20064,29144,-33329,21059,27730,-142182,355626,-689121,1114937,-1490892,1461360,-337220,-2996465,10030587,-22226506,39921442,-60118930,72788383,-55703295,-31057776,247613760,-666753040,1344178911,-2248833597,3133103338,-3330235094,1496049954,4618285679,-18145875143,42416953532,-78927570800,123059441268,-156666689793,137332362843,13871110382,-420003171150,1237730509254,-2604385487537,4506096995617,-6522861862344 mul $0,3 mov $2,1 mov $5,1 lpb $0 sub $0,1 mov $4,$2 mov $2,$1 mov $1,$3 div $4,-1 add $5,$4 mov $3,$5 mov $5,$4 lpe mov $0,$2
<% from pwnlib.shellcraft.i386.linux import syscall %> <%page args="fromfd, from_, tofd, to, flags"/> <%docstring> Invokes the syscall linkat. See 'man 2 linkat' for more information. Arguments: fromfd(int): fromfd from(char): from tofd(int): tofd to(char): to flags(int): flags </%docstring> ${syscall('SYS_linkat', fromfd, from_, tofd, to, flags)}
; A086113: Number of 3 X n (0,1) matrices such that each row and each column is nondecreasing or nonincreasing. ; 6,36,102,216,390,636,966,1392,1926,2580,3366,4296,5382,6636,8070,9696,11526,13572,15846,18360,21126,24156,27462,31056,34950,39156,43686,48552,53766,59340,65286,71616,78342,85476,93030,101016,109446,118332,127686,137520,147846,158676,170022,181896,194310,207276,220806,234912,249606,264900,280806,297336,314502,332316,350790,369936,389766,410292,431526,453480,476166,499596,523782,548736,574470,600996,628326,656472,685446,715260,745926,777456,809862,843156,877350,912456,948486,985452,1023366 add $0,3 mov $2,2 sub $2,$0 bin $0,3 mul $0,2 add $0,$2 mul $0,6
<% from pwnlib.shellcraft.thumb.linux import syscall %> <%page args="rgid, egid, sgid"/> <%docstring> Invokes the syscall getresgid. See 'man 2 getresgid' for more information. Arguments: rgid(gid_t): rgid egid(gid_t): egid sgid(gid_t): sgid </%docstring> ${syscall('SYS_getresgid', rgid, egid, sgid)}
; A021058: Decimal expansion of 1/54. ; 0,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8,5,1,8 lpb $0 sub $2,2 add $2,$0 trn $0,$1 sub $1,$0 trn $1,1 add $1,4 trn $1,$0 add $1,2 add $2,2 mov $3,$2 sub $3,4 trn $3,$0 add $1,$3 mov $2,$1 sub $2,$0 trn $0,1 add $2,$1 lpe trn $1,4
; ; Generic pseudo graphics routines for text-only platforms ; ; Xor pixel at (x,y) coordinate. SECTION code_clib PUBLIC c_xorpixel defc NEEDxor = 1 .c_xorpixel INCLUDE "c_pixel.asm"
; by Ish. ; Public domain from https://ish.works/bootsector/bootsector.html bits 16 ; tell NASM this is 16 bit code org 0x7c00 ; tell NASM that our code will be loaded at offset 0x7c00 %define CURRENT_LEVEL 0x1000 %define CURRENT_LEVEL_4 0x1004 %define SCREEN_DS 0xb800 boot: ; clear screen (re-set text mode) xor ah, ah mov al, 0x03 ; text mode 80x25 16 colours int 0x10 ; disable cursor mov ah, 0x01 mov ch, 0x3f int 0x10 ; set up stack mov ax, 0x9000 mov ss, ax mov sp, 0x400 ; set current level to test level by copying mov si, test_level ; get width and height and multiply by each other mov ax, [si] mul ah ; set multiplied width and height + 4 as counter mov cx, ax ;add cx, 4 mov di, CURRENT_LEVEL ; next address to copy to xor ax, ax mov es, ax ; copy map size and player position ("uncompressed") lodsw stosw lodsw stosw .copy_level_loop: ; load "compressed" byte: e.g. 0x28 or 0x44 into AL lodsb mov ah, al ; AX = 0x2828 and ax, 0x0FF0 ; AX = 0x0820 (little endian: 20 08) shr al, 4 ; AX = 0x0802 (little endian: 02 08) ; save "uncompressed" word: e.g. 02 08 or 04 04 from AX stosw loop .copy_level_loop call draw_current_level .mainloop: ; read key xor ax, ax int 0x16 cmp ah, 0x01 ; esc je boot cmp ah, 0x50 ; down arrow je .try_move_down cmp ah, 0x48 ; up arrow je .try_move_up cmp ah, 0x4b ; left arrow je .try_move_left cmp ah, 0x4d ; right arrow je .try_move_right .redraw: call draw_current_level .check_win: ; get width and height mov ax, [CURRENT_LEVEL] ; al = width; ah = height mul ah mov cx, ax ; cx = size of map xor bx, bx ; bx = number of bricks-NOT-on-a-spot mov si, CURRENT_LEVEL_4 .check_win_loop: lodsb cmp al, 2 jne .not_a_brick inc bx .not_a_brick: loop .check_win_loop ; so, did we win? is the number of spotless bricks == 0?? cmp bx, 0 je win jmp .mainloop .try_move_down: mov al, byte [CURRENT_LEVEL] ; (width of current level) to the right = 1 down call try_move jmp .redraw .try_move_up: mov al, byte [CURRENT_LEVEL] neg al ; (width of current level) to the left = 1 up call try_move jmp .redraw .try_move_left: mov al, -1 ; one to the left call try_move jmp .redraw .try_move_right: mov al, 1 ; one to the right call try_move jmp .redraw win: ; print a nice win message to the middle of the screen mov si, str_you_win ; destination position on screen mov ax, SCREEN_DS mov es, ax mov di, (80 * 12 + 40 - 6) * 2 mov ah, 0x0F .loop: lodsb cmp al, 0 je wait_for_esc stosw jmp .loop wait_for_esc: ; read key xor ax, ax int 0x16 cmp ah, 0x01 ; esc je boot jmp wait_for_esc ; halt: ; cli ; clear interrupt flag ; hlt ; halt execution ;; functions: draw_current_level: ; get width and height mov cx, [CURRENT_LEVEL] ; cl = width; ch = height push cx ; put it in the stack for later reuse ; print in the middle and not in the corner mov di, 2000; middle of screen ; offset by half of width mov bl, cl and bx, 0x00FE sub di, bx ; offset by half of height mov cl, ch and cx, 0x00FE mov ax, 80 mul cx sub di, ax mov si, CURRENT_LEVEL_4 ; source byte ; screen memory in text mode mov ax, SCREEN_DS mov es, ax .loop: mov bl, [si] xor bh, bh add bx, bx add bx, display_chars mov dx, [bx] mov [es:di], dx inc si add di, 2 pop cx ; get counters dec cl ; subtract 1 from X axis counter jz .nextrow push cx jmp .loop .nextrow: dec ch ; subtract 1 from Y axis counter jz .finished mov cl, [CURRENT_LEVEL] push cx ; jump to next row down xor ch, ch neg cx add cx, 80 add cx, cx add di, cx jmp .loop .finished: ret try_move: ; try to move the player ; al = offset of how much to move by pusha ; extend al into ax (signed) test al, al ; check if negative js .negative_al xor ah, ah jmp .after_al .negative_al: mov ah, 0xFF .after_al: push ax ; calculate total level size mov ax, [CURRENT_LEVEL] mul ah ; calculate requested destination position pop bx push bx mov dx, [CURRENT_LEVEL + 2] add bx, dx ; check if in bounds cmp bx, 0 jl .finished cmp bx, ax jg .finished ; get value at destination position mov cl, [CURRENT_LEVEL_4 + bx] cmp cl, 4 je .cant_push ; it's a wall test cl, 0x02 jz .dont_push ; it's not a brick (on spot, or not), so don't try pushing ; try pushing brick pop cx ; get move offset push bx ; store player's destination position (brick's current position) mov dx, bx ; dx = current brick position add bx, cx ; bx = next brick position ; check bounds cmp bx, 0 jl .cant_push cmp bx, ax jg .cant_push ; get value at destination position mov ch, [CURRENT_LEVEL_4 + bx] test ch, 0x0E ; test if the destination is occupied at all by ANDing with 0000 1110 jnz .cant_push ; all checks passed! push the brick ; add new brick to screen or ch, 0x02 ; add brick bit, by ORing with 0000 0010 mov [CURRENT_LEVEL_4 + bx], ch ; remove old brick from screen mov si, dx mov cl, [CURRENT_LEVEL_4 + si] and cl, 0xFD ; remove brick bit, by ANDing with 1111 1101 mov [CURRENT_LEVEL_4 + si], cl mov dx, [CURRENT_LEVEL + 2] ; dx = current player position pop bx ; bx = next player position jmp .redraw_player .cant_push: pop bx jmp .finished .dont_push: pop cx ; don't need to have this offset in the stack anymore .redraw_player: ; remove old player from screen mov si, dx mov cl, [CURRENT_LEVEL_4 + si] and cl, 0xF7 ; remove player bit, by ANDing with 1111 0111 mov [CURRENT_LEVEL_4 + si], cl ; add new player to screen mov ch, [CURRENT_LEVEL_4 + bx] or ch, 0x08 ; add player bit, by ORing with 0000 1000 mov [CURRENT_LEVEL_4 + bx], ch ; update player position in memory mov [CURRENT_LEVEL + 2], bx .finished: popa ret ; data section: ; 0000 0000 EMPTY ; 0000 0001 SPOT ; 0000 0010 BRICK ; 0000 0011 BRICK ON SPOT ; 0000 0100 WALL ; 0000 1000 PLAYER ; 0000 1001 PLAYER ON SPOT test_level: ; this was the original level format, which was quite big: ; db 9, 7 ; width, height ; dw 32 ; playerxy ; db 4,4,4,4,4,4,0,0,0 ; db 4,0,0,0,0,4,0,0,0 ; db 4,0,0,2,0,4,4,0,0 ; db 4,0,2,4,1,9,4,4,4 ; db 4,4,0,0,3,1,2,0,4 ; db 0,4,0,0,0,0,0,0,4 ; db 0,4,4,4,4,4,4,4,4 ; db 14, 10 ;width, height ; dw 63 ;playerxy ; when i tried to put in THIS level (from https://www.youtube.com/watch?v=fg8QImlvB-k) ; i passed the 512 byte limit... ; db 4,4,4,4,4,4,4,4,4,4,4,4,0,0 ; db 4,1,1,0,0,4,0,0,0,0,0,4,4,4 ; db 4,1,1,0,0,4,0,2,0,0,2,0,0,4 ; db 4,1,1,0,0,4,2,4,4,4,4,0,0,4 ; db 4,1,1,0,0,0,0,8,0,4,4,0,0,4 ; db 4,1,1,0,0,4,0,4,0,0,2,0,4,4 ; db 4,4,4,4,4,4,0,4,4,2,0,2,0,4 ; db 0,0,4,0,2,0,0,2,0,2,0,2,0,4 ; db 0,0,4,0,0,0,0,4,0,0,0,0,0,4 ; db 0,0,4,4,4,4,4,4,4,4,4,4,4,4 ; so i compressed it! high nybble first, low nybble second db 14, 10 ;width, height dw 63 ;playerxy db 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00 db 0x41, 0x10, 0x04, 0x00, 0x00, 0x04, 0x44 db 0x41, 0x10, 0x04, 0x02, 0x00, 0x20, 0x04 db 0x41, 0x10, 0x04, 0x24, 0x44, 0x40, 0x04 db 0x41, 0x10, 0x00, 0x08, 0x04, 0x40, 0x04 db 0x41, 0x10, 0x04, 0x04, 0x00, 0x20, 0x44 db 0x44, 0x44, 0x44, 0x04, 0x42, 0x02, 0x04 db 0x00, 0x40, 0x20, 0x02, 0x02, 0x02, 0x04 db 0x00, 0x40, 0x00, 0x04, 0x00, 0x00, 0x04 db 0x00, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 display_chars: db 0, 0x07 ; blank db 249, 0x07 ; spot db 4, 0x0C ; brick db 4, 0x0A ; brick on spot db 178, 0x71 ; wall db "5", 0x07 ; (no 5) db "6", 0x07 ; (no 6) db "7", 0x07 ; (no 7) db 1, 0x0F ; player db 1, 0x0F ; player on spot str_you_win: db 'YOU WIN! ',1,1,1,0 times 510 - ($-$$) db 0 ; pad remaining 510 bytes with zeroes dw 0xaa55 ; magic bootloader magic - marks this 512 byte sector bootable! ; if you don't want your resulting file to be as big as a floppy, then comment the following line: times (1440 * 1024) - ($-$$) db 0 ; pad with zeroes to make a floppy-sized image
// // Created by Oleg on 6/14/2018. // #include "neural_matrix.h" #include "namespaces.h" // // Created by oleg on 6/4/18. // #include <iostream> #include <cmath> #include <stdexcept> #include <random> #include <ctime> #pragma clang diagnostic push #pragma ide diagnostic ignored "OCDFAInspection" /************ NEURON IMPLEMENTATION *************/ const long double neural_networks::utilities::Neuron::operator()(const long double input) { data = input; function = activation_function(input); function_derivative = activation_function_prime(input); return function; } // for "firing" the neuron const long double neural_networks::utilities::Neuron::operator()(void) { return function; } // for setting the values of Neuron objects from just one input const long double neural_networks::utilities::Neuron::set(const neural_networks::utilities::Neuron::ld input) { data = input; function = activation_function(input); function_derivative = activation_function_prime(input); return function; } // activation function const long double neural_networks::utilities::Neuron::activation_function(const long double input) const { return exp(input) / (exp(input) + 1); } // activation function const long double neural_networks::utilities::Neuron::activation_function_prime(const long double input) const { return neural_networks::utilities::Neuron::activation_function(input) * (1 - neural_networks::utilities::Neuron::activation_function(input)); } // print function void neural_networks::utilities::Neuron::print(void) const { /* std::cout << '\n' << this << ": {\n"; std::cout << "\tx: " << data << "\n\tฯƒ(x): " << function << "\n\tฯƒ'(x): " << function_derivative << "\n};\n"; */ std::cout << data << " "; } neural_networks::utilities::Neuron* neural_networks::utilities::Neuron::copy(void) const { Neuron* new_neuron = new Neuron(data); return new_neuron; } /************ NEURAL MATRIX IMPLEMENTATION *******************/ /***** CONSTRUCTORS **********/ neural_networks::utilities::NeuralMatrix::NeuralMatrix( const std::vector<long double> &vec) : Matrix<Neuron* >(vec.size(), 1) { register size_t i; for(i = 0; i < N; ++i) { matrix[i][0] = new Neuron(vec[i]); } } neural_networks::utilities::NeuralMatrix::NeuralMatrix(const NeuralMatrix& other) : Matrix<Neuron *>(other.N, other.M) { register size_t i, j; for(i = 0; i < N; ++i) { for(j = 0; j < M; ++j) { // assumes that the copy constructor for the Neuron works correctly matrix[i][j] = new Neuron(*other.matrix[i][j]); } } } neural_networks::utilities::NeuralMatrix::NeuralMatrix(const std::vector<std::vector<long double> > &matrix_other) : Matrix<Neuron *>(matrix_other.size(), matrix_other[0].size()) { register size_t i, j; for(i = 0; i < N; ++i) { if(matrix_other[i].size() != M) { throw std::invalid_argument("Matrix passed is not rectangular"); } for(j = 0; j < M; ++j) { matrix[i][j] = new Neuron(matrix_other[i][j]); } } } // pointers are not initialized in the Matrix<Neuron *> call neural_networks::utilities::NeuralMatrix::NeuralMatrix(const size_t n, const size_t m, bool is_null, bool random) : Matrix<Neuron *>(n, m) { if(!is_null) { // size_t sum = 0; register size_t i, j; if(!random) { for (i = 0; i < N; ++i) { for (j = 0; j < M; ++j) { this->matrix[i][j] = new Neuron; // sum += sizeof(matrix[i][j]); } } } else { // otherwise if we were given a randomization request // for a guassian distribution // seeding it std::default_random_engine generator(static_cast<size_t>(time(0))); std::normal_distribution<long double> distribution(0.0, 2.0); for (i = 0; i < N; ++i) { for (j = 0; j < M; ++j) { this->matrix[i][j] = new Neuron(distribution(generator)); // sum += sizeof(matrix[i][j]); } } } // std::cout << "Allocated " << sum << "B of memory at " << this << "\n"; } } // deconstructor neural_networks::utilities::NeuralMatrix::~NeuralMatrix() { register size_t i, j; // size_t sum = 0; for(i = 0; i < N; ++i) { for(j = 0; j < M; ++j) { // sum += sizeof(matrix[i][j]); delete matrix[i][j]; matrix[i][j] = nullptr; } } // std::cout << "Freed " << sum << "B of memory at " << this << "\n"; } neural_networks::utilities::NeuralMatrix* neural_networks::utilities::NeuralMatrix::operator*(const NeuralMatrix *other) const { if(Matrix<Neuron *>::M == other -> N) { NeuralMatrix *new_layer = new NeuralMatrix(Matrix<Neuron *>::N, other -> M); size_t i, j; register size_t k; for(i = 0; i < new_layer -> N; ++i) { for(j = 0; j < new_layer -> M; ++j) { for(k = 0; k < M; ++k) { (new_layer -> matrix[i][j]) -> data += (this -> matrix[i][k]) -> data * (other -> matrix[k][j]) -> data; } } } return new_layer; } else { std::cerr << "Matrix Multiplication: Dimensions Mismatched\n"; return nullptr; } } neural_networks::utilities::NeuralMatrix* neural_networks::utilities::NeuralMatrix::hadamard_product(const NeuralMatrix *other) const { if(equal_size(*other)) { NeuralMatrix *new_layer = new NeuralMatrix(N, M); register size_t i, j; std::cerr << "Computing hadamard product for the following indices: "; for(i = 0; i < N; ++i) { for(j = 0; j < M; ++j) { std::cerr << "(" << i << ", " << j << ") "; new_layer -> at(i, j) = this -> matrix[i][j] -> data * other -> matrix[i][j] -> data; } } std::cerr << "\n"; return new_layer; } else { std::cerr << "Error: Hadamard product for:" << this << ", dimension mismatched with " << other << "\n"; return nullptr; } } neural_networks::utilities::NeuralMatrix* neural_networks::utilities::NeuralMatrix::operator+(const NeuralMatrix *other) const { if(equal_size(*other)) { NeuralMatrix *new_layer = new NeuralMatrix(N, M); if(!new_layer) { std::cerr << "Error at " << this << ": cannot allocate new matrix, not enough space\n"; return nullptr; } register size_t i, j; for(i = 0; i < N; ++i) { for(j = 0; j < M; ++j) { new_layer -> matrix[i][j] -> data = matrix[i][j] -> data + other -> matrix[i][j] -> data; } } return new_layer; } else { std::cerr << "Error adding [" << other << "] to [" << this << "]: Dimension Mismatch\n"; return nullptr; } } neural_networks::utilities::NeuralMatrix* neural_networks::utilities::NeuralMatrix::operator-(const NeuralMatrix *other) const { if(equal_size(*other)) { NeuralMatrix *new_layer = new NeuralMatrix(N, M); if(!new_layer) { std::cerr << "Error at " << this << ": cannot allocate new matrix, not enough space\n"; return nullptr; } register size_t i, j; for(i = 0; i < N; ++i) { for(j = 0; j < M; ++j) { new_layer -> matrix[i][j] -> data = matrix[i][j] -> data - other -> matrix[i][j] -> data; } } return new_layer; } else { std::cerr << "Error subtracting [" << other << "] to [" << this << "]: Dimension Mismatch\n"; return nullptr; } } neural_networks::utilities::NeuralMatrix* neural_networks::utilities::NeuralMatrix::transpose(const NeuralMatrix* other) { NeuralMatrix *new_mat = new NeuralMatrix(other -> M, other -> N, true); register size_t i, j; for(i = 0; i < other -> N; ++i) { for(j = 0; j < other -> M; ++j) { new_mat -> matrix[j][i] = other -> matrix[i][j] -> copy(); } } return new_mat; } void neural_networks::utilities::NeuralMatrix::print(void) const { register size_t i, j; std::cout << "Printing NeuralMatrix object at " << this << ":\n"; for(i = 0; i < N; ++i) { std::cout << "[ "; for(j = 0; j < M; ++j) { matrix[i][j] -> print(); std::cout << " "; } std::cout << "]\n"; } std::cout << std::endl; } neural_networks::utilities::NeuralMatrix* neural_networks::utilities::NeuralMatrix::transpose(void) const { NeuralMatrix *copy = new NeuralMatrix(M, N, true); if(copy == nullptr) { std::cerr << "Error: Memory Allocation Failed at " << this << '\n'; return nullptr; } register size_t i, j; for(i = 0; i < N; ++i) { for(j = 0; j < M; ++j) { copy -> matrix[j][i] = matrix[i][j] -> copy(); } } return copy; } void neural_networks::utilities::NeuralMatrix::transpose_self() { std::vector< std::vector< Neuron *> > new_matrix(M, std::vector< Neuron *>(N, nullptr)); register size_t i, j; for(i = 0; i < N; ++i) { for(j = 0; j < M; ++j) { new_matrix[j][i] = matrix[i][j]; } } matrix = new_matrix; N = matrix.size(); M = matrix[0].size(); } #pragma clang diagnostic pop
/*************************************************************************** * * Project _____ __ ____ _ _ * ( _ ) /__\ (_ _)_| |_ _| |_ * )(_)( /(__)\ )( (_ _)(_ _) * (_____)(__)(__)(__) |_| |_| * * * Copyright 2018-present, Leonid Stryzhevskyi <lganzzzo@gmail.com> * Benedikt-Alexander MokroรŸ <oatpp@bamkrs.de> * * 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 "MyCustomAuthorizationController.hpp"
_BillsHouseText_1e865:: text "Hiya! I'm a" line "#MON..." cont "...No I'm not!" para "Call me BILL!" line "I'm a true blue" cont "#MANIAC! Hey!" cont "What's with that" cont "skeptical look?" para "I'm not joshing" line "you, I screwed up" cont "an experiment and" cont "got combined with" cont "a #MON!" para "So, how about it?" line "Help me out here!" done _BillsHouseText_1e86a:: text "When I'm in the" line "TELEPORTER, go to" cont "my PC and run the" cont "Cell Separation" cont "System!" done _BillsHouseText_1e86f:: text "No!? Come on, you" line "gotta help a guy" cont "in deep trouble!" para "What do you say," line "chief? Please?" cont "OK? All right!" prompt _BillThankYouText:: text "BILL: Yeehah!" line "Thanks, bud! I" cont "owe you one!" para "So, did you come" line "to see my #MON" cont "collection?" cont "You didn't?" cont "That's a bummer." para "I've got to thank" line "you... Oh here," cont "maybe this'll do." prompt _SSTicketReceivedText:: text $52, " received" line "an @" TX_RAM wcf4b text "!@@" _SSTicketNoRoomText:: text "You've got too" line "much stuff, bud!" done _BillsHouseText_1e8cb:: text "That cruise ship," line "S.S.ANNE, is in" cont "VERMILION CITY." cont "Its passengers" cont "are all trainers!" para "They invited me" line "to their party," cont "but I can't stand" cont "fancy do's. Why" cont "don't you go" cont "instead of me?" done _BillsHouseText_1e8da:: text "BILL: Look, bud," line "just check out" cont "some of my rare" cont "#MON on my PC!" done
; Z88 Small C+ Run time Library ; Moved functions over to proper libdefs ; To make startup code smaller and neater! ; ; 6/9/98 djm SECTION code_l_sccz80 PUBLIC l_gchar, l_gchar_sxt l_gchar: ; fetch char from (HL) and sign extend into HL ld a,(hl) l_gchar_sxt: ; sign extend a into hl ld l,a rlca sbc a,a ld h,a ret
MoveEffectsPointers: ; entries correspond to EFFECT_* constants dw NormalHit dw DoSleep dw PoisonHit dw LeechHit dw BurnHit dw FreezeHit dw ParalyzeHit dw Selfdestruct dw DreamEater dw MirrorMove dw AttackUp dw DefenseUp dw SpeedUp dw SpecialAttackUp dw SpecialDefenseUp dw AccuracyUp dw EvasionUp dw NormalHit dw AttackDown dw DefenseDown dw SpeedDown dw SpecialAttackDown dw SpecialDefenseDown dw AccuracyDown dw EvasionDown dw ResetStats dw Bide dw Rampage dw ForceSwitch dw MultiHit dw Conversion dw FlinchHit dw Heal dw Toxic dw PayDay dw LightScreen dw TriAttack dw NormalHit dw OHKOHit dw RazorWind dw SuperFang dw StaticDamage dw TrapTarget dw NormalHit dw MultiHit dw NormalHit dw Mist dw FocusEnergy dw RecoilHit dw DoConfuse dw AttackUp2 dw DefenseUp2 dw SpeedUp2 dw SpecialAttackUp2 dw SpecialDefenseUp2 dw AccuracyUp2 dw EvasionUp2 dw Transform dw AttackDown2 dw DefenseDown2 dw SpeedDown2 dw SpecialAttackDown2 dw SpecialDefenseDown2 dw AccuracyDown2 dw EvasionDown2 dw Reflect dw DoPoison dw DoParalyze dw AttackDownHit dw DefenseDownHit dw SpeedDownHit dw SpecialAttackDownHit dw SpecialDefenseDownHit dw AccuracyDownHit dw EvasionDownHit dw SkyAttack dw ConfuseHit dw PoisonMultiHit dw NormalHit dw Substitute dw HyperBeam dw Rage dw Mimic dw Metronome dw LeechSeed dw Splash dw Disable dw StaticDamage dw Psywave dw Counter dw Encore dw PainSplit dw Snore dw Conversion2 dw LockOn dw Sketch dw DefrostOpponent dw SleepTalk dw DestinyBond dw Reversal dw Spite dw FalseSwipe dw HealBell dw NormalHit dw TripleKick dw Thief dw MeanLook dw Nightmare dw FlameWheel dw Curse dw NormalHit dw Protect dw Spikes dw Foresight dw PerishSong dw Sandstorm dw Endure dw Rollout dw Swagger dw FuryCutter dw Attract dw Return dw Present dw Frustration dw Safeguard dw SacredFire dw Magnitude dw BatonPass dw Pursuit dw RapidSpin dw NormalHit dw NormalHit dw MorningSun dw Synthesis dw Moonlight dw HiddenPower dw RainDance dw SunnyDay dw DefenseUpHit dw AttackUpHit dw AllUpHit dw FakeOut dw BellyDrum dw PsychUp dw MirrorCoat dw SkullBash dw Twister dw Earthquake dw FutureSight dw Gust dw Stomp dw Solarbeam dw Thunder dw Teleport dw BeatUp dw Fly dw DefenseCurl
; A258881: a(n) = n + the sum of the squared digits of n. ; 0,2,6,12,20,30,42,56,72,90,11,13,17,23,31,41,53,67,83,101,24,26,30,36,44,54,66,80,96,114,39,41,45,51,59,69,81,95,111,129,56,58,62,68,76,86,98,112,128,146,75,77,81,87,95,105,117,131,147,165,96,98,102 mov $1,$0 add $0,100 lpb $1 mov $2,$1 div $1,10 mod $2,10 pow $2,2 add $0,$2 lpe sub $0,100
/**************************************************************************** ** Copyright (c) 2001-2014 ** ** This file is part of the QuickFIX FIX Engine ** ** This file may be distributed under the terms of the quickfixengine.org ** license as defined by quickfixengine.org and appearing in the file ** LICENSE included in the packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.quickfixengine.org/LICENSE for licensing information. ** ** Contact ask@quickfixengine.org if any conditions of this licensing are ** not clear to you. ** ****************************************************************************/ #ifdef _MSC_VER #pragma warning( disable : 4503 4355 4786 ) #include "stdafx.h" #else #include "config.h" #endif #include <UnitTest++.h> #include <MessageStore.h> namespace FIX { struct memoryStoreFixture { memoryStoreFixture() { SessionID sessionID( BeginString( "FIX.4.2" ), SenderCompID( "SETGET" ), TargetCompID( "TEST" ) ); object = factory.create( sessionID ); } ~memoryStoreFixture() { factory.destroy( object ); } MemoryStoreFactory factory; MessageStore* object; }; }
; A040894: Continued fraction for sqrt(925). ; 30,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2,60,2,2,2,2 mov $6,2 mov $7,$0 lpb $6 mov $0,$7 sub $6,1 add $0,$6 mov $2,8 mov $3,8 lpb $0 sub $0,4 trn $0,1 add $3,$2 mov $2,29 lpe sub $3,2 mov $4,$6 mov $5,$3 lpb $4 mov $1,$5 sub $4,1 lpe lpe lpb $7 sub $1,$5 mov $7,0 lpe mul $1,2 add $1,2
;****************************************************************************** ;* x86 optimized Format Conversion Utils ;* Copyright (c) 2008 Loren Merritt ;* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com> ;* ;* This file is part of Libav. ;* ;* Libav 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. ;* ;* Libav 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 Libav; if not, write to the Free Software ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** %include "libavutil/x86/x86util.asm" %include "util.asm" SECTION_RODATA 32 pf_s32_inv_scale: times 8 dd 0x30000000 pf_s32_scale: times 8 dd 0x4f000000 pf_s32_clip: times 8 dd 0x4effffff pf_s16_inv_scale: times 4 dd 0x38000000 pf_s16_scale: times 4 dd 0x47000000 pb_shuf_unpack_even: db -1, -1, 0, 1, -1, -1, 2, 3, -1, -1, 8, 9, -1, -1, 10, 11 pb_shuf_unpack_odd: db -1, -1, 4, 5, -1, -1, 6, 7, -1, -1, 12, 13, -1, -1, 14, 15 pb_interleave_words: SHUFFLE_MASK_W 0, 4, 1, 5, 2, 6, 3, 7 pb_deinterleave_words: SHUFFLE_MASK_W 0, 2, 4, 6, 1, 3, 5, 7 pw_zero_even: times 4 dw 0x0000, 0xffff SECTION_TEXT ;------------------------------------------------------------------------------ ; void ff_conv_s16_to_s32(int32_t *dst, const int16_t *src, int len); ;------------------------------------------------------------------------------ INIT_XMM sse2 cglobal conv_s16_to_s32, 3,3,3, dst, src, len lea lenq, [2*lend] lea dstq, [dstq+2*lenq] add srcq, lenq neg lenq .loop: mova m2, [srcq+lenq] pxor m0, m0 pxor m1, m1 punpcklwd m0, m2 punpckhwd m1, m2 mova [dstq+2*lenq ], m0 mova [dstq+2*lenq+mmsize], m1 add lenq, mmsize jl .loop REP_RET ;------------------------------------------------------------------------------ ; void ff_conv_s16_to_flt(float *dst, const int16_t *src, int len); ;------------------------------------------------------------------------------ %macro CONV_S16_TO_FLT 0 cglobal conv_s16_to_flt, 3,3,3, dst, src, len lea lenq, [2*lend] add srcq, lenq lea dstq, [dstq + 2*lenq] neg lenq mova m2, [pf_s16_inv_scale] ALIGN 16 .loop: mova m0, [srcq+lenq] S16_TO_S32_SX 0, 1 cvtdq2ps m0, m0 cvtdq2ps m1, m1 mulps m0, m2 mulps m1, m2 mova [dstq+2*lenq ], m0 mova [dstq+2*lenq+mmsize], m1 add lenq, mmsize jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16_TO_FLT INIT_XMM sse4 CONV_S16_TO_FLT ;------------------------------------------------------------------------------ ; void ff_conv_s32_to_s16(int16_t *dst, const int32_t *src, int len); ;------------------------------------------------------------------------------ %macro CONV_S32_TO_S16 0 cglobal conv_s32_to_s16, 3,3,4, dst, src, len lea lenq, [2*lend] lea srcq, [srcq+2*lenq] add dstq, lenq neg lenq .loop: mova m0, [srcq+2*lenq ] mova m1, [srcq+2*lenq+ mmsize] mova m2, [srcq+2*lenq+2*mmsize] mova m3, [srcq+2*lenq+3*mmsize] psrad m0, 16 psrad m1, 16 psrad m2, 16 psrad m3, 16 packssdw m0, m1 packssdw m2, m3 mova [dstq+lenq ], m0 mova [dstq+lenq+mmsize], m2 add lenq, mmsize*2 jl .loop %if mmsize == 8 emms RET %else REP_RET %endif %endmacro INIT_MMX mmx CONV_S32_TO_S16 INIT_XMM sse2 CONV_S32_TO_S16 ;------------------------------------------------------------------------------ ; void ff_conv_s32_to_flt(float *dst, const int32_t *src, int len); ;------------------------------------------------------------------------------ %macro CONV_S32_TO_FLT 0 cglobal conv_s32_to_flt, 3,3,3, dst, src, len lea lenq, [4*lend] add srcq, lenq add dstq, lenq neg lenq mova m0, [pf_s32_inv_scale] ALIGN 16 .loop: cvtdq2ps m1, [srcq+lenq ] cvtdq2ps m2, [srcq+lenq+mmsize] mulps m1, m1, m0 mulps m2, m2, m0 mova [dstq+lenq ], m1 mova [dstq+lenq+mmsize], m2 add lenq, mmsize*2 jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_S32_TO_FLT %if HAVE_AVX_EXTERNAL INIT_YMM avx CONV_S32_TO_FLT %endif ;------------------------------------------------------------------------------ ; void ff_conv_flt_to_s16(int16_t *dst, const float *src, int len); ;------------------------------------------------------------------------------ INIT_XMM sse2 cglobal conv_flt_to_s16, 3,3,5, dst, src, len lea lenq, [2*lend] lea srcq, [srcq+2*lenq] add dstq, lenq neg lenq mova m4, [pf_s16_scale] .loop: mova m0, [srcq+2*lenq ] mova m1, [srcq+2*lenq+1*mmsize] mova m2, [srcq+2*lenq+2*mmsize] mova m3, [srcq+2*lenq+3*mmsize] mulps m0, m4 mulps m1, m4 mulps m2, m4 mulps m3, m4 cvtps2dq m0, m0 cvtps2dq m1, m1 cvtps2dq m2, m2 cvtps2dq m3, m3 packssdw m0, m1 packssdw m2, m3 mova [dstq+lenq ], m0 mova [dstq+lenq+mmsize], m2 add lenq, mmsize*2 jl .loop REP_RET ;------------------------------------------------------------------------------ ; void ff_conv_flt_to_s32(int32_t *dst, const float *src, int len); ;------------------------------------------------------------------------------ %macro CONV_FLT_TO_S32 0 cglobal conv_flt_to_s32, 3,3,6, dst, src, len lea lenq, [lend*4] add srcq, lenq add dstq, lenq neg lenq mova m4, [pf_s32_scale] mova m5, [pf_s32_clip] .loop: mulps m0, m4, [srcq+lenq ] mulps m1, m4, [srcq+lenq+1*mmsize] mulps m2, m4, [srcq+lenq+2*mmsize] mulps m3, m4, [srcq+lenq+3*mmsize] minps m0, m0, m5 minps m1, m1, m5 minps m2, m2, m5 minps m3, m3, m5 cvtps2dq m0, m0 cvtps2dq m1, m1 cvtps2dq m2, m2 cvtps2dq m3, m3 mova [dstq+lenq ], m0 mova [dstq+lenq+1*mmsize], m1 mova [dstq+lenq+2*mmsize], m2 mova [dstq+lenq+3*mmsize], m3 add lenq, mmsize*4 jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_FLT_TO_S32 %if HAVE_AVX_EXTERNAL INIT_YMM avx CONV_FLT_TO_S32 %endif ;------------------------------------------------------------------------------ ; void ff_conv_s16p_to_s16_2ch(int16_t *dst, int16_t *const *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_S16P_TO_S16_2CH 0 cglobal conv_s16p_to_s16_2ch, 3,4,5, dst, src0, len, src1 mov src1q, [src0q+gprsize] mov src0q, [src0q ] lea lenq, [2*lend] add src0q, lenq add src1q, lenq lea dstq, [dstq+2*lenq] neg lenq .loop: mova m0, [src0q+lenq ] mova m1, [src1q+lenq ] mova m2, [src0q+lenq+mmsize] mova m3, [src1q+lenq+mmsize] SBUTTERFLY2 wd, 0, 1, 4 SBUTTERFLY2 wd, 2, 3, 4 mova [dstq+2*lenq+0*mmsize], m0 mova [dstq+2*lenq+1*mmsize], m1 mova [dstq+2*lenq+2*mmsize], m2 mova [dstq+2*lenq+3*mmsize], m3 add lenq, 2*mmsize jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16P_TO_S16_2CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_S16P_TO_S16_2CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_s16p_to_s16_6ch(int16_t *dst, int16_t *const *src, int len, ; int channels); ;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------ ; NOTE: In the 6-channel functions, len could be used as an index on x86-64 ; instead of just a counter, which would avoid incrementing the ; pointers, but the extra complexity and amount of code is not worth ; the small gain. On x86-32 there are not enough registers to use len ; as an index without keeping two of the pointers on the stack and ; loading them in each iteration. ;------------------------------------------------------------------------------ %macro CONV_S16P_TO_S16_6CH 0 %if ARCH_X86_64 cglobal conv_s16p_to_s16_6ch, 3,8,7, dst, src0, len, src1, src2, src3, src4, src5 %else cglobal conv_s16p_to_s16_6ch, 2,7,7, dst, src0, src1, src2, src3, src4, src5 %define lend dword r2m %endif mov src1q, [src0q+1*gprsize] mov src2q, [src0q+2*gprsize] mov src3q, [src0q+3*gprsize] mov src4q, [src0q+4*gprsize] mov src5q, [src0q+5*gprsize] mov src0q, [src0q] sub src1q, src0q sub src2q, src0q sub src3q, src0q sub src4q, src0q sub src5q, src0q .loop: %if cpuflag(sse2slow) movq m0, [src0q ] ; m0 = 0, 6, 12, 18, x, x, x, x movq m1, [src0q+src1q] ; m1 = 1, 7, 13, 19, x, x, x, x movq m2, [src0q+src2q] ; m2 = 2, 8, 14, 20, x, x, x, x movq m3, [src0q+src3q] ; m3 = 3, 9, 15, 21, x, x, x, x movq m4, [src0q+src4q] ; m4 = 4, 10, 16, 22, x, x, x, x movq m5, [src0q+src5q] ; m5 = 5, 11, 17, 23, x, x, x, x ; unpack words: punpcklwd m0, m1 ; m0 = 0, 1, 6, 7, 12, 13, 18, 19 punpcklwd m2, m3 ; m2 = 4, 5, 10, 11, 16, 17, 22, 23 punpcklwd m4, m5 ; m4 = 2, 3, 8, 9, 14, 15, 20, 21 ; blend dwords shufps m1, m0, m2, q2020 ; m1 = 0, 1, 12, 13, 2, 3, 14, 15 shufps m0, m4, q2031 ; m0 = 6, 7, 18, 19, 4, 5, 16, 17 shufps m2, m4, q3131 ; m2 = 8, 9, 20, 21, 10, 11, 22, 23 ; shuffle dwords pshufd m0, m0, q1302 ; m0 = 4, 5, 6, 7, 16, 17, 18, 19 pshufd m1, m1, q3120 ; m1 = 0, 1, 2, 3, 12, 13, 14, 15 pshufd m2, m2, q3120 ; m2 = 8, 9, 10, 11, 20, 21, 22, 23 movq [dstq+0*mmsize/2], m1 movq [dstq+1*mmsize/2], m0 movq [dstq+2*mmsize/2], m2 movhps [dstq+3*mmsize/2], m1 movhps [dstq+4*mmsize/2], m0 movhps [dstq+5*mmsize/2], m2 add src0q, mmsize/2 add dstq, mmsize*3 sub lend, mmsize/4 %else mova m0, [src0q ] ; m0 = 0, 6, 12, 18, 24, 30, 36, 42 mova m1, [src0q+src1q] ; m1 = 1, 7, 13, 19, 25, 31, 37, 43 mova m2, [src0q+src2q] ; m2 = 2, 8, 14, 20, 26, 32, 38, 44 mova m3, [src0q+src3q] ; m3 = 3, 9, 15, 21, 27, 33, 39, 45 mova m4, [src0q+src4q] ; m4 = 4, 10, 16, 22, 28, 34, 40, 46 mova m5, [src0q+src5q] ; m5 = 5, 11, 17, 23, 29, 35, 41, 47 ; unpack words: SBUTTERFLY2 wd, 0, 1, 6 ; m0 = 0, 1, 6, 7, 12, 13, 18, 19 ; m1 = 24, 25, 30, 31, 36, 37, 42, 43 SBUTTERFLY2 wd, 2, 3, 6 ; m2 = 2, 3, 8, 9, 14, 15, 20, 21 ; m3 = 26, 27, 32, 33, 38, 39, 44, 45 SBUTTERFLY2 wd, 4, 5, 6 ; m4 = 4, 5, 10, 11, 16, 17, 22, 23 ; m5 = 28, 29, 34, 35, 40, 41, 46, 47 ; blend dwords shufps m6, m0, m2, q2020 ; m6 = 0, 1, 12, 13, 2, 3, 14, 15 shufps m0, m4, q2031 ; m0 = 6, 7, 18, 19, 4, 5, 16, 17 shufps m2, m4, q3131 ; m2 = 8, 9, 20, 21, 10, 11, 22, 23 SWAP 4,6 ; m4 = 0, 1, 12, 13, 2, 3, 14, 15 shufps m6, m1, m3, q2020 ; m6 = 24, 25, 36, 37, 26, 27, 38, 39 shufps m1, m5, q2031 ; m1 = 30, 31, 42, 43, 28, 29, 40, 41 shufps m3, m5, q3131 ; m3 = 32, 33, 44, 45, 34, 35, 46, 47 SWAP 5,6 ; m5 = 24, 25, 36, 37, 26, 27, 38, 39 ; shuffle dwords pshufd m0, m0, q1302 ; m0 = 4, 5, 6, 7, 16, 17, 18, 19 pshufd m2, m2, q3120 ; m2 = 8, 9, 10, 11, 20, 21, 22, 23 pshufd m4, m4, q3120 ; m4 = 0, 1, 2, 3, 12, 13, 14, 15 pshufd m1, m1, q1302 ; m1 = 28, 29, 30, 31, 40, 41, 42, 43 pshufd m3, m3, q3120 ; m3 = 32, 33, 34, 35, 44, 45, 46, 47 pshufd m5, m5, q3120 ; m5 = 24, 25, 26, 27, 36, 37, 38, 39 ; shuffle qwords punpcklqdq m6, m4, m0 ; m6 = 0, 1, 2, 3, 4, 5, 6, 7 punpckhqdq m0, m2 ; m0 = 16, 17, 18, 19, 20, 21, 22, 23 shufps m2, m4, q3210 ; m2 = 8, 9, 10, 11, 12, 13, 14, 15 SWAP 4,6 ; m4 = 0, 1, 2, 3, 4, 5, 6, 7 punpcklqdq m6, m5, m1 ; m6 = 24, 25, 26, 27, 28, 29, 30, 31 punpckhqdq m1, m3 ; m1 = 40, 41, 42, 43, 44, 45, 46, 47 shufps m3, m5, q3210 ; m3 = 32, 33, 34, 35, 36, 37, 38, 39 SWAP 5,6 ; m5 = 24, 25, 26, 27, 28, 29, 30, 31 mova [dstq+0*mmsize], m4 mova [dstq+1*mmsize], m2 mova [dstq+2*mmsize], m0 mova [dstq+3*mmsize], m5 mova [dstq+4*mmsize], m3 mova [dstq+5*mmsize], m1 add src0q, mmsize add dstq, mmsize*6 sub lend, mmsize/2 %endif jg .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16P_TO_S16_6CH INIT_XMM sse2slow CONV_S16P_TO_S16_6CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_S16P_TO_S16_6CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_s16p_to_flt_2ch(float *dst, int16_t *const *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_S16P_TO_FLT_2CH 0 cglobal conv_s16p_to_flt_2ch, 3,4,6, dst, src0, len, src1 lea lenq, [2*lend] mov src1q, [src0q+gprsize] mov src0q, [src0q ] lea dstq, [dstq+4*lenq] add src0q, lenq add src1q, lenq neg lenq mova m5, [pf_s32_inv_scale] .loop: mova m2, [src0q+lenq] ; m2 = 0, 2, 4, 6, 8, 10, 12, 14 mova m4, [src1q+lenq] ; m4 = 1, 3, 5, 7, 9, 11, 13, 15 SBUTTERFLY2 wd, 2, 4, 3 ; m2 = 0, 1, 2, 3, 4, 5, 6, 7 ; m4 = 8, 9, 10, 11, 12, 13, 14, 15 pxor m3, m3 punpcklwd m0, m3, m2 ; m0 = 0, 1, 2, 3 punpckhwd m1, m3, m2 ; m1 = 4, 5, 6, 7 punpcklwd m2, m3, m4 ; m2 = 8, 9, 10, 11 punpckhwd m3, m4 ; m3 = 12, 13, 14, 15 cvtdq2ps m0, m0 cvtdq2ps m1, m1 cvtdq2ps m2, m2 cvtdq2ps m3, m3 mulps m0, m5 mulps m1, m5 mulps m2, m5 mulps m3, m5 mova [dstq+4*lenq ], m0 mova [dstq+4*lenq+ mmsize], m1 mova [dstq+4*lenq+2*mmsize], m2 mova [dstq+4*lenq+3*mmsize], m3 add lenq, mmsize jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16P_TO_FLT_2CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_S16P_TO_FLT_2CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_s16p_to_flt_6ch(float *dst, int16_t *const *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_S16P_TO_FLT_6CH 0 %if ARCH_X86_64 cglobal conv_s16p_to_flt_6ch, 3,8,8, dst, src, len, src1, src2, src3, src4, src5 %else cglobal conv_s16p_to_flt_6ch, 2,7,8, dst, src, src1, src2, src3, src4, src5 %define lend dword r2m %endif mov src1q, [srcq+1*gprsize] mov src2q, [srcq+2*gprsize] mov src3q, [srcq+3*gprsize] mov src4q, [srcq+4*gprsize] mov src5q, [srcq+5*gprsize] mov srcq, [srcq] sub src1q, srcq sub src2q, srcq sub src3q, srcq sub src4q, srcq sub src5q, srcq mova m7, [pf_s32_inv_scale] %if cpuflag(ssse3) %define unpack_even m6 mova m6, [pb_shuf_unpack_even] %if ARCH_X86_64 %define unpack_odd m8 mova m8, [pb_shuf_unpack_odd] %else %define unpack_odd [pb_shuf_unpack_odd] %endif %endif .loop: movq m0, [srcq ] ; m0 = 0, 6, 12, 18, x, x, x, x movq m1, [srcq+src1q] ; m1 = 1, 7, 13, 19, x, x, x, x movq m2, [srcq+src2q] ; m2 = 2, 8, 14, 20, x, x, x, x movq m3, [srcq+src3q] ; m3 = 3, 9, 15, 21, x, x, x, x movq m4, [srcq+src4q] ; m4 = 4, 10, 16, 22, x, x, x, x movq m5, [srcq+src5q] ; m5 = 5, 11, 17, 23, x, x, x, x ; unpack words: punpcklwd m0, m1 ; m0 = 0, 1, 6, 7, 12, 13, 18, 19 punpcklwd m2, m3 ; m2 = 2, 3, 8, 9, 14, 15, 20, 21 punpcklwd m4, m5 ; m4 = 4, 5, 10, 11, 16, 17, 22, 23 ; blend dwords shufps m1, m4, m0, q3120 ; m1 = 4, 5, 16, 17, 6, 7, 18, 19 shufps m0, m2, q2020 ; m0 = 0, 1, 12, 13, 2, 3, 14, 15 shufps m2, m4, q3131 ; m2 = 8, 9, 20, 21, 10, 11, 22, 23 %if cpuflag(ssse3) pshufb m3, m0, unpack_odd ; m3 = 12, 13, 14, 15 pshufb m0, unpack_even ; m0 = 0, 1, 2, 3 pshufb m4, m1, unpack_odd ; m4 = 16, 17, 18, 19 pshufb m1, unpack_even ; m1 = 4, 5, 6, 7 pshufb m5, m2, unpack_odd ; m5 = 20, 21, 22, 23 pshufb m2, unpack_even ; m2 = 8, 9, 10, 11 %else ; shuffle dwords pshufd m0, m0, q3120 ; m0 = 0, 1, 2, 3, 12, 13, 14, 15 pshufd m1, m1, q3120 ; m1 = 4, 5, 6, 7, 16, 17, 18, 19 pshufd m2, m2, q3120 ; m2 = 8, 9, 10, 11, 20, 21, 22, 23 pxor m6, m6 ; convert s16 in m0-m2 to s32 in m0-m5 punpcklwd m3, m6, m0 ; m3 = 0, 1, 2, 3 punpckhwd m4, m6, m0 ; m4 = 12, 13, 14, 15 punpcklwd m0, m6, m1 ; m0 = 4, 5, 6, 7 punpckhwd m5, m6, m1 ; m5 = 16, 17, 18, 19 punpcklwd m1, m6, m2 ; m1 = 8, 9, 10, 11 punpckhwd m6, m2 ; m6 = 20, 21, 22, 23 SWAP 6,2,1,0,3,4,5 ; swap registers 3,0,1,4,5,6 to 0,1,2,3,4,5 %endif cvtdq2ps m0, m0 ; convert s32 to float cvtdq2ps m1, m1 cvtdq2ps m2, m2 cvtdq2ps m3, m3 cvtdq2ps m4, m4 cvtdq2ps m5, m5 mulps m0, m7 ; scale float from s32 range to [-1.0,1.0] mulps m1, m7 mulps m2, m7 mulps m3, m7 mulps m4, m7 mulps m5, m7 mova [dstq ], m0 mova [dstq+ mmsize], m1 mova [dstq+2*mmsize], m2 mova [dstq+3*mmsize], m3 mova [dstq+4*mmsize], m4 mova [dstq+5*mmsize], m5 add srcq, mmsize/2 add dstq, mmsize*6 sub lend, mmsize/4 jg .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16P_TO_FLT_6CH INIT_XMM ssse3 CONV_S16P_TO_FLT_6CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_S16P_TO_FLT_6CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_fltp_to_s16_2ch(int16_t *dst, float *const *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_FLTP_TO_S16_2CH 0 cglobal conv_fltp_to_s16_2ch, 3,4,3, dst, src0, len, src1 lea lenq, [4*lend] mov src1q, [src0q+gprsize] mov src0q, [src0q ] add dstq, lenq add src0q, lenq add src1q, lenq neg lenq mova m2, [pf_s16_scale] %if cpuflag(ssse3) mova m3, [pb_interleave_words] %endif .loop: mulps m0, m2, [src0q+lenq] ; m0 = 0, 2, 4, 6 mulps m1, m2, [src1q+lenq] ; m1 = 1, 3, 5, 7 cvtps2dq m0, m0 cvtps2dq m1, m1 %if cpuflag(ssse3) packssdw m0, m1 ; m0 = 0, 2, 4, 6, 1, 3, 5, 7 pshufb m0, m3 ; m0 = 0, 1, 2, 3, 4, 5, 6, 7 %else packssdw m0, m0 ; m0 = 0, 2, 4, 6, x, x, x, x packssdw m1, m1 ; m1 = 1, 3, 5, 7, x, x, x, x punpcklwd m0, m1 ; m0 = 0, 1, 2, 3, 4, 5, 6, 7 %endif mova [dstq+lenq], m0 add lenq, mmsize jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_FLTP_TO_S16_2CH INIT_XMM ssse3 CONV_FLTP_TO_S16_2CH ;------------------------------------------------------------------------------ ; void ff_conv_fltp_to_s16_6ch(int16_t *dst, float *const *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_FLTP_TO_S16_6CH 0 %if ARCH_X86_64 cglobal conv_fltp_to_s16_6ch, 3,8,7, dst, src, len, src1, src2, src3, src4, src5 %else cglobal conv_fltp_to_s16_6ch, 2,7,7, dst, src, src1, src2, src3, src4, src5 %define lend dword r2m %endif mov src1q, [srcq+1*gprsize] mov src2q, [srcq+2*gprsize] mov src3q, [srcq+3*gprsize] mov src4q, [srcq+4*gprsize] mov src5q, [srcq+5*gprsize] mov srcq, [srcq] sub src1q, srcq sub src2q, srcq sub src3q, srcq sub src4q, srcq sub src5q, srcq movaps xmm6, [pf_s16_scale] .loop: %if cpuflag(sse2) mulps m0, m6, [srcq ] mulps m1, m6, [srcq+src1q] mulps m2, m6, [srcq+src2q] mulps m3, m6, [srcq+src3q] mulps m4, m6, [srcq+src4q] mulps m5, m6, [srcq+src5q] cvtps2dq m0, m0 cvtps2dq m1, m1 cvtps2dq m2, m2 cvtps2dq m3, m3 cvtps2dq m4, m4 cvtps2dq m5, m5 packssdw m0, m3 ; m0 = 0, 6, 12, 18, 3, 9, 15, 21 packssdw m1, m4 ; m1 = 1, 7, 13, 19, 4, 10, 16, 22 packssdw m2, m5 ; m2 = 2, 8, 14, 20, 5, 11, 17, 23 ; unpack words: movhlps m3, m0 ; m3 = 3, 9, 15, 21, x, x, x, x punpcklwd m0, m1 ; m0 = 0, 1, 6, 7, 12, 13, 18, 19 punpckhwd m1, m2 ; m1 = 4, 5, 10, 11, 16, 17, 22, 23 punpcklwd m2, m3 ; m2 = 2, 3, 8, 9, 14, 15, 20, 21 ; blend dwords: shufps m3, m0, m2, q2020 ; m3 = 0, 1, 12, 13, 2, 3, 14, 15 shufps m0, m1, q2031 ; m0 = 6, 7, 18, 19, 4, 5, 16, 17 shufps m2, m1, q3131 ; m2 = 8, 9, 20, 21, 10, 11, 22, 23 ; shuffle dwords: shufps m1, m2, m3, q3120 ; m1 = 8, 9, 10, 11, 12, 13, 14, 15 shufps m3, m0, q0220 ; m3 = 0, 1, 2, 3, 4, 5, 6, 7 shufps m0, m2, q3113 ; m0 = 16, 17, 18, 19, 20, 21, 22, 23 mova [dstq+0*mmsize], m3 mova [dstq+1*mmsize], m1 mova [dstq+2*mmsize], m0 %else ; sse movlps xmm0, [srcq ] movlps xmm1, [srcq+src1q] movlps xmm2, [srcq+src2q] movlps xmm3, [srcq+src3q] movlps xmm4, [srcq+src4q] movlps xmm5, [srcq+src5q] mulps xmm0, xmm6 mulps xmm1, xmm6 mulps xmm2, xmm6 mulps xmm3, xmm6 mulps xmm4, xmm6 mulps xmm5, xmm6 cvtps2pi mm0, xmm0 cvtps2pi mm1, xmm1 cvtps2pi mm2, xmm2 cvtps2pi mm3, xmm3 cvtps2pi mm4, xmm4 cvtps2pi mm5, xmm5 packssdw mm0, mm3 ; m0 = 0, 6, 3, 9 packssdw mm1, mm4 ; m1 = 1, 7, 4, 10 packssdw mm2, mm5 ; m2 = 2, 8, 5, 11 ; unpack words pshufw mm3, mm0, q1032 ; m3 = 3, 9, 0, 6 punpcklwd mm0, mm1 ; m0 = 0, 1, 6, 7 punpckhwd mm1, mm2 ; m1 = 4, 5, 10, 11 punpcklwd mm2, mm3 ; m2 = 2, 3, 8, 9 ; unpack dwords pshufw mm3, mm0, q1032 ; m3 = 6, 7, 0, 1 punpckldq mm0, mm2 ; m0 = 0, 1, 2, 3 (final) punpckhdq mm2, mm1 ; m2 = 8, 9, 10, 11 (final) punpckldq mm1, mm3 ; m1 = 4, 5, 6, 7 (final) mova [dstq+0*mmsize], mm0 mova [dstq+1*mmsize], mm1 mova [dstq+2*mmsize], mm2 %endif add srcq, mmsize add dstq, mmsize*3 sub lend, mmsize/4 jg .loop %if mmsize == 8 emms RET %else REP_RET %endif %endmacro INIT_MMX sse CONV_FLTP_TO_S16_6CH INIT_XMM sse2 CONV_FLTP_TO_S16_6CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_FLTP_TO_S16_6CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_fltp_to_flt_2ch(float *dst, float *const *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_FLTP_TO_FLT_2CH 0 cglobal conv_fltp_to_flt_2ch, 3,4,5, dst, src0, len, src1 mov src1q, [src0q+gprsize] mov src0q, [src0q] lea lenq, [4*lend] add src0q, lenq add src1q, lenq lea dstq, [dstq+2*lenq] neg lenq .loop: mova m0, [src0q+lenq ] mova m1, [src1q+lenq ] mova m2, [src0q+lenq+mmsize] mova m3, [src1q+lenq+mmsize] SBUTTERFLYPS 0, 1, 4 SBUTTERFLYPS 2, 3, 4 mova [dstq+2*lenq+0*mmsize], m0 mova [dstq+2*lenq+1*mmsize], m1 mova [dstq+2*lenq+2*mmsize], m2 mova [dstq+2*lenq+3*mmsize], m3 add lenq, 2*mmsize jl .loop REP_RET %endmacro INIT_XMM sse CONV_FLTP_TO_FLT_2CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_FLTP_TO_FLT_2CH %endif ;----------------------------------------------------------------------------- ; void ff_conv_fltp_to_flt_6ch(float *dst, float *const *src, int len, ; int channels); ;----------------------------------------------------------------------------- %macro CONV_FLTP_TO_FLT_6CH 0 cglobal conv_fltp_to_flt_6ch, 2,8,7, dst, src, src1, src2, src3, src4, src5, len %if ARCH_X86_64 mov lend, r2d %else %define lend dword r2m %endif mov src1q, [srcq+1*gprsize] mov src2q, [srcq+2*gprsize] mov src3q, [srcq+3*gprsize] mov src4q, [srcq+4*gprsize] mov src5q, [srcq+5*gprsize] mov srcq, [srcq] sub src1q, srcq sub src2q, srcq sub src3q, srcq sub src4q, srcq sub src5q, srcq .loop: mova m0, [srcq ] mova m1, [srcq+src1q] mova m2, [srcq+src2q] mova m3, [srcq+src3q] mova m4, [srcq+src4q] mova m5, [srcq+src5q] %if cpuflag(sse4) SBUTTERFLYPS 0, 1, 6 SBUTTERFLYPS 2, 3, 6 SBUTTERFLYPS 4, 5, 6 blendps m6, m4, m0, 1100b movlhps m0, m2 movhlps m4, m2 blendps m2, m5, m1, 1100b movlhps m1, m3 movhlps m5, m3 movaps [dstq ], m0 movaps [dstq+16], m6 movaps [dstq+32], m4 movaps [dstq+48], m1 movaps [dstq+64], m2 movaps [dstq+80], m5 %else ; mmx SBUTTERFLY dq, 0, 1, 6 SBUTTERFLY dq, 2, 3, 6 SBUTTERFLY dq, 4, 5, 6 movq [dstq ], m0 movq [dstq+ 8], m2 movq [dstq+16], m4 movq [dstq+24], m1 movq [dstq+32], m3 movq [dstq+40], m5 %endif add srcq, mmsize add dstq, mmsize*6 sub lend, mmsize/4 jg .loop %if mmsize == 8 emms RET %else REP_RET %endif %endmacro INIT_MMX mmx CONV_FLTP_TO_FLT_6CH INIT_XMM sse4 CONV_FLTP_TO_FLT_6CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_FLTP_TO_FLT_6CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_s16_to_s16p_2ch(int16_t *const *dst, int16_t *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_S16_TO_S16P_2CH 0 cglobal conv_s16_to_s16p_2ch, 3,4,4, dst0, src, len, dst1 lea lenq, [2*lend] mov dst1q, [dst0q+gprsize] mov dst0q, [dst0q ] lea srcq, [srcq+2*lenq] add dst0q, lenq add dst1q, lenq neg lenq %if cpuflag(ssse3) mova m3, [pb_deinterleave_words] %endif .loop: mova m0, [srcq+2*lenq ] ; m0 = 0, 1, 2, 3, 4, 5, 6, 7 mova m1, [srcq+2*lenq+mmsize] ; m1 = 8, 9, 10, 11, 12, 13, 14, 15 %if cpuflag(ssse3) pshufb m0, m3 ; m0 = 0, 2, 4, 6, 1, 3, 5, 7 pshufb m1, m3 ; m1 = 8, 10, 12, 14, 9, 11, 13, 15 SBUTTERFLY2 qdq, 0, 1, 2 ; m0 = 0, 2, 4, 6, 8, 10, 12, 14 ; m1 = 1, 3, 5, 7, 9, 11, 13, 15 %else ; sse2 pshuflw m0, m0, q3120 ; m0 = 0, 2, 1, 3, 4, 5, 6, 7 pshufhw m0, m0, q3120 ; m0 = 0, 2, 1, 3, 4, 6, 5, 7 pshuflw m1, m1, q3120 ; m1 = 8, 10, 9, 11, 12, 13, 14, 15 pshufhw m1, m1, q3120 ; m1 = 8, 10, 9, 11, 12, 14, 13, 15 DEINT2_PS 0, 1, 2 ; m0 = 0, 2, 4, 6, 8, 10, 12, 14 ; m1 = 1, 3, 5, 7, 9, 11, 13, 15 %endif mova [dst0q+lenq], m0 mova [dst1q+lenq], m1 add lenq, mmsize jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16_TO_S16P_2CH INIT_XMM ssse3 CONV_S16_TO_S16P_2CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_S16_TO_S16P_2CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_s16_to_s16p_6ch(int16_t *const *dst, int16_t *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_S16_TO_S16P_6CH 0 %if ARCH_X86_64 cglobal conv_s16_to_s16p_6ch, 3,8,5, dst, src, len, dst1, dst2, dst3, dst4, dst5 %else cglobal conv_s16_to_s16p_6ch, 2,7,5, dst, src, dst1, dst2, dst3, dst4, dst5 %define lend dword r2m %endif mov dst1q, [dstq+ gprsize] mov dst2q, [dstq+2*gprsize] mov dst3q, [dstq+3*gprsize] mov dst4q, [dstq+4*gprsize] mov dst5q, [dstq+5*gprsize] mov dstq, [dstq ] sub dst1q, dstq sub dst2q, dstq sub dst3q, dstq sub dst4q, dstq sub dst5q, dstq .loop: mova m0, [srcq+0*mmsize] ; m0 = 0, 1, 2, 3, 4, 5, 6, 7 mova m3, [srcq+1*mmsize] ; m3 = 8, 9, 10, 11, 12, 13, 14, 15 mova m2, [srcq+2*mmsize] ; m2 = 16, 17, 18, 19, 20, 21, 22, 23 PALIGNR m1, m3, m0, 12, m4 ; m1 = 6, 7, 8, 9, 10, 11, x, x shufps m3, m2, q1032 ; m3 = 12, 13, 14, 15, 16, 17, 18, 19 psrldq m2, 4 ; m2 = 18, 19, 20, 21, 22, 23, x, x SBUTTERFLY2 wd, 0, 1, 4 ; m0 = 0, 6, 1, 7, 2, 8, 3, 9 ; m1 = 4, 10, 5, 11, x, x, x, x SBUTTERFLY2 wd, 3, 2, 4 ; m3 = 12, 18, 13, 19, 14, 20, 15, 21 ; m2 = 16, 22, 17, 23, x, x, x, x SBUTTERFLY2 dq, 0, 3, 4 ; m0 = 0, 6, 12, 18, 1, 7, 13, 19 ; m3 = 2, 8, 14, 20, 3, 9, 15, 21 punpckldq m1, m2 ; m1 = 4, 10, 16, 22, 5, 11, 17, 23 movq [dstq ], m0 movhps [dstq+dst1q], m0 movq [dstq+dst2q], m3 movhps [dstq+dst3q], m3 movq [dstq+dst4q], m1 movhps [dstq+dst5q], m1 add srcq, mmsize*3 add dstq, mmsize/2 sub lend, mmsize/4 jg .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16_TO_S16P_6CH INIT_XMM ssse3 CONV_S16_TO_S16P_6CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_S16_TO_S16P_6CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_s16_to_fltp_2ch(float *const *dst, int16_t *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_S16_TO_FLTP_2CH 0 cglobal conv_s16_to_fltp_2ch, 3,4,5, dst0, src, len, dst1 lea lenq, [4*lend] mov dst1q, [dst0q+gprsize] mov dst0q, [dst0q ] add srcq, lenq add dst0q, lenq add dst1q, lenq neg lenq mova m3, [pf_s32_inv_scale] mova m4, [pw_zero_even] .loop: mova m1, [srcq+lenq] pslld m0, m1, 16 pand m1, m4 cvtdq2ps m0, m0 cvtdq2ps m1, m1 mulps m0, m0, m3 mulps m1, m1, m3 mova [dst0q+lenq], m0 mova [dst1q+lenq], m1 add lenq, mmsize jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16_TO_FLTP_2CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_S16_TO_FLTP_2CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_s16_to_fltp_6ch(float *const *dst, int16_t *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_S16_TO_FLTP_6CH 0 %if ARCH_X86_64 cglobal conv_s16_to_fltp_6ch, 3,8,7, dst, src, len, dst1, dst2, dst3, dst4, dst5 %else cglobal conv_s16_to_fltp_6ch, 2,7,7, dst, src, dst1, dst2, dst3, dst4, dst5 %define lend dword r2m %endif mov dst1q, [dstq+ gprsize] mov dst2q, [dstq+2*gprsize] mov dst3q, [dstq+3*gprsize] mov dst4q, [dstq+4*gprsize] mov dst5q, [dstq+5*gprsize] mov dstq, [dstq ] sub dst1q, dstq sub dst2q, dstq sub dst3q, dstq sub dst4q, dstq sub dst5q, dstq mova m6, [pf_s16_inv_scale] .loop: mova m0, [srcq+0*mmsize] ; m0 = 0, 1, 2, 3, 4, 5, 6, 7 mova m3, [srcq+1*mmsize] ; m3 = 8, 9, 10, 11, 12, 13, 14, 15 mova m2, [srcq+2*mmsize] ; m2 = 16, 17, 18, 19, 20, 21, 22, 23 PALIGNR m1, m3, m0, 12, m4 ; m1 = 6, 7, 8, 9, 10, 11, x, x shufps m3, m2, q1032 ; m3 = 12, 13, 14, 15, 16, 17, 18, 19 psrldq m2, 4 ; m2 = 18, 19, 20, 21, 22, 23, x, x SBUTTERFLY2 wd, 0, 1, 4 ; m0 = 0, 6, 1, 7, 2, 8, 3, 9 ; m1 = 4, 10, 5, 11, x, x, x, x SBUTTERFLY2 wd, 3, 2, 4 ; m3 = 12, 18, 13, 19, 14, 20, 15, 21 ; m2 = 16, 22, 17, 23, x, x, x, x SBUTTERFLY2 dq, 0, 3, 4 ; m0 = 0, 6, 12, 18, 1, 7, 13, 19 ; m3 = 2, 8, 14, 20, 3, 9, 15, 21 punpckldq m1, m2 ; m1 = 4, 10, 16, 22, 5, 11, 17, 23 S16_TO_S32_SX 0, 2 ; m0 = 0, 6, 12, 18 ; m2 = 1, 7, 13, 19 S16_TO_S32_SX 3, 4 ; m3 = 2, 8, 14, 20 ; m4 = 3, 9, 15, 21 S16_TO_S32_SX 1, 5 ; m1 = 4, 10, 16, 22 ; m5 = 5, 11, 17, 23 SWAP 1,2,3,4 cvtdq2ps m0, m0 cvtdq2ps m1, m1 cvtdq2ps m2, m2 cvtdq2ps m3, m3 cvtdq2ps m4, m4 cvtdq2ps m5, m5 mulps m0, m6 mulps m1, m6 mulps m2, m6 mulps m3, m6 mulps m4, m6 mulps m5, m6 mova [dstq ], m0 mova [dstq+dst1q], m1 mova [dstq+dst2q], m2 mova [dstq+dst3q], m3 mova [dstq+dst4q], m4 mova [dstq+dst5q], m5 add srcq, mmsize*3 add dstq, mmsize sub lend, mmsize/4 jg .loop REP_RET %endmacro INIT_XMM sse2 CONV_S16_TO_FLTP_6CH INIT_XMM ssse3 CONV_S16_TO_FLTP_6CH INIT_XMM sse4 CONV_S16_TO_FLTP_6CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_S16_TO_FLTP_6CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_flt_to_s16p_2ch(int16_t *const *dst, float *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_FLT_TO_S16P_2CH 0 cglobal conv_flt_to_s16p_2ch, 3,4,6, dst0, src, len, dst1 lea lenq, [2*lend] mov dst1q, [dst0q+gprsize] mov dst0q, [dst0q ] lea srcq, [srcq+4*lenq] add dst0q, lenq add dst1q, lenq neg lenq mova m5, [pf_s16_scale] .loop: mova m0, [srcq+4*lenq ] mova m1, [srcq+4*lenq+ mmsize] mova m2, [srcq+4*lenq+2*mmsize] mova m3, [srcq+4*lenq+3*mmsize] DEINT2_PS 0, 1, 4 DEINT2_PS 2, 3, 4 mulps m0, m0, m5 mulps m1, m1, m5 mulps m2, m2, m5 mulps m3, m3, m5 cvtps2dq m0, m0 cvtps2dq m1, m1 cvtps2dq m2, m2 cvtps2dq m3, m3 packssdw m0, m2 packssdw m1, m3 mova [dst0q+lenq], m0 mova [dst1q+lenq], m1 add lenq, mmsize jl .loop REP_RET %endmacro INIT_XMM sse2 CONV_FLT_TO_S16P_2CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_FLT_TO_S16P_2CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_flt_to_s16p_6ch(int16_t *const *dst, float *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_FLT_TO_S16P_6CH 0 %if ARCH_X86_64 cglobal conv_flt_to_s16p_6ch, 3,8,7, dst, src, len, dst1, dst2, dst3, dst4, dst5 %else cglobal conv_flt_to_s16p_6ch, 2,7,7, dst, src, dst1, dst2, dst3, dst4, dst5 %define lend dword r2m %endif mov dst1q, [dstq+ gprsize] mov dst2q, [dstq+2*gprsize] mov dst3q, [dstq+3*gprsize] mov dst4q, [dstq+4*gprsize] mov dst5q, [dstq+5*gprsize] mov dstq, [dstq ] sub dst1q, dstq sub dst2q, dstq sub dst3q, dstq sub dst4q, dstq sub dst5q, dstq mova m6, [pf_s16_scale] .loop: mulps m0, m6, [srcq+0*mmsize] mulps m3, m6, [srcq+1*mmsize] mulps m1, m6, [srcq+2*mmsize] mulps m4, m6, [srcq+3*mmsize] mulps m2, m6, [srcq+4*mmsize] mulps m5, m6, [srcq+5*mmsize] cvtps2dq m0, m0 cvtps2dq m1, m1 cvtps2dq m2, m2 cvtps2dq m3, m3 cvtps2dq m4, m4 cvtps2dq m5, m5 packssdw m0, m3 ; m0 = 0, 1, 2, 3, 4, 5, 6, 7 packssdw m1, m4 ; m1 = 8, 9, 10, 11, 12, 13, 14, 15 packssdw m2, m5 ; m2 = 16, 17, 18, 19, 20, 21, 22, 23 PALIGNR m3, m1, m0, 12, m4 ; m3 = 6, 7, 8, 9, 10, 11, x, x shufps m1, m2, q1032 ; m1 = 12, 13, 14, 15, 16, 17, 18, 19 psrldq m2, 4 ; m2 = 18, 19, 20, 21, 22, 23, x, x SBUTTERFLY2 wd, 0, 3, 4 ; m0 = 0, 6, 1, 7, 2, 8, 3, 9 ; m3 = 4, 10, 5, 11, x, x, x, x SBUTTERFLY2 wd, 1, 2, 4 ; m1 = 12, 18, 13, 19, 14, 20, 15, 21 ; m2 = 16, 22, 17, 23, x, x, x, x SBUTTERFLY2 dq, 0, 1, 4 ; m0 = 0, 6, 12, 18, 1, 7, 13, 19 ; m1 = 2, 8, 14, 20, 3, 9, 15, 21 punpckldq m3, m2 ; m3 = 4, 10, 16, 22, 5, 11, 17, 23 movq [dstq ], m0 movhps [dstq+dst1q], m0 movq [dstq+dst2q], m1 movhps [dstq+dst3q], m1 movq [dstq+dst4q], m3 movhps [dstq+dst5q], m3 add srcq, mmsize*6 add dstq, mmsize/2 sub lend, mmsize/4 jg .loop REP_RET %endmacro INIT_XMM sse2 CONV_FLT_TO_S16P_6CH INIT_XMM ssse3 CONV_FLT_TO_S16P_6CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_FLT_TO_S16P_6CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_flt_to_fltp_2ch(float *const *dst, float *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_FLT_TO_FLTP_2CH 0 cglobal conv_flt_to_fltp_2ch, 3,4,3, dst0, src, len, dst1 lea lenq, [4*lend] mov dst1q, [dst0q+gprsize] mov dst0q, [dst0q ] lea srcq, [srcq+2*lenq] add dst0q, lenq add dst1q, lenq neg lenq .loop: mova m0, [srcq+2*lenq ] mova m1, [srcq+2*lenq+mmsize] DEINT2_PS 0, 1, 2 mova [dst0q+lenq], m0 mova [dst1q+lenq], m1 add lenq, mmsize jl .loop REP_RET %endmacro INIT_XMM sse CONV_FLT_TO_FLTP_2CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_FLT_TO_FLTP_2CH %endif ;------------------------------------------------------------------------------ ; void ff_conv_flt_to_fltp_6ch(float *const *dst, float *src, int len, ; int channels); ;------------------------------------------------------------------------------ %macro CONV_FLT_TO_FLTP_6CH 0 %if ARCH_X86_64 cglobal conv_flt_to_fltp_6ch, 3,8,7, dst, src, len, dst1, dst2, dst3, dst4, dst5 %else cglobal conv_flt_to_fltp_6ch, 2,7,7, dst, src, dst1, dst2, dst3, dst4, dst5 %define lend dword r2m %endif mov dst1q, [dstq+ gprsize] mov dst2q, [dstq+2*gprsize] mov dst3q, [dstq+3*gprsize] mov dst4q, [dstq+4*gprsize] mov dst5q, [dstq+5*gprsize] mov dstq, [dstq ] sub dst1q, dstq sub dst2q, dstq sub dst3q, dstq sub dst4q, dstq sub dst5q, dstq .loop: mova m0, [srcq+0*mmsize] ; m0 = 0, 1, 2, 3 mova m1, [srcq+1*mmsize] ; m1 = 4, 5, 6, 7 mova m2, [srcq+2*mmsize] ; m2 = 8, 9, 10, 11 mova m3, [srcq+3*mmsize] ; m3 = 12, 13, 14, 15 mova m4, [srcq+4*mmsize] ; m4 = 16, 17, 18, 19 mova m5, [srcq+5*mmsize] ; m5 = 20, 21, 22, 23 SBUTTERFLY2 dq, 0, 3, 6 ; m0 = 0, 12, 1, 13 ; m3 = 2, 14, 3, 15 SBUTTERFLY2 dq, 1, 4, 6 ; m1 = 4, 16, 5, 17 ; m4 = 6, 18, 7, 19 SBUTTERFLY2 dq, 2, 5, 6 ; m2 = 8, 20, 9, 21 ; m5 = 10, 22, 11, 23 SBUTTERFLY2 dq, 0, 4, 6 ; m0 = 0, 6, 12, 18 ; m4 = 1, 7, 13, 19 SBUTTERFLY2 dq, 3, 2, 6 ; m3 = 2, 8, 14, 20 ; m2 = 3, 9, 15, 21 SBUTTERFLY2 dq, 1, 5, 6 ; m1 = 4, 10, 16, 22 ; m5 = 5, 11, 17, 23 mova [dstq ], m0 mova [dstq+dst1q], m4 mova [dstq+dst2q], m3 mova [dstq+dst3q], m2 mova [dstq+dst4q], m1 mova [dstq+dst5q], m5 add srcq, mmsize*6 add dstq, mmsize sub lend, mmsize/4 jg .loop REP_RET %endmacro INIT_XMM sse2 CONV_FLT_TO_FLTP_6CH %if HAVE_AVX_EXTERNAL INIT_XMM avx CONV_FLT_TO_FLTP_6CH %endif
; ; ; ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. ; ; Copyright 2007-2019 Broadcom Inc. All rights reserved. ; ; ; This is the default program for Greyhound SKUs: ; BCM534x6 Option2, BCM534x6 Option3 ; ; To start it, use the following commands from BCM: ; ; led load gh_sdk53406_opt2.hex ; led auto on ; led start ; ; Assume 1 LED per port for Link. And 2 bits stream per LED. ; Link-Down = Off (b'00) ; Link-Up = On (b'01) ; ; Totally 12 ports/LEDs will be outputed. ; ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED ; processor does not always have access to link status. This program ; assumes link status is kept current in bit 0 of RAM byte (0xA0 + portnum). ; Generally, a program running on the main CPU must update these ; locations on link change; see linkscan callback in ; $SDK/src/appl/diag/ledproc.c. ; ; ; Constants ; NUM_PORTS equ 12 MIN_PORT_0 equ 2 MAX_PORT_0 equ 2 MIN_PORT_1 equ 18 MAX_PORT_1 equ 18 MIN_PORT_2 equ 22 MAX_PORT_2 equ 22 MIN_PORT_3 equ 26 MAX_PORT_3 equ 26 MIN_PORT_4 equ 30 MAX_PORT_4 equ 37 ; ; LED process ; start: ld a, MIN_PORT_0 iter_sec0: cmp a, MAX_PORT_0+1 jnc iter_sec1 cmp a, MIN_PORT_0 jz iter_sec0_init jc iter_sec0_init jmp iter_sec0_start iter_sec0_init: ld a, MIN_PORT_0 ld b, MAX_PORT_0 ld (SEC_MAX), b iter_sec0_start: jmp iter_common iter_sec1: cmp a, MAX_PORT_1+1 jnc iter_sec2 cmp a, MIN_PORT_1 jz iter_sec1_init jc iter_sec1_init jmp iter_sec1_start iter_sec1_init: ld a, MIN_PORT_1 ld b, MAX_PORT_1 ld (SEC_MAX), b iter_sec1_start: jmp iter_common iter_sec2: cmp a, MAX_PORT_2+1 jnc iter_sec3 cmp a, MIN_PORT_2 jz iter_sec2_init jc iter_sec2_init jmp iter_sec2_start iter_sec2_init: ld a, MIN_PORT_2 ld b, MAX_PORT_2 ld (SEC_MAX), b iter_sec2_start: jmp iter_common iter_sec3: cmp a, MAX_PORT_3+1 jnc iter_sec4 cmp a, MIN_PORT_3 jz iter_sec3_init jc iter_sec3_init jmp iter_sec3_start iter_sec3_init: ld a, MIN_PORT_3 ld b, MAX_PORT_3 ld (SEC_MAX), b iter_sec3_start: jmp iter_common iter_sec4: cmp a, MAX_PORT_4+1 jnc end cmp a, MIN_PORT_4 jz iter_sec4_init jc iter_sec4_init jmp iter_sec4_start iter_sec4_init: ld a, MIN_PORT_4 ld b, MAX_PORT_4 ld (SEC_MAX), b iter_sec4_start: jmp iter_common iter_common: port a ld (PORT_NUM), a call get_link ld a, (PORT_NUM) inc a ld b, (SEC_MAX) inc b cmp a, b jz iter_sec0 jmp iter_common end: send 2*NUM_PORTS ; ; get_link ; ; This routine finds the link status LED for a port. ; Link info is in bit 0 of the byte read from PORTDATA[port] ; Inputs: (PORT_NUM) ; Outputs: Carry flag set if link is up, clear if link is down. ; Destroys: a, b get_link: ld b, PORTDATA add b, (PORT_NUM) ld a, (b) tst a, 0 jc led_green jmp led_black ; ; led_green ; ; Outputs: Bits to the LED stream indicating ON ; led_green: push 0 pack push 1 pack ret ; ; led_black ; ; Outputs: Bits to the LED stream indicating OFF ; led_black: push 0 pack push 0 pack ret ; Variables (SDK software initializes LED memory from 0xA0-0xff to 0) PORTDATA equ 0xA0 PORT_NUM equ 0xE0 SEC_MAX equ 0xE1 ; Symbolic names for the bits of the port status fields RX equ 0x0 ; received packet TX equ 0x1 ; transmitted packet COLL equ 0x2 ; collision indicator SPEED_C equ 0x3 ; 100 Mbps SPEED_M equ 0x4 ; 1000 Mbps DUPLEX equ 0x5 ; half/full duplex FLOW equ 0x6 ; flow control capable LINKUP equ 0x7 ; link down/up status LINKEN equ 0x8 ; link disabled/enabled status ZERO equ 0xE ; always 0 ONE equ 0xF ; always 1
; int tape_load_block(void *addr, size_t len, unsigned char type) ; CALLER linkage for function pointers PUBLIC tape_load_block EXTERN tape_load_block_callee EXTERN ASMDISP_TAPE_LOAD_BLOCK_CALLEE .tape_load_block pop ix pop bc pop de pop hl push hl push de push bc push ix jp tape_load_block_callee + ASMDISP_TAPE_LOAD_BLOCK_CALLEE
; ================================================================== ; MATH ROUTINES ; ================================================================== ; ------------------------------------------------------------------ ; os_seed_random -- Seed the random number generator based on clock ; IN: Nothing; OUT: Nothing (registers preserved) os_seed_random: pusha mov ah, 02h int 1Ah mov dl, cl ; Move the minutes into DL (seconds are already in DH) mov word [os_random_seed], dx ; Store the data popa ret os_random_seed dw 0 ; ------------------------------------------------------------------ ; os_get_random -- Return a random integer between low and high (inclusive) ; IN: AX = low integer, BX = high integer ; OUT: CX = random integer os_get_random: push dx push bx push ax sub bx, ax ; We want a number between 0 and (high-low) call .generate_random mov dx, bx add dx, 1 mul dx mov cx, dx pop ax pop bx pop dx add cx, ax ; Add the low offset back ret .generate_random: push dx push bx mov ax, [os_random_seed] mov dx, 0x7383 ; The magic number (random.org) mul dx ; DX:AX = AX * DX mov [os_random_seed], ax pop bx pop dx ret ; ------------------------------------------------------------------ ; os_bcd_to_int -- Converts binary coded decimal number to an integer ; IN: AL = BCD number; OUT: AX = integer value os_bcd_to_int: pusha mov bl, al ; Store entire number for now and ax, 0Fh ; Zero-out high bits mov cx, ax ; CH/CL = lower BCD number, zero extended shr bl, 4 ; Move higher BCD number into lower bits, zero fill msb mov al, 10 mul bl ; AX = 10 * BL add ax, cx ; Add lower BCD to 10*higher mov [.tmp], ax popa mov ax, [.tmp] ; And return it in AX! ret .tmp dw 0 ; Calculates EAX^EBX. ; IN: EAX^EBX = input ; OUT: EAX = result os_math_power: pushad cmp ebx, 1 je near .power_end cmp ebx, 0 je near .zero mov ecx, ebx ; Prepare the data mov ebx, eax .power_loop: mul ebx dec ecx cmp ecx, 1 jnle .power_loop .power_end: mov [.tmp_dword], eax popad mov eax, [.tmp_dword] mov edx, 0 ret .zero: popad mov eax, 1 mov edx, 0 ret .tmp_dword dd 0 .tmp_dword2 dd 0 ; Calculates the EBX root of EAX. ; IN: EAX = input, EBX = root ; OUT: EAX(EDX = 0) = result; EAX to EDX = range os_math_root: pushad mov ecx, eax ; Prepare the data mov esi, 2 .root_loop: mov eax, esi call os_math_power cmp eax, ecx je near .root_exact jg near .root_range inc esi jmp .root_loop .root_exact: mov [.tmp_dword], esi popad mov eax, [.tmp_dword] mov edx, 0 ret .root_range: mov [.tmp_dword2], esi dec esi mov [.tmp_dword], esi popad mov eax, [.tmp_dword] mov edx, [.tmp_dword2] ret .tmp_dword dd 0 .tmp_dword2 dd 0 ; ==================================================================
#include "TP_Type.h" #include "third-party/fmt/core.h" namespace decompiler { u32 regs_to_gpr_mask(const std::vector<Register>& regs) { u32 result = 0; for (const auto& reg : regs) { if (reg.get_kind() == Reg::GPR) { result |= (1 << reg.get_gpr()); } } return result; } std::string TypeState::print_gpr_masked(u32 mask) const { std::string result; for (int i = 0; i < 32; i++) { if (mask & (1 << i)) { result += Register(Reg::GPR, i).to_charp(); result += ": "; result += gpr_types[i].print(); result += " "; } } return result; } std::string TP_Type::print() const { switch (kind) { case Kind::TYPESPEC: return m_ts.print(); case Kind::TYPE_OF_TYPE_OR_CHILD: return fmt::format("<the type {}>", m_ts.print()); case Kind::TYPE_OF_TYPE_NO_VIRTUAL: return fmt::format("<the etype {}>", m_ts.print()); case Kind::FALSE_AS_NULL: return fmt::format("'#f"); case Kind::UNINITIALIZED: return fmt::format("<uninitialized>"); case Kind::PRODUCT_WITH_CONSTANT: return fmt::format("<value x {}>", m_int); case Kind::OBJECT_PLUS_PRODUCT_WITH_CONSTANT: return fmt::format("<{} + (value x {})>", m_ts.print(), m_int); case Kind::OBJECT_NEW_METHOD: return fmt::format("<(object-new) for {}>", m_ts.print()); case Kind::STRING_CONSTANT: return fmt::format("<string \"{}\">", m_str); case Kind::FORMAT_STRING: return fmt::format("<string with {} args>", m_int); case Kind::INTEGER_CONSTANT: return fmt::format("<integer {}>", m_int); case Kind::INTEGER_CONSTANT_PLUS_VAR: return fmt::format("<integer {} + {}>", m_int, m_ts.print()); case Kind::INTEGER_CONSTANT_PLUS_VAR_MULT: return fmt::format("<integer {} + ({} x {})>", m_int, m_extra_multiplier, m_ts.print()); case Kind::DYNAMIC_METHOD_ACCESS: return fmt::format("<dynamic-method-access>"); case Kind::VIRTUAL_METHOD: return fmt::format("<vmethod {}>", m_ts.print()); case Kind::NON_VIRTUAL_METHOD: return fmt::format("<method {}>", m_ts.print()); case Kind::LEFT_SHIFTED_BITFIELD: if (m_pcpyud) { return fmt::format("(<{}> << {}) :u", m_ts.print(), m_int); } else { return fmt::format("(<{}> << {})", m_ts.print(), m_int); } case Kind::PCPYUD_BITFIELD: return fmt::format("<pcpyud {}>", m_ts.print()); case Kind::PCPYUD_BITFIELD_AND: return fmt::format("<pcpyud-and {}>", m_ts.print()); case Kind::LABEL_ADDR: return "<label-addr>"; case Kind::ENTER_STATE_FUNCTION: return "<enter-state-func>"; case Kind::INVALID: default: assert(false); return {}; } } bool TP_Type::operator==(const TP_Type& other) const { if (kind != other.kind) { return false; } switch (kind) { case Kind::TYPESPEC: return m_ts == other.m_ts; case Kind::TYPE_OF_TYPE_OR_CHILD: return m_ts == other.m_ts; case Kind::TYPE_OF_TYPE_NO_VIRTUAL: return m_ts == other.m_ts; case Kind::VIRTUAL_METHOD: return m_ts == other.m_ts; case Kind::NON_VIRTUAL_METHOD: return m_ts == other.m_ts; case Kind::FALSE_AS_NULL: return true; case Kind::UNINITIALIZED: return true; case Kind::PRODUCT_WITH_CONSTANT: return m_int == other.m_int; case Kind::OBJECT_PLUS_PRODUCT_WITH_CONSTANT: return m_ts == other.m_ts && m_int == other.m_int; case Kind::OBJECT_NEW_METHOD: return m_ts == other.m_ts; case Kind::STRING_CONSTANT: return m_str == other.m_str; case Kind::INTEGER_CONSTANT: return m_int == other.m_int; case Kind::FORMAT_STRING: return m_int == other.m_int; case Kind::INTEGER_CONSTANT_PLUS_VAR: return m_int == other.m_int && m_ts == other.m_ts; case Kind::DYNAMIC_METHOD_ACCESS: return true; case Kind::INTEGER_CONSTANT_PLUS_VAR_MULT: return m_int == other.m_int && m_ts == other.m_ts && m_extra_multiplier == other.m_extra_multiplier; case Kind::LEFT_SHIFTED_BITFIELD: return m_int == other.m_int && m_ts == other.m_ts && m_pcpyud == other.m_pcpyud; case Kind::PCPYUD_BITFIELD: return m_pcpyud == other.m_pcpyud && m_ts == other.m_ts; case Kind::PCPYUD_BITFIELD_AND: return m_pcpyud == other.m_pcpyud && m_ts == other.m_ts; case Kind::LABEL_ADDR: case Kind::ENTER_STATE_FUNCTION: return true; case Kind::INVALID: default: assert(false); return false; } } bool TP_Type::operator!=(const TP_Type& other) const { return !((*this) == other); } TypeSpec TP_Type::typespec() const { switch (kind) { case Kind::TYPESPEC: return m_ts; case Kind::TYPE_OF_TYPE_OR_CHILD: case Kind::TYPE_OF_TYPE_NO_VIRTUAL: return TypeSpec("type"); case Kind::FALSE_AS_NULL: return TypeSpec("symbol"); case Kind::UNINITIALIZED: return TypeSpec("none"); case Kind::PRODUCT_WITH_CONSTANT: return m_ts; case Kind::OBJECT_PLUS_PRODUCT_WITH_CONSTANT: if (m_ts.base_type() == "pointer") { return m_ts; } // this can be part of an array access, so we don't really know the type. // probably not a good idea to try to do anything with this as a typespec // so let's be very vague return TypeSpec("int"); case Kind::OBJECT_NEW_METHOD: // similar to previous case, being more vague than we need to be because we don't // want to assume the return type incorrectly and you shouldn't try to do anything with // this as a typespec. return TypeSpec("function"); case Kind::STRING_CONSTANT: return TypeSpec("string"); case Kind::INTEGER_CONSTANT: return TypeSpec("int"); case Kind::INTEGER_CONSTANT_PLUS_VAR: case Kind::INTEGER_CONSTANT_PLUS_VAR_MULT: return m_ts; case Kind::DYNAMIC_METHOD_ACCESS: return TypeSpec("object"); case Kind::FORMAT_STRING: return TypeSpec("string"); case Kind::VIRTUAL_METHOD: return m_ts; case Kind::NON_VIRTUAL_METHOD: return m_ts; case Kind::LEFT_SHIFTED_BITFIELD: return TypeSpec("int"); // ideally this is never used. case Kind::PCPYUD_BITFIELD: return TypeSpec("int"); case Kind::PCPYUD_BITFIELD_AND: return TypeSpec("int"); case Kind::LABEL_ADDR: return TypeSpec("pointer"); // ? case Kind::ENTER_STATE_FUNCTION: // give a general function so we can't call it normally. return TypeSpec("function"); case Kind::INVALID: default: assert(false); return {}; } } } // namespace decompiler
; A021800: Decimal expansion of 1/796. ; Submitted by Jon Maiga ; 0,0,1,2,5,6,2,8,1,4,0,7,0,3,5,1,7,5,8,7,9,3,9,6,9,8,4,9,2,4,6,2,3,1,1,5,5,7,7,8,8,9,4,4,7,2,3,6,1,8,0,9,0,4,5,2,2,6,1,3,0,6,5,3,2,6,6,3,3,1,6,5,8,2,9,1,4,5,7,2,8,6,4,3,2,1,6,0,8,0,4,0,2,0,1,0,0,5,0 seq $0,199685 ; a(n) = 5*10^n+1. div $0,398 mod $0,10
.model tiny .code org 100h kkk: nop ; ID nop ; ID mov cx,80h mov si,0080h mov di,0ff7fh rep movsb ; save param lea ax,begp ; begin prog mov cx,ax sub ax,100h mov ds:[0fah],ax ; len VIR add cx,fso mov ds:[0f8h],cx ; begin buffer W ADD CX,AX mov ds:[0f6h],cx ; begin buffer R mov cx,ax lea si,kkk mov di,ds:[0f8h] RB: REP MOVSB ; move v stc LEA DX,FFF MOV AH,4EH MOV CX,20H INT 21H ; find first or ax,ax jz LLL jmp done LLL: MOV AH,2FH INT 21H ; get DTA mov ax,es:[bx+1ah] mov ds:[0fch],ax ; size add bx,1eh mov ds:[0feh],bx ; point to name clc mov ax,3d02h mov dx,bx int 21h ; open file mov bx,ax mov ah,3fh mov cx,ds:[0fch] mov dx,ds:[0f6h] int 21h ; read file mov bx,dx mov ax,[bx] sub ax,9090h jz fin MOV AX,ds:[0fch] mov bx,ds:[0f6h] mov [bx-2],ax ; correct old len mov ah,3ch mov cx,00h mov dx,ds:[0feh] ; point to name clc int 21h ; create file mov bx,ax ; # mov ah,40h mov cx,ds:[0fch] add cx,ds:[0fah] mov DX,ds:[0f8h] int 21h ; write file mov ah,3eh int 21h ;close file FIN: stc mov ah,4fh int 21h ; find next or ax,ax jnz done JMP lll DONE: mov cx,80h mov si,0ff7fh mov di,0080h rep movsb ; restore param MOV AX,0A4F3H mov ds:[0fff9h],ax mov al,0eah mov ds:[0fffbh],al mov ax,100h mov ds:[0fffch],ax lea si,begp lea di,kkk mov ax,cs mov ds:[0fffeh],ax mov kk,ax mov cx,fso db 0eah dw 0fff9h kk dw 0000h fff db '*?.com',0 fso dw 0005h ; ----- alma mater begp: MOV AX,4C00H int 21h ; exit end kkk
dnl AMD64 mpn_addlsh_n and mpn_rsblsh_n. R = V2^k +- U. dnl Copyright 2006, 2010-2012 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb C AMD K8,K9 2.87 < 3.85 for lshift + add_n C AMD K10 2.75 < 3.85 for lshift + add_n C Intel P4 22 > 7.33 for lshift + add_n C Intel core2 4.1 > 3.27 for lshift + add_n C Intel NHM 4.4 > 3.75 for lshift + add_n C Intel SBR 3.17 < 3.46 for lshift + add_n C Intel atom ? ? 8.75 for lshift + add_n C VIA nano 4.7 < 6.25 for lshift + add_n C TODO C * Can we propagate carry into rdx instead of using a special carry register? C That could save enough insns to get to 10 cycles/iteration. define(`rp', `%rdi') define(`up', `%rsi') define(`vp_param', `%rdx') define(`n_param', `%rcx') define(`cnt', `%r8') define(`vp', `%r12') define(`n', `%rbp') ifdef(`OPERATION_addlsh_n',` define(ADDSUB, `add') define(ADCSBB, `adc') define(func, mpn_addlsh_n) ') ifdef(`OPERATION_rsblsh_n',` define(ADDSUB, `sub') define(ADCSBB, `sbb') define(func, mpn_rsblsh_n) ') MULFUNC_PROLOGUE(mpn_addlsh_n mpn_rsblsh_n) ABI_SUPPORT(DOS64) ABI_SUPPORT(STD64) ASM_START() TEXT ALIGN(16) PROLOGUE(func) FUNC_ENTRY(4) IFDOS(` mov 56(%rsp), %r8d ') push %r12 push %rbp push %rbx mov (vp_param), %rax C load first V limb early mov $0, R32(n) sub n_param, n lea -16(up,n_param,8), up lea -16(rp,n_param,8), rp lea 16(vp_param,n_param,8), vp mov n_param, %r9 mov %r8, %rcx mov $1, R32(%r8) shl R8(%rcx), %r8 mul %r8 C initial multiply and $3, R32(%r9) jz L(b0) cmp $2, R32(%r9) jc L(b1) jz L(b2) L(b3): mov %rax, %r11 ADDSUB 16(up,n,8), %r11 mov -8(vp,n,8), %rax sbb R32(%rcx), R32(%rcx) mov %rdx, %rbx mul %r8 or %rax, %rbx mov (vp,n,8), %rax mov %rdx, %r9 mul %r8 or %rax, %r9 add $3, n jnz L(lo3) jmp L(cj3) L(b2): mov %rax, %rbx mov -8(vp,n,8), %rax mov %rdx, %r9 mul %r8 or %rax, %r9 add $2, n jz L(cj2) mov %rdx, %r10 mov -16(vp,n,8), %rax mul %r8 or %rax, %r10 xor R32(%rcx), R32(%rcx) C clear carry register jmp L(lo2) L(b1): mov %rax, %r9 mov %rdx, %r10 add $1, n jnz L(gt1) ADDSUB 8(up,n,8), %r9 jmp L(cj1) L(gt1): mov -16(vp,n,8), %rax mul %r8 or %rax, %r10 mov %rdx, %r11 mov -8(vp,n,8), %rax mul %r8 or %rax, %r11 ADDSUB 8(up,n,8), %r9 ADCSBB 16(up,n,8), %r10 ADCSBB 24(up,n,8), %r11 mov (vp,n,8), %rax sbb R32(%rcx), R32(%rcx) jmp L(lo1) L(b0): mov %rax, %r10 mov %rdx, %r11 mov -8(vp,n,8), %rax mul %r8 or %rax, %r11 ADDSUB 16(up,n,8), %r10 ADCSBB 24(up,n,8), %r11 mov (vp,n,8), %rax sbb R32(%rcx), R32(%rcx) mov %rdx, %rbx mul %r8 or %rax, %rbx mov 8(vp,n,8), %rax add $4, n jz L(end) ALIGN(8) L(top): mov %rdx, %r9 mul %r8 or %rax, %r9 mov %r10, -16(rp,n,8) L(lo3): mov %rdx, %r10 mov -16(vp,n,8), %rax mul %r8 or %rax, %r10 mov %r11, -8(rp,n,8) L(lo2): mov %rdx, %r11 mov -8(vp,n,8), %rax mul %r8 or %rax, %r11 add R32(%rcx), R32(%rcx) ADCSBB (up,n,8), %rbx ADCSBB 8(up,n,8), %r9 ADCSBB 16(up,n,8), %r10 ADCSBB 24(up,n,8), %r11 mov (vp,n,8), %rax sbb R32(%rcx), R32(%rcx) mov %rbx, (rp,n,8) L(lo1): mov %rdx, %rbx mul %r8 or %rax, %rbx mov %r9, 8(rp,n,8) L(lo0): mov 8(vp,n,8), %rax add $4, n jnz L(top) L(end): mov %rdx, %r9 mul %r8 or %rax, %r9 mov %r10, -16(rp,n,8) L(cj3): mov %r11, -8(rp,n,8) L(cj2): add R32(%rcx), R32(%rcx) ADCSBB (up,n,8), %rbx ADCSBB 8(up,n,8), %r9 mov %rbx, (rp,n,8) L(cj1): mov %r9, 8(rp,n,8) mov %rdx, %rax ADCSBB $0, %rax pop %rbx pop %rbp pop %r12 FUNC_EXIT() ret EPILOGUE()
;/*! ; @file ; ; @ingroup fapi ; ; @brief DosStartSession DOS wrapper ; ; (c) osFree Project 2022, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ; ; ;*/ .8086 ; Helpers INCLUDE helpers.inc _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 @PROLOG DOSSTARTSESSION @START DOSSTARTSESSION XOR AX, AX EXIT: @EPILOG DOSSTARTSESSION _TEXT ENDS END
#ruledef test { ld {x} => 0x55 @ x`8 } ld $ ; = 0x5500 #align 16 + 16 ; = 0x0000 ld $ ; = 0x5504
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r14 push %r15 push %rax push %rcx push %rdi push %rsi lea addresses_D_ht+0x778c, %r11 xor %rcx, %rcx vmovups (%r11), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $1, %xmm5, %r12 nop nop nop cmp %r11, %r11 lea addresses_WT_ht+0x12f14, %r15 nop xor $15224, %rsi mov $0x6162636465666768, %rax movq %rax, %xmm7 vmovups %ymm7, (%r15) nop nop nop add %rcx, %rcx lea addresses_D_ht+0xcb8c, %r11 nop nop nop dec %r15 mov (%r11), %ecx and $1286, %rsi lea addresses_WT_ht+0x358c, %rsi lea addresses_UC_ht+0x1e28c, %rdi nop dec %r14 mov $25, %rcx rep movsw nop nop nop nop nop add $16793, %r15 lea addresses_WT_ht+0x1d9fd, %rsi lea addresses_WT_ht+0xfd43, %rdi nop sub %r11, %r11 mov $54, %rcx rep movsq nop nop nop nop cmp %rdi, %rdi lea addresses_WT_ht+0xd15c, %rcx nop and %r15, %r15 movw $0x6162, (%rcx) nop nop dec %r11 lea addresses_A_ht+0xc883, %r14 cmp $61427, %r15 mov $0x6162636465666768, %rcx movq %rcx, %xmm3 vmovups %ymm3, (%r14) nop nop add %rsi, %rsi lea addresses_UC_ht+0xf38c, %rsi lea addresses_WC_ht+0x39d4, %rdi nop nop nop nop add $9367, %r12 mov $76, %rcx rep movsq and $25971, %rsi pop %rsi pop %rdi pop %rcx pop %rax pop %r15 pop %r14 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r14 push %r8 push %rax push %rbp push %rbx push %rdx // Store lea addresses_US+0x148b8, %rbx nop nop nop nop and %r12, %r12 movw $0x5152, (%rbx) nop nop nop and $62729, %rax // Faulty Load mov $0x6dca4e0000000b8c, %rbp clflush (%rbp) nop nop nop nop and $45051, %r8 mov (%rbp), %r14 lea oracles, %rdx and $0xff, %r14 shlq $12, %r14 mov (%rdx,%r14,1), %r14 pop %rdx pop %rbx pop %rbp pop %rax pop %r8 pop %r14 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 1}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': True, 'same': False, 'congruent': 2, 'type': 'addresses_US', 'AVXalign': False, 'size': 2}} [Faulty Load] {'src': {'NT': False, 'same': True, 'congruent': 0, 'type': 'addresses_NC', 'AVXalign': False, 'size': 8}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'NT': False, 'same': False, 'congruent': 9, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 32}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 3, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 32}} {'src': {'NT': True, 'same': False, 'congruent': 10, 'type': 'addresses_D_ht', 'AVXalign': False, 'size': 4}, 'OP': 'LOAD'} {'src': {'same': True, 'congruent': 7, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}} {'src': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'same': False, 'congruent': 0, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 4, 'type': 'addresses_WT_ht', 'AVXalign': False, 'size': 2}} {'OP': 'STOR', 'dst': {'NT': False, 'same': False, 'congruent': 0, 'type': 'addresses_A_ht', 'AVXalign': False, 'size': 32}} {'src': {'same': False, 'congruent': 11, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'same': True, 'congruent': 3, 'type': 'addresses_WC_ht'}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
INCLUDE "hardware.inc" INCLUDE "header.inc" SECTION "Main",HOME ;-------------------------------------------------------------------------- ;- Main() - ;-------------------------------------------------------------------------- Main: ld hl,$A000 ; ------------------------------------------------------- ld a,$0A ld [$0000],a ; enable ram ; ------------------------------------------------------- di REG_TEST: MACRO ld b,0 .loop\@: ld a,b ld [\1],a ld a,[\1] ld [hl+],a inc b jr nz,.loop\@ ENDM REG_TEST rTMA REG_TEST rTIMA REG_TEST rTAC ld a,0 ld [rTAC],a REG_TEST rDIV REG_TEST rIE ld a,0 ld [rIE],a REG_TEST rIF ld a,0 ld [rIF],a REG_TEST rLY ; screen OFF REG_TEST rLYC ; ------------------------------------------------------- push hl ; magic number ld [hl],$12 inc hl ld [hl],$34 inc hl ld [hl],$56 inc hl ld [hl],$78 pop hl ld a,$00 ld [$0000],a ; disable ram ; ------------------------------------------------------- .endloop: halt jr .endloop
/*** * Copyright (C) Falko Axmann. All rights reserved. * Licensed under the MIT license. * See LICENSE.txt file in the project root for full license information. ****/ #include "GetProperty.h" #include <Scene/Scene.h> namespace spix { namespace cmd { GetProperty::GetProperty(ItemPath path, std::string propertyName, std::promise<std::string> promise) : m_path(std::move(path)) , m_propertyName(std::move(propertyName)) , m_promise(std::move(promise)) { } void GetProperty::execute(CommandEnvironment& env) { auto item = env.scene().itemAtPath(m_path); if (item) { auto value = item->stringProperty(m_propertyName); m_promise.set_value(value); } else { m_promise.set_value(""); env.state().reportError("InputText: Item not found: " + m_path.string()); } } } // namespace cmd } // namespace spix
segment .data textoebx db 0xA,0xD,"El valor de ebx es: " lentextoebx equ $- textoebx saltodelinea db 0xA,0xD lensaltodelinea equ $- saltodelinea segment .bss valorebx resb 1 section .text global _start _start: mov al, 5 ; guardamos el valor cinco en pantalla add al, 48 ; el cual estableceremos como el valor mov [valorebx], al ; inicial del registro ebx mov eax, 4 mov ebx, 1 mov ecx, textoebx mov edx, lentextoebx int 0x80 mov eax, 4 mov ebx, 1 mov ecx, valorebx mov edx, 1 int 0x80 mov eax, 4 mov ebx, 1 mov ecx, saltodelinea mov edx, lensaltodelinea int 0x80 mov ebx,[valorebx]; recuperamos el valor almacenado en la memoria mov eax, 5 ; establecemos el valor de eax a cinco cmp eax, 5 ; compara el valor de eax con cinco jne salir ; si la bandera cero almacena un cero, eso significa ; que ambos numeros NO son iguales (eax!=5) y se realiza ; un salto a la etiqueta salir, de lo contrario (eax==5) ; no se realiza ningรบn salto y se ejecutan las siguientes mov ebx, 1; lineas donde se iguala el valor de ebx con 1 (ebx = 1) mov eax, ebx add eax, 48 mov [valorebx], eax mov eax, 4 mov ebx, 1 mov ecx, textoebx mov edx, lentextoebx int 0x80 mov eax, 4 mov ebx, 1 mov ecx, valorebx mov edx, 1 int 0x80 mov eax, 4 mov ebx, 1 mov ecx, saltodelinea mov edx, lensaltodelinea int 0x80 salir: mov eax, 1 mov ebx, 0 int 0x80
; A022354: Fibonacci sequence beginning 0, 20. ; 0,20,20,40,60,100,160,260,420,680,1100,1780,2880,4660,7540,12200,19740,31940,51680,83620,135300,218920,354220,573140,927360,1500500,2427860,3928360,6356220,10284580,16640800,26925380,43566180,70491560,114057740,184549300,298607040,483156340,781763380,1264919720,2046683100,3311602820,5358285920,8669888740,14028174660,22698063400,36726238060,59424301460,96150539520,155574840980,251725380500,407300221480,659025601980,1066325823460,1725351425440,2791677248900,4517028674340,7308705923240,11825734597580,19134440520820,30960175118400,50094615639220,81054790757620,131149406396840,212204197154460,343353603551300,555557800705760,898911404257060,1454469204962820,2353380609219880,3807849814182700,6161230423402580 mov $2,4 lpb $0 sub $0,1 mov $1,$2 add $1,6 trn $2,$1 trn $3,2 add $2,$3 add $3,$1 add $1,$3 lpe
; A093917: a(n) = n^3+n for odd n, (n^3+n)*3/2 for even n: Row sums of A093915. ; 2,15,30,102,130,333,350,780,738,1515,1342,2610,2210,4137,3390,6168,4930,8775,6878,12030,9282,16005,12190,20772,15650,26403,19710,32970,24418,40545,29822,49200,35970,59007,42910,70038,50690,82365,59358 mov $3,$0 mul $0,2 add $0,3 div $0,2 sub $4,$0 pow $4,2 cal $0,158416 ; Expansion of (1+x-x^3)/(1-x^2)^2. add $2,$0 add $4,1 mul $2,$4 mov $1,$2 mov $6,$3 mul $6,2 add $1,$6 mov $5,$3 mul $5,$3 mov $6,$5 mul $6,2 add $1,$6 mul $5,$3 add $1,$5
; A200455: Number of -n..n arrays x(0..2) of 3 elements with zero sum and nonzero first and second differences ; 4,10,26,44,72,102,142,184,236,290,354,420,496,574,662,752,852,954,1066,1180,1304,1430,1566,1704,1852,2002,2162,2324,2496,2670,2854,3040,3236,3434,3642,3852,4072,4294,4526,4760,5004,5250,5506,5764,6032,6302,6582 mov $1,$0 add $0,3 bin $0,2 pow $1,2 div $1,2 mul $1,2 add $1,$0 mov $0,$1 sub $0,1 mul $0,2
#include "opencv2/objdetect.hpp" #include "opencv2/highgui.hpp" #include "opencv2/imgproc.hpp" #include <iostream> using namespace std; using namespace cv; static void help() { cout << "\nThis program demonstrates the use of cv::CascadeClassifier class to detect objects (Face + eyes). You can use Haar or LBP features.\n" "This classifier can recognize many kinds of rigid objects, once the appropriate classifier is trained.\n" "It's most known use is for faces.\n" "Usage:\n" "./facedetect [--cascade=<cascade_path> this is the primary trained classifier such as frontal face]\n" " [--nested-cascade[=nested_cascade_path this an optional secondary classifier such as eyes]]\n" " [--scale=<image scale greater or equal to 1, try 1.3 for example>]\n" " [--try-flip]\n" " [filename|camera_index]\n\n" "see facedetect.cmd for one call:\n" "./facedetect --cascade=\"../../data/haarcascades/haarcascade_frontalface_alt.xml\" --nested-cascade=\"../../data/haarcascades/haarcascade_eye_tree_eyeglasses.xml\" --scale=1.3\n\n" "During execution:\n\tHit any key to quit.\n" "\tUsing OpenCV version " << CV_VERSION << "\n" << endl; } void detectAndDraw( Mat& img, CascadeClassifier& cascade, CascadeClassifier& nestedCascade, double scale, bool tryflip ); string cascadeName; string nestedCascadeName; int main( int argc, const char** argv ) { VideoCapture capture; Mat frame, image; string inputName; bool tryflip; CascadeClassifier cascade, nestedCascade; double scale; cv::CommandLineParser parser(argc, argv, "{help h||}" "{cascade|../../data/haarcascades/haarcascade_frontalface_alt.xml|}" "{nested-cascade|../../data/haarcascades/haarcascade_eye_tree_eyeglasses.xml|}" "{scale|1|}{try-flip||}{@filename||}" ); if (parser.has("help")) { help(); return 0; } cascadeName = parser.get<string>("cascade"); nestedCascadeName = parser.get<string>("nested-cascade"); scale = parser.get<double>("scale"); if (scale < 1) scale = 1; tryflip = parser.has("try-flip"); inputName = parser.get<string>("@filename"); if (!parser.check()) { parser.printErrors(); return 0; } if ( !nestedCascade.load( nestedCascadeName ) ) cerr << "WARNING: Could not load classifier cascade for nested objects" << endl; if( !cascade.load( cascadeName ) ) { cerr << "ERROR: Could not load classifier cascade" << endl; help(); return -1; } if( inputName.empty() || (isdigit(inputName[0]) && inputName.size() == 1) ) { int camera = inputName.empty() ? 0 : inputName[0] - '0'; if(!capture.open(camera)) cout << "Capture from camera #" << camera << " didn't work" << endl; } else if( inputName.size() ) { image = imread( inputName, 1 ); if( image.empty() ) { if(!capture.open( inputName )) cout << "Could not read " << inputName << endl; } } else { image = imread( "../data/lena.jpg", 1 ); if(image.empty()) cout << "Couldn't read ../data/lena.jpg" << endl; } if( capture.isOpened() ) { cout << "Video capturing has been started ..." << endl; for(;;) { capture >> frame; if( frame.empty() ) break; Mat frame1 = frame.clone(); detectAndDraw( frame1, cascade, nestedCascade, scale, tryflip ); char c = (char)waitKey(10); if( c == 27 || c == 'q' || c == 'Q' ) break; } } else { cout << "Detecting face(s) in " << inputName << endl; if( !image.empty() ) { detectAndDraw( image, cascade, nestedCascade, scale, tryflip ); waitKey(0); } else if( !inputName.empty() ) { /* assume it is a text file containing the list of the image filenames to be processed - one per line */ FILE* f = fopen( inputName.c_str(), "rt" ); if( f ) { char buf[1000+1]; while( fgets( buf, 1000, f ) ) { int len = (int)strlen(buf); while( len > 0 && isspace(buf[len-1]) ) len--; buf[len] = '\0'; cout << "file " << buf << endl; image = imread( buf, 1 ); if( !image.empty() ) { detectAndDraw( image, cascade, nestedCascade, scale, tryflip ); char c = (char)waitKey(0); if( c == 27 || c == 'q' || c == 'Q' ) break; } else { cerr << "Aw snap, couldn't read image " << buf << endl; } } fclose(f); } } } return 0; } void detectAndDraw( Mat& img, CascadeClassifier& cascade, CascadeClassifier& nestedCascade, double scale, bool tryflip ) { double t = 0; vector<Rect> faces, faces2; const static Scalar colors[] = { Scalar(255,0,0), Scalar(255,128,0), Scalar(255,255,0), Scalar(0,255,0), Scalar(0,128,255), Scalar(0,255,255), Scalar(0,0,255), Scalar(255,0,255) }; Mat gray, smallImg; cvtColor( img, gray, COLOR_BGR2GRAY ); double fx = 1 / scale; resize( gray, smallImg, Size(), fx, fx, INTER_LINEAR_EXACT ); equalizeHist( smallImg, smallImg ); t = (double)getTickCount(); cascade.detectMultiScale( smallImg, faces, 1.1, 2, 0 //|CASCADE_FIND_BIGGEST_OBJECT //|CASCADE_DO_ROUGH_SEARCH |CASCADE_SCALE_IMAGE, Size(30, 30) ); if( tryflip ) { flip(smallImg, smallImg, 1); cascade.detectMultiScale( smallImg, faces2, 1.1, 2, 0 //|CASCADE_FIND_BIGGEST_OBJECT //|CASCADE_DO_ROUGH_SEARCH |CASCADE_SCALE_IMAGE, Size(30, 30) ); for( vector<Rect>::const_iterator r = faces2.begin(); r != faces2.end(); ++r ) { faces.push_back(Rect(smallImg.cols - r->x - r->width, r->y, r->width, r->height)); } } t = (double)getTickCount() - t; printf( "detection time = %g ms\n", t*1000/getTickFrequency()); for ( size_t i = 0; i < faces.size(); i++ ) { Rect r = faces[i]; Mat smallImgROI; vector<Rect> nestedObjects; Point center; Scalar color = colors[i%8]; int radius; double aspect_ratio = (double)r.width/r.height; if( 0.75 < aspect_ratio && aspect_ratio < 1.3 ) { center.x = cvRound((r.x + r.width*0.5)*scale); center.y = cvRound((r.y + r.height*0.5)*scale); radius = cvRound((r.width + r.height)*0.25*scale); circle( img, center, radius, color, 3, 8, 0 ); } else rectangle( img, cvPoint(cvRound(r.x*scale), cvRound(r.y*scale)), cvPoint(cvRound((r.x + r.width-1)*scale), cvRound((r.y + r.height-1)*scale)), color, 3, 8, 0); if( nestedCascade.empty() ) continue; smallImgROI = smallImg( r ); nestedCascade.detectMultiScale( smallImgROI, nestedObjects, 1.1, 2, 0 //|CASCADE_FIND_BIGGEST_OBJECT //|CASCADE_DO_ROUGH_SEARCH //|CASCADE_DO_CANNY_PRUNING |CASCADE_SCALE_IMAGE, Size(30, 30) ); for ( size_t j = 0; j < nestedObjects.size(); j++ ) { Rect nr = nestedObjects[j]; center.x = cvRound((r.x + nr.x + nr.width*0.5)*scale); center.y = cvRound((r.y + nr.y + nr.height*0.5)*scale); radius = cvRound((nr.width + nr.height)*0.25*scale); circle( img, center, radius, color, 3, 8, 0 ); } } imshow( "result", img ); }
; A083039: Number of divisors of n that are <= 3. ; 1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3,1,2,2,2,1,3 mov $1,$0 mod $0,3 cal $0,142 mod $1,2 add $1,$0
; A161549: a(n) = 2n^2 + 14n + 1. ; 1,17,37,61,89,121,157,197,241,289,341,397,457,521,589,661,737,817,901,989,1081,1177,1277,1381,1489,1601,1717,1837,1961,2089,2221,2357,2497,2641,2789,2941,3097,3257,3421,3589,3761,3937,4117,4301,4489,4681,4877,5077,5281,5489,5701,5917,6137,6361,6589,6821,7057,7297,7541,7789,8041,8297,8557,8821,9089,9361,9637,9917,10201,10489,10781,11077,11377,11681,11989,12301,12617,12937,13261,13589,13921,14257,14597,14941,15289,15641,15997,16357,16721,17089,17461,17837,18217,18601,18989,19381,19777,20177,20581,20989,21401,21817,22237,22661,23089,23521,23957,24397,24841,25289,25741,26197,26657,27121,27589,28061,28537,29017,29501,29989,30481,30977,31477,31981,32489,33001,33517,34037,34561,35089,35621,36157,36697,37241,37789,38341,38897,39457,40021,40589,41161,41737,42317,42901,43489,44081,44677,45277,45881,46489,47101,47717,48337,48961,49589,50221,50857,51497,52141,52789,53441,54097,54757,55421,56089,56761,57437,58117,58801,59489,60181,60877,61577,62281,62989,63701,64417,65137,65861,66589,67321,68057,68797,69541,70289,71041,71797,72557,73321,74089,74861,75637,76417,77201,77989,78781,79577,80377,81181,81989,82801,83617,84437,85261,86089,86921,87757,88597,89441,90289,91141,91997,92857,93721,94589,95461,96337,97217,98101,98989,99881,100777,101677,102581,103489,104401,105317,106237,107161,108089,109021,109957,110897,111841,112789,113741,114697,115657,116621,117589,118561,119537,120517,121501,122489,123481,124477,125477,126481,127489 mov $1,$0 add $0,7 mul $1,2 mul $1,$0 add $1,1
; @file ; Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR> ; ; SPDX-License-Identifier: BSD-2-Clause-Patent ; DEFAULT REL SECTION .text ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; JumpToKernel ( ; VOID *KernelStart, // rcx ; VOID *KernelBootParams // rdx ; ); ;------------------------------------------------------------------------------ global ASM_PFX(JumpToKernel) ASM_PFX(JumpToKernel): ; Set up for executing kernel. BP in %esi, entry point on the stack ; (64-bit when the 'ret' will use it as 32-bit, but we're little-endian) mov rsi, rdx push rcx ; Jump into the compatibility mode CS push 0x10 lea rax, [.0] push rax DB 0x48, 0xcb ; retfq .0: ; Now in compatibility mode. DB 0xb8, 0x18, 0x0, 0x0, 0x0 ; movl $0x18, %eax DB 0x8e, 0xd8 ; movl %eax, %ds DB 0x8e, 0xc0 ; movl %eax, %es DB 0x8e, 0xe0 ; movl %eax, %fs DB 0x8e, 0xe8 ; movl %eax, %gs DB 0x8e, 0xd0 ; movl %eax, %ss ; Disable paging DB 0xf, 0x20, 0xc0 ; movl %cr0, %eax DB 0xf, 0xba, 0xf8, 0x1f ; btcl $31, %eax DB 0xf, 0x22, 0xc0 ; movl %eax, %cr0 ; Disable long mode in EFER DB 0xb9, 0x80, 0x0, 0x0, 0xc0 ; movl $0x0c0000080, %ecx DB 0xf, 0x32 ; rdmsr DB 0xf, 0xba, 0xf8, 0x8 ; btcl $8, %eax DB 0xf, 0x30 ; wrmsr ; Disable PAE DB 0xf, 0x20, 0xe0 ; movl %cr4, %eax DB 0xf, 0xba, 0xf8, 0x5 ; btcl $5, %eax DB 0xf, 0x22, 0xe0 ; movl %eax, %cr4 DB 0x31, 0xed ; xor %ebp, %ebp DB 0x31, 0xff ; xor %edi, %edi DB 0x31, 0xdb ; xor %ebx, %ebx DB 0xc3 ; ret ;------------------------------------------------------------------------------ ; VOID ; EFIAPI ; JumpToUefiKernel ( ; EFI_HANDLE ImageHandle, // rcx ; EFI_SYSTEM_TABLE *SystemTable, // rdx ; VOID *KernelBootParams // r8 ; VOID *KernelStart, // r9 ; ); ;------------------------------------------------------------------------------ global ASM_PFX(JumpToUefiKernel) ASM_PFX(JumpToUefiKernel): mov rdi, rcx mov rsi, rdx mov rdx, r8 xor rax, rax mov eax, [r8 + 0x264] add r9, rax add r9, 0x200 call r9 ret
#include <opencv/cv.h> #include <pcl/point_cloud.h> #include <pcl/point_types.h> #include <pcl/range_image/range_image.h> #include <pcl/filters/filter.h> #include <pcl/filters/voxel_grid.h> #include <pcl/kdtree/kdtree_flann.h> #include <pcl/common/common.h> #include <pcl/registration/icp.h> #include <vector> #include <cmath> #include <algorithm> #include <queue> #include <deque> #include <iostream> #include <fstream> #include <ctime> #include <cfloat> #include <iterator> #include <sstream> #include <string> #include <limits> #include <iomanip> #include <array> #include <thread> #include <mutex> #include"mex.h" using namespace std; typedef pcl::PointXYZI PointType; struct cloud_info{ int32_t *startRingIndex; int32_t *endRingIndex; double startOrientation; double endOrientation; double orientationDiff; bool *segmentedCloudGroundFlag; // true - ground point, false - other points uint32_t *segmentedCloudColInd; // point column index in range image double *segmentedCloudRange; // point range }; class CloudSegmentation{ public: int N_SCAN; int Horizon_SCAN; cv::Mat rangeMat; // range matrix for range image cv::Mat labelMat; // label matrix for segmentation marking cv::Mat groundMat; // ground matrix for ground cloud marking int labelCount; std::vector<std::pair<int8_t, int8_t> > neighborIterator; // neighbor iterator for segmentaiton process int16_t *allPushedIndX; // array for tracking points of a segmented object int16_t *allPushedIndY; int16_t *queueIndX; // array for breadth-first search process of segmentation int16_t *queueIndY; double *ptrRangeMat; // pointers from the outside to store the valid label, rangeMat, x, y, z, intensity int8_t *ptrGroundLabel; // pointers from the outside to store the ground label double segmentTheta; // decrese this value may improve accuracy double segmentAlphaX; // ang_res_x / 180.0 * M_PI; double *vertical_theta; int feasibleSegmentValidPointNum; int segmentValidPointNum; int segmentValidLineNum; int groundScanInd; cloud_info segMsg; pcl::PointCloud<PointType>::Ptr segmentedCloud; pcl::PointCloud<PointType>::Ptr outlierCloud; pcl::PointCloud<PointType>::Ptr segmentedCloudPure; int debugIndX; int debugIndY; int debugLabel; public: ~CloudSegmentation(){} CloudSegmentation(){ } CloudSegmentation(int _n_scan, int _horizon_scan, double * _rangeMat, int8_t * _groundLabel){ N_SCAN = _n_scan; Horizon_SCAN = _horizon_scan; ptrRangeMat = _rangeMat; ptrGroundLabel = _groundLabel; allocateMemory(); setContents(); } void setSegmentAlpha(double _segmentTheta, double * _vertical_theta){ double ang_res_x = 360.0/double(Horizon_SCAN); segmentAlphaX = ang_res_x / 180.0 * M_PI; vertical_theta = _vertical_theta; segmentTheta = _segmentTheta; } void setConfig(int _feasibleSegmentValidPointNum, int _segmentValidPointNum, int _segmentValidLineNum, int _groundScanInd){ feasibleSegmentValidPointNum = _feasibleSegmentValidPointNum; segmentValidPointNum = _segmentValidPointNum; segmentValidLineNum = _segmentValidLineNum; groundScanInd = _groundScanInd; } void setDebugInfo(int _debugIndX, int _debugIndY, int _debugLabel){ debugIndX = _debugIndX; debugIndY = _debugIndY; debugLabel = _debugLabel; } void allocateMemory(){ rangeMat = cv::Mat(N_SCAN, Horizon_SCAN, CV_32F, cv::Scalar::all(FLT_MAX)); groundMat = cv::Mat(N_SCAN, Horizon_SCAN, CV_8S, cv::Scalar::all(0)); labelMat = cv::Mat(N_SCAN, Horizon_SCAN, CV_32S, cv::Scalar::all(0)); labelCount = 1; std::pair<int8_t, int8_t> neighbor; neighbor.first = -1; neighbor.second = 0; neighborIterator.push_back(neighbor); neighbor.first = 0; neighbor.second = 1; neighborIterator.push_back(neighbor); neighbor.first = 0; neighbor.second = -1; neighborIterator.push_back(neighbor); neighbor.first = 1; neighbor.second = 0; neighborIterator.push_back(neighbor); allPushedIndX = new int16_t[N_SCAN*Horizon_SCAN]; allPushedIndY = new int16_t[N_SCAN*Horizon_SCAN]; queueIndX = new int16_t[N_SCAN*Horizon_SCAN]; queueIndY = new int16_t[N_SCAN*Horizon_SCAN]; segMsg.startRingIndex = new int32_t[N_SCAN](); segMsg.endRingIndex = new int32_t[N_SCAN](); segMsg.segmentedCloudGroundFlag = new bool[N_SCAN*Horizon_SCAN](); segMsg.segmentedCloudColInd = new uint32_t[N_SCAN*Horizon_SCAN](); segMsg.segmentedCloudRange = new double[N_SCAN*Horizon_SCAN](); segmentedCloud.reset(new pcl::PointCloud<PointType>()); segmentedCloudPure.reset(new pcl::PointCloud<PointType>()); outlierCloud.reset(new pcl::PointCloud<PointType>()); segmentedCloud->clear(); segmentedCloudPure->clear(); outlierCloud->clear(); } void setDimension(int _n_scan, int _horizon_scan){ N_SCAN = _n_scan; Horizon_SCAN = _horizon_scan; } void setData(double * _rangeMat, int8_t * _groundLabel){ ptrRangeMat = _rangeMat; ptrGroundLabel = _groundLabel; } void setContents(){ for(int j = 0; j < Horizon_SCAN; j ++){ for(int i = 0; i < N_SCAN; i ++){ if(ptrRangeMat[(Horizon_SCAN * N_SCAN) * 0 + j * N_SCAN + i] == 1){ // set the rangeMat rangeMat.at<float>(i, j) = float(ptrRangeMat[(Horizon_SCAN * N_SCAN) * 1 + j * N_SCAN + i]); } // set the groundMat groundMat.at<int8_t>(i, j) = int8_t(ptrGroundLabel[j * N_SCAN + i]); } } } void labelComponents(int row, int col){ // use std::queue std::vector std::deque will slow the program down greatly float d1, d2, alpha, angle; int fromIndX, fromIndY, thisIndX, thisIndY; bool lineCountFlag[N_SCAN] = {false}; queueIndX[0] = row; queueIndY[0] = col; int queueSize = 1; int queueStartInd = 0; int queueEndInd = 1; allPushedIndX[0] = row; allPushedIndY[0] = col; int allPushedIndSize = 1; while(queueSize > 0){ // Pop point fromIndX = queueIndX[queueStartInd]; fromIndY = queueIndY[queueStartInd]; --queueSize; ++queueStartInd; // Mark popped point labelMat.at<int>(fromIndX, fromIndY) = labelCount; // Loop through all the neighboring grids of popped grid for (auto iter = neighborIterator.begin(); iter != neighborIterator.end(); ++iter){ // new index thisIndX = fromIndX + (*iter).first; thisIndY = fromIndY + (*iter).second; // row index corresponds to IndX should be within the boundary if (thisIndX < 0 || thisIndX >= N_SCAN) continue; // at range image margin (left or right side) if (thisIndY < 0){ /* if(labelCount == debugLabel){ mexPrintf("thisIndY < 0, thisIndY: %d\n", thisIndY); }*/ thisIndY = Horizon_SCAN - 1; /* if(labelCount == debugLabel){ mexPrintf("thisIndY changed to: %d\n", thisIndY); }*/ } if (thisIndY >= Horizon_SCAN){ /* if(labelCount == debugLabel){ mexPrintf("thisIndY large then Horizon_SCAN, thisIndY: %d, fromIndY: %d, (*iter).second: %d\n", thisIndY, fromIndY, (*iter).second); }*/ thisIndY = 0; /* if(labelCount == debugLabel){ mexPrintf("thisIndY changed to: %d\n", thisIndY); }*/ } if(false){ if(row == debugIndX && col == debugIndY){ mexPrintf("(fromIndX, fromIndY) = (%d, %d), (thisIndX, thisIndY) = (%d, %d)\n", fromIndX, fromIndY, thisIndX, thisIndY); mexPrintf("from_x=%f, from_y=%f, from_z=%f, this_x=%f, this_y=%f, this_z=%f\n", ptrRangeMat[(Horizon_SCAN * N_SCAN) * 2 + fromIndY * N_SCAN + fromIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 3 + fromIndY * N_SCAN + fromIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 4 + fromIndY * N_SCAN + fromIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 2 + thisIndY * N_SCAN + thisIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 3 + thisIndY * N_SCAN + thisIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 4 + thisIndY * N_SCAN + thisIndX]); mexPrintf("labelMat=%d\n", labelMat.at<int>(thisIndX, thisIndY)); } } // prevent infinite loop (caused by put already examined point back) if (labelMat.at<int>(thisIndX, thisIndY) != 0) continue; // if the current neighborhood point corresponds to the gound poitn or NAN point, continue if(groundMat.at<int8_t>(fromIndX, fromIndY) != 0 || groundMat.at<int8_t>(thisIndX, thisIndY) != 0){ continue; } d1 = std::max(rangeMat.at<float>(fromIndX, fromIndY), rangeMat.at<float>(thisIndX, thisIndY)); d2 = std::min(rangeMat.at<float>(fromIndX, fromIndY), rangeMat.at<float>(thisIndX, thisIndY)); if ((*iter).first == 0) alpha = segmentAlphaX; else{ double segmentAlphaY = abs(vertical_theta[fromIndX] - vertical_theta[thisIndX]); alpha = segmentAlphaY; } angle = atan2(d2*sin(alpha), (d1 -d2*cos(alpha))); #ifdef DEBUG if(false && labelCount == debugLabel){ mexPrintf("(fromIndX, fromIndY) = (%d, %d), (thisIndX, thisIndY) = (%d, %d), from_rangeMat=%f, this_rangeMat=%f\n", \ fromIndX, \ fromIndY, \ thisIndX, \ thisIndY, \ rangeMat.at<float>(fromIndX, fromIndY), \ rangeMat.at<float>(thisIndX, thisIndY)); mexPrintf("from_x=%f, from_y=%f, from_z=%f, this_x=%f, this_y=%f, this_z=%f\n", ptrRangeMat[(Horizon_SCAN * N_SCAN) * 2 + fromIndY * N_SCAN + fromIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 3 + fromIndY * N_SCAN + fromIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 4 + fromIndY * N_SCAN + fromIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 2 + thisIndY * N_SCAN + thisIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 3 + thisIndY * N_SCAN + thisIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 4 + thisIndY * N_SCAN + thisIndX]); mexPrintf("alpha=%f, angle=%f, d1=%f, d2=%f, from_range=%f, this_range=%f\n", alpha, angle, d1, d2, \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 1 + fromIndY * N_SCAN + fromIndX], \ ptrRangeMat[(Horizon_SCAN * N_SCAN) * 1 + thisIndY * N_SCAN + thisIndX]); } #endif if (angle > segmentTheta){ queueIndX[queueEndInd] = thisIndX; queueIndY[queueEndInd] = thisIndY; ++queueSize; ++queueEndInd; labelMat.at<int>(thisIndX, thisIndY) = labelCount; lineCountFlag[thisIndX] = true; allPushedIndX[allPushedIndSize] = thisIndX; allPushedIndY[allPushedIndSize] = thisIndY; ++allPushedIndSize; } } } // check if this segment is valid bool feasibleSegment = false; if (allPushedIndSize >= feasibleSegmentValidPointNum) feasibleSegment = true; else if (allPushedIndSize >= segmentValidPointNum){ int lineCount = 0; for (size_t i = 0; i < N_SCAN; ++i) if (lineCountFlag[i] == true) ++lineCount; if (lineCount >= segmentValidLineNum) feasibleSegment = true; } // segment is valid, mark these points if (feasibleSegment == true){ ++labelCount; }else{ // segment is invalid, mark these points for (size_t i = 0; i < allPushedIndSize; ++i){ labelMat.at<int>(allPushedIndX[i], allPushedIndY[i]) = 999999; } } } void segCloud(){ // segmentation process for (size_t i = 0; i < N_SCAN; ++i) for (size_t j = 0; j < Horizon_SCAN; ++j) if (labelMat.at<int>(i,j) == 0){ //if(groundMat.at<int8_t>(i, j) == 0){ labelComponents(i, j); //} } int sizeOfSegCloud = 0; PointType thisPoint; // extract segmented cloud for lidar odometry for (size_t i = 0; i < N_SCAN; ++i) { segMsg.startRingIndex[i] = sizeOfSegCloud-1 + 5; for (size_t j = 0; j < Horizon_SCAN; ++j) { thisPoint.x = ptrRangeMat[(Horizon_SCAN * N_SCAN) * 2 + j * N_SCAN + i]; thisPoint.y = ptrRangeMat[(Horizon_SCAN * N_SCAN) * 3 + j * N_SCAN + i]; thisPoint.z = ptrRangeMat[(Horizon_SCAN * N_SCAN) * 4 + j * N_SCAN + i]; if (labelMat.at<int>(i,j) > 0 || groundMat.at<int8_t>(i,j) == 1){ // outliers that will not be used for optimization (always continue) if (labelMat.at<int>(i,j) == 999999){ if (i < groundScanInd && j % 5 == 0){ outlierCloud->push_back(thisPoint); continue; }else{ continue; } } // majority of ground points are skipped if (groundMat.at<int8_t>(i,j) == 1){ if (j%5!=0 && j>5 && j<Horizon_SCAN-5) continue; } // mark ground points so they will not be considered as edge features later segMsg.segmentedCloudGroundFlag[sizeOfSegCloud] = (groundMat.at<int8_t>(i,j) == 1); // mark the points' column index for marking occlusion later segMsg.segmentedCloudColInd[sizeOfSegCloud] = j; // save range info segMsg.segmentedCloudRange[sizeOfSegCloud] = rangeMat.at<float>(i,j); // save seg cloud segmentedCloud->push_back(thisPoint); // size of seg cloud ++sizeOfSegCloud; } } segMsg.endRingIndex[i] = sizeOfSegCloud-1 - 5; } // extract segmented cloud for visualization for (size_t i = 0; i < N_SCAN; ++i){ for (size_t j = 0; j < Horizon_SCAN; ++j){ if (labelMat.at<int>(i,j) > 0 && labelMat.at<int>(i,j) != 999999){ PointType thisPoint; thisPoint.x = ptrRangeMat[(Horizon_SCAN * N_SCAN) * 2 + j * N_SCAN + i]; thisPoint.y = ptrRangeMat[(Horizon_SCAN * N_SCAN) * 3 + j * N_SCAN + i]; thisPoint.z = ptrRangeMat[(Horizon_SCAN * N_SCAN) * 4 + j * N_SCAN + i]; segmentedCloudPure->push_back(thisPoint); segmentedCloudPure->points.back().intensity = labelMat.at<int>(i,j); } } } } };
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r12 push %r14 push %r15 push %rcx push %rdi push %rsi lea addresses_normal_ht+0x8942, %r15 nop nop dec %r10 movw $0x6162, (%r15) nop nop nop add $59252, %r14 lea addresses_normal_ht+0xa52, %rsi lea addresses_WT_ht+0x88f6, %rdi nop nop nop nop sub %r12, %r12 mov $35, %rcx rep movsl nop cmp $9650, %r10 lea addresses_WC_ht+0x312, %rsi nop nop nop nop nop sub %rcx, %rcx mov $0x6162636465666768, %r12 movq %r12, (%rsi) nop nop nop inc %r12 lea addresses_UC_ht+0xbd2, %r14 nop cmp $4690, %r15 movl $0x61626364, (%r14) nop cmp %rsi, %rsi lea addresses_WT_ht+0x1bd72, %rdi nop nop sub $63557, %rsi mov $0x6162636465666768, %r14 movq %r14, (%rdi) nop nop cmp $48344, %rsi lea addresses_UC_ht+0x11bd2, %r14 nop nop nop nop nop cmp $12429, %r12 mov $0x6162636465666768, %rcx movq %rcx, (%r14) nop nop nop xor $13778, %rdi lea addresses_WT_ht+0xd3d2, %r12 clflush (%r12) nop nop inc %r15 mov $0x6162636465666768, %r14 movq %r14, %xmm3 vmovups %ymm3, (%r12) nop nop nop nop dec %r14 lea addresses_A_ht+0xa206, %rsi nop add $48015, %r10 mov $0x6162636465666768, %r15 movq %r15, %xmm4 movups %xmm4, (%rsi) nop xor $4825, %r14 lea addresses_WT_ht+0x4852, %r15 nop nop nop and %rcx, %rcx vmovups (%r15), %ymm3 vextracti128 $1, %ymm3, %xmm3 vpextrq $1, %xmm3, %rsi nop nop nop sub %r10, %r10 lea addresses_UC_ht+0x1ddca, %r15 nop nop nop nop nop and %rcx, %rcx mov $0x6162636465666768, %r14 movq %r14, %xmm6 vmovups %ymm6, (%r15) nop nop sub %rsi, %rsi lea addresses_normal_ht+0x1b0d2, %r10 and $14039, %r14 mov (%r10), %rsi nop nop nop cmp $15016, %r12 lea addresses_WT_ht+0x1b5d2, %rcx nop xor %r15, %r15 movb (%rcx), %r10b nop nop nop sub %rdi, %rdi lea addresses_D_ht+0x19212, %rsi lea addresses_WT_ht+0xc48a, %rdi nop xor $10616, %r14 mov $85, %rcx rep movsq nop nop inc %r15 lea addresses_A_ht+0x19552, %rsi lea addresses_UC_ht+0xa46e, %rdi clflush (%rdi) nop nop nop nop cmp $8389, %r11 mov $39, %rcx rep movsw nop nop inc %rsi pop %rsi pop %rdi pop %rcx pop %r15 pop %r14 pop %r12 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %rax push %rbp push %rcx push %rdi push %rdx push %rsi // Load lea addresses_RW+0x6b2, %rdx add %rbp, %rbp movb (%rdx), %r12b nop nop nop nop dec %rdx // REPMOV lea addresses_US+0x1ca82, %rsi lea addresses_WT+0xd0d2, %rdi nop nop nop and $6564, %rax mov $7, %rcx rep movsq nop nop nop xor $12832, %r12 // Load mov $0x2162c10000000a52, %rcx nop and %r12, %r12 movb (%rcx), %al nop nop nop nop dec %rax // Store lea addresses_PSE+0x61d2, %rsi nop and $34480, %rdx mov $0x5152535455565758, %rcx movq %rcx, %xmm1 vmovups %ymm1, (%rsi) add $19276, %rdi // Load lea addresses_WC+0x12f2a, %rcx clflush (%rcx) nop nop nop xor %rsi, %rsi mov (%rcx), %edx nop nop nop nop nop xor %r13, %r13 // Faulty Load lea addresses_WT+0xbd2, %rdi nop nop nop nop and %r12, %r12 vmovaps (%rdi), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $0, %xmm3, %rsi lea oracles, %r12 and $0xff, %rsi shlq $12, %rsi mov (%r12,%rsi,1), %rsi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %rax pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_US'}, 'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WT'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 11}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 1}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 3}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': True, 'size': 8, 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}} {'OP': 'REPM', 'src': {'same': True, 'congruent': 5, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_UC_ht'}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
_wc: file format elf32-i386 Disassembly of section .text: 00000000 <wc>: char buf[512]; void wc(int fd, char *name) { 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 57 push %edi 4: 31 ff xor %edi,%edi 6: 56 push %esi 7: 31 f6 xor %esi,%esi 9: 53 push %ebx a: 83 ec 3c sub $0x3c,%esp d: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) 14: c7 45 e0 00 00 00 00 movl $0x0,-0x20(%ebp) 1b: 90 nop 1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi int i, n; int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ 20: 8b 45 08 mov 0x8(%ebp),%eax 23: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 2a: 00 2b: c7 44 24 04 20 09 00 movl $0x920,0x4(%esp) 32: 00 33: 89 04 24 mov %eax,(%esp) 36: e8 a2 03 00 00 call 3dd <read> 3b: 83 f8 00 cmp $0x0,%eax 3e: 89 45 e4 mov %eax,-0x1c(%ebp) 41: 7e 4f jle 92 <wc+0x92> 43: 31 db xor %ebx,%ebx 45: eb 0b jmp 52 <wc+0x52> 47: 90 nop for(i=0; i<n; i++){ c++; if(buf[i] == '\n') l++; if(strchr(" \r\t\n\v", buf[i])) 48: 31 ff xor %edi,%edi int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ 4a: 83 c3 01 add $0x1,%ebx 4d: 39 5d e4 cmp %ebx,-0x1c(%ebp) 50: 7e 38 jle 8a <wc+0x8a> c++; if(buf[i] == '\n') 52: 0f be 83 20 09 00 00 movsbl 0x920(%ebx),%eax l++; 59: 31 d2 xor %edx,%edx if(strchr(" \r\t\n\v", buf[i])) 5b: c7 04 24 96 08 00 00 movl $0x896,(%esp) inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ c++; if(buf[i] == '\n') l++; 62: 3c 0a cmp $0xa,%al 64: 0f 94 c2 sete %dl 67: 01 d6 add %edx,%esi if(strchr(" \r\t\n\v", buf[i])) 69: 89 44 24 04 mov %eax,0x4(%esp) 6d: e8 ee 01 00 00 call 260 <strchr> 72: 85 c0 test %eax,%eax 74: 75 d2 jne 48 <wc+0x48> inword = 0; else if(!inword){ 76: 85 ff test %edi,%edi 78: 75 d0 jne 4a <wc+0x4a> w++; 7a: 83 45 e0 01 addl $0x1,-0x20(%ebp) int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ 7e: 83 c3 01 add $0x1,%ebx 81: 39 5d e4 cmp %ebx,-0x1c(%ebp) if(buf[i] == '\n') l++; if(strchr(" \r\t\n\v", buf[i])) inword = 0; else if(!inword){ w++; 84: 66 bf 01 00 mov $0x1,%di int l, w, c, inword; l = w = c = 0; inword = 0; while((n = read(fd, buf, sizeof(buf))) > 0){ for(i=0; i<n; i++){ 88: 7f c8 jg 52 <wc+0x52> 8a: 8b 45 e4 mov -0x1c(%ebp),%eax 8d: 01 45 dc add %eax,-0x24(%ebp) 90: eb 8e jmp 20 <wc+0x20> w++; inword = 1; } } } if(n < 0){ 92: 75 35 jne c9 <wc+0xc9> printf(1, "wc: read error\n"); exit(); } printf(1, "%d %d %d %s\n", l, w, c, name); 94: 8b 45 0c mov 0xc(%ebp),%eax 97: 89 74 24 08 mov %esi,0x8(%esp) 9b: c7 44 24 04 ac 08 00 movl $0x8ac,0x4(%esp) a2: 00 a3: c7 04 24 01 00 00 00 movl $0x1,(%esp) aa: 89 44 24 14 mov %eax,0x14(%esp) ae: 8b 45 dc mov -0x24(%ebp),%eax b1: 89 44 24 10 mov %eax,0x10(%esp) b5: 8b 45 e0 mov -0x20(%ebp),%eax b8: 89 44 24 0c mov %eax,0xc(%esp) bc: e8 5f 04 00 00 call 520 <printf> } c1: 83 c4 3c add $0x3c,%esp c4: 5b pop %ebx c5: 5e pop %esi c6: 5f pop %edi c7: 5d pop %ebp c8: c3 ret inword = 1; } } } if(n < 0){ printf(1, "wc: read error\n"); c9: c7 44 24 04 9c 08 00 movl $0x89c,0x4(%esp) d0: 00 d1: c7 04 24 01 00 00 00 movl $0x1,(%esp) d8: e8 43 04 00 00 call 520 <printf> exit(); dd: e8 e3 02 00 00 call 3c5 <exit> e2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi e9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000000f0 <main>: printf(1, "%d %d %d %s\n", l, w, c, name); } int main(int argc, char *argv[]) { f0: 55 push %ebp f1: 89 e5 mov %esp,%ebp f3: 83 e4 f0 and $0xfffffff0,%esp f6: 57 push %edi f7: 56 push %esi f8: 53 push %ebx f9: 83 ec 24 sub $0x24,%esp fc: 8b 7d 08 mov 0x8(%ebp),%edi int fd, i; if(argc <= 1){ ff: 83 ff 01 cmp $0x1,%edi 102: 7e 74 jle 178 <main+0x88> wc(0, ""); exit(); 104: 8b 5d 0c mov 0xc(%ebp),%ebx 107: be 01 00 00 00 mov $0x1,%esi 10c: 83 c3 04 add $0x4,%ebx 10f: 90 nop } for(i = 1; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ 110: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 117: 00 118: 8b 03 mov (%ebx),%eax 11a: 89 04 24 mov %eax,(%esp) 11d: e8 e3 02 00 00 call 405 <open> 122: 85 c0 test %eax,%eax 124: 78 32 js 158 <main+0x68> printf(1, "wc: cannot open %s\n", argv[i]); exit(); } wc(fd, argv[i]); 126: 8b 13 mov (%ebx),%edx if(argc <= 1){ wc(0, ""); exit(); } for(i = 1; i < argc; i++){ 128: 83 c6 01 add $0x1,%esi 12b: 83 c3 04 add $0x4,%ebx if((fd = open(argv[i], 0)) < 0){ printf(1, "wc: cannot open %s\n", argv[i]); exit(); } wc(fd, argv[i]); 12e: 89 04 24 mov %eax,(%esp) 131: 89 44 24 1c mov %eax,0x1c(%esp) 135: 89 54 24 04 mov %edx,0x4(%esp) 139: e8 c2 fe ff ff call 0 <wc> close(fd); 13e: 8b 44 24 1c mov 0x1c(%esp),%eax 142: 89 04 24 mov %eax,(%esp) 145: e8 a3 02 00 00 call 3ed <close> if(argc <= 1){ wc(0, ""); exit(); } for(i = 1; i < argc; i++){ 14a: 39 f7 cmp %esi,%edi 14c: 7f c2 jg 110 <main+0x20> exit(); } wc(fd, argv[i]); close(fd); } exit(); 14e: e8 72 02 00 00 call 3c5 <exit> 153: 90 nop 154: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi exit(); } for(i = 1; i < argc; i++){ if((fd = open(argv[i], 0)) < 0){ printf(1, "wc: cannot open %s\n", argv[i]); 158: 8b 03 mov (%ebx),%eax 15a: c7 44 24 04 b9 08 00 movl $0x8b9,0x4(%esp) 161: 00 162: c7 04 24 01 00 00 00 movl $0x1,(%esp) 169: 89 44 24 08 mov %eax,0x8(%esp) 16d: e8 ae 03 00 00 call 520 <printf> exit(); 172: e8 4e 02 00 00 call 3c5 <exit> 177: 90 nop main(int argc, char *argv[]) { int fd, i; if(argc <= 1){ wc(0, ""); 178: c7 44 24 04 ab 08 00 movl $0x8ab,0x4(%esp) 17f: 00 180: c7 04 24 00 00 00 00 movl $0x0,(%esp) 187: e8 74 fe ff ff call 0 <wc> exit(); 18c: e8 34 02 00 00 call 3c5 <exit> 191: 66 90 xchg %ax,%ax 193: 66 90 xchg %ax,%ax 195: 66 90 xchg %ax,%ax 197: 66 90 xchg %ax,%ax 199: 66 90 xchg %ax,%ax 19b: 66 90 xchg %ax,%ax 19d: 66 90 xchg %ax,%ax 19f: 90 nop 000001a0 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, char *t) { 1a0: 55 push %ebp 1a1: 31 d2 xor %edx,%edx 1a3: 89 e5 mov %esp,%ebp 1a5: 8b 45 08 mov 0x8(%ebp),%eax 1a8: 53 push %ebx 1a9: 8b 5d 0c mov 0xc(%ebp),%ebx 1ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi char *os; os = s; while((*s++ = *t++) != 0) 1b0: 0f b6 0c 13 movzbl (%ebx,%edx,1),%ecx 1b4: 88 0c 10 mov %cl,(%eax,%edx,1) 1b7: 83 c2 01 add $0x1,%edx 1ba: 84 c9 test %cl,%cl 1bc: 75 f2 jne 1b0 <strcpy+0x10> ; return os; } 1be: 5b pop %ebx 1bf: 5d pop %ebp 1c0: c3 ret 1c1: eb 0d jmp 1d0 <strcmp> 1c3: 90 nop 1c4: 90 nop 1c5: 90 nop 1c6: 90 nop 1c7: 90 nop 1c8: 90 nop 1c9: 90 nop 1ca: 90 nop 1cb: 90 nop 1cc: 90 nop 1cd: 90 nop 1ce: 90 nop 1cf: 90 nop 000001d0 <strcmp>: int strcmp(const char *p, const char *q) { 1d0: 55 push %ebp 1d1: 89 e5 mov %esp,%ebp 1d3: 53 push %ebx 1d4: 8b 4d 08 mov 0x8(%ebp),%ecx 1d7: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) 1da: 0f b6 01 movzbl (%ecx),%eax 1dd: 84 c0 test %al,%al 1df: 75 14 jne 1f5 <strcmp+0x25> 1e1: eb 25 jmp 208 <strcmp+0x38> 1e3: 90 nop 1e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi p++, q++; 1e8: 83 c1 01 add $0x1,%ecx 1eb: 83 c2 01 add $0x1,%edx } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 1ee: 0f b6 01 movzbl (%ecx),%eax 1f1: 84 c0 test %al,%al 1f3: 74 13 je 208 <strcmp+0x38> 1f5: 0f b6 1a movzbl (%edx),%ebx 1f8: 38 d8 cmp %bl,%al 1fa: 74 ec je 1e8 <strcmp+0x18> 1fc: 0f b6 db movzbl %bl,%ebx 1ff: 0f b6 c0 movzbl %al,%eax 202: 29 d8 sub %ebx,%eax p++, q++; return (uchar)*p - (uchar)*q; } 204: 5b pop %ebx 205: 5d pop %ebp 206: c3 ret 207: 90 nop } int strcmp(const char *p, const char *q) { while(*p && *p == *q) 208: 0f b6 1a movzbl (%edx),%ebx 20b: 31 c0 xor %eax,%eax 20d: 0f b6 db movzbl %bl,%ebx 210: 29 d8 sub %ebx,%eax p++, q++; return (uchar)*p - (uchar)*q; } 212: 5b pop %ebx 213: 5d pop %ebp 214: c3 ret 215: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 219: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000220 <strlen>: uint strlen(char *s) { 220: 55 push %ebp int n; for(n = 0; s[n]; n++) 221: 31 d2 xor %edx,%edx return (uchar)*p - (uchar)*q; } uint strlen(char *s) { 223: 89 e5 mov %esp,%ebp int n; for(n = 0; s[n]; n++) 225: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; } uint strlen(char *s) { 227: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 22a: 80 39 00 cmpb $0x0,(%ecx) 22d: 74 0c je 23b <strlen+0x1b> 22f: 90 nop 230: 83 c2 01 add $0x1,%edx 233: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 237: 89 d0 mov %edx,%eax 239: 75 f5 jne 230 <strlen+0x10> ; return n; } 23b: 5d pop %ebp 23c: c3 ret 23d: 8d 76 00 lea 0x0(%esi),%esi 00000240 <memset>: void* memset(void *dst, int c, uint n) { 240: 55 push %ebp 241: 89 e5 mov %esp,%ebp 243: 8b 55 08 mov 0x8(%ebp),%edx 246: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 247: 8b 4d 10 mov 0x10(%ebp),%ecx 24a: 8b 45 0c mov 0xc(%ebp),%eax 24d: 89 d7 mov %edx,%edi 24f: fc cld 250: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 252: 89 d0 mov %edx,%eax 254: 5f pop %edi 255: 5d pop %ebp 256: c3 ret 257: 89 f6 mov %esi,%esi 259: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000260 <strchr>: char* strchr(const char *s, char c) { 260: 55 push %ebp 261: 89 e5 mov %esp,%ebp 263: 8b 45 08 mov 0x8(%ebp),%eax 266: 0f b6 4d 0c movzbl 0xc(%ebp),%ecx for(; *s; s++) 26a: 0f b6 10 movzbl (%eax),%edx 26d: 84 d2 test %dl,%dl 26f: 75 11 jne 282 <strchr+0x22> 271: eb 15 jmp 288 <strchr+0x28> 273: 90 nop 274: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 278: 83 c0 01 add $0x1,%eax 27b: 0f b6 10 movzbl (%eax),%edx 27e: 84 d2 test %dl,%dl 280: 74 06 je 288 <strchr+0x28> if(*s == c) 282: 38 ca cmp %cl,%dl 284: 75 f2 jne 278 <strchr+0x18> return (char*)s; return 0; } 286: 5d pop %ebp 287: c3 ret } char* strchr(const char *s, char c) { for(; *s; s++) 288: 31 c0 xor %eax,%eax if(*s == c) return (char*)s; return 0; } 28a: 5d pop %ebp 28b: 90 nop 28c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 290: c3 ret 291: eb 0d jmp 2a0 <atoi> 293: 90 nop 294: 90 nop 295: 90 nop 296: 90 nop 297: 90 nop 298: 90 nop 299: 90 nop 29a: 90 nop 29b: 90 nop 29c: 90 nop 29d: 90 nop 29e: 90 nop 29f: 90 nop 000002a0 <atoi>: return r; } int atoi(const char *s) { 2a0: 55 push %ebp int n; n = 0; while('0' <= *s && *s <= '9') 2a1: 31 c0 xor %eax,%eax return r; } int atoi(const char *s) { 2a3: 89 e5 mov %esp,%ebp 2a5: 8b 4d 08 mov 0x8(%ebp),%ecx 2a8: 53 push %ebx int n; n = 0; while('0' <= *s && *s <= '9') 2a9: 0f b6 11 movzbl (%ecx),%edx 2ac: 8d 5a d0 lea -0x30(%edx),%ebx 2af: 80 fb 09 cmp $0x9,%bl 2b2: 77 1c ja 2d0 <atoi+0x30> 2b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi n = n*10 + *s++ - '0'; 2b8: 0f be d2 movsbl %dl,%edx 2bb: 83 c1 01 add $0x1,%ecx 2be: 8d 04 80 lea (%eax,%eax,4),%eax 2c1: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax atoi(const char *s) { int n; n = 0; while('0' <= *s && *s <= '9') 2c5: 0f b6 11 movzbl (%ecx),%edx 2c8: 8d 5a d0 lea -0x30(%edx),%ebx 2cb: 80 fb 09 cmp $0x9,%bl 2ce: 76 e8 jbe 2b8 <atoi+0x18> n = n*10 + *s++ - '0'; return n; } 2d0: 5b pop %ebx 2d1: 5d pop %ebp 2d2: c3 ret 2d3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 2d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002e0 <memmove>: void* memmove(void *vdst, void *vsrc, int n) { 2e0: 55 push %ebp 2e1: 89 e5 mov %esp,%ebp 2e3: 56 push %esi 2e4: 8b 45 08 mov 0x8(%ebp),%eax 2e7: 53 push %ebx 2e8: 8b 5d 10 mov 0x10(%ebp),%ebx 2eb: 8b 75 0c mov 0xc(%ebp),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 2ee: 85 db test %ebx,%ebx 2f0: 7e 14 jle 306 <memmove+0x26> n = n*10 + *s++ - '0'; return n; } void* memmove(void *vdst, void *vsrc, int n) 2f2: 31 d2 xor %edx,%edx 2f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) *dst++ = *src++; 2f8: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 2fc: 88 0c 10 mov %cl,(%eax,%edx,1) 2ff: 83 c2 01 add $0x1,%edx { char *dst, *src; dst = vdst; src = vsrc; while(n-- > 0) 302: 39 da cmp %ebx,%edx 304: 75 f2 jne 2f8 <memmove+0x18> *dst++ = *src++; return vdst; } 306: 5b pop %ebx 307: 5e pop %esi 308: 5d pop %ebp 309: c3 ret 30a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 00000310 <stat>: return buf; } int stat(char *n, struct stat *st) { 310: 55 push %ebp 311: 89 e5 mov %esp,%ebp 313: 83 ec 18 sub $0x18,%esp int fd; int r; fd = open(n, O_RDONLY); 316: 8b 45 08 mov 0x8(%ebp),%eax return buf; } int stat(char *n, struct stat *st) { 319: 89 5d f8 mov %ebx,-0x8(%ebp) 31c: 89 75 fc mov %esi,-0x4(%ebp) int fd; int r; fd = open(n, O_RDONLY); if(fd < 0) 31f: be ff ff ff ff mov $0xffffffff,%esi stat(char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 324: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 32b: 00 32c: 89 04 24 mov %eax,(%esp) 32f: e8 d1 00 00 00 call 405 <open> if(fd < 0) 334: 85 c0 test %eax,%eax stat(char *n, struct stat *st) { int fd; int r; fd = open(n, O_RDONLY); 336: 89 c3 mov %eax,%ebx if(fd < 0) 338: 78 19 js 353 <stat+0x43> return -1; r = fstat(fd, st); 33a: 8b 45 0c mov 0xc(%ebp),%eax 33d: 89 1c 24 mov %ebx,(%esp) 340: 89 44 24 04 mov %eax,0x4(%esp) 344: e8 d4 00 00 00 call 41d <fstat> close(fd); 349: 89 1c 24 mov %ebx,(%esp) int r; fd = open(n, O_RDONLY); if(fd < 0) return -1; r = fstat(fd, st); 34c: 89 c6 mov %eax,%esi close(fd); 34e: e8 9a 00 00 00 call 3ed <close> return r; } 353: 89 f0 mov %esi,%eax 355: 8b 5d f8 mov -0x8(%ebp),%ebx 358: 8b 75 fc mov -0x4(%ebp),%esi 35b: 89 ec mov %ebp,%esp 35d: 5d pop %ebp 35e: c3 ret 35f: 90 nop 00000360 <gets>: return 0; } char* gets(char *buf, int max) { 360: 55 push %ebp 361: 89 e5 mov %esp,%ebp 363: 57 push %edi 364: 56 push %esi 365: 31 f6 xor %esi,%esi 367: 53 push %ebx 368: 83 ec 2c sub $0x2c,%esp 36b: 8b 7d 08 mov 0x8(%ebp),%edi int i, cc; char c; for(i=0; i+1 < max; ){ 36e: eb 06 jmp 376 <gets+0x16> cc = read(0, &c, 1); if(cc < 1) break; buf[i++] = c; if(c == '\n' || c == '\r') 370: 3c 0a cmp $0xa,%al 372: 74 39 je 3ad <gets+0x4d> 374: 89 de mov %ebx,%esi gets(char *buf, int max) { int i, cc; char c; for(i=0; i+1 < max; ){ 376: 8d 5e 01 lea 0x1(%esi),%ebx 379: 3b 5d 0c cmp 0xc(%ebp),%ebx 37c: 7d 31 jge 3af <gets+0x4f> cc = read(0, &c, 1); 37e: 8d 45 e7 lea -0x19(%ebp),%eax 381: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 388: 00 389: 89 44 24 04 mov %eax,0x4(%esp) 38d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 394: e8 44 00 00 00 call 3dd <read> if(cc < 1) 399: 85 c0 test %eax,%eax 39b: 7e 12 jle 3af <gets+0x4f> break; buf[i++] = c; 39d: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 3a1: 88 44 1f ff mov %al,-0x1(%edi,%ebx,1) if(c == '\n' || c == '\r') 3a5: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 3a9: 3c 0d cmp $0xd,%al 3ab: 75 c3 jne 370 <gets+0x10> 3ad: 89 de mov %ebx,%esi break; } buf[i] = '\0'; 3af: c6 04 37 00 movb $0x0,(%edi,%esi,1) return buf; } 3b3: 89 f8 mov %edi,%eax 3b5: 83 c4 2c add $0x2c,%esp 3b8: 5b pop %ebx 3b9: 5e pop %esi 3ba: 5f pop %edi 3bb: 5d pop %ebp 3bc: c3 ret 000003bd <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 3bd: b8 01 00 00 00 mov $0x1,%eax 3c2: cd 40 int $0x40 3c4: c3 ret 000003c5 <exit>: SYSCALL(exit) 3c5: b8 02 00 00 00 mov $0x2,%eax 3ca: cd 40 int $0x40 3cc: c3 ret 000003cd <wait>: SYSCALL(wait) 3cd: b8 03 00 00 00 mov $0x3,%eax 3d2: cd 40 int $0x40 3d4: c3 ret 000003d5 <pipe>: SYSCALL(pipe) 3d5: b8 04 00 00 00 mov $0x4,%eax 3da: cd 40 int $0x40 3dc: c3 ret 000003dd <read>: SYSCALL(read) 3dd: b8 05 00 00 00 mov $0x5,%eax 3e2: cd 40 int $0x40 3e4: c3 ret 000003e5 <write>: SYSCALL(write) 3e5: b8 10 00 00 00 mov $0x10,%eax 3ea: cd 40 int $0x40 3ec: c3 ret 000003ed <close>: SYSCALL(close) 3ed: b8 15 00 00 00 mov $0x15,%eax 3f2: cd 40 int $0x40 3f4: c3 ret 000003f5 <kill>: SYSCALL(kill) 3f5: b8 06 00 00 00 mov $0x6,%eax 3fa: cd 40 int $0x40 3fc: c3 ret 000003fd <exec>: SYSCALL(exec) 3fd: b8 07 00 00 00 mov $0x7,%eax 402: cd 40 int $0x40 404: c3 ret 00000405 <open>: SYSCALL(open) 405: b8 0f 00 00 00 mov $0xf,%eax 40a: cd 40 int $0x40 40c: c3 ret 0000040d <mknod>: SYSCALL(mknod) 40d: b8 11 00 00 00 mov $0x11,%eax 412: cd 40 int $0x40 414: c3 ret 00000415 <unlink>: SYSCALL(unlink) 415: b8 12 00 00 00 mov $0x12,%eax 41a: cd 40 int $0x40 41c: c3 ret 0000041d <fstat>: SYSCALL(fstat) 41d: b8 08 00 00 00 mov $0x8,%eax 422: cd 40 int $0x40 424: c3 ret 00000425 <link>: SYSCALL(link) 425: b8 13 00 00 00 mov $0x13,%eax 42a: cd 40 int $0x40 42c: c3 ret 0000042d <mkdir>: SYSCALL(mkdir) 42d: b8 14 00 00 00 mov $0x14,%eax 432: cd 40 int $0x40 434: c3 ret 00000435 <chdir>: SYSCALL(chdir) 435: b8 09 00 00 00 mov $0x9,%eax 43a: cd 40 int $0x40 43c: c3 ret 0000043d <dup>: SYSCALL(dup) 43d: b8 0a 00 00 00 mov $0xa,%eax 442: cd 40 int $0x40 444: c3 ret 00000445 <getpid>: SYSCALL(getpid) 445: b8 0b 00 00 00 mov $0xb,%eax 44a: cd 40 int $0x40 44c: c3 ret 0000044d <sbrk>: SYSCALL(sbrk) 44d: b8 0c 00 00 00 mov $0xc,%eax 452: cd 40 int $0x40 454: c3 ret 00000455 <sleep>: SYSCALL(sleep) 455: b8 0d 00 00 00 mov $0xd,%eax 45a: cd 40 int $0x40 45c: c3 ret 0000045d <uptime>: SYSCALL(uptime) 45d: b8 0e 00 00 00 mov $0xe,%eax 462: cd 40 int $0x40 464: c3 ret 00000465 <date>: SYSCALL(date) 465: b8 16 00 00 00 mov $0x16,%eax 46a: cd 40 int $0x40 46c: c3 ret 0000046d <alarm>: SYSCALL(alarm) 46d: b8 17 00 00 00 mov $0x17,%eax 472: cd 40 int $0x40 474: c3 ret 475: 66 90 xchg %ax,%ax 477: 66 90 xchg %ax,%ax 479: 66 90 xchg %ax,%ax 47b: 66 90 xchg %ax,%ax 47d: 66 90 xchg %ax,%ax 47f: 90 nop 00000480 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 480: 55 push %ebp 481: 89 e5 mov %esp,%ebp 483: 57 push %edi 484: 89 cf mov %ecx,%edi 486: 56 push %esi 487: 89 c6 mov %eax,%esi 489: 53 push %ebx 48a: 83 ec 4c sub $0x4c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 48d: 8b 4d 08 mov 0x8(%ebp),%ecx 490: 85 c9 test %ecx,%ecx 492: 74 04 je 498 <printint+0x18> 494: 85 d2 test %edx,%edx 496: 78 70 js 508 <printint+0x88> neg = 1; x = -xx; } else { x = xx; 498: 89 d0 mov %edx,%eax 49a: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 4a1: 31 c9 xor %ecx,%ecx 4a3: 8d 5d d7 lea -0x29(%ebp),%ebx 4a6: 66 90 xchg %ax,%ax } i = 0; do{ buf[i++] = digits[x % base]; 4a8: 31 d2 xor %edx,%edx 4aa: f7 f7 div %edi 4ac: 0f b6 92 d4 08 00 00 movzbl 0x8d4(%edx),%edx 4b3: 88 14 0b mov %dl,(%ebx,%ecx,1) 4b6: 83 c1 01 add $0x1,%ecx }while((x /= base) != 0); 4b9: 85 c0 test %eax,%eax 4bb: 75 eb jne 4a8 <printint+0x28> if(neg) 4bd: 8b 45 c4 mov -0x3c(%ebp),%eax 4c0: 85 c0 test %eax,%eax 4c2: 74 08 je 4cc <printint+0x4c> buf[i++] = '-'; 4c4: c6 44 0d d7 2d movb $0x2d,-0x29(%ebp,%ecx,1) 4c9: 83 c1 01 add $0x1,%ecx while(--i >= 0) 4cc: 8d 79 ff lea -0x1(%ecx),%edi 4cf: 01 fb add %edi,%ebx 4d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 4d8: 0f b6 03 movzbl (%ebx),%eax 4db: 83 ef 01 sub $0x1,%edi 4de: 83 eb 01 sub $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4e1: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 4e8: 00 4e9: 89 34 24 mov %esi,(%esp) buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 4ec: 88 45 e7 mov %al,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 4ef: 8d 45 e7 lea -0x19(%ebp),%eax 4f2: 89 44 24 04 mov %eax,0x4(%esp) 4f6: e8 ea fe ff ff call 3e5 <write> buf[i++] = digits[x % base]; }while((x /= base) != 0); if(neg) buf[i++] = '-'; while(--i >= 0) 4fb: 83 ff ff cmp $0xffffffff,%edi 4fe: 75 d8 jne 4d8 <printint+0x58> putc(fd, buf[i]); } 500: 83 c4 4c add $0x4c,%esp 503: 5b pop %ebx 504: 5e pop %esi 505: 5f pop %edi 506: 5d pop %ebp 507: c3 ret uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; 508: 89 d0 mov %edx,%eax 50a: f7 d8 neg %eax 50c: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) 513: eb 8c jmp 4a1 <printint+0x21> 515: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000520 <printf>: } // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, char *fmt, ...) { 520: 55 push %ebp 521: 89 e5 mov %esp,%ebp 523: 57 push %edi 524: 56 push %esi 525: 53 push %ebx 526: 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++){ 529: 8b 45 0c mov 0xc(%ebp),%eax 52c: 0f b6 10 movzbl (%eax),%edx 52f: 84 d2 test %dl,%dl 531: 0f 84 c9 00 00 00 je 600 <printf+0xe0> char *s; int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; 537: 8d 4d 10 lea 0x10(%ebp),%ecx 53a: 31 ff xor %edi,%edi 53c: 89 4d d4 mov %ecx,-0x2c(%ebp) 53f: 31 db xor %ebx,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 541: 8d 75 e7 lea -0x19(%ebp),%esi 544: eb 1e jmp 564 <printf+0x44> 546: 66 90 xchg %ax,%ax state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 548: 83 fa 25 cmp $0x25,%edx 54b: 0f 85 b7 00 00 00 jne 608 <printf+0xe8> 551: 66 bf 25 00 mov $0x25,%di int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 555: 83 c3 01 add $0x1,%ebx 558: 0f b6 14 18 movzbl (%eax,%ebx,1),%edx 55c: 84 d2 test %dl,%dl 55e: 0f 84 9c 00 00 00 je 600 <printf+0xe0> c = fmt[i] & 0xff; if(state == 0){ 564: 85 ff test %edi,%edi uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; 566: 0f b6 d2 movzbl %dl,%edx if(state == 0){ 569: 74 dd je 548 <printf+0x28> if(c == '%'){ state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 56b: 83 ff 25 cmp $0x25,%edi 56e: 75 e5 jne 555 <printf+0x35> if(c == 'd'){ 570: 83 fa 64 cmp $0x64,%edx 573: 0f 84 47 01 00 00 je 6c0 <printf+0x1a0> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 579: 83 fa 70 cmp $0x70,%edx 57c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 580: 0f 84 aa 00 00 00 je 630 <printf+0x110> 586: 83 fa 78 cmp $0x78,%edx 589: 0f 84 a1 00 00 00 je 630 <printf+0x110> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 58f: 83 fa 73 cmp $0x73,%edx 592: 0f 84 c0 00 00 00 je 658 <printf+0x138> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 598: 83 fa 63 cmp $0x63,%edx 59b: 90 nop 59c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 5a0: 0f 84 42 01 00 00 je 6e8 <printf+0x1c8> putc(fd, *ap); ap++; } else if(c == '%'){ 5a6: 83 fa 25 cmp $0x25,%edx 5a9: 0f 84 01 01 00 00 je 6b0 <printf+0x190> #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5af: 8b 4d 08 mov 0x8(%ebp),%ecx 5b2: 89 55 cc mov %edx,-0x34(%ebp) 5b5: c6 45 e7 25 movb $0x25,-0x19(%ebp) 5b9: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 5c0: 00 5c1: 89 74 24 04 mov %esi,0x4(%esp) 5c5: 89 0c 24 mov %ecx,(%esp) 5c8: e8 18 fe ff ff call 3e5 <write> 5cd: 8b 55 cc mov -0x34(%ebp),%edx 5d0: 88 55 e7 mov %dl,-0x19(%ebp) 5d3: 8b 45 08 mov 0x8(%ebp),%eax int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 5d6: 83 c3 01 add $0x1,%ebx #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 5d9: 31 ff xor %edi,%edi 5db: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 5e2: 00 5e3: 89 74 24 04 mov %esi,0x4(%esp) 5e7: 89 04 24 mov %eax,(%esp) 5ea: e8 f6 fd ff ff call 3e5 <write> 5ef: 8b 45 0c mov 0xc(%ebp),%eax int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 5f2: 0f b6 14 18 movzbl (%eax,%ebx,1),%edx 5f6: 84 d2 test %dl,%dl 5f8: 0f 85 66 ff ff ff jne 564 <printf+0x44> 5fe: 66 90 xchg %ax,%ax putc(fd, c); } state = 0; } } } 600: 83 c4 3c add $0x3c,%esp 603: 5b pop %ebx 604: 5e pop %esi 605: 5f pop %edi 606: 5d pop %ebp 607: c3 ret #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 608: 8b 45 08 mov 0x8(%ebp),%eax state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 60b: 88 55 e7 mov %dl,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 60e: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 615: 00 616: 89 74 24 04 mov %esi,0x4(%esp) 61a: 89 04 24 mov %eax,(%esp) 61d: e8 c3 fd ff ff call 3e5 <write> 622: 8b 45 0c mov 0xc(%ebp),%eax 625: e9 2b ff ff ff jmp 555 <printf+0x35> 62a: 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); 630: 8b 45 d4 mov -0x2c(%ebp),%eax 633: b9 10 00 00 00 mov $0x10,%ecx ap++; 638: 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); 63a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 641: 8b 10 mov (%eax),%edx 643: 8b 45 08 mov 0x8(%ebp),%eax 646: e8 35 fe ff ff call 480 <printint> 64b: 8b 45 0c mov 0xc(%ebp),%eax ap++; 64e: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 652: e9 fe fe ff ff jmp 555 <printf+0x35> 657: 90 nop } else if(c == 's'){ s = (char*)*ap; 658: 8b 55 d4 mov -0x2c(%ebp),%edx ap++; if(s == 0) 65b: b9 cd 08 00 00 mov $0x8cd,%ecx ap++; } else if(c == 'x' || c == 'p'){ printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ s = (char*)*ap; 660: 8b 3a mov (%edx),%edi ap++; 662: 83 c2 04 add $0x4,%edx 665: 89 55 d4 mov %edx,-0x2c(%ebp) if(s == 0) 668: 85 ff test %edi,%edi 66a: 0f 44 f9 cmove %ecx,%edi s = "(null)"; while(*s != 0){ 66d: 0f b6 17 movzbl (%edi),%edx 670: 84 d2 test %dl,%dl 672: 74 33 je 6a7 <printf+0x187> 674: 89 5d d0 mov %ebx,-0x30(%ebp) 677: 8b 5d 08 mov 0x8(%ebp),%ebx 67a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi putc(fd, *s); s++; 680: 83 c7 01 add $0x1,%edi } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 683: 88 55 e7 mov %dl,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 686: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 68d: 00 68e: 89 74 24 04 mov %esi,0x4(%esp) 692: 89 1c 24 mov %ebx,(%esp) 695: e8 4b fd ff ff call 3e5 <write> } else if(c == 's'){ s = (char*)*ap; ap++; if(s == 0) s = "(null)"; while(*s != 0){ 69a: 0f b6 17 movzbl (%edi),%edx 69d: 84 d2 test %dl,%dl 69f: 75 df jne 680 <printf+0x160> 6a1: 8b 5d d0 mov -0x30(%ebp),%ebx 6a4: 8b 45 0c mov 0xc(%ebp),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6a7: 31 ff xor %edi,%edi 6a9: e9 a7 fe ff ff jmp 555 <printf+0x35> 6ae: 66 90 xchg %ax,%ax s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; } else if(c == '%'){ 6b0: c6 45 e7 25 movb $0x25,-0x19(%ebp) 6b4: e9 1a ff ff ff jmp 5d3 <printf+0xb3> 6b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 6c0: 8b 45 d4 mov -0x2c(%ebp),%eax 6c3: b9 0a 00 00 00 mov $0xa,%ecx ap++; 6c8: 66 31 ff xor %di,%di } else { putc(fd, c); } } else if(state == '%'){ if(c == 'd'){ printint(fd, *ap, 10, 1); 6cb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 6d2: 8b 10 mov (%eax),%edx 6d4: 8b 45 08 mov 0x8(%ebp),%eax 6d7: e8 a4 fd ff ff call 480 <printint> 6dc: 8b 45 0c mov 0xc(%ebp),%eax ap++; 6df: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 6e3: e9 6d fe ff ff jmp 555 <printf+0x35> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 6e8: 8b 55 d4 mov -0x2c(%ebp),%edx putc(fd, *ap); ap++; 6eb: 31 ff xor %edi,%edi #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6ed: 8b 4d 08 mov 0x8(%ebp),%ecx s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 6f0: 8b 02 mov (%edx),%eax #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 6f2: c7 44 24 08 01 00 00 movl $0x1,0x8(%esp) 6f9: 00 6fa: 89 74 24 04 mov %esi,0x4(%esp) 6fe: 89 0c 24 mov %ecx,(%esp) s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 701: 88 45 e7 mov %al,-0x19(%ebp) #include "user.h" static void putc(int fd, char c) { write(fd, &c, 1); 704: e8 dc fc ff ff call 3e5 <write> 709: 8b 45 0c mov 0xc(%ebp),%eax putc(fd, *s); s++; } } else if(c == 'c'){ putc(fd, *ap); ap++; 70c: 83 45 d4 04 addl $0x4,-0x2c(%ebp) 710: e9 40 fe ff ff jmp 555 <printf+0x35> 715: 66 90 xchg %ax,%ax 717: 66 90 xchg %ax,%ax 719: 66 90 xchg %ax,%ax 71b: 66 90 xchg %ax,%ax 71d: 66 90 xchg %ax,%ax 71f: 90 nop 00000720 <free>: static Header base; static Header *freep; void free(void *ap) { 720: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 721: a1 08 09 00 00 mov 0x908,%eax static Header base; static Header *freep; void free(void *ap) { 726: 89 e5 mov %esp,%ebp 728: 57 push %edi 729: 56 push %esi 72a: 53 push %ebx 72b: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; 72e: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 731: 39 c8 cmp %ecx,%eax 733: 73 1d jae 752 <free+0x32> 735: 8d 76 00 lea 0x0(%esi),%esi 738: 8b 10 mov (%eax),%edx 73a: 39 d1 cmp %edx,%ecx 73c: 72 1a jb 758 <free+0x38> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 73e: 39 d0 cmp %edx,%eax 740: 72 08 jb 74a <free+0x2a> 742: 39 c8 cmp %ecx,%eax 744: 72 12 jb 758 <free+0x38> 746: 39 d1 cmp %edx,%ecx 748: 72 0e jb 758 <free+0x38> 74a: 89 d0 mov %edx,%eax free(void *ap) { Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 74c: 39 c8 cmp %ecx,%eax 74e: 66 90 xchg %ax,%ax 750: 72 e6 jb 738 <free+0x18> 752: 8b 10 mov (%eax),%edx 754: eb e8 jmp 73e <free+0x1e> 756: 66 90 xchg %ax,%ax if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ 758: 8b 71 04 mov 0x4(%ecx),%esi 75b: 8d 3c f1 lea (%ecx,%esi,8),%edi 75e: 39 d7 cmp %edx,%edi 760: 74 19 je 77b <free+0x5b> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 762: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 765: 8b 50 04 mov 0x4(%eax),%edx 768: 8d 34 d0 lea (%eax,%edx,8),%esi 76b: 39 ce cmp %ecx,%esi 76d: 74 23 je 792 <free+0x72> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 76f: 89 08 mov %ecx,(%eax) freep = p; 771: a3 08 09 00 00 mov %eax,0x908 } 776: 5b pop %ebx 777: 5e pop %esi 778: 5f pop %edi 779: 5d pop %ebp 77a: c3 ret bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) break; if(bp + bp->s.size == p->s.ptr){ bp->s.size += p->s.ptr->s.size; 77b: 03 72 04 add 0x4(%edx),%esi 77e: 89 71 04 mov %esi,0x4(%ecx) bp->s.ptr = p->s.ptr->s.ptr; 781: 8b 10 mov (%eax),%edx 783: 8b 12 mov (%edx),%edx 785: 89 53 f8 mov %edx,-0x8(%ebx) } else bp->s.ptr = p->s.ptr; if(p + p->s.size == bp){ 788: 8b 50 04 mov 0x4(%eax),%edx 78b: 8d 34 d0 lea (%eax,%edx,8),%esi 78e: 39 ce cmp %ecx,%esi 790: 75 dd jne 76f <free+0x4f> p->s.size += bp->s.size; 792: 03 51 04 add 0x4(%ecx),%edx 795: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 798: 8b 53 f8 mov -0x8(%ebx),%edx 79b: 89 10 mov %edx,(%eax) } else p->s.ptr = bp; freep = p; 79d: a3 08 09 00 00 mov %eax,0x908 } 7a2: 5b pop %ebx 7a3: 5e pop %esi 7a4: 5f pop %edi 7a5: 5d pop %ebp 7a6: c3 ret 7a7: 89 f6 mov %esi,%esi 7a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000007b0 <malloc>: return freep; } void* malloc(uint nbytes) { 7b0: 55 push %ebp 7b1: 89 e5 mov %esp,%ebp 7b3: 57 push %edi 7b4: 56 push %esi 7b5: 53 push %ebx 7b6: 83 ec 2c sub $0x2c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7b9: 8b 5d 08 mov 0x8(%ebp),%ebx if((prevp = freep) == 0){ 7bc: 8b 0d 08 09 00 00 mov 0x908,%ecx malloc(uint nbytes) { Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 7c2: 83 c3 07 add $0x7,%ebx 7c5: c1 eb 03 shr $0x3,%ebx 7c8: 83 c3 01 add $0x1,%ebx if((prevp = freep) == 0){ 7cb: 85 c9 test %ecx,%ecx 7cd: 0f 84 9b 00 00 00 je 86e <malloc+0xbe> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 7d3: 8b 01 mov (%ecx),%eax if(p->s.size >= nunits){ 7d5: 8b 50 04 mov 0x4(%eax),%edx 7d8: 39 d3 cmp %edx,%ebx 7da: 76 27 jbe 803 <malloc+0x53> p->s.size -= nunits; p += p->s.size; p->s.size = nunits; } freep = prevp; return (void*)(p + 1); 7dc: 8d 3c dd 00 00 00 00 lea 0x0(,%ebx,8),%edi morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 7e3: be 00 80 00 00 mov $0x8000,%esi 7e8: 89 7d e4 mov %edi,-0x1c(%ebp) 7eb: 90 nop 7ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 7f0: 3b 05 08 09 00 00 cmp 0x908,%eax 7f6: 74 30 je 828 <malloc+0x78> 7f8: 89 c1 mov %eax,%ecx 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){ 7fa: 8b 01 mov (%ecx),%eax if(p->s.size >= nunits){ 7fc: 8b 50 04 mov 0x4(%eax),%edx 7ff: 39 d3 cmp %edx,%ebx 801: 77 ed ja 7f0 <malloc+0x40> if(p->s.size == nunits) 803: 39 d3 cmp %edx,%ebx 805: 74 61 je 868 <malloc+0xb8> prevp->s.ptr = p->s.ptr; else { p->s.size -= nunits; 807: 29 da sub %ebx,%edx 809: 89 50 04 mov %edx,0x4(%eax) p += p->s.size; 80c: 8d 04 d0 lea (%eax,%edx,8),%eax p->s.size = nunits; 80f: 89 58 04 mov %ebx,0x4(%eax) } freep = prevp; 812: 89 0d 08 09 00 00 mov %ecx,0x908 return (void*)(p + 1); 818: 83 c0 08 add $0x8,%eax } if(p == freep) if((p = morecore(nunits)) == 0) return 0; } } 81b: 83 c4 2c add $0x2c,%esp 81e: 5b pop %ebx 81f: 5e pop %esi 820: 5f pop %edi 821: 5d pop %ebp 822: c3 ret 823: 90 nop 824: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi morecore(uint nu) { char *p; Header *hp; if(nu < 4096) 828: 8b 45 e4 mov -0x1c(%ebp),%eax 82b: 81 fb 00 10 00 00 cmp $0x1000,%ebx 831: bf 00 10 00 00 mov $0x1000,%edi 836: 0f 43 fb cmovae %ebx,%edi 839: 0f 42 c6 cmovb %esi,%eax nu = 4096; p = sbrk(nu * sizeof(Header)); 83c: 89 04 24 mov %eax,(%esp) 83f: e8 09 fc ff ff call 44d <sbrk> if(p == (char*)-1) 844: 83 f8 ff cmp $0xffffffff,%eax 847: 74 18 je 861 <malloc+0xb1> return 0; hp = (Header*)p; hp->s.size = nu; 849: 89 78 04 mov %edi,0x4(%eax) free((void*)(hp + 1)); 84c: 83 c0 08 add $0x8,%eax 84f: 89 04 24 mov %eax,(%esp) 852: e8 c9 fe ff ff call 720 <free> return freep; 857: 8b 0d 08 09 00 00 mov 0x908,%ecx } freep = prevp; return (void*)(p + 1); } if(p == freep) if((p = morecore(nunits)) == 0) 85d: 85 c9 test %ecx,%ecx 85f: 75 99 jne 7fa <malloc+0x4a> 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){ 861: 31 c0 xor %eax,%eax 863: eb b6 jmp 81b <malloc+0x6b> 865: 8d 76 00 lea 0x0(%esi),%esi if(p->s.size == nunits) prevp->s.ptr = p->s.ptr; 868: 8b 10 mov (%eax),%edx 86a: 89 11 mov %edx,(%ecx) 86c: eb a4 jmp 812 <malloc+0x62> Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 86e: c7 05 08 09 00 00 00 movl $0x900,0x908 875: 09 00 00 base.s.size = 0; 878: b9 00 09 00 00 mov $0x900,%ecx Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; if((prevp = freep) == 0){ base.s.ptr = freep = prevp = &base; 87d: c7 05 00 09 00 00 00 movl $0x900,0x900 884: 09 00 00 base.s.size = 0; 887: c7 05 04 09 00 00 00 movl $0x0,0x904 88e: 00 00 00 891: e9 3d ff ff ff jmp 7d3 <malloc+0x23>
; A258087: Start with all terms set to 0. Then add n to the next n+2 terms for n=0,1,2,... . ; 0,0,1,3,6,9,14,18,25,30,39,45,56,63,76,84,99,108,125,135,154,165,186,198,221,234,259,273,300,315,344,360,391,408,441,459,494,513,550,570,609,630,671,693,736,759,804,828,875,900,949,975,1026,1053,1106,1134,1189,1218,1275,1305,1364,1395,1456,1488,1551,1584,1649,1683,1750,1785,1854,1890,1961,1998,2071,2109,2184,2223,2300,2340,2419,2460,2541,2583,2666,2709,2794,2838,2925,2970,3059,3105,3196,3243,3336,3384,3479,3528,3625,3675,3774,3825,3926,3978,4081,4134,4239,4293,4400,4455,4564,4620,4731,4788,4901,4959,5074,5133,5250,5310,5429,5490,5611,5673,5796,5859,5984,6048,6175,6240,6369,6435,6566,6633,6766,6834,6969,7038,7175,7245,7384,7455,7596,7668,7811,7884,8029,8103,8250,8325,8474,8550,8701,8778,8931,9009,9164,9243,9400,9480,9639,9720,9881,9963,10126,10209,10374,10458,10625,10710,10879,10965,11136,11223,11396,11484,11659,11748,11925,12015,12194,12285,12466,12558,12741,12834,13019,13113,13300,13395,13584,13680,13871,13968,14161,14259,14454,14553,14750,14850,15049,15150,15351,15453,15656,15759,15964,16068,16275,16380,16589,16695,16906,17013,17226,17334,17549,17658,17875,17985,18204,18315,18536,18648,18871,18984,19209,19323,19550,19665,19894,20010,20241,20358,20591,20709,20944,21063,21300,21420,21659,21780,22021,22143,22386,22509,22754,22878,23125,23250 mul $0,3 add $0,2 div $0,2 mov $1,$0 sub $1,1 add $1,$0 pow $1,2 sub $1,3 div $1,24
#include "extensions/filters/http/ext_authz/ext_authz.h" #include "common/common/assert.h" #include "common/common/enum_to_int.h" #include "common/http/utility.h" #include "common/router/config_impl.h" #include "extensions/filters/http/well_known_names.h" namespace Envoy { namespace Extensions { namespace HttpFilters { namespace ExtAuthz { struct RcDetailsValues { // The ext_authz filter denied the downstream request. const std::string AuthzDenied = "ext_authz_denied"; // The ext_authz filter encountered a failure, and was configured to fail-closed. const std::string AuthzError = "ext_authz_error"; }; using RcDetails = ConstSingleton<RcDetailsValues>; void FilterConfigPerRoute::merge(const FilterConfigPerRoute& other) { disabled_ = other.disabled_; auto begin_it = other.context_extensions_.begin(); auto end_it = other.context_extensions_.end(); for (auto it = begin_it; it != end_it; ++it) { context_extensions_[it->first] = it->second; } } void Filter::initiateCall(const Http::HeaderMap& headers) { if (filter_return_ == FilterReturn::StopDecoding) { return; } Router::RouteConstSharedPtr route = callbacks_->route(); if (route == nullptr || route->routeEntry() == nullptr) { return; } cluster_ = callbacks_->clusterInfo(); // Fast route - if we are disabled, no need to merge. const FilterConfigPerRoute* specific_per_route_config = Http::Utility::resolveMostSpecificPerFilterConfig<FilterConfigPerRoute>( HttpFilterNames::get().ExtAuthorization, route); if (specific_per_route_config != nullptr) { if (specific_per_route_config->disabled()) { return; } } // We are not disabled - get a merged view of the config: auto&& maybe_merged_per_route_config = Http::Utility::getMergedPerFilterConfig<FilterConfigPerRoute>( HttpFilterNames::get().ExtAuthorization, route, [](FilterConfigPerRoute& cfg_base, const FilterConfigPerRoute& cfg) { cfg_base.merge(cfg); }); Protobuf::Map<std::string, std::string> context_extensions; if (maybe_merged_per_route_config) { context_extensions = maybe_merged_per_route_config.value().takeContextExtensions(); } // If metadata_context_namespaces is specified, pass matching metadata to the ext_authz service envoy::api::v2::core::Metadata metadata_context; const auto& request_metadata = callbacks_->streamInfo().dynamicMetadata().filter_metadata(); for (const auto& context_key : config_->metadataContextNamespaces()) { const auto& metadata_it = request_metadata.find(context_key); if (metadata_it != request_metadata.end()) { (*metadata_context.mutable_filter_metadata())[metadata_it->first] = metadata_it->second; } } Filters::Common::ExtAuthz::CheckRequestUtils::createHttpCheck( callbacks_, headers, std::move(context_extensions), std::move(metadata_context), check_request_, config_->maxRequestBytes(), config_->includePeerCertificate()); ENVOY_STREAM_LOG(trace, "ext_authz filter calling authorization server", *callbacks_); state_ = State::Calling; filter_return_ = FilterReturn::StopDecoding; // Don't let the filter chain continue as we are // going to invoke check call. initiating_call_ = true; client_->check(*this, check_request_, callbacks_->activeSpan()); initiating_call_ = false; } Http::FilterHeadersStatus Filter::decodeHeaders(Http::HeaderMap& headers, bool end_stream) { if (!config_->filterEnabled()) { return Http::FilterHeadersStatus::Continue; } request_headers_ = &headers; buffer_data_ = config_->withRequestBody() && !(end_stream || Http::Utility::isWebSocketUpgradeRequest(headers) || Http::Utility::isH2UpgradeRequest(headers)); if (buffer_data_) { ENVOY_STREAM_LOG(debug, "ext_authz filter is buffering the request", *callbacks_); if (!config_->allowPartialMessage()) { callbacks_->setDecoderBufferLimit(config_->maxRequestBytes()); } return Http::FilterHeadersStatus::StopIteration; } initiateCall(headers); return filter_return_ == FilterReturn::StopDecoding ? Http::FilterHeadersStatus::StopAllIterationAndWatermark : Http::FilterHeadersStatus::Continue; } Http::FilterDataStatus Filter::decodeData(Buffer::Instance& data, bool end_stream) { if (buffer_data_) { const bool buffer_is_full = isBufferFull(); if (end_stream || buffer_is_full) { ENVOY_STREAM_LOG(debug, "ext_authz filter finished buffering the request since {}", *callbacks_, buffer_is_full ? "buffer is full" : "stream is ended"); if (!buffer_is_full) { // Make sure data is available in initiateCall. callbacks_->addDecodedData(data, true); } initiateCall(*request_headers_); return filter_return_ == FilterReturn::StopDecoding ? Http::FilterDataStatus::StopIterationAndWatermark : Http::FilterDataStatus::Continue; } else { return Http::FilterDataStatus::StopIterationAndBuffer; } } return Http::FilterDataStatus::Continue; } Http::FilterTrailersStatus Filter::decodeTrailers(Http::HeaderMap&) { if (buffer_data_) { if (filter_return_ != FilterReturn::StopDecoding) { ENVOY_STREAM_LOG(debug, "ext_authz filter finished buffering the request", *callbacks_); initiateCall(*request_headers_); } return filter_return_ == FilterReturn::StopDecoding ? Http::FilterTrailersStatus::StopIteration : Http::FilterTrailersStatus::Continue; } return Http::FilterTrailersStatus::Continue; } void Filter::setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) { callbacks_ = &callbacks; } void Filter::onDestroy() { if (state_ == State::Calling) { state_ = State::Complete; client_->cancel(); } } void Filter::onComplete(Filters::Common::ExtAuthz::ResponsePtr&& response) { state_ = State::Complete; using Filters::Common::ExtAuthz::CheckStatus; Stats::StatName empty_stat_name; switch (response->status) { case CheckStatus::OK: { ENVOY_STREAM_LOG(trace, "ext_authz filter added header(s) to the request:", *callbacks_); if (config_->clearRouteCache() && (!response->headers_to_add.empty() || !response->headers_to_append.empty())) { ENVOY_STREAM_LOG(debug, "ext_authz is clearing route cache", *callbacks_); callbacks_->clearRouteCache(); } for (const auto& header : response->headers_to_add) { ENVOY_STREAM_LOG(trace, " '{}':'{}'", *callbacks_, header.first.get(), header.second); Http::HeaderEntry* header_to_modify = request_headers_->get(header.first); if (header_to_modify) { header_to_modify->value(header.second.c_str(), header.second.size()); } else { request_headers_->addCopy(header.first, header.second); } } for (const auto& header : response->headers_to_append) { Http::HeaderEntry* header_to_modify = request_headers_->get(header.first); if (header_to_modify) { ENVOY_STREAM_LOG(trace, " '{}':'{}'", *callbacks_, header.first.get(), header.second); Http::HeaderMapImpl::appendToHeader(header_to_modify->value(), header.second); } } if (cluster_) { config_->incCounter(cluster_->statsScope(), config_->ext_authz_ok_); } stats_.ok_.inc(); continueDecoding(); break; } case CheckStatus::Denied: { ENVOY_STREAM_LOG(trace, "ext_authz filter rejected the request. Response status code: '{}", *callbacks_, enumToInt(response->status_code)); stats_.denied_.inc(); if (cluster_) { config_->incCounter(cluster_->statsScope(), config_->ext_authz_denied_); Http::CodeStats::ResponseStatInfo info{config_->scope(), cluster_->statsScope(), empty_stat_name, enumToInt(response->status_code), true, empty_stat_name, empty_stat_name, empty_stat_name, empty_stat_name, false}; config_->httpContext().codeStats().chargeResponseStat(info); } callbacks_->sendLocalReply( response->status_code, response->body, [& headers = response->headers_to_add, &callbacks = *callbacks_](Http::HeaderMap& response_headers) -> void { ENVOY_STREAM_LOG(trace, "ext_authz filter added header(s) to the local response:", callbacks); // First remove all headers requested by the ext_authz filter, // to ensure that they will override existing headers for (const auto& header : headers) { response_headers.remove(header.first); } // Then set all of the requested headers, allowing the // same header to be set multiple times, e.g. `Set-Cookie` for (const auto& header : headers) { ENVOY_STREAM_LOG(trace, " '{}':'{}'", callbacks, header.first.get(), header.second); response_headers.addCopy(header.first, header.second); } }, absl::nullopt, RcDetails::get().AuthzDenied); callbacks_->streamInfo().setResponseFlag(StreamInfo::ResponseFlag::UnauthorizedExternalService); break; } case CheckStatus::Error: { if (cluster_) { config_->incCounter(cluster_->statsScope(), config_->ext_authz_error_); } stats_.error_.inc(); if (config_->failureModeAllow()) { ENVOY_STREAM_LOG(trace, "ext_authz filter allowed the request with error", *callbacks_); stats_.failure_mode_allowed_.inc(); if (cluster_) { config_->incCounter(cluster_->statsScope(), config_->ext_authz_failure_mode_allowed_); } continueDecoding(); } else { ENVOY_STREAM_LOG( trace, "ext_authz filter rejected the request with an error. Response status code: {}", *callbacks_, enumToInt(config_->statusOnError())); callbacks_->streamInfo().setResponseFlag( StreamInfo::ResponseFlag::UnauthorizedExternalService); callbacks_->sendLocalReply(config_->statusOnError(), EMPTY_STRING, nullptr, absl::nullopt, RcDetails::get().AuthzError); } break; } default: NOT_REACHED_GCOVR_EXCL_LINE; break; } } bool Filter::isBufferFull() { const auto* buffer = callbacks_->decodingBuffer(); if (config_->allowPartialMessage() && buffer != nullptr) { return buffer->length() >= config_->maxRequestBytes(); } return false; } void Filter::continueDecoding() { filter_return_ = FilterReturn::ContinueDecoding; if (!initiating_call_) { callbacks_->continueDecoding(); } } } // namespace ExtAuthz } // namespace HttpFilters } // namespace Extensions } // namespace Envoy
; ; ; ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. ; ; Copyright 2007-2019 Broadcom Inc. All rights reserved. ; ; ; This is the default program for the (24+1+4 port) BCM56685K24TS ; To start it, use the following commands from BCM: ; ; 0:led load sdk56685.hex ; 0:led auto on ; 0:led start ; ; The are 2 signle color LEDs per GE port. ; ; There is one bits per LED with the following colors: ; ZERO Green ; ONE Black ; ; Each chip drives only its own LEDs and needs to write them in the order: ; L01, A01, L02, ..., L24, A24 ; ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED ; processor does not always have access to link status. This program ; assumes link status is kept current in bit 0 of RAM byte (0xa0 + portnum). ; Generally, a program running on the main CPU must update these ; locations on link change; see linkscan callback in ; $SDK/src/appl/diag/ledproc.c. ; ; Current implementation: ; ; L01 reflects port 1 link status: ; Black: no link ; Green: link ; ; A01 reflects port 1 activity (even if port is down) ; Black: idle ; Green: RX/TX (pulse extended to 1/3 sec) ; NUM_PORT EQU 24 ; The TX/RX activity lights will be extended for ACT_EXT_TICKS ; so they will be more visible. TICKS EQU 1 SECOND_TICKS EQU (30*TICKS) ACT_EXT_TICKS EQU (SECOND_TICKS/3) TXRX_ALT_TICKS EQU (SECOND_TICKS/6) ; ; Main Update Routine ; ; This routine is called once per tick. ; update: ld a, 30 call link_status call activity ld a, 31 call link_status call activity ld a, 33 call link_status call activity ld a, 32 call link_status call activity ld a, 34 call link_status call activity ld a, 35 call link_status call activity ld a, 36 call link_status call activity ld a, 37 call link_status call activity ld a, 38 call link_status call activity ld a, 39 call link_status call activity ld a, 41 call link_status call activity ld a, 40 call link_status call activity ld a, 42 call link_status call activity ld a, 43 call link_status call activity ld a, 44 call link_status call activity ld a, 45 call link_status call activity ld a, 46 call link_status call activity ld a, 47 call link_status call activity ld a, 49 call link_status call activity ld a, 48 call link_status call activity ld a, 50 call link_status call activity ld a, 51 call link_status call activity ld a, 52 call link_status call activity ld a, 53 call link_status call activity inc (TXRX_ALT_COUNT) send NUM_PORT * 2 ; ; activity ; ; This routine calculates the activity LED for the current port. ; It extends the activity lights using timers (new activity overrides ; and resets the timers). ; ; Inputs: (PORT_NUM) ; Outputs: one bit sent to LED stream ; activity: ;jmp led_green ;DEBUG ONLY call get_link jnc led_black port a pushst RX pushst TX tor pop jnc led_black ;jmp led_green ;DEBUG ONLY ld b, (TXRX_ALT_COUNT) and b, TXRX_ALT_TICKS jnz led_green jmp led_black link_status: ;jmp led_black ;DEBUG ONLY call get_link jnc led_black jmp led_green ; ; get_link ; ; This routine finds the link status LED for a port. ; Link info is in bit 0 of the byte read from PORTDATA[port] ; ; Inputs: Port number in a ; Outputs: Carry flag set if link is up, clear if link is down. ; Destroys: a, b ; get_link: ld b,PORTDATA add b,a ld b,(b) tst b,0 ret ; ; led_black, led_green ; ; Inputs: None ; Outputs: one bit to the LED stream indicating color ; Destroys: None ; led_black: pushst ONE pack ret led_green: pushst ZERO pack ret ; ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) ; TXRX_ALT_COUNT equ 0xe0 PORT_NUM equ 0xe1 ; ; Port data, which must be updated continually by main CPU's ; linkscan task. See $SDK/src/appl/diag/ledproc.c for examples. ; In this program, bit 0 is assumed to contain the link up/down status. ; ;Offset 0x1e80 PORTDATA equ 0xa0 ; Size 48 + 1 + 4 bytes ; ; Symbolic names for the bits of the port status fields ; RX equ 0x0 ; received packet TX equ 0x1 ; transmitted packet COLL equ 0x2 ; collision indicator SPEED_C equ 0x3 ; 100 Mbps SPEED_M equ 0x4 ; 1000 Mbps DUPLEX equ 0x5 ; half/full duplex FLOW equ 0x6 ; flow control capable LINKUP equ 0x7 ; link down/up status LINKEN equ 0x8 ; link disabled/enabled status ZERO equ 0xE ; always 0 ONE equ 0xF ; always 1
BITS 32 SECTION .rodata vakioteksti db "12345", 0 SECTION .text EXTERN strtoul EXTERN reset_errno EXTERN get_errno GLOBAL muunna:function ;Vastaa: const char *muunna(unsigned long *) ;Kokeilufunktio, joka kutsuu C-funktioita. Varsinaisesti muuntaa merkkijonon numeeriseen muotoon. ;Palauttaa numeerisen tuloksen ja osoitteen lรคhdemerkkijonoon. Osoite on NULL, jos muunnos epรคonnistui. muunna: push ebp ;ABI: rekisterin tila sรคilytettรคvรค mov ebp, esp ;funktion pinokehys sub esp, 4 ;varataan pinosta tilaa osoittimelle (4 tavua) call reset_errno mov eax, -1 ;jokin testiarvo != 0 call get_errno cmp eax, 0 ;errno nollattavissa? je .nolla xor eax, eax ;virhetilanne. paluuarvoksi NULL jmp .loppu .nolla: push dword 10 ;kantaluku lea eax, [ebp - 4] ;osoite merkkiin, johon muunnos pysรคhtyi push eax push dword vakioteksti xor eax, eax call strtoul ;standardi C funktio mov edx, eax ;EDX = muunnoksen tulos call get_errno cmp eax, 0 je .toinen_tarkistus xor eax, eax ;virhetilanne. paluuarvoksi NULL jmp .loppu .toinen_tarkistus: mov dword eax, vakioteksti mov ecx, [ebp - 4] cmp eax, ecx ;tekstin pointterien vertailu jne .kolmas_tarkistus xor eax, eax ;muunnos pysรคhtyi ekaan merkkin jmp .loppu .kolmas_tarkistus: cmp byte [ecx], 0 ;muunnettu kokonaan? je .muunnos_ok xor eax, eax ;muunnos pysรคhtyi vรคlille jmp .loppu .muunnos_ok: mov ecx, [ebp + 8] ;ECX = osoite lukuarvomuuttujaan ('pointteri') mov dword [ecx], edx ;unsigned long *pointteri = EDX mov dword eax, vakioteksti .loppu: leave ret
; float __ulong2fs (unsigned long ul) SECTION code_fp_math48 PUBLIC cm48_sdcciyp_ulong2ds EXTERN am48_double32u, cm48_sdcciyp_m482d cm48_sdcciyp_ulong2ds: ; unsigned long to double ; ; enter : stack = unsigned long ul, ret ; ; exit : dehl = sdcc_float(ul) ; ; uses : af, bc, de, hl, bc', de', hl' pop af pop hl pop de push de push hl push af call am48_double32u jp cm48_sdcciyp_m482d
; A130303: A130296 * A000012. ; 1,3,1,5,2,1,7,3,2,1,9,4,3,2,1,11,5,4,3,2,1,13,6,5,4,3,2,1,15,7,6,5,4,3,2,1,17,8,7,6,5,4,3,2,1,19,9,8,7,6,5,4,3,2,1 seq $0,143956 ; Triangle read by rows, A000012 * A136521 * A000012; 1<=k<=n. dif $0,2
.global s_prepare_buffers s_prepare_buffers: push %r10 push %rax push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0xea37, %rsi lea addresses_normal_ht+0x1637, %rdi nop nop nop nop cmp $37314, %rbx mov $42, %rcx rep movsb nop nop nop xor $6827, %rdi lea addresses_WC_ht+0x88c7, %rsi lea addresses_WT_ht+0x11237, %rdi cmp %r10, %r10 mov $111, %rcx rep movsq cmp %rcx, %rcx lea addresses_A_ht+0x18237, %rbp nop nop cmp $60128, %rax mov (%rbp), %r10d sub %rbp, %rbp lea addresses_WT_ht+0xba37, %r10 nop nop nop and %rcx, %rcx movl $0x61626364, (%r10) nop nop nop dec %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r8 push %r9 push %rdi push %rsi // Store lea addresses_normal+0x12237, %r10 nop nop nop cmp %rdi, %rdi mov $0x5152535455565758, %r9 movq %r9, %xmm1 vmovups %ymm1, (%r10) nop nop nop nop nop sub $7988, %rsi // Faulty Load lea addresses_UC+0x5a37, %r13 nop nop nop nop inc %rsi mov (%r13), %di lea oracles, %r13 and $0xff, %rdi shlq $12, %rdi mov (%r13,%rdi,1), %rdi pop %rsi pop %rdi pop %r9 pop %r8 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': True, 'type': 'addresses_UC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_normal'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 2, 'NT': False, 'type': 'addresses_UC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 11, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_WT_ht'}} {'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 4, 'NT': False, 'type': 'addresses_WT_ht'}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
IDEAL MODEL tiny CODESEG ORG 100h start: mov ax, [codex] mov ax, [datax] int 20h codex dw 1234h DATASEG mov ax, [codex] mov ax, [datax] datax dw 5678h CODESEG nop END start
; char *strnchr_callee(const char *s, size_t n, int c) SECTION code_string PUBLIC _strnchr_callee EXTERN asm_strnchr _strnchr_callee: pop af pop hl pop bc pop de push af jp asm_strnchr
/* Copyright 2017 The TensorFlow 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 "tensorflow/compiler/xla/service/hlo_graph_dumper.h" #include <string> #include "tensorflow/compiler/xla/layout_util.h" #include "tensorflow/compiler/xla/legacy_flags/hlo_graph_dumper_flags.h" #include "tensorflow/compiler/xla/literal_util.h" #include "tensorflow/compiler/xla/service/hlo_module.h" #include "tensorflow/compiler/xla/shape_util.h" #include "tensorflow/compiler/xla/types.h" #include "tensorflow/core/lib/core/status.h" #include "tensorflow/core/lib/io/path.h" #include "tensorflow/core/lib/strings/numbers.h" #include "tensorflow/core/lib/strings/str_util.h" #include "tensorflow/core/lib/strings/strcat.h" #include "tensorflow/core/lib/strings/stringprintf.h" #include "tensorflow/core/platform/env.h" #include "tensorflow/core/platform/protobuf.h" using ::tensorflow::Env; using ::tensorflow::WriteStringToFile; using ::tensorflow::io::JoinPath; using ::tensorflow::strings::Appendf; using ::tensorflow::strings::Printf; using ::tensorflow::strings::StrAppend; using ::tensorflow::strings::StrCat; using ::tensorflow::str_util::Join; namespace xla { namespace hlo_graph_dumper { namespace { // Returns the dot graph identifier for the given instruction. string InstructionId(const HloInstruction* instruction) { return Printf("%lld", reinterpret_cast<uint64>(instruction)); } // Returns the dot graph identifier for the given computation. string ComputationId(const HloComputation* computation) { return Printf("%lld", reinterpret_cast<uint64>(computation)); } // Returns a compact string that represents the convolution dimension numbers. string ConvolutionDimensionNumbersToString( const ConvolutionDimensionNumbers& dim_numbers) { return Printf("B@%lld,Z@%lld,KIZ@%lld,KOZ@%lld", dim_numbers.batch_dimension(), dim_numbers.feature_dimension(), dim_numbers.kernel_input_feature_dimension(), dim_numbers.kernel_output_feature_dimension()); } // Returns a compact string that represents the non-trivial fields in the window // description. If there are no non-trivial fields, the empty string is // returned. string WindowToString(const Window& window) { bool display_padding = false; bool display_window_dilation = false; bool display_base_dilation = false; bool display_stride = false; for (const WindowDimension& dimension : window.dimensions()) { display_padding |= dimension.padding_low() != 0 || dimension.padding_high() != 0; display_window_dilation |= dimension.window_dilation() != 1; display_base_dilation |= dimension.base_dilation() != 1; display_stride |= dimension.stride() != 1; } std::vector<string> pieces = {}; if (display_padding) { pieces.push_back("\\n"); pieces.push_back("padding=["); for (const WindowDimension& dimension : window.dimensions()) { pieces.push_back(StrCat("(", dimension.padding_low(), ",", dimension.padding_high(), ")")); pieces.push_back(", "); } pieces.pop_back(); pieces.push_back("]"); } // Make a convenient lambda that adds a simple int64 field in each // WindowDimension. auto add_field = [&pieces, &window]( const string& label, tensorflow::protobuf_int64 (WindowDimension::*member)() const) { pieces.push_back("\\n"); pieces.push_back(label + "=["); for (const WindowDimension& dimension : window.dimensions()) { pieces.push_back(StrCat(((&dimension)->*member)())); pieces.push_back(", "); } pieces.pop_back(); pieces.push_back("]"); }; if (display_window_dilation) { add_field("window_dilation", &WindowDimension::window_dilation); } if (display_base_dilation) { add_field("base_dilation", &WindowDimension::base_dilation); } if (display_stride) { add_field("stride", &WindowDimension::stride); } return Join(pieces, ""); } // Returns the dot graph edges and nodes for the given instruction sequence. // Edges which extend between computations are added to the vector // intercomputation_edges. This is necessary because graphviz does not render // the graph properly unless these inter-computation edges appear after all // subgraph statements. string InstructionSequenceGraph( const std::list<std::unique_ptr<HloInstruction>>& instructions, bool show_addresses, bool show_layouts, std::vector<string>* intercomputation_edges, const HloExecutionProfile* hlo_execution_profile) { string graph_body; // Create a single "record" node for the parameters. This node is a // partitioned rectangle with one partition per parameter node. The keeps // all the parameter instructions together. std::vector<HloInstruction*> param_instructions; for (auto& instruction : instructions) { if (instruction->opcode() == HloOpcode::kParameter) { std::vector<HloInstruction*>::size_type param_number = instruction->parameter_number(); if (param_instructions.size() < param_number + 1) { param_instructions.resize(param_number + 1, nullptr); } param_instructions[param_number] = instruction.get(); } } string param_node_name; if (!param_instructions.empty()) { std::vector<string> param_ports; param_node_name = StrCat("parameters_", InstructionId(param_instructions[0])); for (auto& param : param_instructions) { string label = StrCat(param->parameter_name(), "\\n", ShapeUtil::HumanString(param->shape())); if (show_addresses) { Appendf(&label, "\\n[%p]", param); } if (show_layouts) { StrAppend(&label, "\\nlayout=\\{", Join(param->shape().layout().minor_to_major(), ","), "\\}"); } param_ports.push_back( Printf("<%s> %s", InstructionId(param).c_str(), label.c_str())); } StrAppend(&graph_body, param_node_name, " [shape=record,style=filled,fillcolor=\"lightblue1\",", "label=\"{parameters | {", Join(param_ports, "|"), "}}\"];\n"); } for (auto& instruction : instructions) { string color = "peachpuff"; string shape = "ellipse"; string name = HloOpcodeString(instruction->opcode()); if (HloOpcode::kFusion == instruction->opcode()) { name += ": " + FusionKindString(instruction->fusion_kind()); } if (HloOpcode::kConvolution == instruction->opcode()) { name += ":\\n" + ConvolutionDimensionNumbersToString( instruction->convolution_dimension_numbers()) + WindowToString(instruction->window()); } name += "\\n" + instruction->name(); std::vector<HloComputation*> called_computations; // Pick different colors or shapes for instructions which are particularly // expensive (eg, dot) and those which are unusual in some way or unique // (eg, parameter). switch (instruction->opcode()) { // "Normal" instructions. Mostly cheap and elementwise. No call to // embedded computations. In this case, use default color, shape and // label. case HloOpcode::kAbs: case HloOpcode::kAdd: case HloOpcode::kCeil: case HloOpcode::kClamp: case HloOpcode::kConcatenate: case HloOpcode::kConvert: case HloOpcode::kDivide: case HloOpcode::kDynamicSlice: case HloOpcode::kDynamicUpdateSlice: case HloOpcode::kEq: case HloOpcode::kExp: case HloOpcode::kFloor: case HloOpcode::kGe: case HloOpcode::kGt: case HloOpcode::kIndex: case HloOpcode::kIsFinite: case HloOpcode::kLe: case HloOpcode::kLog: case HloOpcode::kLogicalAnd: case HloOpcode::kLogicalNot: case HloOpcode::kLogicalOr: case HloOpcode::kLt: case HloOpcode::kMaximum: case HloOpcode::kMinimum: case HloOpcode::kMultiply: case HloOpcode::kNe: case HloOpcode::kNegate: case HloOpcode::kPad: case HloOpcode::kPower: case HloOpcode::kRemainder: case HloOpcode::kReshape: case HloOpcode::kReverse: case HloOpcode::kSelect: case HloOpcode::kSign: case HloOpcode::kSlice: case HloOpcode::kSort: case HloOpcode::kSubtract: case HloOpcode::kTanh: case HloOpcode::kTuple: case HloOpcode::kUpdate: break; case HloOpcode::kBroadcast: case HloOpcode::kTranspose: StrAppend(&name, "\\n", "dims={", Join(instruction->dimensions(), ","), "}"); break; case HloOpcode::kGetTupleElement: StrAppend(&name, "\\nindex=", instruction->tuple_index()); break; case HloOpcode::kRng: StrAppend(&name, "\\n", RandomDistribution_Name(instruction->random_distribution())); break; case HloOpcode::kConstant: shape = "boxed"; color = "palegreen"; if (ShapeUtil::IsScalar(instruction->shape())) { StrAppend(&name, "\\n", "value=", LiteralUtil::GetAsString( instruction->literal(), {})); } break; case HloOpcode::kBitcast: case HloOpcode::kCopy: color = "white"; break; case HloOpcode::kCall: color = "tomato"; break; case HloOpcode::kCustomCall: color = "tomato4"; StrAppend(&name, "\\n", "custom_call_target=", instruction->custom_call_target()); break; case HloOpcode::kDot: color = "slateblue"; break; case HloOpcode::kSend: color = "purple"; break; case HloOpcode::kRecv: color = "orange"; break; case HloOpcode::kMap: color = "palevioletred"; break; case HloOpcode::kParameter: // A single record node is created for all the parameter nodes with a // port for each parameter instruction. No need to emit anything in this // case. continue; case HloOpcode::kReduce: StrAppend(&name, " dims=", Join(instruction->dimensions(), ",")); color = "lightsalmon"; break; case HloOpcode::kSelectAndScatter: case HloOpcode::kReduceWindow: color = "lightsalmon"; break; case HloOpcode::kTrace: color = "white"; break; case HloOpcode::kWhile: color = "forestgreen"; break; case HloOpcode::kFusion: color = "gray"; break; case HloOpcode::kConvolution: color = "red"; break; case HloOpcode::kCrossReplicaSum: color = "turquoise"; break; case HloOpcode::kInfeed: case HloOpcode::kOutfeed: color = "blue"; break; } // Create instruction node with appropriate label, shape, and color. string label = StrCat(name, "\\n", ShapeUtil::HumanString(instruction->shape())); if (show_addresses) { Appendf(&label, "\\n[%p]", instruction.get()); } if (show_layouts && LayoutUtil::HasLayout(instruction->shape())) { string layout_string; if (ShapeUtil::IsTuple(instruction->shape())) { // For tuples, emit the full shape because the layout of a tuple is not // represented in a single Layout field. layout_string = ShapeUtil::HumanStringWithLayout(instruction->shape()); } else { layout_string = Join(instruction->shape().layout().minor_to_major(), ","); } StrAppend(&label, "\\nlayout={", layout_string, "}"); } if (hlo_execution_profile != nullptr) { auto hlo_cycles_executed = hlo_execution_profile->GetProfileResult(*instruction); auto total_cycles_executed = hlo_execution_profile->total_cycles_executed(*instruction->parent()); if (hlo_cycles_executed > 0 && total_cycles_executed > 0) { Appendf(&label, "\\n%% of cycles executed=%.2f", (static_cast<double>(hlo_cycles_executed) / static_cast<double>(total_cycles_executed)) * 100); } } Appendf(&graph_body, "%s [label=\"%s\", shape=%s, style=filled, fillcolor=%s];\n", InstructionId(instruction.get()).c_str(), label.c_str(), shape.c_str(), color.c_str()); // Create edges from the instruction's operands to the instruction. int64 operand_number = 0; for (auto* operand : instruction->operands()) { string src; if (operand->opcode() == HloOpcode::kParameter) { // If operand is a parameter, then select the proper partition (port) in // the unified parameter node. src = param_node_name + ":" + InstructionId(operand); } else { src = InstructionId(operand); } Appendf(&graph_body, "%s -> %s", src.c_str(), InstructionId(instruction.get()).c_str()); if (instruction->operand_count() > 1) { Appendf(&graph_body, " [headlabel=\"%lld\",labeldistance=2]", operand_number); } StrAppend(&graph_body, ";\n"); ++operand_number; } // Fusion nodes are handled specially because they contain nested // expressions. if (instruction->opcode() == HloOpcode::kFusion) { string cluster_name = StrCat("cluster_", InstructionId(instruction.get())); StrAppend(&graph_body, "subgraph ", cluster_name, " {\n"); StrAppend(&graph_body, "label=\"fused expression\";\nstyle=filled;\n" "color=lightgrey;\n"); StrAppend(&graph_body, InstructionSequenceGraph( instruction->fused_instructions(), show_addresses, show_layouts, intercomputation_edges, hlo_execution_profile), "}\n"); string fusion_edge = StrCat(InstructionId(instruction->fused_expression_root()), " -> ", InstructionId(instruction.get()), " [ style = \"dotted\", arrowsize=0.0, ltail=", cluster_name, " ];\n"); intercomputation_edges->push_back(fusion_edge); } else { // Add a dotted edge between the instruction and any computations that the // instruction calls. for (auto* computation : instruction->MakeCalledComputationsSet()) { string cluster_name = StrCat("cluster_", ComputationId(computation)); string call_edge = Printf( "%s -> %s [ style=dashed; ltail=%s ];\n", InstructionId(computation->root_instruction()).c_str(), InstructionId(instruction.get()).c_str(), cluster_name.c_str()); intercomputation_edges->push_back(call_edge); } } } return graph_body; } string ComputationToDotGraph(const HloComputation& computation, const string& label, bool show_addresses, bool show_layouts, const HloExecutionProfile* hlo_execution_profile) { string graph_label = StrCat(label, "\\n", computation.name()); if (hlo_execution_profile != nullptr) { auto cycles = hlo_execution_profile->total_cycles_executed(computation); Appendf(&graph_label, "\\ntotal cycles = %lld (%s)", cycles, tensorflow::strings::HumanReadableNum(cycles).c_str()); } string graph = Printf("digraph G {\nrankdir=TB;\ncompound=true;\nlabel=\"%s\"\n", graph_label.c_str()); // Emit embedded computations as subgraph clusters. std::vector<string> intercomputation_edges; for (auto embedded : computation.MakeEmbeddedComputationsList()) { string graph_body = InstructionSequenceGraph( embedded->instructions(), show_addresses, show_layouts, &intercomputation_edges, hlo_execution_profile); Appendf(&graph, "subgraph cluster_%s {\nlabel=\"%s\";\n%s}\n", ComputationId(embedded).c_str(), embedded->name().c_str(), graph_body.c_str()); } StrAppend(&graph, InstructionSequenceGraph(computation.instructions(), show_addresses, show_layouts, &intercomputation_edges, hlo_execution_profile)); // Edges between computations (subgraph clusters) must be emitted last for the // graph to be rendered properly for some reason. StrAppend(&graph, Join(intercomputation_edges, "\n"), "}\n"); return graph; } tensorflow::mutex& RendererMutex() { static tensorflow::mutex* mu = new tensorflow::mutex; return *mu; } std::map<int, GraphRendererInterface*>* GraphRenderers() { static auto* graph_renderers = new std::map<int, GraphRendererInterface*>(); return graph_renderers; } GraphRendererInterface* GetGraphRenderer() { tensorflow::mutex_lock lock(RendererMutex()); auto* graph_renderers = GraphRenderers(); auto it = graph_renderers->rbegin(); CHECK(it != graph_renderers->rend()) << "No registered graph dumpers"; return it->second; } } // namespace Registrar::Registrar(GraphRendererInterface* dumper, int priority) { tensorflow::mutex_lock lock(RendererMutex()); auto* graph_renderers = GraphRenderers(); graph_renderers->emplace(priority, dumper); } namespace { class FileGraphRenderer : public GraphRendererInterface { public: string RenderGraph(const string& graph) override { static std::atomic<int> output_num(0); legacy_flags::HloGraphDumperFlags* flags = legacy_flags::GetHloGraphDumperFlags(); string path = StrCat(flags->xla_hlo_dump_graph_path, "hlo_graph_", output_num++, ".dot"); tensorflow::Status status = tensorflow::WriteStringToFile(tensorflow::Env::Default(), path, graph); if (!status.ok()) { LOG(WARNING) << "Saving HLO graph failed: " << status; } return path; } }; XLA_REGISTER_GRAPH_RENDERER(FileGraphRenderer, 0); } // namespace string DumpGraph(const HloComputation& computation, const string& label, bool show_addresses, bool show_layouts, const HloExecutionProfile* hlo_execution_profile) { string graph = ComputationToDotGraph(computation, label, show_addresses, show_layouts, hlo_execution_profile); string graph_url = GetGraphRenderer()->RenderGraph(graph); LOG(INFO) << "computation " << computation.name() << " [" << label << "]: " << graph_url; return graph_url; } void DumpText(const HloModule& module, const string& label, const string& directory_path, bool do_prefix) { Env* env = Env::Default(); TF_CHECK_OK(env->RecursivelyCreateDir(directory_path)); string prefix = StrCat(env->NowMicros()); string filename = do_prefix ? StrCat(prefix, "-", label, ".txt") : StrCat(label, ".txt"); string path = JoinPath(directory_path, filename); TF_CHECK_OK(WriteStringToFile(env, path, module.ToString())); } } // namespace hlo_graph_dumper } // namespace xla
; Filename: strlen.asm ; Subroutine: STRLEN ; Description: Finds length of an ASCIIZ string ; Assumes: R1 - string address ; Returns: R2 - length of the string ;return length of the string .orig x0200 START LEA R1, S1 JSR STRLEN LEA R1, S6 JSR STRLEN LEA R1, S2 JSR STRLEN LEA R1, S5 JSR STRLEN LEA R1, S3 JSR STRLEN LEA R1, S4 JSR STRLEN LEA R1, S7 JSR STRLEN BR START ; loop forever S1 .STRINGZ "Ciao!" S2 .STRINGZ "Hi!" S3 .STRINGZ "Salve!" S4 .STRINGZ "Hello!" S5 .STRINGZ "Gelato!" S6 .STRINGZ "" S7 .STRINGZ "Italiano" ; Subroutine: STRLEN ; Description: Finds length of ASCIIZ string ; Assumes: R1 = string address ; Returns: R2 = length of the string STRLEN ST R0, STRLEN_R0 ; context save ST R1, STRLEN_R1 ; context save ADDED AND R2, R2, #0 ; ADDED initialize String len to 0 STRLEN_LOOP LDR R0, R1, #0 ; get current character BRz STRLEN_EXIT ; at null terminator? ADD R2, R2, #1 ; ADDED increment the string count//count how many ; numbers of the character is not null ADD R1, R1, #1 ; increment string pointer (address) BR STRLEN_LOOP STRLEN_EXIT LD R0, STRLEN_R0 ; context restore LD R1, STRLEN_R1 ; ADDED ;NOT R3, R3 ;ADD R3, R3, #1 ;ADD R2, R3, #1 RET STRLEN_R0 .BLKW 1 STRLEN_R1 .BLKW 1 ; ADDED .end
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %rax push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0xed9e, %rsi lea addresses_A_ht+0x2232, %rdi nop nop nop nop add %r13, %r13 mov $35, %rcx rep movsb nop nop nop nop add $8734, %rbx lea addresses_D_ht+0x5ee6, %rdx nop nop nop nop nop xor %r10, %r10 and $0xffffffffffffffc0, %rdx movaps (%rdx), %xmm3 vpextrq $1, %xmm3, %rcx nop cmp %rdi, %rdi lea addresses_A_ht+0x3ca6, %rsi lea addresses_WC_ht+0x1ea86, %rdi nop sub %rax, %rax mov $92, %rcx rep movsb nop nop xor %r13, %r13 lea addresses_normal_ht+0x1e6e6, %rbx nop nop nop nop nop sub $32180, %rdx mov $0x6162636465666768, %r10 movq %r10, %xmm6 vmovups %ymm6, (%rbx) nop nop nop nop nop cmp $11383, %rdx lea addresses_normal_ht+0x165dc, %rdx nop nop nop and %rdi, %rdi mov (%rdx), %si nop nop nop nop dec %rax lea addresses_UC_ht+0x185e6, %rsi lea addresses_D_ht+0x1eb86, %rdi clflush (%rdi) nop nop nop and $19410, %r13 mov $127, %rcx rep movsl and $10691, %rdx lea addresses_WC_ht+0x525a, %rbx nop nop inc %r13 movb (%rbx), %al nop nop nop nop and $4719, %r13 lea addresses_normal_ht+0x108e6, %rbx nop nop xor $15492, %rdi mov (%rbx), %si nop nop nop sub $40055, %rsi lea addresses_WT_ht+0x13946, %rdx nop nop nop nop lfence mov $0x6162636465666768, %r10 movq %r10, (%rdx) nop nop nop nop inc %rsi lea addresses_normal_ht+0x17146, %rsi lea addresses_UC_ht+0x6f66, %rdi nop nop nop nop dec %rdx mov $101, %rcx rep movsw nop nop nop inc %r10 lea addresses_WT_ht+0x1bce6, %rsi lea addresses_normal_ht+0x1be06, %rdi nop nop add %rdx, %rdx mov $90, %rcx rep movsl nop nop xor $24407, %rbx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rax pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r15 push %r8 push %r9 push %rbx // Store lea addresses_WC+0x1a6e6, %r9 cmp %r10, %r10 movb $0x51, (%r9) nop nop nop xor %r8, %r8 // Store lea addresses_WT+0x10e86, %r13 nop nop nop sub $13120, %r8 movl $0x51525354, (%r13) // Exception!!! nop nop nop mov (0), %r9 nop nop nop xor $56448, %r13 // Faulty Load lea addresses_D+0x10ee6, %r9 nop nop cmp %rbx, %rbx mov (%r9), %r8 lea oracles, %rbx and $0xff, %r8 shlq $12, %r8 mov (%rbx,%r8,1), %r8 pop %rbx pop %r9 pop %r8 pop %r15 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_D', 'congruent': 0}} {'dst': {'same': False, 'NT': True, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC', 'congruent': 11}, 'OP': 'STOR'} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_WT', 'congruent': 5}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_D', 'congruent': 0}} <gen_prepare_buffer> {'dst': {'same': False, 'congruent': 2, 'type': 'addresses_A_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 10}} {'dst': {'same': False, 'congruent': 5, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_normal_ht', 'congruent': 11}, 'OP': 'STOR'} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': True, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 1}} {'dst': {'same': True, 'congruent': 5, 'type': 'addresses_D_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_WC_ht', 'congruent': 2}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_normal_ht', 'congruent': 9}} {'dst': {'same': False, 'NT': False, 'AVXalign': False, 'size': 8, 'type': 'addresses_WT_ht', 'congruent': 2}, 'OP': 'STOR'} {'dst': {'same': False, 'congruent': 6, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_normal_ht'}} {'dst': {'same': False, 'congruent': 2, 'type': 'addresses_normal_ht'}, 'OP': 'REPM', 'src': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
#include <iostream> using namespace std; int f(int n){ int div=2, nrDiv=0, s=0; while(n>1){ nrDiv=0; while(n%div==0){ n/=div; nrDiv++; } if(nrDiv) s+=div; div++; if(div*div>n) div=n; } return s; } int main(){ int a, b; cin>>a>>b; if(f(a)==f(b)) cout<<"DA"; else cout<<"NU"; return 0; }
; =============================================================== ; Jan 2014 ; =============================================================== ; ; int fflush_unlocked(FILE *stream) ; ; Flush the stream. For streams most recently written to, this ; means sending any buffered output to the device. For streams ; most recently read from, this means seeking backward to unread ; any unconsumed input. ; ; If stream == 0, all streams are flushed. ; ; =============================================================== INCLUDE "clib_cfg.asm" SECTION code_clib SECTION code_stdio PUBLIC asm_fflush_unlocked PUBLIC asm0_fflush_unlocked, asm1_fflush_unlocked EXTERN STDIO_SEEK_CUR, STDIO_MSG_SEEK, STDIO_MSG_FLSH EXTERN asm__fflushall_unlocked, l_jpix, error_mc, error_znc asm_fflush_unlocked: ; enter : ix = FILE * ; ; exit : ix = FILE * ; ; if success ; ; hl = 0 ; carry reset ; ; if stream is in error state ; if write failed ; ; hl = -1 ; carry set ; ; uses : all except ix ld a,ixl or ixh jp z, asm__fflushall_unlocked asm0_fflush_unlocked: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_STDIO & $01 EXTERN __stdio_verify_valid call __stdio_verify_valid ret c ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; asm1_fflush_unlocked: bit 3,(ix+3) jp nz, error_mc ; if stream is in an error state bit 1,(ix+4) jr z, last_was_write last_was_read: ; last operation was a read bit 0,(ix+4) jr z, forward_flush ; unget char present res 0,(ix+4) ; clear ungetchar res 4,(ix+3) ; clear eof ld c,STDIO_SEEK_CUR ld hl,$ffff ld e,l ld d,h ; dehl = -1 exx ld c,STDIO_SEEK_CUR ld a,STDIO_MSG_SEEK call l_jpix ; seek backward one byte last_was_write: ; last operation was write forward_flush: ; forward flush message along stdio chain ld a,STDIO_MSG_FLSH call l_jpix jp nc, error_znc jp error_mc
; A070369: a(n) = 5^n mod 14. ; 1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13,9,3,1,5,11,13 mov $2,6 mov $3,6 lpb $0 sub $0,1 add $2,6 add $1,$2 sub $1,2 sub $1,$3 add $3,$1 lpe add $1,1
; void tshr_cls_wc_pix(struct r_Rect8 *r, uchar pix) SECTION code_clib SECTION code_arch PUBLIC tshr_cls_wc_pix_callee EXTERN asm_tshr_cls_wc_pix tshr_cls_wc_pix_callee: pop af pop hl pop ix push af jp asm_tshr_cls_wc_pix
; A025745: Index of 10^n within sequence of numbers of form 7^i*10^j. ; 1,3,6,10,15,21,29,38,48,59,71,85,100,116,133,151,170,191,213,236,260,285,312,340,369,399,430,462,496,531,567,604,642,682,723,765,808,852,897,944,992,1041,1091,1142,1195,1249,1304,1360,1417,1475,1535,1596,1658 lpb $0 mov $2,$0 sub $0,1 seq $2,32798 ; Numbers such that n(n+1)(n+2)...(n+12) / (n+(n+1)+(n+2)+...+(n+12)) is a multiple of n. add $1,$2 lpe add $1,1 mov $0,$1
; A099925: a(n) = Lucas(n) + (-1)^n. ; 3,0,4,3,8,10,19,28,48,75,124,198,323,520,844,1363,2208,3570,5779,9348,15128,24475,39604,64078,103683,167760,271444,439203,710648,1149850,1860499,3010348,4870848,7881195,12752044,20633238,33385283,54018520,87403804,141422323,228826128,370248450,599074579,969323028,1568397608,2537720635,4106118244,6643838878,10749957123,17393796000,28143753124,45537549123,73681302248,119218851370,192900153619,312119004988,505019158608,817138163595,1322157322204,2139295485798,3461452808003,5600748293800,9062201101804,14662949395603,23725150497408,38388099893010,62113250390419,100501350283428,162614600673848,263115950957275,425730551631124,688846502588398,1114577054219523,1803423556807920,2918000611027444,4721424167835363,7639424778862808 mov $1,$0 mov $2,$0 gcd $0,2 mod $2,2 cal $1,32 ; Lucas numbers beginning at 2: L(n) = L(n-1) + L(n-2), L(0) = 2, L(1) = 1. sub $2,8 sub $2,$0 sub $1,$2 sub $1,9
_sh: file format elf32-i386 Disassembly of section .text: 00000000 <main>: return 0; } int main(void) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 52 push %edx static char buf[100]; int fd; // Ensure that three file descriptors are open. while((fd = open("console", O_RDWR)) >= 0){ f: eb 0c jmp 1d <main+0x1d> 11: 8d 76 00 lea 0x0(%esi),%esi if(fd >= 3){ 14: 83 f8 02 cmp $0x2,%eax 17: 0f 8f af 00 00 00 jg cc <main+0xcc> while((fd = open("console", O_RDWR)) >= 0){ 1d: 83 ec 08 sub $0x8,%esp 20: 6a 02 push $0x2 22: 68 8d 10 00 00 push $0x108d 27: e8 b9 0b 00 00 call be5 <open> 2c: 83 c4 10 add $0x10,%esp 2f: 85 c0 test %eax,%eax 31: 79 e1 jns 14 <main+0x14> 33: eb 2a jmp 5f <main+0x5f> 35: 8d 76 00 lea 0x0(%esi),%esi } } // Read and run input commands. while(getcmd(buf, sizeof(buf)) >= 0){ if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ 38: 80 3d c2 16 00 00 20 cmpb $0x20,0x16c2 3f: 74 4d je 8e <main+0x8e> 41: 8d 76 00 lea 0x0(%esi),%esi int fork1(void) { int pid; pid = fork(); 44: e8 54 0b 00 00 call b9d <fork> if(pid == -1) 49: 83 f8 ff cmp $0xffffffff,%eax 4c: 0f 84 9d 00 00 00 je ef <main+0xef> if(fork1() == 0) 52: 85 c0 test %eax,%eax 54: 0f 84 80 00 00 00 je da <main+0xda> wait(); 5a: e8 4e 0b 00 00 call bad <wait> while(getcmd(buf, sizeof(buf)) >= 0){ 5f: 83 ec 08 sub $0x8,%esp 62: 6a 64 push $0x64 64: 68 c0 16 00 00 push $0x16c0 69: e8 8e 00 00 00 call fc <getcmd> 6e: 83 c4 10 add $0x10,%esp 71: 85 c0 test %eax,%eax 73: 78 14 js 89 <main+0x89> if(buf[0] == 'c' && buf[1] == 'd' && buf[2] == ' '){ 75: 80 3d c0 16 00 00 63 cmpb $0x63,0x16c0 7c: 75 c6 jne 44 <main+0x44> 7e: 80 3d c1 16 00 00 64 cmpb $0x64,0x16c1 85: 75 bd jne 44 <main+0x44> 87: eb af jmp 38 <main+0x38> exit(); 89: e8 17 0b 00 00 call ba5 <exit> buf[strlen(buf)-1] = 0; // chop \n 8e: 83 ec 0c sub $0xc,%esp 91: 68 c0 16 00 00 push $0x16c0 96: e8 ad 09 00 00 call a48 <strlen> 9b: c6 80 bf 16 00 00 00 movb $0x0,0x16bf(%eax) if(chdir(buf+3) < 0) a2: c7 04 24 c3 16 00 00 movl $0x16c3,(%esp) a9: e8 67 0b 00 00 call c15 <chdir> ae: 83 c4 10 add $0x10,%esp b1: 85 c0 test %eax,%eax b3: 79 aa jns 5f <main+0x5f> printf(2, "cannot cd %s\n", buf+3); b5: 50 push %eax b6: 68 c3 16 00 00 push $0x16c3 bb: 68 95 10 00 00 push $0x1095 c0: 6a 02 push $0x2 c2: e8 19 0c 00 00 call ce0 <printf> c7: 83 c4 10 add $0x10,%esp ca: eb 93 jmp 5f <main+0x5f> close(fd); cc: 83 ec 0c sub $0xc,%esp cf: 50 push %eax d0: e8 f8 0a 00 00 call bcd <close> break; d5: 83 c4 10 add $0x10,%esp d8: eb 85 jmp 5f <main+0x5f> runcmd(parsecmd(buf)); da: 83 ec 0c sub $0xc,%esp dd: 68 c0 16 00 00 push $0x16c0 e2: e8 a1 08 00 00 call 988 <parsecmd> e7: 89 04 24 mov %eax,(%esp) ea: e8 6d 00 00 00 call 15c <runcmd> panic("fork"); ef: 83 ec 0c sub $0xc,%esp f2: 68 16 10 00 00 push $0x1016 f7: e8 44 00 00 00 call 140 <panic> 000000fc <getcmd>: { fc: 55 push %ebp fd: 89 e5 mov %esp,%ebp ff: 56 push %esi 100: 53 push %ebx 101: 8b 5d 08 mov 0x8(%ebp),%ebx 104: 8b 75 0c mov 0xc(%ebp),%esi printf(2, "$ "); 107: 83 ec 08 sub $0x8,%esp 10a: 68 ec 0f 00 00 push $0xfec 10f: 6a 02 push $0x2 111: e8 ca 0b 00 00 call ce0 <printf> memset(buf, 0, nbuf); 116: 83 c4 0c add $0xc,%esp 119: 56 push %esi 11a: 6a 00 push $0x0 11c: 53 push %ebx 11d: e8 4e 09 00 00 call a70 <memset> gets(buf, nbuf); 122: 58 pop %eax 123: 5a pop %edx 124: 56 push %esi 125: 53 push %ebx 126: e8 85 09 00 00 call ab0 <gets> if(buf[0] == 0) // EOF 12b: 83 c4 10 add $0x10,%esp 12e: 31 c0 xor %eax,%eax 130: 80 3b 00 cmpb $0x0,(%ebx) 133: 0f 94 c0 sete %al 136: f7 d8 neg %eax } 138: 8d 65 f8 lea -0x8(%ebp),%esp 13b: 5b pop %ebx 13c: 5e pop %esi 13d: 5d pop %ebp 13e: c3 ret 13f: 90 nop 00000140 <panic>: { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 83 ec 0c sub $0xc,%esp printf(2, "%s\n", s); 146: ff 75 08 pushl 0x8(%ebp) 149: 68 89 10 00 00 push $0x1089 14e: 6a 02 push $0x2 150: e8 8b 0b 00 00 call ce0 <printf> exit(); 155: e8 4b 0a 00 00 call ba5 <exit> 15a: 66 90 xchg %ax,%ax 0000015c <runcmd>: { 15c: 55 push %ebp 15d: 89 e5 mov %esp,%ebp 15f: 53 push %ebx 160: 83 ec 14 sub $0x14,%esp 163: 8b 5d 08 mov 0x8(%ebp),%ebx if(cmd == 0) 166: 85 db test %ebx,%ebx 168: 74 76 je 1e0 <runcmd+0x84> switch(cmd->type){ 16a: 83 3b 05 cmpl $0x5,(%ebx) 16d: 0f 87 fc 00 00 00 ja 26f <runcmd+0x113> 173: 8b 03 mov (%ebx),%eax 175: ff 24 85 a4 10 00 00 jmp *0x10a4(,%eax,4) if(pipe(p) < 0) 17c: 83 ec 0c sub $0xc,%esp 17f: 8d 45 f0 lea -0x10(%ebp),%eax 182: 50 push %eax 183: e8 2d 0a 00 00 call bb5 <pipe> 188: 83 c4 10 add $0x10,%esp 18b: 85 c0 test %eax,%eax 18d: 0f 88 fe 00 00 00 js 291 <runcmd+0x135> pid = fork(); 193: e8 05 0a 00 00 call b9d <fork> if(pid == -1) 198: 83 f8 ff cmp $0xffffffff,%eax 19b: 0f 84 59 01 00 00 je 2fa <runcmd+0x19e> if(fork1() == 0){ 1a1: 85 c0 test %eax,%eax 1a3: 0f 84 f5 00 00 00 je 29e <runcmd+0x142> pid = fork(); 1a9: e8 ef 09 00 00 call b9d <fork> if(pid == -1) 1ae: 83 f8 ff cmp $0xffffffff,%eax 1b1: 0f 84 43 01 00 00 je 2fa <runcmd+0x19e> if(fork1() == 0){ 1b7: 85 c0 test %eax,%eax 1b9: 0f 84 0d 01 00 00 je 2cc <runcmd+0x170> close(p[0]); 1bf: 83 ec 0c sub $0xc,%esp 1c2: ff 75 f0 pushl -0x10(%ebp) 1c5: e8 03 0a 00 00 call bcd <close> close(p[1]); 1ca: 58 pop %eax 1cb: ff 75 f4 pushl -0xc(%ebp) 1ce: e8 fa 09 00 00 call bcd <close> wait(); 1d3: e8 d5 09 00 00 call bad <wait> wait(); 1d8: e8 d0 09 00 00 call bad <wait> break; 1dd: 83 c4 10 add $0x10,%esp exit(); 1e0: e8 c0 09 00 00 call ba5 <exit> pid = fork(); 1e5: e8 b3 09 00 00 call b9d <fork> if(pid == -1) 1ea: 83 f8 ff cmp $0xffffffff,%eax 1ed: 0f 84 07 01 00 00 je 2fa <runcmd+0x19e> if(fork1() == 0) 1f3: 85 c0 test %eax,%eax 1f5: 75 e9 jne 1e0 <runcmd+0x84> 1f7: eb 6b jmp 264 <runcmd+0x108> if(ecmd->argv[0] == 0) 1f9: 8b 43 04 mov 0x4(%ebx),%eax 1fc: 85 c0 test %eax,%eax 1fe: 74 e0 je 1e0 <runcmd+0x84> exec(ecmd->argv[0], ecmd->argv); 200: 51 push %ecx 201: 51 push %ecx 202: 8d 53 04 lea 0x4(%ebx),%edx 205: 52 push %edx 206: 50 push %eax 207: e8 d1 09 00 00 call bdd <exec> printf(2, "exec %s failed\n", ecmd->argv[0]); 20c: 83 c4 0c add $0xc,%esp 20f: ff 73 04 pushl 0x4(%ebx) 212: 68 f6 0f 00 00 push $0xff6 217: 6a 02 push $0x2 219: e8 c2 0a 00 00 call ce0 <printf> break; 21e: 83 c4 10 add $0x10,%esp 221: eb bd jmp 1e0 <runcmd+0x84> pid = fork(); 223: e8 75 09 00 00 call b9d <fork> if(pid == -1) 228: 83 f8 ff cmp $0xffffffff,%eax 22b: 0f 84 c9 00 00 00 je 2fa <runcmd+0x19e> if(fork1() == 0) 231: 85 c0 test %eax,%eax 233: 74 2f je 264 <runcmd+0x108> wait(); 235: e8 73 09 00 00 call bad <wait> runcmd(lcmd->right); 23a: 83 ec 0c sub $0xc,%esp 23d: ff 73 08 pushl 0x8(%ebx) 240: e8 17 ff ff ff call 15c <runcmd> close(rcmd->fd); 245: 83 ec 0c sub $0xc,%esp 248: ff 73 14 pushl 0x14(%ebx) 24b: e8 7d 09 00 00 call bcd <close> if(open(rcmd->file, rcmd->mode) < 0){ 250: 58 pop %eax 251: 5a pop %edx 252: ff 73 10 pushl 0x10(%ebx) 255: ff 73 08 pushl 0x8(%ebx) 258: e8 88 09 00 00 call be5 <open> 25d: 83 c4 10 add $0x10,%esp 260: 85 c0 test %eax,%eax 262: 78 18 js 27c <runcmd+0x120> runcmd(bcmd->cmd); 264: 83 ec 0c sub $0xc,%esp 267: ff 73 04 pushl 0x4(%ebx) 26a: e8 ed fe ff ff call 15c <runcmd> panic("runcmd"); 26f: 83 ec 0c sub $0xc,%esp 272: 68 ef 0f 00 00 push $0xfef 277: e8 c4 fe ff ff call 140 <panic> printf(2, "open %s failed\n", rcmd->file); 27c: 51 push %ecx 27d: ff 73 08 pushl 0x8(%ebx) 280: 68 06 10 00 00 push $0x1006 285: 6a 02 push $0x2 287: e8 54 0a 00 00 call ce0 <printf> exit(); 28c: e8 14 09 00 00 call ba5 <exit> panic("pipe"); 291: 83 ec 0c sub $0xc,%esp 294: 68 1b 10 00 00 push $0x101b 299: e8 a2 fe ff ff call 140 <panic> close(1); 29e: 83 ec 0c sub $0xc,%esp 2a1: 6a 01 push $0x1 2a3: e8 25 09 00 00 call bcd <close> dup(p[1]); 2a8: 58 pop %eax 2a9: ff 75 f4 pushl -0xc(%ebp) 2ac: e8 6c 09 00 00 call c1d <dup> close(p[0]); 2b1: 58 pop %eax 2b2: ff 75 f0 pushl -0x10(%ebp) 2b5: e8 13 09 00 00 call bcd <close> close(p[1]); 2ba: 58 pop %eax 2bb: ff 75 f4 pushl -0xc(%ebp) 2be: e8 0a 09 00 00 call bcd <close> runcmd(pcmd->left); 2c3: 5a pop %edx 2c4: ff 73 04 pushl 0x4(%ebx) 2c7: e8 90 fe ff ff call 15c <runcmd> close(0); 2cc: 83 ec 0c sub $0xc,%esp 2cf: 6a 00 push $0x0 2d1: e8 f7 08 00 00 call bcd <close> dup(p[0]); 2d6: 5a pop %edx 2d7: ff 75 f0 pushl -0x10(%ebp) 2da: e8 3e 09 00 00 call c1d <dup> close(p[0]); 2df: 59 pop %ecx 2e0: ff 75 f0 pushl -0x10(%ebp) 2e3: e8 e5 08 00 00 call bcd <close> close(p[1]); 2e8: 58 pop %eax 2e9: ff 75 f4 pushl -0xc(%ebp) 2ec: e8 dc 08 00 00 call bcd <close> runcmd(pcmd->right); 2f1: 58 pop %eax 2f2: ff 73 08 pushl 0x8(%ebx) 2f5: e8 62 fe ff ff call 15c <runcmd> panic("fork"); 2fa: 83 ec 0c sub $0xc,%esp 2fd: 68 16 10 00 00 push $0x1016 302: e8 39 fe ff ff call 140 <panic> 307: 90 nop 00000308 <fork1>: { 308: 55 push %ebp 309: 89 e5 mov %esp,%ebp 30b: 83 ec 08 sub $0x8,%esp pid = fork(); 30e: e8 8a 08 00 00 call b9d <fork> if(pid == -1) 313: 83 f8 ff cmp $0xffffffff,%eax 316: 74 02 je 31a <fork1+0x12> return pid; } 318: c9 leave 319: c3 ret panic("fork"); 31a: 83 ec 0c sub $0xc,%esp 31d: 68 16 10 00 00 push $0x1016 322: e8 19 fe ff ff call 140 <panic> 327: 90 nop 00000328 <execcmd>: //PAGEBREAK! // Constructors struct cmd* execcmd(void) { 328: 55 push %ebp 329: 89 e5 mov %esp,%ebp 32b: 53 push %ebx 32c: 83 ec 10 sub $0x10,%esp struct execcmd *cmd; cmd = malloc(sizeof(*cmd)); 32f: 6a 54 push $0x54 331: e8 be 0b 00 00 call ef4 <malloc> 336: 89 c3 mov %eax,%ebx memset(cmd, 0, sizeof(*cmd)); 338: 83 c4 0c add $0xc,%esp 33b: 6a 54 push $0x54 33d: 6a 00 push $0x0 33f: 50 push %eax 340: e8 2b 07 00 00 call a70 <memset> cmd->type = EXEC; 345: c7 03 01 00 00 00 movl $0x1,(%ebx) return (struct cmd*)cmd; } 34b: 89 d8 mov %ebx,%eax 34d: 8b 5d fc mov -0x4(%ebp),%ebx 350: c9 leave 351: c3 ret 352: 66 90 xchg %ax,%ax 00000354 <redircmd>: struct cmd* redircmd(struct cmd *subcmd, char *file, char *efile, int mode, int fd) { 354: 55 push %ebp 355: 89 e5 mov %esp,%ebp 357: 53 push %ebx 358: 83 ec 10 sub $0x10,%esp struct redircmd *cmd; cmd = malloc(sizeof(*cmd)); 35b: 6a 18 push $0x18 35d: e8 92 0b 00 00 call ef4 <malloc> 362: 89 c3 mov %eax,%ebx memset(cmd, 0, sizeof(*cmd)); 364: 83 c4 0c add $0xc,%esp 367: 6a 18 push $0x18 369: 6a 00 push $0x0 36b: 50 push %eax 36c: e8 ff 06 00 00 call a70 <memset> cmd->type = REDIR; 371: c7 03 02 00 00 00 movl $0x2,(%ebx) cmd->cmd = subcmd; 377: 8b 45 08 mov 0x8(%ebp),%eax 37a: 89 43 04 mov %eax,0x4(%ebx) cmd->file = file; 37d: 8b 45 0c mov 0xc(%ebp),%eax 380: 89 43 08 mov %eax,0x8(%ebx) cmd->efile = efile; 383: 8b 45 10 mov 0x10(%ebp),%eax 386: 89 43 0c mov %eax,0xc(%ebx) cmd->mode = mode; 389: 8b 45 14 mov 0x14(%ebp),%eax 38c: 89 43 10 mov %eax,0x10(%ebx) cmd->fd = fd; 38f: 8b 45 18 mov 0x18(%ebp),%eax 392: 89 43 14 mov %eax,0x14(%ebx) return (struct cmd*)cmd; } 395: 89 d8 mov %ebx,%eax 397: 8b 5d fc mov -0x4(%ebp),%ebx 39a: c9 leave 39b: c3 ret 0000039c <pipecmd>: struct cmd* pipecmd(struct cmd *left, struct cmd *right) { 39c: 55 push %ebp 39d: 89 e5 mov %esp,%ebp 39f: 53 push %ebx 3a0: 83 ec 10 sub $0x10,%esp struct pipecmd *cmd; cmd = malloc(sizeof(*cmd)); 3a3: 6a 0c push $0xc 3a5: e8 4a 0b 00 00 call ef4 <malloc> 3aa: 89 c3 mov %eax,%ebx memset(cmd, 0, sizeof(*cmd)); 3ac: 83 c4 0c add $0xc,%esp 3af: 6a 0c push $0xc 3b1: 6a 00 push $0x0 3b3: 50 push %eax 3b4: e8 b7 06 00 00 call a70 <memset> cmd->type = PIPE; 3b9: c7 03 03 00 00 00 movl $0x3,(%ebx) cmd->left = left; 3bf: 8b 45 08 mov 0x8(%ebp),%eax 3c2: 89 43 04 mov %eax,0x4(%ebx) cmd->right = right; 3c5: 8b 45 0c mov 0xc(%ebp),%eax 3c8: 89 43 08 mov %eax,0x8(%ebx) return (struct cmd*)cmd; } 3cb: 89 d8 mov %ebx,%eax 3cd: 8b 5d fc mov -0x4(%ebp),%ebx 3d0: c9 leave 3d1: c3 ret 3d2: 66 90 xchg %ax,%ax 000003d4 <listcmd>: struct cmd* listcmd(struct cmd *left, struct cmd *right) { 3d4: 55 push %ebp 3d5: 89 e5 mov %esp,%ebp 3d7: 53 push %ebx 3d8: 83 ec 10 sub $0x10,%esp struct listcmd *cmd; cmd = malloc(sizeof(*cmd)); 3db: 6a 0c push $0xc 3dd: e8 12 0b 00 00 call ef4 <malloc> 3e2: 89 c3 mov %eax,%ebx memset(cmd, 0, sizeof(*cmd)); 3e4: 83 c4 0c add $0xc,%esp 3e7: 6a 0c push $0xc 3e9: 6a 00 push $0x0 3eb: 50 push %eax 3ec: e8 7f 06 00 00 call a70 <memset> cmd->type = LIST; 3f1: c7 03 04 00 00 00 movl $0x4,(%ebx) cmd->left = left; 3f7: 8b 45 08 mov 0x8(%ebp),%eax 3fa: 89 43 04 mov %eax,0x4(%ebx) cmd->right = right; 3fd: 8b 45 0c mov 0xc(%ebp),%eax 400: 89 43 08 mov %eax,0x8(%ebx) return (struct cmd*)cmd; } 403: 89 d8 mov %ebx,%eax 405: 8b 5d fc mov -0x4(%ebp),%ebx 408: c9 leave 409: c3 ret 40a: 66 90 xchg %ax,%ax 0000040c <backcmd>: struct cmd* backcmd(struct cmd *subcmd) { 40c: 55 push %ebp 40d: 89 e5 mov %esp,%ebp 40f: 53 push %ebx 410: 83 ec 10 sub $0x10,%esp struct backcmd *cmd; cmd = malloc(sizeof(*cmd)); 413: 6a 08 push $0x8 415: e8 da 0a 00 00 call ef4 <malloc> 41a: 89 c3 mov %eax,%ebx memset(cmd, 0, sizeof(*cmd)); 41c: 83 c4 0c add $0xc,%esp 41f: 6a 08 push $0x8 421: 6a 00 push $0x0 423: 50 push %eax 424: e8 47 06 00 00 call a70 <memset> cmd->type = BACK; 429: c7 03 05 00 00 00 movl $0x5,(%ebx) cmd->cmd = subcmd; 42f: 8b 45 08 mov 0x8(%ebp),%eax 432: 89 43 04 mov %eax,0x4(%ebx) return (struct cmd*)cmd; } 435: 89 d8 mov %ebx,%eax 437: 8b 5d fc mov -0x4(%ebp),%ebx 43a: c9 leave 43b: c3 ret 0000043c <gettoken>: char whitespace[] = " \t\r\n\v"; char symbols[] = "<|>&;()"; int gettoken(char **ps, char *es, char **q, char **eq) { 43c: 55 push %ebp 43d: 89 e5 mov %esp,%ebp 43f: 57 push %edi 440: 56 push %esi 441: 53 push %ebx 442: 83 ec 0c sub $0xc,%esp 445: 8b 5d 0c mov 0xc(%ebp),%ebx 448: 8b 75 10 mov 0x10(%ebp),%esi char *s; int ret; s = *ps; 44b: 8b 45 08 mov 0x8(%ebp),%eax 44e: 8b 38 mov (%eax),%edi while(s < es && strchr(whitespace, *s)) 450: 39 df cmp %ebx,%edi 452: 72 09 jb 45d <gettoken+0x21> 454: eb 1f jmp 475 <gettoken+0x39> 456: 66 90 xchg %ax,%ax s++; 458: 47 inc %edi while(s < es && strchr(whitespace, *s)) 459: 39 fb cmp %edi,%ebx 45b: 74 18 je 475 <gettoken+0x39> 45d: 83 ec 08 sub $0x8,%esp 460: 0f be 07 movsbl (%edi),%eax 463: 50 push %eax 464: 68 a4 16 00 00 push $0x16a4 469: e8 1a 06 00 00 call a88 <strchr> 46e: 83 c4 10 add $0x10,%esp 471: 85 c0 test %eax,%eax 473: 75 e3 jne 458 <gettoken+0x1c> if(q) 475: 85 f6 test %esi,%esi 477: 74 02 je 47b <gettoken+0x3f> *q = s; 479: 89 3e mov %edi,(%esi) ret = *s; 47b: 0f be 07 movsbl (%edi),%eax switch(*s){ 47e: 3c 3c cmp $0x3c,%al 480: 0f 8f ba 00 00 00 jg 540 <gettoken+0x104> 486: 3c 3a cmp $0x3a,%al 488: 0f 8f a6 00 00 00 jg 534 <gettoken+0xf8> 48e: 84 c0 test %al,%al 490: 75 42 jne 4d4 <gettoken+0x98> 492: 31 f6 xor %esi,%esi ret = 'a'; while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) s++; break; } if(eq) 494: 8b 55 14 mov 0x14(%ebp),%edx 497: 85 d2 test %edx,%edx 499: 74 05 je 4a0 <gettoken+0x64> *eq = s; 49b: 8b 45 14 mov 0x14(%ebp),%eax 49e: 89 38 mov %edi,(%eax) while(s < es && strchr(whitespace, *s)) 4a0: 39 df cmp %ebx,%edi 4a2: 72 09 jb 4ad <gettoken+0x71> 4a4: eb 1f jmp 4c5 <gettoken+0x89> 4a6: 66 90 xchg %ax,%ax s++; 4a8: 47 inc %edi while(s < es && strchr(whitespace, *s)) 4a9: 39 fb cmp %edi,%ebx 4ab: 74 18 je 4c5 <gettoken+0x89> 4ad: 83 ec 08 sub $0x8,%esp 4b0: 0f be 07 movsbl (%edi),%eax 4b3: 50 push %eax 4b4: 68 a4 16 00 00 push $0x16a4 4b9: e8 ca 05 00 00 call a88 <strchr> 4be: 83 c4 10 add $0x10,%esp 4c1: 85 c0 test %eax,%eax 4c3: 75 e3 jne 4a8 <gettoken+0x6c> *ps = s; 4c5: 8b 45 08 mov 0x8(%ebp),%eax 4c8: 89 38 mov %edi,(%eax) return ret; } 4ca: 89 f0 mov %esi,%eax 4cc: 8d 65 f4 lea -0xc(%ebp),%esp 4cf: 5b pop %ebx 4d0: 5e pop %esi 4d1: 5f pop %edi 4d2: 5d pop %ebp 4d3: c3 ret switch(*s){ 4d4: 79 52 jns 528 <gettoken+0xec> while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) 4d6: 39 fb cmp %edi,%ebx 4d8: 77 2e ja 508 <gettoken+0xcc> if(eq) 4da: be 61 00 00 00 mov $0x61,%esi 4df: 8b 45 14 mov 0x14(%ebp),%eax 4e2: 85 c0 test %eax,%eax 4e4: 75 b5 jne 49b <gettoken+0x5f> 4e6: eb dd jmp 4c5 <gettoken+0x89> while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) 4e8: 83 ec 08 sub $0x8,%esp 4eb: 0f be 07 movsbl (%edi),%eax 4ee: 50 push %eax 4ef: 68 9c 16 00 00 push $0x169c 4f4: e8 8f 05 00 00 call a88 <strchr> 4f9: 83 c4 10 add $0x10,%esp 4fc: 85 c0 test %eax,%eax 4fe: 75 1d jne 51d <gettoken+0xe1> s++; 500: 47 inc %edi while(s < es && !strchr(whitespace, *s) && !strchr(symbols, *s)) 501: 39 fb cmp %edi,%ebx 503: 74 d5 je 4da <gettoken+0x9e> 505: 0f be 07 movsbl (%edi),%eax 508: 83 ec 08 sub $0x8,%esp 50b: 50 push %eax 50c: 68 a4 16 00 00 push $0x16a4 511: e8 72 05 00 00 call a88 <strchr> 516: 83 c4 10 add $0x10,%esp 519: 85 c0 test %eax,%eax 51b: 74 cb je 4e8 <gettoken+0xac> ret = 'a'; 51d: be 61 00 00 00 mov $0x61,%esi 522: e9 6d ff ff ff jmp 494 <gettoken+0x58> 527: 90 nop switch(*s){ 528: 3c 26 cmp $0x26,%al 52a: 74 08 je 534 <gettoken+0xf8> 52c: 8d 48 d8 lea -0x28(%eax),%ecx 52f: 80 f9 01 cmp $0x1,%cl 532: 77 a2 ja 4d6 <gettoken+0x9a> ret = *s; 534: 0f be f0 movsbl %al,%esi s++; 537: 47 inc %edi break; 538: e9 57 ff ff ff jmp 494 <gettoken+0x58> 53d: 8d 76 00 lea 0x0(%esi),%esi switch(*s){ 540: 3c 3e cmp $0x3e,%al 542: 75 18 jne 55c <gettoken+0x120> s++; 544: 8d 47 01 lea 0x1(%edi),%eax if(*s == '>'){ 547: 80 7f 01 3e cmpb $0x3e,0x1(%edi) 54b: 74 18 je 565 <gettoken+0x129> s++; 54d: 89 c7 mov %eax,%edi 54f: be 3e 00 00 00 mov $0x3e,%esi 554: e9 3b ff ff ff jmp 494 <gettoken+0x58> 559: 8d 76 00 lea 0x0(%esi),%esi switch(*s){ 55c: 3c 7c cmp $0x7c,%al 55e: 74 d4 je 534 <gettoken+0xf8> 560: e9 71 ff ff ff jmp 4d6 <gettoken+0x9a> s++; 565: 83 c7 02 add $0x2,%edi ret = '+'; 568: be 2b 00 00 00 mov $0x2b,%esi 56d: e9 22 ff ff ff jmp 494 <gettoken+0x58> 572: 66 90 xchg %ax,%ax 00000574 <peek>: int peek(char **ps, char *es, char *toks) { 574: 55 push %ebp 575: 89 e5 mov %esp,%ebp 577: 57 push %edi 578: 56 push %esi 579: 53 push %ebx 57a: 83 ec 0c sub $0xc,%esp 57d: 8b 7d 08 mov 0x8(%ebp),%edi 580: 8b 75 0c mov 0xc(%ebp),%esi char *s; s = *ps; 583: 8b 1f mov (%edi),%ebx while(s < es && strchr(whitespace, *s)) 585: 39 f3 cmp %esi,%ebx 587: 72 08 jb 591 <peek+0x1d> 589: eb 1e jmp 5a9 <peek+0x35> 58b: 90 nop s++; 58c: 43 inc %ebx while(s < es && strchr(whitespace, *s)) 58d: 39 de cmp %ebx,%esi 58f: 74 18 je 5a9 <peek+0x35> 591: 83 ec 08 sub $0x8,%esp 594: 0f be 03 movsbl (%ebx),%eax 597: 50 push %eax 598: 68 a4 16 00 00 push $0x16a4 59d: e8 e6 04 00 00 call a88 <strchr> 5a2: 83 c4 10 add $0x10,%esp 5a5: 85 c0 test %eax,%eax 5a7: 75 e3 jne 58c <peek+0x18> *ps = s; 5a9: 89 1f mov %ebx,(%edi) return *s && strchr(toks, *s); 5ab: 0f be 03 movsbl (%ebx),%eax 5ae: 84 c0 test %al,%al 5b0: 75 0a jne 5bc <peek+0x48> 5b2: 31 c0 xor %eax,%eax } 5b4: 8d 65 f4 lea -0xc(%ebp),%esp 5b7: 5b pop %ebx 5b8: 5e pop %esi 5b9: 5f pop %edi 5ba: 5d pop %ebp 5bb: c3 ret return *s && strchr(toks, *s); 5bc: 83 ec 08 sub $0x8,%esp 5bf: 50 push %eax 5c0: ff 75 10 pushl 0x10(%ebp) 5c3: e8 c0 04 00 00 call a88 <strchr> 5c8: 83 c4 10 add $0x10,%esp 5cb: 85 c0 test %eax,%eax 5cd: 0f 95 c0 setne %al 5d0: 0f b6 c0 movzbl %al,%eax } 5d3: 8d 65 f4 lea -0xc(%ebp),%esp 5d6: 5b pop %ebx 5d7: 5e pop %esi 5d8: 5f pop %edi 5d9: 5d pop %ebp 5da: c3 ret 5db: 90 nop 000005dc <parseredirs>: return cmd; } struct cmd* parseredirs(struct cmd *cmd, char **ps, char *es) { 5dc: 55 push %ebp 5dd: 89 e5 mov %esp,%ebp 5df: 57 push %edi 5e0: 56 push %esi 5e1: 53 push %ebx 5e2: 83 ec 1c sub $0x1c,%esp 5e5: 8b 75 0c mov 0xc(%ebp),%esi 5e8: 8b 5d 10 mov 0x10(%ebp),%ebx int tok; char *q, *eq; while(peek(ps, es, "<>")){ 5eb: 90 nop 5ec: 50 push %eax 5ed: 68 3d 10 00 00 push $0x103d 5f2: 53 push %ebx 5f3: 56 push %esi 5f4: e8 7b ff ff ff call 574 <peek> 5f9: 83 c4 10 add $0x10,%esp 5fc: 85 c0 test %eax,%eax 5fe: 74 60 je 660 <parseredirs+0x84> tok = gettoken(ps, es, 0, 0); 600: 6a 00 push $0x0 602: 6a 00 push $0x0 604: 53 push %ebx 605: 56 push %esi 606: e8 31 fe ff ff call 43c <gettoken> 60b: 89 c7 mov %eax,%edi if(gettoken(ps, es, &q, &eq) != 'a') 60d: 8d 45 e4 lea -0x1c(%ebp),%eax 610: 50 push %eax 611: 8d 45 e0 lea -0x20(%ebp),%eax 614: 50 push %eax 615: 53 push %ebx 616: 56 push %esi 617: e8 20 fe ff ff call 43c <gettoken> 61c: 83 c4 20 add $0x20,%esp 61f: 83 f8 61 cmp $0x61,%eax 622: 75 47 jne 66b <parseredirs+0x8f> panic("missing file for redirection"); switch(tok){ 624: 83 ff 3c cmp $0x3c,%edi 627: 74 2b je 654 <parseredirs+0x78> 629: 83 ff 3e cmp $0x3e,%edi 62c: 74 05 je 633 <parseredirs+0x57> 62e: 83 ff 2b cmp $0x2b,%edi 631: 75 b9 jne 5ec <parseredirs+0x10> break; case '>': cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1); break; case '+': // >> cmd = redircmd(cmd, q, eq, O_WRONLY|O_CREATE, 1); 633: 83 ec 0c sub $0xc,%esp 636: 6a 01 push $0x1 638: 68 01 02 00 00 push $0x201 63d: ff 75 e4 pushl -0x1c(%ebp) 640: ff 75 e0 pushl -0x20(%ebp) 643: ff 75 08 pushl 0x8(%ebp) 646: e8 09 fd ff ff call 354 <redircmd> 64b: 89 45 08 mov %eax,0x8(%ebp) break; 64e: 83 c4 20 add $0x20,%esp 651: eb 99 jmp 5ec <parseredirs+0x10> 653: 90 nop cmd = redircmd(cmd, q, eq, O_RDONLY, 0); 654: 83 ec 0c sub $0xc,%esp 657: 6a 00 push $0x0 659: 6a 00 push $0x0 65b: eb e0 jmp 63d <parseredirs+0x61> 65d: 8d 76 00 lea 0x0(%esi),%esi } } return cmd; } 660: 8b 45 08 mov 0x8(%ebp),%eax 663: 8d 65 f4 lea -0xc(%ebp),%esp 666: 5b pop %ebx 667: 5e pop %esi 668: 5f pop %edi 669: 5d pop %ebp 66a: c3 ret panic("missing file for redirection"); 66b: 83 ec 0c sub $0xc,%esp 66e: 68 20 10 00 00 push $0x1020 673: e8 c8 fa ff ff call 140 <panic> 00000678 <parseexec>: return cmd; } struct cmd* parseexec(char **ps, char *es) { 678: 55 push %ebp 679: 89 e5 mov %esp,%ebp 67b: 57 push %edi 67c: 56 push %esi 67d: 53 push %ebx 67e: 83 ec 30 sub $0x30,%esp 681: 8b 75 08 mov 0x8(%ebp),%esi 684: 8b 7d 0c mov 0xc(%ebp),%edi char *q, *eq; int tok, argc; struct execcmd *cmd; struct cmd *ret; if(peek(ps, es, "(")) 687: 68 40 10 00 00 push $0x1040 68c: 57 push %edi 68d: 56 push %esi 68e: e8 e1 fe ff ff call 574 <peek> 693: 83 c4 10 add $0x10,%esp 696: 85 c0 test %eax,%eax 698: 0f 85 82 00 00 00 jne 720 <parseexec+0xa8> 69e: 89 c3 mov %eax,%ebx return parseblock(ps, es); ret = execcmd(); 6a0: e8 83 fc ff ff call 328 <execcmd> 6a5: 89 45 d0 mov %eax,-0x30(%ebp) cmd = (struct execcmd*)ret; argc = 0; ret = parseredirs(ret, ps, es); 6a8: 51 push %ecx 6a9: 57 push %edi 6aa: 56 push %esi 6ab: 50 push %eax 6ac: e8 2b ff ff ff call 5dc <parseredirs> 6b1: 89 45 d4 mov %eax,-0x2c(%ebp) while(!peek(ps, es, "|)&;")){ 6b4: 83 c4 10 add $0x10,%esp 6b7: eb 14 jmp 6cd <parseexec+0x55> 6b9: 8d 76 00 lea 0x0(%esi),%esi cmd->argv[argc] = q; cmd->eargv[argc] = eq; argc++; if(argc >= MAXARGS) panic("too many args"); ret = parseredirs(ret, ps, es); 6bc: 52 push %edx 6bd: 57 push %edi 6be: 56 push %esi 6bf: ff 75 d4 pushl -0x2c(%ebp) 6c2: e8 15 ff ff ff call 5dc <parseredirs> 6c7: 89 45 d4 mov %eax,-0x2c(%ebp) 6ca: 83 c4 10 add $0x10,%esp while(!peek(ps, es, "|)&;")){ 6cd: 50 push %eax 6ce: 68 57 10 00 00 push $0x1057 6d3: 57 push %edi 6d4: 56 push %esi 6d5: e8 9a fe ff ff call 574 <peek> 6da: 83 c4 10 add $0x10,%esp 6dd: 85 c0 test %eax,%eax 6df: 75 5b jne 73c <parseexec+0xc4> if((tok=gettoken(ps, es, &q, &eq)) == 0) 6e1: 8d 45 e4 lea -0x1c(%ebp),%eax 6e4: 50 push %eax 6e5: 8d 45 e0 lea -0x20(%ebp),%eax 6e8: 50 push %eax 6e9: 57 push %edi 6ea: 56 push %esi 6eb: e8 4c fd ff ff call 43c <gettoken> 6f0: 83 c4 10 add $0x10,%esp 6f3: 85 c0 test %eax,%eax 6f5: 74 45 je 73c <parseexec+0xc4> if(tok != 'a') 6f7: 83 f8 61 cmp $0x61,%eax 6fa: 75 5f jne 75b <parseexec+0xe3> cmd->argv[argc] = q; 6fc: 8b 45 e0 mov -0x20(%ebp),%eax 6ff: 8b 55 d0 mov -0x30(%ebp),%edx 702: 89 44 9a 04 mov %eax,0x4(%edx,%ebx,4) cmd->eargv[argc] = eq; 706: 8b 45 e4 mov -0x1c(%ebp),%eax 709: 89 44 9a 2c mov %eax,0x2c(%edx,%ebx,4) argc++; 70d: 43 inc %ebx if(argc >= MAXARGS) 70e: 83 fb 0a cmp $0xa,%ebx 711: 75 a9 jne 6bc <parseexec+0x44> panic("too many args"); 713: 83 ec 0c sub $0xc,%esp 716: 68 49 10 00 00 push $0x1049 71b: e8 20 fa ff ff call 140 <panic> return parseblock(ps, es); 720: 83 ec 08 sub $0x8,%esp 723: 57 push %edi 724: 56 push %esi 725: e8 3a 01 00 00 call 864 <parseblock> 72a: 89 45 d4 mov %eax,-0x2c(%ebp) 72d: 83 c4 10 add $0x10,%esp } cmd->argv[argc] = 0; cmd->eargv[argc] = 0; return ret; } 730: 8b 45 d4 mov -0x2c(%ebp),%eax 733: 8d 65 f4 lea -0xc(%ebp),%esp 736: 5b pop %ebx 737: 5e pop %esi 738: 5f pop %edi 739: 5d pop %ebp 73a: c3 ret 73b: 90 nop cmd->argv[argc] = 0; 73c: 8b 45 d0 mov -0x30(%ebp),%eax 73f: 8d 04 98 lea (%eax,%ebx,4),%eax 742: c7 40 04 00 00 00 00 movl $0x0,0x4(%eax) cmd->eargv[argc] = 0; 749: c7 40 2c 00 00 00 00 movl $0x0,0x2c(%eax) } 750: 8b 45 d4 mov -0x2c(%ebp),%eax 753: 8d 65 f4 lea -0xc(%ebp),%esp 756: 5b pop %ebx 757: 5e pop %esi 758: 5f pop %edi 759: 5d pop %ebp 75a: c3 ret panic("syntax"); 75b: 83 ec 0c sub $0xc,%esp 75e: 68 42 10 00 00 push $0x1042 763: e8 d8 f9 ff ff call 140 <panic> 00000768 <parsepipe>: { 768: 55 push %ebp 769: 89 e5 mov %esp,%ebp 76b: 57 push %edi 76c: 56 push %esi 76d: 53 push %ebx 76e: 83 ec 14 sub $0x14,%esp 771: 8b 75 08 mov 0x8(%ebp),%esi 774: 8b 7d 0c mov 0xc(%ebp),%edi cmd = parseexec(ps, es); 777: 57 push %edi 778: 56 push %esi 779: e8 fa fe ff ff call 678 <parseexec> 77e: 89 c3 mov %eax,%ebx if(peek(ps, es, "|")){ 780: 83 c4 0c add $0xc,%esp 783: 68 5c 10 00 00 push $0x105c 788: 57 push %edi 789: 56 push %esi 78a: e8 e5 fd ff ff call 574 <peek> 78f: 83 c4 10 add $0x10,%esp 792: 85 c0 test %eax,%eax 794: 75 0a jne 7a0 <parsepipe+0x38> } 796: 89 d8 mov %ebx,%eax 798: 8d 65 f4 lea -0xc(%ebp),%esp 79b: 5b pop %ebx 79c: 5e pop %esi 79d: 5f pop %edi 79e: 5d pop %ebp 79f: c3 ret gettoken(ps, es, 0, 0); 7a0: 6a 00 push $0x0 7a2: 6a 00 push $0x0 7a4: 57 push %edi 7a5: 56 push %esi 7a6: e8 91 fc ff ff call 43c <gettoken> cmd = pipecmd(cmd, parsepipe(ps, es)); 7ab: 58 pop %eax 7ac: 5a pop %edx 7ad: 57 push %edi 7ae: 56 push %esi 7af: e8 b4 ff ff ff call 768 <parsepipe> 7b4: 83 c4 10 add $0x10,%esp 7b7: 89 45 0c mov %eax,0xc(%ebp) 7ba: 89 5d 08 mov %ebx,0x8(%ebp) } 7bd: 8d 65 f4 lea -0xc(%ebp),%esp 7c0: 5b pop %ebx 7c1: 5e pop %esi 7c2: 5f pop %edi 7c3: 5d pop %ebp cmd = pipecmd(cmd, parsepipe(ps, es)); 7c4: e9 d3 fb ff ff jmp 39c <pipecmd> 7c9: 8d 76 00 lea 0x0(%esi),%esi 000007cc <parseline>: { 7cc: 55 push %ebp 7cd: 89 e5 mov %esp,%ebp 7cf: 57 push %edi 7d0: 56 push %esi 7d1: 53 push %ebx 7d2: 83 ec 14 sub $0x14,%esp 7d5: 8b 75 08 mov 0x8(%ebp),%esi 7d8: 8b 7d 0c mov 0xc(%ebp),%edi cmd = parsepipe(ps, es); 7db: 57 push %edi 7dc: 56 push %esi 7dd: e8 86 ff ff ff call 768 <parsepipe> 7e2: 89 c3 mov %eax,%ebx while(peek(ps, es, "&")){ 7e4: 83 c4 10 add $0x10,%esp 7e7: eb 1b jmp 804 <parseline+0x38> 7e9: 8d 76 00 lea 0x0(%esi),%esi gettoken(ps, es, 0, 0); 7ec: 6a 00 push $0x0 7ee: 6a 00 push $0x0 7f0: 57 push %edi 7f1: 56 push %esi 7f2: e8 45 fc ff ff call 43c <gettoken> cmd = backcmd(cmd); 7f7: 89 1c 24 mov %ebx,(%esp) 7fa: e8 0d fc ff ff call 40c <backcmd> 7ff: 89 c3 mov %eax,%ebx 801: 83 c4 10 add $0x10,%esp while(peek(ps, es, "&")){ 804: 50 push %eax 805: 68 5e 10 00 00 push $0x105e 80a: 57 push %edi 80b: 56 push %esi 80c: e8 63 fd ff ff call 574 <peek> 811: 83 c4 10 add $0x10,%esp 814: 85 c0 test %eax,%eax 816: 75 d4 jne 7ec <parseline+0x20> if(peek(ps, es, ";")){ 818: 51 push %ecx 819: 68 5a 10 00 00 push $0x105a 81e: 57 push %edi 81f: 56 push %esi 820: e8 4f fd ff ff call 574 <peek> 825: 83 c4 10 add $0x10,%esp 828: 85 c0 test %eax,%eax 82a: 75 0c jne 838 <parseline+0x6c> } 82c: 89 d8 mov %ebx,%eax 82e: 8d 65 f4 lea -0xc(%ebp),%esp 831: 5b pop %ebx 832: 5e pop %esi 833: 5f pop %edi 834: 5d pop %ebp 835: c3 ret 836: 66 90 xchg %ax,%ax gettoken(ps, es, 0, 0); 838: 6a 00 push $0x0 83a: 6a 00 push $0x0 83c: 57 push %edi 83d: 56 push %esi 83e: e8 f9 fb ff ff call 43c <gettoken> cmd = listcmd(cmd, parseline(ps, es)); 843: 58 pop %eax 844: 5a pop %edx 845: 57 push %edi 846: 56 push %esi 847: e8 80 ff ff ff call 7cc <parseline> 84c: 83 c4 10 add $0x10,%esp 84f: 89 45 0c mov %eax,0xc(%ebp) 852: 89 5d 08 mov %ebx,0x8(%ebp) } 855: 8d 65 f4 lea -0xc(%ebp),%esp 858: 5b pop %ebx 859: 5e pop %esi 85a: 5f pop %edi 85b: 5d pop %ebp cmd = listcmd(cmd, parseline(ps, es)); 85c: e9 73 fb ff ff jmp 3d4 <listcmd> 861: 8d 76 00 lea 0x0(%esi),%esi 00000864 <parseblock>: { 864: 55 push %ebp 865: 89 e5 mov %esp,%ebp 867: 57 push %edi 868: 56 push %esi 869: 53 push %ebx 86a: 83 ec 10 sub $0x10,%esp 86d: 8b 5d 08 mov 0x8(%ebp),%ebx 870: 8b 75 0c mov 0xc(%ebp),%esi if(!peek(ps, es, "(")) 873: 68 40 10 00 00 push $0x1040 878: 56 push %esi 879: 53 push %ebx 87a: e8 f5 fc ff ff call 574 <peek> 87f: 83 c4 10 add $0x10,%esp 882: 85 c0 test %eax,%eax 884: 74 4a je 8d0 <parseblock+0x6c> gettoken(ps, es, 0, 0); 886: 6a 00 push $0x0 888: 6a 00 push $0x0 88a: 56 push %esi 88b: 53 push %ebx 88c: e8 ab fb ff ff call 43c <gettoken> cmd = parseline(ps, es); 891: 58 pop %eax 892: 5a pop %edx 893: 56 push %esi 894: 53 push %ebx 895: e8 32 ff ff ff call 7cc <parseline> 89a: 89 c7 mov %eax,%edi if(!peek(ps, es, ")")) 89c: 83 c4 0c add $0xc,%esp 89f: 68 7c 10 00 00 push $0x107c 8a4: 56 push %esi 8a5: 53 push %ebx 8a6: e8 c9 fc ff ff call 574 <peek> 8ab: 83 c4 10 add $0x10,%esp 8ae: 85 c0 test %eax,%eax 8b0: 74 2b je 8dd <parseblock+0x79> gettoken(ps, es, 0, 0); 8b2: 6a 00 push $0x0 8b4: 6a 00 push $0x0 8b6: 56 push %esi 8b7: 53 push %ebx 8b8: e8 7f fb ff ff call 43c <gettoken> cmd = parseredirs(cmd, ps, es); 8bd: 83 c4 0c add $0xc,%esp 8c0: 56 push %esi 8c1: 53 push %ebx 8c2: 57 push %edi 8c3: e8 14 fd ff ff call 5dc <parseredirs> } 8c8: 8d 65 f4 lea -0xc(%ebp),%esp 8cb: 5b pop %ebx 8cc: 5e pop %esi 8cd: 5f pop %edi 8ce: 5d pop %ebp 8cf: c3 ret panic("parseblock"); 8d0: 83 ec 0c sub $0xc,%esp 8d3: 68 60 10 00 00 push $0x1060 8d8: e8 63 f8 ff ff call 140 <panic> panic("syntax - missing )"); 8dd: 83 ec 0c sub $0xc,%esp 8e0: 68 6b 10 00 00 push $0x106b 8e5: e8 56 f8 ff ff call 140 <panic> 8ea: 66 90 xchg %ax,%ax 000008ec <nulterminate>: // NUL-terminate all the counted strings. struct cmd* nulterminate(struct cmd *cmd) { 8ec: 55 push %ebp 8ed: 89 e5 mov %esp,%ebp 8ef: 53 push %ebx 8f0: 53 push %ebx 8f1: 8b 5d 08 mov 0x8(%ebp),%ebx struct execcmd *ecmd; struct listcmd *lcmd; struct pipecmd *pcmd; struct redircmd *rcmd; if(cmd == 0) 8f4: 85 db test %ebx,%ebx 8f6: 0f 84 88 00 00 00 je 984 <nulterminate+0x98> return 0; switch(cmd->type){ 8fc: 83 3b 05 cmpl $0x5,(%ebx) 8ff: 77 5f ja 960 <nulterminate+0x74> 901: 8b 03 mov (%ebx),%eax 903: ff 24 85 bc 10 00 00 jmp *0x10bc(,%eax,4) 90a: 66 90 xchg %ax,%ax nulterminate(pcmd->right); break; case LIST: lcmd = (struct listcmd*)cmd; nulterminate(lcmd->left); 90c: 83 ec 0c sub $0xc,%esp 90f: ff 73 04 pushl 0x4(%ebx) 912: e8 d5 ff ff ff call 8ec <nulterminate> nulterminate(lcmd->right); 917: 58 pop %eax 918: ff 73 08 pushl 0x8(%ebx) 91b: e8 cc ff ff ff call 8ec <nulterminate> break; 920: 83 c4 10 add $0x10,%esp 923: 89 d8 mov %ebx,%eax bcmd = (struct backcmd*)cmd; nulterminate(bcmd->cmd); break; } return cmd; } 925: 8b 5d fc mov -0x4(%ebp),%ebx 928: c9 leave 929: c3 ret 92a: 66 90 xchg %ax,%ax nulterminate(bcmd->cmd); 92c: 83 ec 0c sub $0xc,%esp 92f: ff 73 04 pushl 0x4(%ebx) 932: e8 b5 ff ff ff call 8ec <nulterminate> break; 937: 83 c4 10 add $0x10,%esp 93a: 89 d8 mov %ebx,%eax } 93c: 8b 5d fc mov -0x4(%ebp),%ebx 93f: c9 leave 940: c3 ret 941: 8d 76 00 lea 0x0(%esi),%esi for(i=0; ecmd->argv[i]; i++) 944: 8d 43 08 lea 0x8(%ebx),%eax 947: 8b 4b 04 mov 0x4(%ebx),%ecx 94a: 85 c9 test %ecx,%ecx 94c: 74 12 je 960 <nulterminate+0x74> 94e: 66 90 xchg %ax,%ax *ecmd->eargv[i] = 0; 950: 8b 50 24 mov 0x24(%eax),%edx 953: c6 02 00 movb $0x0,(%edx) for(i=0; ecmd->argv[i]; i++) 956: 83 c0 04 add $0x4,%eax 959: 8b 50 fc mov -0x4(%eax),%edx 95c: 85 d2 test %edx,%edx 95e: 75 f0 jne 950 <nulterminate+0x64> switch(cmd->type){ 960: 89 d8 mov %ebx,%eax } 962: 8b 5d fc mov -0x4(%ebp),%ebx 965: c9 leave 966: c3 ret 967: 90 nop nulterminate(rcmd->cmd); 968: 83 ec 0c sub $0xc,%esp 96b: ff 73 04 pushl 0x4(%ebx) 96e: e8 79 ff ff ff call 8ec <nulterminate> *rcmd->efile = 0; 973: 8b 43 0c mov 0xc(%ebx),%eax 976: c6 00 00 movb $0x0,(%eax) break; 979: 83 c4 10 add $0x10,%esp 97c: 89 d8 mov %ebx,%eax } 97e: 8b 5d fc mov -0x4(%ebp),%ebx 981: c9 leave 982: c3 ret 983: 90 nop return 0; 984: 31 c0 xor %eax,%eax 986: eb 9d jmp 925 <nulterminate+0x39> 00000988 <parsecmd>: { 988: 55 push %ebp 989: 89 e5 mov %esp,%ebp 98b: 56 push %esi 98c: 53 push %ebx es = s + strlen(s); 98d: 8b 5d 08 mov 0x8(%ebp),%ebx 990: 83 ec 0c sub $0xc,%esp 993: 53 push %ebx 994: e8 af 00 00 00 call a48 <strlen> 999: 01 c3 add %eax,%ebx cmd = parseline(&s, es); 99b: 59 pop %ecx 99c: 5e pop %esi 99d: 53 push %ebx 99e: 8d 45 08 lea 0x8(%ebp),%eax 9a1: 50 push %eax 9a2: e8 25 fe ff ff call 7cc <parseline> 9a7: 89 c6 mov %eax,%esi peek(&s, es, ""); 9a9: 83 c4 0c add $0xc,%esp 9ac: 68 05 10 00 00 push $0x1005 9b1: 53 push %ebx 9b2: 8d 45 08 lea 0x8(%ebp),%eax 9b5: 50 push %eax 9b6: e8 b9 fb ff ff call 574 <peek> if(s != es){ 9bb: 8b 45 08 mov 0x8(%ebp),%eax 9be: 83 c4 10 add $0x10,%esp 9c1: 39 d8 cmp %ebx,%eax 9c3: 75 12 jne 9d7 <parsecmd+0x4f> nulterminate(cmd); 9c5: 83 ec 0c sub $0xc,%esp 9c8: 56 push %esi 9c9: e8 1e ff ff ff call 8ec <nulterminate> } 9ce: 89 f0 mov %esi,%eax 9d0: 8d 65 f8 lea -0x8(%ebp),%esp 9d3: 5b pop %ebx 9d4: 5e pop %esi 9d5: 5d pop %ebp 9d6: c3 ret printf(2, "leftovers: %s\n", s); 9d7: 52 push %edx 9d8: 50 push %eax 9d9: 68 7e 10 00 00 push $0x107e 9de: 6a 02 push $0x2 9e0: e8 fb 02 00 00 call ce0 <printf> panic("syntax"); 9e5: c7 04 24 42 10 00 00 movl $0x1042,(%esp) 9ec: e8 4f f7 ff ff call 140 <panic> 9f1: 66 90 xchg %ax,%ax 9f3: 90 nop 000009f4 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 9f4: 55 push %ebp 9f5: 89 e5 mov %esp,%ebp 9f7: 53 push %ebx 9f8: 8b 4d 08 mov 0x8(%ebp),%ecx 9fb: 8b 5d 0c mov 0xc(%ebp),%ebx char *os; os = s; while((*s++ = *t++) != 0) 9fe: 31 c0 xor %eax,%eax a00: 8a 14 03 mov (%ebx,%eax,1),%dl a03: 88 14 01 mov %dl,(%ecx,%eax,1) a06: 40 inc %eax a07: 84 d2 test %dl,%dl a09: 75 f5 jne a00 <strcpy+0xc> ; return os; } a0b: 89 c8 mov %ecx,%eax a0d: 5b pop %ebx a0e: 5d pop %ebp a0f: c3 ret 00000a10 <strcmp>: int strcmp(const char *p, const char *q) { a10: 55 push %ebp a11: 89 e5 mov %esp,%ebp a13: 53 push %ebx a14: 8b 5d 08 mov 0x8(%ebp),%ebx a17: 8b 55 0c mov 0xc(%ebp),%edx while(*p && *p == *q) a1a: 0f b6 03 movzbl (%ebx),%eax a1d: 0f b6 0a movzbl (%edx),%ecx a20: 84 c0 test %al,%al a22: 75 10 jne a34 <strcmp+0x24> a24: eb 1a jmp a40 <strcmp+0x30> a26: 66 90 xchg %ax,%ax p++, q++; a28: 43 inc %ebx a29: 42 inc %edx while(*p && *p == *q) a2a: 0f b6 03 movzbl (%ebx),%eax a2d: 0f b6 0a movzbl (%edx),%ecx a30: 84 c0 test %al,%al a32: 74 0c je a40 <strcmp+0x30> a34: 38 c8 cmp %cl,%al a36: 74 f0 je a28 <strcmp+0x18> return (uchar)*p - (uchar)*q; a38: 29 c8 sub %ecx,%eax } a3a: 5b pop %ebx a3b: 5d pop %ebp a3c: c3 ret a3d: 8d 76 00 lea 0x0(%esi),%esi a40: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; a42: 29 c8 sub %ecx,%eax } a44: 5b pop %ebx a45: 5d pop %ebp a46: c3 ret a47: 90 nop 00000a48 <strlen>: uint strlen(const char *s) { a48: 55 push %ebp a49: 89 e5 mov %esp,%ebp a4b: 8b 55 08 mov 0x8(%ebp),%edx int n; for(n = 0; s[n]; n++) a4e: 80 3a 00 cmpb $0x0,(%edx) a51: 74 15 je a68 <strlen+0x20> a53: 31 c0 xor %eax,%eax a55: 8d 76 00 lea 0x0(%esi),%esi a58: 40 inc %eax a59: 89 c1 mov %eax,%ecx a5b: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) a5f: 75 f7 jne a58 <strlen+0x10> ; return n; } a61: 89 c8 mov %ecx,%eax a63: 5d pop %ebp a64: c3 ret a65: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) a68: 31 c9 xor %ecx,%ecx } a6a: 89 c8 mov %ecx,%eax a6c: 5d pop %ebp a6d: c3 ret a6e: 66 90 xchg %ax,%ax 00000a70 <memset>: void* memset(void *dst, int c, uint n) { a70: 55 push %ebp a71: 89 e5 mov %esp,%ebp a73: 57 push %edi } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : a74: 8b 7d 08 mov 0x8(%ebp),%edi a77: 8b 4d 10 mov 0x10(%ebp),%ecx a7a: 8b 45 0c mov 0xc(%ebp),%eax a7d: fc cld a7e: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } a80: 8b 45 08 mov 0x8(%ebp),%eax a83: 5f pop %edi a84: 5d pop %ebp a85: c3 ret a86: 66 90 xchg %ax,%ax 00000a88 <strchr>: char* strchr(const char *s, char c) { a88: 55 push %ebp a89: 89 e5 mov %esp,%ebp a8b: 8b 45 08 mov 0x8(%ebp),%eax a8e: 8a 4d 0c mov 0xc(%ebp),%cl for(; *s; s++) a91: 8a 10 mov (%eax),%dl a93: 84 d2 test %dl,%dl a95: 75 0c jne aa3 <strchr+0x1b> a97: eb 13 jmp aac <strchr+0x24> a99: 8d 76 00 lea 0x0(%esi),%esi a9c: 40 inc %eax a9d: 8a 10 mov (%eax),%dl a9f: 84 d2 test %dl,%dl aa1: 74 09 je aac <strchr+0x24> if(*s == c) aa3: 38 d1 cmp %dl,%cl aa5: 75 f5 jne a9c <strchr+0x14> return (char*)s; return 0; } aa7: 5d pop %ebp aa8: c3 ret aa9: 8d 76 00 lea 0x0(%esi),%esi return 0; aac: 31 c0 xor %eax,%eax } aae: 5d pop %ebp aaf: c3 ret 00000ab0 <gets>: char* gets(char *buf, int max) { ab0: 55 push %ebp ab1: 89 e5 mov %esp,%ebp ab3: 57 push %edi ab4: 56 push %esi ab5: 53 push %ebx ab6: 83 ec 1c sub $0x1c,%esp int i, cc; char c; for(i=0; i+1 < max; ){ ab9: 8b 75 08 mov 0x8(%ebp),%esi abc: bb 01 00 00 00 mov $0x1,%ebx ac1: 29 f3 sub %esi,%ebx cc = read(0, &c, 1); ac3: 8d 7d e7 lea -0x19(%ebp),%edi for(i=0; i+1 < max; ){ ac6: eb 20 jmp ae8 <gets+0x38> cc = read(0, &c, 1); ac8: 50 push %eax ac9: 6a 01 push $0x1 acb: 57 push %edi acc: 6a 00 push $0x0 ace: e8 ea 00 00 00 call bbd <read> if(cc < 1) ad3: 83 c4 10 add $0x10,%esp ad6: 85 c0 test %eax,%eax ad8: 7e 16 jle af0 <gets+0x40> break; buf[i++] = c; ada: 8a 45 e7 mov -0x19(%ebp),%al add: 88 06 mov %al,(%esi) if(c == '\n' || c == '\r') adf: 46 inc %esi ae0: 3c 0a cmp $0xa,%al ae2: 74 0c je af0 <gets+0x40> ae4: 3c 0d cmp $0xd,%al ae6: 74 08 je af0 <gets+0x40> for(i=0; i+1 < max; ){ ae8: 8d 04 33 lea (%ebx,%esi,1),%eax aeb: 39 45 0c cmp %eax,0xc(%ebp) aee: 7f d8 jg ac8 <gets+0x18> break; } buf[i] = '\0'; af0: c6 06 00 movb $0x0,(%esi) return buf; } af3: 8b 45 08 mov 0x8(%ebp),%eax af6: 8d 65 f4 lea -0xc(%ebp),%esp af9: 5b pop %ebx afa: 5e pop %esi afb: 5f pop %edi afc: 5d pop %ebp afd: c3 ret afe: 66 90 xchg %ax,%ax 00000b00 <stat>: int stat(const char *n, struct stat *st) { b00: 55 push %ebp b01: 89 e5 mov %esp,%ebp b03: 56 push %esi b04: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); b05: 83 ec 08 sub $0x8,%esp b08: 6a 00 push $0x0 b0a: ff 75 08 pushl 0x8(%ebp) b0d: e8 d3 00 00 00 call be5 <open> if(fd < 0) b12: 83 c4 10 add $0x10,%esp b15: 85 c0 test %eax,%eax b17: 78 27 js b40 <stat+0x40> b19: 89 c3 mov %eax,%ebx return -1; r = fstat(fd, st); b1b: 83 ec 08 sub $0x8,%esp b1e: ff 75 0c pushl 0xc(%ebp) b21: 50 push %eax b22: e8 d6 00 00 00 call bfd <fstat> b27: 89 c6 mov %eax,%esi close(fd); b29: 89 1c 24 mov %ebx,(%esp) b2c: e8 9c 00 00 00 call bcd <close> return r; b31: 83 c4 10 add $0x10,%esp } b34: 89 f0 mov %esi,%eax b36: 8d 65 f8 lea -0x8(%ebp),%esp b39: 5b pop %ebx b3a: 5e pop %esi b3b: 5d pop %ebp b3c: c3 ret b3d: 8d 76 00 lea 0x0(%esi),%esi return -1; b40: be ff ff ff ff mov $0xffffffff,%esi b45: eb ed jmp b34 <stat+0x34> b47: 90 nop 00000b48 <atoi>: int atoi(const char *s) { b48: 55 push %ebp b49: 89 e5 mov %esp,%ebp b4b: 53 push %ebx b4c: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') b4f: 0f be 01 movsbl (%ecx),%eax b52: 8d 50 d0 lea -0x30(%eax),%edx b55: 80 fa 09 cmp $0x9,%dl n = 0; b58: ba 00 00 00 00 mov $0x0,%edx while('0' <= *s && *s <= '9') b5d: 77 16 ja b75 <atoi+0x2d> b5f: 90 nop n = n*10 + *s++ - '0'; b60: 41 inc %ecx b61: 8d 14 92 lea (%edx,%edx,4),%edx b64: 01 d2 add %edx,%edx b66: 8d 54 02 d0 lea -0x30(%edx,%eax,1),%edx while('0' <= *s && *s <= '9') b6a: 0f be 01 movsbl (%ecx),%eax b6d: 8d 58 d0 lea -0x30(%eax),%ebx b70: 80 fb 09 cmp $0x9,%bl b73: 76 eb jbe b60 <atoi+0x18> return n; } b75: 89 d0 mov %edx,%eax b77: 5b pop %ebx b78: 5d pop %ebp b79: c3 ret b7a: 66 90 xchg %ax,%ax 00000b7c <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { b7c: 55 push %ebp b7d: 89 e5 mov %esp,%ebp b7f: 57 push %edi b80: 56 push %esi b81: 8b 45 08 mov 0x8(%ebp),%eax b84: 8b 75 0c mov 0xc(%ebp),%esi b87: 8b 55 10 mov 0x10(%ebp),%edx char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) b8a: 85 d2 test %edx,%edx b8c: 7e 0b jle b99 <memmove+0x1d> b8e: 01 c2 add %eax,%edx dst = vdst; b90: 89 c7 mov %eax,%edi b92: 66 90 xchg %ax,%ax *dst++ = *src++; b94: a4 movsb %ds:(%esi),%es:(%edi) while(n-- > 0) b95: 39 fa cmp %edi,%edx b97: 75 fb jne b94 <memmove+0x18> return vdst; } b99: 5e pop %esi b9a: 5f pop %edi b9b: 5d pop %ebp b9c: c3 ret 00000b9d <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) b9d: b8 01 00 00 00 mov $0x1,%eax ba2: cd 40 int $0x40 ba4: c3 ret 00000ba5 <exit>: SYSCALL(exit) ba5: b8 02 00 00 00 mov $0x2,%eax baa: cd 40 int $0x40 bac: c3 ret 00000bad <wait>: SYSCALL(wait) bad: b8 03 00 00 00 mov $0x3,%eax bb2: cd 40 int $0x40 bb4: c3 ret 00000bb5 <pipe>: SYSCALL(pipe) bb5: b8 04 00 00 00 mov $0x4,%eax bba: cd 40 int $0x40 bbc: c3 ret 00000bbd <read>: SYSCALL(read) bbd: b8 05 00 00 00 mov $0x5,%eax bc2: cd 40 int $0x40 bc4: c3 ret 00000bc5 <write>: SYSCALL(write) bc5: b8 10 00 00 00 mov $0x10,%eax bca: cd 40 int $0x40 bcc: c3 ret 00000bcd <close>: SYSCALL(close) bcd: b8 15 00 00 00 mov $0x15,%eax bd2: cd 40 int $0x40 bd4: c3 ret 00000bd5 <kill>: SYSCALL(kill) bd5: b8 06 00 00 00 mov $0x6,%eax bda: cd 40 int $0x40 bdc: c3 ret 00000bdd <exec>: SYSCALL(exec) bdd: b8 07 00 00 00 mov $0x7,%eax be2: cd 40 int $0x40 be4: c3 ret 00000be5 <open>: SYSCALL(open) be5: b8 0f 00 00 00 mov $0xf,%eax bea: cd 40 int $0x40 bec: c3 ret 00000bed <mknod>: SYSCALL(mknod) bed: b8 11 00 00 00 mov $0x11,%eax bf2: cd 40 int $0x40 bf4: c3 ret 00000bf5 <unlink>: SYSCALL(unlink) bf5: b8 12 00 00 00 mov $0x12,%eax bfa: cd 40 int $0x40 bfc: c3 ret 00000bfd <fstat>: SYSCALL(fstat) bfd: b8 08 00 00 00 mov $0x8,%eax c02: cd 40 int $0x40 c04: c3 ret 00000c05 <link>: SYSCALL(link) c05: b8 13 00 00 00 mov $0x13,%eax c0a: cd 40 int $0x40 c0c: c3 ret 00000c0d <mkdir>: SYSCALL(mkdir) c0d: b8 14 00 00 00 mov $0x14,%eax c12: cd 40 int $0x40 c14: c3 ret 00000c15 <chdir>: SYSCALL(chdir) c15: b8 09 00 00 00 mov $0x9,%eax c1a: cd 40 int $0x40 c1c: c3 ret 00000c1d <dup>: SYSCALL(dup) c1d: b8 0a 00 00 00 mov $0xa,%eax c22: cd 40 int $0x40 c24: c3 ret 00000c25 <getpid>: SYSCALL(getpid) c25: b8 0b 00 00 00 mov $0xb,%eax c2a: cd 40 int $0x40 c2c: c3 ret 00000c2d <sbrk>: SYSCALL(sbrk) c2d: b8 0c 00 00 00 mov $0xc,%eax c32: cd 40 int $0x40 c34: c3 ret 00000c35 <sleep>: SYSCALL(sleep) c35: b8 0d 00 00 00 mov $0xd,%eax c3a: cd 40 int $0x40 c3c: c3 ret 00000c3d <uptime>: SYSCALL(uptime) c3d: b8 0e 00 00 00 mov $0xe,%eax c42: cd 40 int $0x40 c44: c3 ret 00000c45 <mprotect>: #me SYSCALL(mprotect) c45: b8 16 00 00 00 mov $0x16,%eax c4a: cd 40 int $0x40 c4c: c3 ret 00000c4d <munprotect>: SYSCALL(munprotect) c4d: b8 17 00 00 00 mov $0x17,%eax c52: cd 40 int $0x40 c54: c3 ret c55: 66 90 xchg %ax,%ax c57: 90 nop 00000c58 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { c58: 55 push %ebp c59: 89 e5 mov %esp,%ebp c5b: 57 push %edi c5c: 56 push %esi c5d: 53 push %ebx c5e: 83 ec 3c sub $0x3c,%esp c61: 89 45 bc mov %eax,-0x44(%ebp) c64: 89 4d c4 mov %ecx,-0x3c(%ebp) uint x; neg = 0; if(sgn && xx < 0){ neg = 1; x = -xx; c67: 89 d1 mov %edx,%ecx if(sgn && xx < 0){ c69: 8b 5d 08 mov 0x8(%ebp),%ebx c6c: 85 db test %ebx,%ebx c6e: 74 04 je c74 <printint+0x1c> c70: 85 d2 test %edx,%edx c72: 78 68 js cdc <printint+0x84> neg = 0; c74: c7 45 08 00 00 00 00 movl $0x0,0x8(%ebp) } else { x = xx; } i = 0; c7b: 31 ff xor %edi,%edi c7d: 8d 75 d7 lea -0x29(%ebp),%esi do{ buf[i++] = digits[x % base]; c80: 89 c8 mov %ecx,%eax c82: 31 d2 xor %edx,%edx c84: f7 75 c4 divl -0x3c(%ebp) c87: 89 fb mov %edi,%ebx c89: 8d 7f 01 lea 0x1(%edi),%edi c8c: 8a 92 dc 10 00 00 mov 0x10dc(%edx),%dl c92: 88 54 1e 01 mov %dl,0x1(%esi,%ebx,1) }while((x /= base) != 0); c96: 89 4d c0 mov %ecx,-0x40(%ebp) c99: 89 c1 mov %eax,%ecx c9b: 8b 45 c4 mov -0x3c(%ebp),%eax c9e: 3b 45 c0 cmp -0x40(%ebp),%eax ca1: 76 dd jbe c80 <printint+0x28> if(neg) ca3: 8b 4d 08 mov 0x8(%ebp),%ecx ca6: 85 c9 test %ecx,%ecx ca8: 74 09 je cb3 <printint+0x5b> buf[i++] = '-'; caa: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) buf[i++] = digits[x % base]; caf: 89 fb mov %edi,%ebx buf[i++] = '-'; cb1: b2 2d mov $0x2d,%dl while(--i >= 0) cb3: 8d 5c 1d d7 lea -0x29(%ebp,%ebx,1),%ebx cb7: 8b 7d bc mov -0x44(%ebp),%edi cba: eb 03 jmp cbf <printint+0x67> cbc: 8a 13 mov (%ebx),%dl cbe: 4b dec %ebx putc(fd, buf[i]); cbf: 88 55 d7 mov %dl,-0x29(%ebp) write(fd, &c, 1); cc2: 50 push %eax cc3: 6a 01 push $0x1 cc5: 56 push %esi cc6: 57 push %edi cc7: e8 f9 fe ff ff call bc5 <write> while(--i >= 0) ccc: 83 c4 10 add $0x10,%esp ccf: 39 de cmp %ebx,%esi cd1: 75 e9 jne cbc <printint+0x64> } cd3: 8d 65 f4 lea -0xc(%ebp),%esp cd6: 5b pop %ebx cd7: 5e pop %esi cd8: 5f pop %edi cd9: 5d pop %ebp cda: c3 ret cdb: 90 nop x = -xx; cdc: f7 d9 neg %ecx cde: eb 9b jmp c7b <printint+0x23> 00000ce0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { ce0: 55 push %ebp ce1: 89 e5 mov %esp,%ebp ce3: 57 push %edi ce4: 56 push %esi ce5: 53 push %ebx ce6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ ce9: 8b 75 0c mov 0xc(%ebp),%esi cec: 8a 1e mov (%esi),%bl cee: 84 db test %bl,%bl cf0: 0f 84 a3 00 00 00 je d99 <printf+0xb9> cf6: 46 inc %esi ap = (uint*)(void*)&fmt + 1; cf7: 8d 45 10 lea 0x10(%ebp),%eax cfa: 89 45 d0 mov %eax,-0x30(%ebp) state = 0; cfd: 31 d2 xor %edx,%edx write(fd, &c, 1); cff: 8d 7d e7 lea -0x19(%ebp),%edi d02: eb 29 jmp d2d <printf+0x4d> d04: 89 55 d4 mov %edx,-0x2c(%ebp) c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ d07: 83 f8 25 cmp $0x25,%eax d0a: 0f 84 94 00 00 00 je da4 <printf+0xc4> state = '%'; } else { putc(fd, c); d10: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); d13: 50 push %eax d14: 6a 01 push $0x1 d16: 57 push %edi d17: ff 75 08 pushl 0x8(%ebp) d1a: e8 a6 fe ff ff call bc5 <write> putc(fd, c); d1f: 83 c4 10 add $0x10,%esp d22: 8b 55 d4 mov -0x2c(%ebp),%edx for(i = 0; fmt[i]; i++){ d25: 46 inc %esi d26: 8a 5e ff mov -0x1(%esi),%bl d29: 84 db test %bl,%bl d2b: 74 6c je d99 <printf+0xb9> c = fmt[i] & 0xff; d2d: 0f be cb movsbl %bl,%ecx d30: 0f b6 c3 movzbl %bl,%eax if(state == 0){ d33: 85 d2 test %edx,%edx d35: 74 cd je d04 <printf+0x24> } } else if(state == '%'){ d37: 83 fa 25 cmp $0x25,%edx d3a: 75 e9 jne d25 <printf+0x45> if(c == 'd'){ d3c: 83 f8 64 cmp $0x64,%eax d3f: 0f 84 97 00 00 00 je ddc <printf+0xfc> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ d45: 81 e1 f7 00 00 00 and $0xf7,%ecx d4b: 83 f9 70 cmp $0x70,%ecx d4e: 74 60 je db0 <printf+0xd0> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ d50: 83 f8 73 cmp $0x73,%eax d53: 0f 84 8f 00 00 00 je de8 <printf+0x108> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ d59: 83 f8 63 cmp $0x63,%eax d5c: 0f 84 d6 00 00 00 je e38 <printf+0x158> putc(fd, *ap); ap++; } else if(c == '%'){ d62: 83 f8 25 cmp $0x25,%eax d65: 0f 84 c1 00 00 00 je e2c <printf+0x14c> putc(fd, c); } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); d6b: c6 45 e7 25 movb $0x25,-0x19(%ebp) write(fd, &c, 1); d6f: 50 push %eax d70: 6a 01 push $0x1 d72: 57 push %edi d73: ff 75 08 pushl 0x8(%ebp) d76: e8 4a fe ff ff call bc5 <write> putc(fd, c); d7b: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); d7e: 83 c4 0c add $0xc,%esp d81: 6a 01 push $0x1 d83: 57 push %edi d84: ff 75 08 pushl 0x8(%ebp) d87: e8 39 fe ff ff call bc5 <write> putc(fd, c); d8c: 83 c4 10 add $0x10,%esp } state = 0; d8f: 31 d2 xor %edx,%edx for(i = 0; fmt[i]; i++){ d91: 46 inc %esi d92: 8a 5e ff mov -0x1(%esi),%bl d95: 84 db test %bl,%bl d97: 75 94 jne d2d <printf+0x4d> } } } d99: 8d 65 f4 lea -0xc(%ebp),%esp d9c: 5b pop %ebx d9d: 5e pop %esi d9e: 5f pop %edi d9f: 5d pop %ebp da0: c3 ret da1: 8d 76 00 lea 0x0(%esi),%esi state = '%'; da4: ba 25 00 00 00 mov $0x25,%edx da9: e9 77 ff ff ff jmp d25 <printf+0x45> dae: 66 90 xchg %ax,%ax printint(fd, *ap, 16, 0); db0: 83 ec 0c sub $0xc,%esp db3: 6a 00 push $0x0 db5: b9 10 00 00 00 mov $0x10,%ecx dba: 8b 5d d0 mov -0x30(%ebp),%ebx dbd: 8b 13 mov (%ebx),%edx dbf: 8b 45 08 mov 0x8(%ebp),%eax dc2: e8 91 fe ff ff call c58 <printint> ap++; dc7: 89 d8 mov %ebx,%eax dc9: 83 c0 04 add $0x4,%eax dcc: 89 45 d0 mov %eax,-0x30(%ebp) dcf: 83 c4 10 add $0x10,%esp state = 0; dd2: 31 d2 xor %edx,%edx ap++; dd4: e9 4c ff ff ff jmp d25 <printf+0x45> dd9: 8d 76 00 lea 0x0(%esi),%esi printint(fd, *ap, 10, 1); ddc: 83 ec 0c sub $0xc,%esp ddf: 6a 01 push $0x1 de1: b9 0a 00 00 00 mov $0xa,%ecx de6: eb d2 jmp dba <printf+0xda> s = (char*)*ap; de8: 8b 45 d0 mov -0x30(%ebp),%eax deb: 8b 18 mov (%eax),%ebx ap++; ded: 83 c0 04 add $0x4,%eax df0: 89 45 d0 mov %eax,-0x30(%ebp) if(s == 0) df3: 85 db test %ebx,%ebx df5: 74 65 je e5c <printf+0x17c> while(*s != 0){ df7: 8a 03 mov (%ebx),%al df9: 84 c0 test %al,%al dfb: 74 70 je e6d <printf+0x18d> dfd: 89 75 d4 mov %esi,-0x2c(%ebp) e00: 89 de mov %ebx,%esi e02: 8b 5d 08 mov 0x8(%ebp),%ebx e05: 8d 76 00 lea 0x0(%esi),%esi putc(fd, *s); e08: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); e0b: 50 push %eax e0c: 6a 01 push $0x1 e0e: 57 push %edi e0f: 53 push %ebx e10: e8 b0 fd ff ff call bc5 <write> s++; e15: 46 inc %esi while(*s != 0){ e16: 8a 06 mov (%esi),%al e18: 83 c4 10 add $0x10,%esp e1b: 84 c0 test %al,%al e1d: 75 e9 jne e08 <printf+0x128> e1f: 8b 75 d4 mov -0x2c(%ebp),%esi state = 0; e22: 31 d2 xor %edx,%edx e24: e9 fc fe ff ff jmp d25 <printf+0x45> e29: 8d 76 00 lea 0x0(%esi),%esi putc(fd, c); e2c: 88 5d e7 mov %bl,-0x19(%ebp) write(fd, &c, 1); e2f: 52 push %edx e30: e9 4c ff ff ff jmp d81 <printf+0xa1> e35: 8d 76 00 lea 0x0(%esi),%esi putc(fd, *ap); e38: 8b 5d d0 mov -0x30(%ebp),%ebx e3b: 8b 03 mov (%ebx),%eax e3d: 88 45 e7 mov %al,-0x19(%ebp) write(fd, &c, 1); e40: 51 push %ecx e41: 6a 01 push $0x1 e43: 57 push %edi e44: ff 75 08 pushl 0x8(%ebp) e47: e8 79 fd ff ff call bc5 <write> ap++; e4c: 83 c3 04 add $0x4,%ebx e4f: 89 5d d0 mov %ebx,-0x30(%ebp) e52: 83 c4 10 add $0x10,%esp state = 0; e55: 31 d2 xor %edx,%edx e57: e9 c9 fe ff ff jmp d25 <printf+0x45> s = "(null)"; e5c: bb d4 10 00 00 mov $0x10d4,%ebx while(*s != 0){ e61: b0 28 mov $0x28,%al e63: 89 75 d4 mov %esi,-0x2c(%ebp) e66: 89 de mov %ebx,%esi e68: 8b 5d 08 mov 0x8(%ebp),%ebx e6b: eb 9b jmp e08 <printf+0x128> state = 0; e6d: 31 d2 xor %edx,%edx e6f: e9 b1 fe ff ff jmp d25 <printf+0x45> 00000e74 <free>: static Header base; static Header *freep; void free(void *ap) { e74: 55 push %ebp e75: 89 e5 mov %esp,%ebp e77: 57 push %edi e78: 56 push %esi e79: 53 push %ebx e7a: 8b 5d 08 mov 0x8(%ebp),%ebx Header *bp, *p; bp = (Header*)ap - 1; e7d: 8d 4b f8 lea -0x8(%ebx),%ecx for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) e80: a1 24 17 00 00 mov 0x1724,%eax e85: 8b 10 mov (%eax),%edx e87: 39 c8 cmp %ecx,%eax e89: 73 11 jae e9c <free+0x28> e8b: 90 nop e8c: 39 d1 cmp %edx,%ecx e8e: 72 14 jb ea4 <free+0x30> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) e90: 39 d0 cmp %edx,%eax e92: 73 10 jae ea4 <free+0x30> { e94: 89 d0 mov %edx,%eax for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) e96: 8b 10 mov (%eax),%edx e98: 39 c8 cmp %ecx,%eax e9a: 72 f0 jb e8c <free+0x18> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) e9c: 39 d0 cmp %edx,%eax e9e: 72 f4 jb e94 <free+0x20> ea0: 39 d1 cmp %edx,%ecx ea2: 73 f0 jae e94 <free+0x20> break; if(bp + bp->s.size == p->s.ptr){ ea4: 8b 73 fc mov -0x4(%ebx),%esi ea7: 8d 3c f1 lea (%ecx,%esi,8),%edi eaa: 39 fa cmp %edi,%edx eac: 74 1a je ec8 <free+0x54> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; eae: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ eb1: 8b 50 04 mov 0x4(%eax),%edx eb4: 8d 34 d0 lea (%eax,%edx,8),%esi eb7: 39 f1 cmp %esi,%ecx eb9: 74 24 je edf <free+0x6b> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; ebb: 89 08 mov %ecx,(%eax) freep = p; ebd: a3 24 17 00 00 mov %eax,0x1724 } ec2: 5b pop %ebx ec3: 5e pop %esi ec4: 5f pop %edi ec5: 5d pop %ebp ec6: c3 ret ec7: 90 nop bp->s.size += p->s.ptr->s.size; ec8: 03 72 04 add 0x4(%edx),%esi ecb: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; ece: 8b 10 mov (%eax),%edx ed0: 8b 12 mov (%edx),%edx ed2: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ ed5: 8b 50 04 mov 0x4(%eax),%edx ed8: 8d 34 d0 lea (%eax,%edx,8),%esi edb: 39 f1 cmp %esi,%ecx edd: 75 dc jne ebb <free+0x47> p->s.size += bp->s.size; edf: 03 53 fc add -0x4(%ebx),%edx ee2: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; ee5: 8b 53 f8 mov -0x8(%ebx),%edx ee8: 89 10 mov %edx,(%eax) freep = p; eea: a3 24 17 00 00 mov %eax,0x1724 } eef: 5b pop %ebx ef0: 5e pop %esi ef1: 5f pop %edi ef2: 5d pop %ebp ef3: c3 ret 00000ef4 <malloc>: return freep; } void* malloc(uint nbytes) { ef4: 55 push %ebp ef5: 89 e5 mov %esp,%ebp ef7: 57 push %edi ef8: 56 push %esi ef9: 53 push %ebx efa: 83 ec 1c sub $0x1c,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; efd: 8b 45 08 mov 0x8(%ebp),%eax f00: 8d 70 07 lea 0x7(%eax),%esi f03: c1 ee 03 shr $0x3,%esi f06: 46 inc %esi if((prevp = freep) == 0){ f07: 8b 3d 24 17 00 00 mov 0x1724,%edi f0d: 85 ff test %edi,%edi f0f: 0f 84 a3 00 00 00 je fb8 <malloc+0xc4> base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ f15: 8b 07 mov (%edi),%eax if(p->s.size >= nunits){ f17: 8b 48 04 mov 0x4(%eax),%ecx f1a: 39 f1 cmp %esi,%ecx f1c: 73 67 jae f85 <malloc+0x91> f1e: 89 f3 mov %esi,%ebx f20: 81 fe 00 10 00 00 cmp $0x1000,%esi f26: 0f 82 80 00 00 00 jb fac <malloc+0xb8> p = sbrk(nu * sizeof(Header)); f2c: 8d 0c dd 00 00 00 00 lea 0x0(,%ebx,8),%ecx f33: 89 4d e4 mov %ecx,-0x1c(%ebp) f36: eb 11 jmp f49 <malloc+0x55> for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ f38: 8b 10 mov (%eax),%edx if(p->s.size >= nunits){ f3a: 8b 4a 04 mov 0x4(%edx),%ecx f3d: 39 f1 cmp %esi,%ecx f3f: 73 4b jae f8c <malloc+0x98> f41: 8b 3d 24 17 00 00 mov 0x1724,%edi f47: 89 d0 mov %edx,%eax p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) f49: 39 c7 cmp %eax,%edi f4b: 75 eb jne f38 <malloc+0x44> p = sbrk(nu * sizeof(Header)); f4d: 83 ec 0c sub $0xc,%esp f50: ff 75 e4 pushl -0x1c(%ebp) f53: e8 d5 fc ff ff call c2d <sbrk> if(p == (char*)-1) f58: 83 c4 10 add $0x10,%esp f5b: 83 f8 ff cmp $0xffffffff,%eax f5e: 74 1b je f7b <malloc+0x87> hp->s.size = nu; f60: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); f63: 83 ec 0c sub $0xc,%esp f66: 83 c0 08 add $0x8,%eax f69: 50 push %eax f6a: e8 05 ff ff ff call e74 <free> return freep; f6f: a1 24 17 00 00 mov 0x1724,%eax if((p = morecore(nunits)) == 0) f74: 83 c4 10 add $0x10,%esp f77: 85 c0 test %eax,%eax f79: 75 bd jne f38 <malloc+0x44> return 0; f7b: 31 c0 xor %eax,%eax } } f7d: 8d 65 f4 lea -0xc(%ebp),%esp f80: 5b pop %ebx f81: 5e pop %esi f82: 5f pop %edi f83: 5d pop %ebp f84: c3 ret if(p->s.size >= nunits){ f85: 89 c2 mov %eax,%edx f87: 89 f8 mov %edi,%eax f89: 8d 76 00 lea 0x0(%esi),%esi if(p->s.size == nunits) f8c: 39 ce cmp %ecx,%esi f8e: 74 54 je fe4 <malloc+0xf0> p->s.size -= nunits; f90: 29 f1 sub %esi,%ecx f92: 89 4a 04 mov %ecx,0x4(%edx) p += p->s.size; f95: 8d 14 ca lea (%edx,%ecx,8),%edx p->s.size = nunits; f98: 89 72 04 mov %esi,0x4(%edx) freep = prevp; f9b: a3 24 17 00 00 mov %eax,0x1724 return (void*)(p + 1); fa0: 8d 42 08 lea 0x8(%edx),%eax } fa3: 8d 65 f4 lea -0xc(%ebp),%esp fa6: 5b pop %ebx fa7: 5e pop %esi fa8: 5f pop %edi fa9: 5d pop %ebp faa: c3 ret fab: 90 nop fac: bb 00 10 00 00 mov $0x1000,%ebx fb1: e9 76 ff ff ff jmp f2c <malloc+0x38> fb6: 66 90 xchg %ax,%ax base.s.ptr = freep = prevp = &base; fb8: c7 05 24 17 00 00 28 movl $0x1728,0x1724 fbf: 17 00 00 fc2: c7 05 28 17 00 00 28 movl $0x1728,0x1728 fc9: 17 00 00 base.s.size = 0; fcc: c7 05 2c 17 00 00 00 movl $0x0,0x172c fd3: 00 00 00 fd6: bf 28 17 00 00 mov $0x1728,%edi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ fdb: 89 f8 mov %edi,%eax fdd: e9 3c ff ff ff jmp f1e <malloc+0x2a> fe2: 66 90 xchg %ax,%ax prevp->s.ptr = p->s.ptr; fe4: 8b 0a mov (%edx),%ecx fe6: 89 08 mov %ecx,(%eax) fe8: eb b1 jmp f9b <malloc+0xa7>
extern m7_ippsECCPVerifyDSA:function extern n8_ippsECCPVerifyDSA:function extern y8_ippsECCPVerifyDSA:function extern e9_ippsECCPVerifyDSA:function extern l9_ippsECCPVerifyDSA:function extern n0_ippsECCPVerifyDSA:function extern k0_ippsECCPVerifyDSA:function extern ippcpJumpIndexForMergedLibs extern ippcpSafeInit:function segment .data align 8 dq .Lin_ippsECCPVerifyDSA .Larraddr_ippsECCPVerifyDSA: dq m7_ippsECCPVerifyDSA dq n8_ippsECCPVerifyDSA dq y8_ippsECCPVerifyDSA dq e9_ippsECCPVerifyDSA dq l9_ippsECCPVerifyDSA dq n0_ippsECCPVerifyDSA dq k0_ippsECCPVerifyDSA segment .text global ippsECCPVerifyDSA:function (ippsECCPVerifyDSA.LEndippsECCPVerifyDSA - ippsECCPVerifyDSA) .Lin_ippsECCPVerifyDSA: db 0xf3, 0x0f, 0x1e, 0xfa call ippcpSafeInit wrt ..plt align 16 ippsECCPVerifyDSA: db 0xf3, 0x0f, 0x1e, 0xfa mov rax, qword [rel ippcpJumpIndexForMergedLibs wrt ..gotpc] movsxd rax, dword [rax] lea r11, [rel .Larraddr_ippsECCPVerifyDSA] mov r11, qword [r11+rax*8] jmp r11 .LEndippsECCPVerifyDSA:
; A176402: Decimal expansion of (9+sqrt(87))/3. ; Submitted by Jon Maiga ; 6,1,0,9,1,2,6,3,5,1,0,2,9,6,0,5,0,1,5,1,8,4,8,2,5,1,8,0,7,7,3,5,1,8,9,9,4,4,2,5,4,1,3,5,6,4,7,3,0,5,5,1,5,5,7,0,1,8,7,3,2,4,3,2,8,1,5,5,9,4,8,4,9,6,0,2,4,1,6,5,5,9,4,7,1,4,0,6,8,5,4,3,0,3,9,6,0,6,7,2 mov $2,1 mov $3,$0 mul $3,3 mov $5,2 lpb $3 add $1,$2 add $5,$2 add $5,$2 add $1,$5 mul $1,12 add $2,$1 mov $1,1 sub $3,2 lpe mov $1,1 add $1,$5 mul $1,2 mov $4,10 pow $4,$0 div $2,$4 div $1,$2 mov $0,$1 mod $0,10
; A083101: a(n) = 2*a(n-1) + 10*a(n-2). ; Submitted by Jamie Morken(w4) ; 1,12,34,188,716,3312,13784,60688,259216,1125312,4842784,20938688,90305216,389997312,1683046784,7266066688,31362601216,135385869312,584397750784,2522654194688,10889285897216,47005113741312,202903086454784,875857310322688,3780745485193216,16320064073613312,70447582999158784,304095806734450688,1312667443460489216,5666292954265485312,24459260343135862784,105581450228926578688,455755503889211785216,1967325510067689357312,8492206059027496566784,36657667218731886706688,158237395027738739081216 lpb $0 sub $0,1 mul $2,5 mov $3,$2 mul $4,2 add $4,1 mov $2,$4 add $4,$3 lpe mov $0,$2 mul $0,11 add $0,1
; ; ARMv7 versions of the font routines ; format ELF ; entry start ; segment readable executable USE32 section '.text' ; code readable executable ; Declare public symbols ; Declare public symbols public _draw_bitfont_32asm public draw_bitfont_32asm public _draw_bitfont_16asm public draw_bitfont_16asm public _draw_bytefont_32asm public draw_bytefont_32asm public _draw_bytefont_16asm public draw_bytefont_16asm public _draw_colourfont_32asm public draw_colourfont_32asm public _draw_colourfont_16asm public draw_colourfont_16asm ; Monochrome bitpacked fonts ; 32bpp _draw_bitfont_32asm: draw_bitfont_32asm: push {r4-r8} ; r0 = dest ; r1 = source ; r2 = width offset ; r3 = colour ; Get width offset and convert to dwords, stick into r5 lsl r5,r2,#2 mov r4,r0 eor r0,r0 ; Clear high words mov r6,#8 ; 8 pixels high ; Now r0 = scratch, r1 = source, r2 = width, r3 = colour, r4 = dest, r5 = width offset, r6 = height bitfont32h: mov r2,#8 ; Set to 8 pixels wide ldrb r0,[r1] ; get byte into r0 add r1,#1 bitfont32w: tst r0,#128 ; Test high bit of AL stmiane r4,{r3} ; Write and don't increment add r4,#4 lsl r0,#1 ; Slide AL across to get next bit subs r2,#1 bne bitfont32w add r4, r5 subs r6,#1 bne bitfont32h pop {r4-r8} mov pc,lr ; 16bpp _draw_bitfont_16asm: draw_bitfont_16asm: push {r4-r8} ; r0 = dest ; r1 = source ; r2 = width offset ; r3 = colour ; Get width offset and convert to words, stick into r5 lsl r5,r2,#1 mov r4,r0 eor r0,r0 ; Clear high words mov r6,#8 ; 8 pixels high ; Now r0 = scratch, r1 = source, r2 = width, r3 = colour, r4 = dest, r5 = width offset, r6 = height mov r2,#8 ; Set to 8 pixels wide ldrb r0,[r1],#1 ; get byte into r0 ; add r1,#1 ALIGN 4 bitfont16w: tst r0,#128 ; Test high bit of AL strhne r3,[r4] ; Write and don't increment add r4,#2 lsl.b r0,#1 ; Slide AL across to get next bit subs r2,#1 bne bitfont16w add r4, r5 subs r6,#1 bne bitfont16h pop {r4-r8} mov pc,lr ; Monochrome sprite fonts ; 32bpp _draw_bytefont_32asm: draw_bytefont_32asm: mov pc,lr ; r0 = dest ; r1 = font data ; r2 = width ; r3 = height mov r12,sp push {r4-r8} stmfd r12,{r4-r5} ; r4 = offset, r5 = colour ; Convert width offset to dwords lsl r4,#2 ; Move dest to R6, R0 as scratch mov r6,r0 eor r0,r0 ; Clear high words ; Now r0 = scratch, r1 = source, r2 = width, r3 = height, r4 =offset, r5 = colour, r6 = dest bytefont32h: mov r7,r2 ;width bytefont32w: ldrb r0,[r1],#1 ; get byte into r0 and increment r1 tst r0,r0 stmiaeq r6,{r4} ; Write and don't increment bytefont32skip: add r6,#4 subs r7,#1 bne bytefont32w add r6,r4 subs r3,#1 bne bytefont32h pop {r4-r8} mov pc,lr ; 16bpp _draw_bytefont_16asm: draw_bytefont_16asm: mov pc,lr ; r0 = dest ; r1 = font data ; r2 = width ; r3 = height mov r12,sp push {r4-r7} stmfd r12,{r4-r5} ; r4 = offset, r5 = colour ; Convert width offset to words lsl r4,#1 ; Move dest to R6, R0 as scratch mov r6,r0 eor r0,r0 ; Clear high words ; Now r0 = scratch, r1 = source, r2 = width, r3 = height, r4 =offset, r5 = colour, r6 = dest bytefont16h: mov r7,r2 ;width bytefont16w: ldrb r0,[r1],#1 ; get byte into r0 and increment r1 tst r0,r0 strheq r5,[r6] ; Write and don't increment bytefont16skip: add r6,#4 subs r7,#1 bne bytefont16w add r6,r4 subs r3,#1 bne bytefont16h pop {r4-r7} mov pc,lr ; Colour sprite fonts ; 32bpp _draw_colourfont_32asm: draw_colourfont_32asm: ; r0 = dest ; r1 = font data ; r2 = palette ; r3 = width mov r12,sp push {r4-r8} stmfd r12,{r4-r5} ; r4 = height, r5 = offset ; Convert width offset to dwords lsl r4,#2 ; Move dest to R6, R0 as scratch mov r6,r0 eor r0,r0 ; Clear high words ; Now r0 = scratch, r1 = source, r2 = palette, r3 = width, r4 =height, r5 = offset, r6 = dest colourfont32h: mov r7,r3 ;width colourfont32w: ldrb r0,[r1],#1 ; get byte into r0 and increment r1 tst r0,r0 beq colourfont32skip lsl r0,#2 ; Multiply R0 by 4 to convert to dword index ldr r8,[r2,r0] ; Lookup str r8,[r6] ; Write to dest eor r0,r0 ; Clear it colourfont32skip: add r6,#4 subs r7,#1 bne colourfont32w add r6, r5 subs r4,#1 bne colourfont32h pop {r4-r8} mov pc,lr _draw_colourfont_16asm: draw_colourfont_16asm: ; r0 = dest ; r1 = font data ; r2 = palette ; r3 = width mov r12,sp push {r4-r8} stmfd r12,{r4-r5} ; r4 = height, r5 = offset ; Convert width offset to words lsl r4,#1 ; Move dest to R6, R0 as scratch mov r6,r0 eor r0,r0 ; Clear high words ; Now r0 = scratch, r1 = source, r2 = palette, r3 = width, r4 =height, r5 = offset, r6 = dest colourfont16h: mov r7,r3 ;width colourfont16w: ldrb r0,[r1],#1 ; get byte into r0 and increment r1 tst r0,r0 beq colourfont16skip lsl r0,#2 ; Multiply R0 by 4 to convert to dword index (yes, even in 16bpp) ldr r8,[r2,r0] ; Lookup strh r8,[r6] ; Write to dest eor r0,r0 ; Clear it colourfont16skip: add r6,#2 subs r7,#1 bne colourfont16w add r6, r5 subs r4,#1 bne colourfont16h pop {r4-r8} mov pc,lr
; A143829: Numbers n such that 10n^2 - 1 is prime. ; Submitted by Jon Maiga ; 3,6,9,12,21,30,33,36,45,48,60,69,72,75,81,87,99,108,111,114,117,120,123,126,129,153,165,168,174,177,183,201,204,207,222,234,243,252,267,279,282,285,294,303,312,315,318,339,345,348,369,378,381,384,393,396 mov $2,332202 lpb $2 seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0. sub $0,$3 add $5,$1 add $1,9 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 sub $2,18 sub $5,1 add $5,$1 add $1,1 mov $3,$5 add $5,2 lpe mov $0,$1 div $0,30 mul $0,3
; A173529: a(n) = 1 + A053830(n-1), where A053830 is the sum of the digits of its argument in base 9. ; 1,2,3,4,5,6,7,8,9,2,3,4,5,6,7,8,9,10,3,4,5,6,7,8,9,10,11,4,5,6,7,8,9,10,11,12,5,6,7,8,9,10,11,12,13,6,7,8,9,10,11,12,13,14,7,8,9,10,11,12,13,14,15,8,9,10,11,12,13,14,15,16,9,10,11,12,13,14,15,16,17,2,3,4,5,6,7,8,9,10,3,4,5,6,7,8,9,10,11,4 lpb $0 mov $2,$0 lpb $2 mod $2,9 lpe div $0,9 add $1,$2 lpe add $1,1 mov $0,$1
copyright zengfr site:http://github.com/zengfr/romhack 004A84 abcd -(A0), -(A2) [1p+93] copyright zengfr site:http://github.com/zengfr/romhack
; A246640: Sequence a(n) = 1 + A001519(n+1) appearing in a certain touching problem for three circles and a chord, together with A246638. ; 2,3,6,14,35,90,234,611,1598,4182,10947,28658,75026,196419,514230,1346270,3524579,9227466,24157818,63245987,165580142,433494438,1134903171,2971215074,7778742050,20365011075,53316291174,139583862446,365435296163,956722026042,2504730781962,6557470319843,17167680177566,44945570212854,117669030460995,308061521170130,806515533049394,2111485077978051,5527939700884758,14472334024676222,37889062373143907,99194853094755498,259695496911122586,679891637638612259,1779979416004714190,4660046610375530310 mov $1,1 lpb $0 sub $0,1 add $2,$1 add $1,$2 lpe add $1,1 mov $0,$1
#include "Timer.h" #include "Image.h" HRESULT Timer::Init() { posX = (WINSIZE_X / 2)+3; posY = (WINSIZE_Y / 10)*1.5; CountDown_Num = new Image(); CountNum = 0; CountDown_Num->Init("Image/Timer.bmp", posX, posY, 140, 75, 10, 3, true, transColor[CountNum]); printTime = 45; currKeyFrameY = 0; elapsedFrame = 0; scale = 1.7f; return S_OK; } void Timer::Release() { CountDown_Num->Release(); delete CountDown_Num; } void Timer::Update() { if (printTime > 10) { currKeyFrameX = printTime % 10; currKeyFrameX2 = (printTime - (printTime % 10)) / 10; } else { CountNum = 1; CountDown_Num->SetTransColor(transColor[CountNum]); currKeyFrameY = 1; currKeyFrameX = printTime % 10; currKeyFrameX2 = (printTime - (printTime % 10)) / 10; } } void Timer::Render(HDC hdc) { CountDown_Num->FrameRender(hdc, posX - 25, posY, currKeyFrameX2, currKeyFrameY, scale); CountDown_Num->FrameRender(hdc, posX, posY, currKeyFrameX, currKeyFrameY, scale); } Timer::Timer() { } Timer::~Timer() { }
// This file was automatically generated on Sat Oct 11 19:26:16 2014 // by libs/config/tools/generate.cpp // Copyright John Maddock 2002-4. // Use, modification and distribution are subject to 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) // See http://www.boost.org/libs/config for the most recent version.// // Revision $Id$ // // Test file for macro BOOST_NO_CXX14_BINARY_LITERALS // This file should not compile, if it does then // BOOST_NO_CXX14_BINARY_LITERALS should not be defined. // See file boost_no_cxx14_binary_literals.ipp for details // Must not have BOOST_ASSERT_CONFIG set; it defeats // the objective of this file: #ifdef BOOST_ASSERT_CONFIG # undef BOOST_ASSERT_CONFIG #endif #include <boost/config.hpp> #include "test.hpp" #ifdef BOOST_NO_CXX14_BINARY_LITERALS #include "boost_no_cxx14_binary_literals.ipp" #else #error "this file should not compile" #endif int main( int, char *[] ) { return boost_no_cxx14_binary_literals::test(); }
SECTION "mobile_40", ROMX Function100000: Function100022: Function100057: call DisableMobile call ReturnToMapFromSubmenu ld hl, wVramState res 1, [hl] ret SetRAMStateForMobile: xor a ld hl, wBGMapBuffer ld bc, $65 call ByteFill xor a ld hl, wc300 ld bc, $100 call ByteFill ldh a, [rIE] ld [wBGMapBuffer], a xor a ldh [hMapAnims], a ldh [hLCDCPointer], a ret EnableMobile: xor a ld hl, wOverworldMapBlocks ld bc, wOverworldMapBlocksEnd - wOverworldMapBlocks call ByteFill di call DoubleSpeed xor a ldh [rIF], a ld a, IE_DEFAULT ldh [rIE], a xor a ldh [hMapAnims], a ldh [hLCDCPointer], a ld a, $01 ldh [hMobileReceive], a ldh [hMobile], a ei ret DisableMobile: di xor a ldh [hMobileReceive], a ldh [hMobile], a xor a ldh [hVBlank], a call NormalSpeed xor a ldh [rIF], a ld a, [wBGMapBuffer] ldh [rIE], a ei ret Function1000ba: .loop ; call [wcd22]:([wcd23][wcd24] + [wMobileCommsJumptableIndex]) ld hl, wcd23 ld a, [hli] ld h, [hl] ld l, a ld a, [wMobileCommsJumptableIndex] ld e, a ld d, 0 add hl, de add hl, de ld a, [wcd22] call GetFarHalfword ld a, [wcd22] rst FarCall call Function1000e8 call Function1000fa call Function100144 call Function100163 ld a, [wcd2b] and a jr z, .loop call DelayFrame ret Function1000e8: ld hl, wcd29 bit 7, [hl] ret z farcall Function115dd3 ld hl, wcd29 set 6, [hl] ret Function1000fa: ld a, [wc30d] and a ret z ld hl, wcd29 bit 4, [hl] ret z ld a, [wcd2b] and a jr nz, .asm_100117 farcall Function11619d ld hl, wcd29 set 6, [hl] ret .asm_100117 di xor a ldh [rIF], a ldh a, [rIE] and $1f ^ (1 << SERIAL | 1 << TIMER) ldh [rIE], a xor a ldh [hMobileReceive], a ldh [hMobile], a ei ld a, [wLinkMode] push af xor a ld [wLinkMode], a ld a, $04 ld [wc314 + 5], a farcall Function11619d ld hl, wcd29 set 6, [hl] pop af ld [wLinkMode], a ret Function100144: ld hl, wcd29 bit 5, [hl] jr z, .asm_100155 res 5, [hl] res 2, [hl] res 6, [hl] call Function100320 ret .asm_100155 bit 2, [hl] ret z res 2, [hl] res 6, [hl] farcall HDMATransferTileMapToWRAMBank3 ret Function100163: ld hl, wcd29 bit 6, [hl] ret z res 6, [hl] call DelayFrame ret Function10016f: ld a, [wcd2b] cp $01 ret z cp $02 ret z cp $ff jp z, .asm_1001f5 cp $fe jr z, .asm_1001c4 cp $f5 jr z, .asm_1001e7 cp $f6 jr z, .asm_1001b6 cp $fa jp z, .asm_1001bd cp $f7 jp z, .asm_1001ee cp $f4 jr z, .asm_1001d2 cp $f3 jr z, .asm_1001cb cp $f1 jr z, .asm_1001c4 cp $f2 jr z, .asm_1001c4 cp $fc jr z, .asm_1001e6 cp $fb jr z, .asm_1001af cp $f8 ret z ret ; ???????????????????????????? .asm_1001af ld a, $d7 ld de, 0 jr .asm_1001d7 .asm_1001b6 ld a, $d5 ld de, 0 jr .asm_1001d7 .asm_1001bd ld a, $d6 ld de, 0 jr .asm_1001d7 .asm_1001c4 ld a, $d2 ld de, 2 jr .asm_1001d7 .asm_1001cb ld a, $d1 ld de, 1 jr .asm_1001d7 .asm_1001d2 ld a, $d0 ld de, 0 .asm_1001d7 ld [wc300], a ld a, d ld [wc302], a ld a, e ld [wc301], a call Function10020b ret .asm_1001e6 ret .asm_1001e7 ld de, String10025e call Function100232 ret .asm_1001ee ld de, String10024d call Function100232 ret .asm_1001f5 ld a, [wcd2c] ld [wc300], a ld a, [wcd2d] ld [wc302], a ld a, [wcd2d] ld [wc301], a call Function10020b ret Function10020b: xor a ld [wc303], a farcall FadeOutPalettes farcall Function106464 call HideSprites call DelayFrame ldh a, [rSVBK] push af ld a, $01 ldh [rSVBK], a farcall DisplayMobileError pop af ldh [rSVBK], a ret Function100232: push de farcall Function106464 call Function3f20 call UpdateSprites hlcoord 1, 2 pop de call PlaceString call Function100320 call JoyWaitAorB ret String10024d: db "ใคใ†ใ—ใ‚“ใ‚’ใ€€ใ‚ญใƒฃใƒณใ‚ปใƒซใ€€ใ—ใพใ—ใŸ@" String10025e: db "ใŠใจใ‚‚ใ ใกใจใ€€ใˆใ‚‰ใ‚“ใ ใ€€ใธใ‚„ใŒ" next "ใกใŒใ†ใ‚ˆใ†ใงใ™@" Function100276: ld a, [wcd2b] cp $01 jr z, .asm_10029f cp $02 jr z, .asm_100296 cp $f5 jr z, .asm_1002a5 cp $f6 jr z, .asm_1002a5 cp $f7 jr z, .asm_100293 cp $f8 jr z, .asm_1002b1 jr .asm_1002c0 .asm_100293 ld c, $02 ret .asm_100296 farcall Script_reloadmappart ld c, $04 ret .asm_10029f call Function1002dc ld c, 0 ret .asm_1002a5 farcall Script_reloadmappart call Function1002ed ld c, $03 ret .asm_1002b1 call Function1002c9 call Function1002dc ld de, String10024d call Function100232 ld c, $02 ret .asm_1002c0 call Function1002c9 call Function1002dc ld c, $01 ret Function1002c9: ld hl, wcd2a bit 0, [hl] ret z farcall CleanUpBattleRAM farcall LoadPokemonData ret Function1002dc: ld a, MAPSETUP_LINKRETURN ldh [hMapEntryMethod], a farcall RunMapSetupScript xor a ldh [hMapEntryMethod], a call LoadStandardFont ret Function1002ed: farcall LoadOW_BGPal7 farcall ApplyPals ld a, $01 ldh [hCGBPalUpdate], a call DelayFrame ret Function100301: ld hl, wcd2a bit 1, [hl] ret z farcall Function106464 farcall Function10202c farcall Function115dd3 call Function100320 call JoyWaitAorB ret Function100320: farcall Mobile_ReloadMapPart ret Function100327: farcall HDMATransferTileMapToWRAMBank3 ret Function10032e: call Function10034d ld e, a ret nc ld [wcd2b], a ret Function100337: call Function10032e ret c ld a, [wc821] bit 4, a jr z, .asm_100345 ld a, e and a ret .asm_100345 ld a, $f9 ld e, a ld [wcd2b], a scf ret Function10034d: ld a, [wc821] bit 1, a jr nz, .asm_10036a bit 2, a jr nz, .asm_10037e bit 3, a jr nz, .asm_100366 bit 0, a jr nz, .asm_100364 ld a, $01 and a ret .asm_100364 xor a ret .asm_100366 ld a, $02 and a ret .asm_10036a ld a, 0 call Function3e32 ld [wcd2c], a ld a, h ld [wcd2d], a ld a, l ld [wcd2e], a ld a, $ff scf ret .asm_10037e ld a, $fe scf ret Function100382: ld a, [wcd27] ld hl, Jumptable_10044e rst JumpTable ret Function10038a: ld hl, wccb4 ld a, $2e call Function3e32 ret Function100393: ld hl, wcc60 ld a, $3a call Function3e32 ret Function10039c: ld hl, wcc60 ld de, w3_d000 ld bc, $54 ld a, $03 call FarCopyWRAM ret Function1003ab: ld hl, w3_d000 ld de, wcc60 ld bc, $54 ld a, $03 call FarCopyWRAM ret Function1003ba: ld hl, wccb4 ld de, w3_d080 ld bc, $54 ld a, $03 call FarCopyWRAM ret Function1003c9: ld hl, w3_d080 ld de, wccb4 ld bc, $54 ld a, $03 call FarCopyWRAM ret Function1003d8: ld hl, wccb4 ld a, [hli] ld c, a ld b, 0 push hl add hl, bc ld a, [wBGMapPalBuffer] ld [hl], a pop hl inc bc call Function10043a add hl, bc ld [hl], e inc hl ld [hl], d ld a, c add $02 ld [wccb4], a ret Function1003f5: ld a, [wcc60] sub $03 ld [wcc60], a ld a, [wccb4] sub $03 ld [wccb4], a ret Function100406: ld a, [wcc60] sub $02 ld c, a ld b, 0 ld hl, wcc61 call Function10043a add hl, bc ld a, [hli] cp e jr nz, .asm_100426 ld a, [hld] cp d jr nz, .asm_100426 dec hl ld a, [wBGMapPalBuffer] cp [hl] jr nz, .asm_10042d xor a ret .asm_100426 ld a, $f4 ld [wcd2b], a jr .asm_100432 .asm_10042d ld a, $f3 ld [wcd2b], a .asm_100432 push hl ld hl, wcd7c inc [hl] pop hl scf ret Function10043a: push hl push bc ld de, 0 .asm_10043f ld a, [hli] add e ld e, a ld a, d adc 0 ld d, a dec bc ld a, b or c jr nz, .asm_10043f pop bc pop hl ret Jumptable_10044e: dw Function10046a dw Function10047c dw Function100493 dw Function1004ba dw Function1004f4 dw Function1004ce dw Function1004de dw Function1004a4 dw Function100495 dw Function1004ce dw Function1004de dw Function1004e9 dw Function1004f4 dw Function1004a4 Function10046a: ld hl, wBGMapPalBuffer inc [hl] call Function1003d8 call Function1003ba ld a, [wcd27] inc a ld [wcd27], a ret Function10047c: call Function100337 ret c ret z cp $02 jr z, .asm_100487 jr .asm_10048d .asm_100487 ld a, $08 ld [wcd27], a ret .asm_10048d ld a, $02 ld [wcd27], a ret Function100493: jr asm_100497 Function100495: jr asm_100497 asm_100497: call Function100337 ret c ret z ld a, [wcd27] inc a ld [wcd27], a ret Function1004a4: call Function100406 jr c, .asm_1004b8 call Function1003c9 call Function1003f5 ld a, [wcd27] set 7, a ld [wcd27], a ret .asm_1004b8 scf ret Function1004ba: call Function10038a and a jr nz, .asm_1004c8 ld a, [wcd27] inc a ld [wcd27], a ret .asm_1004c8 ld a, $08 ld [wcd27], a ret Function1004ce: call Function100337 ret c ret z cp $02 ret nz ld a, [wcd27] inc a ld [wcd27], a ret Function1004de: call Function100393 ld a, [wcd27] inc a ld [wcd27], a ret Function1004e9: call Function10038a ld a, [wcd27] inc a ld [wcd27], a ret Function1004f4: call Function100337 ret c ret z ld a, [wcd27] inc a ld [wcd27], a call Function10039c ret Function100504: push de call Function3f20 call UpdateSprites pop de hlcoord 4, 2 call PlaceString ret Function100513: call Function3f7c call PlaceVerticalMenuItems call InitVerticalMenuCursor ld hl, w2DMenuFlags1 set 7, [hl] ret Function100522: ld a, [wcd28] ld hl, Jumptable_10052a rst JumpTable ret Jumptable_10052a: dw Function100534 dw Function100545 dw Function100545 dw Function100545 dw Function10054d Function100534: call Function100513 call UpdateSprites call ApplyTilemap ld a, [wcd28] inc a ld [wcd28], a ret Function100545: ld a, [wcd28] inc a ld [wcd28], a ret Function10054d: farcall MobileMenuJoypad ld a, c ld hl, wMenuJoypadFilter and [hl] ret z call MenuClickSound bit 0, a jr nz, .asm_100565 bit 1, a jr nz, .asm_10056f ret .asm_100565 ld a, [wcd28] set 7, a ld [wcd28], a and a ret .asm_10056f ld a, [wcd28] set 7, a ld [wcd28], a scf ret Function100579: ld a, [wcd26] ld hl, Jumptable_100581 rst JumpTable ret Jumptable_100581: dw Function100585 dw Function100597 Function100585: ld hl, MenuHeader_1005b2 call LoadMenuHeader ld a, 0 ld [wcd28], a ld a, [wcd26] inc a ld [wcd26], a Function100597: call Function100522 ld a, [wcd28] bit 7, a ret z jr nc, .asm_1005a6 xor a ld [wMenuCursorY], a .asm_1005a6 call ExitMenu ld a, [wcd26] set 7, a ld [wcd26], a ret MenuHeader_1005b2: db MENU_BACKUP_TILES ; flags db 6, 14 db 10, 19 dw MenuData_1005ba db 1 ; default option MenuData_1005ba: db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 2 db "ใฏใ„@" db "ใ„ใ„ใˆ@" Function1005c3: ld a, [wcd26] ld hl, Jumptable_1005cb rst JumpTable ret Jumptable_1005cb: dw Function1005cf dw Function1005e1 Function1005cf: ld hl, MenuHeader_1005fc call LoadMenuHeader ld a, 0 ld [wcd28], a ld a, [wcd26] inc a ld [wcd26], a Function1005e1: call Function100522 ld a, [wcd28] bit 7, a ret z jr nc, .asm_1005f0 xor a ld [wMenuCursorY], a .asm_1005f0 call ExitMenu ld a, [wcd26] set 7, a ld [wcd26], a ret MenuHeader_1005fc: db MENU_BACKUP_TILES ; flags db 6, 14 db 10, 19 dw MenuData_100604 db 1 ; default option MenuData_100604: db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 2 db "ใ‹ใ‘ใ‚‹@" db "ใพใค@" Mobile_CommunicationStandby: hlcoord 3, 10 ld b, 1 ld c, 11 call Function3eea ld de, .String hlcoord 4, 11 call PlaceString ret .String: db "ใคใ†ใ—ใ‚“ใŸใ„ใใกใ‚…ใ†๏ผ@" AdvanceMobileInactivityTimerAndCheckExpired: push bc call IncrementMobileInactivityTimerByCFrames pop bc ld a, [wMobileInactivityTimerMinutes] cp b jr nc, .timed_out and a ret .timed_out ld a, $fa ld [wcd2b], a scf ret StartMobileInactivityTimer: xor a ld [wMobileInactivityTimerMinutes], a ld [wMobileInactivityTimerSeconds], a ld [wMobileInactivityTimerFrames], a ret IncrementMobileInactivityTimerBy1Frame: ld c, 1 IncrementMobileInactivityTimerByCFrames: ld hl, wMobileInactivityTimerFrames ; timer? ld a, [hl] add c cp 60 jr c, .seconds xor a .seconds ld [hld], a ret c ld a, [hl] inc a cp 60 jr c, .minutes xor a .minutes ld [hld], a ret c inc [hl] ret Function100665: call UpdateTime ld hl, wcd36 ldh a, [hHours] ld [hli], a ldh a, [hMinutes] ld [hli], a ldh a, [hSeconds] ld [hl], a ret Function100675: ld hl, wcd2a bit 2, [hl] set 2, [hl] ret nz call Function1006d3 ret Function100681: push hl ld hl, wcd2a bit 2, [hl] ld hl, wcd2a set 2, [hl] pop hl jr nz, .asm_100694 push hl call Function1006d3 pop hl .asm_100694 ld de, wcd32 Function100697: ld a, [de] and a jr nz, .asm_1006bb inc de push de call .asm_1006b4 ld de, String1006c2 call PlaceString ld h, b ld l, c pop de inc de call .asm_1006b4 ld de, String1006c6 call PlaceString ret .asm_1006b4 lb bc, PRINTNUM_LEADINGZEROS | 1, 2 call PrintNum ret .asm_1006bb ld de, String1006ca call PlaceString ret String1006c2: db "ใตใ‚“ใ€€@" String1006c6: db "ใณใ‚‡ใ†@" String1006ca: db "๏ผ‘ใ˜ใ‹ใ‚“ใ„ใ˜ใ‚‡ใ†@" Function1006d3: call UpdateTime ld de, wcd34 ld hl, wcd38 Function1006dc: ld a, [hld] ld c, a ldh a, [hSeconds] sub c jr nc, .asm_1006e5 add $3c .asm_1006e5 ld [de], a dec de ld a, [hld] ld c, a ldh a, [hMinutes] sbc c jr nc, .asm_1006f0 add $3c .asm_1006f0 ld [de], a dec de ld a, [hl] ld c, a ldh a, [hHours] sbc c jr nc, .asm_1006fb add $18 .asm_1006fb ld [de], a ret Function1006fd: ld a, $04 ld hl, $a800 call GetSRAMBank xor a ld [hli], a ld [hli], a ld [hli], a call CloseSRAM ret Function10070d: ld a, $04 ld hl, $a800 call GetSRAMBank xor a ld [hli], a ld a, $0a ld [hli], a xor a ld [hli], a call CloseSRAM ret Function100720: xor a ld [wcd6a], a call UpdateTime ldh a, [hHours] ld [wcd72], a ldh a, [hMinutes] ld [wcd73], a ldh a, [hSeconds] ld [wcd74], a ld a, $04 ld hl, $a800 call GetSRAMBank ld a, [hli] ld [wcd6c], a ld a, [hli] ld [wcd6d], a ld a, [hli] ld [wcd6e], a call CloseSRAM ld a, [wcd6d] ld [wcd6b], a ret Function100754: call UpdateTime ldh a, [hHours] ld [wcd72], a ldh a, [hMinutes] ld [wcd73], a ldh a, [hSeconds] ld [wcd74], a ld a, [wcd6d] ld [wcd6b], a ld hl, wcd2a res 6, [hl] ret Function100772: push de ld hl, wcd6c ld a, [de] cp [hl] jr c, .asm_10079a jr nz, .asm_10078c inc hl inc de ld a, [de] cp [hl] jr c, .asm_10079a jr nz, .asm_10078c inc hl inc de ld a, [de] cp [hl] jr c, .asm_10079a jr z, .asm_10079a .asm_10078c pop hl ld a, [hli] ld [wcd6c], a ld a, [hli] ld [wcd6d], a ld a, [hli] ld [wcd6e], a ret .asm_10079a pop de ret Function10079c: ld a, [wcd21] cp $01 jr nz, .dont_quit ld hl, wcd2a bit 5, [hl] jr nz, .dont_quit ld hl, wcd2a bit 6, [hl] jr nz, .dont_quit ld a, [wcd6a] add c cp 60 jr nc, .overflow ld [wcd6a], a and a ret .overflow sub 60 ld [wcd6a], a ld d, b push de call Function1007f6 pop de jr c, .quit ld a, c and a jr nz, .quit ld a, b cp 10 jr nc, .quit ld a, d and a ret z ld a, [wcd6b] cp b ret z ld a, b ld [wcd6b], a call Function1008e0 and a ret .quit call Function1008e0 ld hl, wcd2a set 4, [hl] ld a, $fc ld [wcd2b], a scf ret .dont_quit and a ret Function1007f6: call UpdateTime ld hl, wcd74 ld de, wcd71 call Function1006dc ld a, $04 call GetSRAMBank ld hl, $a802 call Function100826 call CloseSRAM ld hl, wcd6e call Function100826 ldh a, [hHours] ld [wcd72], a ldh a, [hMinutes] ld [wcd73], a ldh a, [hSeconds] ld [wcd74], a ret Function100826: ld a, [wcd71] add [hl] sub $3c jr nc, .asm_100830 add $3c .asm_100830 ld [hld], a ccf ld a, [wBGMapBufferPtrs] adc [hl] sub $3c jr nc, .asm_10083c add $3c .asm_10083c ld [hld], a ld b, a ccf ld a, [wcd6f] adc [hl] ld [hl], a ld c, a ret Function100846: ld hl, wcd2a bit 5, [hl] jr nz, .asm_10087c ld a, [wcd6e] ld c, a ld a, 0 sub c jr nc, .asm_100858 add $3c .asm_100858 ld [wStringBuffer2 + 2], a ld a, [wcd6d] ld c, a ld a, $0a sbc c ld [wStringBuffer2 + 1], a xor a ld [wStringBuffer2], a ld de, String_10088e hlcoord 1, 14 call PlaceString ld de, wStringBuffer2 hlcoord 4, 16 call Function100697 ret .asm_10087c ld de, String_10088e hlcoord 1, 14 call PlaceString ld h, b ld l, c ld de, String_10089f call PlaceString ret String_10088e: db "ใƒขใƒใ‚คใƒซใŸใ„ใ›ใ‚“ใ€€ใงใใ‚‹" next "ใ˜ใ‹ใ‚“@" String_10089f: db "ใ€€ใ‚€ใ›ใ„ใ’ใ‚“@" Function1008a6: ld a, $04 ld hl, $a800 call GetSRAMBank ld a, [hli] ld [wStringBuffer2], a ld a, [hli] ld [wStringBuffer2 + 1], a ld a, [hli] ld [wStringBuffer2 + 2], a call CloseSRAM ld a, [wStringBuffer2 + 2] ld b, a ld a, 0 sub b jr nc, .asm_1008c8 add $3c .asm_1008c8 ld b, a ld a, [wStringBuffer2 + 1] ld c, a ld a, $0a sbc c ld c, a jr c, .asm_1008da ld a, [wStringBuffer2] and a jr nz, .asm_1008da ret .asm_1008da call Function10070d ld c, 0 ret Function1008e0: ldh a, [hBGMapMode] ld b, a ldh a, [hVBlank] ld c, a push bc xor a ldh [hBGMapMode], a ld a, $03 ldh [hVBlank], a call Function100970 call Function100902 call Function100989 call DelayFrame pop bc ld a, c ldh [hVBlank], a ld a, b ldh [hBGMapMode], a ret Function100902: hlcoord 3, 10 ld b, $01 ld c, $0b call Textbox ld a, [wcd6d] ld c, a ld a, $0a sub c ld [wStringBuffer2], a jr z, .asm_10093f ld de, .string_100966 hlcoord 4, 11 call PlaceString hlcoord 8, 11 lb bc, 1, 2 ld de, wStringBuffer2 call PrintNum ld de, SFX_TWO_PC_BEEPS call PlaySFX farcall ReloadMapPart ld c, $3c call DelayFrames ret .asm_10093f ld de, .string_10095a hlcoord 4, 11 call PlaceString ld de, SFX_4_NOTE_DITTY call PlaySFX farcall ReloadMapPart ld c, 120 call DelayFrames ret .string_10095a db "ใŸใ„ใ›ใ‚“ใ€€ใ—ใ‚…ใ†ใ‚Šใ‚‡ใ†@" .string_100966 db "ใฎใ“ใ‚Šใ€€ใ€€ใ€€ใตใ‚“๏ผ@" Function100970: hlcoord 0, 0 ld de, w3_dc00 call Function1009a5 hlcoord 0, 0, wAttrMap ld de, w3_dd68 call Function1009a5 call Function1009d2 call Function1009ae ret Function100989: ld hl, w3_dc00 decoord 0, 0 call Function1009a5 call Function1009ae farcall ReloadMapPart ld hl, w3_dd68 decoord 0, 0, wAttrMap call Function1009a5 ret Function1009a5: ld bc, SCREEN_WIDTH * SCREEN_HEIGHT ld a, $03 call FarCopyWRAM ret Function1009ae: ldh a, [rSVBK] push af ld a, $03 ldh [rSVBK], a ld hl, w3_d800 decoord 0, 0, wAttrMap ld c, SCREEN_WIDTH ld b, SCREEN_HEIGHT .loop_row push bc .loop_col ld a, [hli] ld [de], a inc de dec c jr nz, .loop_col ld bc, BG_MAP_WIDTH - SCREEN_WIDTH add hl, bc pop bc dec b jr nz, .loop_row pop af ldh [rSVBK], a ret Function1009d2: ldh a, [rSVBK] push af ld a, $03 ldh [rSVBK], a ldh a, [rVBK] push af ld a, $01 ldh [rVBK], a ld hl, w3_d800 debgcoord 0, 0 lb bc, $03, $24 call Get2bpp pop af ldh [rVBK], a pop af ldh [rSVBK], a ret Function1009f3: ldh a, [hJoyDown] and SELECT + A_BUTTON cp SELECT + A_BUTTON jr nz, .select_a ld hl, wcd2a set 4, [hl] ld a, $f8 ld [wcd2b], a scf ret .select_a xor a ret _LinkBattleSendReceiveAction: call .StageForSend ld [wd431], a farcall PlaceWaitingText ld a, [wLinkMode] cp LINK_MOBILE jr nz, .not_mobile call .MobileBattle_SendReceiveAction call Function100da5 farcall FinishBattleAnim jr .done .not_mobile call .LinkBattle_SendReceiveAction .done ret .StageForSend: ld a, [wBattlePlayerAction] and a ; BATTLEPLAYERACTION_USEMOVE? jr nz, .switch ld a, [wCurPlayerMove] call GetMoveIndexFromID ld b, BATTLEACTION_STRUGGLE ld a, h if HIGH(STRUGGLE) cp HIGH(STRUGGLE) else and a endc jr nz, .not_struggle ld a, l cp LOW(STRUGGLE) jr z, .struggle .not_struggle ld b, BATTLEACTION_SKIPTURN cp $ff jr z, .struggle ld a, [wCurMoveNum] jr .use_move .switch ld a, [wCurPartyMon] add BATTLEACTION_SWITCH1 jr .use_move .struggle ld a, b .use_move and $0f ret .LinkBattle_SendReceiveAction: ld a, [wd431] ld [wPlayerLinkAction], a ld a, $ff ld [wOtherPlayerLinkAction], a .waiting call LinkTransfer call DelayFrame ld a, [wOtherPlayerLinkAction] inc a jr z, .waiting ld b, 10 .receive call DelayFrame call LinkTransfer dec b jr nz, .receive ld b, 10 .acknowledge call DelayFrame call LinkDataReceived dec b jr nz, .acknowledge ld a, [wOtherPlayerLinkAction] ld [wBattleAction], a ret .MobileBattle_SendReceiveAction: call Function100acf call StartMobileInactivityTimer ld a, 0 ld [wcd27], a .asm_100a92 call DelayFrame call GetJoypad farcall Function100382 ld c, $01 ld b, $03 push bc call AdvanceMobileInactivityTimerAndCheckExpired pop bc jr c, .asm_100ac7 ld b, $01 call Function10079c jr c, .asm_100ac7 call Function1009f3 jr c, .asm_100ac7 ld a, [wcd2b] and a jr nz, .asm_100ac7 ld a, [wcd27] bit 7, a jr z, .asm_100a92 call Function100ae7 jr .asm_100ace .asm_100ac7 ld a, $0f ld [wd430], a jr .asm_100ace .asm_100ace ret Function100acf: ld de, Unknown_100b0a ld hl, wccb5 ld a, [wd431] ld [hli], a ld c, $01 .asm_100adb ld a, [de] inc de ld [hli], a inc c and a jr nz, .asm_100adb ld a, c ld [wccb4], a ret Function100ae7: ld de, Unknown_100b0a ld hl, wcc62 .asm_100aed ld a, [de] inc de and a jr z, .asm_100af8 cp [hl] jr nz, .asm_100aff inc hl jr .asm_100aed .asm_100af8 ld a, [wcc61] ld [wd430], a ret .asm_100aff ld a, $0f ld [wd430], a ld a, $f1 ld [wcd2b], a ret SECTION "tetsuji", ROMX pushc setcharmap ascii Unknown_100b0a: db "tetsuji", 0 popc SECTION "bank40_2", ROMX Function100b12: call Function100dd8 ret c ld hl, BattleMenuHeader ld a, BANK(BattleMenuHeader) ld de, LoadMenuHeader call FarCall_de ld a, BANK(BattleMenuHeader) ld [wMenuData_2DMenuItemStringsBank], a ld a, [wBattleMenuCursorBuffer] ld [wMenuCursorBuffer], a call Function100e72 call Function100b45 farcall InitPartyMenuBGPal7 call Function100ed4 ld a, [wMenuCursorBuffer] ld [wBattleMenuCursorBuffer], a call ExitMenu ret Function100b45: call Function100b7a .loop call Mobile_SetOverworldDelay farcall MobileMenuJoypad push bc farcall HDMATransferTileMapToWRAMBank3 call Function100e2d pop bc jr c, .asm_100b6b ld a, [wMenuJoypadFilter] and c jr z, .loop farcall Mobile_GetMenuSelection ret .asm_100b6b ld a, [w2DMenuNumCols] ld c, a ld a, [w2DMenuNumRows] call SimpleMultiply ld [wMenuCursorBuffer], a and a ret Function100b7a: ld hl, CopyMenuData ld a, [wMenuData_2DMenuItemStringsBank] rst FarCall farcall Draw2DMenu farcall MobileTextBorder call UpdateSprites call ApplyTilemap farcall Init2DMenuCursorPosition ld hl, w2DMenuFlags1 set 7, [hl] ret MobileMoveSelectionScreen: xor a ld [wMoveSwapBuffer], a farcall CheckPlayerHasUsableMoves ret z call Function100dd8 jp c, xor_a_dec_a call Function100e72 call .GetMoveSelection push af farcall InitPartyMenuBGPal7 call Function100ed4 pop af ret .GetMoveSelection: xor a ldh [hBGMapMode], a call Function100c74 call Function100c98 .master_loop farcall MoveInfoBox .loop call Mobile_SetOverworldDelay farcall MobileMenuJoypad push bc farcall HDMATransferTileMapToWRAMBank3 call Function100e2d pop bc jr c, .b_button ld a, [wMenuJoypadFilter] and c bit D_UP_F, a jp nz, .d_up bit D_DOWN_F, a jp nz, .d_down bit A_BUTTON_F, a jr nz, .a_button bit B_BUTTON_F, a jr nz, .b_button jr .loop .d_up ld a, [wMenuCursorY] and a jp nz, .master_loop ld a, [wNumMoves] inc a ld [wMenuCursorY], a jp .master_loop .d_down ld a, [wMenuCursorY] ld b, a ld a, [wNumMoves] inc a inc a cp b jp nz, .master_loop ld a, $01 ld [wMenuCursorY], a jp .master_loop .b_button ld a, [wMenuCursorY] dec a ld [wCurMoveNum], a ld a, $01 and a ret .a_button ld a, [wMenuCursorY] dec a ld [wCurMoveNum], a ld a, [wMenuCursorY] dec a ld c, a ld b, 0 ld hl, wBattleMonPP add hl, bc ld a, [hl] and $3f jr z, .no_pp_left ld a, [wPlayerDisableCount] swap a and $0f dec a cp c jr z, .move_disabled ld a, [wMenuCursorY] dec a ld c, a ld b, 0 ld hl, wBattleMonMoves add hl, bc ld a, [hl] ld [wCurPlayerMove], a xor a ret .move_disabled ld hl, BattleText_TheMoveIsDisabled jr .print_text .no_pp_left ld hl, BattleText_TheresNoPPLeftForThisMove .print_text call StdBattleTextbox call Call_LoadTempTileMapToTileMap jp .GetMoveSelection Function100c74: hlcoord 0, 8 ld b, 8 ld c, 8 call Textbox ld hl, wBattleMonMoves ld de, wListMoves_MoveIndicesBuffer ld bc, NUM_MOVES call CopyBytes ld a, SCREEN_WIDTH * 2 ld [wBuffer1], a hlcoord 2, 10 predef ListMoves ret Function100c98: ld de, .attrs call SetMenuAttributes ld a, [wNumMoves] inc a ld [w2DMenuNumRows], a ld a, [wCurMoveNum] inc a ld [wMenuCursorY], a ret .attrs db 10, 1 db 255, 1 db $a0, $00 dn 2, 0 db D_UP | D_DOWN | A_BUTTON | B_BUTTON Mobile_PartyMenuSelect: call Function100dd8 ret c ld hl, w2DMenuFlags1 set 7, [hl] res 6, [hl] .loop call Mobile_SetOverworldDelay farcall MobileMenuJoypad push bc farcall PlaySpriteAnimations farcall HDMATransferTileMapToWRAMBank3 call MobileComms_CheckInactivityTimer pop bc jr c, .done ld a, [wMenuJoypadFilter] and c jr z, .loop call PlaceHollowCursor ld a, [wPartyCount] inc a ld b, a ld a, [wMenuCursorY] cp b jr z, .done ld [wPartyMenuCursor], a ldh a, [hJoyLast] ld b, a bit 1, b jr nz, .done ld a, [wMenuCursorY] dec a ld [wCurPartyMon], a ld c, a ld b, 0 ld hl, wPartySpecies add hl, bc ld a, [hl] ld [wCurPartySpecies], a ld de, SFX_READ_TEXT_2 call PlaySFX call WaitSFX and a ret .done ld de, SFX_READ_TEXT_2 call PlaySFX call WaitSFX scf ret MobileBattleMonMenu: call Function100dd8 ret c call Function100d67 ld hl, w2DMenuFlags1 set 7, [hl] res 6, [hl] .asm_100d30 call Mobile_SetOverworldDelay farcall MobileMenuJoypad push bc farcall PlaySpriteAnimations farcall HDMATransferTileMapToWRAMBank3 call MobileComms_CheckInactivityTimer pop bc jr c, .asm_100d54 ld a, [wMenuJoypadFilter] and c jr nz, .asm_100d56 jr .asm_100d30 .asm_100d54 scf ret .asm_100d56 push af ld de, SFX_READ_TEXT_2 call PlaySFX pop af bit 1, a jr z, .asm_100d65 ret z scf ret .asm_100d65 and a ret Function100d67: ld hl, .MenuHeader call CopyMenuHeader xor a ldh [hBGMapMode], a call MenuBox call UpdateSprites call PlaceVerticalMenuItems call WaitBGMap call CopyMenuData call InitVerticalMenuCursor ld hl, w2DMenuFlags1 set 6, [hl] ret .MenuHeader: db 0 ; flags menu_coords 11, 11, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1 dw .MenuData db 1 ; default option .MenuData: db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 3 db "ใ„ใ‚Œใ‹ใˆใ‚‹@" ; TRADE db "ใคใ‚ˆใ•ใ‚’ใฟใ‚‹@" ; STATS db "ใ‚ญใƒฃใƒณใ‚ปใƒซ@" ; CANCEL Function100da5: ld hl, wcd2a res 3, [hl] ld hl, wcd29 res 0, [hl] ret Function100db0: ld hl, wcd2a bit 3, [hl] jr nz, .asm_100dbe ld hl, wcd2a set 3, [hl] scf ret .asm_100dbe xor a ret Function100dc0: ld a, [wLinkMode] cp LINK_MOBILE jr nz, .mobile ld hl, wcd2a bit 3, [hl] jr z, .mobile scf ret .mobile xor a ret Mobile_SetOverworldDelay: ld a, 30 ld [wOverworldDelay], a ret Function100dd8: ld c, $01 ld b, $03 farcall AdvanceMobileInactivityTimerAndCheckExpired jr c, .asm_100dfb ld c, $3c ld b, $01 call Function10079c jr c, .asm_100dfb farcall Function10032e ld a, [wcd2b] and a jr nz, .asm_100dfb xor a ret .asm_100dfb scf ret MobileComms_CheckInactivityTimer: ld a, [wOverworldDelay] ld c, a ld a, 30 sub c ld c, a ld b, 3 push bc farcall AdvanceMobileInactivityTimerAndCheckExpired ; useless to farcall pop bc jr c, .quit ld b, 1 call Function10079c jr c, .quit call Function1009f3 jr c, .quit farcall Function10032e ; useless to farcall ld a, [wcd2b] and a jr nz, .quit xor a ret .quit scf ret Function100e2d: ld a, [wOverworldDelay] ld c, a ld a, 30 sub c ld c, a ld b, 3 push bc farcall AdvanceMobileInactivityTimerAndCheckExpired pop bc jr c, .asm_100e61 ld b, 1 call Function10079c jr c, .asm_100e61 call Function1009f3 jr c, .asm_100e61 farcall Function10032e ld a, [wcd2b] and a jr nz, .asm_100e61 call Function100e63 call Function100e84 xor a ret .asm_100e61 scf ret Function100e63: ld a, e cp $02 ret nz call Function100db0 ret nc ld de, SFX_ELEVATOR_END call PlaySFX ret Function100e72: xor a ld hl, wcd29 bit 0, [hl] jr z, .asm_100e7c ld a, $0a .asm_100e7c ld [wcd67], a xor a ld [wcd68], a ret Function100e84: ld a, [wcd67] ld hl, Jumptable_100e8c rst JumpTable ret Jumptable_100e8c: dw Function100ea2 dw Function100eae dw Function100eb4 dw Function100eae dw Function100eb4 dw Function100eae dw Function100eb4 dw Function100eae dw Function100eb4 dw Function100eae dw Function100ec4 Function100ea2: call Function100dc0 ret nc ld hl, wcd29 set 0, [hl] call Function100ec5 Function100eae: scf call Function100eca jr asm_100eb8 Function100eb4: and a call Function100eca asm_100eb8: ld hl, wcd68 inc [hl] ld a, [hl] cp $02 ret c ld [hl], 0 jr Function100ec5 Function100ec4: ret Function100ec5: ld hl, wcd67 inc [hl] ret Function100eca: farcall Mobile_InitPartyMenuBGPal7 call Function100ed4 ret Function100ed4: farcall ApplyPals ld a, $01 ldh [hCGBPalUpdate], a ret Function100edf: ld hl, Unknown_100fc0 ld c, 1 jr asm_100f02 Function100ee6: ld hl, Unknown_100fc0 ld c, 2 jr asm_100f02 Function100eed: ld hl, Unknown_100feb ld c, 1 jr asm_100f02 Function100ef4: ld hl, Unknown_100ff3 ld c, 1 jr asm_100f02 Function100efb: ld hl, Unknown_10102c ld c, 1 jr asm_100f02 asm_100f02: ld a, c ld [wStringBuffer2], a ; someting that was previously stored in de gets backed up to here ld a, e ld [wStringBuffer2 + 1], a ld a, d ld [wStringBuffer2 + 2], a ; empty this xor a ld [wStringBuffer2 + 4], a ld [wStringBuffer2 + 5], a .loop ld a, [hl] cp $ff jr z, .done ld [wStringBuffer2 + 3], a ; bank push hl inc hl ; addr 1 ld a, [hli] ld e, a ld a, [hli] ld d, a ; size ld a, [hli] ld c, a ld a, [hli] ld b, a ; addr 2 ld a, [hli] ld h, [hl] ld l, a call Function100f3d ; next line pop hl ld de, 7 add hl, de jr .loop .done ; recover the values into bc ld a, [wStringBuffer2 + 4] ld c, a ld a, [wStringBuffer2 + 5] ld b, a ret Function100f3d: ; parameter ld a, [wStringBuffer2] cp $02 jr z, .two cp $01 jr z, .one cp $03 jr z, .three ret .three ; what was once in de gets copied to hl, ; modified by Function100f8d, and put back ; into this backup ld a, [wStringBuffer2 + 1] ld l, a ld a, [wStringBuffer2 + 2] ld h, a call Function100f8d ld a, l ld [wStringBuffer2 + 1], a ld a, h ld [wStringBuffer2 + 2], a ret .two ; hl gets backed up to de, then ; do the same as in .three ld d, h ld e, l ld a, [wStringBuffer2 + 1] ld l, a ld a, [wStringBuffer2 + 2] ld h, a call Function100f8d ld a, l ld [wStringBuffer2 + 1], a ld a, h ld [wStringBuffer2 + 2], a ret .one ; de gets copied to hl, then ; load the backup into de, ; finally run Function100f8d ; and store the de result ld h, d ld l, e ld a, [wStringBuffer2 + 1] ld e, a ld a, [wStringBuffer2 + 2] ld d, a call Function100f8d ld a, e ld [wStringBuffer2 + 1], a ld a, d ld [wStringBuffer2 + 2], a ret Function100f8d: push hl ld a, [wStringBuffer2 + 4] ld l, a ld a, [wStringBuffer2 + 5] ld h, a add hl, bc ld a, l ld [wStringBuffer2 + 4], a ld a, h ld [wStringBuffer2 + 5], a pop hl ld a, [wStringBuffer2 + 3] bit 7, a res 7, a jr z, .sram and a jr nz, .far_wram call CopyBytes ret .far_wram and $7f call FarCopyWRAM ret .sram call GetSRAMBank call CopyBytes call CloseSRAM ret Unknown_100fc0: ; first byte: ; Bit 7 set: Not SRAM ; Lower 7 bits: Bank ; Address, size (dw), address dbwww $80, wPlayerName, NAME_LENGTH, wOTPlayerName dbwww $80, wPartyCount, 1 + PARTY_LENGTH + 1, wOTPartyCount dbwww $80, wPlayerID, 2, wOTPlayerID dbwww $80, wPartyMons, PARTYMON_STRUCT_LENGTH * PARTY_LENGTH, wOTPartyMons dbwww $80, wPartyMonOT, NAME_LENGTH * PARTY_LENGTH, wOTPartyMonOT dbwww $80, wPartyMonNicknames, MON_NAME_LENGTH * PARTY_LENGTH, wOTPartyMonNicknames db -1 Unknown_100feb: dbwww $00, sPartyMail, MAIL_STRUCT_LENGTH * PARTY_LENGTH, NULL db -1 Unknown_100ff3: dbwww $80, wdc41, 1, NULL dbwww $80, wPlayerName, NAME_LENGTH, NULL dbwww $80, wPlayerName, NAME_LENGTH, NULL dbwww $80, wPlayerID, 2, NULL dbwww $80, wSecretID, 2, NULL dbwww $80, wPlayerGender, 1, NULL dbwww $04, $a603, 8, NULL dbwww $04, $a007, PARTYMON_STRUCT_LENGTH, NULL db -1 Unknown_10102c: dbwww $80, wOTPlayerName, NAME_LENGTH, NULL dbwww $80, wOTPlayerID, 2, NULL dbwww $80, wOTPartyMonNicknames, MON_NAME_LENGTH * PARTY_LENGTH, NULL dbwww $80, wOTPartyMonOT, NAME_LENGTH * PARTY_LENGTH, NULL dbwww $80, wOTPartyMons, PARTYMON_STRUCT_LENGTH * PARTY_LENGTH, NULL db -1 Function101050: call Function10107d ld a, [wOTPartyCount] rept 2 ; ??? ld hl, wc608 endr ld bc, wc7bb - wc608 call Function1010de ld hl, wc7bb ld [hl], e inc hl ld [hl], d ld a, $07 call GetSRAMBank ld hl, wc608 ld de, $a001 ld bc, wc7bd - wc608 call CopyBytes call CloseSRAM ret Function10107d: xor a ld hl, wc608 ld bc, wc7bd - wc608 call ByteFill ld hl, wOTPlayerName ld de, wc608 ld bc, NAME_LENGTH call CopyBytes ld hl, wd271 ld a, [hli] ld [wc608 + 11], a ld a, [hl] ld [wc608 + 12], a ld hl, wOTPartyMonNicknames ld de, wc608 + 13 ld bc, NAME_LENGTH call .CopyAllFromOT ld hl, wOTPartyMonOT ld de, wOTClassName + 1 ld bc, NAME_LENGTH call .CopyAllFromOT ld hl, wOTPartyMon1Species ld de, $c699 ld bc, PARTYMON_STRUCT_LENGTH call .CopyAllFromOT ld a, $50 ld [wc7b9], a ld a, $33 ld [wc7ba], a ret .CopyAllFromOT: push hl ld hl, 0 ld a, [wOTPartyCount] call AddNTimes ld b, h ld c, l pop hl call CopyBytes ret Function1010de: push hl push bc ld de, 0 .loop ld a, [hli] add e ld e, a ld a, d adc 0 ld d, a dec bc ld a, b or c jr nz, .loop pop bc pop hl ret LoadSelectedPartiesForColosseum: xor a ld hl, wStringBuffer2 ld bc, 9 call ByteFill ld hl, wPlayerMonSelection ld de, wPartyCount call .CopyThreeSpecies ld hl, wPlayerMonSelection ld de, wPartyMon1Species call .CopyPartyStruct ld hl, wPlayerMonSelection ld de, wPartyMonOT call .CopyName ld hl, wPlayerMonSelection ld de, wPartyMonNicknames call .CopyName ld hl, wOTMonSelection ld de, wOTPartyCount call .CopyThreeSpecies ld hl, wOTMonSelection ld de, wOTPartyMon1Species call .CopyPartyStruct ld hl, wOTMonSelection ld de, wOTPartyMonOT call .CopyName ld hl, wOTMonSelection ld de, wOTPartyMonNicknames call .CopyName ret .CopyThreeSpecies: ; Load the 3 choices to the buffer push de ld bc, wStringBuffer2 + NAME_LENGTH_JAPANESE xor a .party_loop push af call .GetNthSpecies ld [bc], a inc bc pop af inc a cp 3 jr nz, .party_loop pop de ; Copy the 3 choices to the party ld a, 3 ld [de], a inc de ld hl, wStringBuffer2 + NAME_LENGTH_JAPANESE ld bc, 3 call CopyBytes ld a, $ff ld [de], a ret .GetNthSpecies: ; Preserves hl and de ; Get the index of the Nth selection push hl add l ld l, a ld a, h adc 0 ld h, a ld a, [hl] pop hl ; Get the corresponding species push de inc de add e ld e, a ld a, d adc 0 ld d, a ld a, [de] pop de ret .CopyPartyStruct: ld bc, PARTYMON_STRUCT_LENGTH jr .ContinueCopy .CopyName: ld bc, NAME_LENGTH .ContinueCopy: ; Copy, via wc608... ld a, LOW(wc608) ld [wStringBuffer2], a ld a, HIGH(wc608) ld [wStringBuffer2 + 1], a ; ... bc bytes... ld a, c ld [wStringBuffer2 + 2], a ld a, b ld [wStringBuffer2 + 3], a ; ... to de... ld a, e ld [wStringBuffer2 + 4], a ld a, d ld [wStringBuffer2 + 5], a ; ... 3 times. ld a, 3 .big_copy_loop push af ld a, [hli] push hl push af call .GetDestinationAddress call .GetCopySize pop af call AddNTimes ld a, [wStringBuffer2] ld e, a ld a, [wStringBuffer2 + 1] ld d, a call CopyBytes ld a, e ld [wStringBuffer2], a ld a, d ld [wStringBuffer2 + 1], a pop hl pop af dec a jr nz, .big_copy_loop call .GetCopySize ld a, 3 ld hl, 0 call AddNTimes ld b, h ld c, l call .GetDestinationAddress ld d, h ld e, l ld hl, wc608 call CopyBytes ret .GetDestinationAddress: ld a, [wStringBuffer2 + 4] ld l, a ld a, [wStringBuffer2 + 5] ld h, a ret .GetCopySize: ld a, [wStringBuffer2 + 2] ld c, a ld a, [wStringBuffer2 + 3] ld b, a ret Function1011f1: ld a, $04 call GetSRAMBank ld a, [$a60c] ld [wdc41], a call CloseSRAM ld hl, wdc41 res 4, [hl] ld hl, wGameTimerPause bit GAMETIMERPAUSE_MOBILE_7_F, [hl] jr z, .skip ld hl, wdc41 set 4, [hl] .skip call Function10209c xor a ld [wdc5f], a ld [wdc60], a ld a, LINK_MOBILE ld [wLinkMode], a ret Function101220: xor a ld [wLinkMode], a ret Function101225: ld d, 1 ld e, BANK(Jumptable_101297) ld bc, Jumptable_101297 call Function100000 jr Function10123d Function101231: ld d, 2 ld e, BANK(Jumptable_101297) ld bc, Jumptable_101297 call Function100000 jr Function10123d Function10123d: xor a ld [wScriptVar], a ld a, c ld hl, Jumptable_101247 rst JumpTable ret Jumptable_101247: dw Function101251 dw Function10127d dw Function10127c dw Function10126c dw Function101265 Function101251: call UpdateSprites call RefreshScreen ld hl, UnknownText_0x1021f4 call Function1021e0 call Function1020ea ret c call Function102142 ret Function101265: ld hl, UnknownText_0x1021ef call Function1021e0 ret Function10126c: call UpdateSprites farcall Script_reloadmappart ld hl, UnknownText_0x1021f4 call Function1021e0 ret Function10127c: ret Function10127d: ret Function10127e: ld a, [wdc5f] and a jr z, .zero cp 1 ld c, $27 jr z, .load cp 2 ld c, $37 jr z, .load .zero ld c, 0 .load ld a, c ld [wMobileCommsJumptableIndex], a ret Jumptable_101297: dw Function101a97 ; 00 dw Function101ab4 ; 01 dw Function101475 ; 02 dw Function101b0f ; 03 dw Function101438 ; 04 dw Function101b2b ; 05 dw Function101b59 ; 06 dw Function101475 ; 07 dw Function101b70 ; 08 dw Function101438 ; 09 dw Function101b8f ; 0a dw Function101d7b ; 0b dw Function101d95 ; 0c dw Function101475 ; 0d dw Function101db2 ; 0e dw Function101e4f ; 0f dw Function101475 ; 10 dw Function101e64 ; 11 dw Function101e4f ; 12 dw Function101475 ; 13 dw Function101e64 ; 14 dw Function101d95 ; 15 dw Function101475 ; 16 dw Function101db2 ; 17 dw Function101dd0 ; 18 dw Function101de3 ; 19 dw Function101e39 ; 1a dw Function101e09 ; 1b dw Function101e4f ; 1c dw Function101475 ; 1d dw Function101e64 ; 1e dw Function101d95 ; 1f dw Function101475 ; 20 dw Function101db2 ; 21 dw Function101e09 ; 22 dw Function101e31 ; 23 dw Function101bc8 ; 24 dw Function101438 ; 25 dw Function101be5 ; 26 dw Function101ac6 ; 27 dw Function101ab4 ; 28 dw Function101475 ; 29 dw Function101c11 ; 2a dw Function1014f4 ; 2b dw Function101cc8 ; 2c dw Function1014e2 ; 2d dw Function1014e2 ; 2e dw Function101d10 ; 2f dw Function101d2a ; 30 dw Function101d2a ; 31 dw Function101507 ; 32 dw Function10156d ; 33 dw Function101557 ; 34 dw Function10158a ; 35 dw Function101c42 ; 36 dw Function101aed ; 37 dw Function101ab4 ; 38 dw Function101475 ; 39 dw Function101c2b ; 3a dw Function1014f4 ; 3b dw Function101cdf ; 3c dw Function1014e2 ; 3d dw Function1014e2 ; 3e dw Function101d1e ; 3f dw Function101d2a ; 40 dw Function101d2a ; 41 dw Function101507 ; 42 dw Function10156d ; 43 dw Function101544 ; 44 dw Function10158a ; 45 dw Function101c42 ; 46 dw Function101c50 ; 47 dw Function1014ce ; 48 dw Function101cf6 ; 49 dw Function101826 ; 4a dw Function1017e4 ; 4b dw Function1017f1 ; 4c dw Function1018a8 ; 4d dw Function1018d6 ; 4e dw Function1017e4 ; 4f dw Function1017f1 ; 50 dw Function1018e1 ; 51 dw Function1015df ; 52 dw Function10167d ; 53 dw Function10168a ; 54 dw Function10162a ; 55 dw Function1015be ; 56 dw Function10167d ; 57 dw Function10168a ; 58 dw Function10161f ; 59 dw Function10159d ; 5a dw Function10167d ; 5b dw Function10168a ; 5c dw Function101600 ; 5d dw Function101d03 ; 5e dw Function101d6b ; 5f dw Function10159d ; 60 dw Function1014ce ; 61 dw Function10168e ; 62 dw Function101600 ; 63 dw Function101913 ; 64 dw Function10194b ; 65 dw _SelectMonsForMobileBattle ; 66 dw Function1017e4 ; 67 dw Function1017f5 ; 68 dw _StartMobileBattle ; 69 dw Function101537 ; 6a dw Function101571 ; 6b dw Function101c92 ; 6c dw Function10152a ; 6d dw Function101571 ; 6e dw Function101a4f ; 6f dw Function101cbc ; 70 dw Function101c62 ; 71 dw Function101537 ; 72 dw Function101571 ; 73 dw Function101c92 ; 74 dw Function10152a ; 75 dw Function101571 ; 76 dw Function101ca0 ; 77 dw Function101475 ; 78 dw Function101cbc ; 79 Function10138b: farcall Function8adcc ld c, 0 jr c, .asm_101396 inc c .asm_101396 sla c ld a, [wcd2f] and a jr z, .asm_10139f inc c .asm_10139f sla c ld a, [wcd21] cp $01 jr z, .asm_1013a9 inc c .asm_1013a9 ret Function1013aa: call ClearBGPalettes call ExitMenu call ReloadTilesetAndPalettes farcall Function106464 call UpdateSprites call FinishExitMenu ret Function1013c0: farcall BlankScreen farcall Stubbed_Function106462 farcall Function106464 call FinishExitMenu ret Function1013d6: farcall HDMATransferAttrMapAndTileMapToWRAMBank3 ret Function1013dd: call CGBOnly_CopyTilemapAtOnce ret Unreferenced_Function1013e1: push de inc de ld b, a ld c, 0 .asm_1013e6 inc c ld a, [hli] ld [de], a inc de and a jr z, .asm_1013f1 dec b jr nz, .asm_1013e6 scf .asm_1013f1 pop de ld a, c ld [de], a ret Function1013f5: ld a, [hli] ld [de], a inc de ld c, a .asm_1013f9 ld a, [hli] ld [de], a inc de dec c jr nz, .asm_1013f9 ret Unreferenced_Function101400: ld a, [de] inc de cp [hl] jr nz, asm_101416 inc hl Function101406: ld c, a ld b, 0 .asm_101409 ld a, [de] inc de cp [hl] jr nz, asm_101416 inc hl dec bc ld a, b or c jr nz, .asm_101409 and a ret asm_101416: scf ret Function101418: call GetJoypad ldh a, [hJoyDown] and SELECT + A_BUTTON cp SELECT + A_BUTTON jr z, .asm_101425 xor a ret .asm_101425 ld a, $f7 ld [wcd2b], a scf ret Function10142c: ld a, $01 ld [wc305], a farcall Function115e18 ret Function101438: ld hl, wcd29 set 6, [hl] ld a, [wcd26] ld hl, Jumptable_101457 rst JumpTable ld a, [wcd26] bit 7, a ret z ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Jumptable_101457: dw Function10145b dw Function101467 Function10145b: ld a, $3c ld [wcd42], a ld a, [wcd26] inc a ld [wcd26], a Function101467: ld hl, wcd42 dec [hl] ret nz ld a, [wcd26] set 7, a ld [wcd26], a ret Function101475: ld hl, wcd29 set 6, [hl] ld a, [wcd26] ld hl, Jumptable_101494 rst JumpTable ld a, [wcd26] bit 7, a ret z ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Jumptable_101494: dw Function10149a dw Function1014a6 dw Function1014b7 Function10149a: ld a, $28 ld [wcd42], a ld a, [wcd26] inc a ld [wcd26], a Function1014a6: ld hl, wcd42 dec [hl] ret nz ld a, $50 ld [wcd42], a ld a, [wcd26] inc a ld [wcd26], a Function1014b7: call GetJoypad ldh a, [hJoyPressed] and $03 jr nz, .asm_1014c5 ld hl, wcd42 dec [hl] ret nz .asm_1014c5 ld a, [wcd26] set 7, a ld [wcd26], a ret Function1014ce: farcall Function100720 farcall StartMobileInactivityTimer ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function1014e2: ld hl, wcd29 set 6, [hl] ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function1014f4: farcall EnableMobile ld hl, wcd29 set 6, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101507: ld de, wcd30 ld hl, $40 ld bc, $40 ld a, $02 call Function3e32 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Unreferenced_Function10151d: ld a, $34 call Function3e32 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function10152a: ld a, $36 call Function3e32 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101537: ld a, $0a call Function3e32 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101544: farcall StartMobileInactivityTimer ld a, $12 call Function3e32 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101557: farcall StartMobileInactivityTimer ld hl, wcd53 ld a, $08 call Function3e32 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function10156d: call Function101418 ret c Function101571: farcall Function10032e ret c ret z ld a, e cp $01 jr z, .asm_101582 ld [wcd2b], a ret .asm_101582 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function10158a: farcall IncrementMobileInactivityTimerBy1Frame ld a, [wMobileInactivityTimerMinutes] cp $0a jr c, Function10156d ld a, $fb ld [wcd2b], a ret Function10159d: ld de, wc608 farcall Function100edf ld de, wc608 ld a, $05 ld hl, w5_d800 call Function10174c ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function1015be: ld de, wc608 farcall Function100eed ld de, wc608 ld a, $05 ld hl, w5_d800 call Function10174c ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function1015df: ld de, wc608 farcall Function100ef4 ld de, wc608 ld a, $05 ld hl, w5_d800 call Function10174c ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101600: ld hl, w5_d800 ld de, wc608 ld bc, $1e0 ld a, $05 call FarCopyWRAM ld de, wc608 farcall Function100ee6 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function10161f: call Function101649 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function10162a: call Function101663 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101635: ld de, wc608 ld bc, $1e0 call FarCopyWRAM ret Function10163f: ld hl, wc608 ld bc, $1e0 call FarCopyWRAM ret Function101649: ld a, $05 ld hl, w5_d800 call Function101635 ld a, $05 ld de, w5_da00 call Function10163f ret Function10165a: ld a, $05 ld hl, w5_da00 call Function101635 ret Function101663: ld a, $05 ld hl, w5_d800 call Function101635 ld a, $05 ld de, w5_dc00 call Function10163f ret Unreferenced_Function101674: ld a, $05 ld hl, w5_dc00 call Function101635 ret Function10167d: ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function10168a: call Function101418 ret c Function10168e: ld b, 0 ld c, $01 farcall Function10079c ret c ld c, $01 ld b, $03 farcall AdvanceMobileInactivityTimerAndCheckExpired ret c ld a, [wcd26] ld hl, Jumptable_1016c3 rst JumpTable ld hl, wcd29 set 6, [hl] ld a, [wcd26] bit 7, a ret z ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Jumptable_1016c3: dw Function1016cf dw Function1016de dw Function1016f8 dw Function101705 dw Function101719 dw Function101724 Function1016cf: ld hl, wcd3a inc [hl] call Function10176f ld a, [wcd26] inc a ld [wcd26], a ret Function1016de: call Function10177b jr nc, .asm_1016eb ld a, [wcd26] inc a ld [wcd26], a ret .asm_1016eb ld a, $ff ld [wcd39], a ld a, [wcd26] inc a ld [wcd26], a ret Function1016f8: ld a, 0 ld [wcd27], a ld a, [wcd26] inc a ld [wcd26], a ret Function101705: farcall Function100382 ld a, [wcd27] bit 7, a ret z ld a, [wcd26] inc a ld [wcd26], a ret Function101719: call Function1017c7 ld a, [wcd26] inc a ld [wcd26], a ret Function101724: ld a, [wcd39] cp $ff jr z, .asm_101731 ld a, 0 ld [wcd26], a ret .asm_101731 ld a, [wcd26] set 7, a ld [wcd26], a ret Unknown_10173a: db $50 Function10173b: push bc push af ld a, [hli] ld h, [hl] ld l, a ld a, [Unknown_10173a] ld c, a ld b, 0 pop af call AddNTimes pop bc ret Function10174c: ld [wcd3d], a ld a, l ld [wcd3e], a ld a, h ld [wcd3f], a ld a, e ld [wcd3b], a ld a, d ld [wcd3c], a ld a, c ld [wcd40], a ld a, b ld [wcd41], a xor a ld [wcd39], a ld [wcd3a], a ret Function10176f: ld hl, wccb4 ld bc, $54 ld a, $11 call ByteFill ret Function10177b: ld a, [Unknown_10173a] ld c, a ld b, 0 ld a, [wcd3a] ld hl, 0 call AddNTimes ld e, l ld d, h ld hl, wcd40 ld a, [hli] ld h, [hl] ld l, a ld a, l sub e ld l, a ld a, h sbc d ld h, a jr c, .asm_1017a0 add hl, bc call Function1017b0 scf ret .asm_1017a0 ld a, $ff ld [wcd39], a add hl, bc ld a, h or l ret z ld c, l ld b, h call Function1017b0 xor a ret Function1017b0: ld a, c ld [wccb4], a push bc ld a, [wcd3a] dec a ld hl, wcd3b call Function10173b pop bc ld de, wccb5 call CopyBytes ret Function1017c7: ld a, [wcc60] ld c, a ld b, 0 ld a, [wcd3a] dec a ld hl, wcd3e call Function10173b ld e, l ld d, h ld hl, wcc61 ld a, [wcd3d] call FarCopyWRAM and a ret Function1017e4: ld a, 0 ld [wcd27], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function1017f1: call Function101418 ret c Function1017f5: ld b, 0 ld c, $01 farcall Function10079c ret c ld c, $01 ld b, $03 farcall AdvanceMobileInactivityTimerAndCheckExpired ret c farcall Function100382 ld a, [wcd27] bit 7, a jr nz, .next ld hl, wcd29 set 6, [hl] ret .next ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101826: ld a, [wcd21] cp $02 jr z, .asm_101833 cp $01 jr z, .asm_101844 jr .asm_101869 .asm_101833 ld hl, Unknown_10186f ld de, wccb4 call Function1013f5 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_101844 farcall Function103654 ld a, c ld hl, Unknown_101882 cp $01 jr z, .asm_10185b ld hl, Unknown_101895 cp $02 jr z, .asm_10185b jr .asm_101869 .asm_10185b ld de, wccb4 call Function1013f5 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_101869 ld a, $fe ld [wcd2b], a ret SECTION "ascii 10186f", ROMX pushc setcharmap ascii Unknown_10186f: db .end - @ db $19, $73, $09, $13, "trade_crystal" .end db 0 Unknown_101882: db .end - @ db $19, $67, $10, $01, "free__crystal" .end db 0 Unknown_101895: db .end - @ db $19, $67, $10, $01, "limit_crystal" .end db 0 popc SECTION "bank40_3", ROMX Function1018a8: ld hl, wccb5 ld de, wcc61 ld a, $04 call Function101406 jr c, .asm_1018d0 ld hl, wccb9 ld de, wcc65 ld a, $06 call Function101406 jr c, .asm_1018ca ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_1018ca ld a, $f6 ld [wcd2b], a ret .asm_1018d0 ld a, $f5 ld [wcd2b], a ret Function1018d6: call Function1018ec ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function1018e1: call Function1018fb ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function1018ec: ld a, $0a ld hl, wccb4 ld [hli], a ld c, a .asm_1018f3 call Random ld [hli], a dec c jr nz, .asm_1018f3 ret Function1018fb: ld a, [wcd2f] and a jr z, .asm_101906 ld hl, wcc61 jr .asm_101909 .asm_101906 ld hl, wccb5 .asm_101909 ld de, wLinkBattleRNs ld bc, 10 call CopyBytes ret Function101913: ld hl, wcd2a set 0, [hl] xor a ld [wc30d], a ld hl, wcd29 res 4, [hl] xor a ld [wc305], a ld hl, wcd29 res 7, [hl] ld a, $90 ldh [hWY], a ld a, [wcd21] cp $01 jr z, .asm_10193f cp $02 jr z, .asm_101945 ld a, $71 ld [wMobileCommsJumptableIndex], a ret .asm_10193f ld a, $66 ld [wMobileCommsJumptableIndex], a ret .asm_101945 ld a, $65 ld [wMobileCommsJumptableIndex], a ret Function10194b: call DisableSpriteUpdates call ClearSprites farcall Function1021f9 ld hl, wcd29 bit 3, [hl] jr nz, .asm_101967 call Function1013c0 ld a, $71 ld [wMobileCommsJumptableIndex], a ret .asm_101967 ld a, $60 ld [wMobileCommsJumptableIndex], a ret _SelectMonsForMobileBattle: farcall BlankScreen farcall Mobile_CommunicationStandby ld hl, wcd29 set 5, [hl] ld hl, wcd2a set 6, [hl] ld a, $06 ld [wccb4], a ld hl, wPlayerMonSelection ld de, wccb5 ld bc, 3 call CopyBytes ld hl, wcd6c ld a, [hli] ld [wccb8], a ld a, [hli] ld [wccb9], a ld a, [hl] ld [wccba], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret _StartMobileBattle: call CopyOtherPlayersBattleMonSelection farcall Function100754 xor a ld [wdc5f], a ld [wdc60], a farcall BlankScreen call SpeechTextbox farcall Function100846 ld c, 120 call DelayFrames farcall ClearTileMap call .CopyOTDetails call StartMobileBattle ld a, [wcd2b] cp $fc jr nz, .asm_1019e6 xor a ld [wcd2b], a .asm_1019e6 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .CopyOTDetails: ldh a, [rSVBK] push af ld a, 5 ldh [rSVBK], a ld bc, w5_dc0d ld de, w5_dc11 farcall GetMobileOTTrainerClass pop af ldh [rSVBK], a ld a, c ld [wOtherTrainerClass], a ld hl, wOTPlayerName ld de, wOTClassName ld bc, NAME_LENGTH call CopyBytes ld a, [wcd2f] and a ld a, USING_INTERNAL_CLOCK jr z, .got_link_player_number ld a, USING_EXTERNAL_CLOCK .got_link_player_number ldh [hSerialConnectionStatus], a ret StartMobileBattle: ; force stereo and fast text speed ld hl, wOptions ld a, [hl] push af and (1 << STEREO) or 1 ; 1 frame per character i.e. fast text ld [hl], a ld a, 1 ld [wDisableTextAcceleration], a farcall BattleIntro farcall DoBattle farcall ShowLinkBattleParticipantsAfterEnd xor a ld [wDisableTextAcceleration], a ld a, CONNECTION_NOT_ESTABLISHED ldh [hSerialConnectionStatus], a pop af ld [wOptions], a ret Function101a4f: ld a, 1 ld [wDisableTextAcceleration], a farcall DisplayLinkBattleResult xor a ld [wDisableTextAcceleration], a farcall CleanUpBattleRAM farcall LoadPokemonData call Function1013c0 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret CopyOtherPlayersBattleMonSelection: ld hl, wcc61 ld de, wOTMonSelection ld bc, 3 call CopyBytes ld de, wcc64 farcall Function100772 farcall Function101050 farcall LoadSelectedPartiesForColosseum ret Function101a97: farcall Function115d99 ld hl, wcd29 set 7, [hl] ld c, $02 call Function10142c ld hl, wcd29 set 6, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101ab4: ld e, $01 call Function101ee4 ld hl, wcd29 set 5, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101ac6: farcall Function115d99 ld hl, wcd29 set 7, [hl] ld c, $02 call Function10142c ld hl, wcd29 set 6, [hl] xor a ld [wcd2f], a ld de, wdc42 call Function102068 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101aed: farcall Function115d99 ld hl, wcd29 set 7, [hl] ld c, $02 call Function10142c ld hl, wcd29 set 6, [hl] ld a, $01 ld [wcd2f], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101b0f: ld c, 0 call Function10142c ld e, $03 call Function101ee4 ld hl, wcd29 set 5, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ld a, 0 ld [wcd26], a ret Function101b2b: farcall Function100579 ld hl, wcd29 set 2, [hl] ld a, [wcd26] bit 7, a ret z call Function1013dd ld a, 0 ld [wcd26], a ld a, [wMenuCursorY] cp $01 jr z, .asm_101b51 ld a, $02 ld [wcd2b], a ret .asm_101b51 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101b59: ld c, $02 call Function10142c ld e, $02 call Function101ee4 ld hl, wcd29 set 5, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101b70: ld c, $02 call Function10142c ld e, $04 call Function101ee4 ld hl, wcd29 set 5, [hl] call UpdateSprites ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ld a, 0 ld [wcd26], a ret Function101b8f: farcall Function1005c3 ld hl, wcd29 set 2, [hl] ld a, [wcd26] bit 7, a ret z call Function1013dd ld a, 0 ld [wcd26], a ld a, [wMenuCursorY] cp $01 jr z, .asm_101bbc ld a, $01 ld [wcd2f], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_101bbc xor a ld [wcd2f], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101bc8: ld c, $02 call Function10142c ld e, $08 call Function101ee4 call Function102048 call Function1013dd ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101be5: farcall Function100579 ld hl, wcd29 set 2, [hl] ld a, [wcd26] bit 7, a ret z call Function1013dd ld a, 0 ld [wcd26], a ld a, [wMenuCursorY] cp $01 jr nz, .asm_101c0b ld a, $2a ld [wMobileCommsJumptableIndex], a ret .asm_101c0b ld a, $02 ld [wcd2b], a ret Function101c11: ld a, $01 ld [wdc5f], a ld e, $09 call Function101ee4 call Function102048 ld hl, wcd29 set 5, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101c2b: ld a, $02 ld [wdc5f], a ld e, $07 call Function101ee4 ld hl, wcd29 set 5, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101c42: ld hl, wcd2a set 1, [hl] call Function100665 ld a, $47 ld [wMobileCommsJumptableIndex], a ret Function101c50: ld e, $0a call Function101ee4 ld hl, wcd29 set 2, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101c62: farcall Function115d99 ld hl, wcd29 set 7, [hl] ld c, $01 call Function10142c xor a ld [wc30d], a ld hl, wcd29 res 4, [hl] ld e, $0b call Function101ee4 ld hl, wcd29 set 5, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ld a, 0 ld [wcd26], a ret Function101c92: farcall Function100675 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101ca0: ld c, $02 call Function10142c ld e, $0c call Function101ee4 ld hl, wcd29 set 5, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ld a, 0 ld [wcd26], a ret Function101cbc: ld a, $01 ld [wcd2b], a ret Unreferenced_Function101cc2: ld a, $02 ld [wcd2b], a ret Function101cc8: ld a, $01 ld [wc314], a ld a, $01 ld [wc30d], a ld hl, wcd29 set 4, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101cdf: ld a, $06 ld [wc314], a ld a, $01 ld [wc30d], a ld hl, wcd29 set 4, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101cf6: ld a, $0b ld [wc314 + 1], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101d03: ld a, $0e ld [wc314 + 1], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101d10: ld c, $01 call Function10142c ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a jr Function101d2a Function101d1e: ld c, $03 call Function10142c ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a Function101d2a: call Function101418 ret c ld hl, wcd29 set 6, [hl] ld a, [wcd26] ld hl, Jumptable_101d4d rst JumpTable ld a, [wcd26] bit 7, a ret z ld a, 0 ld [wcd26], a ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Jumptable_101d4d: dw Function101d51 dw Function101d5d Function101d51: ld a, $3c ld [wcd42], a ld a, [wcd26] inc a ld [wcd26], a Function101d5d: ld hl, wcd42 dec [hl] ret nz ld a, [wcd26] set 7, a ld [wcd26], a ret Function101d6b: ld a, [wc30d] and a ret nz ld hl, wcd29 res 4, [hl] ld a, $64 ld [wMobileCommsJumptableIndex], a ret Function101d7b: farcall Function10138b ld b, 0 ld hl, Unknown_101d8d add hl, bc ld c, [hl] ld a, c ld [wMobileCommsJumptableIndex], a ret Unknown_101d8d: db $15, $15, $1f, $1f, $0c, $12, $3a, $3a Function101d95: call Function101ee2 call LoadStandardMenuHeader ld e, $0e call Function101ee4 ld hl, wcd29 set 5, [hl] ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ld a, 0 ld [wcd26], a ret Function101db2: farcall Function103302 call ExitMenu ld hl, wcd29 set 5, [hl] jr c, .asm_101dca ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_101dca ld a, $02 ld [wcd2b], a ret Function101dd0: ld hl, wdc41 bit 1, [hl] jr nz, .asm_101ddd ld a, $19 ld [wMobileCommsJumptableIndex], a ret .asm_101ddd ld a, $1b ld [wMobileCommsJumptableIndex], a ret Function101de3: call Function101ecc call Function101ead jr c, .asm_101df3 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_101df3 call Function101e98 jr c, .asm_101e00 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_101e00 call Function101ed3 ld a, $02 ld [wcd2b], a ret Function101e09: call Function101ead jr c, .asm_101e16 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_101e16 call Function101ecc call Function101e98 push af call Function101ed3 pop af jr c, .asm_101e2b ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret .asm_101e2b ld a, $02 ld [wcd2b], a ret Function101e31: ld a, $3a ld [wMobileCommsJumptableIndex], a jp Function101c2b Function101e39: call Function1020bf push af call Function101ed3 pop af jr c, .asm_101e49 ld a, $2a ld [wMobileCommsJumptableIndex], a ret .asm_101e49 ld a, $02 ld [wcd2b], a ret Function101e4f: ld e, $06 call Function101ee4 call Function1013d6 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ld a, 0 ld [wcd26], a ret Function101e64: call Function101ecc call Function1020a8 push af call Function101ed3 pop af jr c, .asm_101e77 ld a, $24 ld [wMobileCommsJumptableIndex], a ret .asm_101e77 ld hl, wcd29 set 5, [hl] ld a, $02 ld [wcd2b], a ret Unreferenced_Function101e82: call Function101ecc ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Unreferenced_Function101e8d: call Function101ed3 ld a, [wMobileCommsJumptableIndex] inc a ld [wMobileCommsJumptableIndex], a ret Function101e98: call ClearSprites farcall Function8adb3 ret c ld hl, wGameTimerPause set GAMETIMERPAUSE_MOBILE_7_F, [hl] ld hl, wdc41 set 4, [hl] ret Function101ead: ld hl, wGameTimerPause bit GAMETIMERPAUSE_MOBILE_7_F, [hl] jr nz, .asm_101ec8 ld hl, wdc41 bit 2, [hl] jr z, .asm_101eca ld a, [wcd2f] and a jr nz, .asm_101ec8 ld hl, wdc41 bit 1, [hl] jr z, .asm_101eca .asm_101ec8 xor a ret .asm_101eca scf ret Function101ecc: call Function101ee2 call FadeToMenu ret Function101ed3: call Function1013aa farcall Function115d99 ld hl, wcd29 set 7, [hl] ret Function101ee2: ld e, 0 Function101ee4: ld d, 0 ld hl, Unknown_101ef5 add hl, de add hl, de ld a, [hli] ld d, [hl] ld e, a farcall Function100504 ret Unknown_101ef5: dw String_101f13 dw String_101f14 dw String_101f32 dw String_101f4f dw String_101f69 dw String_101f81 dw String_101f93 dw String_101faa dw String_101fc5 dw String_101fd2 dw String_101fe1 dw String_101fef dw String_102000 dw String_10200c dw String_102014 String_101f13: db "@" String_101f14: db "ใƒขใƒใ‚คใƒซใ‚ขใƒ€ใƒ—ใ‚ฟใ‚’ใ€€ใคใ‹ใฃใฆ" next "ใŠใจใ‚‚ใ ใกใจใ€€ใคใ†ใ—ใ‚“ใ—ใพใ™@" String_101f32: db "ใงใ‚“ใ‚ใ‚’ใ€€ใ‹ใ‘ใ‚‹ใฒใจใซใฏ" next "ใคใ†ใ‚ใ‚Šใ‚‡ใ†ใใ‚“ใŒใ€€ใ‹ใ‹ใ‚Šใพใ™@" String_101f4f: db "ใƒขใƒใ‚คใƒซใ‚ขใƒ€ใƒ—ใ‚ฟใฎใ€€ใ˜ใ‚…ใ‚“ใณใฏ" next "ใงใใฆใ€€ใ„ใพใ™ใ‹๏ผŸ@" String_101f69: db "ใ‚ใชใŸใŒใ€€ใŠใจใ‚‚ใ ใกใซ" next "ใงใ‚“ใ‚ใ‚’ใ€€ใ‹ใ‘ใพใ™ใ‹๏ผŸ@" String_101f81: db "ใ‚ใ„ใ—ใƒ•ใ‚ฉใƒซใƒ€ใƒผใ‚’" next "ใคใ‹ใ„ใพใ™ใ‹๏ผŸ@" String_101f93: db "ใงใ‚“ใ‚ใฐใ‚“ใ”ใ†ใ‚’ใ€€ใซใ‚…ใ†ใ‚Šใ‚‡ใ" next "ใ—ใฆใใ ใ•ใ„@" String_101faa: db "ใใ‚Œใงใฏใ€€ใŠใจใ‚‚ใ ใกใ‹ใ‚‰ใฎ" next "ใงใ‚“ใ‚ใ‚’ใ€€ใŠใพใกใ—ใพใ™โ‹ฏ@" String_101fc5: next "ใซใ€€ใงใ‚“ใ‚ใ‚’ใ€€ใ‹ใ‘ใพใ™@" String_101fd2: next "ใซใ€€ใงใ‚“ใ‚ใ‚’ใ€€ใ‹ใ‘ใฆใ„ใพใ™@" String_101fe1: db "ใงใ‚“ใ‚ใŒใ€€ใคใชใŒใ‚Šใพใ—ใŸ!@" String_101fef: db "ใคใ†ใ‚ใ‚’" next "ใ—ใ‚…ใ†ใ‚Šใ‚‡ใ†ใ€€ใ—ใพใ™โ‹ฏ@" String_102000: db "ใคใ†ใ—ใ‚“ใ€€ใ—ใ‚…ใ†ใ‚Šใ‚‡ใ†@" String_10200c: db "ใคใ†ใ‚ใ€€ใ˜ใ‹ใ‚“@" String_102014: db "ใใ‚Œใงใฏใ€€ใคใ†ใ—ใ‚“ใฎ" next "ใ›ใฃใฆใ„ใ‚’ใ€€ใ—ใฆใใ ใ•ใ„@" Function10202c: farcall Function115d99 ld hl, wcd29 set 7, [hl] ld c, $02 call Function10142c ld e, $0d call Function101ee4 hlcoord 4, 4 call Function100681 ret Function102048: call Function10204c ret Function10204c: hlcoord 3, 2 ld c, $10 ld de, wcd53 .asm_102054 ld a, [de] inc de and a jr z, .asm_102067 sub $30 jr c, .asm_102067 cp $0a jr nc, .asm_102067 add $f6 ld [hli], a dec c jr nz, .asm_102054 .asm_102067 ret Function102068: ld hl, wcd53 ld c, $08 .asm_10206d ld a, [de] call Function102080 jr c, .asm_10207f ld a, [de] swap a call Function102080 jr c, .asm_10207f inc de dec c jr nz, .asm_10206d .asm_10207f ret Function102080: and $0f cp $0f jr z, .asm_10208a add $30 ld [hli], a ret .asm_10208a ld [hl], 0 scf ret Function10208e: push de ld h, d ld l, e ld de, wdc42 ld bc, 8 call CopyBytes pop de ret Function10209c: ld a, $ff ld hl, wdc42 ld bc, 8 call ByteFill ret Function1020a8: call Function10209c ld c, $01 ld de, wdc42 farcall Function17a68f ret c call Function10208e call Function102068 xor a ret Function1020bf: call ClearSprites farcall Function8aba9 ld a, c and a jr z, .asm_1020e8 dec a ld hl, $a04c ld bc, $25 call AddNTimes ld d, h ld e, l ld a, $04 call GetSRAMBank call Function10208e call Function102068 call CloseSRAM xor a ret .asm_1020e8 scf ret Function1020ea: ld hl, wdc41 bit 4, [hl] jr z, .quit ld hl, wdc41 bit 2, [hl] jr nz, .quit call Function10218d ld hl, wc608 bit 4, [hl] jr z, .quit ld hl, wc608 bit 2, [hl] jr nz, .quit call Function102112 jr z, .quit and a ret .quit scf ret Function102112: ld a, $04 call GetSRAMBank ld hl, $a041 ld c, 40 .outer_loop push hl ld de, $c60f ld b, 31 .inner_loop ld a, [de] cp [hl] jr nz, .not_matching inc de inc hl dec b jr nz, .inner_loop pop hl xor a jr .done .not_matching pop hl ld de, 37 add hl, de dec c jr nz, .outer_loop ld a, $01 and a jr .done ; useless jr .done push af call CloseSRAM pop af ret Function102142: call Function10218d call Function102180 ld hl, UnknownText_0x1021d1 call MenuTextbox ld de, SFX_LEVEL_UP call PlaySFX call JoyWaitAorB call ExitMenu call Function10219f ld hl, UnknownText_0x1021d6 call MenuTextbox call YesNoBox call ExitMenu jr c, .asm_10217c call Function1021b8 jr c, .asm_10217c call Function10218d call Function102180 ld hl, UnknownText_0x1021db call PrintText .asm_10217c call Function1013d6 ret Function102180: ld hl, wc608 + 1 ld de, wStringBuffer2 ld bc, 11 call CopyBytes ret Function10218d: ld hl, w5_dc00 ld de, wc608 ld bc, $26 ld a, $05 call FarCopyWRAM ld de, wc608 + 1 ; useless ret Function10219f: call FadeToMenu call Function10218d ld de, wc608 + 1 farcall Function8ac4e call JoyWaitAorB call PlayClickSFX call Function1013aa ret Function1021b8: call FadeToMenu call Function10218d ld de, wPlayerMoveStruct farcall Function8ac70 ld a, c ld [wStringBuffer1], a push af call Function1013aa pop af ret UnknownText_0x1021d1: text_far UnknownText_0x1bd19a text_end UnknownText_0x1021d6: text_far UnknownText_0x1bd1ba text_end UnknownText_0x1021db: text_far UnknownText_0x1bd1dd text_end Function1021e0: call MenuTextbox call JoyWaitAorB call ExitMenu ret UnknownText_0x1021ea: text_far UnknownText_0x1bd201 text_end UnknownText_0x1021ef: text_far UnknownText_0x1bd211 text_end UnknownText_0x1021f4: text_far UnknownText_0x1bd223 text_end Function1021f9: call Function102233 ld a, $0 ; Function10234b ld [wcd49], a ld hl, wcd29 bit 3, [hl] res 3, [hl] jr z, .asm_10220f ld a, $1 ; Function102361 ld [wcd49], a .asm_10220f call Function1022ca ld a, [wcd49] ld hl, Jumptable_1022f5 rst JumpTable call Function102241 call Function1022d0 jr c, .asm_102231 ld a, [wcd49] bit 7, a jr z, .asm_10220f xor a ld hl, wcd29 bit 3, [hl] ret z scf ret .asm_102231 xor a ret Function102233: ld hl, wcd49 ld bc, 10 xor a call ByteFill call Function10304f ret Function102241: call Function10226a call Function102274 call Function10224b ret Function10224b: ld hl, wcd4b bit 1, [hl] jr nz, .asm_10225e bit 2, [hl] jr nz, .asm_10225e call DelayFrame call DelayFrame xor a ret .asm_10225e res 1, [hl] res 2, [hl] farcall Mobile_ReloadMapPart scf ret Function10226a: ld hl, wcd4b bit 0, [hl] ret z call Function10305d ret Function102274: ld hl, wcd4b bit 3, [hl] ret z res 3, [hl] ld de, 8 call PlaySFX ret Function102283: ld a, $01 ld [wAttrMapEnd], a ld hl, wcd4b set 0, [hl] ret Function10228e: xor a ld [wAttrMapEnd], a ld hl, wcd4b res 0, [hl] ret Function102298: ld a, e cp $02 ret nz ld hl, wcd4b bit 6, [hl] jr z, .asm_1022b6 ld hl, wcd4b bit 7, [hl] ld hl, wcd4b set 7, [hl] ret nz ld de, SFX_ELEVATOR_END call PlaySFX jr .asm_1022c1 .asm_1022b6 ld hl, wcd4b bit 7, [hl] ld hl, wcd4b res 7, [hl] ret z .asm_1022c1 call Function10304f ld a, $01 ld [wAttrMapEnd], a ret Function1022ca: ld a, 30 ld [wOverworldDelay], a ret Function1022d0: farcall Function10032e ld a, [wcd2b] and a jr nz, .asm_1022f3 call Function102298 ld a, [wOverworldDelay] ld c, a ld a, 30 sub c ld c, a ld b, $03 farcall AdvanceMobileInactivityTimerAndCheckExpired jr c, .asm_1022f3 xor a ret .asm_1022f3 scf ret Jumptable_1022f5: dw Function10234b ; 00 dw Function102361 ; 01 dw Function10236e ; 02 dw Function102387 ; 03 dw Function1023a1 ; 04 dw Function1025c7 ; 05 dw Function1025dc ; 06 dw Function1024f6 ; 07 dw Function10250c ; 08 dw Function1024a8 ; 09 dw Function102591 ; 0a dw Function1024a8 ; 0b dw Function1025b0 ; 0c dw Function1025bd ; 0d dw Function102814 ; 0e dw Function10283c ; 0f dw Function102862 ; 10 dw Function10286f ; 11 dw Function1024a8 ; 12 dw Function1028a5 ; 13 dw Function1028ab ; 14 dw Function1023b5 ; 15 dw Function1023c6 ; 16 dw Function1024af ; 17 dw Function102416 ; 18 dw Function102423 ; 19 dw Function10244b ; 1a dw Function1024af ; 1b dw Function10246a ; 1c dw Function102652 ; 1d dw Function10266b ; 1e dw Function1025e9 ; 1f dw Function1025ff ; 20 dw Function102738 ; 21 dw Function102754 ; 22 dw Function1026b7 ; 23 dw Function1026c8 ; 24 dw Function1028bf ; 25 dw Function1028c6 ; 26 dw Function1028d3 ; 27 dw Function1028da ; 28 dw Function1024a8 ; 29 dw Function10248d ; 2a Function10234b: call Function102d9a call Function102dd3 call Function102dec ld hl, wcd4b set 1, [hl] ld a, [wcd49] inc a ld [wcd49], a ret Function102361: ld a, $cc call Function1028e8 ld a, [wcd49] inc a ld [wcd49], a ret Function10236e: call Function1028fc ret nc ld a, [wcd51] cp $cc jr z, .asm_10237f ld a, $f2 ld [wcd2b], a ret .asm_10237f ld a, [wcd49] inc a ld [wcd49], a ret Function102387: ld hl, wcd4b set 6, [hl] xor a ld [wdc5f], a ld de, MUSIC_ROUTE_30 call PlayMusic call Function102d9a call Function102dd3 ld a, $01 ld [wMenuCursorY], a Function1023a1: call Function102283 call Function102db7 call Function102dec ld hl, wcd4b set 1, [hl] ld a, $1d ld [wcd49], a ret Function1023b5: call Function10228e call Function102a3b call Function102b12 ld a, [wcd49] inc a ld [wcd49], a ret Function1023c6: call Function102c48 call Function102c87 ld a, [wcd4c] dec a ld [wCurPartyMon], a xor a ; REMOVE_PARTY ld [wPokemonWithdrawDepositParameter], a farcall RemoveMonFromPartyOrBox ld hl, wPartyCount inc [hl] ld a, [hli] ld c, a ld b, 0 add hl, bc ld [hl], $ff ld a, [wPartyCount] ld [wcd4c], a call Function102c07 call Function102d48 call Function102b32 call Function102f50 ld hl, wcd4b set 1, [hl] ld a, $14 ld [wcd4e], a ld a, 0 ld [wcd4f], a ld a, 0 ld [wcd4a], a ld a, [wcd49] inc a ld [wcd49], a ret Function102416: ld a, $aa call Function1028e8 ld a, [wcd49] inc a ld [wcd49], a ret Function102423: call Function102921 ret nc farcall SaveAfterLinkTrade farcall StubbedTrainerRankings_Trades farcall BackupMobileEventIndex ld hl, wcd4b set 1, [hl] ld a, 0 ld [wcd4a], a ld a, [wcd49] inc a ld [wcd49], a ret Function10244b: call Function102f32 ld hl, wcd4b set 1, [hl] ld a, $19 ld [wcd4e], a ld a, 0 ld [wcd4f], a ld a, 0 ld [wcd4a], a ld a, [wcd49] inc a ld [wcd49], a ret Function10246a: call Function102d9a ld hl, wcd29 set 3, [hl] call Function102e07 ld hl, wcd4b set 1, [hl] ld a, $2a ld [wcd49], a ret Function102480: ld c, $32 call DelayFrames ld a, [wcd49] inc a ld [wcd49], a ret Function10248d: ld a, [wcd49] set 7, a ld [wcd49], a ret Function102496: ld hl, wcd4e dec [hl] ret nz ld a, 0 ld [wcd4a], a ld a, [wcd49] inc a ld [wcd49], a ret Function1024a8: farcall Function1009f3 ret c Function1024af: call GetJoypad ld a, [wcd4a] ld hl, Jumptable_1024ba rst JumpTable ret Jumptable_1024ba: dw Function1024c0 dw Function1024cb dw Function1024de Function1024c0: ld hl, wcd4e inc [hl] ld a, [wcd4a] inc a ld [wcd4a], a Function1024cb: ld hl, wcd4e dec [hl] ret nz ld a, [wcd4f] inc a ld [wcd4e], a ld a, [wcd4a] inc a ld [wcd4a], a Function1024de: ld hl, wcd4e dec [hl] jr z, .asm_1024e9 ldh a, [hJoyPressed] and A_BUTTON | B_BUTTON ret z .asm_1024e9 ld a, 0 ld [wcd4a], a ld a, [wcd49] inc a ld [wcd49], a ret Function1024f6: call PlaceHollowCursor ld hl, wcd4b set 1, [hl] ld a, [wcd4c] call Function1028e8 ld a, [wcd49] inc a ld [wcd49], a ret Function10250c: call Function1028fc ret nc ld a, [wcd51] cp $0f jr z, .asm_10254b and a jr z, .asm_102572 cp $aa jr z, .asm_102572 cp $07 jr nc, .asm_102572 ld [wcd4d], a dec a ld [wd003], a ld a, [wcd4c] dec a ld [wd002], a call Function102b9c call Function102bdc jr c, .asm_10256d farcall Functionfb5dd jr c, .asm_102568 ld hl, wcd4b set 1, [hl] ld a, $0e ld [wcd49], a ret .asm_10254b call Function103021 ld hl, wcd4b set 1, [hl] ld a, 0 ld [wcd4a], a ld a, $1e ld [wcd4e], a ld a, $1e ld [wcd4f], a ld a, $29 ld [wcd49], a ret .asm_102568 call Function102ff5 jr .asm_102577 .asm_10256d call Function102f85 jr .asm_102577 .asm_102572 call Function102fce jr .asm_102577 .asm_102577 ld hl, wcd4b set 1, [hl] ld a, 0 ld [wcd4a], a ld a, $1e ld [wcd4e], a ld a, $3c ld [wcd4f], a ld a, $09 ld [wcd49], a ret Function102591: call Function102ee7 ld hl, wcd4b set 1, [hl] ld a, 0 ld [wcd4a], a ld a, $1e ld [wcd4e], a ld a, $3c ld [wcd4f], a ld a, [wcd49] inc a ld [wcd49], a ret Function1025b0: ld a, $09 call Function1028e8 ld a, [wcd49] inc a ld [wcd49], a ret Function1025bd: call Function1028fc ret nc ld a, $04 ld [wcd49], a ret Function1025c7: call Function102f6d ld hl, wcd4b set 1, [hl] ld a, $0f call Function1028e8 ld a, [wcd49] inc a ld [wcd49], a ret Function1025dc: call Function1028fc ret nc ld a, [wcd49] set 7, a ld [wcd49], a ret Function1025e9: nop ld hl, wcd4b set 6, [hl] call Function102b4e ld hl, wcd4b set 1, [hl] ld a, [wcd49] inc a ld [wcd49], a ret Function1025ff: ld hl, wcd4b set 2, [hl] farcall Function1009f3 ret c farcall MobileMenuJoypad ld a, [wMenuJoypadFilter] and c ret z bit A_BUTTON_F, c jr nz, .a_button bit D_UP_F, c jr nz, .d_up bit D_DOWN_F, c jr nz, .d_down ret .a_button ld hl, wcd4b set 3, [hl] ld a, $27 ; Function1028d3 ld [wcd49], a ret .d_up ld a, [wMenuCursorY] ld b, a ld a, [wOTPartyCount] cp b ret nz call HideCursor ld a, [wPartyCount] ld [wMenuCursorY], a ld a, $1d ; Function102652 ld [wcd49], a ret .d_down ld a, [wMenuCursorY] cp $01 ret nz ld a, $23 ; Function1026b7 ld [wcd49], a ret Function102652: nop ld hl, wcd4b set 6, [hl] nop call Function102b7b nop ld hl, wcd4b set 1, [hl] nop ld a, [wcd49] inc a ld [wcd49], a ret Function10266b: ld hl, wcd4b set 2, [hl] farcall Function1009f3 ret c farcall MobileMenuJoypad ld a, [wMenuJoypadFilter] and c ret z bit A_BUTTON_F, c jr nz, .a_button bit D_DOWN_F, c jr nz, .d_down bit D_UP_F, c jr nz, .d_up ret .a_button ld hl, wcd4b set 3, [hl] ld a, $21 ; Function102738 ld [wcd49], a ret .d_down ld a, [wMenuCursorY] dec a ret nz call HideCursor ld a, $1f ; Function1025e9 ld [wcd49], a ret .d_up ld a, [wMenuCursorY] ld b, a ld a, [wPartyCount] cp b ret nz ld a, $23 ; Function1026b7 ld [wcd49], a ret Function1026b7: ld hl, wcd4b set 6, [hl] ld a, [wcd49] inc a ld [wcd49], a ld a, 0 ld [wcd4a], a Function1026c8: call GetJoypad farcall Function1009f3 ret c ld a, [wcd4a] ld hl, Jumptable_1026da rst JumpTable ret Jumptable_1026da: dw Function1026de dw Function1026f3 Function1026de: call HideCursor hlcoord 9, 17 ld [hl], $ed ld a, [wcd4a] inc a ld [wcd4a], a ld hl, wcd4b set 1, [hl] ret Function1026f3: ldh a, [hJoyPressed] bit A_BUTTON_F, a jr nz, .asm_102723 bit D_UP_F, a jr nz, .asm_102712 bit D_DOWN_F, a jr nz, .asm_102702 ret .asm_102702 hlcoord 9, 17 ld [hl], " " ld a, $01 ld [wMenuCursorY], a ld a, $1d ; Function102652 ld [wcd49], a ret .asm_102712 hlcoord 9, 17 ld [hl], " " ld a, [wOTPartyCount] ld [wMenuCursorY], a ld a, $1f ; Function1025e9 ld [wcd49], a ret .asm_102723 hlcoord 9, 17 ld [hl], "โ–ท" ld hl, wcd4b set 3, [hl] ld hl, wcd4b set 2, [hl] ld a, $5 ; Function1025c7 ld [wcd49], a ret Function102738: ld hl, wcd4b set 6, [hl] call PlaceHollowCursor call Function1027eb ld hl, wcd4b set 1, [hl] ld a, [wcd49] inc a ld [wcd49], a ld a, 0 ld [wcd4a], a Function102754: call GetJoypad farcall Function1009f3 ret c ld a, [wcd4a] ld hl, Jumptable_102766 rst JumpTable ret Jumptable_102766: dw Function102770 dw Function102775 dw Function10278c dw Function1027a0 dw Function1027b7 Function102770: ld a, $01 ld [wcd4a], a Function102775: hlcoord 1, 16 ld [hl], "โ–ถ" hlcoord 11, 16 ld [hl], " " ld hl, wcd4b set 2, [hl] ld a, [wcd4a] inc a ld [wcd4a], a ret Function10278c: ldh a, [hJoyPressed] bit A_BUTTON_F, a jr nz, asm_1027c6 bit B_BUTTON_F, a jr nz, asm_1027e2 bit D_RIGHT_F, a jr nz, .asm_10279b ret .asm_10279b ld a, $03 ld [wcd4a], a Function1027a0: hlcoord 1, 16 ld [hl], " " hlcoord 11, 16 ld [hl], "โ–ถ" ld hl, wcd4b set 2, [hl] ld a, [wcd4a] inc a ld [wcd4a], a ret Function1027b7: ldh a, [hJoyPressed] bit A_BUTTON_F, a jr nz, asm_1027d1 bit B_BUTTON_F, a jr nz, asm_1027e2 bit D_LEFT_F, a jr nz, Function102770 ret asm_1027c6: ld hl, wcd4b set 3, [hl] ld a, $25 ; Function1028bf ld [wcd49], a ret asm_1027d1: ld hl, wcd4b set 3, [hl] ld a, [wMenuCursorY] ld [wcd4c], a ld a, $7 ; Function1024f6 ld [wcd49], a ret asm_1027e2: call Function102db7 ld a, $1d ; Function102652 ld [wcd49], a ret Function1027eb: hlcoord 0, 14 ld b, 2 ld c, 18 ld d, h ld e, l farcall _LinkTextbox ld de, .Stats_Trade hlcoord 2, 16 call PlaceString ret .Stats_Trade: db "STATS TRADE@" Function102814: ld a, [wMenuCursorY] ld [wcd52], a ld a, [wcd4c] dec a ld [wd002], a ld a, [wcd4d] dec a ld [wd003], a call Function102ea8 ld a, [wcd49] inc a ld [wcd49], a ld a, 0 ld [wcd4a], a ld hl, wcd4b set 1, [hl] Function10283c: ld hl, wcd4b set 2, [hl] call Function1029c3 ret z jr c, .asm_102852 ld a, $10 ; Function102862 ld [wcd49], a ld hl, wcd4b set 1, [hl] ret .asm_102852 ld a, $14 ; Function1028ab ld [wcd49], a ld hl, wcd4b set 3, [hl] ld hl, wcd4b set 1, [hl] ret Function102862: ld a, $08 call Function1028e8 ld a, [wcd49] inc a ld [wcd49], a ret Function10286f: call Function1028fc ret nc ld a, [wcd52] ld [wMenuCursorY], a ld a, [wcd51] cp $08 jr nz, .asm_102886 ld a, $15 ; Function1023b5 ld [wcd49], a ret .asm_102886 call Function102ee7 ld hl, wcd4b set 1, [hl] ld a, $1e ld [wcd4e], a ld a, $3c ld [wcd4f], a ld a, 0 ld [wcd4a], a ld a, [wcd49] inc a ld [wcd49], a ret Function1028a5: ld a, $4 ; Function1023a1 ld [wcd49], a ret Function1028ab: ld a, [wcd52] ld [wMenuCursorY], a call Function102f15 ld hl, wcd4b set 1, [hl] ld a, $c ; Function1025b0 ld [wcd49], a ret Function1028bf: ld a, [wcd49] inc a ld [wcd49], a Function1028c6: xor a ld [wMonType], a call Function102bac ld a, $1d ; Function102652 ld [wcd49], a ret Function1028d3: ld a, [wcd49] inc a ld [wcd49], a Function1028da: ld a, OTPARTYMON ld [wMonType], a call Function102bac ld a, $1f ; Function1025e9 ld [wcd49], a ret Function1028e8: ld hl, wcd4b res 6, [hl] ld [wcd50], a farcall StartMobileInactivityTimer ld a, 0 ld [wcd4a], a ret Function1028fc: call GetJoypad farcall Function1009f3 jr nc, .asm_102909 and a ret .asm_102909 ld a, [wcd4a] ld hl, Jumptable_102917 rst JumpTable ret nc ld a, 0 ld [wcd4a], a ret Jumptable_102917: dw Function102933 dw Function10294f dw Function10295d dw Function10296e dw Function102996 Function102921: ld a, [wcd4a] ld hl, Jumptable_10292f rst JumpTable ret nc ld a, 0 ld [wcd4a], a ret Jumptable_10292f: dw Function10295d dw Function102984 Function102933: ld hl, MenuHeader_1029bb call LoadMenuHeader call Function102e07 ld a, $32 ld [wTextDelayFrames], a ld hl, wcd4b set 1, [hl] ld a, [wcd4a] inc a ld [wcd4a], a and a ret Function10294f: ld a, [wTextDelayFrames] and a ret nz ld a, [wcd4a] inc a ld [wcd4a], a and a ret Function10295d: call Function10299e ld a, 0 ld [wcd27], a ld a, [wcd4a] inc a ld [wcd4a], a and a ret Function10296e: farcall Function100382 and a ld a, [wcd27] bit 7, a ret z ld a, [wcd4a] inc a ld [wcd4a], a and a ret Function102984: farcall Function100382 and a ld a, [wcd27] bit 7, a ret z call Function1029af scf ret Function102996: call Function1029af call ExitMenu scf ret Function10299e: ld a, $01 ld [wccb4], a ld a, [wcd50] ld [wccb5], a ld a, $aa ld [wcd51], a ret Function1029af: ld hl, wcd4b res 7, [hl] ld a, [wcc61] ld [wcd51], a ret MenuHeader_1029bb: db MENU_BACKUP_TILES ; flags menu_coords 3, 10, 15, 12 dw NULL db 1 ; default option Function1029c3: ld a, [wcd4a] ld hl, Jumptable_1029cb rst JumpTable ret Jumptable_1029cb: dw Function1029cf dw Function1029fe Function1029cf: call LoadStandardMenuHeader hlcoord 10, 7 ld b, 3 ld c, 8 ld d, h ld e, l farcall _LinkTextbox ld de, String_102a26 hlcoord 12, 8 call PlaceString ld hl, wcd4b set 1, [hl] ld de, MenuData3_102a33 call SetMenuAttributes ld a, [wcd4a] inc a ld [wcd4a], a xor a ret Function1029fe: farcall Function1009f3 ret c farcall MobileMenuJoypad ld a, c ld hl, wMenuJoypadFilter and [hl] ret z push af call ExitMenu pop af ld a, [wMenuCursorY] cp $01 jr nz, .asm_102a21 ld a, $01 and a ret .asm_102a21 ld a, $01 and a scf ret String_102a26: db "TRADE" next "CANCEL" db "@" MenuData3_102a33: db 8, 11 db 2, 1 db $80, $00 dn 2, 0 db A_BUTTON Function102a3b: ld a, [wcd30] ld [wc74e], a ld hl, wPlayerName ld de, wPlayerTrademonSenderName ld bc, NAME_LENGTH call CopyBytes ld a, [wcd4c] dec a ld c, a ld b, 0 ld hl, wPartySpecies add hl, bc ld a, [hl] ld [wPlayerTrademonSpecies], a ld a, [wcd4c] dec a ld hl, wPartyMonOT call SkipNames ld de, wPlayerTrademonOTName ld bc, NAME_LENGTH call CopyBytes ld a, [wcd4c] dec a ld hl, wPartyMon1ID call GetPartyLocation ld a, [hli] ld [wPlayerTrademonID], a ld a, [hl] ld [wPlayerTrademonID + 1], a ld a, [wcd4c] dec a ld hl, wPartyMon1DVs call GetPartyLocation ld a, [hli] ld [wPlayerTrademonDVs], a ld a, [hl] ld [wPlayerTrademonDVs + 1], a ld a, [wcd4c] dec a ld hl, wPartyMon1Species call GetPartyLocation ld b, h ld c, l farcall GetCaughtGender ld a, c ld [wPlayerTrademonCaughtData], a ld hl, wOTPlayerName ld de, wOTTrademonSenderName ld bc, NAME_LENGTH call CopyBytes ld a, [wcd4d] dec a ld c, a ld b, 0 ld hl, wOTPartySpecies add hl, bc ld a, [hl] ld [wOTTrademonSpecies], a ld a, [wcd4d] dec a ld hl, wOTPartyMonOT call SkipNames ld de, wOTTrademonOTName ld bc, NAME_LENGTH call CopyBytes ld a, [wcd4d] dec a ld hl, wOTPartyMon1ID call GetPartyLocation ld a, [hli] ld [wOTTrademonID], a ld a, [hl] ld [wOTTrademonID + 1], a ld a, [wcd4d] dec a ld hl, wOTPartyMon1DVs call GetPartyLocation ld a, [hli] ld [wOTTrademonDVs], a ld a, [hl] ld [wOTTrademonDVs + 1], a ld a, [wcd4d] dec a ld hl, wOTPartyMon1Species call GetPartyLocation ld b, h ld c, l farcall GetCaughtGender ld a, c ld [wOTTrademonCaughtData], a ret Function102b12: ld c, 100 call DelayFrames call Function102d9a call LoadFontsBattleExtra ld a, [wcd2f] and a jr nz, .asm_102b2b farcall Function108026 jr .asm_102b31 .asm_102b2b farcall Function10802a .asm_102b31 ret Function102b32: ld a, [wcd4c] dec a ld [wCurPartyMon], a ld a, $01 ld [wForceEvolution], a farcall EvolvePokemon call Function102d9a call Function102dd3 call Function102dec ret Function102b4e: ld a, OTPARTYMON ld [wMonType], a ld a, [wMenuCursorY] push af ld de, Unknown_102b73 call SetMenuAttributes pop af ld [wMenuCursorY], a ld a, [wOTPartyCount] ld [w2DMenuNumRows], a ret Unreferenced_Function102b68: xor a ld hl, wWindowStackPointer ld bc, $10 call ByteFill ret Unknown_102b73: db 9, 6 db 255, 1 db $a0, $00 dn 1, 0 db D_UP | D_DOWN | A_BUTTON Function102b7b: xor a ld [wMonType], a ld a, [wMenuCursorY] push af ld de, Unknown_102b94 call SetMenuAttributes pop af ld [wMenuCursorY], a ld a, [wPartyCount] ld [w2DMenuNumRows], a ret Unknown_102b94: db 1, 6 db 255, 1 db $a0, $00 dn 1, 0 db D_UP | D_DOWN | A_BUTTON Function102b9c: ld a, [wcd4d] dec a hlcoord 6, 9 ld bc, $14 call AddNTimes ld [hl], $ec ret Function102bac: ld a, [wMenuCursorY] dec a ld [wCurPartyMon], a call LowVolume call ClearSprites farcall _MobileStatsScreenInit ld a, [wCurPartyMon] inc a ld [wMenuCursorY], a call Function102d9a call ClearPalettes call DelayFrame call MaxVolume call Function102dd3 call Function102dec call Function102db7 ret Function102bdc: ld a, [wcd4d] dec a ld hl, wOTPartyMon1Species call GetPartyLocation push hl ld a, [wcd4d] ld c, a ld b, 0 ld hl, wOTPartyCount add hl, bc ld a, [hl] pop hl cp EGG jr z, .asm_102bfa cp [hl] jr nz, .asm_102c05 .asm_102bfa ld bc, MON_LEVEL add hl, bc ld a, [hl] cp MAX_LEVEL + 1 jr nc, .asm_102c05 and a ret .asm_102c05 scf ret Function102c07: call Function102c14 call Function102c3b call Function102c21 call Function102c2e ret Function102c14: ld hl, wPartySpecies ld de, wOTPartySpecies ld bc, 1 call Function102c71 ret Function102c21: ld hl, wPartyMonNicknames ld de, wOTPartyMonNicknames ld bc, 11 call Function102c71 ret Function102c2e: ld hl, wPartyMonOT ld de, wOTPartyMonOT ld bc, 11 call Function102c71 ret Function102c3b: ld hl, wPartyMon1 ld de, wOTPartyMon1 ld bc, $30 call Function102c71 ret Function102c48: farcall Function10165a ld a, 0 call GetSRAMBank ld hl, $a600 ld de, wc608 ld bc, $2f call Function102c71 call CloseSRAM ld hl, wc608 ld de, w5_da00 ld bc, $1e0 ld a, $05 call FarCopyWRAM ret Function102c71: ld a, [wcd4c] dec a call AddNTimes push hl ld h, d ld l, e ld a, [wcd4d] dec a call AddNTimes pop de call SwapBytes ret Function102c87: ld a, [wJumptableIndex] push af ld a, [wcf64] push af ld a, [wcd4c] ld [wJumptableIndex], a ld a, [wPartyCount] ld [wcf64], a ld a, 0 ld hl, $a600 ld de, wc608 ld bc, $11a call Function102d3e call Function102cee ld a, 0 ld hl, wc608 ld de, $a600 ld bc, $11a call Function102d3e ld a, [wcd4d] ld [wJumptableIndex], a ld a, [wOTPartyCount] ld [wcf64], a ld a, $05 ld hl, w5_da00 ld de, wc608 ld bc, $11a call FarCopyWRAM call Function102cee ld a, $05 ld hl, wc608 ld de, w5_da00 ld bc, $11a call FarCopyWRAM pop af ld [wcf64], a pop af ld [wJumptableIndex], a ret Function102cee: ld a, [wJumptableIndex] dec a call Function102d34 ld de, wd002 ld bc, $2f call CopyBytes ld a, [wJumptableIndex] ld c, a ld a, $06 sub c ret z ld bc, $2f ld hl, 0 call AddNTimes push hl ld a, [wJumptableIndex] dec a call Function102d34 ld d, h ld e, l ld hl, $2f add hl, de pop bc call CopyBytes ld a, [wcf64] dec a call Function102d34 ld d, h ld e, l ld hl, wd002 ld bc, $2f call CopyBytes ret Function102d34: ld hl, wc608 ld bc, $2f call AddNTimes ret Function102d3e: call GetSRAMBank call CopyBytes call CloseSRAM ret Function102d48: ld a, [wcd4c] ld e, a ld d, 0 ld hl, wPartyCount add hl, de ld a, [hl] ld [wTempSpecies], a cp EGG jr z, .asm_102d6d call SetSeenAndCaughtMon ld a, [wcd4c] dec a ld bc, PARTYMON_STRUCT_LENGTH ld hl, wPartyMon1Happiness call AddNTimes ld [hl], BASE_HAPPINESS .asm_102d6d ld a, [wTempSpecies] call GetPokemonIndexFromID ld a, l sub LOW(UNOWN) if HIGH(UNOWN) == 0 or h else jr nz, .asm_102d98 if HIGH(UNOWN) == 1 dec h else ld a, h cp HIGH(UNOWN) endc endc jr nz, .asm_102d98 ld a, [wcd4c] dec a ld bc, PARTYMON_STRUCT_LENGTH ld hl, wPartyMon1DVs call AddNTimes predef GetUnownLetter farcall UpdateUnownDex ld a, [wFirstUnownSeen] and a jr nz, .asm_102d98 ld a, [wUnownLetter] ld [wFirstUnownSeen], a .asm_102d98 and a ret Function102d9a: ld a, " " hlcoord 0, 0 ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill ld a, $07 hlcoord 0, 0, wAttrMap ld bc, SCREEN_WIDTH * SCREEN_HEIGHT call ByteFill farcall HDMATransferAttrMapAndTileMapToWRAMBank3 ret Function102db7: call Function102e4f call Function102e3e ld hl, wcd4b set 1, [hl] ret Function102dc3: hlcoord 0, 12 ld b, 4 ld c, 18 ld d, h ld e, l farcall _LinkTextbox ret Function102dd3: call DisableLCD ld de, GFX_1032a2 ld hl, vTiles0 lb bc, BANK(GFX_1032a2), 4 call Get2bpp farcall __LoadTradeScreenBorder call EnableLCD ret Function102dec: ld hl, Palettes_1032e2 ld de, wOBPals1 ld bc, 4 palettes ld a, $05 call FarCopyWRAM farcall Function49742 call SetPalettes call DelayFrame ret Function102e07: hlcoord 3, 10 ld b, 1 ld c, 11 ld a, [wBattleMode] and a jr z, .link_battle call Textbox jr .okay .link_battle ; this is idiotic hlcoord 3, 10 ld b, 1 ld c, 11 ld d, h ld e, l farcall _LinkTextbox .okay ld de, .waiting hlcoord 4, 11 call PlaceString ret .waiting db "Waiting...!@" Function102e3e: ld de, .CANCEL hlcoord 10, 17 call PlaceString ret .CANCEL: db "CANCEL@" Function102e4f: farcall Function16d42e farcall _InitMG_Mobile_LinkTradePalMap ld de, wPlayerName hlcoord 4, 0 call PlaceString ld a, $14 ld [bc], a ld de, wOTPlayerName hlcoord 4, 8 call PlaceString ld a, $14 ld [bc], a hlcoord 7, 1 ld de, wPartySpecies call .PlaceSpeciesNames hlcoord 7, 9 ld de, wOTPartySpecies call .PlaceSpeciesNames ret .PlaceSpeciesNames: ld c, 0 .count_loop ld a, [de] cp $ff ret z ld [wNamedObjectIndexBuffer], a push bc push hl push de push hl ld a, c ldh [hDividend], a call GetPokemonName pop hl call PlaceString pop de inc de pop hl ld bc, SCREEN_WIDTH add hl, bc pop bc inc c jr .count_loop Function102ea8: call Function102dc3 ld a, [wcd4c] dec a ld c, a ld b, 0 ld hl, wPartySpecies add hl, bc ld a, [hl] ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, wStringBuffer1 ld de, wStringBuffer2 ld bc, 11 call CopyBytes ld a, [wcd4d] dec a ld c, a ld b, 0 ld hl, wOTPartySpecies add hl, bc ld a, [hl] ld [wNamedObjectIndexBuffer], a call GetPokemonName ld hl, UnknownText_0x102ee2 call PrintTextboxText ret UnknownText_0x102ee2: text_far UnknownText_0x1bd286 text_end Function102ee7: call Function102dc3 ld de, String_102ef4 hlcoord 1, 14 call PlaceString ret String_102ef4: db "Too bad! The trade" next "was canceled!" db "@" Function102f15: call Function102dc3 ld de, .TooBadTheTradeWasCanceled hlcoord 1, 14 call PlaceString ret .TooBadTheTradeWasCanceled: db "ใ“ใ†ใ‹ใ‚“ใ‚’ใ€€ใ‚ญใƒฃใƒณใ‚ปใƒซใ—ใพใ—ใŸ@" Function102f32: call Function102dc3 ld de, .TradeCompleted hlcoord 1, 14 call PlaceString ret .TradeCompleted: db "Trade completed!@" Function102f50: call Function102dc3 ld de, .PleaseWait hlcoord 1, 14 call PlaceString ret .PleaseWait: db "ใ—ใ‚‡ใ†ใ—ใ‚‡ใ†ใ€€ใŠใพใกใ€€ใใ ใ•ใ„@" Function102f6d: call Function102dc3 ld de, .Finished hlcoord 1, 14 call PlaceString ret .Finished: db "ใ—ใ‚…ใ†ใ‚Šใ‚‡ใ†ใ€€ใ—ใพใ™@" Function102f85: ld a, [wd003] ld c, a ld b, 0 ld hl, wOTPartySpecies add hl, bc ld a, [hl] ld [wNamedObjectIndexBuffer], a call GetPokemonName call Function102dc3 ld de, String_102fb2 hlcoord 1, 14 call PlaceString ld de, wStringBuffer1 hlcoord 13, 14 call PlaceString ld de, String_102fcc call PlaceString ret String_102fb2: db "ใ‚ใ„ใฆใŒใ‚<PKMN>ใˆใ‚‰ใ‚“ใ ใ€€" next "ใ„ใ˜ใ‚‡ใ†<PKMN>ใ‚ใ‚‹ใ‚ˆใ†ใงใ™๏ผ๏ผ" db "@" String_102fcc: db "ใซ@" Function102fce: call Function102dc3 ld de, String_102fdb hlcoord 1, 14 call PlaceString ret String_102fdb: db "ใ‚ใ„ใฆใŒใ‚<NO>ใ›ใ‚“ใŸใใซ" next "ใ„ใ˜ใ‚‡ใ†<PKMN>ใ‚ใ‚‹ใ‚ˆใ†ใงใ™๏ผ๏ผ" done Function102ff5: call Function102dc3 ld de, String_103002 hlcoord 1, 14 call PlaceString ret String_103002: db "ใใฎ#ใ‚’ใ€€ใ“ใ†ใ‹ใ‚“ใ™ใ‚‹ใจ" next "ใ›ใ‚“ใจใ†ใ€€ใงใใชใใ€€ใชใฃใกใ‚ƒใ†ใ‚ˆ๏ผ" db "@" Function103021: call Function102dc3 ld de, String_10302e hlcoord 1, 14 call PlaceString ret String_10302e: db "ใ‚ใ„ใฆใŒใ€€ใกใ‚…ใ†ใ—ใ‚’ใ€€ใˆใ‚‰ใ‚“ใ ใฎใง" next "ใ“ใ†ใ‹ใ‚“ใ‚’ใ€€ใกใ‚…ใ†ใ—ใ€€ใ—ใพใ™" db "@" Function10304f: xor a ld [wAttrMapEnd], a ld [wcf42], a ld [wcf44], a ld [wcf45], a ret Function10305d: nop ld a, [wAttrMapEnd] and a ret z call Function10307f ret c call Function103094 call Function10306e ret Function10306e: ld a, $01 ldh [hOAMUpdate], a call ClearSprites ld de, wVirtualOAM call Function1030cd xor a ldh [hOAMUpdate], a ret Function10307f: ld c, $02 ld hl, wcd4b bit 7, [hl] jr z, .asm_10308a ld c, $01 .asm_10308a ld hl, wcf45 inc [hl] ld a, [hl] cp c ret c xor a ld [hl], a ret Function103094: ld hl, wcd4b bit 7, [hl] jr nz, .asm_1030c0 ld a, [wcf42] bit 7, a jr nz, .asm_1030b2 ld a, [wcf44] inc a ld [wcf44], a cp $2c ret nz ld hl, wcf42 set 7, [hl] ret .asm_1030b2 ld a, [wcf44] dec a ld [wcf44], a ret nz ld hl, wcf42 res 7, [hl] ret .asm_1030c0 ld hl, wcf44 ld a, [hl] and a jr z, .asm_1030ca dec a ld [hl], a ret nz .asm_1030ca ld [hl], $2c ret Function1030cd: ld a, [wcf44] ld l, a ld h, 0 add hl, hl add hl, hl add hl, hl ld bc, Unknown_103112 add hl, bc ld b, $30 ld c, $08 .asm_1030de push hl ld hl, wcd4b bit 7, [hl] pop hl ld a, 0 jr z, .asm_1030eb ld a, $05 .asm_1030eb add [hl] inc hl push hl add a add a add LOW(Unknown_10327a) ld l, a ld a, HIGH(Unknown_10327a) adc 0 ld h, a ld a, b add [hl] inc hl ld [de], a inc de ld a, $0a add [hl] inc hl ld [de], a inc de ld a, [hli] ld [de], a inc de ld a, [hli] ld [de], a inc de pop hl ld a, b add $08 ld b, a dec c jr nz, .asm_1030de ret Unknown_103112: db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $01, $00, $00, $00, $00, $00, $00, $00 db $02, $01, $00, $00, $00, $00, $00, $00 db $03, $02, $01, $00, $00, $00, $00, $00 db $04, $03, $02, $01, $00, $00, $00, $00 db $04, $04, $03, $02, $01, $00, $00, $00 db $04, $04, $04, $03, $02, $01, $00, $00 db $04, $04, $04, $04, $03, $02, $01, $00 db $04, $04, $04, $04, $04, $03, $02, $01 db $04, $04, $04, $04, $04, $04, $03, $02 db $04, $04, $04, $04, $04, $04, $04, $03 db $04, $04, $04, $04, $04, $04, $04, $04 db $04, $04, $04, $04, $04, $04, $04, $04 db $04, $04, $04, $04, $04, $04, $04, $04 db $04, $04, $04, $04, $04, $04, $04, $04 db $04, $04, $04, $04, $04, $04, $04, $04 db $04, $04, $04, $04, $04, $04, $04, $04 db $04, $04, $04, $04, $04, $04, $04, $04 db $04, $04, $04, $04, $04, $04, $04, $04 db $03, $04, $04, $04, $04, $04, $04, $04 db $02, $03, $04, $04, $04, $04, $04, $04 db $01, $02, $03, $04, $04, $04, $04, $04 db $00, $01, $02, $03, $04, $04, $04, $04 db $00, $00, $01, $02, $03, $04, $04, $04 db $00, $00, $00, $01, $02, $03, $04, $04 db $00, $00, $00, $00, $01, $02, $03, $04 db $00, $00, $00, $00, $00, $01, $02, $03 db $00, $00, $00, $00, $00, $00, $01, $02 db $00, $00, $00, $00, $00, $00, $00, $01 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 db $00, $00, $00, $00, $00, $00, $00, $00 Unknown_10327a: db $00, $00, $00, $00 db $00, $00, $01, $00 db $00, $00, $02, $00 db $00, $00, $03, $00 db $00, $00, $01, $01 db $00, $00, $00, $00 db $00, $00, $01, $02 db $00, $00, $02, $02 db $00, $00, $03, $02 db $00, $00, $01, $03 GFX_1032a2: INCBIN "gfx/unknown/1032a2.2bpp" Palettes_1032e2: RGB 0, 0, 0 RGB 31, 31, 7 RGB 20, 31, 6 RGB 13, 20, 16 RGB 0, 0, 0 RGB 7, 11, 17 RGB 0, 0, 0 RGB 0, 0, 0 RGB 0, 0, 0 RGB 31, 24, 4 RGB 25, 12, 0 RGB 31, 7, 4 RGB 0, 0, 0 RGB 25, 0, 0 RGB 0, 0, 0 RGB 0, 0, 0 Function103302: call Function103309 call Function103362 ret Function103309: xor a ldh [hBGMapMode], a ld hl, wBuffer1 ld bc, 10 xor a call ByteFill ld a, $04 call GetSRAMBank ld a, [wdc41] ld [$a60c], a ld [wBuffer1], a call CloseSRAM call Function1035c6 ld a, [hli] ld e, a ld a, [hli] ld d, a ld a, [hli] ld c, a ld a, [hli] ld b, a ld a, [hli] ld [wd1ef], a ld a, [hli] ld [wd1ec], a ld a, [hli] ld [wd1ed], a ld h, d ld l, e call Function3eea ld hl, wd1ec ld a, [hli] ld h, [hl] ld l, a ld a, [hl] ld [wd1ee], a call Function1034be call UpdateSprites farcall HDMATransferAttrMapAndTileMapToWRAMBank3 ld a, $01 ld [wd1f0], a call Function10339a ret Function103362: .asm_103362 ld a, [wd1f0] ld [wd1f1], a call Function1033af call Function10339a call Function10342c farcall HDMATransferTileMapToWRAMBank3 ld a, [wBuffer2] bit 7, a jr z, .asm_103362 ld hl, wBuffer2 bit 6, [hl] jr z, .asm_103398 ld a, $04 call GetSRAMBank ld a, [wBuffer1] ld [$a60c], a ld [wdc41], a call CloseSRAM xor a ret .asm_103398 scf ret Function10339a: ld a, [wd1f0] ld [wd1f2], a ld c, a ld b, 0 ld hl, wd1ec ld a, [hli] ld h, [hl] ld l, a add hl, bc ld a, [hl] ld [wd1f3], a ret Function1033af: call GetJoypad ldh a, [hJoyPressed] bit D_LEFT_F, a jr nz, .left bit D_RIGHT_F, a jr nz, .right bit B_BUTTON_F, a jr nz, .b bit A_BUTTON_F, a jr nz, .a bit D_UP_F, a jr nz, .up bit D_DOWN_F, a jr nz, .down ret .up ld a, [wd1f0] dec a ld [wd1f0], a cp 1 ret nc ld a, [wd1ee] ld [wd1f0], a ret .down ld a, [wd1f0] inc a ld [wd1f0], a ld c, a ld a, [wd1ee] cp c ret nc ld a, 1 ld [wd1f0], a ret .b call PlayClickSFX ld hl, wBuffer2 set 7, [hl] ret .a ld a, [wd1f3] cp 3 jr nz, .a_return ld de, SFX_TRANSACTION call PlaySFX ld hl, wBuffer2 set 7, [hl] ld hl, wBuffer2 set 6, [hl] ret .left .right .a_return ld a, [wd1f3] cp 3 ret z ld de, SFX_PUSH_BUTTON call PlaySFX ld bc, 8 call Function10350f ld a, [wBuffer1] xor e ld [wBuffer1], a ret Function10342c: ld a, [wd1f0] ld [wd1f2], a call Function103490 call Function10343c call Function1034a7 ret Function10343c: ld a, [wd1f3] cp $02 jr nz, .asm_103452 ld bc, 1 call Function1034f7 ld c, $12 ld b, $01 call Function1034e0 jr .asm_10345f .asm_103452 ld bc, $ffed call Function1034f7 ld c, $12 ld b, $02 call Function1034e0 .asm_10345f ld bc, 0 call Function10350f ld bc, 1 call Function103487 ld bc, 8 call Function10350f ld a, [wBuffer1] and e ld bc, 2 jr z, .asm_10347d ld bc, 4 .asm_10347d call Function10350f ld bc, 11 call Function103487 ret Function103487: push de call Function1034f7 pop de call PlaceString ret Function103490: hlcoord 0, 15 ld c, $14 ld b, $03 call Function1034e0 ld bc, 6 call Function10350f hlcoord 1, 16 call PlaceString ret Function1034a7: ld a, [wd1f1] ld [wd1f2], a ld bc, 10 call Function1034f7 ld [hl], $7f ld bc, 10 call Function1034f1 ld [hl], $ed ret Function1034be: ld a, $01 ld [wd1f2], a ld hl, wd1ec ld a, [hli] ld h, [hl] ld l, a ld a, [hli] .asm_1034ca push af ld a, [hli] push hl ld [wd1f3], a call Function10343c ld hl, wd1f2 inc [hl] pop hl pop af dec a jr nz, .asm_1034ca call Function103490 ret Function1034e0: push bc push hl call ClearBox pop hl ld bc, wAttrMap - wTileMap add hl, bc pop bc ld a, $06 call FillBoxWithByte ret Function1034f1: ld a, [wd1f0] ld [wd1f2], a Function1034f7: hlcoord 0, 0 add hl, bc ld a, [wd1ef] ld bc, SCREEN_WIDTH call AddNTimes ld a, [wd1f2] dec a ld bc, 40 call AddNTimes ret Function10350f: ld a, [wd1f3] push bc ld hl, Unknown_103522 ld bc, 9 call AddNTimes pop bc add hl, bc ld a, [hli] ld d, [hl] ld e, a ret Unknown_103522: dw String_103546 dw String_103598 dw String_1035a0 dw String_10355f db $01 dw String_10354f dw String_1035a8 dw String_1035b1 dw String_103571 db $02 dw String_103557 dw String_1035ba dw String_1035bd dw String_103585 db $04 dw String_103545 dw String_1035c1 dw String_1035c1 dw String_103545 String_103545: db "@" String_103546: db "ใ›ใ‚“ใจใ†ใ€€ใ‚ขใƒ‹ใƒก@" String_10354f: db "ใงใ‚“ใ‚ใฐใ‚“ใ”ใ†@" String_103557: db "ใ‚ใ„ใ—ใ“ใ†ใ‹ใ‚“@" String_10355f: db "ใงใ‚“ใ‚ใ‚’ใ€€ใ‹ใ‘ใ‚‹ใฒใจใŒใ€€ใใ‚ใ‚‰ใ‚Œใ‚‹@" String_103571: db "ใงใ‚“ใ‚ใฐใ‚“ใ”ใ†ใฎใ€€ใซใ‚…ใ†ใ‚Šใ‚‡ใใฎใ—ใ‹ใŸ@" String_103585: db "ใ‚ใŸใ‚‰ใ—ใ„ใ‚ใ„ใ—ใŒใ€€ใ‚ใ‚Œใฐใ€€ใ“ใ†ใ‹ใ‚“@" String_103598: db "ใจใฐใ—ใฆใ€€ใฟใ‚‹@" String_1035a0: db "ใ˜ใฃใใ‚Šใ€€ใฟใ‚‹@" String_1035a8: db "ใ‚ใ„ใ—ใ‹ใ‚‰ใˆใ‚‰ใถ@" String_1035b1: db "ใ™ใ†ใ˜ใงใ€€ใ„ใ‚Œใ‚‹@" String_1035ba: db "ใ™ใ‚‹@" String_1035bd: db "ใ—ใชใ„@" String_1035c1: db "ใ‘ใฃใฆใ„@" Function1035c6: farcall Function10138b ld b, 0 ld hl, Unknown_1035d7 add hl, bc add hl, bc ld a, [hli] ld h, [hl] ld l, a ret Unknown_1035d7: dw Unknown_1035e7 dw Unknown_1035f3 dw Unknown_103608 dw Unknown_103608 dw Unknown_1035fe dw AskMobileOrCable dw AskMobileOrCable dw AskMobileOrCable Unknown_1035e7: dwcoord 0, 6 db $12, $07, $07 dw .this .this db 4, 2, 1, 0, 3 Unknown_1035f3: dwcoord 0, 7 db $12, $06, $09 dw .this .this db 3, 2, 1, 3 Unknown_1035fe: dwcoord 0, 9 db $12, $04, $0b dw .this .this db 2, 0, 3 Unknown_103608: dwcoord 0, 9 db $12, $04, $0b dw .this .this db 2, 2, 3 AskMobileOrCable: ld hl, MenuHeader_103640 call LoadMenuHeader ld a, [wMobileOrCable_LastSelection] and $0f jr z, .skip_load ld [wMenuCursorBuffer], a .skip_load call VerticalMenu call CloseWindow jr c, .pressed_b ld a, [wMenuCursorY] ld [wScriptVar], a ld c, a ld a, [wMobileOrCable_LastSelection] and $f0 or c ld [wMobileOrCable_LastSelection], a ret .pressed_b xor a ld [wScriptVar], a ret MenuHeader_103640: db MENU_BACKUP_TILES ; flags menu_coords 13, 6, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw MenuData_103648 db 1 ; default option MenuData_103648: db STATICMENU_CURSOR ; flags db 2 db "ใƒขใƒใ‚คใƒซ@" db "ใ‚ฑใƒผใƒ–ใƒซ@" Function103654: farcall Mobile_AlwaysReturnNotCarry bit 7, c jr nz, .asm_103666 ld hl, wcd2a res 5, [hl] ld c, $02 ret .asm_103666 ld hl, wcd2a set 5, [hl] ld c, $01 ret Mobile_SelectThreeMons: farcall Mobile_AlwaysReturnNotCarry bit 7, c jr z, .asm_10369b ld hl, UnknownText_0x10375d call PrintText call YesNoBox jr c, .asm_103696 farcall CheckForMobileBattleRules jr nc, .asm_103690 call JoyWaitAorB jr .asm_103696 .asm_103690 ld a, $01 ld [wScriptVar], a ret .asm_103696 xor a ld [wScriptVar], a ret .asm_10369b ld hl, wMobileOrCable_LastSelection bit 7, [hl] set 7, [hl] jr nz, .asm_1036b5 ld hl, UnknownText_0x103762 call PrintText call YesNoBox jr c, .asm_1036b5 call Function1036f9 call JoyWaitAorB .asm_1036b5 call Function103700 jr c, .asm_1036f4 ld hl, MenuHeader_103747 call LoadMenuHeader call VerticalMenu call ExitMenu jr c, .asm_1036f4 ld a, [wMenuCursorY] cp $01 jr z, .asm_1036d9 cp $02 jr z, .asm_1036f4 cp $03 jr z, .asm_1036ec jr .asm_1036b5 .asm_1036d9 farcall CheckForMobileBattleRules jr nc, .asm_1036e6 call JoyWaitAorB jr .asm_1036f4 .asm_1036e6 ld a, $01 ld [wScriptVar], a ret .asm_1036ec call Function1036f9 call JoyWaitAorB jr .asm_1036b5 .asm_1036f4 xor a ld [wScriptVar], a ret Function1036f9: ld hl, UnknownText_0x103767 call PrintText ret Function103700: ld c, $0a ld hl, wSwarmFlags bit SWARMFLAGS_MOBILE_4_F, [hl] jr z, .asm_10370f farcall Function1008a6 .asm_10370f ld a, c ld [wStringBuffer2], a ld a, [wStringBuffer2] cp $05 jr nc, .asm_103724 cp $02 jr nc, .asm_10372c cp $01 jr nc, .asm_103734 jr .asm_10373c .asm_103724 ld hl, UnknownText_0x10376c call PrintText and a ret .asm_10372c ld hl, UnknownText_0x103771 call PrintText and a ret .asm_103734 ld hl, UnknownText_0x103776 call PrintText and a ret .asm_10373c ld hl, UnknownText_0x10377b call PrintText call JoyWaitAorB scf ret MenuHeader_103747: db MENU_BACKUP_TILES ; flags menu_coords 13, 5, SCREEN_WIDTH - 1, TEXTBOX_Y - 1 dw MenuData_10374f db 1 ; default option MenuData_10374f: db STATICMENU_CURSOR | STATICMENU_NO_TOP_SPACING ; flags db 3 db "ใฏใ„@" db "ใ‚„ใ‚ใ‚‹@" db "ใ›ใคใ‚ใ„@" UnknownText_0x10375d: text_far UnknownText_0x1c422a text_end UnknownText_0x103762: text_far UnknownText_0x1c4275 text_end UnknownText_0x103767: text_far UnknownText_0x1c4298 text_end UnknownText_0x10376c: text_far UnknownText_0x1c439c text_end UnknownText_0x103771: text_far UnknownText_0x1c43dc text_end UnknownText_0x103776: text_far UnknownText_0x1c4419 text_end UnknownText_0x10377b: text_far UnknownText_0x1c445a text_end Function103780: ld a, [wChosenCableClubRoom] push af call Function10378c pop af ld [wChosenCableClubRoom], a ret Function10378c: ld c, 0 ld hl, wSwarmFlags bit SWARMFLAGS_MOBILE_4_F, [hl] jr nz, .already_set ld c, 1 ld hl, wSwarmFlags set SWARMFLAGS_MOBILE_4_F, [hl] .already_set push bc farcall Link_SaveGame pop bc jr c, .failed_to_save ld a, 1 ld [wScriptVar], a ld a, c and a ret z farcall Function1006fd ret .failed_to_save xor a ld [wScriptVar], a ld a, c and a ret z ld hl, wSwarmFlags res SWARMFLAGS_MOBILE_4_F, [hl] ret Function1037c2: call Function103823 jr c, .nope ld a, [wdc5f] and a jr z, .nope ld hl, UnknownText_0x1037e6 call PrintText call YesNoBox jr c, .nope ld a, $01 ld [wScriptVar], a ret .nope xor a ld [wdc5f], a ld [wScriptVar], a ret UnknownText_0x1037e6: text_far UnknownText_0x1c449c text_end Function1037eb: call Function103823 jr nc, .asm_103807 ld hl, UnknownText_0x103819 call PrintText call JoyWaitAorB ld hl, UnknownText_0x10381e call PrintText call JoyWaitAorB xor a ld [wScriptVar], a ret .asm_103807 ld a, [wdc60] and a jr nz, .asm_103813 ld a, $01 ld [wScriptVar], a ret .asm_103813 ld a, $02 ld [wScriptVar], a ret UnknownText_0x103819: text_far UnknownText_0x1c44c0 text_end UnknownText_0x10381e: text_far UnknownText_0x1c44e7 text_end Function103823: farcall Mobile_AlwaysReturnNotCarry bit 7, c jr nz, .asm_103838 farcall Function1008a6 ld a, c cp $01 jr c, .asm_10383a .asm_103838 xor a ret .asm_10383a scf ret Function10383c: ld a, $01 ld [wdc60], a xor a ld hl, wPlayerMonSelection ld [hli], a ld [hli], a ld [hl], a ld hl, UnknownText_0x103876 call PrintText call JoyWaitAorB farcall Script_reloadmappart farcall Function4a94e jr c, .asm_103870 ld hl, wd002 ld de, wPlayerMonSelection ld bc, 3 call CopyBytes xor a ld [wScriptVar], a ret .asm_103870 ld a, $01 ld [wScriptVar], a ret UnknownText_0x103876: text_far UnknownText_0x1c4508 text_end Function10387b: farcall Mobile_AlwaysReturnNotCarry bit 7, c ret nz farcall Function1008a6 ld a, c ld [wStringBuffer2], a ld hl, UnknownText_0x103898 call PrintText call JoyWaitAorB ret UnknownText_0x103898: text_far UnknownText_0x1c4525 text_end
;code by unic0rn/Asm Force org 100h segment .code mov al,13h int 10h xor ax,ax mov dx,03C8h out dx,al inc dx pal: push ax mov cl,al shr al,2 and cl,0Fh cmp cl,0Fh je ps1 ror ax,1 ps1: out dx,al out dx,al je ps2 rol ax,1 ps2: out dx,al pop ax inc al jne pal push 9000h pop ds push 0A000h pop es push 8000h pop gs mov bx,sm stars: push ds push cs pop ds mov si,[bx] l1: cmp byte [gs:si],0 jne s11 mov di,si shl di,4 add di,[bx] rdtsc xor eax,[bx+14] push ax cbw mov [di],ax pop ax mov al,ah cbw mov [di+2],ax mov dword [di+4],43800000h bswap eax xor ah,ah inc ax mov [di+8],ax inc byte [gs:si] add dword [bx+14],eax s11: dec si jne l1 pop ds not cx l2: cmp byte [si],0 je s21 sub byte [si],17 jnc s21 mov byte [si],0 s21: inc si loop l2 push ds push cs pop ds inc dword [bx+4] mov si,[bx] l3: mov di,si shl di,4 add di,[bx] fild word [di+8] fmul dword [bx-4] fld dword [di+4] fsubrp st1,st0 fst dword [di+4] xor bp,bp clc call scalc inc bp inc bp stc call scalc fistp word [bx+12] mov ax,[bx+10] cmp ax,cx js s31 cmp ax,200 jnc s31 imul ax,320 mov dx,[bx+8] add dx,60 cmp dx,cx js s31 cmp dx,320 jnc s31 add ax,dx xchg ax,si xor dl,dl sub dl,[bx+12] or dl,0Fh pop ds mov [si],dl push ds push cs pop ds xchg ax,si jmp s32 s31: mov byte [gs:si],cl s32: dec si jne l3 pop ds not cx xor si,si xor di,di rep movsb in al,60h dec al jnz stars ret scalc: fild word [di+bp] fimul word [bx] fdiv st1 fild dword [bx+4] fmul dword [bx-4] jc sc1 fcos jmp sc2 sc1: fsin sc2: fld1 faddp st1,st0 fimul word [bx+2] faddp st1,st0 fistp word [time+bp+4] ret tm: dd 0.0028 sm: dw 768 hm: dw 100 time:
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x19ad, %r8 nop cmp %rdx, %rdx movups (%r8), %xmm4 vpextrq $0, %xmm4, %rdi nop nop nop nop sub $47133, %rcx lea addresses_A_ht+0x1ad41, %rsi clflush (%rsi) nop dec %rbx movups (%rsi), %xmm0 vpextrq $1, %xmm0, %r12 nop nop nop nop dec %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r15 push %r9 push %rdx // Faulty Load lea addresses_normal+0xaa2d, %r11 nop nop nop nop nop add $64522, %r9 mov (%r11), %r14d lea oracles, %r15 and $0xff, %r14 shlq $12, %r14 mov (%r15,%r14,1), %r14 pop %rdx pop %r9 pop %r15 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_normal', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_normal', 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_D_ht', 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_A_ht', 'congruent': 2}} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
// Copyright 2019 Amazon.com, Inc. or its affiliates. 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. #ifndef RUNNER__RUNNER_HPP_ #define RUNNER__RUNNER_HPP_ #include <future> #include <memory> #include <string> #include <vector> #include "rclcpp/executor.hpp" #include "rclcpp/logger.hpp" #include "rclcpp/node.hpp" #include "rclcpp_lifecycle/lifecycle_node.hpp" #include "rcutils/logging_macros.h" #include "utilities/lifecycle_service_client.hpp" namespace ros_sec_test { namespace runner { /// Main class containing the whole application logic, instantiated in main(). /** * Runner holds a ROS 2 node and one additional lifecycle_node per enabled attack node. * * The additional ROS 2 node (node_) is used to keep isolated from attack nodes the * calls to the services managing the lifecycle nodes. * * Attack nodes are set a instantiation time and can *never* be changed. * * The only public method exposed by this class is spin() which starts, execute the attacks * and stop all the nodes when needed. */ class Runner { public: /// Instantiate all nodes from parameter without activating them. /** * CAVEAT: rclcpp::init() *must* be called before instantiating this object. */ Runner(); /// Use a vector of already instantiated nodes. /** * CAVEAT: rclcpp::init() *must* be called before instantiating this object. */ explicit Runner(const std::vector<rclcpp_lifecycle::LifecycleNode::SharedPtr> & attack_nodes); Runner(const Runner &) = delete; Runner & operator=(const Runner &) = delete; /// Starts, executes all attacks and shutdown all nodes. void spin(); private: /// Holds a shared pointer to a node and the associated lifecycle client. struct AttackNodeData { rclcpp_lifecycle::LifecycleNode::SharedPtr node; /// Wraps lifecycle service calls in a conveninent interface. std::shared_ptr<utilities::LifecycleServiceClient> lifecycle_client; }; /// Execute all attacks synchronously. /** * Running attacks in a different thread allow us to spin from the main thread. */ std::future<void> execute_all_attacks_async(); /// Initialize the attack_nodes_ attributes. Invoked from the class constructor. /** * \param[in] node_names All attack nodes to be instantiated. */ void initialize_attack_nodes(const std::vector<std::string> & node_names); /// Read the list of attacks to be run from the node parameter. /** * \return Names of all enabled attacks. */ std::vector<std::string> retrieve_attack_nodes_names(); /// Read the attack duration in seconds from the node parameter. /** * \return Duration of attack in seconds. */ std::chrono::seconds retrieve_attack_duration_s(); /// Relies on lifecycle client to start and stop all attacks. void start_and_stop_all_nodes(); /// Log a message explaining that no attack have been specified and the runner will do nothing. void warn_user_no_attack_nodes_passed(); /// Create a separate node to send lifecycle requests. rclcpp::Node::SharedPtr node_; /// Contain all attack nodes information. std::vector<AttackNodeData> attack_nodes_; /// Executor shared by all nodes. rclcpp::executors::SingleThreadedExecutor executor_; rclcpp::Logger logger_; }; } // namespace runner } // namespace ros_sec_test #endif // RUNNER__RUNNER_HPP_
; A295683: a(n) = a(n-1) + a(n-3) + a(n-4), where a(0) = 2, a(1) = 1, a(2) = 0, a(3) = 1. ; Submitted by Jon Maiga ; 2,1,0,1,4,5,6,11,20,31,48,79,130,209,336,545,884,1429,2310,3739,6052,9791,15840,25631,41474,67105,108576,175681,284260,459941,744198,1204139,1948340,3152479,5100816,8253295,13354114,21607409,34961520,56568929,91530452,148099381,239629830,387729211,627359044,1015088255,1642447296,2657535551,4299982850,6957518401,11257501248,18215019649,29472520900,47687540549,77160061446,124847601995,202007663444,326855265439,528862928880,855718194319,1384581123202,2240299317521,3624880440720,5865179758241 mov $1,2 mov $2,1 mov $4,-1 lpb $0 sub $0,1 sub $3,$4 mov $4,$2 mov $2,$3 add $2,$1 mov $1,$3 add $5,$4 mov $3,$5 lpe mov $0,$1
; A026058: a(n) = (d(n)-r(n))/2, where d = A026057 and r is the periodic sequence with fundamental period (0,0,1,0). ; 13,25,41,63,90,123,162,209,263,325,395,475,564,663,772,893,1025,1169,1325,1495,1678,1875,2086,2313,2555,2813,3087,3379,3688,4015,4360,4725,5109,5513,5937,6383,6850,7339,7850,8385,8943,9525,10131,10763,11420,12103,12812,13549,14313,15105,15925 mov $1,$0 mov $2,$0 add $2,2 mov $4,$0 lpb $2,1 add $0,$2 mov $3,1 add $3,$2 lpb $0,1 sub $0,1 add $1,$2 lpe sub $1,$2 add $1,$3 sub $2,1 trn $2,3 lpe lpb $4,1 add $1,3 sub $4,1 lpe add $1,8
//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007-2017 Laurent Gomila (laurent@sfml-dev.org) // // This software is provided 'as-is', without any express or implied warranty. // In no event will the authors be held liable for any damages arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it freely, // subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; // you must not claim that you wrote the original software. // If you use this software in a product, an acknowledgment // in the product documentation would be appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, // and must not be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // //////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T>::Vector2() : x(0), y(0) { } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T>::Vector2(T X, T Y) : x(X), y(Y) { } //////////////////////////////////////////////////////////// template <typename T> template <typename U> inline Vector2<T>::Vector2(const Vector2<U>& vector) : x(static_cast<T>(vector.x)), y(static_cast<T>(vector.y)) { } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T> operator -(const Vector2<T>& right) { return Vector2<T>(-right.x, -right.y); } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T>& operator +=(Vector2<T>& left, const Vector2<T>& right) { left.x += right.x; left.y += right.y; return left; } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T>& operator -=(Vector2<T>& left, const Vector2<T>& right) { left.x -= right.x; left.y -= right.y; return left; } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T> operator +(const Vector2<T>& left, const Vector2<T>& right) { return Vector2<T>(left.x + right.x, left.y + right.y); } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T> operator -(const Vector2<T>& left, const Vector2<T>& right) { return Vector2<T>(left.x - right.x, left.y - right.y); } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T> operator *(const Vector2<T>& left, T right) { return Vector2<T>(left.x * right, left.y * right); } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T> operator *(T left, const Vector2<T>& right) { return Vector2<T>(right.x * left, right.y * left); } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T>& operator *=(Vector2<T>& left, T right) { left.x *= right; left.y *= right; return left; } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T> operator /(const Vector2<T>& left, T right) { return Vector2<T>(left.x / right, left.y / right); } //////////////////////////////////////////////////////////// template <typename T> inline Vector2<T>& operator /=(Vector2<T>& left, T right) { left.x /= right; left.y /= right; return left; } //////////////////////////////////////////////////////////// template <typename T> inline bool operator ==(const Vector2<T>& left, const Vector2<T>& right) { return (left.x == right.x) && (left.y == right.y); } //////////////////////////////////////////////////////////// template <typename T> inline bool operator !=(const Vector2<T>& left, const Vector2<T>& right) { return (left.x != right.x) || (left.y != right.y); }
Name: zel_mpdt.asm Type: file Size: 269850 Last-Modified: '2016-05-13T04:36:32Z' SHA-1: C9C5750DE42B4CAC127993B51DF2B6A355FCB988 Description: null
//===-- AVRAsmBackend.cpp - AVR Asm Backend ------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // This file implements the AVRAsmBackend class. // //===----------------------------------------------------------------------===// #include "MCTargetDesc/AVRAsmBackend.h" #include "MCTargetDesc/AVRFixupKinds.h" #include "MCTargetDesc/AVRMCTargetDesc.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDirectives.h" #include "llvm/MC/MCELFObjectWriter.h" #include "llvm/MC/MCFixupKindInfo.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCValue.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" // FIXME: we should be doing checks to make sure asm operands // are not out of bounds. namespace adjust { using namespace llvm; void signed_width(unsigned Width, uint64_t Value, std::string Description, const MCFixup &Fixup, MCContext *Ctx = nullptr) { if (!isIntN(Width, Value)) { std::string Diagnostic = "out of range " + Description; int64_t Min = minIntN(Width); int64_t Max = maxIntN(Width); Diagnostic += " (expected an integer in the range " + std::to_string(Min) + " to " + std::to_string(Max) + ")"; if (Ctx) { Ctx->reportFatalError(Fixup.getLoc(), Diagnostic); } else { llvm_unreachable(Diagnostic.c_str()); } } } void unsigned_width(unsigned Width, uint64_t Value, std::string Description, const MCFixup &Fixup, MCContext *Ctx = nullptr) { if (!isUIntN(Width, Value)) { std::string Diagnostic = "out of range " + Description; int64_t Max = maxUIntN(Width); Diagnostic += " (expected an integer in the range 0 to " + std::to_string(Max) + ")"; if (Ctx) { Ctx->reportFatalError(Fixup.getLoc(), Diagnostic); } else { llvm_unreachable(Diagnostic.c_str()); } } } /// Adjusts the value of a branch target before fixup application. void adjustBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { // We have one extra bit of precision because the value is rightshifted by // one. unsigned_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx); // Rightshifts the value by one. AVR::fixups::adjustBranchTarget(Value); } /// Adjusts the value of a relative branch target before fixup application. void adjustRelativeBranch(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { // We have one extra bit of precision because the value is rightshifted by // one. signed_width(Size + 1, Value, std::string("branch target"), Fixup, Ctx); Value -= 2; // Rightshifts the value by one. AVR::fixups::adjustBranchTarget(Value); } /// 22-bit absolute fixup. /// /// Resolves to: /// 1001 kkkk 010k kkkk kkkk kkkk 111k kkkk /// /// Offset of 0 (so the result is left shifted by 3 bits before application). void fixup_call(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { adjustBranch(Size, Fixup, Value, Ctx); auto top = Value & (0xf00000 << 6); // the top four bits auto middle = Value & (0x1ffff << 5); // the middle 13 bits auto bottom = Value & 0x1f; // end bottom 5 bits Value = (top << 6) | (middle << 3) | (bottom << 0); } /// 7-bit PC-relative fixup. /// /// Resolves to: /// 0000 00kk kkkk k000 /// Offset of 0 (so the result is left shifted by 3 bits before application). void fixup_7_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { adjustRelativeBranch(Size, Fixup, Value, Ctx); // Because the value may be negative, we must mask out the sign bits Value &= 0x7f; } /// 12-bit PC-relative fixup. /// Yes, the fixup is 12 bits even though the name says otherwise. /// /// Resolves to: /// 0000 kkkk kkkk kkkk /// Offset of 0 (so the result isn't left-shifted before application). void fixup_13_pcrel(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { adjustRelativeBranch(Size, Fixup, Value, Ctx); // Because the value may be negative, we must mask out the sign bits Value &= 0xfff; } /// 6-bit fixup for the immediate operand of the ADIW family of /// instructions. /// /// Resolves to: /// 0000 0000 kk00 kkkk void fixup_6_adiw(const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { unsigned_width(6, Value, std::string("immediate"), Fixup, Ctx); Value = ((Value & 0x30) << 2) | (Value & 0x0f); } /// 5-bit port number fixup on the SBIC family of instructions. /// /// Resolves to: /// 0000 0000 AAAA A000 void fixup_port5(const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { unsigned_width(5, Value, std::string("port number"), Fixup, Ctx); Value &= 0x1f; Value <<= 3; } /// 6-bit port number fixup on the `IN` family of instructions. /// /// Resolves to: /// 1011 0AAd dddd AAAA void fixup_port6(const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { unsigned_width(6, Value, std::string("port number"), Fixup, Ctx); Value = ((Value & 0x30) << 5) | (Value & 0x0f); } /// Adjusts a program memory address. /// This is a simple right-shift. void pm(uint64_t &Value) { Value >>= 1; } /// Fixups relating to the LDI instruction. namespace ldi { /// Adjusts a value to fix up the immediate of an `LDI Rd, K` instruction. /// /// Resolves to: /// 0000 KKKK 0000 KKKK /// Offset of 0 (so the result isn't left-shifted before application). void fixup(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { uint64_t upper = Value & 0xf0; uint64_t lower = Value & 0x0f; Value = (upper << 4) | lower; } void neg(uint64_t &Value) { Value *= -1; } void lo8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { Value &= 0xff; ldi::fixup(Size, Fixup, Value, Ctx); } void hi8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { Value = (Value & 0xff00) >> 8; ldi::fixup(Size, Fixup, Value, Ctx); } void hh8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { Value = (Value & 0xff0000) >> 16; ldi::fixup(Size, Fixup, Value, Ctx); } void ms8(unsigned Size, const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx = nullptr) { Value = (Value & 0xff000000) >> 24; ldi::fixup(Size, Fixup, Value, Ctx); } } // end of ldi namespace } // end of adjust namespace namespace llvm { // Prepare value for the target space for it void AVRAsmBackend::adjustFixupValue(const MCFixup &Fixup, uint64_t &Value, MCContext *Ctx) const { // The size of the fixup in bits. uint64_t Size = AVRAsmBackend::getFixupKindInfo(Fixup.getKind()).TargetSize; unsigned Kind = Fixup.getKind(); switch (Kind) { default: llvm_unreachable("unhandled fixup"); case AVR::fixup_7_pcrel: adjust::fixup_7_pcrel(Size, Fixup, Value, Ctx); break; case AVR::fixup_13_pcrel: adjust::fixup_13_pcrel(Size, Fixup, Value, Ctx); break; case AVR::fixup_call: adjust::fixup_call(Size, Fixup, Value, Ctx); break; case AVR::fixup_ldi: adjust::ldi::fixup(Size, Fixup, Value, Ctx); break; case AVR::fixup_lo8_ldi: case AVR::fixup_lo8_ldi_pm: if (Kind == AVR::fixup_lo8_ldi_pm) adjust::pm(Value); adjust::ldi::lo8(Size, Fixup, Value, Ctx); break; case AVR::fixup_hi8_ldi: case AVR::fixup_hi8_ldi_pm: if (Kind == AVR::fixup_hi8_ldi_pm) adjust::pm(Value); adjust::ldi::hi8(Size, Fixup, Value, Ctx); break; case AVR::fixup_hh8_ldi: case AVR::fixup_hh8_ldi_pm: if (Kind == AVR::fixup_hh8_ldi_pm) adjust::pm(Value); adjust::ldi::hh8(Size, Fixup, Value, Ctx); break; case AVR::fixup_ms8_ldi: adjust::ldi::ms8(Size, Fixup, Value, Ctx); break; case AVR::fixup_lo8_ldi_neg: case AVR::fixup_lo8_ldi_pm_neg: if (Kind == AVR::fixup_lo8_ldi_pm_neg) adjust::pm(Value); adjust::ldi::neg(Value); adjust::ldi::lo8(Size, Fixup, Value, Ctx); break; case AVR::fixup_hi8_ldi_neg: case AVR::fixup_hi8_ldi_pm_neg: if (Kind == AVR::fixup_hi8_ldi_pm_neg) adjust::pm(Value); adjust::ldi::neg(Value); adjust::ldi::hi8(Size, Fixup, Value, Ctx); break; case AVR::fixup_hh8_ldi_neg: case AVR::fixup_hh8_ldi_pm_neg: if (Kind == AVR::fixup_hh8_ldi_pm_neg) adjust::pm(Value); adjust::ldi::neg(Value); adjust::ldi::hh8(Size, Fixup, Value, Ctx); break; case AVR::fixup_ms8_ldi_neg: adjust::ldi::neg(Value); adjust::ldi::ms8(Size, Fixup, Value, Ctx); break; case AVR::fixup_16: adjust::unsigned_width(16, Value, std::string("port number"), Fixup, Ctx); Value &= 0xffff; break; case AVR::fixup_6_adiw: adjust::fixup_6_adiw(Fixup, Value, Ctx); break; case AVR::fixup_port5: adjust::fixup_port5(Fixup, Value, Ctx); break; case AVR::fixup_port6: adjust::fixup_port6(Fixup, Value, Ctx); break; // Fixups which do not require adjustments. case FK_Data_2: case FK_Data_4: case FK_Data_8: break; case FK_GPRel_4: llvm_unreachable("don't know how to adjust this fixup"); break; } } MCObjectWriter *AVRAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const { return createAVRELFObjectWriter(OS, MCELFObjectTargetWriter::getOSABI(OSType)); } void AVRAsmBackend::applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, uint64_t Value, bool IsPCRel) const { if (Value == 0) return; // Doesn't change encoding. MCFixupKindInfo Info = getFixupKindInfo(Fixup.getKind()); // The number of bits in the fixup mask auto NumBits = Info.TargetSize + Info.TargetOffset; auto NumBytes = (NumBits / 8) + ((NumBits % 8) == 0 ? 0 : 1); // Shift the value into position. Value <<= Info.TargetOffset; unsigned Offset = Fixup.getOffset(); assert(Offset + NumBytes <= DataSize && "Invalid fixup offset!"); // For each byte of the fragment that the fixup touches, mask in the // bits from the fixup value. for (unsigned i = 0; i < NumBytes; ++i) { uint8_t mask = (((Value >> (i * 8)) & 0xff)); Data[Offset + i] |= mask; } } MCFixupKindInfo const &AVRAsmBackend::getFixupKindInfo(MCFixupKind Kind) const { // NOTE: Many AVR fixups work on sets of non-contignous bits. We work around // this by saying that the fixup is the size of the entire instruction. const static MCFixupKindInfo Infos[AVR::NumTargetFixupKinds] = { // This table *must* be in same the order of fixup_* kinds in // AVRFixupKinds.h. // // name offset bits flags {"fixup_32", 0, 32, 0}, {"fixup_7_pcrel", 3, 7, MCFixupKindInfo::FKF_IsPCRel}, {"fixup_13_pcrel", 0, 12, MCFixupKindInfo::FKF_IsPCRel}, {"fixup_16", 0, 16, 0}, {"fixup_16_pm", 0, 16, 0}, {"fixup_ldi", 0, 8, 0}, {"fixup_lo8_ldi", 0, 8, 0}, {"fixup_hi8_ldi", 0, 8, 0}, {"fixup_hh8_ldi", 0, 8, 0}, {"fixup_ms8_ldi", 0, 8, 0}, {"fixup_lo8_ldi_neg", 0, 8, 0}, {"fixup_hi8_ldi_neg", 0, 8, 0}, {"fixup_hh8_ldi_neg", 0, 8, 0}, {"fixup_ms8_ldi_neg", 0, 8, 0}, {"fixup_lo8_ldi_pm", 0, 8, 0}, {"fixup_hi8_ldi_pm", 0, 8, 0}, {"fixup_hh8_ldi_pm", 0, 8, 0}, {"fixup_lo8_ldi_pm_neg", 0, 8, 0}, {"fixup_hi8_ldi_pm_neg", 0, 8, 0}, {"fixup_hh8_ldi_pm_neg", 0, 8, 0}, {"fixup_call", 0, 22, 0}, {"fixup_6", 0, 16, 0}, // non-contiguous {"fixup_6_adiw", 0, 6, 0}, {"fixup_lo8_ldi_gs", 0, 8, 0}, {"fixup_hi8_ldi_gs", 0, 8, 0}, {"fixup_8", 0, 8, 0}, {"fixup_8_lo8", 0, 8, 0}, {"fixup_8_hi8", 0, 8, 0}, {"fixup_8_hlo8", 0, 8, 0}, {"fixup_sym_diff", 0, 32, 0}, {"fixup_16_ldst", 0, 16, 0}, {"fixup_lds_sts_16", 0, 16, 0}, {"fixup_port6", 0, 16, 0}, // non-contiguous {"fixup_port5", 3, 5, 0}, }; if (Kind < FirstTargetFixupKind) return MCAsmBackend::getFixupKindInfo(Kind); assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && "Invalid kind!"); return Infos[Kind - FirstTargetFixupKind]; } bool AVRAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const { // If the count is not 2-byte aligned, we must be writing data into the text // section (otherwise we have unaligned instructions, and thus have far // bigger problems), so just write zeros instead. assert((Count % 2) == 0 && "NOP instructions must be 2 bytes"); OW->WriteZeros(Count); return true; } void AVRAsmBackend::processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFixup &Fixup, const MCFragment *DF, const MCValue &Target, uint64_t &Value, bool &IsResolved) { switch ((unsigned) Fixup.getKind()) { // Fixups which should always be recorded as relocations. case AVR::fixup_7_pcrel: case AVR::fixup_13_pcrel: case AVR::fixup_call: IsResolved = false; break; default: // Parsed LLVM-generated temporary labels are already // adjusted for instruction size, but normal labels aren't. // // To handle both cases, we simply un-adjust the temporary label // case so it acts like all other labels. if (Target.getSymA()->getSymbol().isTemporary()) Value += 2; adjustFixupValue(Fixup, Value, &Asm.getContext()); break; } } MCAsmBackend *createAVRAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU, const llvm::MCTargetOptions &TO) { return new AVRAsmBackend(TT.getOS()); } } // end of namespace llvm
;*! ;* \copy ;* Copyright (c) 2004-2013, Cisco Systems ;* All rights reserved. ;* ;* Redistribution and use in source and binary forms, with or without ;* modification, are permitted provided that the following conditions ;* are met: ;* ;* * Redistributions of source code must retain the above copyright ;* notice, this list of conditions and the following disclaimer. ;* ;* * Redistributions in binary form must reproduce the above copyright ;* notice, this list of conditions and the following disclaimer in ;* the documentation and/or other materials provided with the ;* distribution. ;* ;* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ;* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ;* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ;* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ;* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ;* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ;* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ;* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ;* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ;* POSSIBILITY OF SUCH DAMAGE. ;* ;* ;* mc_chroma.asm ;* ;* Abstract ;* mmx motion compensation for chroma ;* ;* History ;* 10/13/2004 Created ;* ;* ;*************************************************************************/ %include "asm_inc.asm" ;*********************************************************************** ; Local Data (Read Only) ;*********************************************************************** SECTION .rodata align=16 ;*********************************************************************** ; Various memory constants (trigonometric values or rounding values) ;*********************************************************************** ALIGN 16 h264_d0x20_sse2: dw 32,32,32,32,32,32,32,32 ALIGN 16 h264_d0x20_mmx: dw 32,32,32,32 ;============================================================================= ; Code ;============================================================================= SECTION .text ;******************************************************************************* ; void McChromaWidthEq4_mmx( const uint8_t *src, ; int32_t iSrcStride, ; uint8_t *pDst, ; int32_t iDstStride, ; const uint8_t *pABCD, ; int32_t iHeigh ); ;******************************************************************************* WELS_EXTERN McChromaWidthEq4_mmx %assign push_num 0 LOAD_6_PARA SIGN_EXTENSION r1, r1d SIGN_EXTENSION r3, r3d SIGN_EXTENSION r5, r5d movd mm3, [r4]; [eax] WELS_Zero mm7 punpcklbw mm3, mm3 movq mm4, mm3 punpcklwd mm3, mm3 punpckhwd mm4, mm4 movq mm5, mm3 punpcklbw mm3, mm7 punpckhbw mm5, mm7 movq mm6, mm4 punpcklbw mm4, mm7 punpckhbw mm6, mm7 lea r4, [r0 + r1] ;lea ebx, [esi + eax] movd mm0, [r0] movd mm1, [r0+1] punpcklbw mm0, mm7 punpcklbw mm1, mm7 .xloop: pmullw mm0, mm3 pmullw mm1, mm5 paddw mm0, mm1 movd mm1, [r4] punpcklbw mm1, mm7 movq mm2, mm1 pmullw mm1, mm4 paddw mm0, mm1 movd mm1, [r4+1] punpcklbw mm1, mm7 movq mm7, mm1 pmullw mm1,mm6 paddw mm0, mm1 movq mm1,mm7 paddw mm0, [h264_d0x20_mmx] psrlw mm0, 6 WELS_Zero mm7 packuswb mm0, mm7 movd [r2], mm0 movq mm0, mm2 lea r2, [r2 + r3] lea r4, [r4 + r1] dec r5 jnz near .xloop WELSEMMS LOAD_6_PARA_POP ret ;******************************************************************************* ; void McChromaWidthEq8_sse2( const uint8_t *pSrc, ; int32_t iSrcStride, ; uint8_t *pDst, ; int32_t iDstStride, ; const uint8_t *pABCD, ; int32_t iheigh ); ;******************************************************************************* WELS_EXTERN McChromaWidthEq8_sse2 %assign push_num 0 LOAD_6_PARA PUSH_XMM 8 SIGN_EXTENSION r1, r1d SIGN_EXTENSION r3, r3d SIGN_EXTENSION r5, r5d movd xmm3, [r4] WELS_Zero xmm7 punpcklbw xmm3, xmm3 punpcklwd xmm3, xmm3 movdqa xmm4, xmm3 punpckldq xmm3, xmm3 punpckhdq xmm4, xmm4 movdqa xmm5, xmm3 movdqa xmm6, xmm4 punpcklbw xmm3, xmm7 punpckhbw xmm5, xmm7 punpcklbw xmm4, xmm7 punpckhbw xmm6, xmm7 lea r4, [r0 + r1] ;lea ebx, [esi + eax] movq xmm0, [r0] movq xmm1, [r0+1] punpcklbw xmm0, xmm7 punpcklbw xmm1, xmm7 .xloop: pmullw xmm0, xmm3 pmullw xmm1, xmm5 paddw xmm0, xmm1 movq xmm1, [r4] punpcklbw xmm1, xmm7 movdqa xmm2, xmm1 pmullw xmm1, xmm4 paddw xmm0, xmm1 movq xmm1, [r4+1] punpcklbw xmm1, xmm7 movdqa xmm7, xmm1 pmullw xmm1, xmm6 paddw xmm0, xmm1 movdqa xmm1,xmm7 paddw xmm0, [h264_d0x20_sse2] psrlw xmm0, 6 WELS_Zero xmm7 packuswb xmm0, xmm7 movq [r2], xmm0 movdqa xmm0, xmm2 lea r2, [r2 + r3] lea r4, [r4 + r1] dec r5 jnz near .xloop POP_XMM LOAD_6_PARA_POP ret ;*********************************************************************** ; void McChromaWidthEq8_ssse3( const uint8_t *pSrc, ; int32_t iSrcStride, ; uint8_t *pDst, ; int32_t iDstStride, ; const uint8_t *pABCD, ; int32_t iHeigh); ;*********************************************************************** WELS_EXTERN McChromaWidthEq8_ssse3 %assign push_num 0 LOAD_6_PARA PUSH_XMM 8 SIGN_EXTENSION r1, r1d SIGN_EXTENSION r3, r3d SIGN_EXTENSION r5, r5d pxor xmm7, xmm7 movd xmm5, [r4] punpcklwd xmm5, xmm5 punpckldq xmm5, xmm5 movdqa xmm6, xmm5 punpcklqdq xmm5, xmm5 punpckhqdq xmm6, xmm6 sub r2, r3 ;sub esi, edi sub r2, r3 movdqa xmm7, [h264_d0x20_sse2] movdqu xmm0, [r0] movdqa xmm1, xmm0 psrldq xmm1, 1 punpcklbw xmm0, xmm1 .hloop_chroma: lea r2, [r2+2*r3] movdqu xmm2, [r0+r1] movdqa xmm3, xmm2 psrldq xmm3, 1 punpcklbw xmm2, xmm3 movdqa xmm4, xmm2 pmaddubsw xmm0, xmm5 pmaddubsw xmm2, xmm6 paddw xmm0, xmm2 paddw xmm0, xmm7 psrlw xmm0, 6 packuswb xmm0, xmm0 movq [r2],xmm0 lea r0, [r0+2*r1] movdqu xmm2, [r0] movdqa xmm3, xmm2 psrldq xmm3, 1 punpcklbw xmm2, xmm3 movdqa xmm0, xmm2 pmaddubsw xmm4, xmm5 pmaddubsw xmm2, xmm6 paddw xmm4, xmm2 paddw xmm4, xmm7 psrlw xmm4, 6 packuswb xmm4, xmm4 movq [r2+r3],xmm4 sub r5, 2 jnz .hloop_chroma POP_XMM LOAD_6_PARA_POP ret
; Ellipse Workstation 1100 (fictitious computer) ; Ellipse DOS file I/O functionality ; ; Copyright (c) 2020 Sampo Hippelรคinen (hisahi) ; ; 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. ; ; Written for the WLA-DX assembler ; DOSREADFILECHAR: LDA DOSLD|DOSACTIVEHANDLE.L BEQ + CMP #$0001 BNE @FILE JMP DOSREADCONCHAR + LDA #$FFFF RTS @FILE STP;TODO DOSREADFILELINE: LDA DOSLD|DOSACTIVEHANDLE.L BEQ + CMP #$0001 BNE ++ JMP DOSREADCONLINE + LDY #0 RTS ++ PHX TYA DEC A STA DOSLD|DOSTMP1.L LDY #0 - JSR DOSREADFILECHAR@FILE.W BEQ @CR ACC8 CMP #$08 BEQ @BKSP PHA TYA CMP DOSLD|DOSTMP1.L BEQ + BCS @BUFEND + PLA STA $0000.W,X JSL TEXT_WRCHR.L CMP #$0D BEQ @CR ACC16 INX INY TYA BRA - @CR PLX RTS @BKSP CPX #0 BEQ - DEX DEY BRA - @BUFEND .ACCU 8 PLA CMP #$0D BEQ @CR BRA - .ACCU 16 DOSWRITEFILECHAR: PHA LDA DOSLD|DOSACTIVEHANDLE.L BEQ + CMP #$0001 BNE ++ PLA JMP DOSWRITECONCHAR + RTS ++ PLA @FILE STP ;TODO DOSWRITEFILESTR: LDA DOSLD|DOSACTIVEHANDLE.L BEQ + CMP #$0001 BNE ++ JMP DOSWRITECONSTR + RTS ++ LDA $0000.W,X CMP DOSLD|DOSFILESTRTERM.L BEQ + PHX JSR DOSWRITEFILECHAR@FILE.W PLX INX JMP DOSWRITECONSTR + RTS